PointLightHelper.js 1.5 KB

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