UNPKG

lingo3d

Version:

Lingo3D is a React/Vue 3d game development framework that ships with a complete visual editor

34 lines 1.51 kB
import getIntensityFactor from "../memo/getIntensityFactor"; import { releasePointLight, requestPointLight } from "../pools/objectPools/pointLightPool"; import scene from "../engine/scene"; import { pointLightPoolPtr } from "../pointers/pointLightPoolPtr"; import { clearNumberPtrSystem } from "./clearNumberPtrSystem"; import createInternalSystem from "./utils/createInternalSystem"; const countPtr = [0]; clearNumberPtrSystem.add(countPtr); export const pooledPointLightSystem = createInternalSystem("pooledPointLightSystem", { data: { visible: false }, update: (self, data) => { const intensityFactor = getIntensityFactor(self); const visible = !!intensityFactor && ++countPtr[0] <= pointLightPoolPtr[0]; if (visible && !data.visible) { const light = (self.$light = requestPointLight([], "")); self.object3d.add(light.outerObject3d); light.distance = self.distance; light.intensity = self.intensity; light.color = self.color; light.shadows = self.shadows; light.fade = self.fade; } else if (!visible && data.visible) { const light = self.$light; releasePointLight(light); scene.add(light.outerObject3d); light.intensity = 0; self.$light = undefined; } data.visible = visible; }, sort: (a, b) => getIntensityFactor(b) - getIntensityFactor(a) }); //# sourceMappingURL=pooledPointLightSystem.js.map