PointLightHelper.js 1.7 KB
Newer Older
A
alteredq 已提交
1 2
/**
 * @author alteredq / http://alteredqualia.com/
M
Mr.doob 已提交
3
 * @author mrdoob / http://mrdoob.com/
A
alteredq 已提交
4 5 6 7
 */

THREE.PointLightHelper = function ( light, sphereSize ) {

8
	this.light = light;
M
Mr.doob 已提交
9
	this.light.updateMatrixWorld();
10

11
	var geometry = new THREE.SphereBufferGeometry( sphereSize, 4, 2 );
M
Mr.doob 已提交
12
	var material = new THREE.MeshBasicMaterial( { wireframe: true, fog: false } );
13 14
	material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );

15 16
	THREE.Mesh.call( this, geometry, material );

17
	this.matrix = this.light.matrixWorld;
18
	this.matrixAutoUpdate = false;
19

20
	/*
21 22
	var distanceGeometry = new THREE.IcosahedronGeometry( 1, 2 );
	var distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
A
alteredq 已提交
23

24
	this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
25 26 27 28 29 30 31 32 33 34 35 36 37
	this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );

	var d = light.distance;

	if ( d === 0.0 ) {

		this.lightDistance.visible = false;

	} else {

		this.lightDistance.scale.set( d, d, d );

	}
A
alteredq 已提交
38

39
	this.add( this.lightDistance );
M
Mr.doob 已提交
40
	*/
41

M
Mr.doob 已提交
42
};
A
alteredq 已提交
43

44
THREE.PointLightHelper.prototype = Object.create( THREE.Mesh.prototype );
45
THREE.PointLightHelper.prototype.constructor = THREE.PointLightHelper;
A
alteredq 已提交
46

47
THREE.PointLightHelper.prototype.dispose = function () {
48

49 50
	this.geometry.dispose();
	this.material.dispose();
G
gero3 已提交
51

52 53
};

A
alteredq 已提交
54 55
THREE.PointLightHelper.prototype.update = function () {

56
	this.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
57

M
Mr.doob 已提交
58
	/*
59 60 61 62 63 64 65 66 67 68 69 70
	var d = this.light.distance;

	if ( d === 0.0 ) {

		this.lightDistance.visible = false;

	} else {

		this.lightDistance.visible = true;
		this.lightDistance.scale.set( d, d, d );

	}
M
Mr.doob 已提交
71
	*/
A
alteredq 已提交
72

M
Mr.doob 已提交
73
};