PointLightHelper.js 1.7 KB

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