Spaces:
Sleeping
Sleeping
File size: 915 Bytes
2b7aae2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import { Light } from './Light.js';
class RectAreaLight extends Light {
constructor(color, intensity, width = 10, height = 10) {
super(color, intensity);
this.type = 'RectAreaLight';
this.width = width;
this.height = height;
}
get power() {
// compute the light's luminous power (in lumens) from its intensity (in nits)
return this.intensity * this.width * this.height * Math.PI;
}
set power(power) {
// set the light's intensity (in nits) from the desired luminous power (in lumens)
this.intensity = power / (this.width * this.height * Math.PI);
}
copy(source) {
super.copy(source);
this.width = source.width;
this.height = source.height;
return this;
}
toJSON(meta) {
const data = super.toJSON(meta);
data.object.width = this.width;
data.object.height = this.height;
return data;
}
}
RectAreaLight.prototype.isRectAreaLight = true;
export { RectAreaLight };
|