LCCObject::setRenderState
Sets the RenderState of the LCC model.
Includes depth testing, depth writing, render pass, and other parameters.
Version Requirement
SDK v0.4.0+
Engine Support
CesiumJS
API
LCCObject::setRenderState(renderState: RenderStateParam): void
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
renderState.depthTest | Object | No | - | Depth test configuration. |
renderState.depthTest.enabled | boolean | No | true | Whether to enable depth testing. |
renderState.depthTest.func | number | No | - | Depth test function, e.g., Cesium.WebGLConstants.ALWAYS. |
renderState.depthMask | boolean | No | true | Whether to write to the depth buffer. |
renderState.passIndex | number | No | Cesium.Pass.CESIUM_3D_TILE | Cesium render pass. |
renderState.stencilTest | Object | No | - | Stencil test configuration. SDK v0.5.0+ |
Return Value
void
Usage Example
Recommended Depth Test Configuration (SDK v0.4.0+)
The LCC model writes to the depth buffer and renders in a higher-priority pass. When subsequent Cesium objects have depth testing enabled, correct occlusion relationships are achieved.
const renderState = {
depthTest: {
enabled: true,
func: Cesium.WebGLConstants.ALWAYS,
},
depthMask: true,
passIndex: Cesium.Pass.CESIUM_3D_TILE
};
lccObject.setRenderState(renderState);
Translucent Object Pass (SDK v0.4.0+)
When using Pass.TRANSLUCENT, occlusion relationships between objects depend on Cesium's sorting of all transparent objects in the scene, based on the distance from the camera to the scene bounding box. In this mode, occlusion results may not match the expectations from raiseToTop() or lowerToBottom().
const renderState = {
depthTest: {
enabled: true,
func: Cesium.WebGLConstants.LESS,
},
depthMask: false,
passIndex: Cesium.Pass.TRANSLUCENT
};
lccObject.setRenderState(renderState);
Using Stencil Test (SDK v0.5.0+)
const renderState = {
depthTest: {
enabled: true,
func: Cesium.WebGLConstants.ALWAYS,
},
depthMask: true,
passIndex: Cesium.Pass.CESIUM_3D_TILE,
stencilTest: Cesium.StencilConstants.setCesium3DTileBit()
};
lccObject.setRenderState(renderState);
Notes
- This method can be called synchronously immediately after
LCCRender.load(). - Versions v0.4.0 and v0.4.1 only support
depthTest,depthMask, andpassIndexparameters. - v0.5.0+ supports all RenderState parameters and merges them with existing settings.
- When using
depthMask: false, depth writing is disabled, and occlusion relationships between the LCC model and other transparent objects depend on Cesium's sorting results.
Related APIs
LCCObject::lowerToBottom()LCCObject::raiseToTop()