12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { Light } from './Light.js';
- import { SpotLightShadow } from './SpotLightShadow.js';
- import { Object3D } from '../core/Object3D.js';
- class SpotLight extends Light {
- constructor( color, intensity, distance = 0, angle = Math.PI / 3, penumbra = 0, decay = 1 ) {
- super( color, intensity );
- this.type = 'SpotLight';
- this.position.copy( Object3D.DefaultUp );
- this.updateMatrix();
- this.target = new Object3D();
- this.distance = distance;
- this.angle = angle;
- this.penumbra = penumbra;
- this.decay = decay; // for physically correct lights, should be 2.
- this.shadow = new SpotLightShadow();
- }
- get power() {
- // intensity = power per solid angle.
- // ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
- return this.intensity * Math.PI;
- }
- set power( power ) {
- // intensity = power per solid angle.
- // ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf
- this.intensity = power / Math.PI;
- }
- dispose() {
- this.shadow.dispose();
- }
- copy( source ) {
- super.copy( source );
- this.distance = source.distance;
- this.angle = source.angle;
- this.penumbra = source.penumbra;
- this.decay = source.decay;
- this.target = source.target.clone();
- this.shadow = source.shadow.clone();
- return this;
- }
- }
- SpotLight.prototype.isSpotLight = true;
- export { SpotLight };
|