API Reference

Class List

pc.MeshInstance

An instance of a pc.Mesh. A single mesh can be referenced by many mesh instances that can have different transforms and materials.

// Create a mesh instance pointing to a 1x1x1 'cube' mesh
var mesh = pc.createBox(graphicsDevice);
var material = new pc.StandardMaterial();
var node = new pc.GraphNode();
var meshInstance = new pc.MeshInstance(node, mesh, material);

Summary

Properties

aabbThe world space axis-aligned bounding box for this mesh instance.
castShadowControls whether the mesh instance casts shadows.
cullControls whether the mesh instance can be culled by with frustum culling (pc.CameraComponent#frustumCulling).
drawOrderUse this value to affect rendering order of mesh instances.
maskMask controlling which pc.LightComponents light this mesh instance, which pc.CameraComponent sees it and in which pc.Layer it is rendered.
materialThe material used by this mesh instance.
renderStyleThe render style of the mesh instance.
visibleEnable rendering for this mesh instance.
visibleThisFrameRead this value in pc.Layer#onPostCull to determine if the object is actually going to be rendered.

Details

Constructor

MeshInstance(node, mesh, material)

Create a new mesh instance.

// Create a mesh instance pointing to a 1x1x1 'cube' mesh
var mesh = pc.createBox(graphicsDevice);
var material = new pc.StandardMaterial();
var node = new pc.GraphNode();
var meshInstance = new pc.MeshInstance(node, mesh, material);

Parameters

nodepc.GraphNodeThe graph node defining the transform for this instance.
meshpc.MeshThe graphics mesh being instanced.
materialpc.MaterialThe material used to render this instance.

Properties

pc.BoundingBoxaabb

The world space axis-aligned bounding box for this mesh instance.

BooleancastShadow

Controls whether the mesh instance casts shadows. Defaults to false.

Booleancull

Controls whether the mesh instance can be culled by with frustum culling (pc.CameraComponent#frustumCulling).

NumberdrawOrder

Use this value to affect rendering order of mesh instances. Only used when mesh instances are added to a pc.Layer with pc.Layer#opaqueSortMode or pc.Layer#transparentSortMode (depending on the material) set to pc.SORTMODE_MANUAL.

Numbermask

Mask controlling which pc.LightComponents light this mesh instance, which pc.CameraComponent sees it and in which pc.Layer it is rendered. Defaults to 1.

pc.Materialmaterial

The material used by this mesh instance.

NumberrenderStyle

The render style of the mesh instance. Can be:

  • pc.RENDERSTYLE_SOLID
  • pc.RENDERSTYLE_WIREFRAME
  • pc.RENDERSTYLE_POINTS
Defaults to pc.RENDERSTYLE_SOLID.

Booleanvisible

Enable rendering for this mesh instance. Use visible property to enable/disable rendering without overhead of removing from scene. But note that the mesh instance is still in the hierarchy and still in the draw call list.

BooleanvisibleThisFrame

Read this value in pc.Layer#onPostCull to determine if the object is actually going to be rendered.