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)Clone functin of the pawn object.
createSolidCube(color)Create a solid cube in given color.
createTexturedQuad(images)Create a textured cube in given color.
destroy()Destroy the pawn.
getSkeletons()Get the skeletons of the loaded pawn. Every pawn can have multiple skeletons and every skeleton can have multiple animations (call skeleton.getAnimations() to get them).
load(modelId)Load the model with model ID.
loadGltfModel(url)Load gltf 2.0 file to the pawn. Currently, we only support gltf 2.0 file without embedded resource.
setDiffuseColor(color)Set the diffuse color of the pawn.

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);
}