lingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
77 lines • 2.38 kB
JavaScript
import { disposeSpotLights, releaseSpotLight, requestSpotLight } from "../../pools/objectPools/spotLightPool";
import { pooledSpotLightDefaults, pooledSpotLightSchema } from "../../interface/IPooledSpotLight";
import { onSpotLightPool } from "../../events/onSpotLightPool";
import { spotLightPoolPtr } from "../../pointers/spotLightPoolPtr";
import PooledPointLightBase from "../core/PooledPointLightBase";
import { pooledSpotLightSystem } from "../../systems/pooledSpotLightSystem";
const lightSet = new Set();
let requested = false;
const requestSpotLights = () => {
if (requested)
return;
requested = true;
const lights = [];
for (let i = 0; i < spotLightPoolPtr[0]; ++i)
lights.push(requestSpotLight([], ""));
for (const light of lights)
releaseSpotLight(light);
};
onSpotLightPool(() => {
if (!requested)
return;
requested = false;
disposeSpotLights();
requestSpotLights();
for (const light of lightSet)
pooledSpotLightSystem.add(light);
});
class PooledSpotLight extends PooledPointLightBase {
static componentName = "pooledSpotLight";
static defaults = pooledSpotLightDefaults;
static schema = pooledSpotLightSchema;
constructor() {
super();
requestSpotLights();
pooledSpotLightSystem.add(this);
lightSet.add(this);
this.then(() => lightSet.delete(this));
}
_angle = 45;
get angle() {
return this._angle;
}
set angle(value) {
this._angle = value;
if (this.$light)
this.$light.angle = value;
}
_penumbra = 0.2;
get penumbra() {
return this._penumbra;
}
set penumbra(value) {
this._penumbra = value;
if (this.$light)
this.$light.penumbra = value;
}
_volumetric = false;
get volumetric() {
return this._volumetric;
}
set volumetric(value) {
this._volumetric = value;
if (this.$light)
this.$light.volumetric = value;
}
_volumetricDistance = 1;
get volumetricDistance() {
return this._volumetricDistance;
}
set volumetricDistance(value) {
this._volumetricDistance = value;
if (this.$light)
this.$light.volumetricDistance = value;
}
}
export default PooledSpotLight;
//# sourceMappingURL=PooledSpotLight.js.map