Integrate Caustics with frontend frameworks
mainWhen using frontend frameworks (like React), standard construction might not handle lifecycle changes or prop updates correctly. Use these exported symbols to bridge the integration:
CausticsProjectionMaterial: A material that projects the caustics onto the catcher plane.CausticsMaterial: A material that renders the caustics.createCausticsUpdate: A function that accepts anupdateParametersgetter to create anupdatefunction for your animation loop. This ensures the effect uses the latest state from your framework.
export function createCausticsUpdate(
updateParameters: () => {
params: Omit<CausticsProps, 'color'>
scene: THREE.Scene
group: THREE.Group
camera: THREE.OrthographicCamera
plane: THREE.Mesh<PlaneGeometry, InstanceInstance<typeof CausticsProjectionMaterial>>
normalTarget: THREE.WebGLRenderTarget
normalTargetB: THREE.WebGLRenderTarget
causticsTarget: THREE.WebGLRenderTarget
causticsTargetB: THREE.WebGLRenderTarget
helper?: THREE.CameraHelper | null
}
): (gl: THREE.WebGLRenderer) => void