123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * @author alteredq / http://alteredqualia.com/
- * @author mrdoob / http://mrdoob.com/
- */
- THREE.DirectionalLightHelper = function ( light, size ) {
- THREE.Object3D.call( this );
- this.light = light;
- this.light.updateMatrixWorld();
- this.matrixWorld = light.matrixWorld;
- this.matrixAutoUpdate = false;
- var geometry = new THREE.PlaneGeometry( size, size );
- var material = new THREE.MeshBasicMaterial( { wireframe: true, fog: false } );
- material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
- this.lightPlane = new THREE.Mesh( geometry, material );
- this.add( this.lightPlane );
- geometry = new THREE.Geometry();
- geometry.vertices.push( new THREE.Vector3() );
- geometry.vertices.push( new THREE.Vector3() );
- geometry.computeLineDistances();
- material = new THREE.LineBasicMaterial( { fog: false } );
- material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
- this.targetLine = new THREE.Line( geometry, material );
- this.add( this.targetLine );
- this.update();
- };
- THREE.DirectionalLightHelper.prototype = Object.create( THREE.Object3D.prototype );
- THREE.DirectionalLightHelper.prototype.dispose = function () {
-
- this.lightPlane.geometry.dispose();
- this.lightPlane.material.dispose();
- this.targetLine.geometry.dispose();
- this.targetLine.material.dispose();
- };
- THREE.DirectionalLightHelper.prototype.update = function () {
- var vector = new THREE.Vector3();
- return function () {
- vector.getPositionFromMatrix( this.light.matrixWorld ).negate();
- this.lightPlane.lookAt( vector );
- this.lightPlane.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
- this.targetLine.geometry.vertices[ 1 ].copy( vector );
- this.targetLine.geometry.verticesNeedUpdate = true;
- this.targetLine.material.color.copy( this.lightPlane.material.color );
- }
- }();
|