diff --git a/examples/jsm/csm/CSMShadowNode.js b/examples/jsm/csm/CSMShadowNode.js index af63c5ad357b0d..9eb2e0c6c9a9bc 100644 --- a/examples/jsm/csm/CSMShadowNode.js +++ b/examples/jsm/csm/CSMShadowNode.js @@ -163,7 +163,6 @@ class CSMShadowNode extends ShadowBaseNode { this.mainFrustum = new CSMFrustum( data ); const light = this.light; - const parent = light.parent; for ( let i = 0; i < this.cascades; i ++ ) { @@ -175,9 +174,6 @@ class CSMShadowNode extends ShadowBaseNode { this.lights.push( lwLight ); - parent.add( lwLight ); - parent.add( lwLight.target ); - lwLight.shadow = lShadow; this._shadowNodes.push( shadow( lwLight, lShadow ) ); @@ -503,9 +499,26 @@ class CSMShadowNode extends ShadowBaseNode { updateBefore( /*builder*/ ) { const light = this.light; + const parent = light.parent; const camera = this.camera; const frustums = this.frustums; + // make sure the placeholder light objects which represent the + // multiple cascade shadow casters are part of the scene graph + + for ( let i = 0; i < this.lights.length; i ++ ) { + + const lwLight = this.lights[ i ]; + + if ( lwLight.parent === null ) { + + parent.add( lwLight.target ); + parent.add( lwLight ); + + } + + } + _lightDirection.subVectors( light.target.position, light.position ).normalize(); // for each frustum we need to find its min-max box aligned with the light orientation diff --git a/examples/webgpu_shadowmap_csm.html b/examples/webgpu_shadowmap_csm.html index af36471c8ea951..66c02e14ac8d14 100644 --- a/examples/webgpu_shadowmap_csm.html +++ b/examples/webgpu_shadowmap_csm.html @@ -177,7 +177,7 @@ gui.add( params, 'shadows' ).onChange( function ( value ) { - renderer.shadowMap.enabled = value; + csmDirectionalLight.castShadow = value; } ); diff --git a/src/nodes/lighting/ShadowBaseNode.js b/src/nodes/lighting/ShadowBaseNode.js index 67a5cc1cd96aed..dc1db209d8f5fa 100644 --- a/src/nodes/lighting/ShadowBaseNode.js +++ b/src/nodes/lighting/ShadowBaseNode.js @@ -68,17 +68,6 @@ class ShadowBaseNode extends Node { } - /** - * Can be called when the shadow isn't required anymore. That can happen when - * a lighting node stops casting shadows by setting {@link Object3D#castShadow} - * to `false`. - */ - dispose() { - - this.updateBeforeType = NodeUpdateType.NONE; - - } - } /**