@onerjs/core 8.23.12 → 8.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Meshes/index.d.ts +1 -0
- package/Behaviors/Meshes/index.js +1 -0
- package/Behaviors/Meshes/index.js.map +1 -1
- package/Behaviors/Meshes/pointerDragBehavior.d.ts +6 -34
- package/Behaviors/Meshes/pointerDragBehavior.js +0 -12
- package/Behaviors/Meshes/pointerDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/pointerDragEvents.d.ts +38 -0
- package/Behaviors/Meshes/pointerDragEvents.js +2 -0
- package/Behaviors/Meshes/pointerDragEvents.js.map +1 -0
- package/Buffers/storageBuffer.d.ts +6 -0
- package/Buffers/storageBuffer.js +8 -0
- package/Buffers/storageBuffer.js.map +1 -1
- package/Engines/Extensions/engine.multiRender.d.ts +2 -1
- package/Engines/Extensions/engine.multiRender.js +12 -7
- package/Engines/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/Extensions/engine.multiview.js +5 -5
- package/Engines/Extensions/engine.multiview.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.d.ts +2 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +12 -7
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +6 -0
- package/Engines/WebGPU/webgpuDrawContext.js +9 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/abstractEngine.js +3 -3
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engineCapabilities.d.ts +4 -0
- package/Engines/engineCapabilities.js.map +1 -1
- package/Engines/engineFactory.d.ts +4 -1
- package/Engines/engineFactory.js.map +1 -1
- package/Engines/nativeEngine.js +2 -0
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js +2 -0
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js +17 -0
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +7 -0
- package/Engines/webgpuEngine.js +19 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +12 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +52 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +0 -3
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +7 -2
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.d.ts +4 -0
- package/FrameGraph/Tasks/Layers/baseLayerTask.js +7 -1
- package/FrameGraph/Tasks/Layers/baseLayerTask.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +11 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +6 -6
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +27 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +76 -8
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +2 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +0 -7
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderTarget.js +1 -1
- package/FrameGraph/frameGraphRenderTarget.js.map +1 -1
- package/Gizmos/cameraGizmo.js +2 -2
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/lightGizmo.js +2 -2
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.d.ts +7 -6
- package/Gizmos/positionGizmo.js +3 -9
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.d.ts +7 -6
- package/Gizmos/rotationGizmo.js +3 -9
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.d.ts +7 -6
- package/Gizmos/scaleGizmo.js +3 -9
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Instrumentation/sceneInstrumentation.d.ts +2 -0
- package/Instrumentation/sceneInstrumentation.js +58 -32
- package/Instrumentation/sceneInstrumentation.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.d.ts +102 -0
- package/Lights/Clustered/clusteredLightContainer.js +487 -0
- package/Lights/Clustered/clusteredLightContainer.js.map +1 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.d.ts +34 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.js +47 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.js.map +1 -0
- package/Lights/Clustered/index.d.ts +6 -0
- package/Lights/Clustered/index.js +7 -0
- package/Lights/Clustered/index.js.map +1 -0
- package/Lights/Shadows/cascadedShadowGenerator.js +1 -0
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.js +10 -8
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Lights/index.d.ts +1 -0
- package/Lights/index.js +1 -0
- package/Lights/index.js.map +1 -1
- package/Lights/light.d.ts +7 -1
- package/Lights/light.js +7 -1
- package/Lights/light.js.map +1 -1
- package/Lights/lightConstants.d.ts +4 -0
- package/Lights/lightConstants.js +4 -0
- package/Lights/lightConstants.js.map +1 -1
- package/Lights/spotLight.d.ts +6 -3
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +0 -5
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js +3 -2
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.d.ts +5 -0
- package/Materials/Textures/renderTargetTexture.js +9 -0
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +12 -4
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/standardMaterial.js +4 -3
- package/Materials/standardMaterial.js.map +1 -1
- package/Materials/uniformBuffer.d.ts +7 -4
- package/Materials/uniformBuffer.js +37 -15
- package/Materials/uniformBuffer.js.map +1 -1
- package/Maths/math.vector.d.ts +1 -1
- package/Maths/math.vector.js +2 -2
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/abstractMesh.d.ts +25 -0
- package/Meshes/abstractMesh.hotSpot.js +37 -25
- package/Meshes/abstractMesh.hotSpot.js.map +1 -1
- package/Meshes/abstractMesh.js +4 -0
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/csg2.js +6 -4
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/geometry.js +1 -1
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/instancedMesh.d.ts +1 -0
- package/Meshes/instancedMesh.js +3 -0
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/linesMesh.d.ts +5 -3
- package/Meshes/linesMesh.js +27 -8
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +0 -19
- package/Meshes/mesh.js +2 -26
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.d.ts +2 -2
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Misc/dumpTools.d.ts +1 -1
- package/Misc/dumpTools.js +23 -14
- package/Misc/dumpTools.js.map +1 -1
- package/Misc/fileTools.js +8 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.js +16 -7
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/lazy.d.ts +16 -0
- package/Misc/lazy.js +25 -0
- package/Misc/lazy.js.map +1 -0
- package/Misc/screenshotTools.js +1 -1
- package/Misc/screenshotTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.d.ts +6 -3
- package/Misc/snapshotRenderingHelper.js +37 -6
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +4 -0
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +4 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +17 -3
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +0 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +31 -0
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +67 -0
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +1 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +2 -2
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +3 -3
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +3 -0
- package/Particles/Node/Blocks/systemBlock.js +3 -0
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +3 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +2 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.js +3 -1
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +2 -1
- package/Particles/Node/nodeParticleSystemSet.helper.js +118 -61
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +1 -0
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/particle.d.ts +8 -0
- package/Particles/particle.js +10 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/particleSystem.d.ts +2 -4
- package/Particles/particleSystem.js +2 -4
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +6 -0
- package/Particles/thinParticleSystem.function.d.ts +2 -0
- package/Particles/thinParticleSystem.function.js +3 -0
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +15 -5
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +33 -3
- package/Rendering/objectRenderer.js +164 -38
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/clusteredLightingFunctions.d.ts +5 -0
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js +19 -0
- package/Shaders/ShadersInclude/clusteredLightingFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/helperFunctions.js +6 -1
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +33 -1
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js +3 -0
- package/Shaders/ShadersInclude/lightFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightUboDeclaration.js +5 -0
- package/Shaders/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js +2 -0
- package/Shaders/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +20 -0
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +3 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.d.ts +7 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +125 -0
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -0
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/Shaders/default.fragment.js +5 -0
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/default.vertex.js +6 -0
- package/Shaders/default.vertex.js.map +1 -1
- package/Shaders/lightProxy.fragment.d.ts +5 -0
- package/Shaders/lightProxy.fragment.js +13 -0
- package/Shaders/lightProxy.fragment.js.map +1 -0
- package/Shaders/lightProxy.vertex.d.ts +8 -0
- package/Shaders/lightProxy.vertex.js +19 -0
- package/Shaders/lightProxy.vertex.js.map +1 -0
- package/Shaders/pbr.fragment.d.ts +1 -0
- package/Shaders/pbr.fragment.js +4 -0
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +6 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.js +24 -0
- package/ShadersWGSL/ShadersInclude/clusteredLightingFunctions.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightFragment.js +33 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +6 -0
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +22 -1
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +3 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.d.ts +2 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +115 -0
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentExtraDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +5 -0
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +6 -0
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/lightProxy.fragment.d.ts +5 -0
- package/ShadersWGSL/lightProxy.fragment.js +13 -0
- package/ShadersWGSL/lightProxy.fragment.js.map +1 -0
- package/ShadersWGSL/lightProxy.vertex.d.ts +7 -0
- package/ShadersWGSL/lightProxy.vertex.js +19 -0
- package/ShadersWGSL/lightProxy.vertex.js.map +1 -0
- package/ShadersWGSL/pbr.vertex.js +6 -0
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/Sprites/spriteManager.d.ts +5 -0
- package/Sprites/spriteManager.js +6 -0
- package/Sprites/spriteManager.js.map +1 -1
- package/Sprites/spriteRenderer.d.ts +5 -2
- package/Sprites/spriteRenderer.js.map +1 -1
- package/States/alphaCullingState.d.ts +3 -1
- package/States/alphaCullingState.js +39 -37
- package/States/alphaCullingState.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +28 -1
- package/scene.js +198 -34
- package/scene.js.map +1 -1
- package/sceneComponent.d.ts +2 -0
- package/sceneComponent.js +2 -0
- package/sceneComponent.js.map +1 -1
package/Lights/index.d.ts
CHANGED
package/Lights/index.js
CHANGED
package/Lights/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./light\";\r\nexport * from \"./shadowLight\";\r\nexport * from \"./Shadows/index\";\r\nexport * from \"./directionalLight\";\r\nexport * from \"./hemisphericLight\";\r\nexport * from \"./pointLight\";\r\nexport * from \"./spotLight\";\r\nexport * from \"./areaLight\";\r\nexport * from \"./rectAreaLight\";\r\nexport * from \"./IES/iesLoader\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./light\";\r\nexport * from \"./shadowLight\";\r\nexport * from \"./Shadows/index\";\r\nexport * from \"./directionalLight\";\r\nexport * from \"./hemisphericLight\";\r\nexport * from \"./pointLight\";\r\nexport * from \"./spotLight\";\r\nexport * from \"./areaLight\";\r\nexport * from \"./rectAreaLight\";\r\nexport * from \"./Clustered/index\";\r\nexport * from \"./IES/iesLoader\";\r\n"]}
|
package/Lights/light.d.ts
CHANGED
|
@@ -121,7 +121,8 @@ export declare abstract class Light extends Node implements ISortableLight {
|
|
|
121
121
|
*/
|
|
122
122
|
intensity: number;
|
|
123
123
|
private _range;
|
|
124
|
-
|
|
124
|
+
/** @internal */
|
|
125
|
+
_inverseSquaredRange: number;
|
|
125
126
|
/**
|
|
126
127
|
* Defines how far from the source the light is impacting in scene units.
|
|
127
128
|
* Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
|
|
@@ -258,6 +259,11 @@ export declare abstract class Light extends Node implements ISortableLight {
|
|
|
258
259
|
/** @internal */
|
|
259
260
|
_renderId: number;
|
|
260
261
|
private _lastUseSpecular;
|
|
262
|
+
/**
|
|
263
|
+
* Used internally by ClusteredLight to sort lights
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
_currentViewDepth: number;
|
|
261
267
|
/**
|
|
262
268
|
* Creates a Light object in the scene.
|
|
263
269
|
* Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction
|
package/Lights/light.js
CHANGED
|
@@ -197,6 +197,7 @@ export class Light extends Node {
|
|
|
197
197
|
*/
|
|
198
198
|
this.intensity = 1.0;
|
|
199
199
|
this._range = Number.MAX_VALUE;
|
|
200
|
+
/** @internal */
|
|
200
201
|
this._inverseSquaredRange = 0;
|
|
201
202
|
/**
|
|
202
203
|
* Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
|
|
@@ -227,6 +228,11 @@ export class Light extends Node {
|
|
|
227
228
|
* @internal Internal use only.
|
|
228
229
|
*/
|
|
229
230
|
this._includedOnlyMeshesIds = new Array();
|
|
231
|
+
/**
|
|
232
|
+
* Used internally by ClusteredLight to sort lights
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
235
|
+
this._currentViewDepth = 0;
|
|
230
236
|
/** @internal */
|
|
231
237
|
this._isLight = true;
|
|
232
238
|
this.getScene().addLight(this);
|
|
@@ -303,7 +309,7 @@ export class Light extends Node {
|
|
|
303
309
|
*/
|
|
304
310
|
toString(fullDetails) {
|
|
305
311
|
let ret = "Name: " + this.name;
|
|
306
|
-
ret += ", type: " + ["Point", "Directional", "Spot", "Hemispheric"][this.getTypeID()];
|
|
312
|
+
ret += ", type: " + ["Point", "Directional", "Spot", "Hemispheric", "Clustered"][this.getTypeID()];
|
|
307
313
|
if (this.animations) {
|
|
308
314
|
for (let i = 0; i < this.animations.length; i++) {
|
|
309
315
|
ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
|
package/Lights/light.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"light.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/light.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAIpF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG/B,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE;;;;GAIG;AACH,MAAM,OAAgB,KAAM,SAAQ,IAAI;IA+HpC;;;OAGG;IAEH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD;;;OAGG;IACH,IAAW,K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oB,kCAA4B,GAAG,cAAc,CAAC,4BAA4B,AAA9C,CAA+C;AAClG;;GAEG;AACoB,2BAAqB,GAAG,cAAc,CAAC,qBAAqB,AAAvC,CAAwC;AACpF;;GAEG;AACoB,kCAA4B,GAAG,cAAc,CAAC,4BAA4B,AAA9C,CAA+C;AAElG;;GAEG;AACoB,gCAA0B,GAAG,cAAc,CAAC,0BAA0B,AAA5C,CAA6C;AAMvF;IADN,iBAAiB,EAAE;sCACuB;AAOpC;IADN,iBAAiB,EAAE;uCACwB;AAWrC;IADN,SAAS,EAAE;0CAC+B;AAQpC;IADN,SAAS,EAAE;wCACW;AAUvB;IADC,SAAS,EAAE;kCAGX;AAsBD;IADC,SAAS,EAAE;0CAGX;AAeD;IADC,SAAS,EAAE;mCAGX;AAUO;IADP,SAAS,EAAE;8CACoB;AAMzB;IADN,gBAAgB,CAAC,uBAAuB,CAAC;6CACR;AAG1B;IADP,SAAS,CAAC,eAAe,CAAC;6CACY;AAoD/B;IADP,SAAS,CAAC,sBAAsB,CAAC;oDACA;AAkB1B;IADP,SAAS,CAAC,0BAA0B,CAAC;wDACA;AAkB9B;IADP,SAAS,CAAC,cAAc,CAAC;4CACA","sourcesContent":["import { serialize, serializeAsColor3, expandToProperty } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, TmpColors } from \"../Maths/math.color\";\r\nimport { Node } from \"../node\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport type { IShadowGenerator } from \"./Shadows/shadowGenerator\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\nimport type { ISortableLight } from \"./lightConstants\";\r\nimport { LightConstants } from \"./lightConstants\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n/**\r\n * Base class of all the lights in Babylon. It groups all the generic information about lights.\r\n * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.\r\n * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.\r\n */\r\nexport abstract class Light extends Node implements ISortableLight {\r\n /**\r\n * Falloff Default: light is falling off following the material specification:\r\n * standard material is using standard falloff whereas pbr material can request special falloff per materials.\r\n */\r\n public static readonly FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Falloff Physical: light is falling off following the inverse squared distance law.\r\n */\r\n public static readonly FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL;\r\n\r\n /**\r\n * Falloff gltf: light is falling off as described in the gltf moving to PBR document\r\n * to enhance interoperability with other engines.\r\n */\r\n public static readonly FALLOFF_GLTF = LightConstants.FALLOFF_GLTF;\r\n\r\n /**\r\n * Falloff Standard: light is falling off like in the standard material\r\n * to enhance interoperability with other materials.\r\n */\r\n public static readonly FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD;\r\n\r\n //lightmapMode Consts\r\n /**\r\n * If every light affecting the material is in this lightmapMode,\r\n * material.lightmapTexture adds or multiplies\r\n * (depends on material.useLightmapAsShadowmap)\r\n * after every other light calculations.\r\n */\r\n public static readonly LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT;\r\n /**\r\n * material.lightmapTexture as only diffuse lighting from this light\r\n * adds only specular lighting from this light\r\n * adds dynamic shadows\r\n */\r\n public static readonly LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR;\r\n /**\r\n * material.lightmapTexture as only lighting\r\n * no light calculation from this light\r\n * only adds dynamic shadows from this light\r\n */\r\n public static readonly LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY;\r\n\r\n // Intensity Mode Consts\r\n /**\r\n * Each light type uses the default quantity according to its type:\r\n * point/spot lights use luminous intensity\r\n * directional lights use illuminance\r\n */\r\n public static readonly INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * lumen (lm)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER;\r\n /**\r\n * candela (lm/sr)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY;\r\n /**\r\n * lux (lm/m^2)\r\n */\r\n public static readonly INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE;\r\n /**\r\n * nit (cd/m^2)\r\n */\r\n public static readonly INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE;\r\n\r\n // Light types ids const.\r\n /**\r\n * Light type const id of the point light.\r\n */\r\n public static readonly LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT;\r\n /**\r\n * Light type const id of the directional light.\r\n */\r\n public static readonly LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT;\r\n /**\r\n * Light type const id of the spot light.\r\n */\r\n public static readonly LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT;\r\n /**\r\n * Light type const id of the hemispheric light.\r\n */\r\n public static readonly LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT;\r\n\r\n /**\r\n * Light type const id of the area light.\r\n */\r\n public static readonly LIGHTTYPEID_RECT_AREALIGHT = LightConstants.LIGHTTYPEID_RECT_AREALIGHT;\r\n\r\n /**\r\n * Diffuse gives the basic color to an object.\r\n */\r\n @serializeAsColor3()\r\n public diffuse = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Specular produces a highlight color on an object.\r\n * Note: This is not affecting PBR materials.\r\n */\r\n @serializeAsColor3()\r\n public specular = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Defines the falloff type for this light. This lets overriding how punctual light are\r\n * falling off base on range or angle.\r\n * This can be set to any values in Light.FALLOFF_x.\r\n *\r\n * Note: This is only useful for PBR Materials at the moment. This could be extended if required to\r\n * other types of materials.\r\n */\r\n @serialize()\r\n public falloffType = Light.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Strength of the light.\r\n * Note: By default it is define in the framework own unit.\r\n * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.\r\n */\r\n @serialize()\r\n public intensity = 1.0;\r\n\r\n private _range = Number.MAX_VALUE;\r\n protected _inverseSquaredRange = 0;\r\n\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n @serialize()\r\n public get range(): number {\r\n return this._range;\r\n }\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n public set range(value: number) {\r\n this._range = value;\r\n this._inverseSquaredRange = 1.0 / (this.range * this.range);\r\n }\r\n\r\n /**\r\n * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type\r\n * of light.\r\n */\r\n private _photometricScale = 1.0;\r\n\r\n private _intensityMode: number = Light.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * Gets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n @serialize()\r\n public get intensityMode(): number {\r\n return this._intensityMode;\r\n }\r\n /**\r\n * Sets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n public set intensityMode(value: number) {\r\n this._intensityMode = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n private _radius = 0.00001;\r\n /**\r\n * Gets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n @serialize()\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n /**\r\n * sets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n @serialize()\r\n private _renderPriority: number;\r\n /**\r\n * Defines the rendering priority of the lights. It can help in case of fallback or number of lights\r\n * exceeding the number allowed of the materials.\r\n */\r\n @expandToProperty(\"_reorderLightsInScene\")\r\n public renderPriority: number = 0;\r\n\r\n @serialize(\"shadowEnabled\")\r\n private _shadowEnabled: boolean = true;\r\n /**\r\n * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public get shadowEnabled(): boolean {\r\n return this._shadowEnabled;\r\n }\r\n /**\r\n * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public set shadowEnabled(value: boolean) {\r\n if (this._shadowEnabled === value) {\r\n return;\r\n }\r\n\r\n this._shadowEnabled = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n private _includedOnlyMeshes: AbstractMesh[];\r\n /**\r\n * Gets the only meshes impacted by this light.\r\n */\r\n public get includedOnlyMeshes(): AbstractMesh[] {\r\n return this._includedOnlyMeshes;\r\n }\r\n /**\r\n * Sets the only meshes impacted by this light.\r\n */\r\n public set includedOnlyMeshes(value: AbstractMesh[]) {\r\n this._includedOnlyMeshes = value;\r\n this._hookArrayForIncludedOnly(value);\r\n }\r\n\r\n private _excludedMeshes: AbstractMesh[];\r\n /**\r\n * Gets the meshes not impacted by this light.\r\n */\r\n public get excludedMeshes(): AbstractMesh[] {\r\n return this._excludedMeshes;\r\n }\r\n /**\r\n * Sets the meshes not impacted by this light.\r\n */\r\n public set excludedMeshes(value: AbstractMesh[]) {\r\n this._excludedMeshes = value;\r\n this._hookArrayForExcluded(value);\r\n }\r\n\r\n @serialize(\"excludeWithLayerMask\")\r\n private _excludeWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get excludeWithLayerMask(): number {\r\n return this._excludeWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set excludeWithLayerMask(value: number) {\r\n this._excludeWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"includeOnlyWithLayerMask\")\r\n private _includeOnlyWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get includeOnlyWithLayerMask(): number {\r\n return this._includeOnlyWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set includeOnlyWithLayerMask(value: number) {\r\n this._includeOnlyWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"lightmapMode\")\r\n private _lightmapMode = 0;\r\n /**\r\n * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public get lightmapMode(): number {\r\n return this._lightmapMode;\r\n }\r\n /**\r\n * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public set lightmapMode(value: number) {\r\n if (this._lightmapMode === value) {\r\n return;\r\n }\r\n\r\n this._lightmapMode = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n /**\r\n * Returns the view matrix.\r\n * @param _faceIndex The index of the face for which we want to extract the view matrix. Only used for point light types.\r\n * @returns The view matrix. Can be null, if a view matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getViewMatrix(_faceIndex?: number): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Returns the projection matrix.\r\n * Note that viewMatrix and renderList are optional and are only used by lights that calculate the projection matrix from a list of meshes (e.g. directional lights with automatic extents calculation).\r\n * @param _viewMatrix The view transform matrix of the light (optional).\r\n * @param _renderList The list of meshes to take into account when calculating the projection matrix (optional).\r\n * @returns The projection matrix. Can be null, if a projection matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getProjectionMatrix(_viewMatrix?: Matrix, _renderList?: Array<AbstractMesh>): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Shadow generators associated to the light.\r\n * @internal Internal use only.\r\n */\r\n public _shadowGenerators: Nullable<Map<Nullable<Camera>, IShadowGenerator>> = null;\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _excludedMeshesIds = new Array<string>();\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _includedOnlyMeshesIds = new Array<string>();\r\n\r\n /**\r\n * The current light uniform buffer.\r\n * @internal Internal use only.\r\n */\r\n public _uniformBuffer: UniformBuffer;\r\n\r\n /** @internal */\r\n public _renderId: number;\r\n\r\n private _lastUseSpecular: boolean;\r\n\r\n /**\r\n * Creates a Light object in the scene.\r\n * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n * @param name The friendly name of the light\r\n * @param scene The scene the light belongs too\r\n */\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene, false);\r\n this.getScene().addLight(this);\r\n this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name);\r\n this._buildUniformLayout();\r\n\r\n this.includedOnlyMeshes = [] as AbstractMesh[];\r\n this.excludedMeshes = [] as AbstractMesh[];\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n protected abstract _buildUniformLayout(): void;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n public abstract transferToEffect(effect: Effect, lightIndex: string): Light;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light textures.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\r\n // Do nothing by default.\r\n return this;\r\n }\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param lightIndex Light index\r\n * @param scene The scene where the light belongs to\r\n * @param effect The effect we are binding the data to\r\n * @param useSpecular Defines if specular is supported\r\n * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows\r\n */\r\n public _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows = true): void {\r\n const iAsString = lightIndex.toString();\r\n let needUpdate = false;\r\n\r\n this._uniformBuffer.bindToEffect(effect, \"Light\" + iAsString);\r\n\r\n if (this._renderId !== scene.getRenderId() || this._lastUseSpecular !== useSpecular || !this._uniformBuffer.useUbo) {\r\n this._renderId = scene.getRenderId();\r\n this._lastUseSpecular = useSpecular;\r\n\r\n const scaledIntensity = this.getScaledIntensity();\r\n\r\n this.transferToEffect(effect, iAsString);\r\n\r\n this.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\r\n this._uniformBuffer.updateColor4(\"vLightDiffuse\", TmpColors.Color3[0], this.range, iAsString);\r\n if (useSpecular) {\r\n this.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\r\n this._uniformBuffer.updateColor4(\"vLightSpecular\", TmpColors.Color3[1], this.radius, iAsString);\r\n }\r\n needUpdate = true;\r\n }\r\n\r\n // Textures might still need to be rebound.\r\n this.transferTexturesToEffect(effect, iAsString);\r\n\r\n // Shadows\r\n if (scene.shadowsEnabled && this.shadowEnabled && receiveShadows) {\r\n const shadowGenerator = this.getShadowGenerator(scene.activeCamera) ?? this.getShadowGenerator();\r\n if (shadowGenerator) {\r\n shadowGenerator.bindShadowLight(iAsString, effect);\r\n needUpdate = true;\r\n }\r\n }\r\n\r\n if (needUpdate) {\r\n this._uniformBuffer.update();\r\n } else {\r\n this._uniformBuffer.bindUniformBuffer();\r\n }\r\n }\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightDataUniformName The uniform used to store light data (position or direction)\r\n * @returns The light\r\n */\r\n public abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;\r\n\r\n /**\r\n * Returns the string \"Light\".\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"Light\";\r\n }\r\n\r\n /** @internal */\r\n public readonly _isLight = true;\r\n\r\n /**\r\n * Converts the light information to a readable string for debug purpose.\r\n * @param fullDetails Supports for multiple levels of logging within scene loading\r\n * @returns the human readable light info\r\n */\r\n public override toString(fullDetails?: boolean): string {\r\n let ret = \"Name: \" + this.name;\r\n ret += \", type: \" + [\"Point\", \"Directional\", \"Spot\", \"Hemispheric\"][this.getTypeID()];\r\n if (this.animations) {\r\n for (let i = 0; i < this.animations.length; i++) {\r\n ret += \", animation[0]: \" + this.animations[i].toString(fullDetails);\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n /** @internal */\r\n protected override _syncParentEnabledState() {\r\n super._syncParentEnabledState();\r\n if (!this.isDisposed()) {\r\n this._resyncMeshes();\r\n }\r\n }\r\n\r\n /**\r\n * Set the enabled state of this node.\r\n * @param value - the new enabled state\r\n */\r\n public override setEnabled(value: boolean): void {\r\n super.setEnabled(value);\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n /**\r\n * Returns the Light associated shadow generator if any.\r\n * @param camera Camera for which the shadow generator should be retrieved (default: null). If null, retrieves the default shadow generator\r\n * @returns the associated shadow generator.\r\n */\r\n public getShadowGenerator(camera: Nullable<Camera> = null): Nullable<IShadowGenerator> {\r\n if (this._shadowGenerators === null) {\r\n return null;\r\n }\r\n\r\n return this._shadowGenerators.get(camera) ?? null;\r\n }\r\n\r\n /**\r\n * Returns all the shadow generators associated to this light\r\n * @returns\r\n */\r\n public getShadowGenerators(): Nullable<Map<Nullable<Camera>, IShadowGenerator>> {\r\n return this._shadowGenerators;\r\n }\r\n\r\n /**\r\n * Returns a Vector3, the absolute light position in the World.\r\n * @returns the world space position of the light\r\n */\r\n public getAbsolutePosition(): Vector3 {\r\n return Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Specifies if the light will affect the passed mesh.\r\n * @param mesh The mesh to test against the light\r\n * @returns true the mesh is affected otherwise, false.\r\n */\r\n public canAffectMesh(mesh: AbstractMesh): boolean {\r\n if (!mesh) {\r\n return true;\r\n }\r\n\r\n if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {\r\n return false;\r\n }\r\n\r\n if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {\r\n return false;\r\n }\r\n\r\n if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {\r\n return false;\r\n }\r\n\r\n if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases resources associated with this node.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n if (this._shadowGenerators) {\r\n const iterator = this._shadowGenerators.values();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const shadowGenerator = key.value;\r\n shadowGenerator.dispose();\r\n }\r\n this._shadowGenerators = null;\r\n }\r\n\r\n // Animations\r\n this.getScene().stopAnimation(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.lights.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.lights.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n // Remove from meshes\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._removeLightSource(this, true);\r\n }\r\n\r\n this._uniformBuffer.dispose();\r\n\r\n // Remove from scene\r\n this.getScene().removeLight(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * Returns the light type ID (integer).\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public getTypeID(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.\r\n * @returns the scaled intensity in intensity mode unit\r\n */\r\n public getScaledIntensity() {\r\n return this._photometricScale * this.intensity;\r\n }\r\n\r\n /**\r\n * Returns a new Light object, named \"name\", from the current one.\r\n * @param name The name of the cloned light\r\n * @param newParent The parent of this light, if it has one\r\n * @returns the new created light\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n const clonedLight = SerializationHelper.Clone(constructor, this);\r\n if (name) {\r\n clonedLight.name = name;\r\n }\r\n if (newParent) {\r\n clonedLight.parent = newParent;\r\n }\r\n clonedLight.setEnabled(this.isEnabled());\r\n\r\n this.onClonedObservable.notifyObservers(clonedLight);\r\n\r\n return clonedLight;\r\n }\r\n\r\n /**\r\n * Serializes the current light into a Serialization object.\r\n * @returns the serialized object.\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n serializationObject.uniqueId = this.uniqueId;\r\n\r\n // Type\r\n serializationObject.type = this.getTypeID();\r\n\r\n // Parent\r\n if (this.parent) {\r\n this.parent._serializeAsParent(serializationObject);\r\n }\r\n\r\n // Inclusion / exclusions\r\n if (this.excludedMeshes.length > 0) {\r\n serializationObject.excludedMeshesIds = [];\r\n for (const mesh of this.excludedMeshes) {\r\n serializationObject.excludedMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n if (this.includedOnlyMeshes.length > 0) {\r\n serializationObject.includedOnlyMeshesIds = [];\r\n for (const mesh of this.includedOnlyMeshes) {\r\n serializationObject.includedOnlyMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n serializationObject.ranges = this.serializeAnimationRanges();\r\n\r\n serializationObject.isEnabled = this.isEnabled();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.\r\n * This new light is named \"name\" and added to the passed scene.\r\n * @param type Type according to the types available in Light.LIGHTTYPEID_x\r\n * @param name The friendly name of the light\r\n * @param scene The scene the new light will belong to\r\n * @returns the constructor function\r\n */\r\n static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light> {\r\n const constructorFunc = Node.Construct(\"Light_Type_\" + type, name, scene);\r\n\r\n if (constructorFunc) {\r\n return <() => Light>constructorFunc;\r\n }\r\n\r\n // Default to no light for none present once.\r\n return null;\r\n }\r\n\r\n /**\r\n * Parses the passed \"parsedLight\" and returns a new instanced Light from this parsing.\r\n * @param parsedLight The JSON representation of the light\r\n * @param scene The scene to create the parsed light in\r\n * @returns the created light after parsing\r\n */\r\n public static Parse(parsedLight: any, scene: Scene): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n\r\n const light = SerializationHelper.Parse(constructor, parsedLight, scene);\r\n\r\n // Inclusion / exclusions\r\n if (parsedLight.excludedMeshesIds) {\r\n light._excludedMeshesIds = parsedLight.excludedMeshesIds;\r\n }\r\n\r\n if (parsedLight.includedOnlyMeshesIds) {\r\n light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;\r\n }\r\n\r\n // Parent\r\n if (parsedLight.parentId !== undefined) {\r\n light._waitingParentId = parsedLight.parentId;\r\n }\r\n\r\n if (parsedLight.parentInstanceIndex !== undefined) {\r\n light._waitingParentInstanceIndex = parsedLight.parentInstanceIndex;\r\n }\r\n\r\n // Falloff\r\n if (parsedLight.falloffType !== undefined) {\r\n light.falloffType = parsedLight.falloffType;\r\n }\r\n\r\n // Lightmaps\r\n if (parsedLight.lightmapMode !== undefined) {\r\n light.lightmapMode = parsedLight.lightmapMode;\r\n }\r\n\r\n // Animations\r\n if (parsedLight.animations) {\r\n for (let animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {\r\n const parsedAnimation = parsedLight.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n light.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n Node.ParseAnimationRanges(light, parsedLight, scene);\r\n }\r\n\r\n if (parsedLight.autoAnimate) {\r\n scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);\r\n }\r\n\r\n // Check if isEnabled is defined to be back compatible with prior serialized versions.\r\n if (parsedLight.isEnabled !== undefined) {\r\n light.setEnabled(parsedLight.isEnabled);\r\n }\r\n\r\n return light;\r\n }\r\n\r\n private _hookArrayForExcluded(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n for (const item of items) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.apply(array, [index, deleteCount]);\r\n\r\n for (const item of deleted) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return deleted;\r\n };\r\n\r\n for (const item of array) {\r\n item._resyncLightSource(this);\r\n }\r\n }\r\n\r\n private _hookArrayForIncludedOnly(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n this._resyncMeshes();\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.apply(array, [index, deleteCount]);\r\n\r\n this._resyncMeshes();\r\n\r\n return deleted;\r\n };\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n private _resyncMeshes() {\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._resyncLightSource(this);\r\n }\r\n }\r\n\r\n /**\r\n * Forces the meshes to update their light related information in their rendering used effects\r\n * @internal Internal Use Only\r\n */\r\n public _markMeshesAsLightDirty() {\r\n for (const mesh of this.getScene().meshes) {\r\n if (mesh.lightSources.indexOf(this) !== -1) {\r\n mesh._markSubMeshesAsLightDirty();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Recomputes the cached photometric scale if needed.\r\n */\r\n private _computePhotometricScale(): void {\r\n this._photometricScale = this._getPhotometricScale();\r\n this.getScene().resetCachedMaterial();\r\n }\r\n\r\n /**\r\n * @returns the Photometric Scale according to the light type and intensity mode.\r\n */\r\n private _getPhotometricScale() {\r\n let photometricScale = 0.0;\r\n const lightTypeID = this.getTypeID();\r\n\r\n //get photometric mode\r\n let photometricMode = this.intensityMode;\r\n if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {\r\n if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {\r\n photometricMode = Light.INTENSITYMODE_ILLUMINANCE;\r\n } else {\r\n photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;\r\n }\r\n }\r\n\r\n //compute photometric scale\r\n switch (lightTypeID) {\r\n case Light.LIGHTTYPEID_POINTLIGHT:\r\n case Light.LIGHTTYPEID_SPOTLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_LUMINOUSPOWER:\r\n photometricScale = 1.0 / (4.0 * Math.PI);\r\n break;\r\n case Light.INTENSITYMODE_LUMINOUSINTENSITY:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE:\r\n photometricScale = this.radius * this.radius;\r\n break;\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_DIRECTIONALLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_ILLUMINANCE:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE: {\r\n // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.\r\n // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).\r\n let apexAngleRadians = this.radius;\r\n // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).\r\n apexAngleRadians = Math.max(apexAngleRadians, 0.001);\r\n const solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));\r\n photometricScale = solidAngle;\r\n break;\r\n }\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_HEMISPHERICLIGHT:\r\n // No fall off in hemispheric light.\r\n photometricScale = 1.0;\r\n break;\r\n }\r\n return photometricScale;\r\n }\r\n\r\n /**\r\n * Reorder the light in the scene according to their defined priority.\r\n * @internal Internal Use Only\r\n */\r\n public _reorderLightsInScene(): void {\r\n const scene = this.getScene();\r\n if (this._renderPriority != 0) {\r\n scene.requireLightSorting = true;\r\n }\r\n this.getScene().sortLightsByPriority();\r\n }\r\n\r\n /**\r\n * Prepares the list of defines specific to the light type.\r\n * @param defines the list of defines\r\n * @param lightIndex defines the index of the light for the effect\r\n */\r\n public abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _isReady() {\r\n return true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"light.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/light.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAIpF,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,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4CACA","sourcesContent":["import { serialize, serializeAsColor3, expandToProperty } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Matrix } from \"../Maths/math.vector\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, TmpColors } from \"../Maths/math.color\";\r\nimport { Node } from \"../node\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport { UniformBuffer } from \"../Materials/uniformBuffer\";\r\nimport type { IShadowGenerator } from \"./Shadows/shadowGenerator\";\r\nimport { GetClass } from \"../Misc/typeStore\";\r\nimport type { ISortableLight } from \"./lightConstants\";\r\nimport { LightConstants } from \"./lightConstants\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { SerializationHelper } from \"../Misc/decorators.serialization\";\r\n/**\r\n * Base class of all the lights in Babylon. It groups all the generic information about lights.\r\n * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.\r\n * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.\r\n */\r\nexport abstract class Light extends Node implements ISortableLight {\r\n /**\r\n * Falloff Default: light is falling off following the material specification:\r\n * standard material is using standard falloff whereas pbr material can request special falloff per materials.\r\n */\r\n public static readonly FALLOFF_DEFAULT = LightConstants.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Falloff Physical: light is falling off following the inverse squared distance law.\r\n */\r\n public static readonly FALLOFF_PHYSICAL = LightConstants.FALLOFF_PHYSICAL;\r\n\r\n /**\r\n * Falloff gltf: light is falling off as described in the gltf moving to PBR document\r\n * to enhance interoperability with other engines.\r\n */\r\n public static readonly FALLOFF_GLTF = LightConstants.FALLOFF_GLTF;\r\n\r\n /**\r\n * Falloff Standard: light is falling off like in the standard material\r\n * to enhance interoperability with other materials.\r\n */\r\n public static readonly FALLOFF_STANDARD = LightConstants.FALLOFF_STANDARD;\r\n\r\n //lightmapMode Consts\r\n /**\r\n * If every light affecting the material is in this lightmapMode,\r\n * material.lightmapTexture adds or multiplies\r\n * (depends on material.useLightmapAsShadowmap)\r\n * after every other light calculations.\r\n */\r\n public static readonly LIGHTMAP_DEFAULT = LightConstants.LIGHTMAP_DEFAULT;\r\n /**\r\n * material.lightmapTexture as only diffuse lighting from this light\r\n * adds only specular lighting from this light\r\n * adds dynamic shadows\r\n */\r\n public static readonly LIGHTMAP_SPECULAR = LightConstants.LIGHTMAP_SPECULAR;\r\n /**\r\n * material.lightmapTexture as only lighting\r\n * no light calculation from this light\r\n * only adds dynamic shadows from this light\r\n */\r\n public static readonly LIGHTMAP_SHADOWSONLY = LightConstants.LIGHTMAP_SHADOWSONLY;\r\n\r\n // Intensity Mode Consts\r\n /**\r\n * Each light type uses the default quantity according to its type:\r\n * point/spot lights use luminous intensity\r\n * directional lights use illuminance\r\n */\r\n public static readonly INTENSITYMODE_AUTOMATIC = LightConstants.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * lumen (lm)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSPOWER = LightConstants.INTENSITYMODE_LUMINOUSPOWER;\r\n /**\r\n * candela (lm/sr)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSINTENSITY = LightConstants.INTENSITYMODE_LUMINOUSINTENSITY;\r\n /**\r\n * lux (lm/m^2)\r\n */\r\n public static readonly INTENSITYMODE_ILLUMINANCE = LightConstants.INTENSITYMODE_ILLUMINANCE;\r\n /**\r\n * nit (cd/m^2)\r\n */\r\n public static readonly INTENSITYMODE_LUMINANCE = LightConstants.INTENSITYMODE_LUMINANCE;\r\n\r\n // Light types ids const.\r\n /**\r\n * Light type const id of the point light.\r\n */\r\n public static readonly LIGHTTYPEID_POINTLIGHT = LightConstants.LIGHTTYPEID_POINTLIGHT;\r\n /**\r\n * Light type const id of the directional light.\r\n */\r\n public static readonly LIGHTTYPEID_DIRECTIONALLIGHT = LightConstants.LIGHTTYPEID_DIRECTIONALLIGHT;\r\n /**\r\n * Light type const id of the spot light.\r\n */\r\n public static readonly LIGHTTYPEID_SPOTLIGHT = LightConstants.LIGHTTYPEID_SPOTLIGHT;\r\n /**\r\n * Light type const id of the hemispheric light.\r\n */\r\n public static readonly LIGHTTYPEID_HEMISPHERICLIGHT = LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT;\r\n\r\n /**\r\n * Light type const id of the area light.\r\n */\r\n public static readonly LIGHTTYPEID_RECT_AREALIGHT = LightConstants.LIGHTTYPEID_RECT_AREALIGHT;\r\n\r\n /**\r\n * Diffuse gives the basic color to an object.\r\n */\r\n @serializeAsColor3()\r\n public diffuse = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Specular produces a highlight color on an object.\r\n * Note: This is not affecting PBR materials.\r\n */\r\n @serializeAsColor3()\r\n public specular = new Color3(1.0, 1.0, 1.0);\r\n\r\n /**\r\n * Defines the falloff type for this light. This lets overriding how punctual light are\r\n * falling off base on range or angle.\r\n * This can be set to any values in Light.FALLOFF_x.\r\n *\r\n * Note: This is only useful for PBR Materials at the moment. This could be extended if required to\r\n * other types of materials.\r\n */\r\n @serialize()\r\n public falloffType = Light.FALLOFF_DEFAULT;\r\n\r\n /**\r\n * Strength of the light.\r\n * Note: By default it is define in the framework own unit.\r\n * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.\r\n */\r\n @serialize()\r\n public intensity = 1.0;\r\n\r\n private _range = Number.MAX_VALUE;\r\n /** @internal */\r\n public _inverseSquaredRange = 0;\r\n\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n @serialize()\r\n public get range(): number {\r\n return this._range;\r\n }\r\n /**\r\n * Defines how far from the source the light is impacting in scene units.\r\n * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.\r\n */\r\n public set range(value: number) {\r\n this._range = value;\r\n this._inverseSquaredRange = 1.0 / (this.range * this.range);\r\n }\r\n\r\n /**\r\n * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type\r\n * of light.\r\n */\r\n private _photometricScale = 1.0;\r\n\r\n private _intensityMode: number = Light.INTENSITYMODE_AUTOMATIC;\r\n /**\r\n * Gets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n @serialize()\r\n public get intensityMode(): number {\r\n return this._intensityMode;\r\n }\r\n /**\r\n * Sets the photometric scale used to interpret the intensity.\r\n * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.\r\n */\r\n public set intensityMode(value: number) {\r\n this._intensityMode = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n private _radius = 0.00001;\r\n /**\r\n * Gets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n @serialize()\r\n public get radius(): number {\r\n return this._radius;\r\n }\r\n /**\r\n * sets the light radius used by PBR Materials to simulate soft area lights.\r\n */\r\n public set radius(value: number) {\r\n this._radius = value;\r\n this._computePhotometricScale();\r\n }\r\n\r\n @serialize()\r\n private _renderPriority: number;\r\n /**\r\n * Defines the rendering priority of the lights. It can help in case of fallback or number of lights\r\n * exceeding the number allowed of the materials.\r\n */\r\n @expandToProperty(\"_reorderLightsInScene\")\r\n public renderPriority: number = 0;\r\n\r\n @serialize(\"shadowEnabled\")\r\n private _shadowEnabled: boolean = true;\r\n /**\r\n * Gets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public get shadowEnabled(): boolean {\r\n return this._shadowEnabled;\r\n }\r\n /**\r\n * Sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n public set shadowEnabled(value: boolean) {\r\n if (this._shadowEnabled === value) {\r\n return;\r\n }\r\n\r\n this._shadowEnabled = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n private _includedOnlyMeshes: AbstractMesh[];\r\n /**\r\n * Gets the only meshes impacted by this light.\r\n */\r\n public get includedOnlyMeshes(): AbstractMesh[] {\r\n return this._includedOnlyMeshes;\r\n }\r\n /**\r\n * Sets the only meshes impacted by this light.\r\n */\r\n public set includedOnlyMeshes(value: AbstractMesh[]) {\r\n this._includedOnlyMeshes = value;\r\n this._hookArrayForIncludedOnly(value);\r\n }\r\n\r\n private _excludedMeshes: AbstractMesh[];\r\n /**\r\n * Gets the meshes not impacted by this light.\r\n */\r\n public get excludedMeshes(): AbstractMesh[] {\r\n return this._excludedMeshes;\r\n }\r\n /**\r\n * Sets the meshes not impacted by this light.\r\n */\r\n public set excludedMeshes(value: AbstractMesh[]) {\r\n this._excludedMeshes = value;\r\n this._hookArrayForExcluded(value);\r\n }\r\n\r\n @serialize(\"excludeWithLayerMask\")\r\n private _excludeWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get excludeWithLayerMask(): number {\r\n return this._excludeWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are not impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set excludeWithLayerMask(value: number) {\r\n this._excludeWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"includeOnlyWithLayerMask\")\r\n private _includeOnlyWithLayerMask = 0;\r\n /**\r\n * Gets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public get includeOnlyWithLayerMask(): number {\r\n return this._includeOnlyWithLayerMask;\r\n }\r\n /**\r\n * Sets the layer id use to find what meshes are impacted by the light.\r\n * Inactive if 0\r\n */\r\n public set includeOnlyWithLayerMask(value: number) {\r\n this._includeOnlyWithLayerMask = value;\r\n this._resyncMeshes();\r\n }\r\n\r\n @serialize(\"lightmapMode\")\r\n private _lightmapMode = 0;\r\n /**\r\n * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public get lightmapMode(): number {\r\n return this._lightmapMode;\r\n }\r\n /**\r\n * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)\r\n */\r\n public set lightmapMode(value: number) {\r\n if (this._lightmapMode === value) {\r\n return;\r\n }\r\n\r\n this._lightmapMode = value;\r\n this._markMeshesAsLightDirty();\r\n }\r\n\r\n /**\r\n * Returns the view matrix.\r\n * @param _faceIndex The index of the face for which we want to extract the view matrix. Only used for point light types.\r\n * @returns The view matrix. Can be null, if a view matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getViewMatrix(_faceIndex?: number): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Returns the projection matrix.\r\n * Note that viewMatrix and renderList are optional and are only used by lights that calculate the projection matrix from a list of meshes (e.g. directional lights with automatic extents calculation).\r\n * @param _viewMatrix The view transform matrix of the light (optional).\r\n * @param _renderList The list of meshes to take into account when calculating the projection matrix (optional).\r\n * @returns The projection matrix. Can be null, if a projection matrix cannot be defined for the type of light considered (as for a hemispherical light, for example).\r\n */\r\n public getProjectionMatrix(_viewMatrix?: Matrix, _renderList?: Array<AbstractMesh>): Nullable<Matrix> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Shadow generators associated to the light.\r\n * @internal Internal use only.\r\n */\r\n public _shadowGenerators: Nullable<Map<Nullable<Camera>, IShadowGenerator>> = null;\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _excludedMeshesIds = new Array<string>();\r\n\r\n /**\r\n * @internal Internal use only.\r\n */\r\n public _includedOnlyMeshesIds = new Array<string>();\r\n\r\n /**\r\n * The current light uniform buffer.\r\n * @internal Internal use only.\r\n */\r\n public _uniformBuffer: UniformBuffer;\r\n\r\n /** @internal */\r\n public _renderId: number;\r\n\r\n private _lastUseSpecular: boolean;\r\n\r\n /**\r\n * Used internally by ClusteredLight to sort lights\r\n * @internal\r\n */\r\n public _currentViewDepth = 0;\r\n\r\n /**\r\n * Creates a Light object in the scene.\r\n * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n * @param name The friendly name of the light\r\n * @param scene The scene the light belongs too\r\n */\r\n constructor(name: string, scene?: Scene) {\r\n super(name, scene, false);\r\n this.getScene().addLight(this);\r\n this._uniformBuffer = new UniformBuffer(this.getScene().getEngine(), undefined, undefined, name);\r\n this._buildUniformLayout();\r\n\r\n this.includedOnlyMeshes = [] as AbstractMesh[];\r\n this.excludedMeshes = [] as AbstractMesh[];\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n protected abstract _buildUniformLayout(): void;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n public abstract transferToEffect(effect: Effect, lightIndex: string): Light;\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light textures.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\r\n // Do nothing by default.\r\n return this;\r\n }\r\n\r\n /**\r\n * Binds the lights information from the scene to the effect for the given mesh.\r\n * @param lightIndex Light index\r\n * @param scene The scene where the light belongs to\r\n * @param effect The effect we are binding the data to\r\n * @param useSpecular Defines if specular is supported\r\n * @param receiveShadows Defines if the effect (mesh) we bind the light for receives shadows\r\n */\r\n public _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, receiveShadows = true): void {\r\n const iAsString = lightIndex.toString();\r\n let needUpdate = false;\r\n\r\n this._uniformBuffer.bindToEffect(effect, \"Light\" + iAsString);\r\n\r\n if (this._renderId !== scene.getRenderId() || this._lastUseSpecular !== useSpecular || !this._uniformBuffer.useUbo) {\r\n this._renderId = scene.getRenderId();\r\n this._lastUseSpecular = useSpecular;\r\n\r\n const scaledIntensity = this.getScaledIntensity();\r\n\r\n this.transferToEffect(effect, iAsString);\r\n\r\n this.diffuse.scaleToRef(scaledIntensity, TmpColors.Color3[0]);\r\n this._uniformBuffer.updateColor4(\"vLightDiffuse\", TmpColors.Color3[0], this.range, iAsString);\r\n if (useSpecular) {\r\n this.specular.scaleToRef(scaledIntensity, TmpColors.Color3[1]);\r\n this._uniformBuffer.updateColor4(\"vLightSpecular\", TmpColors.Color3[1], this.radius, iAsString);\r\n }\r\n needUpdate = true;\r\n }\r\n\r\n // Textures might still need to be rebound.\r\n this.transferTexturesToEffect(effect, iAsString);\r\n\r\n // Shadows\r\n if (scene.shadowsEnabled && this.shadowEnabled && receiveShadows) {\r\n const shadowGenerator = this.getShadowGenerator(scene.activeCamera) ?? this.getShadowGenerator();\r\n if (shadowGenerator) {\r\n shadowGenerator.bindShadowLight(iAsString, effect);\r\n needUpdate = true;\r\n }\r\n }\r\n\r\n if (needUpdate) {\r\n this._uniformBuffer.update();\r\n } else {\r\n this._uniformBuffer.bindUniformBuffer();\r\n }\r\n }\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light information.\r\n * @param effect The effect to update\r\n * @param lightDataUniformName The uniform used to store light data (position or direction)\r\n * @returns The light\r\n */\r\n public abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;\r\n\r\n /**\r\n * Returns the string \"Light\".\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"Light\";\r\n }\r\n\r\n /** @internal */\r\n public readonly _isLight = true;\r\n\r\n /**\r\n * Converts the light information to a readable string for debug purpose.\r\n * @param fullDetails Supports for multiple levels of logging within scene loading\r\n * @returns the human readable light info\r\n */\r\n public override toString(fullDetails?: boolean): string {\r\n let ret = \"Name: \" + this.name;\r\n ret += \", type: \" + [\"Point\", \"Directional\", \"Spot\", \"Hemispheric\", \"Clustered\"][this.getTypeID()];\r\n if (this.animations) {\r\n for (let i = 0; i < this.animations.length; i++) {\r\n ret += \", animation[0]: \" + this.animations[i].toString(fullDetails);\r\n }\r\n }\r\n return ret;\r\n }\r\n\r\n /** @internal */\r\n protected override _syncParentEnabledState() {\r\n super._syncParentEnabledState();\r\n if (!this.isDisposed()) {\r\n this._resyncMeshes();\r\n }\r\n }\r\n\r\n /**\r\n * Set the enabled state of this node.\r\n * @param value - the new enabled state\r\n */\r\n public override setEnabled(value: boolean): void {\r\n super.setEnabled(value);\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n /**\r\n * Returns the Light associated shadow generator if any.\r\n * @param camera Camera for which the shadow generator should be retrieved (default: null). If null, retrieves the default shadow generator\r\n * @returns the associated shadow generator.\r\n */\r\n public getShadowGenerator(camera: Nullable<Camera> = null): Nullable<IShadowGenerator> {\r\n if (this._shadowGenerators === null) {\r\n return null;\r\n }\r\n\r\n return this._shadowGenerators.get(camera) ?? null;\r\n }\r\n\r\n /**\r\n * Returns all the shadow generators associated to this light\r\n * @returns\r\n */\r\n public getShadowGenerators(): Nullable<Map<Nullable<Camera>, IShadowGenerator>> {\r\n return this._shadowGenerators;\r\n }\r\n\r\n /**\r\n * Returns a Vector3, the absolute light position in the World.\r\n * @returns the world space position of the light\r\n */\r\n public getAbsolutePosition(): Vector3 {\r\n return Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Specifies if the light will affect the passed mesh.\r\n * @param mesh The mesh to test against the light\r\n * @returns true the mesh is affected otherwise, false.\r\n */\r\n public canAffectMesh(mesh: AbstractMesh): boolean {\r\n if (!mesh) {\r\n return true;\r\n }\r\n\r\n if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {\r\n return false;\r\n }\r\n\r\n if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {\r\n return false;\r\n }\r\n\r\n if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {\r\n return false;\r\n }\r\n\r\n if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases resources associated with this node.\r\n * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)\r\n * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)\r\n */\r\n public override dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {\r\n if (this._shadowGenerators) {\r\n const iterator = this._shadowGenerators.values();\r\n for (let key = iterator.next(); key.done !== true; key = iterator.next()) {\r\n const shadowGenerator = key.value;\r\n shadowGenerator.dispose();\r\n }\r\n this._shadowGenerators = null;\r\n }\r\n\r\n // Animations\r\n this.getScene().stopAnimation(this);\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.lights.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.lights.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n\r\n // Remove from meshes\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._removeLightSource(this, true);\r\n }\r\n\r\n this._uniformBuffer.dispose();\r\n\r\n // Remove from scene\r\n this.getScene().removeLight(this);\r\n super.dispose(doNotRecurse, disposeMaterialAndTextures);\r\n }\r\n\r\n /**\r\n * Returns the light type ID (integer).\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public getTypeID(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.\r\n * @returns the scaled intensity in intensity mode unit\r\n */\r\n public getScaledIntensity() {\r\n return this._photometricScale * this.intensity;\r\n }\r\n\r\n /**\r\n * Returns a new Light object, named \"name\", from the current one.\r\n * @param name The name of the cloned light\r\n * @param newParent The parent of this light, if it has one\r\n * @returns the new created light\r\n */\r\n public override clone(name: string, newParent: Nullable<Node> = null): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n const clonedLight = SerializationHelper.Clone(constructor, this);\r\n if (name) {\r\n clonedLight.name = name;\r\n }\r\n if (newParent) {\r\n clonedLight.parent = newParent;\r\n }\r\n clonedLight.setEnabled(this.isEnabled());\r\n\r\n this.onClonedObservable.notifyObservers(clonedLight);\r\n\r\n return clonedLight;\r\n }\r\n\r\n /**\r\n * Serializes the current light into a Serialization object.\r\n * @returns the serialized object.\r\n */\r\n public serialize(): any {\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n serializationObject.uniqueId = this.uniqueId;\r\n\r\n // Type\r\n serializationObject.type = this.getTypeID();\r\n\r\n // Parent\r\n if (this.parent) {\r\n this.parent._serializeAsParent(serializationObject);\r\n }\r\n\r\n // Inclusion / exclusions\r\n if (this.excludedMeshes.length > 0) {\r\n serializationObject.excludedMeshesIds = [];\r\n for (const mesh of this.excludedMeshes) {\r\n serializationObject.excludedMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n if (this.includedOnlyMeshes.length > 0) {\r\n serializationObject.includedOnlyMeshesIds = [];\r\n for (const mesh of this.includedOnlyMeshes) {\r\n serializationObject.includedOnlyMeshesIds.push(mesh.id);\r\n }\r\n }\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n serializationObject.ranges = this.serializeAnimationRanges();\r\n\r\n serializationObject.isEnabled = this.isEnabled();\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.\r\n * This new light is named \"name\" and added to the passed scene.\r\n * @param type Type according to the types available in Light.LIGHTTYPEID_x\r\n * @param name The friendly name of the light\r\n * @param scene The scene the new light will belong to\r\n * @returns the constructor function\r\n */\r\n static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light> {\r\n const constructorFunc = Node.Construct(\"Light_Type_\" + type, name, scene);\r\n\r\n if (constructorFunc) {\r\n return <() => Light>constructorFunc;\r\n }\r\n\r\n // Default to no light for none present once.\r\n return null;\r\n }\r\n\r\n /**\r\n * Parses the passed \"parsedLight\" and returns a new instanced Light from this parsing.\r\n * @param parsedLight The JSON representation of the light\r\n * @param scene The scene to create the parsed light in\r\n * @returns the created light after parsing\r\n */\r\n public static Parse(parsedLight: any, scene: Scene): Nullable<Light> {\r\n const constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);\r\n\r\n if (!constructor) {\r\n return null;\r\n }\r\n\r\n const light = SerializationHelper.Parse(constructor, parsedLight, scene);\r\n\r\n // Inclusion / exclusions\r\n if (parsedLight.excludedMeshesIds) {\r\n light._excludedMeshesIds = parsedLight.excludedMeshesIds;\r\n }\r\n\r\n if (parsedLight.includedOnlyMeshesIds) {\r\n light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;\r\n }\r\n\r\n // Parent\r\n if (parsedLight.parentId !== undefined) {\r\n light._waitingParentId = parsedLight.parentId;\r\n }\r\n\r\n if (parsedLight.parentInstanceIndex !== undefined) {\r\n light._waitingParentInstanceIndex = parsedLight.parentInstanceIndex;\r\n }\r\n\r\n // Falloff\r\n if (parsedLight.falloffType !== undefined) {\r\n light.falloffType = parsedLight.falloffType;\r\n }\r\n\r\n // Lightmaps\r\n if (parsedLight.lightmapMode !== undefined) {\r\n light.lightmapMode = parsedLight.lightmapMode;\r\n }\r\n\r\n // Animations\r\n if (parsedLight.animations) {\r\n for (let animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {\r\n const parsedAnimation = parsedLight.animations[animationIndex];\r\n const internalClass = GetClass(\"BABYLON.Animation\");\r\n if (internalClass) {\r\n light.animations.push(internalClass.Parse(parsedAnimation));\r\n }\r\n }\r\n Node.ParseAnimationRanges(light, parsedLight, scene);\r\n }\r\n\r\n if (parsedLight.autoAnimate) {\r\n scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);\r\n }\r\n\r\n // Check if isEnabled is defined to be back compatible with prior serialized versions.\r\n if (parsedLight.isEnabled !== undefined) {\r\n light.setEnabled(parsedLight.isEnabled);\r\n }\r\n\r\n return light;\r\n }\r\n\r\n private _hookArrayForExcluded(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n for (const item of items) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.apply(array, [index, deleteCount]);\r\n\r\n for (const item of deleted) {\r\n item._resyncLightSource(this);\r\n }\r\n\r\n return deleted;\r\n };\r\n\r\n for (const item of array) {\r\n item._resyncLightSource(this);\r\n }\r\n }\r\n\r\n private _hookArrayForIncludedOnly(array: AbstractMesh[]): void {\r\n const oldPush = array.push;\r\n array.push = (...items: AbstractMesh[]) => {\r\n const result = oldPush.apply(array, items);\r\n\r\n this._resyncMeshes();\r\n\r\n return result;\r\n };\r\n\r\n const oldSplice = array.splice;\r\n array.splice = (index: number, deleteCount?: number) => {\r\n const deleted = oldSplice.apply(array, [index, deleteCount]);\r\n\r\n this._resyncMeshes();\r\n\r\n return deleted;\r\n };\r\n\r\n this._resyncMeshes();\r\n }\r\n\r\n private _resyncMeshes() {\r\n for (const mesh of this.getScene().meshes) {\r\n mesh._resyncLightSource(this);\r\n }\r\n }\r\n\r\n /**\r\n * Forces the meshes to update their light related information in their rendering used effects\r\n * @internal Internal Use Only\r\n */\r\n public _markMeshesAsLightDirty() {\r\n for (const mesh of this.getScene().meshes) {\r\n if (mesh.lightSources.indexOf(this) !== -1) {\r\n mesh._markSubMeshesAsLightDirty();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Recomputes the cached photometric scale if needed.\r\n */\r\n private _computePhotometricScale(): void {\r\n this._photometricScale = this._getPhotometricScale();\r\n this.getScene().resetCachedMaterial();\r\n }\r\n\r\n /**\r\n * @returns the Photometric Scale according to the light type and intensity mode.\r\n */\r\n private _getPhotometricScale() {\r\n let photometricScale = 0.0;\r\n const lightTypeID = this.getTypeID();\r\n\r\n //get photometric mode\r\n let photometricMode = this.intensityMode;\r\n if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {\r\n if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {\r\n photometricMode = Light.INTENSITYMODE_ILLUMINANCE;\r\n } else {\r\n photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;\r\n }\r\n }\r\n\r\n //compute photometric scale\r\n switch (lightTypeID) {\r\n case Light.LIGHTTYPEID_POINTLIGHT:\r\n case Light.LIGHTTYPEID_SPOTLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_LUMINOUSPOWER:\r\n photometricScale = 1.0 / (4.0 * Math.PI);\r\n break;\r\n case Light.INTENSITYMODE_LUMINOUSINTENSITY:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE:\r\n photometricScale = this.radius * this.radius;\r\n break;\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_DIRECTIONALLIGHT:\r\n switch (photometricMode) {\r\n case Light.INTENSITYMODE_ILLUMINANCE:\r\n photometricScale = 1.0;\r\n break;\r\n case Light.INTENSITYMODE_LUMINANCE: {\r\n // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.\r\n // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).\r\n let apexAngleRadians = this.radius;\r\n // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).\r\n apexAngleRadians = Math.max(apexAngleRadians, 0.001);\r\n const solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));\r\n photometricScale = solidAngle;\r\n break;\r\n }\r\n }\r\n break;\r\n\r\n case Light.LIGHTTYPEID_HEMISPHERICLIGHT:\r\n // No fall off in hemispheric light.\r\n photometricScale = 1.0;\r\n break;\r\n }\r\n return photometricScale;\r\n }\r\n\r\n /**\r\n * Reorder the light in the scene according to their defined priority.\r\n * @internal Internal Use Only\r\n */\r\n public _reorderLightsInScene(): void {\r\n const scene = this.getScene();\r\n if (this._renderPriority != 0) {\r\n scene.requireLightSorting = true;\r\n }\r\n this.getScene().sortLightsByPriority();\r\n }\r\n\r\n /**\r\n * Prepares the list of defines specific to the light type.\r\n * @param defines the list of defines\r\n * @param lightIndex defines the index of the light for the effect\r\n */\r\n public abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _isReady() {\r\n return true;\r\n }\r\n}\r\n"]}
|
|
@@ -80,6 +80,10 @@ export declare class LightConstants {
|
|
|
80
80
|
* Light type const id of the area light.
|
|
81
81
|
*/
|
|
82
82
|
static readonly LIGHTTYPEID_RECT_AREALIGHT = 4;
|
|
83
|
+
/**
|
|
84
|
+
* Light type const id of the clustered light.
|
|
85
|
+
*/
|
|
86
|
+
static readonly LIGHTTYPEID_CLUSTERED_CONTAINER = 5;
|
|
83
87
|
/**
|
|
84
88
|
* Sort function to order lights for rendering.
|
|
85
89
|
* @param a First Light object to compare to second.
|
package/Lights/lightConstants.js
CHANGED
|
@@ -98,4 +98,8 @@ LightConstants.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
|
|
|
98
98
|
* Light type const id of the area light.
|
|
99
99
|
*/
|
|
100
100
|
LightConstants.LIGHTTYPEID_RECT_AREALIGHT = 4;
|
|
101
|
+
/**
|
|
102
|
+
* Light type const id of the clustered light.
|
|
103
|
+
*/
|
|
104
|
+
LightConstants.LIGHTTYPEID_CLUSTERED_CONTAINER = 5;
|
|
101
105
|
//# sourceMappingURL=lightConstants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lightConstants.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/lightConstants.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,MAAM,OAAO,cAAc;
|
|
1
|
+
{"version":3,"file":"lightConstants.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/lightConstants.ts"],"names":[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ACjD;;GAEG;AACoB,2CAA4B,GAAG,CAAC,CAAC;AAExD;;GAEG;AACoB,yCAA0B,GAAG,CAAC,CAAC;AAEtD;;GAEG;AACoB,8CAA+B,GAAG,CAAC,CAAC","sourcesContent":["/** Defines the cross module constantsused by lights to avoid circular dependencies */\r\nexport class LightConstants {\r\n /**\r\n * Falloff Default: light is falling off following the material specification:\r\n * standard material is using standard falloff whereas pbr material can request special falloff per materials.\r\n */\r\n public static readonly FALLOFF_DEFAULT = 0;\r\n\r\n /**\r\n * Falloff Physical: light is falling off following the inverse squared distance law.\r\n */\r\n public static readonly FALLOFF_PHYSICAL = 1;\r\n\r\n /**\r\n * Falloff gltf: light is falling off as described in the gltf moving to PBR document\r\n * to enhance interoperability with other engines.\r\n */\r\n public static readonly FALLOFF_GLTF = 2;\r\n\r\n /**\r\n * Falloff Standard: light is falling off like in the standard material\r\n * to enhance interoperability with other materials.\r\n */\r\n public static readonly FALLOFF_STANDARD = 3;\r\n\r\n //lightmapMode Consts\r\n /**\r\n * If every light affecting the material is in this lightmapMode,\r\n * material.lightmapTexture adds or multiplies\r\n * (depends on material.useLightmapAsShadowmap)\r\n * after every other light calculations.\r\n */\r\n public static readonly LIGHTMAP_DEFAULT = 0;\r\n /**\r\n * material.lightmapTexture as only diffuse lighting from this light\r\n * adds only specular lighting from this light\r\n * adds dynamic shadows\r\n */\r\n public static readonly LIGHTMAP_SPECULAR = 1;\r\n /**\r\n * material.lightmapTexture as only lighting\r\n * no light calculation from this light\r\n * only adds dynamic shadows from this light\r\n */\r\n public static readonly LIGHTMAP_SHADOWSONLY = 2;\r\n\r\n // Intensity Mode Consts\r\n /**\r\n * Each light type uses the default quantity according to its type:\r\n * point/spot lights use luminous intensity\r\n * directional lights use illuminance\r\n */\r\n public static readonly INTENSITYMODE_AUTOMATIC = 0;\r\n /**\r\n * lumen (lm)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSPOWER = 1;\r\n /**\r\n * candela (lm/sr)\r\n */\r\n public static readonly INTENSITYMODE_LUMINOUSINTENSITY = 2;\r\n /**\r\n * lux (lm/m^2)\r\n */\r\n public static readonly INTENSITYMODE_ILLUMINANCE = 3;\r\n /**\r\n * nit (cd/m^2)\r\n */\r\n public static readonly INTENSITYMODE_LUMINANCE = 4;\r\n\r\n // Light types ids const.\r\n /**\r\n * Light type const id of the point light.\r\n */\r\n public static readonly LIGHTTYPEID_POINTLIGHT = 0;\r\n /**\r\n * Light type const id of the directional light.\r\n */\r\n public static readonly LIGHTTYPEID_DIRECTIONALLIGHT = 1;\r\n /**\r\n * Light type const id of the spot light.\r\n */\r\n public static readonly LIGHTTYPEID_SPOTLIGHT = 2;\r\n /**\r\n * Light type const id of the hemispheric light.\r\n */\r\n public static readonly LIGHTTYPEID_HEMISPHERICLIGHT = 3;\r\n\r\n /**\r\n * Light type const id of the area light.\r\n */\r\n public static readonly LIGHTTYPEID_RECT_AREALIGHT = 4;\r\n\r\n /**\r\n * Light type const id of the clustered light.\r\n */\r\n public static readonly LIGHTTYPEID_CLUSTERED_CONTAINER = 5;\r\n\r\n /**\r\n * Sort function to order lights for rendering.\r\n * @param a First Light object to compare to second.\r\n * @param b Second Light object to compare first.\r\n * @returns -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.\r\n */\r\n public static CompareLightsPriority(a: ISortableLight, b: ISortableLight): number {\r\n //shadow-casting lights have priority over non-shadow-casting lights\r\n //the renderPriority is a secondary sort criterion\r\n if (a.shadowEnabled !== b.shadowEnabled) {\r\n return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);\r\n }\r\n return b.renderPriority - a.renderPriority;\r\n }\r\n}\r\n\r\n/**\r\n * Defines the common interface of sortable lights\r\n */\r\nexport interface ISortableLight {\r\n /**\r\n * Gets or sets whether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching\r\n * the current shadow generator.\r\n */\r\n shadowEnabled: boolean;\r\n /**\r\n * Defines the rendering priority of the lights. It can help in case of fallback or number of lights\r\n * exceeding the number allowed of the materials.\r\n */\r\n renderPriority: number;\r\n}\r\n"]}
|
package/Lights/spotLight.d.ts
CHANGED
|
@@ -17,9 +17,12 @@ import type { Camera } from "../Cameras/camera.js";
|
|
|
17
17
|
export declare class SpotLight extends ShadowLight {
|
|
18
18
|
private _angle;
|
|
19
19
|
private _innerAngle;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
/** @internal */
|
|
21
|
+
_cosHalfAngle: number;
|
|
22
|
+
/** @internal */
|
|
23
|
+
_lightAngleScale: number;
|
|
24
|
+
/** @internal */
|
|
25
|
+
_lightAngleOffset: number;
|
|
23
26
|
private _iesProfileTexture;
|
|
24
27
|
/**
|
|
25
28
|
* Gets or sets the IES profile texture used to create the spotlight
|
package/Lights/spotLight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotLight.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/spotLight.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAI/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAGxD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAEnD,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;IACpD,OAAO,GAAG,EAAE,CAAC,IAAI,SAAS,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,EA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aAAa,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsTexture } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { Node } from \"../node\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Light } from \"./light\";\r\nimport { ShadowLight } from \"./shadowLight\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { ProceduralTexture } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\nNode.AddNodeConstructor(\"Light_Type_2\", (name, scene) => {\r\n return () => new SpotLight(name, Vector3.Zero(), Vector3.Zero(), 0, 0, scene);\r\n});\r\n\r\n/**\r\n * A spot light is defined by a position, a direction, an angle, and an exponent.\r\n * These values define a cone of light starting from the position, emitting toward the direction.\r\n * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,\r\n * and the exponent defines the speed of the decay of the light with distance (reach).\r\n * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n */\r\nexport class SpotLight extends ShadowLight {\r\n /*\r\n upVector , rightVector and direction will form the coordinate system for this spot light.\r\n These three vectors will be used as projection matrix when doing texture projection.\r\n\r\n Also we have the following rules always holds:\r\n direction cross up = right\r\n right cross direction = up\r\n up cross right = forward\r\n\r\n light_near and light_far will control the range of the texture projection. If a plane is\r\n out of the range in spot light space, there is no texture projection.\r\n */\r\n\r\n private _angle: number;\r\n private _innerAngle: number = 0;\r\n private _cosHalfAngle: number;\r\n\r\n private _lightAngleScale: number;\r\n private _lightAngleOffset: number;\r\n\r\n private _iesProfileTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Gets or sets the IES profile texture used to create the spotlight\r\n * @see https://playground.babylonjs.com/#UIAXAU#1\r\n */\r\n public get iesProfileTexture(): Nullable<BaseTexture> {\r\n return this._iesProfileTexture;\r\n }\r\n\r\n public set iesProfileTexture(value: Nullable<BaseTexture>) {\r\n if (this._iesProfileTexture === value) {\r\n return;\r\n }\r\n\r\n this._iesProfileTexture = value;\r\n\r\n if (this._iesProfileTexture && SpotLight._IsTexture(this._iesProfileTexture)) {\r\n this._iesProfileTexture.onLoadObservable.addOnce(() => {\r\n this._markMeshesAsLightDirty();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Gets the cone angle of the spot light in Radians.\r\n */\r\n @serialize()\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n /**\r\n * Sets the cone angle of the spot light in Radians.\r\n */\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._cosHalfAngle = Math.cos(value * 0.5);\r\n this._projectionTextureProjectionLightDirty = true;\r\n this.forceProjectionMatrixCompute();\r\n this._computeAngleValues();\r\n }\r\n\r\n /**\r\n * Only used in gltf falloff mode, this defines the angle where\r\n * the directional falloff will start before cutting at angle which could be seen\r\n * as outer angle.\r\n */\r\n @serialize()\r\n public get innerAngle(): number {\r\n return this._innerAngle;\r\n }\r\n /**\r\n * Only used in gltf falloff mode, this defines the angle where\r\n * the directional falloff will start before cutting at angle which could be seen\r\n * as outer angle.\r\n */\r\n public set innerAngle(value: number) {\r\n this._innerAngle = value;\r\n this._computeAngleValues();\r\n }\r\n\r\n private _shadowAngleScale: number;\r\n /**\r\n * Allows scaling the angle of the light for shadow generation only.\r\n */\r\n @serialize()\r\n public get shadowAngleScale(): number {\r\n return this._shadowAngleScale;\r\n }\r\n /**\r\n * Allows scaling the angle of the light for shadow generation only.\r\n */\r\n public set shadowAngleScale(value: number) {\r\n this._shadowAngleScale = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n /**\r\n * The light decay speed with the distance from the emission spot.\r\n */\r\n @serialize()\r\n public exponent: number;\r\n\r\n private _projectionTextureMatrix = Matrix.Zero();\r\n /**\r\n * Allows reading the projection texture\r\n */\r\n public get projectionTextureMatrix(): Matrix {\r\n return this._projectionTextureMatrix;\r\n }\r\n\r\n protected _projectionTextureLightNear: number = 1e-6;\r\n /**\r\n * Gets the near clip of the Spotlight for texture projection.\r\n */\r\n @serialize()\r\n public get projectionTextureLightNear(): number {\r\n return this._projectionTextureLightNear;\r\n }\r\n /**\r\n * Sets the near clip of the Spotlight for texture projection.\r\n */\r\n public set projectionTextureLightNear(value: number) {\r\n this._projectionTextureLightNear = value;\r\n this._projectionTextureProjectionLightDirty = true;\r\n }\r\n\r\n protected _projectionTextureLightFar: number = 1000.0;\r\n /**\r\n * Gets the far clip of the Spotlight for texture projection.\r\n */\r\n @serialize()\r\n public get projectionTextureLightFar(): number {\r\n return this._projectionTextureLightFar;\r\n }\r\n /**\r\n * Sets the far clip of the Spotlight for texture projection.\r\n */\r\n public set projectionTextureLightFar(value: number) {\r\n this._projectionTextureLightFar = value;\r\n this._projectionTextureProjectionLightDirty = true;\r\n }\r\n\r\n protected _projectionTextureUpDirection: Vector3 = Vector3.Up();\r\n /**\r\n * Gets the Up vector of the Spotlight for texture projection.\r\n */\r\n @serialize()\r\n public get projectionTextureUpDirection(): Vector3 {\r\n return this._projectionTextureUpDirection;\r\n }\r\n /**\r\n * Sets the Up vector of the Spotlight for texture projection.\r\n */\r\n public set projectionTextureUpDirection(value: Vector3) {\r\n this._projectionTextureUpDirection = value;\r\n this._projectionTextureProjectionLightDirty = true;\r\n }\r\n\r\n @serializeAsTexture(\"projectedLightTexture\")\r\n private _projectionTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Gets the projection texture of the light.\r\n */\r\n public get projectionTexture(): Nullable<BaseTexture> {\r\n return this._projectionTexture;\r\n }\r\n /**\r\n * Sets the projection texture of the light.\r\n */\r\n public set projectionTexture(value: Nullable<BaseTexture>) {\r\n if (this._projectionTexture === value) {\r\n return;\r\n }\r\n this._projectionTexture = value;\r\n this._projectionTextureDirty = true;\r\n if (this._projectionTexture && !this._projectionTexture.isReady()) {\r\n if (SpotLight._IsProceduralTexture(this._projectionTexture)) {\r\n this._projectionTexture.getEffect().executeWhenCompiled(() => {\r\n this._markMeshesAsLightDirty();\r\n });\r\n } else if (SpotLight._IsTexture(this._projectionTexture)) {\r\n this._projectionTexture.onLoadObservable.addOnce(() => {\r\n this._markMeshesAsLightDirty();\r\n });\r\n }\r\n }\r\n }\r\n\r\n private static _IsProceduralTexture(texture: BaseTexture): texture is ProceduralTexture {\r\n return (texture as ProceduralTexture).onGeneratedObservable !== undefined;\r\n }\r\n\r\n private static _IsTexture(texture: BaseTexture): texture is Texture {\r\n return (texture as Texture).onLoadObservable !== undefined;\r\n }\r\n\r\n private _projectionTextureViewLightDirty = true;\r\n private _projectionTextureProjectionLightDirty = true;\r\n private _projectionTextureDirty = true;\r\n private _projectionTextureViewTargetVector = Vector3.Zero();\r\n private _projectionTextureViewLightMatrix = Matrix.Zero();\r\n\r\n private _projectionTextureProjectionLightMatrix = Matrix.Zero();\r\n /**\r\n * Gets or sets the light projection matrix as used by the projection texture\r\n */\r\n public get projectionTextureProjectionLightMatrix(): Matrix {\r\n return this._projectionTextureProjectionLightMatrix;\r\n }\r\n\r\n public set projectionTextureProjectionLightMatrix(projection: Matrix) {\r\n this._projectionTextureProjectionLightMatrix = projection;\r\n this._projectionTextureProjectionLightDirty = false;\r\n this._projectionTextureDirty = true;\r\n }\r\n\r\n private _projectionTextureScalingMatrix = Matrix.FromValues(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);\r\n\r\n /**\r\n * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.\r\n * It can cast shadows.\r\n * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n * @param name The light friendly name\r\n * @param position The position of the spot light in the scene\r\n * @param direction The direction of the light in the scene\r\n * @param angle The cone angle of the light in Radians\r\n * @param exponent The light decay speed with the distance from the emission spot\r\n * @param scene The scene the lights belongs to\r\n */\r\n constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene?: Scene) {\r\n super(name, scene);\r\n\r\n this.position = position;\r\n this.direction = direction;\r\n this.angle = angle;\r\n this.exponent = exponent;\r\n }\r\n\r\n /**\r\n * Returns the string \"SpotLight\".\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SpotLight\";\r\n }\r\n\r\n /**\r\n * Returns the integer 2.\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public override getTypeID(): number {\r\n return Light.LIGHTTYPEID_SPOTLIGHT;\r\n }\r\n\r\n /**\r\n * Overrides the direction setter to recompute the projection texture view light Matrix.\r\n * @param value\r\n */\r\n protected override _setDirection(value: Vector3) {\r\n super._setDirection(value);\r\n this._projectionTextureViewLightDirty = true;\r\n }\r\n\r\n /**\r\n * Overrides the position setter to recompute the projection texture view light Matrix.\r\n * @param value\r\n */\r\n protected override _setPosition(value: Vector3) {\r\n super._setPosition(value);\r\n this._projectionTextureViewLightDirty = true;\r\n }\r\n\r\n /**\r\n * Sets the passed matrix \"matrix\" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.\r\n * Returns the SpotLight.\r\n * @param matrix\r\n * @param viewMatrix\r\n * @param renderList\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void {\r\n const activeCamera = this.getScene().activeCamera;\r\n\r\n if (!activeCamera) {\r\n return;\r\n }\r\n\r\n this._shadowAngleScale = this._shadowAngleScale || 1;\r\n const angle = this._shadowAngleScale * this._angle;\r\n\r\n const minZ = this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;\r\n const maxZ = this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;\r\n\r\n const useReverseDepthBuffer = this.getScene().getEngine().useReverseDepthBuffer;\r\n\r\n Matrix.PerspectiveFovLHToRef(\r\n angle,\r\n 1.0,\r\n useReverseDepthBuffer ? maxZ : minZ,\r\n useReverseDepthBuffer ? minZ : maxZ,\r\n matrix,\r\n true,\r\n this._scene.getEngine().isNDCHalfZRange,\r\n undefined,\r\n useReverseDepthBuffer\r\n );\r\n }\r\n\r\n protected _computeProjectionTextureViewLightMatrix(): void {\r\n this._projectionTextureViewLightDirty = false;\r\n this._projectionTextureDirty = true;\r\n\r\n this.getAbsolutePosition().addToRef(this.getShadowDirection(), this._projectionTextureViewTargetVector);\r\n Matrix.LookAtLHToRef(this.getAbsolutePosition(), this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);\r\n }\r\n\r\n protected _computeProjectionTextureProjectionLightMatrix(): void {\r\n this._projectionTextureProjectionLightDirty = false;\r\n this._projectionTextureDirty = true;\r\n\r\n const lightFar = this.projectionTextureLightFar;\r\n const lightNear = this.projectionTextureLightNear;\r\n\r\n const p = lightFar / (lightFar - lightNear);\r\n const q = -p * lightNear;\r\n const s = 1.0 / Math.tan(this._angle / 2.0);\r\n const a = 1.0;\r\n\r\n Matrix.FromValuesToRef(s / a, 0.0, 0.0, 0.0, 0.0, s, 0.0, 0.0, 0.0, 0.0, p, 1.0, 0.0, 0.0, q, 0.0, this._projectionTextureProjectionLightMatrix);\r\n }\r\n\r\n /**\r\n * Main function for light texture projection matrix computing.\r\n */\r\n protected _computeProjectionTextureMatrix(): void {\r\n this._projectionTextureDirty = false;\r\n\r\n this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);\r\n if (this._projectionTexture instanceof Texture) {\r\n const u = this._projectionTexture.uScale / 2.0;\r\n const v = this._projectionTexture.vScale / 2.0;\r\n Matrix.FromValuesToRef(u, 0.0, 0.0, 0.0, 0.0, v, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0, this._projectionTextureScalingMatrix);\r\n }\r\n this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);\r\n }\r\n\r\n protected _buildUniformLayout(): void {\r\n this._uniformBuffer.addUniform(\"vLightData\", 4);\r\n this._uniformBuffer.addUniform(\"vLightDiffuse\", 4);\r\n this._uniformBuffer.addUniform(\"vLightSpecular\", 4);\r\n this._uniformBuffer.addUniform(\"vLightDirection\", 3);\r\n this._uniformBuffer.addUniform(\"vLightFalloff\", 4);\r\n this._uniformBuffer.addUniform(\"shadowsInfo\", 3);\r\n this._uniformBuffer.addUniform(\"depthValues\", 2);\r\n this._uniformBuffer.create();\r\n }\r\n\r\n private _computeAngleValues(): void {\r\n this._lightAngleScale = 1.0 / Math.max(0.001, Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle);\r\n this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;\r\n }\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light textures.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n public override transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\r\n if (this.projectionTexture && this.projectionTexture.isReady()) {\r\n if (this._projectionTextureViewLightDirty) {\r\n this._computeProjectionTextureViewLightMatrix();\r\n }\r\n if (this._projectionTextureProjectionLightDirty) {\r\n this._computeProjectionTextureProjectionLightMatrix();\r\n }\r\n if (this._projectionTextureDirty) {\r\n this._computeProjectionTextureMatrix();\r\n }\r\n effect.setMatrix(\"textureProjectionMatrix\" + lightIndex, this._projectionTextureMatrix);\r\n effect.setTexture(\"projectionLightTexture\" + lightIndex, this.projectionTexture);\r\n }\r\n\r\n if (this._iesProfileTexture && this._iesProfileTexture.isReady()) {\r\n effect.setTexture(\"iesLightTexture\" + lightIndex, this._iesProfileTexture);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The spot light\r\n */\r\n public transferToEffect(effect: Effect, lightIndex: string): SpotLight {\r\n let normalizeDirection;\r\n\r\n if (this.computeTransformedInformation()) {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);\r\n\r\n normalizeDirection = Vector3.Normalize(this.transformedDirection);\r\n } else {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);\r\n\r\n normalizeDirection = Vector3.Normalize(this.direction);\r\n }\r\n\r\n this._uniformBuffer.updateFloat4(\"vLightDirection\", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);\r\n\r\n this._uniformBuffer.updateFloat4(\"vLightFalloff\", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);\r\n return this;\r\n }\r\n\r\n public transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string) {\r\n let normalizeDirection;\r\n\r\n if (this.computeTransformedInformation()) {\r\n normalizeDirection = Vector3.Normalize(this.transformedDirection);\r\n } else {\r\n normalizeDirection = Vector3.Normalize(this.direction);\r\n }\r\n\r\n if (this.getScene().useRightHandedSystem) {\r\n effect.setFloat3(lightDataUniformName, -normalizeDirection.x, -normalizeDirection.y, -normalizeDirection.z);\r\n } else {\r\n effect.setFloat3(lightDataUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Disposes the light and the associated resources.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n if (this._projectionTexture) {\r\n this._projectionTexture.dispose();\r\n }\r\n if (this._iesProfileTexture) {\r\n this._iesProfileTexture.dispose();\r\n this._iesProfileTexture = null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the minZ used for shadow according to both the scene and the light.\r\n * @param activeCamera The camera we are returning the min for\r\n * @returns the depth min z\r\n */\r\n public override getDepthMinZ(activeCamera: Nullable<Camera>): number {\r\n const engine = this._scene.getEngine();\r\n const minZ = this.shadowMinZ !== undefined ? this.shadowMinZ : (activeCamera?.minZ ?? Constants.ShadowMinZ);\r\n\r\n return engine.useReverseDepthBuffer && engine.isNDCHalfZRange ? minZ : this._scene.getEngine().isNDCHalfZRange ? 0 : minZ;\r\n }\r\n\r\n /**\r\n * Gets the maxZ used for shadow according to both the scene and the light.\r\n * @param activeCamera The camera we are returning the max for\r\n * @returns the depth max z\r\n */\r\n public override getDepthMaxZ(activeCamera: Nullable<Camera>): number {\r\n const engine = this._scene.getEngine();\r\n const maxZ = this.shadowMaxZ !== undefined ? this.shadowMaxZ : (activeCamera?.maxZ ?? Constants.ShadowMaxZ);\r\n\r\n return engine.useReverseDepthBuffer && engine.isNDCHalfZRange ? 0 : maxZ;\r\n }\r\n\r\n /**\r\n * Prepares the list of defines specific to the light type.\r\n * @param defines the list of defines\r\n * @param lightIndex defines the index of the light for the effect\r\n */\r\n public prepareLightSpecificDefines(defines: any, lightIndex: number): void {\r\n defines[\"SPOTLIGHT\" + lightIndex] = true;\r\n defines[\"PROJECTEDLIGHTTEXTURE\" + lightIndex] = this.projectionTexture && this.projectionTexture.isReady() ? true : false;\r\n defines[\"IESLIGHTTEXTURE\" + lightIndex] = this._iesProfileTexture && this._iesProfileTexture.isReady() ? true : false;\r\n }\r\n}\r\n\r\n// Register Class Name\r\nRegisterClass(\"BABYLON.SpotLight\", SpotLight);\r\n"]}
|
|
1
|
+
{"version":3,"file":"spotLight.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/spotLight.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,E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B,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1H,OAAO,CAAC,iBAAiB,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC,kBAAkB,IAAI,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC1H,CAAC;CACJ;AAnbG;IADC,SAAS,EAAE;sCAGX;AAkBD;IADC,SAAS,EAAE;2CAGX;AAgBD;IADC,SAAS,EAAE;iDAGX;AAaM;IADN,SAAS,EAAE;2CACY;AAexB;IADC,SAAS,EAAE;2DAGX;AAcD;IADC,SAAS,EAAE;0DAGX;AAcD;IADC,SAAS,EAAE;6DAGX;AAUO;IADP,kBAAkB,CAAC,uBAAuB,CAAC;qDACM;AAqUtD,sBAAsB;AACtB,aAAa,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC","sourcesContent":["import { serialize, serializeAsTexture } from \"../Misc/decorators\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Matrix, Vector3 } from \"../Maths/math.vector\";\r\nimport { Node } from \"../node\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport type { Effect } from \"../Materials/effect\";\r\nimport type { BaseTexture } from \"../Materials/Textures/baseTexture\";\r\nimport { Light } from \"./light\";\r\nimport { ShadowLight } from \"./shadowLight\";\r\nimport { Texture } from \"../Materials/Textures/texture\";\r\nimport type { ProceduralTexture } from \"../Materials/Textures/Procedurals/proceduralTexture\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { RegisterClass } from \"../Misc/typeStore\";\r\nimport { Constants } from \"core/Engines/constants\";\r\n\r\nNode.AddNodeConstructor(\"Light_Type_2\", (name, scene) => {\r\n return () => new SpotLight(name, Vector3.Zero(), Vector3.Zero(), 0, 0, scene);\r\n});\r\n\r\n/**\r\n * A spot light is defined by a position, a direction, an angle, and an exponent.\r\n * These values define a cone of light starting from the position, emitting toward the direction.\r\n * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,\r\n * and the exponent defines the speed of the decay of the light with distance (reach).\r\n * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n */\r\nexport class SpotLight extends ShadowLight {\r\n /*\r\n upVector , rightVector and direction will form the coordinate system for this spot light.\r\n These three vectors will be used as projection matrix when doing texture projection.\r\n\r\n Also we have the following rules always holds:\r\n direction cross up = right\r\n right cross direction = up\r\n up cross right = forward\r\n\r\n light_near and light_far will control the range of the texture projection. If a plane is\r\n out of the range in spot light space, there is no texture projection.\r\n */\r\n\r\n private _angle: number;\r\n private _innerAngle: number = 0;\r\n /** @internal */\r\n public _cosHalfAngle: number;\r\n\r\n /** @internal */\r\n public _lightAngleScale: number;\r\n /** @internal */\r\n public _lightAngleOffset: number;\r\n\r\n private _iesProfileTexture: Nullable<BaseTexture> = null;\r\n\r\n /**\r\n * Gets or sets the IES profile texture used to create the spotlight\r\n * @see https://playground.babylonjs.com/#UIAXAU#1\r\n */\r\n public get iesProfileTexture(): Nullable<BaseTexture> {\r\n return this._iesProfileTexture;\r\n }\r\n\r\n public set iesProfileTexture(value: Nullable<BaseTexture>) {\r\n if (this._iesProfileTexture === value) {\r\n return;\r\n }\r\n\r\n this._iesProfileTexture = value;\r\n\r\n if (this._iesProfileTexture && SpotLight._IsTexture(this._iesProfileTexture)) {\r\n this._iesProfileTexture.onLoadObservable.addOnce(() => {\r\n this._markMeshesAsLightDirty();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * Gets the cone angle of the spot light in Radians.\r\n */\r\n @serialize()\r\n public get angle(): number {\r\n return this._angle;\r\n }\r\n /**\r\n * Sets the cone angle of the spot light in Radians.\r\n */\r\n public set angle(value: number) {\r\n this._angle = value;\r\n this._cosHalfAngle = Math.cos(value * 0.5);\r\n this._projectionTextureProjectionLightDirty = true;\r\n this.forceProjectionMatrixCompute();\r\n this._computeAngleValues();\r\n }\r\n\r\n /**\r\n * Only used in gltf falloff mode, this defines the angle where\r\n * the directional falloff will start before cutting at angle which could be seen\r\n * as outer angle.\r\n */\r\n @serialize()\r\n public get innerAngle(): number {\r\n return this._innerAngle;\r\n }\r\n /**\r\n * Only used in gltf falloff mode, this defines the angle where\r\n * the directional falloff will start before cutting at angle which could be seen\r\n * as outer angle.\r\n */\r\n public set innerAngle(value: number) {\r\n this._innerAngle = value;\r\n this._computeAngleValues();\r\n }\r\n\r\n private _shadowAngleScale: number;\r\n /**\r\n * Allows scaling the angle of the light for shadow generation only.\r\n */\r\n @serialize()\r\n public get shadowAngleScale(): number {\r\n return this._shadowAngleScale;\r\n }\r\n /**\r\n * Allows scaling the angle of the light for shadow generation only.\r\n */\r\n public set shadowAngleScale(value: number) {\r\n this._shadowAngleScale = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n /**\r\n * The light decay speed with the distance from the emission spot.\r\n */\r\n @serialize()\r\n public exponent: number;\r\n\r\n private _projectionTextureMatrix = Matrix.Zero();\r\n /**\r\n * Allows reading the projection texture\r\n */\r\n public get projectionTextureMatrix(): Matrix {\r\n return this._projectionTextureMatrix;\r\n }\r\n\r\n protected _projectionTextureLightNear: number = 1e-6;\r\n /**\r\n * Gets the near clip of the Spotlight for texture projection.\r\n */\r\n @serialize()\r\n public get projectionTextureLightNear(): number {\r\n return this._projectionTextureLightNear;\r\n }\r\n /**\r\n * Sets the near clip of the Spotlight for texture projection.\r\n */\r\n public set projectionTextureLightNear(value: number) {\r\n this._projectionTextureLightNear = value;\r\n this._projectionTextureProjectionLightDirty = true;\r\n }\r\n\r\n protected _projectionTextureLightFar: number = 1000.0;\r\n /**\r\n * Gets the far clip of the Spotlight for texture projection.\r\n */\r\n @serialize()\r\n public get projectionTextureLightFar(): number {\r\n return this._projectionTextureLightFar;\r\n }\r\n /**\r\n * Sets the far clip of the Spotlight for texture projection.\r\n */\r\n public set projectionTextureLightFar(value: number) {\r\n this._projectionTextureLightFar = value;\r\n this._projectionTextureProjectionLightDirty = true;\r\n }\r\n\r\n protected _projectionTextureUpDirection: Vector3 = Vector3.Up();\r\n /**\r\n * Gets the Up vector of the Spotlight for texture projection.\r\n */\r\n @serialize()\r\n public get projectionTextureUpDirection(): Vector3 {\r\n return this._projectionTextureUpDirection;\r\n }\r\n /**\r\n * Sets the Up vector of the Spotlight for texture projection.\r\n */\r\n public set projectionTextureUpDirection(value: Vector3) {\r\n this._projectionTextureUpDirection = value;\r\n this._projectionTextureProjectionLightDirty = true;\r\n }\r\n\r\n @serializeAsTexture(\"projectedLightTexture\")\r\n private _projectionTexture: Nullable<BaseTexture>;\r\n\r\n /**\r\n * Gets the projection texture of the light.\r\n */\r\n public get projectionTexture(): Nullable<BaseTexture> {\r\n return this._projectionTexture;\r\n }\r\n /**\r\n * Sets the projection texture of the light.\r\n */\r\n public set projectionTexture(value: Nullable<BaseTexture>) {\r\n if (this._projectionTexture === value) {\r\n return;\r\n }\r\n this._projectionTexture = value;\r\n this._projectionTextureDirty = true;\r\n if (this._projectionTexture && !this._projectionTexture.isReady()) {\r\n if (SpotLight._IsProceduralTexture(this._projectionTexture)) {\r\n this._projectionTexture.getEffect().executeWhenCompiled(() => {\r\n this._markMeshesAsLightDirty();\r\n });\r\n } else if (SpotLight._IsTexture(this._projectionTexture)) {\r\n this._projectionTexture.onLoadObservable.addOnce(() => {\r\n this._markMeshesAsLightDirty();\r\n });\r\n }\r\n }\r\n }\r\n\r\n private static _IsProceduralTexture(texture: BaseTexture): texture is ProceduralTexture {\r\n return (texture as ProceduralTexture).onGeneratedObservable !== undefined;\r\n }\r\n\r\n private static _IsTexture(texture: BaseTexture): texture is Texture {\r\n return (texture as Texture).onLoadObservable !== undefined;\r\n }\r\n\r\n private _projectionTextureViewLightDirty = true;\r\n private _projectionTextureProjectionLightDirty = true;\r\n private _projectionTextureDirty = true;\r\n private _projectionTextureViewTargetVector = Vector3.Zero();\r\n private _projectionTextureViewLightMatrix = Matrix.Zero();\r\n\r\n private _projectionTextureProjectionLightMatrix = Matrix.Zero();\r\n /**\r\n * Gets or sets the light projection matrix as used by the projection texture\r\n */\r\n public get projectionTextureProjectionLightMatrix(): Matrix {\r\n return this._projectionTextureProjectionLightMatrix;\r\n }\r\n\r\n public set projectionTextureProjectionLightMatrix(projection: Matrix) {\r\n this._projectionTextureProjectionLightMatrix = projection;\r\n this._projectionTextureProjectionLightDirty = false;\r\n this._projectionTextureDirty = true;\r\n }\r\n\r\n private _projectionTextureScalingMatrix = Matrix.FromValues(0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0);\r\n\r\n /**\r\n * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.\r\n * It can cast shadows.\r\n * Documentation : https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n * @param name The light friendly name\r\n * @param position The position of the spot light in the scene\r\n * @param direction The direction of the light in the scene\r\n * @param angle The cone angle of the light in Radians\r\n * @param exponent The light decay speed with the distance from the emission spot\r\n * @param scene The scene the lights belongs to\r\n */\r\n constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene?: Scene) {\r\n super(name, scene);\r\n\r\n this.position = position;\r\n this.direction = direction;\r\n this.angle = angle;\r\n this.exponent = exponent;\r\n }\r\n\r\n /**\r\n * Returns the string \"SpotLight\".\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"SpotLight\";\r\n }\r\n\r\n /**\r\n * Returns the integer 2.\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n public override getTypeID(): number {\r\n return Light.LIGHTTYPEID_SPOTLIGHT;\r\n }\r\n\r\n /**\r\n * Overrides the direction setter to recompute the projection texture view light Matrix.\r\n * @param value\r\n */\r\n protected override _setDirection(value: Vector3) {\r\n super._setDirection(value);\r\n this._projectionTextureViewLightDirty = true;\r\n }\r\n\r\n /**\r\n * Overrides the position setter to recompute the projection texture view light Matrix.\r\n * @param value\r\n */\r\n protected override _setPosition(value: Vector3) {\r\n super._setPosition(value);\r\n this._projectionTextureViewLightDirty = true;\r\n }\r\n\r\n /**\r\n * Sets the passed matrix \"matrix\" as perspective projection matrix for the shadows and the passed view matrix with the fov equal to the SpotLight angle and and aspect ratio of 1.0.\r\n * Returns the SpotLight.\r\n * @param matrix\r\n * @param viewMatrix\r\n * @param renderList\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void {\r\n const activeCamera = this.getScene().activeCamera;\r\n\r\n if (!activeCamera) {\r\n return;\r\n }\r\n\r\n this._shadowAngleScale = this._shadowAngleScale || 1;\r\n const angle = this._shadowAngleScale * this._angle;\r\n\r\n const minZ = this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;\r\n const maxZ = this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;\r\n\r\n const useReverseDepthBuffer = this.getScene().getEngine().useReverseDepthBuffer;\r\n\r\n Matrix.PerspectiveFovLHToRef(\r\n angle,\r\n 1.0,\r\n useReverseDepthBuffer ? maxZ : minZ,\r\n useReverseDepthBuffer ? minZ : maxZ,\r\n matrix,\r\n true,\r\n this._scene.getEngine().isNDCHalfZRange,\r\n undefined,\r\n useReverseDepthBuffer\r\n );\r\n }\r\n\r\n protected _computeProjectionTextureViewLightMatrix(): void {\r\n this._projectionTextureViewLightDirty = false;\r\n this._projectionTextureDirty = true;\r\n\r\n this.getAbsolutePosition().addToRef(this.getShadowDirection(), this._projectionTextureViewTargetVector);\r\n Matrix.LookAtLHToRef(this.getAbsolutePosition(), this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);\r\n }\r\n\r\n protected _computeProjectionTextureProjectionLightMatrix(): void {\r\n this._projectionTextureProjectionLightDirty = false;\r\n this._projectionTextureDirty = true;\r\n\r\n const lightFar = this.projectionTextureLightFar;\r\n const lightNear = this.projectionTextureLightNear;\r\n\r\n const p = lightFar / (lightFar - lightNear);\r\n const q = -p * lightNear;\r\n const s = 1.0 / Math.tan(this._angle / 2.0);\r\n const a = 1.0;\r\n\r\n Matrix.FromValuesToRef(s / a, 0.0, 0.0, 0.0, 0.0, s, 0.0, 0.0, 0.0, 0.0, p, 1.0, 0.0, 0.0, q, 0.0, this._projectionTextureProjectionLightMatrix);\r\n }\r\n\r\n /**\r\n * Main function for light texture projection matrix computing.\r\n */\r\n protected _computeProjectionTextureMatrix(): void {\r\n this._projectionTextureDirty = false;\r\n\r\n this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);\r\n if (this._projectionTexture instanceof Texture) {\r\n const u = this._projectionTexture.uScale / 2.0;\r\n const v = this._projectionTexture.vScale / 2.0;\r\n Matrix.FromValuesToRef(u, 0.0, 0.0, 0.0, 0.0, v, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0, this._projectionTextureScalingMatrix);\r\n }\r\n this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);\r\n }\r\n\r\n protected _buildUniformLayout(): void {\r\n this._uniformBuffer.addUniform(\"vLightData\", 4);\r\n this._uniformBuffer.addUniform(\"vLightDiffuse\", 4);\r\n this._uniformBuffer.addUniform(\"vLightSpecular\", 4);\r\n this._uniformBuffer.addUniform(\"vLightDirection\", 3);\r\n this._uniformBuffer.addUniform(\"vLightFalloff\", 4);\r\n this._uniformBuffer.addUniform(\"shadowsInfo\", 3);\r\n this._uniformBuffer.addUniform(\"depthValues\", 2);\r\n this._uniformBuffer.create();\r\n }\r\n\r\n private _computeAngleValues(): void {\r\n this._lightAngleScale = 1.0 / Math.max(0.001, Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle);\r\n this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;\r\n }\r\n\r\n /**\r\n * Sets the passed Effect \"effect\" with the Light textures.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The light\r\n */\r\n public override transferTexturesToEffect(effect: Effect, lightIndex: string): Light {\r\n if (this.projectionTexture && this.projectionTexture.isReady()) {\r\n if (this._projectionTextureViewLightDirty) {\r\n this._computeProjectionTextureViewLightMatrix();\r\n }\r\n if (this._projectionTextureProjectionLightDirty) {\r\n this._computeProjectionTextureProjectionLightMatrix();\r\n }\r\n if (this._projectionTextureDirty) {\r\n this._computeProjectionTextureMatrix();\r\n }\r\n effect.setMatrix(\"textureProjectionMatrix\" + lightIndex, this._projectionTextureMatrix);\r\n effect.setTexture(\"projectionLightTexture\" + lightIndex, this.projectionTexture);\r\n }\r\n\r\n if (this._iesProfileTexture && this._iesProfileTexture.isReady()) {\r\n effect.setTexture(\"iesLightTexture\" + lightIndex, this._iesProfileTexture);\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * Sets the passed Effect object with the SpotLight transformed position (or position if not parented) and normalized direction.\r\n * @param effect The effect to update\r\n * @param lightIndex The index of the light in the effect to update\r\n * @returns The spot light\r\n */\r\n public transferToEffect(effect: Effect, lightIndex: string): SpotLight {\r\n let normalizeDirection;\r\n\r\n if (this.computeTransformedInformation()) {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);\r\n\r\n normalizeDirection = Vector3.Normalize(this.transformedDirection);\r\n } else {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);\r\n\r\n normalizeDirection = Vector3.Normalize(this.direction);\r\n }\r\n\r\n this._uniformBuffer.updateFloat4(\"vLightDirection\", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);\r\n\r\n this._uniformBuffer.updateFloat4(\"vLightFalloff\", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);\r\n return this;\r\n }\r\n\r\n public transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string) {\r\n let normalizeDirection;\r\n\r\n if (this.computeTransformedInformation()) {\r\n normalizeDirection = Vector3.Normalize(this.transformedDirection);\r\n } else {\r\n normalizeDirection = Vector3.Normalize(this.direction);\r\n }\r\n\r\n if (this.getScene().useRightHandedSystem) {\r\n effect.setFloat3(lightDataUniformName, -normalizeDirection.x, -normalizeDirection.y, -normalizeDirection.z);\r\n } else {\r\n effect.setFloat3(lightDataUniformName, normalizeDirection.x, normalizeDirection.y, normalizeDirection.z);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Disposes the light and the associated resources.\r\n */\r\n public override dispose(): void {\r\n super.dispose();\r\n if (this._projectionTexture) {\r\n this._projectionTexture.dispose();\r\n }\r\n if (this._iesProfileTexture) {\r\n this._iesProfileTexture.dispose();\r\n this._iesProfileTexture = null;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the minZ used for shadow according to both the scene and the light.\r\n * @param activeCamera The camera we are returning the min for\r\n * @returns the depth min z\r\n */\r\n public override getDepthMinZ(activeCamera: Nullable<Camera>): number {\r\n const engine = this._scene.getEngine();\r\n const minZ = this.shadowMinZ !== undefined ? this.shadowMinZ : (activeCamera?.minZ ?? Constants.ShadowMinZ);\r\n\r\n return engine.useReverseDepthBuffer && engine.isNDCHalfZRange ? minZ : this._scene.getEngine().isNDCHalfZRange ? 0 : minZ;\r\n }\r\n\r\n /**\r\n * Gets the maxZ used for shadow according to both the scene and the light.\r\n * @param activeCamera The camera we are returning the max for\r\n * @returns the depth max z\r\n */\r\n public override getDepthMaxZ(activeCamera: Nullable<Camera>): number {\r\n const engine = this._scene.getEngine();\r\n const maxZ = this.shadowMaxZ !== undefined ? this.shadowMaxZ : (activeCamera?.maxZ ?? Constants.ShadowMaxZ);\r\n\r\n return engine.useReverseDepthBuffer && engine.isNDCHalfZRange ? 0 : maxZ;\r\n }\r\n\r\n /**\r\n * Prepares the list of defines specific to the light type.\r\n * @param defines the list of defines\r\n * @param lightIndex defines the index of the light for the effect\r\n */\r\n public prepareLightSpecificDefines(defines: any, lightIndex: number): void {\r\n defines[\"SPOTLIGHT\" + lightIndex] = true;\r\n defines[\"PROJECTEDLIGHTTEXTURE\" + lightIndex] = this.projectionTexture && this.projectionTexture.isReady() ? true : false;\r\n defines[\"IESLIGHTTEXTURE\" + lightIndex] = this._iesProfileTexture && this._iesProfileTexture.isReady() ? true : false;\r\n }\r\n}\r\n\r\n// Register Class Name\r\nRegisterClass(\"BABYLON.SpotLight\", SpotLight);\r\n"]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { __decorate } from "../../../../tslib.es6.js";
|
|
2
1
|
import { NodeMaterialBlockTargets } from "../../Enums/nodeMaterialBlockTargets.js";
|
|
3
2
|
import { CurrentScreenBlock } from "./currentScreenBlock.js";
|
|
4
3
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
5
4
|
import { InputBlock } from "../Input/inputBlock.js";
|
|
6
|
-
import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
|
|
7
5
|
import { SfeModeDefine } from "../Fragment/smartFilterFragmentOutputBlock.js";
|
|
8
6
|
import { NodeMaterialBlockConnectionPointTypes } from "../../Enums/nodeMaterialBlockConnectionPointTypes.js";
|
|
9
7
|
/**
|
|
@@ -84,8 +82,5 @@ export class SmartFilterTextureBlock extends CurrentScreenBlock {
|
|
|
84
82
|
this.isMainInput = serializationObject.isMainInput;
|
|
85
83
|
}
|
|
86
84
|
}
|
|
87
|
-
__decorate([
|
|
88
|
-
editableInPropertyPage("Is Main Input", 0 /* PropertyTypeForEdition.Boolean */, undefined, { notifiers: { rebuild: true } })
|
|
89
|
-
], SmartFilterTextureBlock.prototype, "isMainInput", void 0);
|
|
90
85
|
RegisterClass("BABYLON.SmartFilterTextureBlock", SmartFilterTextureBlock);
|
|
91
86
|
//# sourceMappingURL=smartFilterTextureBlock.js.map
|