PointLightHelper.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. * @author mrdoob / http://mrdoob.com/
  4. */
  5. THREE.PointLightHelper = function ( light, sphereSize ) {
  6. THREE.Object3D.call( this );
  7. this.matrixAutoUpdate = false;
  8. this.light = light;
  9. var geometry = new THREE.SphereGeometry( sphereSize, 4, 2 );
  10. var material = new THREE.MeshBasicMaterial( { fog: false, wireframe: true } );
  11. material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
  12. this.lightSphere = new THREE.Mesh( geometry, material );
  13. this.lightSphere.matrixWorld = this.light.matrixWorld;
  14. this.lightSphere.matrixAutoUpdate = false;
  15. this.add( this.lightSphere );
  16. /*
  17. var distanceGeometry = new THREE.IcosahedronGeometry( 1, 2 );
  18. var distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
  19. this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
  20. this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );
  21. var d = light.distance;
  22. if ( d === 0.0 ) {
  23. this.lightDistance.visible = false;
  24. } else {
  25. this.lightDistance.scale.set( d, d, d );
  26. }
  27. this.add( this.lightDistance );
  28. */
  29. };
  30. THREE.PointLightHelper.prototype = Object.create( THREE.Object3D.prototype );
  31. THREE.PointLightHelper.prototype.update = function () {
  32. this.lightSphere.material.color.copy( this.light.color ).multiplyScalar( this.light.intensity );
  33. /*
  34. this.lightDistance.material.color.copy( this.color );
  35. var d = this.light.distance;
  36. if ( d === 0.0 ) {
  37. this.lightDistance.visible = false;
  38. } else {
  39. this.lightDistance.visible = true;
  40. this.lightDistance.scale.set( d, d, d );
  41. }
  42. */
  43. };