lingo3d
Version:
Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor
44 lines • 1.55 kB
JavaScript
import { disposePointLights, releasePointLight, requestPointLight } from "../../pools/objectPools/pointLightPool";
import { pooledPointLightDefaults, pooledPointLightSchema } from "../../interface/IPooledPointLight";
import { onPointLightPool } from "../../events/onPointLightPool";
import { pointLightPoolPtr } from "../../pointers/pointLightPoolPtr";
import PooledPointLightBase from "../core/PooledPointLightBase";
import { pooledPointLightSystem } from "../../systems/pooledPointLightSystem";
const lightSet = new Set();
let requested = false;
const requestPointLights = () => {
if (requested)
return;
requested = true;
const lights = [];
for (let i = 0; i < pointLightPoolPtr[0]; ++i)
lights.push(requestPointLight([], ""));
for (const light of lights)
releasePointLight(light);
};
onPointLightPool(() => {
if (!requested)
return;
requested = false;
disposePointLights();
requestPointLights();
for (const light of lightSet)
pooledPointLightSystem.add(light);
});
class PooledPointLight extends PooledPointLightBase {
static componentName = "pooledPointLight";
static defaults = pooledPointLightDefaults;
static schema = pooledPointLightSchema;
constructor() {
super();
requestPointLights();
pooledPointLightSystem.add(this);
lightSet.add(this);
}
disposeNode() {
super.disposeNode();
lightSet.delete(this);
}
}
export default PooledPointLight;
//# sourceMappingURL=PooledPointLight.js.map