|
@@ -49,13 +49,6 @@ var Viewport = function ( signals ) {
|
|
|
|
|
|
//
|
|
|
|
|
|
- var lightGeo = new THREE.SphereGeometry( 5, 16, 8 );
|
|
|
- var targetGeo = new THREE.SphereGeometry( 5, 8, 4 );
|
|
|
-
|
|
|
- var direction = new THREE.Vector3();
|
|
|
-
|
|
|
- //
|
|
|
-
|
|
|
var scene = new THREE.Scene();
|
|
|
|
|
|
var camera = new THREE.PerspectiveCamera( 50, 1, 1, 5000 );
|
|
@@ -315,53 +308,16 @@ var Viewport = function ( signals ) {
|
|
|
|
|
|
if ( object instanceof THREE.DirectionalLight ) {
|
|
|
|
|
|
- var lightGizmo = new THREE.Object3D();
|
|
|
- lightGizmo.position = object.position;
|
|
|
- lightGizmo.properties.isGizmo = true;
|
|
|
-
|
|
|
- var lightColor = object.color.clone();
|
|
|
- lightColor.r *= object.intensity;
|
|
|
- lightColor.g *= object.intensity;
|
|
|
- lightColor.b *= object.intensity;
|
|
|
-
|
|
|
- var length = 30;
|
|
|
- direction.sub( object.target.position, object.position );
|
|
|
-
|
|
|
- var lightArrow = new THREE.ArrowHelper( direction, null, length, lightColor.getHex() );
|
|
|
-
|
|
|
- var lightMaterial = new THREE.MeshBasicMaterial( { color: lightColor.getHex() } );
|
|
|
- var lightSphere = new THREE.Mesh( lightGeo, lightMaterial );
|
|
|
-
|
|
|
- lightGizmo.add( lightArrow );
|
|
|
- lightGizmo.add( lightSphere );
|
|
|
-
|
|
|
+ var lightGizmo = new THREE.DirectionalLightHelper( object, 30 );
|
|
|
sceneHelpers.add( lightGizmo );
|
|
|
+ sceneHelpers.add( lightGizmo.targetSphere );
|
|
|
|
|
|
- object.properties.arrow = lightArrow;
|
|
|
- object.properties.pickingProxy = lightSphere;
|
|
|
-
|
|
|
- if ( object.target.properties.targetInverse ) {
|
|
|
-
|
|
|
- var targetMaterial = new THREE.MeshBasicMaterial( { color: lightColor.getHex(), wireframe: true } );
|
|
|
+ object.properties.helper = lightGizmo;
|
|
|
+ object.properties.pickingProxy = lightGizmo.lightSphere;
|
|
|
+ object.target.properties.pickingProxy = lightGizmo.targetSphere;
|
|
|
|
|
|
- var targetSphere = new THREE.Mesh( targetGeo, targetMaterial );
|
|
|
- targetSphere.position = object.target.position;
|
|
|
-
|
|
|
- sceneHelpers.add( targetSphere );
|
|
|
-
|
|
|
- targetSphere.properties.isGizmo = true;
|
|
|
- targetSphere.properties.gizmoSubject = object.target;
|
|
|
- targetSphere.properties.gizmoRoot = targetSphere;
|
|
|
- objects.push( targetSphere );
|
|
|
-
|
|
|
- object.target.properties.pickingProxy = targetSphere;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- lightSphere.properties.isGizmo = true;
|
|
|
- lightSphere.properties.gizmoSubject = object;
|
|
|
- lightSphere.properties.gizmoRoot = lightGizmo;
|
|
|
- objects.push( lightSphere );
|
|
|
+ objects.push( lightGizmo.lightSphere );
|
|
|
+ objects.push( lightGizmo.targetSphere );
|
|
|
|
|
|
} else if ( object instanceof THREE.PointLight ) {
|
|
|
} else if ( object instanceof THREE.SpotLight ) {
|
|
@@ -392,32 +348,14 @@ var Viewport = function ( signals ) {
|
|
|
|
|
|
} else if ( object instanceof THREE.DirectionalLight ) {
|
|
|
|
|
|
- // set gizmo arrow orientation
|
|
|
- // pointing from light to target
|
|
|
-
|
|
|
- direction.sub( object.target.position, object.position );
|
|
|
- object.properties.arrow.setDirection( direction );
|
|
|
-
|
|
|
- // set gizmo color to light color * light intensity
|
|
|
-
|
|
|
- var lightColor = object.properties.pickingProxy.material.color;
|
|
|
- lightColor.copy( object.color );
|
|
|
-
|
|
|
- var intensity = THREE.Math.clamp( object.intensity, 0, 1 );
|
|
|
- lightColor.r *= intensity;
|
|
|
- lightColor.g *= intensity;
|
|
|
- lightColor.b *= intensity;
|
|
|
-
|
|
|
- object.properties.arrow.setColor( lightColor.getHex() );
|
|
|
- object.target.properties.pickingProxy.material.color.copy( lightColor );
|
|
|
+ object.properties.helper.update();
|
|
|
|
|
|
} else if ( object instanceof THREE.PointLight ) {
|
|
|
} else if ( object instanceof THREE.SpotLight ) {
|
|
|
} else if ( object instanceof THREE.HemisphereLight ) {
|
|
|
} else if ( object.properties.targetInverse ) {
|
|
|
|
|
|
- direction.sub( object.position, object.properties.targetInverse.position );
|
|
|
- object.properties.targetInverse.properties.arrow.setDirection( direction );
|
|
|
+ object.properties.targetInverse.properties.helper.update();
|
|
|
|
|
|
}
|
|
|
|