PointLightHelper.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /**
  2. * @author alteredq / http://alteredqualia.com/
  3. * @author mrdoob / http://mrdoob.com/
  4. */
  5. import { Mesh } from '../objects/Mesh.js';
  6. import { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';
  7. import { SphereBufferGeometry } from '../geometries/SphereGeometry.js';
  8. function PointLightHelper( light, sphereSize, color ) {
  9. this.light = light;
  10. this.light.updateMatrixWorld();
  11. this.color = color;
  12. var geometry = new SphereBufferGeometry( sphereSize, 4, 2 );
  13. var material = new MeshBasicMaterial( { wireframe: true, fog: false, toneMapped: false } );
  14. Mesh.call( this, geometry, material );
  15. this.matrix = this.light.matrixWorld;
  16. this.matrixAutoUpdate = false;
  17. this.update();
  18. /*
  19. var distanceGeometry = new THREE.IcosahedronBufferGeometry( 1, 2 );
  20. var distanceMaterial = new THREE.MeshBasicMaterial( { color: hexColor, fog: false, wireframe: true, opacity: 0.1, transparent: true } );
  21. this.lightSphere = new THREE.Mesh( bulbGeometry, bulbMaterial );
  22. this.lightDistance = new THREE.Mesh( distanceGeometry, distanceMaterial );
  23. var d = light.distance;
  24. if ( d === 0.0 ) {
  25. this.lightDistance.visible = false;
  26. } else {
  27. this.lightDistance.scale.set( d, d, d );
  28. }
  29. this.add( this.lightDistance );
  30. */
  31. }
  32. PointLightHelper.prototype = Object.create( Mesh.prototype );
  33. PointLightHelper.prototype.constructor = PointLightHelper;
  34. PointLightHelper.prototype.dispose = function () {
  35. this.geometry.dispose();
  36. this.material.dispose();
  37. };
  38. PointLightHelper.prototype.update = function () {
  39. if ( this.color !== undefined ) {
  40. this.material.color.set( this.color );
  41. } else {
  42. this.material.color.copy( this.light.color );
  43. }
  44. /*
  45. var d = this.light.distance;
  46. if ( d === 0.0 ) {
  47. this.lightDistance.visible = false;
  48. } else {
  49. this.lightDistance.visible = true;
  50. this.lightDistance.scale.set( d, d, d );
  51. }
  52. */
  53. };
  54. export { PointLightHelper };