UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

104 lines (101 loc) 3.84 kB
import { math } from '../../core/math/math.js'; import { Vec3 } from '../../core/math/vec3.js'; import { SHADOW_PCF3_32F } from '../constants.js'; class LightingParams { applySettings(render) { var _render_lightingShadowsEnabled; this.shadowsEnabled = (_render_lightingShadowsEnabled = render.lightingShadowsEnabled) != null ? _render_lightingShadowsEnabled : this.shadowsEnabled; var _render_lightingCookiesEnabled; this.cookiesEnabled = (_render_lightingCookiesEnabled = render.lightingCookiesEnabled) != null ? _render_lightingCookiesEnabled : this.cookiesEnabled; var _render_lightingAreaLightsEnabled; this.areaLightsEnabled = (_render_lightingAreaLightsEnabled = render.lightingAreaLightsEnabled) != null ? _render_lightingAreaLightsEnabled : this.areaLightsEnabled; var _render_lightingShadowAtlasResolution; this.shadowAtlasResolution = (_render_lightingShadowAtlasResolution = render.lightingShadowAtlasResolution) != null ? _render_lightingShadowAtlasResolution : this.shadowAtlasResolution; var _render_lightingCookieAtlasResolution; this.cookieAtlasResolution = (_render_lightingCookieAtlasResolution = render.lightingCookieAtlasResolution) != null ? _render_lightingCookieAtlasResolution : this.cookieAtlasResolution; var _render_lightingMaxLightsPerCell; this.maxLightsPerCell = (_render_lightingMaxLightsPerCell = render.lightingMaxLightsPerCell) != null ? _render_lightingMaxLightsPerCell : this.maxLightsPerCell; var _render_lightingShadowType; this.shadowType = (_render_lightingShadowType = render.lightingShadowType) != null ? _render_lightingShadowType : this.shadowType; if (render.lightingCells) { this.cell = new Vec3(render.lightingCells); } } set cells(value) { this._cells.copy(value); } get cells() { return this._cells; } set maxLightsPerCell(value) { this._maxLightsPerCell = math.clamp(value, 1, 255); } get maxLightsPerCell() { return this._maxLightsPerCell; } set cookieAtlasResolution(value) { this._cookieAtlasResolution = math.clamp(value, 32, this._maxTextureSize); } get cookieAtlasResolution() { return this._cookieAtlasResolution; } set shadowAtlasResolution(value) { this._shadowAtlasResolution = math.clamp(value, 32, this._maxTextureSize); } get shadowAtlasResolution() { return this._shadowAtlasResolution; } set shadowType(value) { if (this._shadowType !== value) { this._shadowType = value; this._dirtyLightsFnc(); } } get shadowType() { return this._shadowType; } set cookiesEnabled(value) { if (this._cookiesEnabled !== value) { this._cookiesEnabled = value; this._dirtyLightsFnc(); } } get cookiesEnabled() { return this._cookiesEnabled; } set areaLightsEnabled(value) { if (this._supportsAreaLights) { if (this._areaLightsEnabled !== value) { this._areaLightsEnabled = value; this._dirtyLightsFnc(); } } } get areaLightsEnabled() { return this._areaLightsEnabled; } set shadowsEnabled(value) { if (this._shadowsEnabled !== value) { this._shadowsEnabled = value; this._dirtyLightsFnc(); } } get shadowsEnabled() { return this._shadowsEnabled; } constructor(supportsAreaLights, maxTextureSize, dirtyLightsFnc){ this._areaLightsEnabled = false; this._cells = new Vec3(10, 3, 10); this._maxLightsPerCell = 255; this._shadowsEnabled = true; this._shadowType = SHADOW_PCF3_32F; this._shadowAtlasResolution = 2048; this._cookiesEnabled = false; this._cookieAtlasResolution = 2048; this.atlasSplit = null; this._supportsAreaLights = supportsAreaLights; this._maxTextureSize = maxTextureSize; this._dirtyLightsFnc = dirtyLightsFnc; } } export { LightingParams };