@babylonjs/core 7.3.0 → 7.3.2
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/Actions/condition.js.map +1 -1
- package/Actions/directActions.js.map +1 -1
- package/Actions/directAudioActions.js.map +1 -1
- package/Actions/interpolateValueAction.js.map +1 -1
- package/Animations/easing.js.map +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
- package/Bones/bone.js.map +1 -1
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/followCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/freeCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphArcRotateCamera.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphFreeCamera.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphGamepadCamera.js.map +1 -1
- package/Cameras/Stereoscopic/anaglyphUniversalCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicArcRotateCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicFreeCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicGamepadCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicScreenUniversalCamera.js.map +1 -1
- package/Cameras/Stereoscopic/stereoscopicUniversalCamera.js.map +1 -1
- package/Cameras/VR/vrDeviceOrientationArcRotateCamera.js.map +1 -1
- package/Cameras/VR/vrDeviceOrientationFreeCamera.js.map +1 -1
- package/Cameras/VR/vrDeviceOrientationGamepadCamera.js.map +1 -1
- package/Cameras/VR/vrExperienceHelper.js.map +1 -1
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/camera.js.map +1 -1
- package/Cameras/deviceOrientationCamera.js.map +1 -1
- package/Cameras/flyCamera.js.map +1 -1
- package/Cameras/followCamera.js.map +1 -1
- package/Cameras/freeCamera.js.map +1 -1
- package/Cameras/freeCameraInputsManager.js.map +1 -1
- package/Cameras/gamepadCamera.js.map +1 -1
- package/Cameras/targetCamera.js.map +1 -1
- package/Cameras/touchCamera.js.map +1 -1
- package/Cameras/universalCamera.js.map +1 -1
- package/Cameras/virtualJoysticksCamera.js.map +1 -1
- package/Debug/boneAxesViewer.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineAndOperator.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator.js.map +1 -1
- package/Engines/Processors/Expressions/Operators/shaderDefineOrOperator.js.map +1 -1
- package/Engines/Processors/shaderCodeConditionNode.js.map +1 -1
- package/Engines/Processors/shaderCodeTestNode.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.rawTexture.js +10 -10
- package/Engines/WebGPU/Extensions/engine.rawTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipelineTree.js.map +1 -1
- package/Engines/WebGPU/webgpuDepthCullingState.js.map +1 -1
- package/Engines/WebGPU/webgpuHardwareTexture.d.ts +2 -0
- package/Engines/WebGPU/webgpuHardwareTexture.js +2 -0
- package/Engines/WebGPU/webgpuHardwareTexture.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuStencilStateComposer.js.map +1 -1
- package/Engines/abstractEngine.js +14 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/engine.d.ts +0 -8
- package/Engines/engine.js +0 -28
- package/Engines/engine.js.map +1 -1
- package/Engines/nativeEngine.js.map +1 -1
- package/Engines/nullEngine.js.map +1 -1
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +4 -0
- package/Engines/webgpuEngine.js +4 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Events/keyboardEvents.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphTernaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.js.map +1 -1
- package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
- package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
- package/Gamepads/dualShockGamepad.js.map +1 -1
- package/Gamepads/gamepad.js.map +1 -1
- package/Gamepads/xboxGamepad.js.map +1 -1
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Gizmos/lightGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Gizmos/positionGizmo.js.map +1 -1
- package/Gizmos/rotationGizmo.js.map +1 -1
- package/Gizmos/scaleGizmo.js.map +1 -1
- package/Helpers/photoDome.js.map +1 -1
- package/Helpers/textureDome.js.map +1 -1
- package/Helpers/videoDome.js.map +1 -1
- package/Layers/glowLayer.js.map +1 -1
- package/Layers/highlightLayer.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Lights/directionalLight.js.map +1 -1
- package/Lights/hemisphericLight.js.map +1 -1
- package/Lights/light.js.map +1 -1
- package/Lights/pointLight.js.map +1 -1
- package/Lights/shadowLight.js.map +1 -1
- package/Lights/spotLight.js.map +1 -1
- package/Materials/Background/backgroundMaterial.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLinePluginMaterial.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/sceneDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/derivativeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/discardBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragDepthBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/prePassOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSpaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/shadowMapBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/twirlBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Input/prePassTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleRampGradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/vertexOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/addBlock.js.map +1 -1
- package/Materials/Node/Blocks/arcTan2Block.js.map +1 -1
- package/Materials/Node/Blocks/biPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/clampBlock.js.map +1 -1
- package/Materials/Node/Blocks/cloudBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/colorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/conditionalBlock.js.map +1 -1
- package/Materials/Node/Blocks/crossBlock.js.map +1 -1
- package/Materials/Node/Blocks/curveBlock.js.map +1 -1
- package/Materials/Node/Blocks/customBlock.js.map +1 -1
- package/Materials/Node/Blocks/desaturateBlock.js.map +1 -1
- package/Materials/Node/Blocks/distanceBlock.js.map +1 -1
- package/Materials/Node/Blocks/divideBlock.js.map +1 -1
- package/Materials/Node/Blocks/dotBlock.js.map +1 -1
- package/Materials/Node/Blocks/elbowBlock.js.map +1 -1
- package/Materials/Node/Blocks/fresnelBlock.js.map +1 -1
- package/Materials/Node/Blocks/gradientBlock.js.map +1 -1
- package/Materials/Node/Blocks/lengthBlock.js.map +1 -1
- package/Materials/Node/Blocks/lerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixBuilderBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixDeterminantBlock.js.map +1 -1
- package/Materials/Node/Blocks/matrixTransposeBlock.js.map +1 -1
- package/Materials/Node/Blocks/maxBlock.js.map +1 -1
- package/Materials/Node/Blocks/meshAttributeExistsBlock.js.map +1 -1
- package/Materials/Node/Blocks/minBlock.js.map +1 -1
- package/Materials/Node/Blocks/modBlock.js.map +1 -1
- package/Materials/Node/Blocks/multiplyBlock.js.map +1 -1
- package/Materials/Node/Blocks/nLerpBlock.js.map +1 -1
- package/Materials/Node/Blocks/negateBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalBlendBlock.js.map +1 -1
- package/Materials/Node/Blocks/normalizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/oneMinusBlock.js.map +1 -1
- package/Materials/Node/Blocks/posterizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/powBlock.js.map +1 -1
- package/Materials/Node/Blocks/randomNumberBlock.js.map +1 -1
- package/Materials/Node/Blocks/reciprocalBlock.js.map +1 -1
- package/Materials/Node/Blocks/reflectBlock.js.map +1 -1
- package/Materials/Node/Blocks/refractBlock.js.map +1 -1
- package/Materials/Node/Blocks/remapBlock.js.map +1 -1
- package/Materials/Node/Blocks/replaceColorBlock.js.map +1 -1
- package/Materials/Node/Blocks/rotate2dBlock.js.map +1 -1
- package/Materials/Node/Blocks/scaleBlock.js.map +1 -1
- package/Materials/Node/Blocks/simplexPerlin3DBlock.js.map +1 -1
- package/Materials/Node/Blocks/smoothStepBlock.js.map +1 -1
- package/Materials/Node/Blocks/stepBlock.js.map +1 -1
- package/Materials/Node/Blocks/subtractBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/Blocks/trigonometryBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorMergerBlock.js.map +1 -1
- package/Materials/Node/Blocks/vectorSplitterBlock.js.map +1 -1
- package/Materials/Node/Blocks/viewDirectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/voronoiNoiseBlock.js.map +1 -1
- package/Materials/Node/Blocks/waveBlock.js.map +1 -1
- package/Materials/Node/Blocks/worleyNoise3DBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialConnectionPointCustomObject.js.map +1 -1
- package/Materials/PBR/pbrAnisotropicConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBRDFConfiguration.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrClearCoatConfiguration.js.map +1 -1
- package/Materials/PBR/pbrIridescenceConfiguration.js.map +1 -1
- package/Materials/PBR/pbrMaterial.js.map +1 -1
- package/Materials/PBR/pbrMetallicRoughnessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSheenConfiguration.js.map +1 -1
- package/Materials/PBR/pbrSpecularGlossinessMaterial.js.map +1 -1
- package/Materials/PBR/pbrSubSurfaceConfiguration.js.map +1 -1
- package/Materials/Textures/MultiviewRenderTarget.js.map +1 -1
- package/Materials/Textures/Procedurals/customProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/noiseProceduralTexture.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/colorGradingTexture.js.map +1 -1
- package/Materials/Textures/cubeTexture.js.map +1 -1
- package/Materials/Textures/dynamicTexture.js.map +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js +1 -1
- package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
- package/Materials/Textures/hdrCubeTexture.js.map +1 -1
- package/Materials/Textures/htmlElementTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/mirrorTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/prePassRenderTarget.js.map +1 -1
- package/Materials/Textures/rawCubeTexture.js.map +1 -1
- package/Materials/Textures/refractionTexture.js.map +1 -1
- package/Materials/Textures/renderTargetTexture.js.map +1 -1
- package/Materials/Textures/texture.js.map +1 -1
- package/Materials/Textures/thinRenderTargetTexture.js.map +1 -1
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/material.decalMapConfiguration.js.map +1 -1
- package/Materials/material.detailMapConfiguration.js.map +1 -1
- package/Materials/materialHelper.d.ts +2 -2
- package/Materials/materialHelper.js.map +1 -1
- package/Materials/meshDebugPluginMaterial.js.map +1 -1
- package/Materials/multiMaterial.js.map +1 -1
- package/Materials/pushMaterial.js.map +1 -1
- package/Materials/shaderMaterial.js.map +1 -1
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineMesh.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineRibbonMesh.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBaseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateLinearBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnFacesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVerticesBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateOnVolumeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Instances/instantiateRadialBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/alignBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationXBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationYBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/rotationZBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/scalingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Matrices/translationBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setColorsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setMaterialIDBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setPositionsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setTangentsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Set/setUVsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/boxBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/capsuleBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/cylinderBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/discBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/gridBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/icoSphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/meshBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/nullBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/planeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/sphereBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Sources/torusBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Teleport/teleportOutBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/boundingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/computeNormalsBlock.js.map +1 -1
- package/Meshes/Node/Blocks/conditionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/debugBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryArcTan2Block.js.map +1 -1
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCollectionBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCrossBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryCurveBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryDesaturateBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryDistanceBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryDotBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryElbowBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInfoBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryInputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryLengthBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryLerpBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryModBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryNLerpBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOutputBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryPosterizeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryPowBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryReplaceColorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryRotate2dBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometrySmoothStepBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryStepBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTransformBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/intFloatConverterBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mapRangeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mappingBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mathBlock.js.map +1 -1
- package/Meshes/Node/Blocks/matrixComposeBlock.js.map +1 -1
- package/Meshes/Node/Blocks/mergeGeometryBlock.js.map +1 -1
- package/Meshes/Node/Blocks/noiseBlock.js.map +1 -1
- package/Meshes/Node/Blocks/normalizeVectorBlock.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Meshes/Node/Blocks/vectorConverterBlock.js.map +1 -1
- package/Meshes/WebGL/webGLDataBuffer.js.map +1 -1
- package/Meshes/WebGPU/webgpuDataBuffer.js.map +1 -1
- package/Meshes/abstractMesh.js.map +1 -1
- package/Meshes/geodesicMesh.js.map +1 -1
- package/Meshes/goldbergMesh.js.map +1 -1
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/instancedMesh.js.map +1 -1
- package/Meshes/linesMesh.js.map +1 -1
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/trailMesh.js.map +1 -1
- package/Meshes/transformNode.js.map +1 -1
- package/Misc/assetsManager.js.map +1 -1
- package/Misc/depthReducer.js.map +1 -1
- package/Misc/sceneOptimizer.js.map +1 -1
- package/Misc/smartArray.js.map +1 -1
- package/Misc/workerPool.js.map +1 -1
- package/Particles/EmitterTypes/cylinderParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Physics/physicsRaycastResult.js.map +1 -1
- package/Physics/proximityCastResult.js.map +1 -1
- package/Physics/v1/physicsJoint.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaRenderingPipeline.js.map +1 -1
- package/PostProcesses/anaglyphPostProcess.js.map +1 -1
- package/PostProcesses/blackAndWhitePostProcess.js.map +1 -1
- package/PostProcesses/bloomMergePostProcess.js.map +1 -1
- package/PostProcesses/blurPostProcess.js.map +1 -1
- package/PostProcesses/chromaticAberrationPostProcess.js.map +1 -1
- package/PostProcesses/circleOfConfusionPostProcess.js.map +1 -1
- package/PostProcesses/colorCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/convolutionPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldBlurPostProcess.js.map +1 -1
- package/PostProcesses/depthOfFieldMergePostProcess.js.map +1 -1
- package/PostProcesses/displayPassPostProcess.js.map +1 -1
- package/PostProcesses/extractHighlightsPostProcess.js.map +1 -1
- package/PostProcesses/filterPostProcess.js.map +1 -1
- package/PostProcesses/fxaaPostProcess.js.map +1 -1
- package/PostProcesses/grainPostProcess.js.map +1 -1
- package/PostProcesses/highlightsPostProcess.js.map +1 -1
- package/PostProcesses/imageProcessingPostProcess.js.map +1 -1
- package/PostProcesses/motionBlurPostProcess.js.map +1 -1
- package/PostProcesses/passPostProcess.js.map +1 -1
- package/PostProcesses/refractionPostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceCurvaturePostProcess.js.map +1 -1
- package/PostProcesses/screenSpaceReflectionPostProcess.js.map +1 -1
- package/PostProcesses/sharpenPostProcess.js.map +1 -1
- package/PostProcesses/stereoscopicInterlacePostProcess.js.map +1 -1
- package/PostProcesses/subSurfaceScatteringPostProcess.js.map +1 -1
- package/PostProcesses/tonemapPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/PostProcesses/vrDistortionCorrectionPostProcess.js.map +1 -1
- package/PostProcesses/vrMultiviewToSingleviewPostProcess.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -1
- package/Rendering/edgesRenderer.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectCustomParticles.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
- package/Rendering/reflectiveShadowMap.js.map +1 -1
- package/Sprites/sprite.js.map +1 -1
- package/Sprites/spritePackedManager.js.map +1 -1
- package/XR/features/Layers/WebXRCompositionLayer.js.map +1 -1
- package/XR/features/Layers/WebXRProjectionLayer.js.map +1 -1
- package/XR/features/WebXRAnchorSystem.js.map +1 -1
- package/XR/features/WebXRBackgroundRemover.js.map +1 -1
- package/XR/features/WebXRControllerMovement.js.map +1 -1
- package/XR/features/WebXRControllerPhysics.js.map +1 -1
- package/XR/features/WebXRControllerPointerSelection.js.map +1 -1
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/features/WebXRDOMOverlay.js.map +1 -1
- package/XR/features/WebXRDepthSensing.js.map +1 -1
- package/XR/features/WebXREyeTracking.js.map +1 -1
- package/XR/features/WebXRFeaturePointSystem.js.map +1 -1
- package/XR/features/WebXRHandTracking.js.map +1 -1
- package/XR/features/WebXRHitTest.js.map +1 -1
- package/XR/features/WebXRHitTestLegacy.js.map +1 -1
- package/XR/features/WebXRImageTracking.js.map +1 -1
- package/XR/features/WebXRLayers.js.map +1 -1
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRMeshDetector.js.map +1 -1
- package/XR/features/WebXRNearInteraction.js.map +1 -1
- package/XR/features/WebXRPlaneDetector.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.js.map +1 -1
- package/XR/features/WebXRWalkingLocomotion.js.map +1 -1
- package/XR/motionController/webXRProfiledMotionController.js.map +1 -1
- package/XR/native/nativeXRRenderTarget.js.map +1 -1
- package/XR/webXRCamera.js.map +1 -1
- package/XR/webXRWebGLLayer.js.map +1 -1
- package/assets/Draco/draco_wasm_wrapper.js +115 -115
- package/package.json +1 -1
- package/scene.js.map +1 -1
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,E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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/**\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 * 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);\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 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 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 _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 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 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 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 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 this.excludedMeshes.forEach((mesh: AbstractMesh) => {\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 this.includedOnlyMeshes.forEach((mesh: AbstractMesh) => {\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"]}
|
|
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;AAEvE;;;;GAIG;AACH,MAAM,OAAgB,KAAM,SAAQ,IAAI;IA0HpC;;;OAGG;IAEH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD;;;OAGG;IACH,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,oBAAoB,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,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ACxF;;GAEG;AACoB,iCAA2B,GAAG,cAAc,CAAC,2BAA2B,AAA7C,CAA8C;AAChG;;GAEG;AACoB,qCAA+B,GAAG,cAAc,CAAC,+BAA+B,AAAjD,CAAkD;AACxG;;GAEG;AACoB,+BAAyB,GAAG,cAAc,CAAC,yBAAyB,AAA3C,CAA4C;AAC5F;;GAEG;AACoB,6BAAuB,GAAG,cAAc,CAAC,uBAAuB,AAAzC,CAA0C;AAExF,yBAAyB;AACzB;;GAEG;AACoB,4BAAsB,GAAG,cAAc,CAAC,sBAAsB,AAAxC,CAAyC;AACtF;;GAEG;AACoB,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;AAM3F;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/**\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 * 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);\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 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 this.excludedMeshes.forEach((mesh: AbstractMesh) => {\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 this.includedOnlyMeshes.forEach((mesh: AbstractMesh) => {\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"]}
|
package/Lights/pointLight.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointLight.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/pointLight.ts"],"names":[],"m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AmB,CAAC,CAAC,CAAC,CAAC;SAC9H;aAAM;YACH,MAAM,CAAC,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC7F;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,2BAA2B,CAAC,OAAY,EAAE,UAAkB;QAC/D,OAAO,CAAC,YAAY,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC;IAC9C,CAAC;CACJ;AA5LG;IADC,SAAS,EAAE;6CAGX","sourcesContent":["import { serialize } from \"../Misc/decorators\";\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 { Light } from \"./light\";\r\nimport { ShadowLight } from \"./shadowLight\";\r\nimport type { Effect } from \"../Materials/effect\";\r\n\r\nNode.AddNodeConstructor(\"Light_Type_0\", (name, scene) => {\r\n return () => new PointLight(name, Vector3.Zero(), scene);\r\n});\r\n\r\n/**\r\n * A point light is a light defined by an unique point in world space.\r\n * The light is emitted in every direction from this point.\r\n * A good example of a point light is a standard light bulb.\r\n * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n */\r\nexport class PointLight extends ShadowLight {\r\n private _shadowAngle = Math.PI / 2;\r\n /**\r\n * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n * This specifies what angle the shadow will use to be created.\r\n *\r\n * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.\r\n */\r\n @serialize()\r\n public get shadowAngle(): number {\r\n return this._shadowAngle;\r\n }\r\n /**\r\n * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n * This specifies what angle the shadow will use to be created.\r\n *\r\n * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.\r\n */\r\n public set shadowAngle(value: number) {\r\n this._shadowAngle = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n /**\r\n * Gets the direction if it has been set.\r\n * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n */\r\n public get direction(): Vector3 {\r\n return this._direction;\r\n }\r\n\r\n /**\r\n * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n */\r\n public set direction(value: Vector3) {\r\n const previousNeedCube = this.needCube();\r\n this._direction = value;\r\n if (this.needCube() !== previousNeedCube && 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.recreateShadowMap();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.\r\n * A PointLight emits the light in every direction.\r\n * It can cast shadows.\r\n * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :\r\n * ```javascript\r\n * var pointLight = new PointLight(\"pl\", camera.position, scene);\r\n * ```\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 point light in the scene\r\n * @param scene The scene the lights belongs to\r\n */\r\n constructor(name: string, position: Vector3, scene?: Scene) {\r\n super(name, scene);\r\n this.position = position;\r\n }\r\n\r\n /**\r\n * Returns the string \"PointLight\"\r\n * @returns the class name\r\n */\r\n public getClassName(): string {\r\n return \"PointLight\";\r\n }\r\n\r\n /**\r\n * Returns the integer 0.\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n public getTypeID(): number {\r\n return Light.LIGHTTYPEID_POINTLIGHT;\r\n }\r\n\r\n /**\r\n * Specifies whether or not the shadowmap should be a cube texture.\r\n * @returns true if the shadowmap needs to be a cube texture.\r\n */\r\n public needCube(): boolean {\r\n return !this.direction;\r\n }\r\n\r\n /**\r\n * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).\r\n * @param faceIndex The index of the face we are computed the direction to generate shadow\r\n * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true\r\n */\r\n public getShadowDirection(faceIndex?: number): Vector3 {\r\n if (this.direction) {\r\n return super.getShadowDirection(faceIndex);\r\n } else {\r\n switch (faceIndex) {\r\n case 0:\r\n return new Vector3(1.0, 0.0, 0.0);\r\n case 1:\r\n return new Vector3(-1.0, 0.0, 0.0);\r\n case 2:\r\n return new Vector3(0.0, -1.0, 0.0);\r\n case 3:\r\n return new Vector3(0.0, 1.0, 0.0);\r\n case 4:\r\n return new Vector3(0.0, 0.0, 1.0);\r\n case 5:\r\n return new Vector3(0.0, 0.0, -1.0);\r\n }\r\n }\r\n\r\n return Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Sets the passed matrix \"matrix\" as a left-handed perspective projection matrix with the following settings :\r\n * - fov = PI / 2\r\n * - aspect ratio : 1.0\r\n * - z-near and far equal to the active camera minZ and maxZ.\r\n * Returns the PointLight.\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 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 this.shadowAngle,\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 _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(\"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 /**\r\n * Sets the passed Effect \"effect\" with the PointLight transformed position (or position, if none) and passed name (string).\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 point light\r\n */\r\n public transferToEffect(effect: Effect, lightIndex: string): PointLight {\r\n if (this.computeTransformedInformation()) {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);\r\n } else {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.position.x, this.position.y, this.position.z, 0, lightIndex);\r\n }\r\n\r\n this._uniformBuffer.updateFloat4(\"vLightFalloff\", this.range, this._inverseSquaredRange, 0, 0, lightIndex);\r\n return this;\r\n }\r\n\r\n public transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string) {\r\n if (this.computeTransformedInformation()) {\r\n effect.setFloat3(lightDataUniformName, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z);\r\n } else {\r\n effect.setFloat3(lightDataUniformName, this.position.x, this.position.y, this.position.z);\r\n }\r\n\r\n return this;\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[\"POINTLIGHT\" + lightIndex] = true;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"pointLight.js","sourceR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AI,CAAC,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;SAC9H;aAAM;YACH,MAAM,CAAC,SAAS,CAAC,oBAAoB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAC7F;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;OAIG;IACI,2BAA2B,CAAC,OAAY,EAAE,UAAkB;QAC/D,OAAO,CAAC,YAAY,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC;IAC9C,CAAC;CACJ;AA5LG;IADC,SAAS,EAAE;6CAGX","sourcesContent":["import { serialize } from \"../Misc/decorators\";\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 { Light } from \"./light\";\r\nimport { ShadowLight } from \"./shadowLight\";\r\nimport type { Effect } from \"../Materials/effect\";\r\n\r\nNode.AddNodeConstructor(\"Light_Type_0\", (name, scene) => {\r\n return () => new PointLight(name, Vector3.Zero(), scene);\r\n});\r\n\r\n/**\r\n * A point light is a light defined by an unique point in world space.\r\n * The light is emitted in every direction from this point.\r\n * A good example of a point light is a standard light bulb.\r\n * Documentation: https://doc.babylonjs.com/features/featuresDeepDive/lights/lights_introduction\r\n */\r\nexport class PointLight extends ShadowLight {\r\n private _shadowAngle = Math.PI / 2;\r\n /**\r\n * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n * This specifies what angle the shadow will use to be created.\r\n *\r\n * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.\r\n */\r\n @serialize()\r\n public get shadowAngle(): number {\r\n return this._shadowAngle;\r\n }\r\n /**\r\n * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n * This specifies what angle the shadow will use to be created.\r\n *\r\n * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.\r\n */\r\n public set shadowAngle(value: number) {\r\n this._shadowAngle = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n /**\r\n * Gets the direction if it has been set.\r\n * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n */\r\n public override get direction(): Vector3 {\r\n return this._direction;\r\n }\r\n\r\n /**\r\n * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback\r\n */\r\n public override set direction(value: Vector3) {\r\n const previousNeedCube = this.needCube();\r\n this._direction = value;\r\n if (this.needCube() !== previousNeedCube && 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.recreateShadowMap();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.\r\n * A PointLight emits the light in every direction.\r\n * It can cast shadows.\r\n * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :\r\n * ```javascript\r\n * var pointLight = new PointLight(\"pl\", camera.position, scene);\r\n * ```\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 point light in the scene\r\n * @param scene The scene the lights belongs to\r\n */\r\n constructor(name: string, position: Vector3, scene?: Scene) {\r\n super(name, scene);\r\n this.position = position;\r\n }\r\n\r\n /**\r\n * Returns the string \"PointLight\"\r\n * @returns the class name\r\n */\r\n public override getClassName(): string {\r\n return \"PointLight\";\r\n }\r\n\r\n /**\r\n * Returns the integer 0.\r\n * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x\r\n */\r\n public override getTypeID(): number {\r\n return Light.LIGHTTYPEID_POINTLIGHT;\r\n }\r\n\r\n /**\r\n * Specifies whether or not the shadowmap should be a cube texture.\r\n * @returns true if the shadowmap needs to be a cube texture.\r\n */\r\n public override needCube(): boolean {\r\n return !this.direction;\r\n }\r\n\r\n /**\r\n * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).\r\n * @param faceIndex The index of the face we are computed the direction to generate shadow\r\n * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true\r\n */\r\n public override getShadowDirection(faceIndex?: number): Vector3 {\r\n if (this.direction) {\r\n return super.getShadowDirection(faceIndex);\r\n } else {\r\n switch (faceIndex) {\r\n case 0:\r\n return new Vector3(1.0, 0.0, 0.0);\r\n case 1:\r\n return new Vector3(-1.0, 0.0, 0.0);\r\n case 2:\r\n return new Vector3(0.0, -1.0, 0.0);\r\n case 3:\r\n return new Vector3(0.0, 1.0, 0.0);\r\n case 4:\r\n return new Vector3(0.0, 0.0, 1.0);\r\n case 5:\r\n return new Vector3(0.0, 0.0, -1.0);\r\n }\r\n }\r\n\r\n return Vector3.Zero();\r\n }\r\n\r\n /**\r\n * Sets the passed matrix \"matrix\" as a left-handed perspective projection matrix with the following settings :\r\n * - fov = PI / 2\r\n * - aspect ratio : 1.0\r\n * - z-near and far equal to the active camera minZ and maxZ.\r\n * Returns the PointLight.\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 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 this.shadowAngle,\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 _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(\"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 /**\r\n * Sets the passed Effect \"effect\" with the PointLight transformed position (or position, if none) and passed name (string).\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 point light\r\n */\r\n public transferToEffect(effect: Effect, lightIndex: string): PointLight {\r\n if (this.computeTransformedInformation()) {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);\r\n } else {\r\n this._uniformBuffer.updateFloat4(\"vLightData\", this.position.x, this.position.y, this.position.z, 0, lightIndex);\r\n }\r\n\r\n this._uniformBuffer.updateFloat4(\"vLightFalloff\", this.range, this._inverseSquaredRange, 0, 0, lightIndex);\r\n return this;\r\n }\r\n\r\n public transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string) {\r\n if (this.computeTransformedInformation()) {\r\n effect.setFloat3(lightDataUniformName, this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z);\r\n } else {\r\n effect.setFloat3(lightDataUniformName, this.position.x, this.position.y, this.position.z);\r\n }\r\n\r\n return this;\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[\"POINTLIGHT\" + lightIndex] = true;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AE;YAC7D,cAAc,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,kDAAkD;SACzF;QAED,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,aAAa,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAEpD,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAEjF,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACI,mBAAmB,CAAC,UAAmB,EAAE,UAAgC;QAC5E,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;QAEzG,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;CACJ;AAlTG;IADC,kBAAkB,EAAE;2CAGpB;AAkBD;IADC,kBAAkB,EAAE;4CAGpB;AAcD;IADC,SAAS,EAAE;6CAGX;AAcD;IADC,SAAS,EAAE;6CAGX","sourcesContent":["import { serialize, serializeAsVector3 } from \"../Misc/decorators\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Matrix, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Light } from \"./light\";\r\nimport { Axis } from \"../Maths/math.axis\";\r\nimport type { Nullable } from \"core/types\";\r\n/**\r\n * Interface describing all the common properties and methods a shadow light needs to implement.\r\n * This helps both the shadow generator and materials to generate the corresponding shadow maps\r\n * as well as binding the different shadow properties to the effects.\r\n */\r\nexport interface IShadowLight extends Light {\r\n /**\r\n * The light id in the scene (used in scene.getLightById for instance)\r\n */\r\n id: string;\r\n /**\r\n * The position the shadow will be casted from.\r\n */\r\n position: Vector3;\r\n /**\r\n * In 2d mode (needCube being false), the direction used to cast the shadow.\r\n */\r\n direction: Vector3;\r\n /**\r\n * The transformed position. Position of the light in world space taking parenting in account.\r\n */\r\n transformedPosition: Vector3;\r\n /**\r\n * The transformed direction. Direction of the light in world space taking parenting in account.\r\n */\r\n transformedDirection: Vector3;\r\n /**\r\n * The friendly name of the light in the scene.\r\n */\r\n name: string;\r\n /**\r\n * Defines the shadow projection clipping minimum z value.\r\n */\r\n shadowMinZ: number;\r\n /**\r\n * Defines the shadow projection clipping maximum z value.\r\n */\r\n shadowMaxZ: number;\r\n\r\n /**\r\n * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light\r\n * @returns true if the information has been computed, false if it does not need to (no parenting)\r\n */\r\n computeTransformedInformation(): boolean;\r\n\r\n /**\r\n * Gets the scene the light belongs to.\r\n * @returns The scene\r\n */\r\n getScene(): Scene;\r\n\r\n /**\r\n * Callback defining a custom Projection Matrix Builder.\r\n * This can be used to override the default projection matrix computation.\r\n */\r\n customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;\r\n\r\n /**\r\n * Sets the shadow projection matrix in parameter to the generated projection matrix.\r\n * @param matrix The matrix to update with the projection information\r\n * @param viewMatrix The transform matrix of the light\r\n * @param renderList The list of mesh to render in the map\r\n * @returns The current light\r\n */\r\n setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;\r\n\r\n /**\r\n * Gets the current depth scale used in ESM.\r\n * @returns The scale\r\n */\r\n getDepthScale(): number;\r\n\r\n /**\r\n * Returns whether or not the shadow generation require a cube texture or a 2d texture.\r\n * @returns true if a cube texture needs to be use\r\n */\r\n needCube(): boolean;\r\n\r\n /**\r\n * Detects if the projection matrix requires to be recomputed this frame.\r\n * @returns true if it requires to be recomputed otherwise, false.\r\n */\r\n needProjectionMatrixCompute(): boolean;\r\n\r\n /**\r\n * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.\r\n */\r\n forceProjectionMatrixCompute(): void;\r\n\r\n /**\r\n * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.\r\n * @param faceIndex The index of the face we are computed the direction to generate shadow\r\n * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true\r\n */\r\n getShadowDirection(faceIndex?: number): Vector3;\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 getDepthMinZ(activeCamera: Camera): number;\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 getDepthMaxZ(activeCamera: Camera): number;\r\n}\r\n\r\n/**\r\n * Base implementation IShadowLight\r\n * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.\r\n */\r\nexport abstract class ShadowLight extends Light implements IShadowLight {\r\n protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;\r\n\r\n protected _position: Vector3;\r\n protected _setPosition(value: Vector3) {\r\n this._position = value;\r\n }\r\n /**\r\n * Sets the position the shadow will be casted from. Also use as the light position for both\r\n * point and spot lights.\r\n */\r\n @serializeAsVector3()\r\n public get position(): Vector3 {\r\n return this._position;\r\n }\r\n /**\r\n * Sets the position the shadow will be casted from. Also use as the light position for both\r\n * point and spot lights.\r\n */\r\n public set position(value: Vector3) {\r\n this._setPosition(value);\r\n }\r\n\r\n protected _direction: Vector3;\r\n protected _setDirection(value: Vector3) {\r\n this._direction = value;\r\n }\r\n /**\r\n * In 2d mode (needCube being false), gets the direction used to cast the shadow.\r\n * Also use as the light direction on spot and directional lights.\r\n */\r\n @serializeAsVector3()\r\n public get direction(): Vector3 {\r\n return this._direction;\r\n }\r\n /**\r\n * In 2d mode (needCube being false), sets the direction used to cast the shadow.\r\n * Also use as the light direction on spot and directional lights.\r\n */\r\n public set direction(value: Vector3) {\r\n this._setDirection(value);\r\n }\r\n\r\n protected _shadowMinZ: number;\r\n /**\r\n * Gets the shadow projection clipping minimum z value.\r\n */\r\n @serialize()\r\n public get shadowMinZ(): number {\r\n return this._shadowMinZ;\r\n }\r\n /**\r\n * Sets the shadow projection clipping minimum z value.\r\n */\r\n public set shadowMinZ(value: number) {\r\n this._shadowMinZ = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n protected _shadowMaxZ: number;\r\n /**\r\n * Sets the shadow projection clipping maximum z value.\r\n */\r\n @serialize()\r\n public get shadowMaxZ(): number {\r\n return this._shadowMaxZ;\r\n }\r\n /**\r\n * Gets the shadow projection clipping maximum z value.\r\n */\r\n public set shadowMaxZ(value: number) {\r\n this._shadowMaxZ = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n /**\r\n * Callback defining a custom Projection Matrix Builder.\r\n * This can be used to override the default projection matrix computation.\r\n */\r\n public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;\r\n\r\n /**\r\n * The transformed position. Position of the light in world space taking parenting in account. Needs to be computed by calling computeTransformedInformation.\r\n */\r\n public transformedPosition: Vector3;\r\n\r\n /**\r\n * The transformed direction. Direction of the light in world space taking parenting in account.\r\n */\r\n public transformedDirection: Vector3;\r\n\r\n private _needProjectionMatrixCompute: boolean = true;\r\n\r\n /**\r\n * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light\r\n * @returns true if the information has been computed, false if it does not need to (no parenting)\r\n */\r\n public computeTransformedInformation(): boolean {\r\n if (this.parent && this.parent.getWorldMatrix) {\r\n if (!this.transformedPosition) {\r\n this.transformedPosition = Vector3.Zero();\r\n }\r\n Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);\r\n\r\n // In case the direction is present.\r\n if (this.direction) {\r\n if (!this.transformedDirection) {\r\n this.transformedDirection = Vector3.Zero();\r\n }\r\n Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Return the depth scale used for the shadow map.\r\n * @returns the depth scale.\r\n */\r\n public getDepthScale(): number {\r\n return 50.0;\r\n }\r\n\r\n /**\r\n * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.\r\n * @param faceIndex The index of the face we are computed the direction to generate shadow\r\n * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getShadowDirection(faceIndex?: number): Vector3 {\r\n return this.transformedDirection ? this.transformedDirection : this.direction;\r\n }\r\n\r\n /**\r\n * If computeTransformedInformation has been called, returns the ShadowLight absolute position in the world. Otherwise, returns the local position.\r\n * @returns the position vector in world space\r\n */\r\n public getAbsolutePosition(): Vector3 {\r\n return this.transformedPosition ? this.transformedPosition : this.position;\r\n }\r\n\r\n /**\r\n * Sets the ShadowLight direction toward the passed target.\r\n * @param target The point to target in local space\r\n * @returns the updated ShadowLight direction\r\n */\r\n public setDirectionToTarget(target: Vector3): Vector3 {\r\n this.direction = Vector3.Normalize(target.subtract(this.position));\r\n return this.direction;\r\n }\r\n\r\n /**\r\n * Returns the light rotation in euler definition.\r\n * @returns the x y z rotation in local space.\r\n */\r\n public getRotation(): Vector3 {\r\n this.direction.normalize();\r\n const xaxis = Vector3.Cross(this.direction, Axis.Y);\r\n const yaxis = Vector3.Cross(xaxis, this.direction);\r\n return Vector3.RotationFromAxis(xaxis, yaxis, this.direction);\r\n }\r\n\r\n /**\r\n * Returns whether or not the shadow generation require a cube texture or a 2d texture.\r\n * @returns true if a cube texture needs to be use\r\n */\r\n public needCube(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Detects if the projection matrix requires to be recomputed this frame.\r\n * @returns true if it requires to be recomputed otherwise, false.\r\n */\r\n public needProjectionMatrixCompute(): boolean {\r\n return this._needProjectionMatrixCompute;\r\n }\r\n\r\n /**\r\n * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.\r\n */\r\n public forceProjectionMatrixCompute(): void {\r\n this._needProjectionMatrixCompute = true;\r\n }\r\n\r\n /** @internal */\r\n public _initCache() {\r\n super._initCache();\r\n\r\n this._cache.position = Vector3.Zero();\r\n }\r\n\r\n /** @internal */\r\n public _isSynchronized(): boolean {\r\n if (!this._cache.position.equals(this.position)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Computes the world matrix of the node\r\n * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch\r\n * @returns the world matrix\r\n */\r\n public computeWorldMatrix(force?: boolean): Matrix {\r\n if (!force && this.isSynchronized()) {\r\n this._currentRenderId = this.getScene().getRenderId();\r\n return this._worldMatrix;\r\n }\r\n\r\n this._updateCache();\r\n this._cache.position.copyFrom(this.position);\r\n\r\n if (!this._worldMatrix) {\r\n this._worldMatrix = Matrix.Identity();\r\n }\r\n\r\n Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);\r\n\r\n if (this.parent && this.parent.getWorldMatrix) {\r\n this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);\r\n\r\n this._markSyncedWithParent();\r\n }\r\n\r\n // Cache the determinant\r\n this._worldMatrixDeterminantIsDirty = true;\r\n\r\n return this._worldMatrix;\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 getDepthMinZ(activeCamera: Camera): number {\r\n return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.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 getDepthMaxZ(activeCamera: Camera): number {\r\n return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;\r\n }\r\n\r\n /**\r\n * Sets the shadow projection matrix in parameter to the generated projection matrix.\r\n * @param matrix The matrix to updated with the projection information\r\n * @param viewMatrix The transform matrix of the light\r\n * @param renderList The list of mesh to render in the map\r\n * @returns The current light\r\n */\r\n public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight {\r\n if (this.customProjectionMatrixBuilder) {\r\n this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);\r\n } else {\r\n this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n protected _syncParentEnabledState() {\r\n super._syncParentEnabledState();\r\n if (!this.parent || !this.parent.getWorldMatrix) {\r\n (this.transformedPosition as any) = null;\r\n (this.transformedDirection as any) = null;\r\n }\r\n }\r\n\r\n protected _viewMatrix: Matrix = Matrix.Identity();\r\n protected _projectionMatrix: Matrix = Matrix.Identity();\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 const lightDirection = TmpVectors.Vector3[0];\r\n\r\n let lightPosition = this.position;\r\n if (this.computeTransformedInformation()) {\r\n lightPosition = this.transformedPosition;\r\n }\r\n\r\n Vector3.NormalizeToRef(this.getShadowDirection(faceIndex), lightDirection);\r\n if (Math.abs(Vector3.Dot(lightDirection, Vector3.Up())) === 1.0) {\r\n lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light\r\n }\r\n\r\n const lightTarget = TmpVectors.Vector3[1];\r\n lightPosition.addToRef(lightDirection, lightTarget);\r\n\r\n Matrix.LookAtLHToRef(lightPosition, lightTarget, Vector3.Up(), this._viewMatrix);\r\n\r\n return this._viewMatrix;\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 this.setShadowProjectionMatrix(this._projectionMatrix, viewMatrix ?? this._viewMatrix, renderList ?? []);\r\n\r\n return this._projectionMatrix;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"shadowLight.js","sourceRoot":"","sources":["../../../../dev/core/src/Lights/shadowLight.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEnE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAiH1C;;;GAGG;AACH,MAAM,OAAgB,WAAY,SAAQ,KAAK;IAA/C;;QA2FY,iCAA4B,GAAY,IAAI,CAAC;QA0L3C,gBAAW,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxC,sBAAiB,GAAW,MAAM,CAAC,QAAQ,EAAE,CAAC;IAwC5D,CAAC;IA1Ta,YAAY,CAAC,KAAc;QACjC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IACD;;;OAGG;IAEH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD;;;OAGG;IACH,IAAW,QAAQ,CAAC,KAAc;QAC9B,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC;IAGS,aAAa,CAAC,KAAc;QAClC,IAAI,CAAC,UAAU,GAAG,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AQ,CAAC;QAClC,IAAI,IAAI,CAAC,6BAA6B,EAAE,EAAE;YACtC,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC;SAC5C;QAED,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,EAAE,cAAc,CAAC,CAAC;QAC3E,IAAI,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,EAAE;YAC7D,cAAc,CAAC,CAAC,GAAG,eAAe,CAAC,CAAC,kDAAkD;SACzF;QAED,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1C,aAAa,CAAC,QAAQ,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAEpD,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAEjF,OAAO,IAAI,CAAC,WAAW,CAAC;IAC5B,CAAC;IAED;;;;;;OAMG;IACa,mBAAmB,CAAC,UAAmB,EAAE,UAAgC;QACrF,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,IAAI,IAAI,CAAC,WAAW,EAAE,UAAU,IAAI,EAAE,CAAC,CAAC;QAEzG,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAClC,CAAC;CACJ;AAlTG;IADC,kBAAkB,EAAE;2CAGpB;AAkBD;IADC,kBAAkB,EAAE;4CAGpB;AAcD;IADC,SAAS,EAAE;6CAGX;AAcD;IADC,SAAS,EAAE;6CAGX","sourcesContent":["import { serialize, serializeAsVector3 } from \"../Misc/decorators\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport type { Scene } from \"../scene\";\r\nimport { Matrix, TmpVectors, Vector3 } from \"../Maths/math.vector\";\r\nimport type { AbstractMesh } from \"../Meshes/abstractMesh\";\r\nimport { Light } from \"./light\";\r\nimport { Axis } from \"../Maths/math.axis\";\r\nimport type { Nullable } from \"core/types\";\r\n/**\r\n * Interface describing all the common properties and methods a shadow light needs to implement.\r\n * This helps both the shadow generator and materials to generate the corresponding shadow maps\r\n * as well as binding the different shadow properties to the effects.\r\n */\r\nexport interface IShadowLight extends Light {\r\n /**\r\n * The light id in the scene (used in scene.getLightById for instance)\r\n */\r\n id: string;\r\n /**\r\n * The position the shadow will be casted from.\r\n */\r\n position: Vector3;\r\n /**\r\n * In 2d mode (needCube being false), the direction used to cast the shadow.\r\n */\r\n direction: Vector3;\r\n /**\r\n * The transformed position. Position of the light in world space taking parenting in account.\r\n */\r\n transformedPosition: Vector3;\r\n /**\r\n * The transformed direction. Direction of the light in world space taking parenting in account.\r\n */\r\n transformedDirection: Vector3;\r\n /**\r\n * The friendly name of the light in the scene.\r\n */\r\n name: string;\r\n /**\r\n * Defines the shadow projection clipping minimum z value.\r\n */\r\n shadowMinZ: number;\r\n /**\r\n * Defines the shadow projection clipping maximum z value.\r\n */\r\n shadowMaxZ: number;\r\n\r\n /**\r\n * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light\r\n * @returns true if the information has been computed, false if it does not need to (no parenting)\r\n */\r\n computeTransformedInformation(): boolean;\r\n\r\n /**\r\n * Gets the scene the light belongs to.\r\n * @returns The scene\r\n */\r\n getScene(): Scene;\r\n\r\n /**\r\n * Callback defining a custom Projection Matrix Builder.\r\n * This can be used to override the default projection matrix computation.\r\n */\r\n customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;\r\n\r\n /**\r\n * Sets the shadow projection matrix in parameter to the generated projection matrix.\r\n * @param matrix The matrix to update with the projection information\r\n * @param viewMatrix The transform matrix of the light\r\n * @param renderList The list of mesh to render in the map\r\n * @returns The current light\r\n */\r\n setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;\r\n\r\n /**\r\n * Gets the current depth scale used in ESM.\r\n * @returns The scale\r\n */\r\n getDepthScale(): number;\r\n\r\n /**\r\n * Returns whether or not the shadow generation require a cube texture or a 2d texture.\r\n * @returns true if a cube texture needs to be use\r\n */\r\n needCube(): boolean;\r\n\r\n /**\r\n * Detects if the projection matrix requires to be recomputed this frame.\r\n * @returns true if it requires to be recomputed otherwise, false.\r\n */\r\n needProjectionMatrixCompute(): boolean;\r\n\r\n /**\r\n * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.\r\n */\r\n forceProjectionMatrixCompute(): void;\r\n\r\n /**\r\n * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.\r\n * @param faceIndex The index of the face we are computed the direction to generate shadow\r\n * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true\r\n */\r\n getShadowDirection(faceIndex?: number): Vector3;\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 getDepthMinZ(activeCamera: Camera): number;\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 getDepthMaxZ(activeCamera: Camera): number;\r\n}\r\n\r\n/**\r\n * Base implementation IShadowLight\r\n * It groups all the common behaviour in order to reduce duplication and better follow the DRY pattern.\r\n */\r\nexport abstract class ShadowLight extends Light implements IShadowLight {\r\n protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;\r\n\r\n protected _position: Vector3;\r\n protected _setPosition(value: Vector3) {\r\n this._position = value;\r\n }\r\n /**\r\n * Sets the position the shadow will be casted from. Also use as the light position for both\r\n * point and spot lights.\r\n */\r\n @serializeAsVector3()\r\n public get position(): Vector3 {\r\n return this._position;\r\n }\r\n /**\r\n * Sets the position the shadow will be casted from. Also use as the light position for both\r\n * point and spot lights.\r\n */\r\n public set position(value: Vector3) {\r\n this._setPosition(value);\r\n }\r\n\r\n protected _direction: Vector3;\r\n protected _setDirection(value: Vector3) {\r\n this._direction = value;\r\n }\r\n /**\r\n * In 2d mode (needCube being false), gets the direction used to cast the shadow.\r\n * Also use as the light direction on spot and directional lights.\r\n */\r\n @serializeAsVector3()\r\n public get direction(): Vector3 {\r\n return this._direction;\r\n }\r\n /**\r\n * In 2d mode (needCube being false), sets the direction used to cast the shadow.\r\n * Also use as the light direction on spot and directional lights.\r\n */\r\n public set direction(value: Vector3) {\r\n this._setDirection(value);\r\n }\r\n\r\n protected _shadowMinZ: number;\r\n /**\r\n * Gets the shadow projection clipping minimum z value.\r\n */\r\n @serialize()\r\n public get shadowMinZ(): number {\r\n return this._shadowMinZ;\r\n }\r\n /**\r\n * Sets the shadow projection clipping minimum z value.\r\n */\r\n public set shadowMinZ(value: number) {\r\n this._shadowMinZ = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n protected _shadowMaxZ: number;\r\n /**\r\n * Sets the shadow projection clipping maximum z value.\r\n */\r\n @serialize()\r\n public get shadowMaxZ(): number {\r\n return this._shadowMaxZ;\r\n }\r\n /**\r\n * Gets the shadow projection clipping maximum z value.\r\n */\r\n public set shadowMaxZ(value: number) {\r\n this._shadowMaxZ = value;\r\n this.forceProjectionMatrixCompute();\r\n }\r\n\r\n /**\r\n * Callback defining a custom Projection Matrix Builder.\r\n * This can be used to override the default projection matrix computation.\r\n */\r\n public customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;\r\n\r\n /**\r\n * The transformed position. Position of the light in world space taking parenting in account. Needs to be computed by calling computeTransformedInformation.\r\n */\r\n public transformedPosition: Vector3;\r\n\r\n /**\r\n * The transformed direction. Direction of the light in world space taking parenting in account.\r\n */\r\n public transformedDirection: Vector3;\r\n\r\n private _needProjectionMatrixCompute: boolean = true;\r\n\r\n /**\r\n * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light\r\n * @returns true if the information has been computed, false if it does not need to (no parenting)\r\n */\r\n public computeTransformedInformation(): boolean {\r\n if (this.parent && this.parent.getWorldMatrix) {\r\n if (!this.transformedPosition) {\r\n this.transformedPosition = Vector3.Zero();\r\n }\r\n Vector3.TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);\r\n\r\n // In case the direction is present.\r\n if (this.direction) {\r\n if (!this.transformedDirection) {\r\n this.transformedDirection = Vector3.Zero();\r\n }\r\n Vector3.TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);\r\n }\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /**\r\n * Return the depth scale used for the shadow map.\r\n * @returns the depth scale.\r\n */\r\n public getDepthScale(): number {\r\n return 50.0;\r\n }\r\n\r\n /**\r\n * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.\r\n * @param faceIndex The index of the face we are computed the direction to generate shadow\r\n * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public getShadowDirection(faceIndex?: number): Vector3 {\r\n return this.transformedDirection ? this.transformedDirection : this.direction;\r\n }\r\n\r\n /**\r\n * If computeTransformedInformation has been called, returns the ShadowLight absolute position in the world. Otherwise, returns the local position.\r\n * @returns the position vector in world space\r\n */\r\n public override getAbsolutePosition(): Vector3 {\r\n return this.transformedPosition ? this.transformedPosition : this.position;\r\n }\r\n\r\n /**\r\n * Sets the ShadowLight direction toward the passed target.\r\n * @param target The point to target in local space\r\n * @returns the updated ShadowLight direction\r\n */\r\n public setDirectionToTarget(target: Vector3): Vector3 {\r\n this.direction = Vector3.Normalize(target.subtract(this.position));\r\n return this.direction;\r\n }\r\n\r\n /**\r\n * Returns the light rotation in euler definition.\r\n * @returns the x y z rotation in local space.\r\n */\r\n public getRotation(): Vector3 {\r\n this.direction.normalize();\r\n const xaxis = Vector3.Cross(this.direction, Axis.Y);\r\n const yaxis = Vector3.Cross(xaxis, this.direction);\r\n return Vector3.RotationFromAxis(xaxis, yaxis, this.direction);\r\n }\r\n\r\n /**\r\n * Returns whether or not the shadow generation require a cube texture or a 2d texture.\r\n * @returns true if a cube texture needs to be use\r\n */\r\n public needCube(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * Detects if the projection matrix requires to be recomputed this frame.\r\n * @returns true if it requires to be recomputed otherwise, false.\r\n */\r\n public needProjectionMatrixCompute(): boolean {\r\n return this._needProjectionMatrixCompute;\r\n }\r\n\r\n /**\r\n * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.\r\n */\r\n public forceProjectionMatrixCompute(): void {\r\n this._needProjectionMatrixCompute = true;\r\n }\r\n\r\n /** @internal */\r\n public override _initCache() {\r\n super._initCache();\r\n\r\n this._cache.position = Vector3.Zero();\r\n }\r\n\r\n /** @internal */\r\n public override _isSynchronized(): boolean {\r\n if (!this._cache.position.equals(this.position)) {\r\n return false;\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Computes the world matrix of the node\r\n * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch\r\n * @returns the world matrix\r\n */\r\n public override computeWorldMatrix(force?: boolean): Matrix {\r\n if (!force && this.isSynchronized()) {\r\n this._currentRenderId = this.getScene().getRenderId();\r\n return this._worldMatrix;\r\n }\r\n\r\n this._updateCache();\r\n this._cache.position.copyFrom(this.position);\r\n\r\n if (!this._worldMatrix) {\r\n this._worldMatrix = Matrix.Identity();\r\n }\r\n\r\n Matrix.TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);\r\n\r\n if (this.parent && this.parent.getWorldMatrix) {\r\n this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);\r\n\r\n this._markSyncedWithParent();\r\n }\r\n\r\n // Cache the determinant\r\n this._worldMatrixDeterminantIsDirty = true;\r\n\r\n return this._worldMatrix;\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 getDepthMinZ(activeCamera: Camera): number {\r\n return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.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 getDepthMaxZ(activeCamera: Camera): number {\r\n return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;\r\n }\r\n\r\n /**\r\n * Sets the shadow projection matrix in parameter to the generated projection matrix.\r\n * @param matrix The matrix to updated with the projection information\r\n * @param viewMatrix The transform matrix of the light\r\n * @param renderList The list of mesh to render in the map\r\n * @returns The current light\r\n */\r\n public setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight {\r\n if (this.customProjectionMatrixBuilder) {\r\n this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);\r\n } else {\r\n this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);\r\n }\r\n return this;\r\n }\r\n\r\n /** @internal */\r\n protected override _syncParentEnabledState() {\r\n super._syncParentEnabledState();\r\n if (!this.parent || !this.parent.getWorldMatrix) {\r\n (this.transformedPosition as any) = null;\r\n (this.transformedDirection as any) = null;\r\n }\r\n }\r\n\r\n protected _viewMatrix: Matrix = Matrix.Identity();\r\n protected _projectionMatrix: Matrix = Matrix.Identity();\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 override getViewMatrix(faceIndex?: number): Nullable<Matrix> {\r\n const lightDirection = TmpVectors.Vector3[0];\r\n\r\n let lightPosition = this.position;\r\n if (this.computeTransformedInformation()) {\r\n lightPosition = this.transformedPosition;\r\n }\r\n\r\n Vector3.NormalizeToRef(this.getShadowDirection(faceIndex), lightDirection);\r\n if (Math.abs(Vector3.Dot(lightDirection, Vector3.Up())) === 1.0) {\r\n lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light\r\n }\r\n\r\n const lightTarget = TmpVectors.Vector3[1];\r\n lightPosition.addToRef(lightDirection, lightTarget);\r\n\r\n Matrix.LookAtLHToRef(lightPosition, lightTarget, Vector3.Up(), this._viewMatrix);\r\n\r\n return this._viewMatrix;\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 override getProjectionMatrix(viewMatrix?: Matrix, renderList?: Array<AbstractMesh>): Nullable<Matrix> {\r\n this.setShadowProjectionMatrix(this._projectionMatrix, viewMatrix ?? this._viewMatrix, renderList ?? []);\r\n\r\n return this._projectionMatrix;\r\n }\r\n}\r\n"]}
|
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;AAIxD,IAAI,CAAC,kBAAkB,CAAC,cAAc,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EA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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\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 /**\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 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 public 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 _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 _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 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(\"projectionLightSampler\" + lightIndex, this.projectionTexture);\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 dispose(): void {\r\n super.dispose();\r\n if (this._projectionTexture) {\r\n this._projectionTexture.dispose();\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 getDepthMinZ(activeCamera: Camera): number {\r\n const engine = this._scene.getEngine();\r\n const minZ = this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;\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 getDepthMaxZ(activeCamera: Camera): number {\r\n const engine = this._scene.getEngine();\r\n const maxZ = this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;\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 }\r\n}\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,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;AAIxD,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,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;AAClF,CAAC,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,OAAO,SAAU,SAAQ,WAAW;IAqBtC;;OAEG;IAEH,IAAW,KAAK;QACZ,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IACD;;OAEG;IACH,IAAW,KAAK,CAAC,KAAa;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC;QAC3C,IAAI,CAAC,sCAAsC,GAAG,IAAI,CAAC;QACnD,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IA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CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7E,CAAC;IAED;;;;OAIG;IACI,2BAA2B,CAAC,OAAY,EAAE,UAAkB;QAC/D,OAAO,CAAC,WAAW,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC;QACzC,OAAO,CAAC,uBAAuB,GAAG,UAAU,CAAC,GAAG,IAAI,CAAC,iBAAiB,IAAI,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9H,CAAC;CACJ;AAzaG;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","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\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 /**\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 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(\"projectionLightSampler\" + lightIndex, this.projectionTexture);\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 }\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: Camera): number {\r\n const engine = this._scene.getEngine();\r\n const minZ = this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;\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: Camera): number {\r\n const engine = this._scene.getEngine();\r\n const maxZ = this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;\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 }\r\n}\r\n"]}
|