Skip to Content
🎉 @playcanvas/react 0.3.0! Now with React 19 support. Read more →

Render

Usage

Rendering an Asset

To render a 3D model loaded from a URL, you can use the asset type and pass the asset directly to the asset prop.

import { Render } from '@playcanvas/react/components' <Entity> <Render type="asset" asset={asset} /> </Entity>

Rendering a primitive shape

This will render a simple box primitive transformed by the parent entity.

import { Render } from '@playcanvas/react/components' Entity> <Render type="box" /> </Entity>

Props

The following props are based on the Render Component from PlayCanvas version 2.3.3. This documentation is automatically generated from the TypeScript types of the installed PlayCanvas package.

NameTypeDefault
type"asset" | "box" | "capsule" | "cone" | "cylinder" | "plane" | "sphere" | "torus"

The type of primitive shape to render.

"box"
assetAsset

The asset to render.

childrenReactNode
isStaticboolean

Mark meshes as non-movable (optimization).

renderStylenumber

Sets the render style of this component’s MeshInstances. Can be:

  • RENDERSTYLE_SOLID
  • RENDERSTYLE_WIREFRAME
  • RENDERSTYLE_POINTS

Defaults to RENDERSTYLE_SOLID. Gets the render style of this component’s MeshInstances.

customAabbBoundingBox

Sets the custom object space bounding box that is used for visibility culling of attached mesh instances. This is an optimization, allowing an oversized bounding box to be specified for skinned characters in order to avoid per frame bounding box computations based on bone positions. Gets the custom object space bounding box that is used for visibility culling of attached mesh instances.

meshInstancesMeshInstance[]

Sets the array of meshInstances contained in the component. Gets the array of meshInstances contained in the component.

lightmappedboolean

Sets whether the component is affected by the runtime lightmapper. If true, the meshes will be lightmapped after using lightmapper.bake(). Gets whether the component is affected by the runtime lightmapper.

castShadowsboolean

Sets whether attached meshes will cast shadows for lights that have shadow casting enabled. Gets whether attached meshes will cast shadows for lights that have shadow casting enabled.

receiveShadowsboolean

Sets whether shadows will be cast on attached meshes. Gets whether shadows will be cast on attached meshes.

castShadowsLightmapboolean

Sets whether meshes instances will cast shadows when rendering lightmaps. Gets whether meshes instances will cast shadows when rendering lightmaps.

lightmapSizeMultipliernumber

Sets the lightmap resolution multiplier. Gets the lightmap resolution multiplier.

layersnumber[]

Sets the array of layer IDs (Layer#id ) to which the mesh instances belong. Don’t push, pop, splice or modify this array. If you want to change it, set a new one instead. Gets the array of layer IDs (Layer#id ) to which the mesh instances belong.

batchGroupIdnumber

Sets the batch group for the mesh instances in this component (see BatchGroup). Default is -1 (no group). Gets the batch group for the mesh instances in this component (see BatchGroup).

materialMaterial

Sets the material Material that will be used to render the component. The material is ignored for renders of type ‘asset’. Gets the material Material that will be used to render the component.

materialAssetsnumber[] | Asset[]

Sets the material assets that will be used to render the component. Each material corresponds to the respective mesh instance. Gets the material assets that will be used to render the component.

materialAssetany
rootBoneany
systemComponentSystem

The ComponentSystem used to create this Component.

entityEntity

The Entity that this Component is attached to.

enabledboolean

Sets the enabled state of the component. Gets the enabled state of the component.

Last updated on