diff --git a/editor/js/ui/Menubar.Add.js b/editor/js/ui/Menubar.Add.js index 327995204836ea83eb973d5c04bf20f0781ec298..d81f4a76309a7e5e06b1a5e815d8c7e27304e674 100644 --- a/editor/js/ui/Menubar.Add.js +++ b/editor/js/ui/Menubar.Add.js @@ -160,7 +160,7 @@ Menubar.Add = function ( signals ) { } ); options.add( option ); - // add torus + // add torus knot var option = new UI.Panel(); option.setClass( 'option' ); @@ -224,9 +224,7 @@ Menubar.Add = function ( signals ) { var light = new THREE.SpotLight( color, intensity, distance, angle, exponent ); light.name = 'SpotLight ' + light.id; - light.target.name = 'SpotLight ' + light.id + ' target'; - - light.target.userData.targetInverse = light; + light.target.name = 'SpotLight ' + light.id + ' Target'; light.position.set( 0, 1, 0 ).multiplyScalar( 200 ); @@ -247,9 +245,7 @@ Menubar.Add = function ( signals ) { var light = new THREE.DirectionalLight( color, intensity ); light.name = 'DirectionalLight ' + light.id; - light.target.name = 'DirectionalLight ' + light.id + ' target'; - - light.target.userData.targetInverse = light; + light.target.name = 'DirectionalLight ' + light.id + ' Target'; light.position.set( 1, 1, 1 ).multiplyScalar( 200 ); diff --git a/editor/js/ui/Viewport.js b/editor/js/ui/Viewport.js index 9320f82e2897516dad39842705a3d99d355cd4e7..3487c589e52bb8129f378f390e12d0e573368c57 100644 --- a/editor/js/ui/Viewport.js +++ b/editor/js/ui/Viewport.js @@ -361,7 +361,7 @@ var Viewport = function ( signals ) { var helper = objectsToHelpers[ selected.id ]; - objects.splice( objects.indexOf( helper ), 1 ); + objects.splice( objects.indexOf( helper.lightSphere ), 1 ); helper.parent.remove( helper ); selected.parent.remove( selected ); @@ -371,6 +371,13 @@ var Viewport = function ( signals ) { updateMaterials( scene ); + if ( selected instanceof THREE.DirectionalLight || + selected instanceof THREE.SpotLight ) { + + selected.target.parent.remove( selected.target ); + + } + } else { selected.traverse( function ( object ) { @@ -389,6 +396,7 @@ var Viewport = function ( signals ) { } + signals.sceneChanged.dispatch( scene ); signals.objectSelected.dispatch( null ); } ); diff --git a/src/extras/helpers/DirectionalLightHelper.js b/src/extras/helpers/DirectionalLightHelper.js index b0511518f0b77816697dde7f6bf33163b6f61f91..5d8d1de87c654c144fb33f06e4d0acef4913e0fa 100644 --- a/src/extras/helpers/DirectionalLightHelper.js +++ b/src/extras/helpers/DirectionalLightHelper.js @@ -20,8 +20,8 @@ THREE.DirectionalLightHelper = function ( light, sphereSize ) { this.add( this.lightSphere ); var lineGeometry = new THREE.Geometry(); - lineGeometry.vertices.push( this.light.position.clone() ); - lineGeometry.vertices.push( new THREE.Vector3() ); + lineGeometry.vertices.push( this.light.position ); + lineGeometry.vertices.push( this.light.target.position ); lineGeometry.computeLineDistances(); var lineMaterial = new THREE.LineDashedMaterial( { dashSize: 4, gapSize: 4, opacity: 0.75, transparent: true, fog: false } ); @@ -52,7 +52,6 @@ THREE.DirectionalLightHelper.prototype.update = function () { this.lightSphere.position.copy( this.light.position ); this.lightSphere.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity ); - this.targetLine.geometry.vertices[ 0 ].copy( this.light.position ); this.targetLine.geometry.computeLineDistances(); this.targetLine.geometry.verticesNeedUpdate = true; this.targetLine.material.color.copy( this.lightSphere.material.color );