function.modifyRenderState
API > modifyRenderState
Function: modifyRenderState
modifyRenderState(
state
,changes
):RenderState
Create a new copy of render state with specified modifications.
Parameters
Parameter | Type | Description |
---|---|---|
state | RenderState | The baseline render state. |
changes | RecursivePartial \< RenderState > | The changes to apply to the baseline state. |
Returns
A new render state with all the changes applied.
Source
@novorender/core3d/state/modify.ts:22
Remarks
This function helps you modify render state in an immutable fashion, which is key for correct and efficient render updates. More specifically, it leaves all the unchanged sub objects of the returned render state alone. This enables checking for changes using strict equality. Making unnecessary copies of unchanged sub objects will reduce render/update performance.
This function also performs some basic validation of the new state changes, at a slight performance cost.
If validation fails, it will throw an error of Error
objects, one per problem.
To mitigate this overhead, accumulating all the changes for a frame into a single object may be beneficial.
The mergeRecursive function may be useful in for this.