Class: ModelInstance

ModelInstance

ModelInstance is a scene graph node that contains Model geometry and a Material to use for rendering. It allows reusing geometry multiple times in the scene.

ModelInstance creates a matching MeshInstance for each Mesh in the Model, in which the Mesh is linked with its Material.


new ModelInstance(model, materials)

Parameters:
Name Type Description
model

The Model to use as the geometry

materials

Either a single Material to link to all Meshes in the Model, or an array of materials to link to the meshes in respective order.

Properties:
Name Type Description
model Model

The model to use as the geometry

castShadows boolean

Defines whether or not this ModelInstance should cast shadows.

numMeshInstances number

The amount of MeshInstance objects.

skeleton Skeleton

The skeleton used for skinning animations.

skeletonPose SkeletonPose

The SkeletonPose object defining the current local skeleton state.

morphPose MorphPose

The MorphPose object defining the current morph target state.

Author:
  • derschmale <http://www.derschmale.com>

Extends

Methods


addComponent()

Adds a single Component object to the Entity.

Inherited From:

addComponents(components)

Adds multiple Component objects to the Entity.

Parameters:
Name Type Description
components Array

An array of components to add.

Inherited From:

assignMaterial()

Forces all MeshInstances in the ModelInstance to use the material.


destroy()

Inherited From:

getComponentsByType()

Returns an array of all Components with a given type.

Inherited From:

getMeshInstance()

Gets the MeshInstance at the given index.


hasComponentType()

Returns whether or not the Entity has a component of a given type assigned to it.

Inherited From:

init(model, materials)

Init allows us to leave the constructor empty and initialize the model lazily.

Parameters:
Name Type Description
model

The Model to use as the geometry

materials

Either a single Material to link to all Meshes in the Model, or an array of materials to link to the meshes in respective order.


removeComponent()

Removes a single Component from the Entity.

Inherited From:

removeComponents(components)

Removes multiple Component objects from the Entity.

Parameters:
Name Type Description
components Array

A list of components to remove.

Inherited From: