File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,9 @@ export var Component = registerComponent('light', {
199199 if ( newLight ) {
200200 if ( this . light ) {
201201 el . removeObject3D ( 'light' ) ;
202+ if ( el . getObject3D ( 'cameraHelper' ) ) {
203+ el . removeObject3D ( 'cameraHelper' ) ;
204+ }
202205 }
203206
204207 this . light = newLight ;
@@ -232,18 +235,20 @@ export var Component = registerComponent('light', {
232235 var data = this . data ;
233236 var light = this . light ;
234237
235- light . castShadow = data . castShadow ;
238+ // Cast shadows if enabled and light type supports shadows.
239+ light . castShadow = data . castShadow && light . shadow ;
236240
237241 // Shadow camera helper.
238242 var cameraHelper = el . getObject3D ( 'cameraHelper' ) ;
239- if ( data . shadowCameraVisible && ! cameraHelper ) {
243+ var shadowCameraVisible = data . shadowCameraVisible && light . shadow ;
244+ if ( shadowCameraVisible && ! cameraHelper ) {
240245 cameraHelper = new THREE . CameraHelper ( light . shadow . camera ) ;
241246 el . setObject3D ( 'cameraHelper' , cameraHelper ) ;
242- } else if ( ! data . shadowCameraVisible && cameraHelper ) {
247+ } else if ( ! shadowCameraVisible && cameraHelper ) {
243248 el . removeObject3D ( 'cameraHelper' ) ;
244249 }
245250
246- if ( ! data . castShadow ) { return light ; }
251+ if ( ! light . castShadow ) { return light ; }
247252
248253 // Shadow appearance.
249254 light . shadow . bias = data . shadowBias ;
You can’t perform that action at this time.
0 commit comments