UNPKG

lingo3d

Version:

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

75 lines 2.37 kB
import { Sphere } from "three"; import { CM2M, M2CM } from "../../globals"; import LightBase from "./LightBase"; import { releaseShadowRenderTarget } from "../../pools/objectPools/shadowRenderTargetPool"; import Cube from "../primitives/Cube"; import unsafeSetValue from "../../utils/unsafeSetValue"; import { lightIntensitySystem } from "../../systems/lightIntensitySystem"; import { addUpdateShadowSystem, deleteUpdateShadowSystem } from "../../systems/updateShadowSystem"; import { shadowModePtr } from "../../pointers/shadowModePtr"; export default class PointLightBase extends LightBase { constructor(light, helper) { super(light, helper); light.shadow.autoUpdate = false; this.distance = 500; this.intensity = 10; this.shadows = true; } disposeNode() { releaseShadowRenderTarget(this.object3d.shadow.map); unsafeSetValue(this.object3d.shadow, "map", null); super.disposeNode(); } renderCheckBox; get isRendered() { if (!this.renderCheckBox) { const renderCheckBox = (this.renderCheckBox = new Cube()); renderCheckBox.$ghost(); renderCheckBox.opacity = 0.001; this.append(renderCheckBox); } return this.renderCheckBox.isRendered; } $boundingSphere = new Sphere(); get distance() { return this.object3d.distance * M2CM; } set distance(val) { this.object3d.distance = val * CM2M; } get shadows() { return this.object3d.castShadow; } set shadows(val) { this.object3d.castShadow = val; val ? addUpdateShadowSystem(this, { count: undefined, shadowMode: shadowModePtr[0] }) : deleteUpdateShadowSystem(this); } _intensity = 1; get intensity() { return this._intensity; } set intensity(val) { this._intensity = val; if (!this._fade) this.object3d.intensity = val; } _fade = false; get fade() { return this._fade; } set fade(val) { this._fade = val; if (val) { lightIntensitySystem.add(this); return; } lightIntensitySystem.delete(this); this.intensity = this._intensity; } } //# sourceMappingURL=PointLightBase.js.map