@babylonjs/core 6.37.1 → 6.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Behaviors/Meshes/baseSixDofDragBehavior.js +1 -1
- package/Behaviors/Meshes/baseSixDofDragBehavior.js.map +1 -1
- package/Behaviors/Meshes/sixDofDragBehavior.js +26 -6
- package/Behaviors/Meshes/sixDofDragBehavior.js.map +1 -1
- package/Bones/skeleton.js +2 -2
- package/Bones/skeleton.js.map +1 -1
- package/Buffers/buffer.align.js +4 -1
- package/Buffers/buffer.align.js.map +1 -1
- package/Buffers/buffer.d.ts +10 -3
- package/Buffers/buffer.js +34 -5
- package/Buffers/buffer.js.map +1 -1
- package/Engines/Extensions/engine.cubeTexture.d.ts +1 -3
- package/Engines/Extensions/engine.cubeTexture.js +1 -3
- package/Engines/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/Extensions/engine.renderTarget.js +6 -17
- package/Engines/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGL/webGLRenderTargetWrapper.d.ts +11 -0
- package/Engines/WebGL/webGLRenderTargetWrapper.js +27 -0
- package/Engines/WebGL/webGLRenderTargetWrapper.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js +8 -4
- package/Engines/WebGPU/Extensions/engine.cubeTexture.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +3 -0
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/renderTargetWrapper.js +7 -1
- package/Engines/renderTargetWrapper.js.map +1 -1
- package/Engines/thinEngine.d.ts +3 -3
- package/Engines/thinEngine.js +16 -8
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +2 -2
- package/Engines/webgpuEngine.js +7 -12
- package/Engines/webgpuEngine.js.map +1 -1
- package/Gizmos/boundingBoxGizmo.js +1 -1
- package/Gizmos/boundingBoxGizmo.js.map +1 -1
- package/Gizmos/cameraGizmo.d.ts +9 -2
- package/Gizmos/cameraGizmo.js +29 -10
- package/Gizmos/cameraGizmo.js.map +1 -1
- package/Lights/shadowLight.d.ts +2 -2
- package/Lights/shadowLight.js +1 -1
- package/Lights/shadowLight.js.map +1 -1
- package/Materials/Textures/baseTexture.d.ts +1 -1
- package/Materials/Textures/baseTexture.js +1 -1
- package/Materials/Textures/baseTexture.js.map +1 -1
- package/Materials/Textures/internalTexture.js +5 -0
- package/Materials/Textures/internalTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.d.ts +1 -1
- package/Materials/Textures/multiRenderTarget.js +4 -4
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/Textures/videoTexture.js +2 -0
- package/Materials/Textures/videoTexture.js.map +1 -1
- package/Materials/materialPluginManager.d.ts +1 -1
- package/Materials/materialPluginManager.js.map +1 -1
- package/Meshes/Node/Blocks/geometryArcTan2Block.d.ts +30 -0
- package/Meshes/Node/Blocks/geometryArcTan2Block.js +81 -0
- package/Meshes/Node/Blocks/geometryArcTan2Block.js.map +1 -0
- package/Meshes/Node/Blocks/geometryClampBlock.d.ts +33 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js +101 -0
- package/Meshes/Node/Blocks/geometryClampBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryCrossBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/geometryCrossBlock.js +76 -0
- package/Meshes/Node/Blocks/geometryCrossBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryLerpBlock.d.ts +34 -0
- package/Meshes/Node/Blocks/geometryLerpBlock.js +90 -0
- package/Meshes/Node/Blocks/geometryLerpBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryModBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/geometryModBlock.js +82 -0
- package/Meshes/Node/Blocks/geometryModBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryNLerpBlock.d.ts +34 -0
- package/Meshes/Node/Blocks/geometryNLerpBlock.js +96 -0
- package/Meshes/Node/Blocks/geometryNLerpBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryPowBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/geometryPowBlock.js +82 -0
- package/Meshes/Node/Blocks/geometryPowBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometrySmoothStepBlock.d.ts +34 -0
- package/Meshes/Node/Blocks/geometrySmoothStepBlock.js +91 -0
- package/Meshes/Node/Blocks/geometrySmoothStepBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryStepBlock.d.ts +30 -0
- package/Meshes/Node/Blocks/geometryStepBlock.js +84 -0
- package/Meshes/Node/Blocks/geometryStepBlock.js.map +1 -0
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.d.ts +19 -15
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js +37 -17
- package/Meshes/Node/Blocks/geometryTrigonometryBlock.js.map +1 -1
- package/Meshes/Node/index.d.ts +9 -0
- package/Meshes/Node/index.js +9 -0
- package/Meshes/Node/index.js.map +1 -1
- package/Meshes/geometry.js +8 -5
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/thinInstanceMesh.d.ts +1 -1
- package/Meshes/thinInstanceMesh.js +2 -2
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +1 -0
- package/Particles/gpuParticleSystem.js +10 -3
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Rendering/GaussianSplatting/gaussianSplatting.d.ts +6 -0
- package/Rendering/GaussianSplatting/gaussianSplatting.js +124 -39
- package/Rendering/GaussianSplatting/gaussianSplatting.js.map +1 -1
- package/Rendering/GlobalIllumination/giRSM.d.ts +54 -0
- package/Rendering/GlobalIllumination/giRSM.js +54 -0
- package/Rendering/GlobalIllumination/giRSM.js.map +1 -0
- package/Rendering/GlobalIllumination/giRSMManager.d.ts +256 -0
- package/Rendering/GlobalIllumination/giRSMManager.js +715 -0
- package/Rendering/GlobalIllumination/giRSMManager.js.map +1 -0
- package/Rendering/GlobalIllumination/index.d.ts +2 -0
- package/Rendering/GlobalIllumination/index.js +3 -0
- package/Rendering/GlobalIllumination/index.js.map +1 -0
- package/Rendering/fluidRenderer/fluidRenderer.js +20 -1
- package/Rendering/fluidRenderer/fluidRenderer.js.map +1 -1
- package/Rendering/index.d.ts +2 -0
- package/Rendering/index.js +2 -0
- package/Rendering/index.js.map +1 -1
- package/Rendering/prePassRendererSceneComponent.js +1 -4
- package/Rendering/prePassRendererSceneComponent.js.map +1 -1
- package/Rendering/reflectiveShadowMap.d.ts +152 -0
- package/Rendering/reflectiveShadowMap.js +389 -0
- package/Rendering/reflectiveShadowMap.js.map +1 -0
- package/Shaders/bilateralBlur.fragment.d.ts +5 -0
- package/Shaders/bilateralBlur.fragment.js +20 -0
- package/Shaders/bilateralBlur.fragment.js.map +1 -0
- package/Shaders/bilateralBlurQuality.fragment.d.ts +5 -0
- package/Shaders/bilateralBlurQuality.fragment.js +20 -0
- package/Shaders/bilateralBlurQuality.fragment.js.map +1 -0
- package/Shaders/rsmFullGlobalIllumination.fragment.d.ts +5 -0
- package/Shaders/rsmFullGlobalIllumination.fragment.js +28 -0
- package/Shaders/rsmFullGlobalIllumination.fragment.js.map +1 -0
- package/Shaders/rsmGlobalIllumination.fragment.d.ts +5 -0
- package/Shaders/rsmGlobalIllumination.fragment.js +33 -0
- package/Shaders/rsmGlobalIllumination.fragment.js.map +1 -0
- package/XR/features/WebXRControllerTeleportation.d.ts +9 -1
- package/XR/features/WebXRControllerTeleportation.js +3 -0
- package/XR/features/WebXRControllerTeleportation.js.map +1 -1
- package/XR/webXRCamera.d.ts +2 -0
- package/XR/webXRCamera.js +2 -0
- package/XR/webXRCamera.js.map +1 -1
- package/package.json +1 -1
- package/scene.js +1 -1
- package/scene.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cameraGizm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C,CAAC,EAAE,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpJ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC;gBACrC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;gBACxB,IAAI,GAAG,WAAW,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpJ,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC,wBAAwB,GAAG,IAAI,CAAC;gBACrC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;aAC3B;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;;AA5ED,wBAAwB;AACT,kBAAM,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport { Matrix } from \"../Maths/math\";\r\nimport { CreateLines } from \"../Meshes/Builders/linesBuilder\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../Events/pointerEvents\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Interface for camera gizmo\r\n */\r\nexport interface ICameraGizmo extends IGizmo {\r\n /** Event that fires each time the gizmo is clicked */\r\n onClickedObservable: Observable<Camera>;\r\n /** A boolean indicating if frustum lines must be rendered */\r\n displayFrustum: boolean;\r\n /** The camera that the gizmo is attached to */\r\n camera: Nullable<Camera>;\r\n /** The material used to render the camera gizmo */\r\n readonly material: StandardMaterial;\r\n}\r\n\r\n/**\r\n * Gizmo that enables viewing a camera\r\n */\r\nexport class CameraGizmo extends Gizmo implements ICameraGizmo {\r\n protected _cameraMesh: Mesh;\r\n protected _cameraLinesMesh: Mesh;\r\n protected _material: StandardMaterial;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n private _gizmoColor?: Color3;\r\n\r\n /**\r\n * Event that fires each time the gizmo is clicked\r\n */\r\n public onClickedObservable = new Observable<Camera>();\r\n\r\n /**\r\n * Creates a CameraGizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n */\r\n constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, gizmoColor?: Color3) {\r\n super(gizmoLayer);\r\n\r\n this._material = new StandardMaterial(\"cameraGizmoMaterial\", this.gizmoLayer.utilityLayerScene);\r\n this._gizmoColor = gizmoColor;\r\n this._material.diffuseColor = gizmoColor ?? new Color3(0.5, 0.5, 0.5);\r\n this._material.specularColor = new Color3(0.1, 0.1, 0.1);\r\n\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (!this._camera) {\r\n return;\r\n }\r\n\r\n this._isHovered = !!(pointerInfo.pickInfo && this._rootMesh.getChildMeshes().indexOf(<Mesh>pointerInfo.pickInfo.pickedMesh) != -1);\r\n if (this._isHovered && pointerInfo.event.button === 0) {\r\n this.onClickedObservable.notifyObservers(this._camera);\r\n }\r\n }, PointerEventTypes.POINTERDOWN);\r\n }\r\n protected _camera: Nullable<Camera> = null;\r\n\r\n /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */\r\n public get displayFrustum() {\r\n return this._cameraLinesMesh.isEnabled();\r\n }\r\n public set displayFrustum(value) {\r\n this._cameraLinesMesh.setEnabled(value);\r\n }\r\n\r\n /**\r\n * The camera that the gizmo is attached to\r\n */\r\n public set camera(camera: Nullable<Camera>) {\r\n this._camera = camera;\r\n this.attachedNode = camera;\r\n if (camera) {\r\n // Create the mesh for the given camera\r\n if (this._cameraMesh) {\r\n this._cameraMesh.dispose();\r\n }\r\n if (this._cameraLinesMesh) {\r\n this._cameraLinesMesh.dispose();\r\n }\r\n this._cameraMesh = CameraGizmo._CreateCameraMesh(this.gizmoLayer.utilityLayerScene);\r\n const linesColor = this._gizmoColor?.toColor4(1) ?? new Color4(1, 1, 1, 1);\r\n this._cameraLinesMesh = CameraGizmo._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene, linesColor);\r\n\r\n this._cameraMesh.getChildMeshes(false).forEach((m) => {\r\n m.material = this._material;\r\n });\r\n this._cameraMesh.parent = this._rootMesh;\r\n\r\n this._cameraLinesMesh.parent = this._rootMesh;\r\n\r\n if (this.gizmoLayer.utilityLayerScene.activeCamera && this.gizmoLayer.utilityLayerScene.activeCamera.maxZ < camera.maxZ * 1.5) {\r\n this.gizmoLayer.utilityLayerScene.activeCamera.maxZ = camera.maxZ * 1.5;\r\n }\r\n\r\n if (!this.attachedNode!.reservedDataStore) {\r\n this.attachedNode!.reservedDataStore = {};\r\n }\r\n this.attachedNode!.reservedDataStore.cameraGizmo = this;\r\n\r\n // Add lighting to the camera gizmo\r\n const gizmoLight = this.gizmoLayer._getSharedGizmoLight();\r\n gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(false));\r\n\r\n this._update();\r\n }\r\n }\r\n\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n /**\r\n * Gets the material used to render the camera gizmo\r\n */\r\n public get material() {\r\n return this._material;\r\n }\r\n /**\r\n * @internal\r\n * Updates the gizmo to match the attached mesh's position/rotation\r\n */\r\n\r\n protected _update() {\r\n super._update();\r\n if (!this._camera) {\r\n return;\r\n }\r\n\r\n // frustum matrix\r\n this._camera.getProjectionMatrix().invertToRef(this._invProjection);\r\n this._cameraLinesMesh.setPivotMatrix(this._invProjection, false);\r\n\r\n this._cameraLinesMesh.scaling.x = 1 / this._rootMesh.scaling.x;\r\n this._cameraLinesMesh.scaling.y = 1 / this._rootMesh.scaling.y;\r\n this._cameraLinesMesh.scaling.z = 1 / this._rootMesh.scaling.z;\r\n\r\n // take care of coordinate system in camera scene to properly display the mesh with the good Y axis orientation in this scene\r\n this._cameraMesh.parent = null;\r\n this._cameraMesh.rotation.y = Math.PI * 0.5 * (this._camera.getScene().useRightHandedSystem ? 1 : -1);\r\n this._cameraMesh.parent = this._rootMesh;\r\n }\r\n\r\n // Static helper methods\r\n private static _Scale = 0.05;\r\n private _invProjection = new Matrix();\r\n\r\n /**\r\n * Disposes of the camera gizmo\r\n */\r\n public dispose() {\r\n this.onClickedObservable.clear();\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n if (this._cameraMesh) {\r\n this._cameraMesh.dispose();\r\n }\r\n if (this._cameraLinesMesh) {\r\n this._cameraLinesMesh.dispose();\r\n }\r\n this._material.dispose();\r\n super.dispose();\r\n }\r\n\r\n private static _CreateCameraMesh(scene: Scene) {\r\n const root = new Mesh(\"rootCameraGizmo\", scene);\r\n\r\n const mesh = new Mesh(root.name, scene);\r\n mesh.parent = root;\r\n\r\n const box = CreateBox(root.name, { width: 1.0, height: 0.8, depth: 0.5 }, scene);\r\n box.parent = mesh;\r\n\r\n const cyl1 = CreateCylinder(root.name, { height: 0.5, diameterTop: 0.8, diameterBottom: 0.8 }, scene);\r\n cyl1.parent = mesh;\r\n cyl1.position.y = 0.3;\r\n cyl1.position.x = -0.6;\r\n cyl1.rotation.x = Math.PI * 0.5;\r\n\r\n const cyl2 = CreateCylinder(root.name, { height: 0.5, diameterTop: 0.6, diameterBottom: 0.6 }, scene);\r\n cyl2.parent = mesh;\r\n cyl2.position.y = 0.5;\r\n cyl2.position.x = 0.4;\r\n cyl2.rotation.x = Math.PI * 0.5;\r\n\r\n const cyl3 = CreateCylinder(root.name, { height: 0.5, diameterTop: 0.5, diameterBottom: 0.5 }, scene);\r\n cyl3.parent = mesh;\r\n cyl3.position.y = 0.0;\r\n cyl3.position.x = 0.6;\r\n cyl3.rotation.z = Math.PI * 0.5;\r\n\r\n root.scaling.scaleInPlace(CameraGizmo._Scale);\r\n mesh.position.x = -0.9;\r\n\r\n return root;\r\n }\r\n\r\n private static _CreateCameraFrustum(scene: Scene, linesColor: Color4) {\r\n const root = new Mesh(\"rootCameraGizmo\", scene);\r\n const mesh = new Mesh(root.name, scene);\r\n mesh.parent = root;\r\n\r\n for (let y = 0; y < 4; y += 2) {\r\n for (let x = 0; x < 4; x += 2) {\r\n let line = CreateLines(\"lines\", { points: [new Vector3(-1 + x, -1 + y, -1), new Vector3(-1 + x, -1 + y, 1)], colors: [linesColor, linesColor] }, scene);\r\n line.parent = mesh;\r\n line.alwaysSelectAsActiveMesh = true;\r\n line.isPickable = false;\r\n line = CreateLines(\"lines\", { points: [new Vector3(-1, -1 + x, -1 + y), new Vector3(1, -1 + x, -1 + y)], colors: [linesColor, linesColor] }, scene);\r\n line.parent = mesh;\r\n line.alwaysSelectAsActiveMesh = true;\r\n line.isPickable = false;\r\n line = CreateLines(\"lines\", { points: [new Vector3(-1 + x, -1, -1 + y), new Vector3(-1 + x, 1, -1 + y)], colors: [linesColor, linesColor] }, scene);\r\n line.parent = mesh;\r\n line.alwaysSelectAsActiveMesh = true;\r\n line.isPickable = false;\r\n }\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U,GAAG,KAAK,CAAC;aAC3B;SACJ;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;;AA5FD,wBAAwB;AACT,kBAAM,GAAG,IAAI,AAAP,CAAQ","sourcesContent":["import type { Nullable } from \"../types\";\r\nimport { Vector3 } from \"../Maths/math.vector\";\r\nimport { Color3, Color4 } from \"../Maths/math.color\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport type { IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { Camera } from \"../Cameras/camera\";\r\nimport { CreateBox } from \"../Meshes/Builders/boxBuilder\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport { Matrix } from \"../Maths/math\";\r\nimport { CreateLines } from \"../Meshes/Builders/linesBuilder\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport { PointerEventTypes } from \"../Events/pointerEvents\";\r\nimport type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Interface for camera gizmo\r\n */\r\nexport interface ICameraGizmo extends IGizmo {\r\n /** Event that fires each time the gizmo is clicked */\r\n onClickedObservable: Observable<Camera>;\r\n /** A boolean indicating if frustum lines must be rendered */\r\n displayFrustum: boolean;\r\n /** The camera that the gizmo is attached to */\r\n camera: Nullable<Camera>;\r\n /** The material used to render the camera gizmo */\r\n readonly material: StandardMaterial;\r\n}\r\n\r\n/**\r\n * Gizmo that enables viewing a camera\r\n */\r\nexport class CameraGizmo extends Gizmo implements ICameraGizmo {\r\n protected _cameraMesh: Mesh;\r\n protected _cameraLinesMesh: Mesh;\r\n protected _material: StandardMaterial;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n private _frustumLinesColor?: Color3;\r\n\r\n /**\r\n * Event that fires each time the gizmo is clicked\r\n */\r\n public onClickedObservable = new Observable<Camera>();\r\n\r\n /**\r\n * Creates a CameraGizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n * @param gizmoColor Camera mesh color. Default is Gray\r\n * @param frustumLinesColor Frustum lines color. Default is White\r\n */\r\n constructor(gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer, gizmoColor?: Color3, frustumLinesColor?: Color3) {\r\n super(gizmoLayer);\r\n\r\n this._material = new StandardMaterial(\"cameraGizmoMaterial\", this.gizmoLayer.utilityLayerScene);\r\n this._frustumLinesColor = frustumLinesColor;\r\n\r\n this._material.diffuseColor = gizmoColor ?? new Color3(0.5, 0.5, 0.5);\r\n this._material.specularColor = new Color3(0.1, 0.1, 0.1);\r\n\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (!this._camera) {\r\n return;\r\n }\r\n\r\n this._isHovered = !!(pointerInfo.pickInfo && this._rootMesh.getChildMeshes().indexOf(<Mesh>pointerInfo.pickInfo.pickedMesh) != -1);\r\n if (this._isHovered && pointerInfo.event.button === 0) {\r\n this.onClickedObservable.notifyObservers(this._camera);\r\n }\r\n }, PointerEventTypes.POINTERDOWN);\r\n }\r\n protected _camera: Nullable<Camera> = null;\r\n\r\n /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */\r\n public get displayFrustum() {\r\n return this._cameraLinesMesh.isEnabled();\r\n }\r\n public set displayFrustum(value) {\r\n this._cameraLinesMesh.setEnabled(value);\r\n }\r\n\r\n /**\r\n * The camera that the gizmo is attached to\r\n */\r\n public set camera(camera: Nullable<Camera>) {\r\n this._camera = camera;\r\n this.attachedNode = camera;\r\n if (camera) {\r\n // Create the mesh for the given camera\r\n if (!this._customMeshSet) {\r\n if (this._cameraMesh) {\r\n this._cameraMesh.dispose();\r\n }\r\n this._cameraMesh = CameraGizmo._CreateCameraMesh(this.gizmoLayer.utilityLayerScene);\r\n\r\n this._cameraMesh.getChildMeshes(false).forEach((m) => {\r\n m.material = this._material;\r\n });\r\n this._cameraMesh.parent = this._rootMesh;\r\n }\r\n\r\n if (this._cameraLinesMesh) {\r\n this._cameraLinesMesh.dispose();\r\n }\r\n const linesColor = this._frustumLinesColor?.toColor4(1) ?? new Color4(1, 1, 1, 1);\r\n this._cameraLinesMesh = CameraGizmo._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene, linesColor);\r\n this._cameraLinesMesh.parent = this._rootMesh;\r\n\r\n if (this.gizmoLayer.utilityLayerScene.activeCamera && this.gizmoLayer.utilityLayerScene.activeCamera.maxZ < camera.maxZ * 1.5) {\r\n this.gizmoLayer.utilityLayerScene.activeCamera.maxZ = camera.maxZ * 1.5;\r\n }\r\n\r\n if (!this.attachedNode!.reservedDataStore) {\r\n this.attachedNode!.reservedDataStore = {};\r\n }\r\n this.attachedNode!.reservedDataStore.cameraGizmo = this;\r\n\r\n // Add lighting to the camera gizmo\r\n const gizmoLight = this.gizmoLayer._getSharedGizmoLight();\r\n gizmoLight.includedOnlyMeshes = gizmoLight.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(false));\r\n\r\n this._update();\r\n }\r\n }\r\n\r\n public get camera() {\r\n return this._camera;\r\n }\r\n\r\n /**\r\n * Gets the material used to render the camera gizmo\r\n */\r\n public get material() {\r\n return this._material;\r\n }\r\n /**\r\n * @internal\r\n * Updates the gizmo to match the attached mesh's position/rotation\r\n */\r\n\r\n protected _update() {\r\n super._update();\r\n if (!this._camera) {\r\n return;\r\n }\r\n\r\n // frustum matrix\r\n this._camera.getProjectionMatrix().invertToRef(this._invProjection);\r\n this._cameraLinesMesh.setPivotMatrix(this._invProjection, false);\r\n\r\n this._cameraLinesMesh.scaling.x = 1 / this._rootMesh.scaling.x;\r\n this._cameraLinesMesh.scaling.y = 1 / this._rootMesh.scaling.y;\r\n this._cameraLinesMesh.scaling.z = 1 / this._rootMesh.scaling.z;\r\n\r\n // take care of coordinate system in camera scene to properly display the mesh with the good Y axis orientation in this scene\r\n this._cameraMesh.parent = null;\r\n this._cameraMesh.rotation.y = Math.PI * 0.5 * (this._camera.getScene().useRightHandedSystem ? 1 : -1);\r\n this._cameraMesh.parent = this._rootMesh;\r\n }\r\n\r\n // Static helper methods\r\n private static _Scale = 0.05;\r\n private _invProjection = new Matrix();\r\n\r\n /**\r\n * Disposes and replaces the current camera mesh in the gizmo with the specified mesh\r\n * @param mesh The mesh to replace the default mesh of the camera gizmo\r\n */\r\n public setCustomMesh(mesh: Mesh) {\r\n if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {\r\n throw \"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)\";\r\n }\r\n if (this._cameraMesh) {\r\n this._cameraMesh.dispose();\r\n }\r\n this._cameraMesh = mesh;\r\n this._cameraMesh.parent = this._rootMesh;\r\n this._customMeshSet = true;\r\n }\r\n\r\n /**\r\n * Disposes of the camera gizmo\r\n */\r\n public dispose() {\r\n this.onClickedObservable.clear();\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n if (this._cameraMesh) {\r\n this._cameraMesh.dispose();\r\n }\r\n if (this._cameraLinesMesh) {\r\n this._cameraLinesMesh.dispose();\r\n }\r\n this._material.dispose();\r\n super.dispose();\r\n }\r\n\r\n private static _CreateCameraMesh(scene: Scene) {\r\n const root = new Mesh(\"rootCameraGizmo\", scene);\r\n\r\n const mesh = new Mesh(root.name, scene);\r\n mesh.parent = root;\r\n\r\n const box = CreateBox(root.name, { width: 1.0, height: 0.8, depth: 0.5 }, scene);\r\n box.parent = mesh;\r\n\r\n const cyl1 = CreateCylinder(root.name, { height: 0.5, diameterTop: 0.8, diameterBottom: 0.8 }, scene);\r\n cyl1.parent = mesh;\r\n cyl1.position.y = 0.3;\r\n cyl1.position.x = -0.6;\r\n cyl1.rotation.x = Math.PI * 0.5;\r\n\r\n const cyl2 = CreateCylinder(root.name, { height: 0.5, diameterTop: 0.6, diameterBottom: 0.6 }, scene);\r\n cyl2.parent = mesh;\r\n cyl2.position.y = 0.5;\r\n cyl2.position.x = 0.4;\r\n cyl2.rotation.x = Math.PI * 0.5;\r\n\r\n const cyl3 = CreateCylinder(root.name, { height: 0.5, diameterTop: 0.5, diameterBottom: 0.5 }, scene);\r\n cyl3.parent = mesh;\r\n cyl3.position.y = 0.0;\r\n cyl3.position.x = 0.6;\r\n cyl3.rotation.z = Math.PI * 0.5;\r\n\r\n root.scaling.scaleInPlace(CameraGizmo._Scale);\r\n mesh.position.x = -0.9;\r\n\r\n return root;\r\n }\r\n\r\n private static _CreateCameraFrustum(scene: Scene, linesColor: Color4) {\r\n const root = new Mesh(\"rootCameraGizmo\", scene);\r\n const mesh = new Mesh(root.name, scene);\r\n mesh.parent = root;\r\n\r\n for (let y = 0; y < 4; y += 2) {\r\n for (let x = 0; x < 4; x += 2) {\r\n let line = CreateLines(\"lines\", { points: [new Vector3(-1 + x, -1 + y, -1), new Vector3(-1 + x, -1 + y, 1)], colors: [linesColor, linesColor] }, scene);\r\n line.parent = mesh;\r\n line.alwaysSelectAsActiveMesh = true;\r\n line.isPickable = false;\r\n line = CreateLines(\"lines\", { points: [new Vector3(-1, -1 + x, -1 + y), new Vector3(1, -1 + x, -1 + y)], colors: [linesColor, linesColor] }, scene);\r\n line.parent = mesh;\r\n line.alwaysSelectAsActiveMesh = true;\r\n line.isPickable = false;\r\n line = CreateLines(\"lines\", { points: [new Vector3(-1 + x, -1, -1 + y), new Vector3(-1 + x, 1, -1 + y)], colors: [linesColor, linesColor] }, scene);\r\n line.parent = mesh;\r\n line.alwaysSelectAsActiveMesh = true;\r\n line.isPickable = false;\r\n }\r\n }\r\n\r\n return root;\r\n }\r\n}\r\n"]}
|
package/Lights/shadowLight.d.ts
CHANGED
|
@@ -157,7 +157,7 @@ export declare abstract class ShadowLight extends Light implements IShadowLight
|
|
|
157
157
|
*/
|
|
158
158
|
customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
|
|
159
159
|
/**
|
|
160
|
-
* The transformed position. Position of the light in world space taking parenting in account.
|
|
160
|
+
* The transformed position. Position of the light in world space taking parenting in account. Needs to be computed by calling computeTransformedInformation.
|
|
161
161
|
*/
|
|
162
162
|
transformedPosition: Vector3;
|
|
163
163
|
/**
|
|
@@ -182,7 +182,7 @@ export declare abstract class ShadowLight extends Light implements IShadowLight
|
|
|
182
182
|
*/
|
|
183
183
|
getShadowDirection(faceIndex?: number): Vector3;
|
|
184
184
|
/**
|
|
185
|
-
*
|
|
185
|
+
* If computeTransformedInformation has been called, returns the ShadowLight absolute position in the world. Otherwise, returns the local position.
|
|
186
186
|
* @returns the position vector in world space
|
|
187
187
|
*/
|
|
188
188
|
getAbsolutePosition(): Vector3;
|
package/Lights/shadowLight.js
CHANGED
|
@@ -112,7 +112,7 @@ export class ShadowLight extends Light {
|
|
|
112
112
|
return this.transformedDirection ? this.transformedDirection : this.direction;
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
115
|
+
* If computeTransformedInformation has been called, returns the ShadowLight absolute position in the world. Otherwise, returns the local position.
|
|
116
116
|
* @returns the position vector in world space
|
|
117
117
|
*/
|
|
118
118
|
getAbsolutePosition() {
|
|
@@ -1 +1 @@
|
|
|
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,IA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iBAAiB,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,IAAI,CAAC,WAAW,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,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.\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 * Returns the ShadowLight absolute position in the World.\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,EAA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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,aAAV,UAAU,cAAV,UAAU,GAAI,IAAI,CAAC,WAAW,EAAE,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,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"]}
|
|
@@ -305,7 +305,7 @@ export declare class BaseTexture extends ThinTexture implements IAnimatable {
|
|
|
305
305
|
*/
|
|
306
306
|
_getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean, useSRGBBuffer?: boolean, isCube?: boolean): Nullable<InternalTexture>;
|
|
307
307
|
/** @internal */
|
|
308
|
-
_rebuild(): void;
|
|
308
|
+
_rebuild(_fromContextLost?: boolean): void;
|
|
309
309
|
/**
|
|
310
310
|
* Clones the texture.
|
|
311
311
|
* @returns the cloned texture
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/baseTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAmCxC;;OAEG;IACH,IAAW,QAAQ,CAAC,KAAc;QAC9B,IAA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;AAaM;IADN,SAAS,EAAE;0CACsC;AAQ3C;IADN,SAAS,EAAE;8DACuE;AAQnF;IADC,SAAS,EAAE;yCAOX;AAcD;IADC,SAAS,EAAE;uCAOX;AAcD;IADC,SAAS,EAAE;4CAOX;AAkBD;IADC,SAAS,EAAE;6CAWX;AA6CM;IADN,SAAS,EAAE;4CACW;AAahB;IADN,SAAS,EAAE;oDACmB;AAM/B;IADC,SAAS,EAAE;sDAOX;AAWD;IADC,SAAS,EAAE;qDAOX;AAaD;IADC,SAAS,EAAE;oDAOX;AAaD;IADC,kBAAkB,EAAE;oDAOpB;AAWM;IADN,SAAS,EAAE;mDACkB","sourcesContent":["import { serialize, SerializationHelper, serializeAsTexture } from \"../../Misc/decorators\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix } from \"../../Maths/math.vector\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { IAnimatable } from \"../../Animations/animatable.interface\";\r\nimport { RandomGUID } from \"../../Misc/guid\";\r\n\r\nimport \"../../Misc/fileTools\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport { ThinTexture } from \"./thinTexture\";\r\nimport type { AbstractScene } from \"../../abstractScene\";\r\n\r\nimport type { Animation } from \"../../Animations/animation\";\r\n\r\n/**\r\n * Base class of all the textures in babylon.\r\n * It groups all the common properties the materials, post process, lights... might need\r\n * in order to make a correct use of the texture.\r\n */\r\nexport class BaseTexture extends ThinTexture implements IAnimatable {\r\n /**\r\n * Default anisotropic filtering level for the application.\r\n * It is set to 4 as a good tradeoff between perf and quality.\r\n */\r\n public static DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;\r\n\r\n /**\r\n * Gets or sets the unique id of the texture\r\n */\r\n @serialize()\r\n public uniqueId: number;\r\n\r\n /**\r\n * Define the name of the texture.\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * Gets or sets an object used to store user defined information.\r\n */\r\n @serialize()\r\n public metadata: any = null;\r\n\r\n /** @internal */\r\n public _internalMetadata: any;\r\n\r\n /**\r\n * For internal use only. Please do not use.\r\n */\r\n public reservedDataStore: any = null;\r\n\r\n @serialize(\"hasAlpha\")\r\n private _hasAlpha = false;\r\n /**\r\n * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).\r\n */\r\n public set hasAlpha(value: boolean) {\r\n if (this._hasAlpha === value) {\r\n return;\r\n }\r\n this._hasAlpha = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get hasAlpha(): boolean {\r\n return this._hasAlpha;\r\n }\r\n\r\n @serialize(\"getAlphaFromRGB\")\r\n private _getAlphaFromRGB = false;\r\n /**\r\n * Defines if the alpha value should be determined via the rgb values.\r\n * If true the luminance of the pixel might be used to find the corresponding alpha value.\r\n */\r\n public set getAlphaFromRGB(value: boolean) {\r\n if (this._getAlphaFromRGB === value) {\r\n return;\r\n }\r\n this._getAlphaFromRGB = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get getAlphaFromRGB(): boolean {\r\n return this._getAlphaFromRGB;\r\n }\r\n\r\n /**\r\n * Intensity or strength of the texture.\r\n * It is commonly used by materials to fine tune the intensity of the texture\r\n */\r\n @serialize()\r\n public level = 1;\r\n\r\n @serialize(\"coordinatesIndex\")\r\n protected _coordinatesIndex = 0;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the texture should try to reduce shader code if there is no UV manipulation.\r\n * (ie. when texture.getTextureMatrix().isIdentityAs3x2() returns true)\r\n */\r\n @serialize()\r\n public optimizeUVAllocation = true;\r\n\r\n /**\r\n * Define the UV channel to use starting from 0 and defaulting to 0.\r\n * This is part of the texture as textures usually maps to one uv set.\r\n */\r\n public set coordinatesIndex(value: number) {\r\n if (this._coordinatesIndex === value) {\r\n return;\r\n }\r\n this._coordinatesIndex = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get coordinatesIndex(): number {\r\n return this._coordinatesIndex;\r\n }\r\n\r\n @serialize(\"coordinatesMode\")\r\n protected _coordinatesMode = Constants.TEXTURE_EXPLICIT_MODE;\r\n\r\n /**\r\n * How a texture is mapped.\r\n *\r\n * | Value | Type | Description |\r\n * | ----- | ----------------------------------- | ----------- |\r\n * | 0 | EXPLICIT_MODE | |\r\n * | 1 | SPHERICAL_MODE | |\r\n * | 2 | PLANAR_MODE | |\r\n * | 3 | CUBIC_MODE | |\r\n * | 4 | PROJECTION_MODE | |\r\n * | 5 | SKYBOX_MODE | |\r\n * | 6 | INVCUBIC_MODE | |\r\n * | 7 | EQUIRECTANGULAR_MODE | |\r\n * | 8 | FIXED_EQUIRECTANGULAR_MODE | |\r\n * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |\r\n */\r\n public set coordinatesMode(value: number) {\r\n if (this._coordinatesMode === value) {\r\n return;\r\n }\r\n this._coordinatesMode = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get coordinatesMode(): number {\r\n return this._coordinatesMode;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n @serialize()\r\n public get wrapU() {\r\n return this._wrapU;\r\n }\r\n public set wrapU(value: number) {\r\n this._wrapU = value;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n @serialize()\r\n public get wrapV() {\r\n return this._wrapV;\r\n }\r\n public set wrapV(value: number) {\r\n this._wrapV = value;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n @serialize()\r\n public wrapR = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n\r\n /**\r\n * With compliant hardware and browser (supporting anisotropic filtering)\r\n * this defines the level of anisotropic filtering in the texture.\r\n * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.\r\n */\r\n @serialize()\r\n public anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;\r\n\r\n /** @internal */\r\n public _isCube = false;\r\n /**\r\n * Define if the texture is a cube texture or if false a 2d texture.\r\n */\r\n @serialize()\r\n public get isCube(): boolean {\r\n if (!this._texture) {\r\n return this._isCube;\r\n }\r\n\r\n return this._texture.isCube;\r\n }\r\n\r\n protected set isCube(value: boolean) {\r\n if (!this._texture) {\r\n this._isCube = value;\r\n } else {\r\n this._texture.isCube = value;\r\n }\r\n }\r\n\r\n /**\r\n * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.\r\n */\r\n @serialize()\r\n public get is3D(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is3D;\r\n }\r\n\r\n protected set is3D(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is3D = value;\r\n }\r\n\r\n /**\r\n * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.\r\n */\r\n @serialize()\r\n public get is2DArray(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is2DArray;\r\n }\r\n\r\n protected set is2DArray(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is2DArray = value;\r\n }\r\n\r\n /** @internal */\r\n protected _gammaSpace = true;\r\n /**\r\n * Define if the texture contains data in gamma space (most of the png/jpg aside bump).\r\n * HDR texture are usually stored in linear space.\r\n * This only impacts the PBR and Background materials\r\n */\r\n @serialize()\r\n public get gammaSpace(): boolean {\r\n if (!this._texture) {\r\n return this._gammaSpace;\r\n } else {\r\n if (this._texture._gammaSpace === null) {\r\n this._texture._gammaSpace = this._gammaSpace;\r\n }\r\n }\r\n\r\n return this._texture._gammaSpace && !this._texture._useSRGBBuffer;\r\n }\r\n\r\n public set gammaSpace(gamma: boolean) {\r\n if (!this._texture) {\r\n if (this._gammaSpace === gamma) {\r\n return;\r\n }\r\n\r\n this._gammaSpace = gamma;\r\n } else {\r\n if (this._texture._gammaSpace === gamma) {\r\n return;\r\n }\r\n this._texture._gammaSpace = gamma;\r\n }\r\n\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n\r\n /**\r\n * Gets or sets whether or not the texture contains RGBD data.\r\n */\r\n public get isRGBD(): boolean {\r\n return this._texture != null && this._texture._isRGBD;\r\n }\r\n public set isRGBD(value: boolean) {\r\n if (value === this.isRGBD) {\r\n return;\r\n }\r\n\r\n if (this._texture) {\r\n this._texture._isRGBD = value;\r\n }\r\n\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n\r\n /**\r\n * Is Z inverted in the texture (useful in a cube texture).\r\n */\r\n @serialize()\r\n public invertZ = false;\r\n\r\n /**\r\n * Are mip maps generated for this texture or not.\r\n */\r\n public get noMipmap(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n @serialize()\r\n public lodLevelInAlpha = false;\r\n\r\n /**\r\n * With prefiltered texture, defined the offset used during the prefiltering steps.\r\n */\r\n @serialize()\r\n public get lodGenerationOffset(): number {\r\n if (this._texture) {\r\n return this._texture._lodGenerationOffset;\r\n }\r\n\r\n return 0.0;\r\n }\r\n public set lodGenerationOffset(value: number) {\r\n if (this._texture) {\r\n this._texture._lodGenerationOffset = value;\r\n }\r\n }\r\n\r\n /**\r\n * With prefiltered texture, defined the scale used during the prefiltering steps.\r\n */\r\n @serialize()\r\n public get lodGenerationScale(): number {\r\n if (this._texture) {\r\n return this._texture._lodGenerationScale;\r\n }\r\n\r\n return 0.0;\r\n }\r\n public set lodGenerationScale(value: number) {\r\n if (this._texture) {\r\n this._texture._lodGenerationScale = value;\r\n }\r\n }\r\n\r\n /**\r\n * With prefiltered texture, defined if the specular generation is based on a linear ramp.\r\n * By default we are using a log2 of the linear roughness helping to keep a better resolution for\r\n * average roughness values.\r\n */\r\n @serialize()\r\n public get linearSpecularLOD(): boolean {\r\n if (this._texture) {\r\n return this._texture._linearSpecularLOD;\r\n }\r\n\r\n return false;\r\n }\r\n public set linearSpecularLOD(value: boolean) {\r\n if (this._texture) {\r\n this._texture._linearSpecularLOD = value;\r\n }\r\n }\r\n\r\n /**\r\n * In case a better definition than spherical harmonics is required for the diffuse part of the environment.\r\n * You can set the irradiance texture to rely on a texture instead of the spherical approach.\r\n * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).\r\n */\r\n @serializeAsTexture()\r\n public get irradianceTexture(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._irradianceTexture;\r\n }\r\n\r\n return null;\r\n }\r\n public set irradianceTexture(value: Nullable<BaseTexture>) {\r\n if (this._texture) {\r\n this._texture._irradianceTexture = value;\r\n }\r\n }\r\n\r\n /**\r\n * Define if the texture is a render target.\r\n */\r\n @serialize()\r\n public isRenderTarget = false;\r\n\r\n /**\r\n * Define the unique id of the texture in the scene.\r\n */\r\n public get uid(): string {\r\n if (!this._uid) {\r\n this._uid = RandomGUID();\r\n }\r\n return this._uid;\r\n }\r\n\r\n /** @internal */\r\n public _prefiltered: boolean = false;\r\n /** @internal */\r\n public _forceSerialize: boolean = false;\r\n\r\n /**\r\n * Return a string representation of the texture.\r\n * @returns the texture as a string\r\n */\r\n public toString(): string {\r\n return this.name;\r\n }\r\n\r\n /**\r\n * Get the class name of the texture.\r\n * @returns \"BaseTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"BaseTexture\";\r\n }\r\n\r\n /**\r\n * Define the list of animation attached to the texture.\r\n */\r\n public animations: Animation[] = [];\r\n\r\n /**\r\n * An event triggered when the texture is disposed.\r\n */\r\n public onDisposeObservable = new Observable<BaseTexture>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<BaseTexture>> = null;\r\n /**\r\n * Callback triggered when the texture has been disposed.\r\n * Kept for back compatibility, you can use the onDisposeObservable instead.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n protected _scene: Nullable<Scene> = null;\r\n\r\n /** @internal */\r\n private _uid: Nullable<string> = null;\r\n\r\n /**\r\n * Define if the texture is preventing a material to render or not.\r\n * If not and the texture is not ready, the engine will use a default black texture instead.\r\n */\r\n public get isBlocking(): boolean {\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n protected _loadingError: boolean = false;\r\n protected _errorObject?: {\r\n message?: string;\r\n exception?: any;\r\n };\r\n\r\n /**\r\n * Was there any loading error?\r\n */\r\n public get loadingError(): boolean {\r\n return this._loadingError;\r\n }\r\n\r\n /**\r\n * If a loading error occurred this object will be populated with information about the error.\r\n */\r\n public get errorObject():\r\n | {\r\n message?: string;\r\n exception?: any;\r\n }\r\n | undefined {\r\n return this._errorObject;\r\n }\r\n\r\n /**\r\n * Instantiates a new BaseTexture.\r\n * Base class of all the textures in babylon.\r\n * It groups all the common properties the materials, post process, lights... might need\r\n * in order to make a correct use of the texture.\r\n * @param sceneOrEngine Define the scene or engine the texture belongs to\r\n * @param internalTexture Define the internal texture associated with the texture\r\n */\r\n constructor(sceneOrEngine?: Nullable<Scene | ThinEngine>, internalTexture: Nullable<InternalTexture> = null) {\r\n super(null);\r\n\r\n if (sceneOrEngine) {\r\n if (BaseTexture._IsScene(sceneOrEngine)) {\r\n this._scene = sceneOrEngine;\r\n } else {\r\n this._engine = sceneOrEngine;\r\n }\r\n } else {\r\n this._scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n if (this._scene) {\r\n this.uniqueId = this._scene.getUniqueId();\r\n this._scene.addTexture(this);\r\n this._engine = this._scene.getEngine();\r\n }\r\n\r\n this._texture = internalTexture;\r\n\r\n this._uid = null;\r\n }\r\n\r\n /**\r\n * Get the scene the texture belongs to.\r\n * @returns the scene or null if undefined\r\n */\r\n public getScene(): Nullable<Scene> {\r\n return this._scene;\r\n }\r\n\r\n /** @internal */\r\n protected _getEngine(): Nullable<ThinEngine> {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Checks if the texture has the same transform matrix than another texture\r\n * @param texture texture to check against\r\n * @returns true if the transforms are the same, else false\r\n */\r\n public checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean {\r\n return texture !== null;\r\n }\r\n\r\n /**\r\n * Get the texture transform matrix used to offset tile the texture for instance.\r\n * @returns the transformation matrix\r\n */\r\n public getTextureMatrix(): Matrix {\r\n return <Matrix>Matrix.IdentityReadOnly;\r\n }\r\n\r\n /**\r\n * Get the texture reflection matrix used to rotate/transform the reflection.\r\n * @returns the reflection matrix\r\n */\r\n public getReflectionTextureMatrix(): Matrix {\r\n return <Matrix>Matrix.IdentityReadOnly;\r\n }\r\n\r\n /**\r\n * Gets a suitable rotate/transform matrix when the texture is used for refraction.\r\n * There's a separate function from getReflectionTextureMatrix because refraction requires a special configuration of the matrix in right-handed mode.\r\n * @returns The refraction matrix\r\n */\r\n public getRefractionTextureMatrix(): Matrix {\r\n return this.getReflectionTextureMatrix();\r\n }\r\n\r\n /**\r\n * Get if the texture is ready to be consumed (either it is ready or it is not blocking)\r\n * @returns true if ready, not blocking or if there was an error loading the texture\r\n */\r\n public isReadyOrNotBlocking(): boolean {\r\n return !this.isBlocking || this.isReady() || this.loadingError;\r\n }\r\n\r\n /**\r\n * Scales the texture if is `canRescale()`\r\n * @param ratio the resize factor we want to use to rescale\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public scale(ratio: number): void {}\r\n\r\n /**\r\n * Get if the texture can rescale.\r\n */\r\n public get canRescale(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean, useSRGBBuffer?: boolean, isCube?: boolean): Nullable<InternalTexture> {\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return null;\r\n }\r\n\r\n const correctedUseSRGBBuffer = engine._getUseSRGBBuffer(!!useSRGBBuffer, noMipmap);\r\n\r\n const texturesCache = engine.getLoadedTexturesCache();\r\n for (let index = 0; index < texturesCache.length; index++) {\r\n const texturesCacheEntry = texturesCache[index];\r\n\r\n if (useSRGBBuffer === undefined || correctedUseSRGBBuffer === texturesCacheEntry._useSRGBBuffer) {\r\n if (invertY === undefined || invertY === texturesCacheEntry.invertY) {\r\n if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {\r\n if (!sampling || sampling === texturesCacheEntry.samplingMode) {\r\n if (isCube === undefined || isCube === texturesCacheEntry.isCube) {\r\n texturesCacheEntry.incrementReferences();\r\n return texturesCacheEntry;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(): void {}\r\n\r\n /**\r\n * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public clone(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Get the texture underlying type (INT, FLOAT...)\r\n */\r\n public get textureType(): number {\r\n if (!this._texture) {\r\n return Constants.TEXTURETYPE_UNSIGNED_INT;\r\n }\r\n\r\n return this._texture.type !== undefined ? this._texture.type : Constants.TEXTURETYPE_UNSIGNED_INT;\r\n }\r\n\r\n /**\r\n * Get the texture underlying format (RGB, RGBA...)\r\n */\r\n public get textureFormat(): number {\r\n if (!this._texture) {\r\n return Constants.TEXTUREFORMAT_RGBA;\r\n }\r\n\r\n return this._texture.format !== undefined ? this._texture.format : Constants.TEXTUREFORMAT_RGBA;\r\n }\r\n\r\n /**\r\n * Indicates that textures need to be re-calculated for all materials\r\n */\r\n protected _markAllSubMeshesAsTexturesDirty() {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n\r\n /**\r\n * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.\r\n * This will returns an RGBA array buffer containing either in values (0-255) or\r\n * float values (0-1) depending of the underlying buffer type.\r\n * @param faceIndex defines the face of the texture to read (in case of cube texture)\r\n * @param level defines the LOD level of the texture to read (in case of Mip Maps)\r\n * @param buffer defines a user defined buffer to fill with data (can be null)\r\n * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels\r\n * @param noDataConversion false to convert the data to Uint8Array (if texture type is UNSIGNED_BYTE) or to Float32Array (if texture type is anything but UNSIGNED_BYTE). If true, the type of the generated buffer (if buffer==null) will depend on the type of the texture\r\n * @param x defines the region x coordinates to start reading from (default to 0)\r\n * @param y defines the region y coordinates to start reading from (default to 0)\r\n * @param width defines the region width to read from (default to the texture size at level)\r\n * @param height defines the region width to read from (default to the texture size at level)\r\n * @returns The Array buffer promise containing the pixels data.\r\n */\r\n public readPixels(\r\n faceIndex = 0,\r\n level = 0,\r\n buffer: Nullable<ArrayBufferView> = null,\r\n flushRenderer = true,\r\n noDataConversion = false,\r\n x = 0,\r\n y = 0,\r\n width = Number.MAX_VALUE,\r\n height = Number.MAX_VALUE\r\n ): Nullable<Promise<ArrayBufferView>> {\r\n if (!this._texture) {\r\n return null;\r\n }\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return null;\r\n }\r\n\r\n const size = this.getSize();\r\n let maxWidth = size.width;\r\n let maxHeight = size.height;\r\n if (level !== 0) {\r\n maxWidth = maxWidth / Math.pow(2, level);\r\n maxHeight = maxHeight / Math.pow(2, level);\r\n maxWidth = Math.round(maxWidth);\r\n maxHeight = Math.round(maxHeight);\r\n }\r\n\r\n width = Math.min(maxWidth, width);\r\n height = Math.min(maxHeight, height);\r\n\r\n try {\r\n if (this._texture.isCube) {\r\n return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion, x, y);\r\n }\r\n\r\n return engine._readTexturePixels(this._texture, width, height, -1, level, buffer, flushRenderer, noDataConversion, x, y);\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _readPixelsSync(faceIndex = 0, level = 0, buffer: Nullable<ArrayBufferView> = null, flushRenderer = true, noDataConversion = false): Nullable<ArrayBufferView> {\r\n if (!this._texture) {\r\n return null;\r\n }\r\n\r\n const size = this.getSize();\r\n let width = size.width;\r\n let height = size.height;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return null;\r\n }\r\n\r\n if (level != 0) {\r\n width = width / Math.pow(2, level);\r\n height = height / Math.pow(2, level);\r\n\r\n width = Math.round(width);\r\n height = Math.round(height);\r\n }\r\n\r\n try {\r\n if (this._texture.isCube) {\r\n return engine._readTexturePixelsSync(this._texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion);\r\n }\r\n\r\n return engine._readTexturePixelsSync(this._texture, width, height, -1, level, buffer, flushRenderer, noDataConversion);\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get _lodTextureHigh(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._lodTextureHigh;\r\n }\r\n return null;\r\n }\r\n\r\n /** @internal */\r\n public get _lodTextureMid(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._lodTextureMid;\r\n }\r\n return null;\r\n }\r\n\r\n /** @internal */\r\n public get _lodTextureLow(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._lodTextureLow;\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public dispose(): void {\r\n if (this._scene) {\r\n // Animations\r\n if (this._scene.stopAnimation) {\r\n this._scene.stopAnimation(this);\r\n }\r\n\r\n // Remove from scene\r\n this._scene.removePendingData(this);\r\n const index = this._scene.textures.indexOf(this);\r\n\r\n if (index >= 0) {\r\n this._scene.textures.splice(index, 1);\r\n }\r\n this._scene.onTextureRemovedObservable.notifyObservers(this);\r\n this._scene = null;\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.textures.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.textures.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n }\r\n\r\n // Callback\r\n this.onDisposeObservable.notifyObservers(this);\r\n this.onDisposeObservable.clear();\r\n\r\n this.metadata = null;\r\n\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Serialize the texture into a JSON representation that can be parsed later on.\r\n * @param allowEmptyName True to force serialization even if name is empty. Default: false\r\n * @returns the JSON representation of the texture\r\n */\r\n public serialize(allowEmptyName = false): any {\r\n if (!this.name && !allowEmptyName) {\r\n return null;\r\n }\r\n\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Helper function to be called back once a list of texture contains only ready textures.\r\n * @param textures Define the list of textures to wait for\r\n * @param callback Define the callback triggered once the entire list will be ready\r\n */\r\n public static WhenAllReady(textures: BaseTexture[], callback: () => void): void {\r\n let numRemaining = textures.length;\r\n if (numRemaining === 0) {\r\n callback();\r\n return;\r\n }\r\n\r\n for (let i = 0; i < textures.length; i++) {\r\n const texture = textures[i];\r\n\r\n if (texture.isReady()) {\r\n if (--numRemaining === 0) {\r\n callback();\r\n }\r\n } else {\r\n const onLoadObservable = (texture as any).onLoadObservable as Observable<BaseTexture>;\r\n\r\n if (onLoadObservable) {\r\n onLoadObservable.addOnce(() => {\r\n if (--numRemaining === 0) {\r\n callback();\r\n }\r\n });\r\n } else {\r\n if (--numRemaining === 0) {\r\n callback();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static _IsScene(sceneOrEngine: Scene | ThinEngine): sceneOrEngine is Scene {\r\n return sceneOrEngine.getClassName() === \"Scene\";\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"baseTexture.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/baseTexture.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3F,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,sBAAsB,CAAC;AAE9B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAK5C;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,WAAW;IAmCxC;;OAEG;IACH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;AAyC7D;IADC,SAAS,EAAE;wCAGX;AAaD;IADC,SAAS,EAAE;wCAGX;AAaM;IADN,SAAS,EAAE;0CACsC;AAQ3C;IADN,SAAS,EAAE;8DACuE;AAQnF;IADC,SAAS,EAAE;yCAOX;AAcD;IADC,SAAS,EAAE;uCAOX;AAcD;IADC,SAAS,EAAE;4CAOX;AAkBD;IADC,SAAS,EAAE;6CAWX;AA6CM;IADN,SAAS,EAAE;4CACW;AAahB;IADN,SAAS,EAAE;oDACmB;AAM/B;IADC,SAAS,EAAE;sDAOX;AAWD;IADC,SAAS,EAAE;qDAOX;AAaD;IADC,SAAS,EAAE;oDAOX;AAaD;IADC,kBAAkB,EAAE;oDAOpB;AAWM;IADN,SAAS,EAAE;mDACkB","sourcesContent":["import { serialize, SerializationHelper, serializeAsTexture } from \"../../Misc/decorators\";\r\nimport type { Observer } from \"../../Misc/observable\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport type { Nullable } from \"../../types\";\r\nimport type { Scene } from \"../../scene\";\r\nimport { Matrix } from \"../../Maths/math.vector\";\r\nimport { EngineStore } from \"../../Engines/engineStore\";\r\nimport type { InternalTexture } from \"../../Materials/Textures/internalTexture\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport type { IAnimatable } from \"../../Animations/animatable.interface\";\r\nimport { RandomGUID } from \"../../Misc/guid\";\r\n\r\nimport \"../../Misc/fileTools\";\r\nimport type { ThinEngine } from \"../../Engines/thinEngine\";\r\nimport { ThinTexture } from \"./thinTexture\";\r\nimport type { AbstractScene } from \"../../abstractScene\";\r\n\r\nimport type { Animation } from \"../../Animations/animation\";\r\n\r\n/**\r\n * Base class of all the textures in babylon.\r\n * It groups all the common properties the materials, post process, lights... might need\r\n * in order to make a correct use of the texture.\r\n */\r\nexport class BaseTexture extends ThinTexture implements IAnimatable {\r\n /**\r\n * Default anisotropic filtering level for the application.\r\n * It is set to 4 as a good tradeoff between perf and quality.\r\n */\r\n public static DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;\r\n\r\n /**\r\n * Gets or sets the unique id of the texture\r\n */\r\n @serialize()\r\n public uniqueId: number;\r\n\r\n /**\r\n * Define the name of the texture.\r\n */\r\n @serialize()\r\n public name: string;\r\n\r\n /**\r\n * Gets or sets an object used to store user defined information.\r\n */\r\n @serialize()\r\n public metadata: any = null;\r\n\r\n /** @internal */\r\n public _internalMetadata: any;\r\n\r\n /**\r\n * For internal use only. Please do not use.\r\n */\r\n public reservedDataStore: any = null;\r\n\r\n @serialize(\"hasAlpha\")\r\n private _hasAlpha = false;\r\n /**\r\n * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).\r\n */\r\n public set hasAlpha(value: boolean) {\r\n if (this._hasAlpha === value) {\r\n return;\r\n }\r\n this._hasAlpha = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get hasAlpha(): boolean {\r\n return this._hasAlpha;\r\n }\r\n\r\n @serialize(\"getAlphaFromRGB\")\r\n private _getAlphaFromRGB = false;\r\n /**\r\n * Defines if the alpha value should be determined via the rgb values.\r\n * If true the luminance of the pixel might be used to find the corresponding alpha value.\r\n */\r\n public set getAlphaFromRGB(value: boolean) {\r\n if (this._getAlphaFromRGB === value) {\r\n return;\r\n }\r\n this._getAlphaFromRGB = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get getAlphaFromRGB(): boolean {\r\n return this._getAlphaFromRGB;\r\n }\r\n\r\n /**\r\n * Intensity or strength of the texture.\r\n * It is commonly used by materials to fine tune the intensity of the texture\r\n */\r\n @serialize()\r\n public level = 1;\r\n\r\n @serialize(\"coordinatesIndex\")\r\n protected _coordinatesIndex = 0;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that the texture should try to reduce shader code if there is no UV manipulation.\r\n * (ie. when texture.getTextureMatrix().isIdentityAs3x2() returns true)\r\n */\r\n @serialize()\r\n public optimizeUVAllocation = true;\r\n\r\n /**\r\n * Define the UV channel to use starting from 0 and defaulting to 0.\r\n * This is part of the texture as textures usually maps to one uv set.\r\n */\r\n public set coordinatesIndex(value: number) {\r\n if (this._coordinatesIndex === value) {\r\n return;\r\n }\r\n this._coordinatesIndex = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get coordinatesIndex(): number {\r\n return this._coordinatesIndex;\r\n }\r\n\r\n @serialize(\"coordinatesMode\")\r\n protected _coordinatesMode = Constants.TEXTURE_EXPLICIT_MODE;\r\n\r\n /**\r\n * How a texture is mapped.\r\n *\r\n * | Value | Type | Description |\r\n * | ----- | ----------------------------------- | ----------- |\r\n * | 0 | EXPLICIT_MODE | |\r\n * | 1 | SPHERICAL_MODE | |\r\n * | 2 | PLANAR_MODE | |\r\n * | 3 | CUBIC_MODE | |\r\n * | 4 | PROJECTION_MODE | |\r\n * | 5 | SKYBOX_MODE | |\r\n * | 6 | INVCUBIC_MODE | |\r\n * | 7 | EQUIRECTANGULAR_MODE | |\r\n * | 8 | FIXED_EQUIRECTANGULAR_MODE | |\r\n * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |\r\n */\r\n public set coordinatesMode(value: number) {\r\n if (this._coordinatesMode === value) {\r\n return;\r\n }\r\n this._coordinatesMode = value;\r\n if (this._scene) {\r\n this._scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n }\r\n public get coordinatesMode(): number {\r\n return this._coordinatesMode;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n @serialize()\r\n public get wrapU() {\r\n return this._wrapU;\r\n }\r\n public set wrapU(value: number) {\r\n this._wrapU = value;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n @serialize()\r\n public get wrapV() {\r\n return this._wrapV;\r\n }\r\n public set wrapV(value: number) {\r\n this._wrapV = value;\r\n }\r\n\r\n /**\r\n * | Value | Type | Description |\r\n * | ----- | ------------------ | ----------- |\r\n * | 0 | CLAMP_ADDRESSMODE | |\r\n * | 1 | WRAP_ADDRESSMODE | |\r\n * | 2 | MIRROR_ADDRESSMODE | |\r\n */\r\n @serialize()\r\n public wrapR = Constants.TEXTURE_WRAP_ADDRESSMODE;\r\n\r\n /**\r\n * With compliant hardware and browser (supporting anisotropic filtering)\r\n * this defines the level of anisotropic filtering in the texture.\r\n * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.\r\n */\r\n @serialize()\r\n public anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;\r\n\r\n /** @internal */\r\n public _isCube = false;\r\n /**\r\n * Define if the texture is a cube texture or if false a 2d texture.\r\n */\r\n @serialize()\r\n public get isCube(): boolean {\r\n if (!this._texture) {\r\n return this._isCube;\r\n }\r\n\r\n return this._texture.isCube;\r\n }\r\n\r\n protected set isCube(value: boolean) {\r\n if (!this._texture) {\r\n this._isCube = value;\r\n } else {\r\n this._texture.isCube = value;\r\n }\r\n }\r\n\r\n /**\r\n * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.\r\n */\r\n @serialize()\r\n public get is3D(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is3D;\r\n }\r\n\r\n protected set is3D(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is3D = value;\r\n }\r\n\r\n /**\r\n * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.\r\n */\r\n @serialize()\r\n public get is2DArray(): boolean {\r\n if (!this._texture) {\r\n return false;\r\n }\r\n\r\n return this._texture.is2DArray;\r\n }\r\n\r\n protected set is2DArray(value: boolean) {\r\n if (!this._texture) {\r\n return;\r\n }\r\n\r\n this._texture.is2DArray = value;\r\n }\r\n\r\n /** @internal */\r\n protected _gammaSpace = true;\r\n /**\r\n * Define if the texture contains data in gamma space (most of the png/jpg aside bump).\r\n * HDR texture are usually stored in linear space.\r\n * This only impacts the PBR and Background materials\r\n */\r\n @serialize()\r\n public get gammaSpace(): boolean {\r\n if (!this._texture) {\r\n return this._gammaSpace;\r\n } else {\r\n if (this._texture._gammaSpace === null) {\r\n this._texture._gammaSpace = this._gammaSpace;\r\n }\r\n }\r\n\r\n return this._texture._gammaSpace && !this._texture._useSRGBBuffer;\r\n }\r\n\r\n public set gammaSpace(gamma: boolean) {\r\n if (!this._texture) {\r\n if (this._gammaSpace === gamma) {\r\n return;\r\n }\r\n\r\n this._gammaSpace = gamma;\r\n } else {\r\n if (this._texture._gammaSpace === gamma) {\r\n return;\r\n }\r\n this._texture._gammaSpace = gamma;\r\n }\r\n\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n\r\n /**\r\n * Gets or sets whether or not the texture contains RGBD data.\r\n */\r\n public get isRGBD(): boolean {\r\n return this._texture != null && this._texture._isRGBD;\r\n }\r\n public set isRGBD(value: boolean) {\r\n if (value === this.isRGBD) {\r\n return;\r\n }\r\n\r\n if (this._texture) {\r\n this._texture._isRGBD = value;\r\n }\r\n\r\n this.getScene()?.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag, (mat) => {\r\n return mat.hasTexture(this);\r\n });\r\n }\r\n\r\n /**\r\n * Is Z inverted in the texture (useful in a cube texture).\r\n */\r\n @serialize()\r\n public invertZ = false;\r\n\r\n /**\r\n * Are mip maps generated for this texture or not.\r\n */\r\n public get noMipmap(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n @serialize()\r\n public lodLevelInAlpha = false;\r\n\r\n /**\r\n * With prefiltered texture, defined the offset used during the prefiltering steps.\r\n */\r\n @serialize()\r\n public get lodGenerationOffset(): number {\r\n if (this._texture) {\r\n return this._texture._lodGenerationOffset;\r\n }\r\n\r\n return 0.0;\r\n }\r\n public set lodGenerationOffset(value: number) {\r\n if (this._texture) {\r\n this._texture._lodGenerationOffset = value;\r\n }\r\n }\r\n\r\n /**\r\n * With prefiltered texture, defined the scale used during the prefiltering steps.\r\n */\r\n @serialize()\r\n public get lodGenerationScale(): number {\r\n if (this._texture) {\r\n return this._texture._lodGenerationScale;\r\n }\r\n\r\n return 0.0;\r\n }\r\n public set lodGenerationScale(value: number) {\r\n if (this._texture) {\r\n this._texture._lodGenerationScale = value;\r\n }\r\n }\r\n\r\n /**\r\n * With prefiltered texture, defined if the specular generation is based on a linear ramp.\r\n * By default we are using a log2 of the linear roughness helping to keep a better resolution for\r\n * average roughness values.\r\n */\r\n @serialize()\r\n public get linearSpecularLOD(): boolean {\r\n if (this._texture) {\r\n return this._texture._linearSpecularLOD;\r\n }\r\n\r\n return false;\r\n }\r\n public set linearSpecularLOD(value: boolean) {\r\n if (this._texture) {\r\n this._texture._linearSpecularLOD = value;\r\n }\r\n }\r\n\r\n /**\r\n * In case a better definition than spherical harmonics is required for the diffuse part of the environment.\r\n * You can set the irradiance texture to rely on a texture instead of the spherical approach.\r\n * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).\r\n */\r\n @serializeAsTexture()\r\n public get irradianceTexture(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._irradianceTexture;\r\n }\r\n\r\n return null;\r\n }\r\n public set irradianceTexture(value: Nullable<BaseTexture>) {\r\n if (this._texture) {\r\n this._texture._irradianceTexture = value;\r\n }\r\n }\r\n\r\n /**\r\n * Define if the texture is a render target.\r\n */\r\n @serialize()\r\n public isRenderTarget = false;\r\n\r\n /**\r\n * Define the unique id of the texture in the scene.\r\n */\r\n public get uid(): string {\r\n if (!this._uid) {\r\n this._uid = RandomGUID();\r\n }\r\n return this._uid;\r\n }\r\n\r\n /** @internal */\r\n public _prefiltered: boolean = false;\r\n /** @internal */\r\n public _forceSerialize: boolean = false;\r\n\r\n /**\r\n * Return a string representation of the texture.\r\n * @returns the texture as a string\r\n */\r\n public toString(): string {\r\n return this.name;\r\n }\r\n\r\n /**\r\n * Get the class name of the texture.\r\n * @returns \"BaseTexture\"\r\n */\r\n public getClassName(): string {\r\n return \"BaseTexture\";\r\n }\r\n\r\n /**\r\n * Define the list of animation attached to the texture.\r\n */\r\n public animations: Animation[] = [];\r\n\r\n /**\r\n * An event triggered when the texture is disposed.\r\n */\r\n public onDisposeObservable = new Observable<BaseTexture>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<BaseTexture>> = null;\r\n /**\r\n * Callback triggered when the texture has been disposed.\r\n * Kept for back compatibility, you can use the onDisposeObservable instead.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n protected _scene: Nullable<Scene> = null;\r\n\r\n /** @internal */\r\n private _uid: Nullable<string> = null;\r\n\r\n /**\r\n * Define if the texture is preventing a material to render or not.\r\n * If not and the texture is not ready, the engine will use a default black texture instead.\r\n */\r\n public get isBlocking(): boolean {\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public _parentContainer: Nullable<AbstractScene> = null;\r\n\r\n protected _loadingError: boolean = false;\r\n protected _errorObject?: {\r\n message?: string;\r\n exception?: any;\r\n };\r\n\r\n /**\r\n * Was there any loading error?\r\n */\r\n public get loadingError(): boolean {\r\n return this._loadingError;\r\n }\r\n\r\n /**\r\n * If a loading error occurred this object will be populated with information about the error.\r\n */\r\n public get errorObject():\r\n | {\r\n message?: string;\r\n exception?: any;\r\n }\r\n | undefined {\r\n return this._errorObject;\r\n }\r\n\r\n /**\r\n * Instantiates a new BaseTexture.\r\n * Base class of all the textures in babylon.\r\n * It groups all the common properties the materials, post process, lights... might need\r\n * in order to make a correct use of the texture.\r\n * @param sceneOrEngine Define the scene or engine the texture belongs to\r\n * @param internalTexture Define the internal texture associated with the texture\r\n */\r\n constructor(sceneOrEngine?: Nullable<Scene | ThinEngine>, internalTexture: Nullable<InternalTexture> = null) {\r\n super(null);\r\n\r\n if (sceneOrEngine) {\r\n if (BaseTexture._IsScene(sceneOrEngine)) {\r\n this._scene = sceneOrEngine;\r\n } else {\r\n this._engine = sceneOrEngine;\r\n }\r\n } else {\r\n this._scene = EngineStore.LastCreatedScene;\r\n }\r\n\r\n if (this._scene) {\r\n this.uniqueId = this._scene.getUniqueId();\r\n this._scene.addTexture(this);\r\n this._engine = this._scene.getEngine();\r\n }\r\n\r\n this._texture = internalTexture;\r\n\r\n this._uid = null;\r\n }\r\n\r\n /**\r\n * Get the scene the texture belongs to.\r\n * @returns the scene or null if undefined\r\n */\r\n public getScene(): Nullable<Scene> {\r\n return this._scene;\r\n }\r\n\r\n /** @internal */\r\n protected _getEngine(): Nullable<ThinEngine> {\r\n return this._engine;\r\n }\r\n\r\n /**\r\n * Checks if the texture has the same transform matrix than another texture\r\n * @param texture texture to check against\r\n * @returns true if the transforms are the same, else false\r\n */\r\n public checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean {\r\n return texture !== null;\r\n }\r\n\r\n /**\r\n * Get the texture transform matrix used to offset tile the texture for instance.\r\n * @returns the transformation matrix\r\n */\r\n public getTextureMatrix(): Matrix {\r\n return <Matrix>Matrix.IdentityReadOnly;\r\n }\r\n\r\n /**\r\n * Get the texture reflection matrix used to rotate/transform the reflection.\r\n * @returns the reflection matrix\r\n */\r\n public getReflectionTextureMatrix(): Matrix {\r\n return <Matrix>Matrix.IdentityReadOnly;\r\n }\r\n\r\n /**\r\n * Gets a suitable rotate/transform matrix when the texture is used for refraction.\r\n * There's a separate function from getReflectionTextureMatrix because refraction requires a special configuration of the matrix in right-handed mode.\r\n * @returns The refraction matrix\r\n */\r\n public getRefractionTextureMatrix(): Matrix {\r\n return this.getReflectionTextureMatrix();\r\n }\r\n\r\n /**\r\n * Get if the texture is ready to be consumed (either it is ready or it is not blocking)\r\n * @returns true if ready, not blocking or if there was an error loading the texture\r\n */\r\n public isReadyOrNotBlocking(): boolean {\r\n return !this.isBlocking || this.isReady() || this.loadingError;\r\n }\r\n\r\n /**\r\n * Scales the texture if is `canRescale()`\r\n * @param ratio the resize factor we want to use to rescale\r\n */\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n public scale(ratio: number): void {}\r\n\r\n /**\r\n * Get if the texture can rescale.\r\n */\r\n public get canRescale(): boolean {\r\n return false;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean, useSRGBBuffer?: boolean, isCube?: boolean): Nullable<InternalTexture> {\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return null;\r\n }\r\n\r\n const correctedUseSRGBBuffer = engine._getUseSRGBBuffer(!!useSRGBBuffer, noMipmap);\r\n\r\n const texturesCache = engine.getLoadedTexturesCache();\r\n for (let index = 0; index < texturesCache.length; index++) {\r\n const texturesCacheEntry = texturesCache[index];\r\n\r\n if (useSRGBBuffer === undefined || correctedUseSRGBBuffer === texturesCacheEntry._useSRGBBuffer) {\r\n if (invertY === undefined || invertY === texturesCacheEntry.invertY) {\r\n if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {\r\n if (!sampling || sampling === texturesCacheEntry.samplingMode) {\r\n if (isCube === undefined || isCube === texturesCacheEntry.isCube) {\r\n texturesCacheEntry.incrementReferences();\r\n return texturesCacheEntry;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return null;\r\n }\r\n\r\n /** @internal */\r\n public _rebuild(_fromContextLost = false): void {}\r\n\r\n /**\r\n * Clones the texture.\r\n * @returns the cloned texture\r\n */\r\n public clone(): Nullable<BaseTexture> {\r\n return null;\r\n }\r\n\r\n /**\r\n * Get the texture underlying type (INT, FLOAT...)\r\n */\r\n public get textureType(): number {\r\n if (!this._texture) {\r\n return Constants.TEXTURETYPE_UNSIGNED_INT;\r\n }\r\n\r\n return this._texture.type !== undefined ? this._texture.type : Constants.TEXTURETYPE_UNSIGNED_INT;\r\n }\r\n\r\n /**\r\n * Get the texture underlying format (RGB, RGBA...)\r\n */\r\n public get textureFormat(): number {\r\n if (!this._texture) {\r\n return Constants.TEXTUREFORMAT_RGBA;\r\n }\r\n\r\n return this._texture.format !== undefined ? this._texture.format : Constants.TEXTUREFORMAT_RGBA;\r\n }\r\n\r\n /**\r\n * Indicates that textures need to be re-calculated for all materials\r\n */\r\n protected _markAllSubMeshesAsTexturesDirty() {\r\n const scene = this.getScene();\r\n\r\n if (!scene) {\r\n return;\r\n }\r\n\r\n scene.markAllMaterialsAsDirty(Constants.MATERIAL_TextureDirtyFlag);\r\n }\r\n\r\n /**\r\n * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.\r\n * This will returns an RGBA array buffer containing either in values (0-255) or\r\n * float values (0-1) depending of the underlying buffer type.\r\n * @param faceIndex defines the face of the texture to read (in case of cube texture)\r\n * @param level defines the LOD level of the texture to read (in case of Mip Maps)\r\n * @param buffer defines a user defined buffer to fill with data (can be null)\r\n * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels\r\n * @param noDataConversion false to convert the data to Uint8Array (if texture type is UNSIGNED_BYTE) or to Float32Array (if texture type is anything but UNSIGNED_BYTE). If true, the type of the generated buffer (if buffer==null) will depend on the type of the texture\r\n * @param x defines the region x coordinates to start reading from (default to 0)\r\n * @param y defines the region y coordinates to start reading from (default to 0)\r\n * @param width defines the region width to read from (default to the texture size at level)\r\n * @param height defines the region width to read from (default to the texture size at level)\r\n * @returns The Array buffer promise containing the pixels data.\r\n */\r\n public readPixels(\r\n faceIndex = 0,\r\n level = 0,\r\n buffer: Nullable<ArrayBufferView> = null,\r\n flushRenderer = true,\r\n noDataConversion = false,\r\n x = 0,\r\n y = 0,\r\n width = Number.MAX_VALUE,\r\n height = Number.MAX_VALUE\r\n ): Nullable<Promise<ArrayBufferView>> {\r\n if (!this._texture) {\r\n return null;\r\n }\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return null;\r\n }\r\n\r\n const size = this.getSize();\r\n let maxWidth = size.width;\r\n let maxHeight = size.height;\r\n if (level !== 0) {\r\n maxWidth = maxWidth / Math.pow(2, level);\r\n maxHeight = maxHeight / Math.pow(2, level);\r\n maxWidth = Math.round(maxWidth);\r\n maxHeight = Math.round(maxHeight);\r\n }\r\n\r\n width = Math.min(maxWidth, width);\r\n height = Math.min(maxHeight, height);\r\n\r\n try {\r\n if (this._texture.isCube) {\r\n return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion, x, y);\r\n }\r\n\r\n return engine._readTexturePixels(this._texture, width, height, -1, level, buffer, flushRenderer, noDataConversion, x, y);\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _readPixelsSync(faceIndex = 0, level = 0, buffer: Nullable<ArrayBufferView> = null, flushRenderer = true, noDataConversion = false): Nullable<ArrayBufferView> {\r\n if (!this._texture) {\r\n return null;\r\n }\r\n\r\n const size = this.getSize();\r\n let width = size.width;\r\n let height = size.height;\r\n\r\n const engine = this._getEngine();\r\n if (!engine) {\r\n return null;\r\n }\r\n\r\n if (level != 0) {\r\n width = width / Math.pow(2, level);\r\n height = height / Math.pow(2, level);\r\n\r\n width = Math.round(width);\r\n height = Math.round(height);\r\n }\r\n\r\n try {\r\n if (this._texture.isCube) {\r\n return engine._readTexturePixelsSync(this._texture, width, height, faceIndex, level, buffer, flushRenderer, noDataConversion);\r\n }\r\n\r\n return engine._readTexturePixelsSync(this._texture, width, height, -1, level, buffer, flushRenderer, noDataConversion);\r\n } catch (e) {\r\n return null;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public get _lodTextureHigh(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._lodTextureHigh;\r\n }\r\n return null;\r\n }\r\n\r\n /** @internal */\r\n public get _lodTextureMid(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._lodTextureMid;\r\n }\r\n return null;\r\n }\r\n\r\n /** @internal */\r\n public get _lodTextureLow(): Nullable<BaseTexture> {\r\n if (this._texture) {\r\n return this._texture._lodTextureLow;\r\n }\r\n return null;\r\n }\r\n\r\n /**\r\n * Dispose the texture and release its associated resources.\r\n */\r\n public dispose(): void {\r\n if (this._scene) {\r\n // Animations\r\n if (this._scene.stopAnimation) {\r\n this._scene.stopAnimation(this);\r\n }\r\n\r\n // Remove from scene\r\n this._scene.removePendingData(this);\r\n const index = this._scene.textures.indexOf(this);\r\n\r\n if (index >= 0) {\r\n this._scene.textures.splice(index, 1);\r\n }\r\n this._scene.onTextureRemovedObservable.notifyObservers(this);\r\n this._scene = null;\r\n\r\n if (this._parentContainer) {\r\n const index = this._parentContainer.textures.indexOf(this);\r\n if (index > -1) {\r\n this._parentContainer.textures.splice(index, 1);\r\n }\r\n this._parentContainer = null;\r\n }\r\n }\r\n\r\n // Callback\r\n this.onDisposeObservable.notifyObservers(this);\r\n this.onDisposeObservable.clear();\r\n\r\n this.metadata = null;\r\n\r\n super.dispose();\r\n }\r\n\r\n /**\r\n * Serialize the texture into a JSON representation that can be parsed later on.\r\n * @param allowEmptyName True to force serialization even if name is empty. Default: false\r\n * @returns the JSON representation of the texture\r\n */\r\n public serialize(allowEmptyName = false): any {\r\n if (!this.name && !allowEmptyName) {\r\n return null;\r\n }\r\n\r\n const serializationObject = SerializationHelper.Serialize(this);\r\n\r\n // Animations\r\n SerializationHelper.AppendSerializedAnimations(this, serializationObject);\r\n\r\n return serializationObject;\r\n }\r\n\r\n /**\r\n * Helper function to be called back once a list of texture contains only ready textures.\r\n * @param textures Define the list of textures to wait for\r\n * @param callback Define the callback triggered once the entire list will be ready\r\n */\r\n public static WhenAllReady(textures: BaseTexture[], callback: () => void): void {\r\n let numRemaining = textures.length;\r\n if (numRemaining === 0) {\r\n callback();\r\n return;\r\n }\r\n\r\n for (let i = 0; i < textures.length; i++) {\r\n const texture = textures[i];\r\n\r\n if (texture.isReady()) {\r\n if (--numRemaining === 0) {\r\n callback();\r\n }\r\n } else {\r\n const onLoadObservable = (texture as any).onLoadObservable as Observable<BaseTexture>;\r\n\r\n if (onLoadObservable) {\r\n onLoadObservable.addOnce(() => {\r\n if (--numRemaining === 0) {\r\n callback();\r\n }\r\n });\r\n } else {\r\n if (--numRemaining === 0) {\r\n callback();\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n private static _IsScene(sceneOrEngine: Scene | ThinEngine): sceneOrEngine is Scene {\r\n return sceneOrEngine.getClassName() === \"Scene\";\r\n }\r\n}\r\n"]}
|
|
@@ -374,6 +374,11 @@ export class InternalTexture extends TextureSampler {
|
|
|
374
374
|
}, null, this.format, this._extension);
|
|
375
375
|
proxy._sphericalPolynomial = this._sphericalPolynomial;
|
|
376
376
|
return;
|
|
377
|
+
case InternalTextureSource.DepthStencil:
|
|
378
|
+
case InternalTextureSource.Depth: {
|
|
379
|
+
// Will be handled at the RenderTargetWrapper level
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
377
382
|
}
|
|
378
383
|
}
|
|
379
384
|
/**
|