diff --git a/editor/js/Editor.js b/editor/js/Editor.js index 2cd5ea313250ba..170b84e5724669 100644 --- a/editor/js/Editor.js +++ b/editor/js/Editor.js @@ -399,6 +399,8 @@ Editor.prototype = { } else if ( object.isDirectionalLight ) { helper = new THREE.DirectionalLightHelper( object, 1 ); + + object.helper = helper; } else if ( object.isSpotLight ) { diff --git a/editor/js/Menubar.Add.js b/editor/js/Menubar.Add.js index dd6c319602a82f..4840d51eec5bb6 100644 --- a/editor/js/Menubar.Add.js +++ b/editor/js/Menubar.Add.js @@ -381,6 +381,13 @@ function MenubarAdd( editor ) { editor.execute( new AddObjectCommand( editor, light ) ); + const lightTarget = new THREE.Object3D(); + lightTarget.name = 'DirectionalLight Target'; + editor.execute( new AddObjectCommand( editor, lightTarget ) ); + + light.target = lightTarget; + lightTarget.userData[ 'fatherLightUUID' ] = light.uuid; + } ); lightSubmenu.add( option ); diff --git a/editor/js/Sidebar.Object.js b/editor/js/Sidebar.Object.js index 18f4469133c3c3..939b8089c1c643 100644 --- a/editor/js/Sidebar.Object.js +++ b/editor/js/Sidebar.Object.js @@ -870,6 +870,14 @@ function SidebarObject( editor ) { } + if ( object.userData[ 'fatherLightUUID' ] ) { + + const fatherLight = editor.objectByUuid( object.userData[ 'fatherLightUUID' ] ); + fatherLight.helper.update(); + signals.sceneGraphChanged.dispatch(); + + } + objectVisible.setValue( object.visible ); objectFrustumCulled.setValue( object.frustumCulled ); objectRenderOrder.setValue( object.renderOrder );