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 with frustum culling
layerThe layer used by this mesh instance.
maskMask controlling which pc.LightComponents light this mesh instance.
materialThe material used by this mesh instance.
renderStyleThe render style of the mesh instance.
visibleEnable rendering for this mesh instance.

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 with frustum culling

Numberlayer

The layer used by this mesh instance. Layers define drawing order. Can be:

  • pc.LAYER_WORLD or 15
  • pc.LAYER_FX or 2
  • pc.LAYER_GIZMO or 1
  • pc.LAYER_HUD or 0
  • Any number between 3 and 14 can be used as a custom layer.
Defaults to pc.LAYER_WORLD.

Numbermask

Mask controlling which pc.LightComponents light this mesh instance. To ignore all dynamic lights, set mask to 0. 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.