source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/mrdoob-three.js-4862f5f/src/extras/helpers/HemisphereLightHelper.js@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 1.5 KB
Line 
1/**
2 * @author alteredq / http://alteredqualia.com/
3 * @author mrdoob / http://mrdoob.com/
4 */
5
6THREE.HemisphereLightHelper = function ( light, sphereSize, arrowLength, domeSize ) {
7
8 THREE.Object3D.call( this );
9
10 this.light = light;
11 this.light.updateMatrixWorld();
12
13 this.matrixWorld = light.matrixWorld;
14 this.matrixAutoUpdate = false;
15
16 this.colors = [ new THREE.Color(), new THREE.Color() ];
17
18 var geometry = new THREE.SphereGeometry( sphereSize, 4, 2 );
19 geometry.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2 ) );
20
21 for ( var i = 0, il = 8; i < il; i ++ ) {
22
23 geometry.faces[ i ].color = this.colors[ i < 4 ? 0 : 1 ];
24
25 }
26
27 var material = new THREE.MeshBasicMaterial( { vertexColors: THREE.FaceColors, wireframe: true } );
28
29 this.lightSphere = new THREE.Mesh( geometry, material );
30 this.add( this.lightSphere );
31
32 this.update();
33
34};
35
36THREE.HemisphereLightHelper.prototype = Object.create( THREE.Object3D.prototype );
37
38THREE.HemisphereLightHelper.prototype.dispose = function () {
39 this.lightSphere.geometry.dispose();
40 this.lightSphere.material.dispose();
41};
42
43THREE.HemisphereLightHelper.prototype.update = function () {
44
45 var vector = new THREE.Vector3();
46
47 return function () {
48
49 this.colors[ 0 ].copy( this.light.color ).multiplyScalar( this.light.intensity );
50 this.colors[ 1 ].copy( this.light.groundColor ).multiplyScalar( this.light.intensity );
51
52 this.lightSphere.lookAt( vector.setFromMatrixPosition( this.light.matrixWorld ).negate() );
53 this.lightSphere.geometry.colorsNeedUpdate = true;
54
55 }
56
57}();
58
Note: See TracBrowser for help on using the repository browser.