提交 943443de 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #11515 from looeee/lighthelper_colours

Added overrideColor parameter to LightHelpers
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<base href="../../" /> <base href="../../" />
<script src="list.js"></script> <script src="list.js"></script>
<script src="page.js"></script> <script src="page.js"></script>
...@@ -32,10 +32,13 @@ ...@@ -32,10 +32,13 @@
<h2>Constructor</h2> <h2>Constructor</h2>
<h3>[name]( [page:DirectionalLight light], [page:Number size] )</h3> <h3>[name]( [page:DirectionalLight light], [page:Number size], [page:Hex color] )</h3>
<div> <div>
[page:DirectionalLight light]-- The light to be visualized. <br /> [page:DirectionalLight light]-- The light to be visualized. <br /><br />
[page:Number size] -- (optional) dimensions of the plane. Default is *1*.<br /><br />
[page:Number size] -- (optional) dimensions of the plane. Default is *1*.<br /><br />
[page:Hex color] -- (optional) if this is not the set the helper will take the color of the light.
</div> </div>
...@@ -58,6 +61,11 @@ ...@@ -58,6 +61,11 @@
light's [page:Object3D.matrixWorld matrixWorld]. light's [page:Object3D.matrixWorld matrixWorld].
</div> </div>
<h3>[property:hex color]</h3>
<div>
The color parameter passed in the constructor. Default is *undefined*. If this is changed,
the helper's color will update the next time [page:.update update] is called.
</div>
<h2>Methods</h2> <h2>Methods</h2>
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<base href="../../" /> <base href="../../" />
<script src="list.js"></script> <script src="list.js"></script>
<script src="page.js"></script> <script src="page.js"></script>
...@@ -29,10 +29,13 @@ scene.add( helper ); ...@@ -29,10 +29,13 @@ scene.add( helper );
<h2>Constructor</h2> <h2>Constructor</h2>
<h3>[name]([page:HemisphereLight light], [page:Number sphereSize])</h3> <h3>[name]( [page:HemisphereLight light], [page:Number sphereSize], [page:Hex color] )</h3>
<div> <div>
[page:HemisphereLight light] -- The light being visualized. <br /> [page:HemisphereLight light] -- The light being visualized. <br /><br />
[page:Number size] -- The size of the mesh used to visualize the light.
[page:Number size] -- The size of the mesh used to visualize the light.<br /><br />
[page:Hex color] -- (optional) if this is not the set the helper will take the color of the light.
</div> </div>
...@@ -51,6 +54,12 @@ scene.add( helper ); ...@@ -51,6 +54,12 @@ scene.add( helper );
hemisphereLight's [page:Object3D.matrixWorld matrixWorld]. hemisphereLight's [page:Object3D.matrixWorld matrixWorld].
</div> </div>
<h3>[property:hex color]</h3>
<div>
The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update
the next time [page:.update update] is called.
</div>
<h2>Methods</h2> <h2>Methods</h2>
<div>See the base [page:Object3D] class for common methods.</div> <div>See the base [page:Object3D] class for common methods.</div>
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<base href="../../" /> <base href="../../" />
<script src="list.js"></script> <script src="list.js"></script>
<script src="page.js"></script> <script src="page.js"></script>
...@@ -37,12 +37,14 @@ ...@@ -37,12 +37,14 @@
<h2>Constructor</h2> <h2>Constructor</h2>
<h3>[name]( [page:PointLight light], [page:Float sphereSize] )</h3> <h3>[name]( [page:PointLight light], [page:Float sphereSize], [page:Hex color] )</h3>
<div> <div>
[page:PointLight light] -- The light to be visualized. <br /> [page:PointLight light] -- The light to be visualized. <br /><br />
[page:Float sphereSize] -- (optional) The size of the sphere helper. Default is *1*.
</div> [page:Float sphereSize] -- (optional) The size of the sphere helper. Default is *1*.<br /><br />
[page:Hex color] -- (optional) if this is not the set the helper will take the color of the light.
</div>
<h2>Properties</h2> <h2>Properties</h2>
<div>See the base [page:Mesh] class for common properties.</div> <div>See the base [page:Mesh] class for common properties.</div>
...@@ -59,7 +61,12 @@ ...@@ -59,7 +61,12 @@
pointLight's [page:Object3D.matrixWorld matrixWorld]. pointLight's [page:Object3D.matrixWorld matrixWorld].
</div> </div>
<h3>[property:hex color]</h3>
<div>
The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update
the next time [page:.update update] is called.
</div>
<h2>Methods</h2> <h2>Methods</h2>
<div>See the base [page:Mesh] class for common methods.</div> <div>See the base [page:Mesh] class for common methods.</div>
......
...@@ -29,8 +29,12 @@ scene.add( helper ); ...@@ -29,8 +29,12 @@ scene.add( helper );
<h2>Constructor</h2> <h2>Constructor</h2>
<h3>[name]( [page:RectAreaLight light] )</h3> <h3>[name]( [page:RectAreaLight light], [page:Hex color] )</h3>
<div>[page:RectAreaLight light] -- The light being visualized.</div> <div>
[page:RectAreaLight light] -- The light being visualized.<br /><br />
[page:Hex color] -- (optional) if this is not the set the helper will take the color of the light.
</div>
<h2>Properties</h2> <h2>Properties</h2>
...@@ -39,6 +43,12 @@ scene.add( helper ); ...@@ -39,6 +43,12 @@ scene.add( helper );
<h3>[property:RectAreaLight light]</h3> <h3>[property:RectAreaLight light]</h3>
<div>Reference to the RectAreaLight being visualized.</div> <div>Reference to the RectAreaLight being visualized.</div>
<h3>[property:hex color]</h3>
<div>
The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update
the next time [page:.update update] is called.
</div>
<h2>Methods</h2> <h2>Methods</h2>
<div>See the base [page:Object3D] class for common methods.</div> <div>See the base [page:Object3D] class for common methods.</div>
......
...@@ -35,8 +35,12 @@ ...@@ -35,8 +35,12 @@
<h2>Constructor</h2> <h2>Constructor</h2>
<h3>[name]([page:SpotLight light])</h3> <h3>[name]( [page:SpotLight light], [page:Hex color] )</h3>
<div>light -- The [page:SpotLight] to be visualized.</div> <div>
[page:SpotLight light] -- The [page:SpotLight] to be visualized. <br /><br/>
[page:Hex color] -- (optional) if this is not the set the helper will take the color of the light.
</div>
<h2>Properties</h2> <h2>Properties</h2>
...@@ -45,7 +49,6 @@ ...@@ -45,7 +49,6 @@
<h3>[property:LineSegments cone]</h3> <h3>[property:LineSegments cone]</h3>
<div>[page:LineSegments] used to visualize the light.</div> <div>[page:LineSegments] used to visualize the light.</div>
<h3>[property:SpotLight light]</h3> <h3>[property:SpotLight light]</h3>
<div>Reference to the [page:SpotLight] being visualized.</div> <div>Reference to the [page:SpotLight] being visualized.</div>
...@@ -58,6 +61,11 @@ ...@@ -58,6 +61,11 @@
spotLight's [page:Object3D.matrixWorld matrixWorld]. spotLight's [page:Object3D.matrixWorld matrixWorld].
</div> </div>
<h3>[property:hex color]</h3>
<div>
The color parameter passed in the constructor. Default is *undefined*. If this is changed, the helper's color will update
the next time [page:.update update] is called.
</div>
<h2>Methods</h2> <h2>Methods</h2>
<div>See the base [page:Object3D] class for common methods.</div> <div>See the base [page:Object3D] class for common methods.</div>
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
light.position.set( 200, 100, 150 ); light.position.set( 200, 100, 150 );
scene.add( light ); scene.add( light );
scene.add( new THREE.PointLightHelper( light, 5 ) ); scene.add( new THREE.PointLightHelper( light, 15 ) );
var gridHelper = new THREE.GridHelper( 400, 40, 0x0000ff, 0x808080 ); var gridHelper = new THREE.GridHelper( 400, 40, 0x0000ff, 0x808080 );
gridHelper.position.y = - 150; gridHelper.position.y = - 150;
......
...@@ -87,7 +87,7 @@ ...@@ -87,7 +87,7 @@
if ( ! Detector.webgl ) Detector.addGetWebGLMessage(); if ( ! Detector.webgl ) Detector.addGetWebGLMessage();
var camera, scene, renderer, dirLight, hemiLight; var camera, scene, renderer, dirLight, dirLightHeper, hemiLight, hemiLightHelper;
var mixers = []; var mixers = [];
var stats; var stats;
...@@ -113,15 +113,18 @@ ...@@ -113,15 +113,18 @@
hemiLight = new THREE.HemisphereLight( 0xffffff, 0xffffff, 0.6 ); hemiLight = new THREE.HemisphereLight( 0xffffff, 0xffffff, 0.6 );
hemiLight.color.setHSL( 0.6, 1, 0.6 ); hemiLight.color.setHSL( 0.6, 1, 0.6 );
hemiLight.groundColor.setHSL( 0.095, 1, 0.75 ); hemiLight.groundColor.setHSL( 0.095, 1, 0.75 );
hemiLight.position.set( 0, 500, 0 ); hemiLight.position.set( 0, 50, 0 );
scene.add( hemiLight ); scene.add( hemiLight );
hemiLightHelper = new THREE.HemisphereLightHelper( hemiLight, 10 );
scene.add( hemiLightHelper );
// //
dirLight = new THREE.DirectionalLight( 0xffffff, 1 ); dirLight = new THREE.DirectionalLight( 0xffffff, 1 );
dirLight.color.setHSL( 0.1, 1, 0.95 ); dirLight.color.setHSL( 0.1, 1, 0.95 );
dirLight.position.set( -1, 1.75, 1 ); dirLight.position.set( -1, 1.75, 1 );
dirLight.position.multiplyScalar( 50 ); dirLight.position.multiplyScalar( 30 );
scene.add( dirLight ); scene.add( dirLight );
dirLight.castShadow = true; dirLight.castShadow = true;
...@@ -139,6 +142,9 @@ ...@@ -139,6 +142,9 @@
dirLight.shadow.camera.far = 3500; dirLight.shadow.camera.far = 3500;
dirLight.shadow.bias = -0.0001; dirLight.shadow.bias = -0.0001;
dirLightHeper = new THREE.DirectionalLightHelper( dirLight, 10 )
scene.add( dirLightHeper );
// GROUND // GROUND
var groundGeo = new THREE.PlaneBufferGeometry( 10000, 10000 ); var groundGeo = new THREE.PlaneBufferGeometry( 10000, 10000 );
...@@ -239,11 +245,13 @@ ...@@ -239,11 +245,13 @@
case 72: // h case 72: // h
hemiLight.visible = !hemiLight.visible; hemiLight.visible = !hemiLight.visible;
hemiLightHelper.visible = !hemiLightHelper.visible;
break; break;
case 68: // d case 68: // d
dirLight.visible = !dirLight.visible; dirLight.visible = !dirLight.visible;
dirLightHeper.visible = !dirLightHeper.visible;
break; break;
} }
......
...@@ -11,7 +11,7 @@ import { Float32BufferAttribute } from '../core/BufferAttribute'; ...@@ -11,7 +11,7 @@ import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry'; import { BufferGeometry } from '../core/BufferGeometry';
import { LineBasicMaterial } from '../materials/LineBasicMaterial'; import { LineBasicMaterial } from '../materials/LineBasicMaterial';
function DirectionalLightHelper( light, size ) { function DirectionalLightHelper( light, size, color ) {
Object3D.call( this ); Object3D.call( this );
...@@ -21,6 +21,8 @@ function DirectionalLightHelper( light, size ) { ...@@ -21,6 +21,8 @@ function DirectionalLightHelper( light, size ) {
this.matrix = light.matrixWorld; this.matrix = light.matrixWorld;
this.matrixAutoUpdate = false; this.matrixAutoUpdate = false;
this.color = color;
if ( size === undefined ) size = 1; if ( size === undefined ) size = 1;
var geometry = new BufferGeometry(); var geometry = new BufferGeometry();
...@@ -32,14 +34,16 @@ function DirectionalLightHelper( light, size ) { ...@@ -32,14 +34,16 @@ function DirectionalLightHelper( light, size ) {
- size, size, 0 - size, size, 0
], 3 ) ); ], 3 ) );
var material = new LineBasicMaterial( { fog: false } ); var material = new LineBasicMaterial( { fog: false, color: this.color } );
this.add( new Line( geometry, material ) ); this.lightPlane = new Line( geometry, material );
this.add( this.lightPlane );
geometry = new BufferGeometry(); geometry = new BufferGeometry();
geometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) ); geometry.addAttribute( 'position', new Float32BufferAttribute( [ 0, 0, 0, 0, 0, 1 ], 3 ) );
this.add( new Line( geometry, material )); this.targetLine = new Line( geometry, material );
this.add( this.targetLine );
this.update(); this.update();
...@@ -50,13 +54,10 @@ DirectionalLightHelper.prototype.constructor = DirectionalLightHelper; ...@@ -50,13 +54,10 @@ DirectionalLightHelper.prototype.constructor = DirectionalLightHelper;
DirectionalLightHelper.prototype.dispose = function () { DirectionalLightHelper.prototype.dispose = function () {
var lightPlane = this.children[ 0 ]; this.lightPlane.geometry.dispose();
var targetLine = this.children[ 1 ]; this.lightPlane.material.dispose();
this.targetLine.geometry.dispose();
lightPlane.geometry.dispose(); this.targetLine.material.dispose();
lightPlane.material.dispose();
targetLine.geometry.dispose();
targetLine.material.dispose();
}; };
...@@ -72,14 +73,22 @@ DirectionalLightHelper.prototype.update = function () { ...@@ -72,14 +73,22 @@ DirectionalLightHelper.prototype.update = function () {
v2.setFromMatrixPosition( this.light.target.matrixWorld ); v2.setFromMatrixPosition( this.light.target.matrixWorld );
v3.subVectors( v2, v1 ); v3.subVectors( v2, v1 );
var lightPlane = this.children[ 0 ]; this.lightPlane.lookAt( v3 );
var targetLine = this.children[ 1 ];
if ( this.color !== undefined ) {
this.lightPlane.material.color.set( this.color );
this.targetLine.material.color.set( this.color );
} else {
this.lightPlane.material.color.copy( this.light.color );
this.targetLine.material.color.copy( this.light.color );
lightPlane.lookAt( v3 ); }
lightPlane.material.color.copy( this.light.color );
targetLine.lookAt( v3 ); this.targetLine.lookAt( v3 );
targetLine.scale.z = v3.length(); this.targetLine.scale.z = v3.length();
}; };
......
...@@ -13,7 +13,7 @@ import { MeshBasicMaterial } from '../materials/MeshBasicMaterial'; ...@@ -13,7 +13,7 @@ import { MeshBasicMaterial } from '../materials/MeshBasicMaterial';
import { OctahedronBufferGeometry } from '../geometries/OctahedronGeometry'; import { OctahedronBufferGeometry } from '../geometries/OctahedronGeometry';
import { BufferAttribute } from '../core/BufferAttribute'; import { BufferAttribute } from '../core/BufferAttribute';
function HemisphereLightHelper( light, size ) { function HemisphereLightHelper( light, size, color ) {
Object3D.call( this ); Object3D.call( this );
...@@ -23,17 +23,20 @@ function HemisphereLightHelper( light, size ) { ...@@ -23,17 +23,20 @@ function HemisphereLightHelper( light, size ) {
this.matrix = light.matrixWorld; this.matrix = light.matrixWorld;
this.matrixAutoUpdate = false; this.matrixAutoUpdate = false;
this.color = color;
var geometry = new OctahedronBufferGeometry( size ); var geometry = new OctahedronBufferGeometry( size );
geometry.rotateY( Math.PI * 0.5 ); geometry.rotateY( Math.PI * 0.5 );
var material = new MeshBasicMaterial( { vertexColors: VertexColors, wireframe: true } ); this.material = new MeshBasicMaterial( { wireframe: true, fog: false, color: this.color } );
if ( this.color === undefined ) this.material.vertexColors = VertexColors;
var position = geometry.getAttribute( 'position' ); var position = geometry.getAttribute( 'position' );
var colors = new Float32Array( position.count * 3 ); var colors = new Float32Array( position.count * 3 );
geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) ); geometry.addAttribute( 'color', new BufferAttribute( colors, 3 ) );
this.add( new Mesh( geometry, material ) ); this.add( new Mesh( geometry, this.material ) );
this.update(); this.update();
...@@ -60,23 +63,31 @@ HemisphereLightHelper.prototype.update = function () { ...@@ -60,23 +63,31 @@ HemisphereLightHelper.prototype.update = function () {
var mesh = this.children[ 0 ]; var mesh = this.children[ 0 ];
var colors = mesh.geometry.getAttribute( 'color' ); if ( this.color !== undefined ) {
this.material.color.set( this.color );
} else {
var colors = mesh.geometry.getAttribute( 'color' );
color1.copy( this.light.color ); color1.copy( this.light.color );
color2.copy( this.light.groundColor ); color2.copy( this.light.groundColor );
for ( var i = 0, l = colors.count; i < l; i ++ ) { for ( var i = 0, l = colors.count; i < l; i ++ ) {
var color = ( i < ( l / 2 ) ) ? color1 : color2; var color = ( i < ( l / 2 ) ) ? color1 : color2;
colors.setXYZ( i, color.r, color.g, color.b ); colors.setXYZ( i, color.r, color.g, color.b );
}
colors.needsUpdate = true;
} }
mesh.lookAt( vector.setFromMatrixPosition( this.light.matrixWorld ).negate() ); mesh.lookAt( vector.setFromMatrixPosition( this.light.matrixWorld ).negate() );
colors.needsUpdate = true;
}; };
}(); }();
......
...@@ -7,20 +7,24 @@ import { Mesh } from '../objects/Mesh'; ...@@ -7,20 +7,24 @@ import { Mesh } from '../objects/Mesh';
import { MeshBasicMaterial } from '../materials/MeshBasicMaterial'; import { MeshBasicMaterial } from '../materials/MeshBasicMaterial';
import { SphereBufferGeometry } from '../geometries/SphereGeometry'; import { SphereBufferGeometry } from '../geometries/SphereGeometry';
function PointLightHelper( light, sphereSize ) { function PointLightHelper( light, sphereSize, color ) {
this.light = light; this.light = light;
this.light.updateMatrixWorld(); this.light.updateMatrixWorld();
this.color = color;
var geometry = new SphereBufferGeometry( sphereSize, 4, 2 ); var geometry = new SphereBufferGeometry( sphereSize, 4, 2 );
var material = new MeshBasicMaterial( { wireframe: true, fog: false } ); var material = new MeshBasicMaterial( { wireframe: true, fog: false, color: this.color } );
material.color.copy( this.light.color );
Mesh.call( this, geometry, material ); Mesh.call( this, geometry, material );
this.matrix = this.light.matrixWorld; this.matrix = this.light.matrixWorld;
this.matrixAutoUpdate = false; this.matrixAutoUpdate = false;
this.update();
/* /*
var distanceGeometry = new THREE.IcosahedronGeometry( 1, 2 ); var distanceGeometry = new THREE.IcosahedronGeometry( 1, 2 );
var distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } ); var distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
...@@ -57,7 +61,15 @@ PointLightHelper.prototype.dispose = function () { ...@@ -57,7 +61,15 @@ PointLightHelper.prototype.dispose = function () {
PointLightHelper.prototype.update = function () { PointLightHelper.prototype.update = function () {
this.material.color.copy( this.light.color ); if ( this.color !== undefined ) {
this.material.color.set( this.color );
} else {
this.material.color.copy( this.light.color );
}
/* /*
var d = this.light.distance; var d = this.light.distance;
......
...@@ -5,13 +5,12 @@ ...@@ -5,13 +5,12 @@
*/ */
import { Object3D } from '../core/Object3D'; import { Object3D } from '../core/Object3D';
import { Vector3 } from '../math/Vector3';
import { Line } from '../objects/Line'; import { Line } from '../objects/Line';
import { LineBasicMaterial } from '../materials/LineBasicMaterial'; import { LineBasicMaterial } from '../materials/LineBasicMaterial';
import { BufferGeometry } from '../core/BufferGeometry'; import { BufferGeometry } from '../core/BufferGeometry';
import { BufferAttribute } from '../core/BufferAttribute'; import { BufferAttribute } from '../core/BufferAttribute';
function RectAreaLightHelper( light ) { function RectAreaLightHelper( light, color ) {
Object3D.call( this ); Object3D.call( this );
...@@ -21,13 +20,17 @@ function RectAreaLightHelper( light ) { ...@@ -21,13 +20,17 @@ function RectAreaLightHelper( light ) {
this.matrix = light.matrixWorld; this.matrix = light.matrixWorld;
this.matrixAutoUpdate = false; this.matrixAutoUpdate = false;
var material = new LineBasicMaterial( { color: light.color } ); this.color = color;
var material = new LineBasicMaterial( { fog: false, color: this.color } );
var geometry = new BufferGeometry(); var geometry = new BufferGeometry();
geometry.addAttribute( 'position', new BufferAttribute( new Float32Array( 5 * 3 ), 3 ) ); geometry.addAttribute( 'position', new BufferAttribute( new Float32Array( 5 * 3 ), 3 ) );
this.add( new Line( geometry, material ) ); this.line = new Line( geometry, material );
this.add( this.line );
this.update(); this.update();
...@@ -45,18 +48,12 @@ RectAreaLightHelper.prototype.dispose = function () { ...@@ -45,18 +48,12 @@ RectAreaLightHelper.prototype.dispose = function () {
RectAreaLightHelper.prototype.update = function () { RectAreaLightHelper.prototype.update = function () {
var line = this.children[ 0 ];
// update material
line.material.color.copy( this.light.color );
// calculate new dimensions of the helper // calculate new dimensions of the helper
var hx = this.light.width * 0.5; var hx = this.light.width * 0.5;
var hy = this.light.height * 0.5; var hy = this.light.height * 0.5;
var position = line.geometry.attributes.position; var position = this.line.geometry.attributes.position;
var array = position.array; var array = position.array;
// update vertices // update vertices
...@@ -69,6 +66,16 @@ RectAreaLightHelper.prototype.update = function () { ...@@ -69,6 +66,16 @@ RectAreaLightHelper.prototype.update = function () {
position.needsUpdate = true; position.needsUpdate = true;
if ( this.color !== undefined ) {
this.line.material.color.set( this.color );
} else {
this.line.material.color.copy( this.light.color );
}
}; };
export { RectAreaLightHelper }; export { RectAreaLightHelper };
...@@ -11,7 +11,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial'; ...@@ -11,7 +11,7 @@ import { LineBasicMaterial } from '../materials/LineBasicMaterial';
import { Float32BufferAttribute } from '../core/BufferAttribute'; import { Float32BufferAttribute } from '../core/BufferAttribute';
import { BufferGeometry } from '../core/BufferGeometry'; import { BufferGeometry } from '../core/BufferGeometry';
function SpotLightHelper( light ) { function SpotLightHelper( light, color ) {
Object3D.call( this ); Object3D.call( this );
...@@ -21,6 +21,8 @@ function SpotLightHelper( light ) { ...@@ -21,6 +21,8 @@ function SpotLightHelper( light ) {
this.matrix = light.matrixWorld; this.matrix = light.matrixWorld;
this.matrixAutoUpdate = false; this.matrixAutoUpdate = false;
this.color = color;
var geometry = new BufferGeometry(); var geometry = new BufferGeometry();
var positions = [ var positions = [
...@@ -45,7 +47,7 @@ function SpotLightHelper( light ) { ...@@ -45,7 +47,7 @@ function SpotLightHelper( light ) {
geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) ); geometry.addAttribute( 'position', new Float32BufferAttribute( positions, 3 ) );
var material = new LineBasicMaterial( { fog: false } ); var material = new LineBasicMaterial( { fog: false, color: this.color } );
this.cone = new LineSegments( geometry, material ); this.cone = new LineSegments( geometry, material );
this.add( this.cone ); this.add( this.cone );
...@@ -83,7 +85,15 @@ SpotLightHelper.prototype.update = function () { ...@@ -83,7 +85,15 @@ SpotLightHelper.prototype.update = function () {
this.cone.lookAt( vector2.sub( vector ) ); this.cone.lookAt( vector2.sub( vector ) );
this.cone.material.color.copy( this.light.color ); if ( this.color !== undefined ) {
this.cone.material.color.set( this.color );
} else {
this.cone.material.color.copy( this.light.color );
}
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册