Home > @modelo.io/api > Pawn

Pawn class

Pawn is a small object that can be inserted into scene dynamically.

Signature:

export default class Pawn extends Entity 

Constructors

ConstructorDescription
(constructor)(name, resourceManager, materialManager)Construct a pawn object.

Methods

MethodDescription
clone(name)
createSolidCube(color)Create a solid cube in given color.
createTexturedQuad(images)Create a textured cube in given color.
destroy()Destroy the pawn.
load(modelId)Load the model with model ID.
setDiffuseColor(color)

Example 1

var pawn1 = new Modelo.Scene3D.Pawn("pawn1", viewer.getResourceManager(), viewer.getMaterialManager());
pawn1.createSolidCube();
pawn1.setScaling(40, 40, 1.0);
viewer.getScene().addPawn(pawn1);

Example 2

var image1 = new Image();
image1.src = "/chessboard.jpg";
image1.onload = function() {
   var pawn2 = new Modelo.Scene3D.Pawn("pawn2", viewer.getResourceManager(), viewer.getMaterialManager());
   pawn2.createTexturedQuad([image1]);
   pawn2.setScaling(40, 40, 1.0);
   pawn2.setTranslation(0, 0, 1.01);
   viewer.getScene().addPawn(pawn2);
}