@babylonjs/core 8.36.1 → 8.37.1
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/Animations/animationGroup.js +1 -4
- package/Animations/animationGroup.js.map +1 -1
- package/AudioV2/abstractAudio/audioEngineV2.d.ts +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js +0 -4
- package/AudioV2/abstractAudio/audioEngineV2.js.map +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js +1 -1
- package/AudioV2/abstractAudio/subNodes/volumeAudioSubNode.js.map +1 -1
- package/AudioV2/audioParameter.d.ts +5 -1
- package/AudioV2/audioParameter.js +4 -0
- package/AudioV2/audioParameter.js.map +1 -1
- package/AudioV2/webAudio/components/webAudioParameterComponent.d.ts +0 -18
- package/AudioV2/webAudio/components/webAudioParameterComponent.js +7 -67
- package/AudioV2/webAudio/components/webAudioParameterComponent.js.map +1 -1
- package/Behaviors/Cameras/interpolatingBehavior.d.ts +58 -0
- package/Behaviors/Cameras/interpolatingBehavior.js +157 -0
- package/Behaviors/Cameras/interpolatingBehavior.js.map +1 -0
- package/Cameras/Inputs/arcRotateCameraPointersInput.d.ts +5 -20
- package/Cameras/Inputs/arcRotateCameraPointersInput.js +9 -69
- package/Cameras/Inputs/arcRotateCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraKeyboardInput.d.ts +81 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js +223 -0
- package/Cameras/Inputs/geospatialCameraKeyboardInput.js.map +1 -0
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js +1 -1
- package/Cameras/Inputs/geospatialCameraMouseWheelInput.js.map +1 -1
- package/Cameras/Inputs/geospatialCameraPointersInput.d.ts +17 -21
- package/Cameras/Inputs/geospatialCameraPointersInput.js +49 -71
- package/Cameras/Inputs/geospatialCameraPointersInput.js.map +1 -1
- package/Cameras/Inputs/orbitCameraPointersInput.d.ts +49 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js +105 -0
- package/Cameras/Inputs/orbitCameraPointersInput.js.map +1 -0
- package/Cameras/Limits/geospatialLimits.d.ts +60 -0
- package/Cameras/Limits/geospatialLimits.js +89 -0
- package/Cameras/Limits/geospatialLimits.js.map +1 -0
- package/Cameras/camera.js +1 -0
- package/Cameras/camera.js.map +1 -1
- package/Cameras/cameraMovement.d.ts +150 -0
- package/Cameras/cameraMovement.js +190 -0
- package/Cameras/cameraMovement.js.map +1 -0
- package/Cameras/geospatialCamera.d.ts +78 -49
- package/Cameras/geospatialCamera.js +210 -191
- package/Cameras/geospatialCamera.js.map +1 -1
- package/Cameras/geospatialCameraInputsManager.d.ts +5 -0
- package/Cameras/geospatialCameraInputsManager.js +9 -0
- package/Cameras/geospatialCameraInputsManager.js.map +1 -1
- package/Cameras/geospatialCameraMovement.d.ts +66 -0
- package/Cameras/geospatialCameraMovement.js +199 -0
- package/Cameras/geospatialCameraMovement.js.map +1 -0
- package/Cameras/targetCamera.js +0 -4
- package/Cameras/targetCamera.js.map +1 -1
- package/Culling/ray.core.js +1 -1
- package/Culling/ray.core.js.map +1 -1
- package/Debug/debugLayer.d.ts +1 -1
- package/Debug/debugLayer.js.map +1 -1
- package/Decorators/nodeDecorator.d.ts +9 -7
- package/Decorators/nodeDecorator.js +9 -7
- package/Decorators/nodeDecorator.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +14 -6
- package/Engines/Native/nativeInterfaces.js +6 -1
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheSampler.js +4 -0
- package/Engines/WebGPU/webgpuCacheSampler.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +2 -2
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/nativeEngine.js +2 -2
- package/Engines/nativeEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVectorMathBlocks.js.map +1 -1
- package/FlowGraph/flowGraphMath.d.ts +25 -0
- package/FlowGraph/flowGraphMath.js +40 -0
- package/FlowGraph/flowGraphMath.js.map +1 -0
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/glowLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Layers/highlightLayerBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/basePostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.d.ts +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js +2 -2
- package/FrameGraph/Node/Blocks/PostProcesses/baseWithPropertiesPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/circleOfConfusionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/colorCorrectionPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/depthOfFieldPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/filterPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/imageProcessingPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssao2PostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js +1 -1
- package/FrameGraph/Node/Blocks/PostProcesses/ssrPostProcessBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js +26 -0
- package/FrameGraph/Node/Blocks/Rendering/baseObjectRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +48 -22
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js +3 -3
- package/FrameGraph/Node/Blocks/Textures/clearBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.d.ts +3 -0
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js +14 -1
- package/FrameGraph/Node/Blocks/Textures/copyTextureBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js +1 -1
- package/FrameGraph/Node/Blocks/Textures/generateMipmapsBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/nodeRenderGraph.js +2 -1
- package/FrameGraph/Node/nodeRenderGraph.js.map +1 -1
- package/FrameGraph/Passes/{cullPass.d.ts → objectListPass.d.ts} +8 -8
- package/FrameGraph/Passes/{cullPass.js → objectListPass.js} +9 -9
- package/FrameGraph/Passes/objectListPass.js.map +1 -0
- package/FrameGraph/Passes/renderPass.d.ts +6 -2
- package/FrameGraph/Passes/renderPass.js +14 -2
- package/FrameGraph/Passes/renderPass.js.map +1 -1
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js +2 -2
- package/FrameGraph/Tasks/Misc/cullObjectsTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +4 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +3 -4
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +10 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/objectRendererTask.d.ts +8 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js +13 -0
- package/FrameGraph/Tasks/Rendering/objectRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +2 -3
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +1 -2
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.d.ts +3 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js +11 -1
- package/FrameGraph/Tasks/Rendering/utilityLayerRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.d.ts +1 -1
- package/FrameGraph/Tasks/Texture/clearTextureTask.js +7 -5
- package/FrameGraph/Tasks/Texture/clearTextureTask.js.map +1 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.d.ts +4 -0
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js +7 -1
- package/FrameGraph/Tasks/Texture/copyToTextureTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +10 -4
- package/FrameGraph/frameGraph.js +22 -9
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +2 -1
- package/FrameGraph/frameGraphRenderContext.js +22 -3
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/FrameGraph/frameGraphTask.js +3 -3
- package/FrameGraph/frameGraphTask.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -1
- package/FrameGraph/index.js +1 -1
- package/FrameGraph/index.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +5 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js +6 -5
- package/Materials/Node/Blocks/GaussianSplatting/splatReaderBlock.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.js +2 -1
- package/Materials/PBR/openpbrMaterial.js.map +1 -1
- package/Materials/floatingOriginMatrixOverrides.js +19 -0
- package/Materials/floatingOriginMatrixOverrides.js.map +1 -1
- package/Materials/shaderMaterial.d.ts +9 -0
- package/Materials/shaderMaterial.js +39 -2
- package/Materials/shaderMaterial.js.map +1 -1
- package/Maths/math.vector.functions.d.ts +5 -24
- package/Maths/math.vector.functions.js +32 -35
- package/Maths/math.vector.functions.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +51 -16
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/Node/Blocks/randomBlock.js +11 -11
- package/Meshes/Node/Blocks/randomBlock.js.map +1 -1
- package/Meshes/csg2.js +1 -1
- package/Meshes/csg2.js.map +1 -1
- package/Meshes/thinInstanceMesh.js +15 -0
- package/Meshes/thinInstanceMesh.js.map +1 -1
- package/Misc/copyTextureToTexture.d.ts +8 -1
- package/Misc/copyTextureToTexture.js +16 -2
- package/Misc/copyTextureToTexture.js.map +1 -1
- package/Misc/fileTools.js.map +1 -1
- package/Misc/tools.d.ts +3 -0
- package/Misc/tools.js +43 -4
- package/Misc/tools.js.map +1 -1
- package/Particles/EmitterTypes/coneParticleEmitter.d.ts +6 -4
- package/Particles/EmitterTypes/coneParticleEmitter.js +18 -12
- package/Particles/EmitterTypes/coneParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -3
- package/Particles/EmitterTypes/customParticleEmitter.js +8 -6
- package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.d.ts +3 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js +7 -1
- package/Particles/EmitterTypes/sphereParticleEmitter.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +2 -1
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.d.ts +15 -4
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js +66 -36
- package/Particles/Node/Blocks/Emitters/coneShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +0 -4
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +1 -8
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +13 -9
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +36 -23
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +10 -1
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +50 -17
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/emitters.functions.d.ts +6 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js +13 -0
- package/Particles/Node/Blocks/Emitters/emitters.functions.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.d.ts +2 -2
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js +5 -1
- package/Particles/Node/Blocks/Emitters/meshShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +3 -1
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +16 -1
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +67 -14
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js +1 -1
- package/Particles/Node/Blocks/Update/basicColorUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +1 -1
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +3 -3
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateSizeBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateSizeBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +1 -0
- package/Particles/Node/Blocks/index.js +1 -0
- package/Particles/Node/Blocks/index.js.map +1 -1
- package/Particles/Node/Blocks/particleInputBlock.js +3 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -1
- package/Particles/Node/Blocks/particleRandomBlock.d.ts +5 -2
- package/Particles/Node/Blocks/particleRandomBlock.js +40 -22
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.d.ts +21 -9
- package/Particles/Node/Blocks/systemBlock.js +37 -22
- package/Particles/Node/Blocks/systemBlock.js.map +1 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +7 -1
- package/Particles/Node/Enums/nodeParticleContextualSources.js +6 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -1
- package/Particles/Node/nodeParticleBuildState.d.ts +5 -5
- package/Particles/Node/nodeParticleBuildState.js +14 -5
- package/Particles/Node/nodeParticleBuildState.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.helper.d.ts +0 -2
- package/Particles/Node/nodeParticleSystemSet.helper.js +586 -148
- package/Particles/Node/nodeParticleSystemSet.helper.js.map +1 -1
- package/Particles/Node/nodeParticleSystemSet.js +1 -1
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -1
- package/Particles/particle.d.ts +4 -0
- package/Particles/particle.js +2 -0
- package/Particles/particle.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +3 -7
- package/Particles/thinParticleSystem.function.d.ts +3 -3
- package/Particles/thinParticleSystem.function.js +11 -8
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.js +5 -7
- package/Particles/thinParticleSystem.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js +2 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.js.map +1 -1
- package/Rendering/prePassRenderer.js +4 -1
- package/Rendering/prePassRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +5 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/Shaders/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/Shaders/copyTextureToTexture.fragment.js +2 -2
- package/Shaders/copyTextureToTexture.fragment.js.map +1 -1
- package/Shaders/gaussianSplatting.vertex.js +3 -3
- package/Shaders/gaussianSplatting.vertex.js.map +1 -1
- package/Shaders/gaussianSplattingDepth.vertex.js +2 -2
- package/Shaders/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +35 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js +2 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js +1 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplattingVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/copyTextureToTexture.fragment.js +3 -3
- package/ShadersWGSL/copyTextureToTexture.fragment.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -2
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/XR/webXRSessionManager.js +4 -0
- package/XR/webXRSessionManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -3
- package/scene.js +8 -7
- package/scene.js.map +1 -1
- package/FrameGraph/Passes/cullPass.js.map +0 -1
|
@@ -34,6 +34,15 @@ export class CopyTextureToTexture {
|
|
|
34
34
|
set source(texture) {
|
|
35
35
|
this._source = texture;
|
|
36
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Gets or sets the LOD level to copy from the source texture
|
|
39
|
+
*/
|
|
40
|
+
get lodLevel() {
|
|
41
|
+
return this._lodLevel;
|
|
42
|
+
}
|
|
43
|
+
set lodLevel(level) {
|
|
44
|
+
this._lodLevel = level;
|
|
45
|
+
}
|
|
37
46
|
_textureIsInternal(texture) {
|
|
38
47
|
return texture.getInternalTexture === undefined;
|
|
39
48
|
}
|
|
@@ -49,6 +58,8 @@ export class CopyTextureToTexture {
|
|
|
49
58
|
this._shadersLoaded = false;
|
|
50
59
|
this._engine = engine;
|
|
51
60
|
this._isDepthTexture = isDepthTexture;
|
|
61
|
+
this._lodLevel = 0;
|
|
62
|
+
this._conversion = 0 /* ConversionMode.None */;
|
|
52
63
|
this._renderer = new EffectRenderer(engine);
|
|
53
64
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
54
65
|
this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);
|
|
@@ -75,7 +86,7 @@ export class CopyTextureToTexture {
|
|
|
75
86
|
name: "CopyTextureToTexture",
|
|
76
87
|
fragmentShader: "copyTextureToTexture",
|
|
77
88
|
useShaderStore: true,
|
|
78
|
-
uniformNames: ["conversion"],
|
|
89
|
+
uniformNames: ["conversion", "lodLevel"],
|
|
79
90
|
samplerNames: ["textureSampler"],
|
|
80
91
|
defines,
|
|
81
92
|
shaderLanguage: this._shaderLanguage,
|
|
@@ -98,6 +109,7 @@ export class CopyTextureToTexture {
|
|
|
98
109
|
this._effectWrapper.effect.setTexture("textureSampler", this._source);
|
|
99
110
|
}
|
|
100
111
|
this._effectWrapper.effect.setFloat("conversion", this._conversion);
|
|
112
|
+
this._effectWrapper.effect.setFloat("lodLevel", this._lodLevel);
|
|
101
113
|
});
|
|
102
114
|
}
|
|
103
115
|
/**
|
|
@@ -112,14 +124,16 @@ export class CopyTextureToTexture {
|
|
|
112
124
|
* @param source The source texture
|
|
113
125
|
* @param destination The destination texture. If null, copy the source to the currently bound framebuffer
|
|
114
126
|
* @param conversion The conversion mode that should be applied when copying
|
|
127
|
+
* @param lod The LOD level to copy from the source texture
|
|
115
128
|
* @returns
|
|
116
129
|
*/
|
|
117
|
-
copy(source, destination = null, conversion = 0 /* ConversionMode.None
|
|
130
|
+
copy(source, destination = null, conversion = 0 /* ConversionMode.None */, lod = 0) {
|
|
118
131
|
if (!this.isReady()) {
|
|
119
132
|
return false;
|
|
120
133
|
}
|
|
121
134
|
this._source = source;
|
|
122
135
|
this._conversion = conversion;
|
|
136
|
+
this._lodLevel = lod;
|
|
123
137
|
const engineDepthFunc = this._engine.getDepthFunction();
|
|
124
138
|
const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates
|
|
125
139
|
this._renderer.render(this._effectWrapper, destination);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copyTextureToTexture.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/copyTextureToTexture.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAG5E,OAAO,EAAE,SAAS,EAAE,gCAA+B;AAKnD;;GAEG;AACH,MAAM,CAAN,IAAkB,cAIjB;AAJD,WAAkB,cAAc;IAC5B,mDAAQ,CAAA;IACR,qEAAiB,CAAA;IACjB,mEAAgB,CAAA;AACpB,CAAC,EAJiB,cAAc,KAAd,cAAc,QAI/B;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAW7B;;OAEG;IACH,IAAW,cAAc;QACrB,OAAO,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,IAAW,MAAM,CAAC,OAAsC;QACpD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;IAEO,kBAAkB,CAAC,OAAsC;QAC7D,OAAQ,OAAuB,CAAC,kBAAkB,KAAK,SAAS,CAAC;IACrE,CAAC;IAED;;;;;OAKG;IACH,YAAY,MAAsB,EAAE,cAAc,GAAG,KAAK,EAAE,YAAY,GAAG,KAAK;QAtChF,2BAA2B;QACjB,oBAAe,+BAAuB;QA+CxC,mBAAc,GAAG,KAAK,CAAC;QAT3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QAEtC,IAAI,CAAC,SAAS,GAAG,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,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAExD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAE5C,IAAI,IAAI,CAAC,eAAe,IAAI,eAAe,EAAE,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Gets the effect wrapper used for the copy\r\n */\r\n public get effectWrapper() {\r\n return this._effectWrapper;\r\n }\r\n\r\n /**\r\n * Gets or sets the source texture\r\n */\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n public set source(texture: InternalTexture | ThinTexture) {\r\n this._source = texture;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @returns\r\n */\r\n public copy(source: InternalTexture | ThinTexture, destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null, conversion = ConversionMode.None): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
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,CAAC;QACtB,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QAErB,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,CAAC;QACxD,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,CAAC,+EAA+E;QAErI,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAExD,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;QAE5C,IAAI,IAAI,CAAC,eAAe,IAAI,eAAe,EAAE,CAAC;YAC1C,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,CAAC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACI,OAAO;QACV,IAAI,CAAC,cAAc,EAAE,OAAO,EAAE,CAAC;QAC/B,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;CACJ","sourcesContent":["import type { AbstractEngine } from \"core/Engines/abstractEngine\";\r\nimport type { InternalTexture } from \"../Materials/Textures/internalTexture\";\r\nimport { EffectRenderer, EffectWrapper } from \"../Materials/effectRenderer\";\r\nimport type { IRenderTargetTexture, RenderTargetWrapper } from \"../Engines/renderTargetWrapper\";\r\nimport type { ThinTexture } from \"../Materials/Textures/thinTexture\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport type { Nullable } from \"core/types\";\r\n\r\nimport { ShaderLanguage } from \"core/Materials/shaderLanguage\";\r\n\r\n/**\r\n * Conversion modes available when copying a texture into another one\r\n */\r\nexport const enum ConversionMode {\r\n None = 0,\r\n ToLinearSpace = 1,\r\n ToGammaSpace = 2,\r\n}\r\n\r\n/**\r\n * Class used for fast copy from one texture to another\r\n */\r\nexport class CopyTextureToTexture {\r\n private _engine: AbstractEngine;\r\n private _isDepthTexture: boolean;\r\n private _renderer: EffectRenderer;\r\n private _effectWrapper: EffectWrapper;\r\n private _source: InternalTexture | ThinTexture;\r\n private _conversion: number;\r\n private _lodLevel: number;\r\n\r\n /** Shader language used */\r\n protected _shaderLanguage = ShaderLanguage.GLSL;\r\n\r\n /**\r\n * Gets the shader language\r\n */\r\n public get shaderLanguage(): ShaderLanguage {\r\n return this._shaderLanguage;\r\n }\r\n\r\n /**\r\n * Gets the effect wrapper used for the copy\r\n */\r\n public get effectWrapper() {\r\n return this._effectWrapper;\r\n }\r\n\r\n /**\r\n * Gets or sets the source texture\r\n */\r\n public get source() {\r\n return this._source;\r\n }\r\n\r\n public set source(texture: InternalTexture | ThinTexture) {\r\n this._source = texture;\r\n }\r\n\r\n /**\r\n * Gets or sets the LOD level to copy from the source texture\r\n */\r\n public get lodLevel(): number {\r\n return this._lodLevel;\r\n }\r\n\r\n public set lodLevel(level: number) {\r\n this._lodLevel = level;\r\n }\r\n\r\n private _textureIsInternal(texture: InternalTexture | ThinTexture): texture is InternalTexture {\r\n return (texture as ThinTexture).getInternalTexture === undefined;\r\n }\r\n\r\n /**\r\n * Constructs a new instance of the class\r\n * @param engine The engine to use for the copy\r\n * @param isDepthTexture True means that we should write (using gl_FragDepth) into the depth texture attached to the destination (default: false)\r\n * @param sameSizeCopy True means that the copy will be done without any sampling (more efficient, but requires the source and destination to be of the same size) (default: false)\r\n */\r\n constructor(engine: AbstractEngine, isDepthTexture = false, sameSizeCopy = false) {\r\n this._engine = engine;\r\n this._isDepthTexture = isDepthTexture;\r\n this._lodLevel = 0;\r\n this._conversion = ConversionMode.None;\r\n\r\n this._renderer = new EffectRenderer(engine);\r\n\r\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\r\n this._initShaderSourceAsync(isDepthTexture, sameSizeCopy);\r\n }\r\n\r\n private _shadersLoaded = false;\r\n private async _initShaderSourceAsync(isDepthTexture: boolean, sameSizeCopy: boolean) {\r\n const engine = this._engine;\r\n\r\n if (engine.isWebGPU) {\r\n this._shaderLanguage = ShaderLanguage.WGSL;\r\n\r\n await import(\"../ShadersWGSL/copyTextureToTexture.fragment\");\r\n } else {\r\n await import(\"../Shaders/copyTextureToTexture.fragment\");\r\n }\r\n\r\n this._shadersLoaded = true;\r\n\r\n const defines: string[] = [];\r\n\r\n if (isDepthTexture) {\r\n defines.push(\"#define DEPTH_TEXTURE\");\r\n }\r\n if (sameSizeCopy) {\r\n defines.push(\"#define NO_SAMPLER\");\r\n }\r\n\r\n this._effectWrapper = new EffectWrapper({\r\n engine: engine,\r\n name: \"CopyTextureToTexture\",\r\n fragmentShader: \"copyTextureToTexture\",\r\n useShaderStore: true,\r\n uniformNames: [\"conversion\", \"lodLevel\"],\r\n samplerNames: [\"textureSampler\"],\r\n defines,\r\n shaderLanguage: this._shaderLanguage,\r\n });\r\n\r\n this._effectWrapper.onApplyObservable.add(() => {\r\n if (isDepthTexture) {\r\n engine.setState(false);\r\n engine.setDepthBuffer(true);\r\n engine.depthCullingState.depthMask = true;\r\n engine.depthCullingState.depthFunc = Constants.ALWAYS;\r\n } else {\r\n engine.depthCullingState.depthMask = false;\r\n // other states are already set by EffectRenderer.applyEffectWrapper\r\n }\r\n\r\n if (this._textureIsInternal(this._source)) {\r\n this._effectWrapper.effect._bindTexture(\"textureSampler\", this._source);\r\n } else {\r\n this._effectWrapper.effect.setTexture(\"textureSampler\", this._source);\r\n }\r\n this._effectWrapper.effect.setFloat(\"conversion\", this._conversion);\r\n this._effectWrapper.effect.setFloat(\"lodLevel\", this._lodLevel);\r\n });\r\n }\r\n\r\n /**\r\n * Indicates if the effect is ready to be used for the copy\r\n * @returns true if \"copy\" can be called without delay, else false\r\n */\r\n public isReady(): boolean {\r\n return this._shadersLoaded && !!this._effectWrapper?.effect?.isReady();\r\n }\r\n\r\n /**\r\n * Copy one texture into another\r\n * @param source The source texture\r\n * @param destination The destination texture. If null, copy the source to the currently bound framebuffer\r\n * @param conversion The conversion mode that should be applied when copying\r\n * @param lod The LOD level to copy from the source texture\r\n * @returns\r\n */\r\n public copy(\r\n source: InternalTexture | ThinTexture,\r\n destination: Nullable<RenderTargetWrapper | IRenderTargetTexture> = null,\r\n conversion = ConversionMode.None,\r\n lod = 0\r\n ): boolean {\r\n if (!this.isReady()) {\r\n return false;\r\n }\r\n\r\n this._source = source;\r\n this._conversion = conversion;\r\n this._lodLevel = lod;\r\n\r\n const engineDepthFunc = this._engine.getDepthFunction();\r\n const engineDepthMask = this._engine.getDepthWrite(); // for some reasons, depthWrite is not restored by EffectRenderer.restoreStates\r\n\r\n this._renderer.render(this._effectWrapper, destination);\r\n\r\n this._engine.setDepthWrite(engineDepthMask);\r\n\r\n if (this._isDepthTexture && engineDepthFunc) {\r\n this._engine.setDepthFunction(engineDepthFunc);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Releases all the resources used by the class\r\n */\r\n public dispose(): void {\r\n this._effectWrapper?.dispose();\r\n this._renderer.dispose();\r\n }\r\n}\r\n"]}
|
package/Misc/fileTools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/fileTools.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAItD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC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B,KAAoD;YAC3E,gBAAgB,CAAC,YAAY,GAAG,KAAK,CAAC;QAC1C,CAAC;KACJ,CAAC,CAAC;AACP,CAAC,CAAC;AAEF,mBAAmB,CAAC,uBAAuB,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-return */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { WebRequest } from \"./webRequest\";\r\nimport { IsWindowObjectExist } from \"./domManagement\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IOfflineProvider } from \"../Offline/IOfflineProvider\";\r\nimport type { IFileRequest } from \"./fileRequest\";\r\nimport { Observable } from \"./observable\";\r\nimport { FilesInputStore } from \"./filesInputStore\";\r\nimport { RetryStrategy } from \"./retryStrategy\";\r\nimport { BaseError, ErrorCodes, RuntimeError } from \"./error\";\r\nimport { DecodeBase64ToBinary, DecodeBase64ToString, EncodeArrayBufferToBase64 } from \"./stringTools\";\r\nimport { _FunctionContainer } from \"../Engines/Processors/shaderProcessor\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"./logger\";\r\nimport { TimingTools } from \"./timingTools\";\r\nimport type { INative } from \"../Engines/Native/nativeInterfaces\";\r\nimport { EngineFunctionContext } from \"core/Engines/abstractEngine.functions\";\r\nimport { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nconst Base64DataUrlRegEx = new RegExp(/^data:([^,]+\\/[^,]+)?;base64,/i);\r\ndeclare const _native: INative;\r\n\r\n/** @ignore */\r\nexport class LoadFileError extends RuntimeError {\r\n public request?: WebRequest;\r\n public file?: File;\r\n\r\n /**\r\n * Creates a new LoadFileError\r\n * @param message defines the message of the error\r\n * @param object defines the optional web request\r\n */\r\n constructor(message: string, object?: WebRequest | File) {\r\n super(message, ErrorCodes.LoadFileError);\r\n\r\n this.name = \"LoadFileError\";\r\n BaseError._setPrototypeOf(this, LoadFileError.prototype);\r\n\r\n if (object instanceof WebRequest) {\r\n this.request = object;\r\n } else {\r\n this.file = object;\r\n }\r\n }\r\n}\r\n\r\n/** @ignore */\r\nexport class RequestFileError extends RuntimeError {\r\n /**\r\n * Creates a new LoadFileError\r\n * @param message defines the message of the error\r\n * @param request defines the optional web request\r\n */\r\n constructor(\r\n message: string,\r\n public request: WebRequest\r\n ) {\r\n super(message, ErrorCodes.RequestFileError);\r\n this.name = \"RequestFileError\";\r\n BaseError._setPrototypeOf(this, RequestFileError.prototype);\r\n }\r\n}\r\n\r\n/** @ignore */\r\nexport class ReadFileError extends RuntimeError {\r\n /**\r\n * Creates a new ReadFileError\r\n * @param message defines the message of the error\r\n * @param file defines the optional file\r\n */\r\n constructor(\r\n message: string,\r\n public file: File\r\n ) {\r\n super(message, ErrorCodes.ReadFileError);\r\n this.name = \"ReadFileError\";\r\n BaseError._setPrototypeOf(this, ReadFileError.prototype);\r\n }\r\n}\r\n\r\n/**\r\n * Removes unwanted characters from an url\r\n * @param url defines the url to clean\r\n * @returns the cleaned url\r\n */\r\nconst CleanUrl = (url: string): string => {\r\n url = url.replace(/#/gm, \"%23\");\r\n return url;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport const FileToolsOptions: {\r\n DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;\r\n BaseUrl: string;\r\n CorsBehavior: string | ((url: string | string[]) => string);\r\n PreprocessUrl: (url: string) => string;\r\n ScriptBaseUrl: string;\r\n ScriptPreprocessUrl: (url: string) => string;\r\n CleanUrl: (url: string) => string;\r\n} = {\r\n /**\r\n * Gets or sets the retry strategy to apply when an error happens while loading an asset.\r\n * When defining this function, return the wait time before trying again or return -1 to\r\n * stop retrying and error out.\r\n */\r\n DefaultRetryStrategy: RetryStrategy.ExponentialBackoff(),\r\n\r\n /**\r\n * Gets or sets the base URL to use to load assets\r\n */\r\n BaseUrl: \"\",\r\n\r\n /**\r\n * Default behaviour for cors in the application.\r\n * It can be a string if the expected behavior is identical in the entire app.\r\n * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)\r\n */\r\n CorsBehavior: \"anonymous\",\r\n\r\n /**\r\n * Gets or sets a function used to pre-process url before using them to load assets\r\n * @param url\r\n * @returns the processed url\r\n */\r\n PreprocessUrl: (url: string) => url,\r\n\r\n /**\r\n * Gets or sets the base URL to use to load scripts\r\n * Used for both JS and WASM\r\n */\r\n ScriptBaseUrl: \"\",\r\n /**\r\n * Gets or sets a function used to pre-process script url before using them to load.\r\n * Used for both JS and WASM\r\n * @param url defines the url to process\r\n * @returns the processed url\r\n */\r\n ScriptPreprocessUrl: (url: string) => url,\r\n\r\n /**\r\n * Gets or sets a function used to clean the url before using it to load assets\r\n * @param url defines the url to clean\r\n * @returns the cleaned url\r\n */\r\n CleanUrl,\r\n};\r\n\r\n/**\r\n * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.\r\n * @param url define the url we are trying\r\n * @param element define the dom element where to configure the cors policy\r\n * @internal\r\n */\r\nexport const SetCorsBehavior = (url: string | string[], element: { crossOrigin: string | null }): void => {\r\n if (url && url.indexOf(\"data:\") === 0) {\r\n return;\r\n }\r\n\r\n if (FileToolsOptions.CorsBehavior) {\r\n if (typeof FileToolsOptions.CorsBehavior === \"string\" || FileToolsOptions.CorsBehavior instanceof String) {\r\n element.crossOrigin = <string>FileToolsOptions.CorsBehavior;\r\n } else {\r\n const result = FileToolsOptions.CorsBehavior(url);\r\n if (result) {\r\n element.crossOrigin = result;\r\n }\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Configuration used to load images\r\n * @see https://playground.babylonjs.com/#DKMEZK#2\r\n */\r\nexport const LoadImageConfiguration: {\r\n /**\r\n * Use this callback if you want to provide the required size of an image before loading it.\r\n */\r\n getRequiredSize: Nullable<\r\n (input: string | ArrayBuffer | ArrayBufferView | Blob) => {\r\n width: number;\r\n height: number;\r\n }\r\n >;\r\n} = {\r\n getRequiredSize: null,\r\n};\r\n\r\n/**\r\n * Loads an image as an HTMLImageElement.\r\n * @param input url string, ArrayBuffer, or Blob to load\r\n * @param onLoad callback called when the image successfully loads\r\n * @param onError callback called when the image fails to load\r\n * @param offlineProvider offline provider for caching\r\n * @param mimeType optional mime type\r\n * @param imageBitmapOptions\r\n * @param engine the engine instance to use\r\n * @returns the HTMLImageElement of the loaded image\r\n * @internal\r\n */\r\nexport const LoadImage = (\r\n input: string | ArrayBuffer | ArrayBufferView | Blob,\r\n onLoad: (img: HTMLImageElement | ImageBitmap) => void,\r\n onError: (message?: string, exception?: any) => void,\r\n offlineProvider: Nullable<IOfflineProvider>,\r\n mimeType: string = \"\",\r\n imageBitmapOptions?: ImageBitmapOptions,\r\n engine = EngineStore.LastCreatedEngine\r\n): Nullable<HTMLImageElement> => {\r\n if (typeof HTMLImageElement === \"undefined\" && !engine?._features.forceBitmapOverHTMLImageElement) {\r\n onError(\"LoadImage is only supported in web or BabylonNative environments.\");\r\n return null;\r\n }\r\n\r\n let url: string;\r\n let usingObjectURL = false;\r\n\r\n if (input instanceof ArrayBuffer || ArrayBuffer.isView(input)) {\r\n if (typeof Blob !== \"undefined\" && typeof URL !== \"undefined\") {\r\n url = URL.createObjectURL(new Blob([input], { type: mimeType }));\r\n usingObjectURL = true;\r\n } else {\r\n url = `data:${mimeType};base64,` + EncodeArrayBufferToBase64(input);\r\n }\r\n } else if (input instanceof Blob) {\r\n url = URL.createObjectURL(input);\r\n usingObjectURL = true;\r\n } else {\r\n url = FileToolsOptions.CleanUrl(input);\r\n url = FileToolsOptions.PreprocessUrl(url);\r\n }\r\n\r\n const onErrorHandler = (exception: any) => {\r\n if (onError) {\r\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\r\n const inputText = url || input.toString();\r\n onError(`Error while trying to load image: ${inputText.indexOf(\"http\") === 0 || inputText.length <= 128 ? inputText : inputText.slice(0, 128) + \"...\"}`, exception);\r\n }\r\n };\r\n\r\n if (engine?._features.forceBitmapOverHTMLImageElement) {\r\n LoadFile(\r\n url,\r\n (data) => {\r\n engine\r\n .createImageBitmap(new Blob([data], { type: mimeType }), { premultiplyAlpha: \"none\", ...imageBitmapOptions })\r\n // eslint-disable-next-line github/no-then\r\n .then((imgBmp) => {\r\n onLoad(imgBmp);\r\n if (usingObjectURL) {\r\n URL.revokeObjectURL(url);\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((reason) => {\r\n if (onError) {\r\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\r\n onError(\"Error while trying to load image: \" + input, reason);\r\n }\r\n });\r\n },\r\n undefined,\r\n offlineProvider || undefined,\r\n true,\r\n (request, exception) => {\r\n onErrorHandler(exception);\r\n }\r\n );\r\n\r\n return null;\r\n }\r\n\r\n const img = new Image();\r\n if (LoadImageConfiguration.getRequiredSize) {\r\n const size = LoadImageConfiguration.getRequiredSize(input);\r\n if (size.width) {\r\n img.width = size.width;\r\n }\r\n if (size.height) {\r\n img.height = size.height;\r\n }\r\n }\r\n SetCorsBehavior(url, img);\r\n\r\n const handlersList: { target: any; name: string; handler: any }[] = [];\r\n\r\n const loadHandlersList = () => {\r\n for (const handler of handlersList) {\r\n handler.target.addEventListener(handler.name, handler.handler);\r\n }\r\n };\r\n\r\n const unloadHandlersList = () => {\r\n for (const handler of handlersList) {\r\n handler.target.removeEventListener(handler.name, handler.handler);\r\n }\r\n handlersList.length = 0;\r\n };\r\n\r\n const loadHandler = () => {\r\n unloadHandlersList();\r\n\r\n onLoad(img);\r\n\r\n // Must revoke the URL after calling onLoad to avoid security exceptions in\r\n // certain scenarios (e.g. when hosted in vscode).\r\n if (usingObjectURL && img.src) {\r\n URL.revokeObjectURL(img.src);\r\n }\r\n };\r\n\r\n const errorHandler = (err: any) => {\r\n unloadHandlersList();\r\n\r\n onErrorHandler(err);\r\n\r\n if (usingObjectURL && img.src) {\r\n URL.revokeObjectURL(img.src);\r\n }\r\n };\r\n\r\n const cspHandler = (err: any) => {\r\n if (err.blockedURI !== img.src || err.disposition === \"report\") {\r\n return;\r\n }\r\n\r\n unloadHandlersList();\r\n const cspException = new Error(`CSP violation of policy ${err.effectiveDirective} ${err.blockedURI}. Current policy is ${err.originalPolicy}`);\r\n\r\n EngineStore.UseFallbackTexture = false;\r\n onErrorHandler(cspException);\r\n if (usingObjectURL && img.src) {\r\n URL.revokeObjectURL(img.src);\r\n }\r\n img.src = \"\";\r\n };\r\n\r\n handlersList.push({ target: img, name: \"load\", handler: loadHandler });\r\n handlersList.push({ target: img, name: \"error\", handler: errorHandler });\r\n handlersList.push({ target: document, name: \"securitypolicyviolation\", handler: cspHandler });\r\n\r\n loadHandlersList();\r\n\r\n const fromBlob = url.substring(0, 5) === \"blob:\";\r\n const fromData = url.substring(0, 5) === \"data:\";\r\n const noOfflineSupport = () => {\r\n if (fromBlob || fromData || !WebRequest.IsCustomRequestAvailable) {\r\n img.src = url;\r\n } else {\r\n LoadFile(\r\n url,\r\n (data, _, contentType) => {\r\n const type = !mimeType && contentType ? contentType : mimeType;\r\n const blob = new Blob([data], { type });\r\n const url = URL.createObjectURL(blob);\r\n usingObjectURL = true;\r\n img.src = url;\r\n },\r\n undefined,\r\n offlineProvider || undefined,\r\n true,\r\n (_request, exception) => {\r\n onErrorHandler(exception);\r\n }\r\n );\r\n }\r\n };\r\n\r\n const loadFromOfflineSupport = () => {\r\n if (offlineProvider) {\r\n offlineProvider.loadImage(url, img);\r\n }\r\n };\r\n\r\n if (!fromBlob && !fromData && offlineProvider && offlineProvider.enableTexturesOffline) {\r\n offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);\r\n } else {\r\n if (url.indexOf(\"file:\") !== -1) {\r\n const textureName = decodeURIComponent(url.substring(5).toLowerCase());\r\n if (FilesInputStore.FilesToLoad[textureName] && typeof URL !== \"undefined\") {\r\n try {\r\n let blobURL;\r\n try {\r\n blobURL = URL.createObjectURL(FilesInputStore.FilesToLoad[textureName]);\r\n } catch (ex) {\r\n // Chrome doesn't support oneTimeOnly parameter\r\n blobURL = URL.createObjectURL(FilesInputStore.FilesToLoad[textureName]);\r\n }\r\n img.src = blobURL;\r\n usingObjectURL = true;\r\n } catch (e) {\r\n img.src = \"\";\r\n }\r\n return img;\r\n }\r\n }\r\n\r\n noOfflineSupport();\r\n }\r\n\r\n return img;\r\n};\r\n\r\n/**\r\n * Reads a file from a File object\r\n * @param file defines the file to load\r\n * @param onSuccess defines the callback to call when data is loaded\r\n * @param onProgress defines the callback to call during loading process\r\n * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer\r\n * @param onError defines the callback to call when an error occurs\r\n * @returns a file request object\r\n * @internal\r\n */\r\nexport const ReadFile = (\r\n file: File,\r\n onSuccess: (data: any) => void,\r\n onProgress?: (ev: ProgressEvent) => any,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: ReadFileError) => void\r\n): IFileRequest => {\r\n const reader = new FileReader();\r\n const fileRequest: IFileRequest = {\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n abort: () => reader.abort(),\r\n };\r\n\r\n reader.onloadend = () => fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n if (onError) {\r\n reader.onerror = () => {\r\n onError(new ReadFileError(`Unable to read ${file.name}`, file));\r\n };\r\n }\r\n reader.onload = (e) => {\r\n //target doesn't have result from ts 1.3\r\n onSuccess((<any>e.target)[\"result\"]);\r\n };\r\n if (onProgress) {\r\n reader.onprogress = onProgress;\r\n }\r\n if (!useArrayBuffer) {\r\n // Asynchronous read\r\n reader.readAsText(file);\r\n } else {\r\n reader.readAsArrayBuffer(file);\r\n }\r\n\r\n return fileRequest;\r\n};\r\n\r\n/**\r\n * Loads a file from a url, a data url, or a file url\r\n * @param fileOrUrl file, url, data url, or file url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @param onOpened\r\n * @returns a file request object\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const LoadFile = (\r\n fileOrUrl: File | string,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string, contentType?: Nullable<string>) => void,\r\n onProgress?: (ev: ProgressEvent) => void,\r\n offlineProvider?: Nullable<IOfflineProvider>,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n): IFileRequest => {\r\n if ((fileOrUrl as File).name) {\r\n return ReadFile(\r\n fileOrUrl as File,\r\n onSuccess,\r\n onProgress,\r\n useArrayBuffer,\r\n onError\r\n ? (error: ReadFileError) => {\r\n onError(undefined, error);\r\n }\r\n : undefined\r\n );\r\n }\r\n\r\n const url = fileOrUrl as string;\r\n\r\n // If file and file input are set\r\n if (url.indexOf(\"file:\") !== -1) {\r\n let fileName = decodeURIComponent(url.substring(5).toLowerCase());\r\n if (fileName.indexOf(\"./\") === 0) {\r\n fileName = fileName.substring(2);\r\n }\r\n const file = FilesInputStore.FilesToLoad[fileName];\r\n if (file) {\r\n return ReadFile(file, onSuccess, onProgress, useArrayBuffer, onError ? (error) => onError(undefined, new LoadFileError(error.message, error.file)) : undefined);\r\n }\r\n }\r\n\r\n // For a Base64 Data URL\r\n const { match, type } = TestBase64DataUrl(url);\r\n if (match) {\r\n const fileRequest: IFileRequest = {\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n abort: () => () => {},\r\n };\r\n\r\n try {\r\n const data = useArrayBuffer ? DecodeBase64UrlToBinary(url) : DecodeBase64UrlToString(url);\r\n onSuccess(data, undefined, type);\r\n } catch (error) {\r\n if (onError) {\r\n onError(undefined, error);\r\n } else {\r\n Logger.Error(error.message || \"Failed to parse the Data URL\");\r\n }\r\n }\r\n\r\n TimingTools.SetImmediate(() => {\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n });\r\n\r\n return fileRequest;\r\n }\r\n\r\n return RequestFile(\r\n url,\r\n (data, request) => {\r\n onSuccess(data, request?.responseURL, request?.getResponseHeader(\"content-type\"));\r\n },\r\n onProgress,\r\n offlineProvider,\r\n useArrayBuffer,\r\n onError\r\n ? (error) => {\r\n onError(error.request, new LoadFileError(error.message, error.request));\r\n }\r\n : undefined,\r\n onOpened\r\n );\r\n};\r\n\r\n/**\r\n * Loads a file from a url\r\n * @param url url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @param onOpened callback called when the web request is opened\r\n * @returns a file request object\r\n * @internal\r\n */\r\nexport const RequestFile = (\r\n url: string,\r\n onSuccess?: (data: string | ArrayBuffer, request?: WebRequest) => void,\r\n onProgress?: (event: ProgressEvent) => void,\r\n offlineProvider?: Nullable<IOfflineProvider>,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: RequestFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n): IFileRequest => {\r\n if (offlineProvider !== null) {\r\n offlineProvider ??= EngineStore.LastCreatedScene?.offlineProvider;\r\n }\r\n url = FileToolsOptions.CleanUrl(url);\r\n url = FileToolsOptions.PreprocessUrl(url);\r\n\r\n const loadUrl = FileToolsOptions.BaseUrl + url;\r\n\r\n let aborted = false;\r\n const fileRequest: IFileRequest = {\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n abort: () => (aborted = true),\r\n };\r\n\r\n const requestFile = () => {\r\n let request: Nullable<WebRequest> = new WebRequest();\r\n let retryHandle: Nullable<ReturnType<typeof setTimeout>> = null;\r\n let onReadyStateChange: Nullable<() => void>;\r\n\r\n const unbindEvents = () => {\r\n if (!request) {\r\n return;\r\n }\r\n\r\n if (onProgress) {\r\n request.removeEventListener(\"progress\", onProgress);\r\n }\r\n if (onReadyStateChange) {\r\n request.removeEventListener(\"readystatechange\", onReadyStateChange);\r\n }\r\n request.removeEventListener(\"loadend\", onLoadEnd!);\r\n };\r\n\r\n let onLoadEnd: Nullable<() => void> = () => {\r\n unbindEvents();\r\n\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n fileRequest.onCompleteObservable.clear();\r\n\r\n onProgress = undefined;\r\n onReadyStateChange = null;\r\n onLoadEnd = null;\r\n onError = undefined;\r\n onOpened = undefined;\r\n onSuccess = undefined;\r\n };\r\n\r\n fileRequest.abort = () => {\r\n aborted = true;\r\n\r\n if (onLoadEnd) {\r\n onLoadEnd();\r\n }\r\n\r\n if (request && request.readyState !== (XMLHttpRequest.DONE || 4)) {\r\n request.abort();\r\n }\r\n\r\n if (retryHandle !== null) {\r\n clearTimeout(retryHandle);\r\n retryHandle = null;\r\n }\r\n\r\n request = null;\r\n };\r\n\r\n const handleError = (error: any) => {\r\n const message = error.message || \"Unknown error\";\r\n if (onError && request) {\r\n onError(new RequestFileError(message, request));\r\n } else {\r\n Logger.Error(message);\r\n }\r\n };\r\n\r\n const retryLoop = (retryIndex: number) => {\r\n if (!request) {\r\n return;\r\n }\r\n request.open(\"GET\", loadUrl);\r\n\r\n if (onOpened) {\r\n try {\r\n onOpened(request);\r\n } catch (e) {\r\n handleError(e);\r\n return;\r\n }\r\n }\r\n\r\n if (useArrayBuffer) {\r\n request.responseType = \"arraybuffer\";\r\n }\r\n\r\n if (onProgress) {\r\n request.addEventListener(\"progress\", onProgress);\r\n }\r\n\r\n if (onLoadEnd) {\r\n request.addEventListener(\"loadend\", onLoadEnd);\r\n }\r\n\r\n onReadyStateChange = () => {\r\n if (aborted || !request) {\r\n return;\r\n }\r\n\r\n // In case of undefined state in some browsers.\r\n if (request.readyState === (XMLHttpRequest.DONE || 4)) {\r\n // Some browsers have issues where onreadystatechange can be called multiple times with the same value.\r\n if (onReadyStateChange) {\r\n request.removeEventListener(\"readystatechange\", onReadyStateChange);\r\n }\r\n\r\n if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!IsWindowObjectExist() || IsFileURL()))) {\r\n // It's possible for the request to have a success status code but null response if the underlying\r\n // underlying HTTP connection was closed prematurely. See _onHttpResponseClose in xhr2.js. In this\r\n // case we will throw an exception if we call the onSuccess handler because \"data\" will be null\r\n // and that then bypasses the retry strategy.\r\n const data = useArrayBuffer ? request.response : request.responseText;\r\n if (data !== null) {\r\n try {\r\n if (onSuccess) {\r\n onSuccess(data, request);\r\n }\r\n } catch (e) {\r\n handleError(e);\r\n }\r\n return;\r\n }\r\n }\r\n\r\n const retryStrategy = FileToolsOptions.DefaultRetryStrategy;\r\n if (retryStrategy) {\r\n const waitTime = retryStrategy(loadUrl, request, retryIndex);\r\n if (waitTime !== -1) {\r\n // Prevent the request from completing for retry.\r\n unbindEvents();\r\n\r\n request = new WebRequest();\r\n retryHandle = setTimeout(() => retryLoop(retryIndex + 1), waitTime);\r\n return;\r\n }\r\n }\r\n\r\n const error = new RequestFileError(\"Error status: \" + request.status + \" \" + request.statusText + \" - Unable to load \" + loadUrl, request);\r\n if (onError) {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n request.addEventListener(\"readystatechange\", onReadyStateChange);\r\n\r\n request.send();\r\n };\r\n\r\n retryLoop(0);\r\n };\r\n\r\n // Caching all files\r\n if (offlineProvider && offlineProvider.enableSceneOffline && !url.startsWith(\"blob:\")) {\r\n const noOfflineSupport = (request?: any) => {\r\n if (request && request.status > 400) {\r\n if (onError) {\r\n onError(request);\r\n }\r\n } else {\r\n requestFile();\r\n }\r\n };\r\n\r\n const loadFromOfflineSupport = () => {\r\n // TODO: database needs to support aborting and should return a IFileRequest\r\n\r\n if (offlineProvider) {\r\n offlineProvider.loadFile(\r\n FileToolsOptions.BaseUrl + url,\r\n (data) => {\r\n if (!aborted && onSuccess) {\r\n onSuccess(data);\r\n }\r\n\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n },\r\n onProgress\r\n ? (event) => {\r\n if (!aborted && onProgress) {\r\n onProgress(event);\r\n }\r\n }\r\n : undefined,\r\n noOfflineSupport,\r\n useArrayBuffer\r\n );\r\n }\r\n };\r\n\r\n offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);\r\n } else {\r\n requestFile();\r\n }\r\n\r\n return fileRequest;\r\n};\r\n\r\n/**\r\n * Reads the mime type from a URL, if available.\r\n * @param url\r\n * @returns\r\n */\r\nexport const GetMimeType = (url: string): string | undefined => {\r\n const { match, type } = TestBase64DataUrl(url);\r\n if (match) {\r\n return type || undefined;\r\n }\r\n\r\n const lastDot = url.lastIndexOf(\".\");\r\n const extension = url.substring(lastDot + 1).toLowerCase();\r\n\r\n switch (extension) {\r\n case \"glb\":\r\n return \"model/gltf-binary\";\r\n case \"bin\":\r\n return \"application/octet-stream\";\r\n case \"gltf\":\r\n return \"model/gltf+json\";\r\n case \"jpg\":\r\n case \"jpeg\":\r\n return \"image/jpeg\";\r\n case \"png\":\r\n return \"image/png\";\r\n case \"webp\":\r\n return \"image/webp\";\r\n case \"ktx\":\r\n return \"image/ktx\";\r\n case \"ktx2\":\r\n return \"image/ktx2\";\r\n case \"avif\":\r\n return \"image/avif\";\r\n default:\r\n return undefined;\r\n }\r\n};\r\n\r\n/**\r\n * Checks if the loaded document was accessed via `file:`-Protocol.\r\n * @returns boolean\r\n * @internal\r\n */\r\nexport const IsFileURL = (): boolean => {\r\n return typeof location !== \"undefined\" && location.protocol === \"file:\";\r\n};\r\n\r\n/**\r\n * Test if the given uri is a valid base64 data url\r\n * @param uri The uri to test\r\n * @returns True if the uri is a base64 data url or false otherwise\r\n * @internal\r\n */\r\nexport const IsBase64DataUrl = (uri: string): boolean => {\r\n return Base64DataUrlRegEx.test(uri);\r\n};\r\n\r\nexport const TestBase64DataUrl = (uri: string): { match: boolean; type: string } => {\r\n const results = Base64DataUrlRegEx.exec(uri);\r\n if (results === null || results.length === 0) {\r\n return { match: false, type: \"\" };\r\n } else {\r\n const type = results[0].replace(\"data:\", \"\").replace(\";base64,\", \"\");\r\n return { match: true, type };\r\n }\r\n};\r\n\r\n/**\r\n * Decode the given base64 uri.\r\n * @param uri The uri to decode\r\n * @returns The decoded base64 data.\r\n * @internal\r\n */\r\nexport function DecodeBase64UrlToBinary(uri: string): ArrayBuffer {\r\n return DecodeBase64ToBinary(uri.split(\",\")[1]);\r\n}\r\n\r\n/**\r\n * Decode the given base64 uri into a UTF-8 encoded string.\r\n * @param uri The uri to decode\r\n * @returns The decoded base64 data.\r\n * @internal\r\n */\r\nexport const DecodeBase64UrlToString = (uri: string): string => {\r\n return DecodeBase64ToString(uri.split(\",\")[1]);\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n AbstractEngine._FileToolsLoadImage = LoadImage;\r\n EngineFunctionContext.loadFile = LoadFile;\r\n _FunctionContainer.loadFile = LoadFile;\r\n};\r\n\r\ninitSideEffects();\r\n\r\n// deprecated\r\n\r\n/**\r\n * FileTools defined as any.\r\n * This should not be imported or used in future releases or in any module in the framework\r\n * @internal\r\n * @deprecated import the needed function from fileTools.ts\r\n */\r\nexport let FileTools: {\r\n DecodeBase64UrlToBinary: (uri: string) => ArrayBuffer;\r\n DecodeBase64UrlToString: (uri: string) => string;\r\n DefaultRetryStrategy: any;\r\n BaseUrl: any;\r\n CorsBehavior: any;\r\n PreprocessUrl: any;\r\n IsBase64DataUrl: (uri: string) => boolean;\r\n IsFileURL: () => boolean;\r\n LoadFile: (\r\n fileOrUrl: string | File,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest;\r\n LoadImage: (\r\n input: string | ArrayBuffer | Blob | ArrayBufferView,\r\n onLoad: (img: HTMLImageElement | ImageBitmap) => void,\r\n onError: (message?: string, exception?: any) => void,\r\n offlineProvider: Nullable<IOfflineProvider>,\r\n mimeType?: string,\r\n imageBitmapOptions?: ImageBitmapOptions\r\n ) => Nullable<HTMLImageElement>;\r\n ReadFile: (\r\n file: File,\r\n onSuccess: (data: any) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => any,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: ReadFileError) => void\r\n ) => IFileRequest;\r\n RequestFile: (\r\n url: string,\r\n onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void,\r\n onProgress?: (event: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: RequestFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest;\r\n SetCorsBehavior: (url: string | string[], element: { crossOrigin: string | null }) => void;\r\n};\r\n/**\r\n * @internal\r\n */\r\nexport const _injectLTSFileTools = (\r\n DecodeBase64UrlToBinary: (uri: string) => ArrayBuffer,\r\n DecodeBase64UrlToString: (uri: string) => string,\r\n FileToolsOptions: { DefaultRetryStrategy: any; BaseUrl: any; CorsBehavior: any; PreprocessUrl: any; CleanUrl: any },\r\n IsBase64DataUrl: (uri: string) => boolean,\r\n IsFileURL: () => boolean,\r\n LoadFile: (\r\n fileOrUrl: string | File,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest,\r\n LoadImage: (\r\n input: string | ArrayBuffer | ArrayBufferView | Blob,\r\n onLoad: (img: HTMLImageElement | ImageBitmap) => void,\r\n onError: (message?: string, exception?: any) => void,\r\n offlineProvider: Nullable<IOfflineProvider>,\r\n mimeType?: string,\r\n imageBitmapOptions?: ImageBitmapOptions\r\n ) => Nullable<HTMLImageElement>,\r\n ReadFile: (\r\n file: File,\r\n onSuccess: (data: any) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => any,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: ReadFileError) => void\r\n ) => IFileRequest,\r\n RequestFile: (\r\n url: string,\r\n onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void,\r\n onProgress?: (event: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: RequestFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest,\r\n SetCorsBehavior: (url: string | string[], element: { crossOrigin: string | null }) => void\r\n) => {\r\n /**\r\n * Backwards compatibility.\r\n * @internal\r\n * @deprecated\r\n */\r\n FileTools = {\r\n DecodeBase64UrlToBinary,\r\n DecodeBase64UrlToString,\r\n DefaultRetryStrategy: FileToolsOptions.DefaultRetryStrategy,\r\n BaseUrl: FileToolsOptions.BaseUrl,\r\n CorsBehavior: FileToolsOptions.CorsBehavior,\r\n PreprocessUrl: FileToolsOptions.PreprocessUrl,\r\n IsBase64DataUrl,\r\n IsFileURL,\r\n LoadFile,\r\n LoadImage,\r\n ReadFile,\r\n RequestFile,\r\n SetCorsBehavior,\r\n };\r\n\r\n Object.defineProperty(FileTools, \"DefaultRetryStrategy\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.DefaultRetryStrategy;\r\n },\r\n set: function (this: null, value: (url: string, request: WebRequest, retryIndex: number) => number) {\r\n FileToolsOptions.DefaultRetryStrategy = value;\r\n },\r\n });\r\n\r\n Object.defineProperty(FileTools, \"BaseUrl\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.BaseUrl;\r\n },\r\n set: function (this: null, value: string) {\r\n FileToolsOptions.BaseUrl = value;\r\n },\r\n });\r\n\r\n Object.defineProperty(FileTools, \"PreprocessUrl\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.PreprocessUrl;\r\n },\r\n set: function (this: null, value: (url: string) => string) {\r\n FileToolsOptions.PreprocessUrl = value;\r\n },\r\n });\r\n\r\n Object.defineProperty(FileTools, \"CorsBehavior\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.CorsBehavior;\r\n },\r\n set: function (this: null, value: string | ((url: string | string[]) => string)) {\r\n FileToolsOptions.CorsBehavior = value;\r\n },\r\n });\r\n};\r\n\r\n_injectLTSFileTools(DecodeBase64UrlToBinary, DecodeBase64UrlToString, FileToolsOptions, IsBase64DataUrl, IsFileURL, LoadFile, LoadImage, ReadFile, RequestFile, SetCorsBehavior);\r\n"]}
|
|
1
|
+
{"version":3,"file":"fileTools.js","sourceRoot":"","sources":["../../../../dev/core/src/Misc/fileTools.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,yDAAyD;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAItD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,+CAA8C;AAC9E,OAAO,EAAE,cAAc,EAAE,MAAM,2BA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W,EAAE,eAAe,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-return */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { WebRequest } from \"./webRequest\";\r\nimport { IsWindowObjectExist } from \"./domManagement\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { IOfflineProvider } from \"../Offline/IOfflineProvider\";\r\nimport type { IFileRequest } from \"./fileRequest\";\r\nimport { Observable } from \"./observable\";\r\nimport { FilesInputStore } from \"./filesInputStore\";\r\nimport { RetryStrategy } from \"./retryStrategy\";\r\nimport { BaseError, ErrorCodes, RuntimeError } from \"./error\";\r\nimport { DecodeBase64ToBinary, DecodeBase64ToString, EncodeArrayBufferToBase64 } from \"./stringTools\";\r\nimport { _FunctionContainer } from \"../Engines/Processors/shaderProcessor\";\r\nimport { EngineStore } from \"../Engines/engineStore\";\r\nimport { Logger } from \"./logger\";\r\nimport { TimingTools } from \"./timingTools\";\r\nimport { EngineFunctionContext } from \"core/Engines/abstractEngine.functions\";\r\nimport { AbstractEngine } from \"../Engines/abstractEngine\";\r\n\r\nconst Base64DataUrlRegEx = new RegExp(/^data:([^,]+\\/[^,]+)?;base64,/i);\r\n\r\n/** @ignore */\r\nexport class LoadFileError extends RuntimeError {\r\n public request?: WebRequest;\r\n public file?: File;\r\n\r\n /**\r\n * Creates a new LoadFileError\r\n * @param message defines the message of the error\r\n * @param object defines the optional web request\r\n */\r\n constructor(message: string, object?: WebRequest | File) {\r\n super(message, ErrorCodes.LoadFileError);\r\n\r\n this.name = \"LoadFileError\";\r\n BaseError._setPrototypeOf(this, LoadFileError.prototype);\r\n\r\n if (object instanceof WebRequest) {\r\n this.request = object;\r\n } else {\r\n this.file = object;\r\n }\r\n }\r\n}\r\n\r\n/** @ignore */\r\nexport class RequestFileError extends RuntimeError {\r\n /**\r\n * Creates a new LoadFileError\r\n * @param message defines the message of the error\r\n * @param request defines the optional web request\r\n */\r\n constructor(\r\n message: string,\r\n public request: WebRequest\r\n ) {\r\n super(message, ErrorCodes.RequestFileError);\r\n this.name = \"RequestFileError\";\r\n BaseError._setPrototypeOf(this, RequestFileError.prototype);\r\n }\r\n}\r\n\r\n/** @ignore */\r\nexport class ReadFileError extends RuntimeError {\r\n /**\r\n * Creates a new ReadFileError\r\n * @param message defines the message of the error\r\n * @param file defines the optional file\r\n */\r\n constructor(\r\n message: string,\r\n public file: File\r\n ) {\r\n super(message, ErrorCodes.ReadFileError);\r\n this.name = \"ReadFileError\";\r\n BaseError._setPrototypeOf(this, ReadFileError.prototype);\r\n }\r\n}\r\n\r\n/**\r\n * Removes unwanted characters from an url\r\n * @param url defines the url to clean\r\n * @returns the cleaned url\r\n */\r\nconst CleanUrl = (url: string): string => {\r\n url = url.replace(/#/gm, \"%23\");\r\n return url;\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport const FileToolsOptions: {\r\n DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;\r\n BaseUrl: string;\r\n CorsBehavior: string | ((url: string | string[]) => string);\r\n PreprocessUrl: (url: string) => string;\r\n ScriptBaseUrl: string;\r\n ScriptPreprocessUrl: (url: string) => string;\r\n CleanUrl: (url: string) => string;\r\n} = {\r\n /**\r\n * Gets or sets the retry strategy to apply when an error happens while loading an asset.\r\n * When defining this function, return the wait time before trying again or return -1 to\r\n * stop retrying and error out.\r\n */\r\n DefaultRetryStrategy: RetryStrategy.ExponentialBackoff(),\r\n\r\n /**\r\n * Gets or sets the base URL to use to load assets\r\n */\r\n BaseUrl: \"\",\r\n\r\n /**\r\n * Default behaviour for cors in the application.\r\n * It can be a string if the expected behavior is identical in the entire app.\r\n * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)\r\n */\r\n CorsBehavior: \"anonymous\",\r\n\r\n /**\r\n * Gets or sets a function used to pre-process url before using them to load assets\r\n * @param url\r\n * @returns the processed url\r\n */\r\n PreprocessUrl: (url: string) => url,\r\n\r\n /**\r\n * Gets or sets the base URL to use to load scripts\r\n * Used for both JS and WASM\r\n */\r\n ScriptBaseUrl: \"\",\r\n /**\r\n * Gets or sets a function used to pre-process script url before using them to load.\r\n * Used for both JS and WASM\r\n * @param url defines the url to process\r\n * @returns the processed url\r\n */\r\n ScriptPreprocessUrl: (url: string) => url,\r\n\r\n /**\r\n * Gets or sets a function used to clean the url before using it to load assets\r\n * @param url defines the url to clean\r\n * @returns the cleaned url\r\n */\r\n CleanUrl,\r\n};\r\n\r\n/**\r\n * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.\r\n * @param url define the url we are trying\r\n * @param element define the dom element where to configure the cors policy\r\n * @internal\r\n */\r\nexport const SetCorsBehavior = (url: string | string[], element: { crossOrigin: string | null }): void => {\r\n if (url && url.indexOf(\"data:\") === 0) {\r\n return;\r\n }\r\n\r\n if (FileToolsOptions.CorsBehavior) {\r\n if (typeof FileToolsOptions.CorsBehavior === \"string\" || FileToolsOptions.CorsBehavior instanceof String) {\r\n element.crossOrigin = <string>FileToolsOptions.CorsBehavior;\r\n } else {\r\n const result = FileToolsOptions.CorsBehavior(url);\r\n if (result) {\r\n element.crossOrigin = result;\r\n }\r\n }\r\n }\r\n};\r\n\r\n/**\r\n * Configuration used to load images\r\n * @see https://playground.babylonjs.com/#DKMEZK#2\r\n */\r\nexport const LoadImageConfiguration: {\r\n /**\r\n * Use this callback if you want to provide the required size of an image before loading it.\r\n */\r\n getRequiredSize: Nullable<\r\n (input: string | ArrayBuffer | ArrayBufferView | Blob) => {\r\n width: number;\r\n height: number;\r\n }\r\n >;\r\n} = {\r\n getRequiredSize: null,\r\n};\r\n\r\n/**\r\n * Loads an image as an HTMLImageElement.\r\n * @param input url string, ArrayBuffer, or Blob to load\r\n * @param onLoad callback called when the image successfully loads\r\n * @param onError callback called when the image fails to load\r\n * @param offlineProvider offline provider for caching\r\n * @param mimeType optional mime type\r\n * @param imageBitmapOptions\r\n * @param engine the engine instance to use\r\n * @returns the HTMLImageElement of the loaded image\r\n * @internal\r\n */\r\nexport const LoadImage = (\r\n input: string | ArrayBuffer | ArrayBufferView | Blob,\r\n onLoad: (img: HTMLImageElement | ImageBitmap) => void,\r\n onError: (message?: string, exception?: any) => void,\r\n offlineProvider: Nullable<IOfflineProvider>,\r\n mimeType: string = \"\",\r\n imageBitmapOptions?: ImageBitmapOptions,\r\n engine = EngineStore.LastCreatedEngine\r\n): Nullable<HTMLImageElement> => {\r\n if (typeof HTMLImageElement === \"undefined\" && !engine?._features.forceBitmapOverHTMLImageElement) {\r\n onError(\"LoadImage is only supported in web or BabylonNative environments.\");\r\n return null;\r\n }\r\n\r\n let url: string;\r\n let usingObjectURL = false;\r\n\r\n if (input instanceof ArrayBuffer || ArrayBuffer.isView(input)) {\r\n if (typeof Blob !== \"undefined\" && typeof URL !== \"undefined\") {\r\n url = URL.createObjectURL(new Blob([input], { type: mimeType }));\r\n usingObjectURL = true;\r\n } else {\r\n url = `data:${mimeType};base64,` + EncodeArrayBufferToBase64(input);\r\n }\r\n } else if (input instanceof Blob) {\r\n url = URL.createObjectURL(input);\r\n usingObjectURL = true;\r\n } else {\r\n url = FileToolsOptions.CleanUrl(input);\r\n url = FileToolsOptions.PreprocessUrl(url);\r\n }\r\n\r\n const onErrorHandler = (exception: any) => {\r\n if (onError) {\r\n // eslint-disable-next-line @typescript-eslint/no-base-to-string\r\n const inputText = url || input.toString();\r\n onError(`Error while trying to load image: ${inputText.indexOf(\"http\") === 0 || inputText.length <= 128 ? inputText : inputText.slice(0, 128) + \"...\"}`, exception);\r\n }\r\n };\r\n\r\n if (engine?._features.forceBitmapOverHTMLImageElement) {\r\n LoadFile(\r\n url,\r\n (data) => {\r\n engine\r\n .createImageBitmap(new Blob([data], { type: mimeType }), { premultiplyAlpha: \"none\", ...imageBitmapOptions })\r\n // eslint-disable-next-line github/no-then\r\n .then((imgBmp) => {\r\n onLoad(imgBmp);\r\n if (usingObjectURL) {\r\n URL.revokeObjectURL(url);\r\n }\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch((reason) => {\r\n if (onError) {\r\n // eslint-disable-next-line @typescript-eslint/restrict-plus-operands\r\n onError(\"Error while trying to load image: \" + input, reason);\r\n }\r\n });\r\n },\r\n undefined,\r\n offlineProvider || undefined,\r\n true,\r\n (request, exception) => {\r\n onErrorHandler(exception);\r\n }\r\n );\r\n\r\n return null;\r\n }\r\n\r\n const img = new Image();\r\n if (LoadImageConfiguration.getRequiredSize) {\r\n const size = LoadImageConfiguration.getRequiredSize(input);\r\n if (size.width) {\r\n img.width = size.width;\r\n }\r\n if (size.height) {\r\n img.height = size.height;\r\n }\r\n }\r\n SetCorsBehavior(url, img);\r\n\r\n const handlersList: { target: any; name: string; handler: any }[] = [];\r\n\r\n const loadHandlersList = () => {\r\n for (const handler of handlersList) {\r\n handler.target.addEventListener(handler.name, handler.handler);\r\n }\r\n };\r\n\r\n const unloadHandlersList = () => {\r\n for (const handler of handlersList) {\r\n handler.target.removeEventListener(handler.name, handler.handler);\r\n }\r\n handlersList.length = 0;\r\n };\r\n\r\n const loadHandler = () => {\r\n unloadHandlersList();\r\n\r\n onLoad(img);\r\n\r\n // Must revoke the URL after calling onLoad to avoid security exceptions in\r\n // certain scenarios (e.g. when hosted in vscode).\r\n if (usingObjectURL && img.src) {\r\n URL.revokeObjectURL(img.src);\r\n }\r\n };\r\n\r\n const errorHandler = (err: any) => {\r\n unloadHandlersList();\r\n\r\n onErrorHandler(err);\r\n\r\n if (usingObjectURL && img.src) {\r\n URL.revokeObjectURL(img.src);\r\n }\r\n };\r\n\r\n const cspHandler = (err: any) => {\r\n if (err.blockedURI !== img.src || err.disposition === \"report\") {\r\n return;\r\n }\r\n\r\n unloadHandlersList();\r\n const cspException = new Error(`CSP violation of policy ${err.effectiveDirective} ${err.blockedURI}. Current policy is ${err.originalPolicy}`);\r\n\r\n EngineStore.UseFallbackTexture = false;\r\n onErrorHandler(cspException);\r\n if (usingObjectURL && img.src) {\r\n URL.revokeObjectURL(img.src);\r\n }\r\n img.src = \"\";\r\n };\r\n\r\n handlersList.push({ target: img, name: \"load\", handler: loadHandler });\r\n handlersList.push({ target: img, name: \"error\", handler: errorHandler });\r\n handlersList.push({ target: document, name: \"securitypolicyviolation\", handler: cspHandler });\r\n\r\n loadHandlersList();\r\n\r\n const fromBlob = url.substring(0, 5) === \"blob:\";\r\n const fromData = url.substring(0, 5) === \"data:\";\r\n const noOfflineSupport = () => {\r\n if (fromBlob || fromData || !WebRequest.IsCustomRequestAvailable) {\r\n img.src = url;\r\n } else {\r\n LoadFile(\r\n url,\r\n (data, _, contentType) => {\r\n const type = !mimeType && contentType ? contentType : mimeType;\r\n const blob = new Blob([data], { type });\r\n const url = URL.createObjectURL(blob);\r\n usingObjectURL = true;\r\n img.src = url;\r\n },\r\n undefined,\r\n offlineProvider || undefined,\r\n true,\r\n (_request, exception) => {\r\n onErrorHandler(exception);\r\n }\r\n );\r\n }\r\n };\r\n\r\n const loadFromOfflineSupport = () => {\r\n if (offlineProvider) {\r\n offlineProvider.loadImage(url, img);\r\n }\r\n };\r\n\r\n if (!fromBlob && !fromData && offlineProvider && offlineProvider.enableTexturesOffline) {\r\n offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);\r\n } else {\r\n if (url.indexOf(\"file:\") !== -1) {\r\n const textureName = decodeURIComponent(url.substring(5).toLowerCase());\r\n if (FilesInputStore.FilesToLoad[textureName] && typeof URL !== \"undefined\") {\r\n try {\r\n let blobURL;\r\n try {\r\n blobURL = URL.createObjectURL(FilesInputStore.FilesToLoad[textureName]);\r\n } catch (ex) {\r\n // Chrome doesn't support oneTimeOnly parameter\r\n blobURL = URL.createObjectURL(FilesInputStore.FilesToLoad[textureName]);\r\n }\r\n img.src = blobURL;\r\n usingObjectURL = true;\r\n } catch (e) {\r\n img.src = \"\";\r\n }\r\n return img;\r\n }\r\n }\r\n\r\n noOfflineSupport();\r\n }\r\n\r\n return img;\r\n};\r\n\r\n/**\r\n * Reads a file from a File object\r\n * @param file defines the file to load\r\n * @param onSuccess defines the callback to call when data is loaded\r\n * @param onProgress defines the callback to call during loading process\r\n * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer\r\n * @param onError defines the callback to call when an error occurs\r\n * @returns a file request object\r\n * @internal\r\n */\r\nexport const ReadFile = (\r\n file: File,\r\n onSuccess: (data: any) => void,\r\n onProgress?: (ev: ProgressEvent) => any,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: ReadFileError) => void\r\n): IFileRequest => {\r\n const reader = new FileReader();\r\n const fileRequest: IFileRequest = {\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n abort: () => reader.abort(),\r\n };\r\n\r\n reader.onloadend = () => fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n if (onError) {\r\n reader.onerror = () => {\r\n onError(new ReadFileError(`Unable to read ${file.name}`, file));\r\n };\r\n }\r\n reader.onload = (e) => {\r\n //target doesn't have result from ts 1.3\r\n onSuccess((<any>e.target)[\"result\"]);\r\n };\r\n if (onProgress) {\r\n reader.onprogress = onProgress;\r\n }\r\n if (!useArrayBuffer) {\r\n // Asynchronous read\r\n reader.readAsText(file);\r\n } else {\r\n reader.readAsArrayBuffer(file);\r\n }\r\n\r\n return fileRequest;\r\n};\r\n\r\n/**\r\n * Loads a file from a url, a data url, or a file url\r\n * @param fileOrUrl file, url, data url, or file url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @param onOpened\r\n * @returns a file request object\r\n * @internal\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport const LoadFile = (\r\n fileOrUrl: File | string,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string, contentType?: Nullable<string>) => void,\r\n onProgress?: (ev: ProgressEvent) => void,\r\n offlineProvider?: Nullable<IOfflineProvider>,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n): IFileRequest => {\r\n if ((fileOrUrl as File).name) {\r\n return ReadFile(\r\n fileOrUrl as File,\r\n onSuccess,\r\n onProgress,\r\n useArrayBuffer,\r\n onError\r\n ? (error: ReadFileError) => {\r\n onError(undefined, error);\r\n }\r\n : undefined\r\n );\r\n }\r\n\r\n const url = fileOrUrl as string;\r\n\r\n // If file and file input are set\r\n if (url.indexOf(\"file:\") !== -1) {\r\n let fileName = decodeURIComponent(url.substring(5).toLowerCase());\r\n if (fileName.indexOf(\"./\") === 0) {\r\n fileName = fileName.substring(2);\r\n }\r\n const file = FilesInputStore.FilesToLoad[fileName];\r\n if (file) {\r\n return ReadFile(file, onSuccess, onProgress, useArrayBuffer, onError ? (error) => onError(undefined, new LoadFileError(error.message, error.file)) : undefined);\r\n }\r\n }\r\n\r\n // For a Base64 Data URL\r\n const { match, type } = TestBase64DataUrl(url);\r\n if (match) {\r\n const fileRequest: IFileRequest = {\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n abort: () => () => {},\r\n };\r\n\r\n try {\r\n const data = useArrayBuffer ? DecodeBase64UrlToBinary(url) : DecodeBase64UrlToString(url);\r\n onSuccess(data, undefined, type);\r\n } catch (error) {\r\n if (onError) {\r\n onError(undefined, error);\r\n } else {\r\n Logger.Error(error.message || \"Failed to parse the Data URL\");\r\n }\r\n }\r\n\r\n TimingTools.SetImmediate(() => {\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n });\r\n\r\n return fileRequest;\r\n }\r\n\r\n return RequestFile(\r\n url,\r\n (data, request) => {\r\n onSuccess(data, request?.responseURL, request?.getResponseHeader(\"content-type\"));\r\n },\r\n onProgress,\r\n offlineProvider,\r\n useArrayBuffer,\r\n onError\r\n ? (error) => {\r\n onError(error.request, new LoadFileError(error.message, error.request));\r\n }\r\n : undefined,\r\n onOpened\r\n );\r\n};\r\n\r\n/**\r\n * Loads a file from a url\r\n * @param url url to load\r\n * @param onSuccess callback called when the file successfully loads\r\n * @param onProgress callback called while file is loading (if the server supports this mode)\r\n * @param offlineProvider defines the offline provider for caching\r\n * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer\r\n * @param onError callback called when the file fails to load\r\n * @param onOpened callback called when the web request is opened\r\n * @returns a file request object\r\n * @internal\r\n */\r\nexport const RequestFile = (\r\n url: string,\r\n onSuccess?: (data: string | ArrayBuffer, request?: WebRequest) => void,\r\n onProgress?: (event: ProgressEvent) => void,\r\n offlineProvider?: Nullable<IOfflineProvider>,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: RequestFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n): IFileRequest => {\r\n if (offlineProvider !== null) {\r\n offlineProvider ??= EngineStore.LastCreatedScene?.offlineProvider;\r\n }\r\n url = FileToolsOptions.CleanUrl(url);\r\n url = FileToolsOptions.PreprocessUrl(url);\r\n\r\n const loadUrl = FileToolsOptions.BaseUrl + url;\r\n\r\n let aborted = false;\r\n const fileRequest: IFileRequest = {\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n abort: () => (aborted = true),\r\n };\r\n\r\n const requestFile = () => {\r\n let request: Nullable<WebRequest> = new WebRequest();\r\n let retryHandle: Nullable<ReturnType<typeof setTimeout>> = null;\r\n let onReadyStateChange: Nullable<() => void>;\r\n\r\n const unbindEvents = () => {\r\n if (!request) {\r\n return;\r\n }\r\n\r\n if (onProgress) {\r\n request.removeEventListener(\"progress\", onProgress);\r\n }\r\n if (onReadyStateChange) {\r\n request.removeEventListener(\"readystatechange\", onReadyStateChange);\r\n }\r\n request.removeEventListener(\"loadend\", onLoadEnd!);\r\n };\r\n\r\n let onLoadEnd: Nullable<() => void> = () => {\r\n unbindEvents();\r\n\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n fileRequest.onCompleteObservable.clear();\r\n\r\n onProgress = undefined;\r\n onReadyStateChange = null;\r\n onLoadEnd = null;\r\n onError = undefined;\r\n onOpened = undefined;\r\n onSuccess = undefined;\r\n };\r\n\r\n fileRequest.abort = () => {\r\n aborted = true;\r\n\r\n if (onLoadEnd) {\r\n onLoadEnd();\r\n }\r\n\r\n if (request && request.readyState !== (XMLHttpRequest.DONE || 4)) {\r\n request.abort();\r\n }\r\n\r\n if (retryHandle !== null) {\r\n clearTimeout(retryHandle);\r\n retryHandle = null;\r\n }\r\n\r\n request = null;\r\n };\r\n\r\n const handleError = (error: any) => {\r\n const message = error.message || \"Unknown error\";\r\n if (onError && request) {\r\n onError(new RequestFileError(message, request));\r\n } else {\r\n Logger.Error(message);\r\n }\r\n };\r\n\r\n const retryLoop = (retryIndex: number) => {\r\n if (!request) {\r\n return;\r\n }\r\n request.open(\"GET\", loadUrl);\r\n\r\n if (onOpened) {\r\n try {\r\n onOpened(request);\r\n } catch (e) {\r\n handleError(e);\r\n return;\r\n }\r\n }\r\n\r\n if (useArrayBuffer) {\r\n request.responseType = \"arraybuffer\";\r\n }\r\n\r\n if (onProgress) {\r\n request.addEventListener(\"progress\", onProgress);\r\n }\r\n\r\n if (onLoadEnd) {\r\n request.addEventListener(\"loadend\", onLoadEnd);\r\n }\r\n\r\n onReadyStateChange = () => {\r\n if (aborted || !request) {\r\n return;\r\n }\r\n\r\n // In case of undefined state in some browsers.\r\n if (request.readyState === (XMLHttpRequest.DONE || 4)) {\r\n // Some browsers have issues where onreadystatechange can be called multiple times with the same value.\r\n if (onReadyStateChange) {\r\n request.removeEventListener(\"readystatechange\", onReadyStateChange);\r\n }\r\n\r\n if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!IsWindowObjectExist() || IsFileURL()))) {\r\n // It's possible for the request to have a success status code but null response if the underlying\r\n // underlying HTTP connection was closed prematurely. See _onHttpResponseClose in xhr2.js. In this\r\n // case we will throw an exception if we call the onSuccess handler because \"data\" will be null\r\n // and that then bypasses the retry strategy.\r\n const data = useArrayBuffer ? request.response : request.responseText;\r\n if (data !== null) {\r\n try {\r\n if (onSuccess) {\r\n onSuccess(data, request);\r\n }\r\n } catch (e) {\r\n handleError(e);\r\n }\r\n return;\r\n }\r\n }\r\n\r\n const retryStrategy = FileToolsOptions.DefaultRetryStrategy;\r\n if (retryStrategy) {\r\n const waitTime = retryStrategy(loadUrl, request, retryIndex);\r\n if (waitTime !== -1) {\r\n // Prevent the request from completing for retry.\r\n unbindEvents();\r\n\r\n request = new WebRequest();\r\n retryHandle = setTimeout(() => retryLoop(retryIndex + 1), waitTime);\r\n return;\r\n }\r\n }\r\n\r\n const error = new RequestFileError(\"Error status: \" + request.status + \" \" + request.statusText + \" - Unable to load \" + loadUrl, request);\r\n if (onError) {\r\n onError(error);\r\n }\r\n }\r\n };\r\n\r\n request.addEventListener(\"readystatechange\", onReadyStateChange);\r\n\r\n request.send();\r\n };\r\n\r\n retryLoop(0);\r\n };\r\n\r\n // Caching all files\r\n if (offlineProvider && offlineProvider.enableSceneOffline && !url.startsWith(\"blob:\")) {\r\n const noOfflineSupport = (request?: any) => {\r\n if (request && request.status > 400) {\r\n if (onError) {\r\n onError(request);\r\n }\r\n } else {\r\n requestFile();\r\n }\r\n };\r\n\r\n const loadFromOfflineSupport = () => {\r\n // TODO: database needs to support aborting and should return a IFileRequest\r\n\r\n if (offlineProvider) {\r\n offlineProvider.loadFile(\r\n FileToolsOptions.BaseUrl + url,\r\n (data) => {\r\n if (!aborted && onSuccess) {\r\n onSuccess(data);\r\n }\r\n\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n },\r\n onProgress\r\n ? (event) => {\r\n if (!aborted && onProgress) {\r\n onProgress(event);\r\n }\r\n }\r\n : undefined,\r\n noOfflineSupport,\r\n useArrayBuffer\r\n );\r\n }\r\n };\r\n\r\n offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);\r\n } else {\r\n requestFile();\r\n }\r\n\r\n return fileRequest;\r\n};\r\n\r\n/**\r\n * Reads the mime type from a URL, if available.\r\n * @param url\r\n * @returns\r\n */\r\nexport const GetMimeType = (url: string): string | undefined => {\r\n const { match, type } = TestBase64DataUrl(url);\r\n if (match) {\r\n return type || undefined;\r\n }\r\n\r\n const lastDot = url.lastIndexOf(\".\");\r\n const extension = url.substring(lastDot + 1).toLowerCase();\r\n\r\n switch (extension) {\r\n case \"glb\":\r\n return \"model/gltf-binary\";\r\n case \"bin\":\r\n return \"application/octet-stream\";\r\n case \"gltf\":\r\n return \"model/gltf+json\";\r\n case \"jpg\":\r\n case \"jpeg\":\r\n return \"image/jpeg\";\r\n case \"png\":\r\n return \"image/png\";\r\n case \"webp\":\r\n return \"image/webp\";\r\n case \"ktx\":\r\n return \"image/ktx\";\r\n case \"ktx2\":\r\n return \"image/ktx2\";\r\n case \"avif\":\r\n return \"image/avif\";\r\n default:\r\n return undefined;\r\n }\r\n};\r\n\r\n/**\r\n * Checks if the loaded document was accessed via `file:`-Protocol.\r\n * @returns boolean\r\n * @internal\r\n */\r\nexport const IsFileURL = (): boolean => {\r\n return typeof location !== \"undefined\" && location.protocol === \"file:\";\r\n};\r\n\r\n/**\r\n * Test if the given uri is a valid base64 data url\r\n * @param uri The uri to test\r\n * @returns True if the uri is a base64 data url or false otherwise\r\n * @internal\r\n */\r\nexport const IsBase64DataUrl = (uri: string): boolean => {\r\n return Base64DataUrlRegEx.test(uri);\r\n};\r\n\r\nexport const TestBase64DataUrl = (uri: string): { match: boolean; type: string } => {\r\n const results = Base64DataUrlRegEx.exec(uri);\r\n if (results === null || results.length === 0) {\r\n return { match: false, type: \"\" };\r\n } else {\r\n const type = results[0].replace(\"data:\", \"\").replace(\";base64,\", \"\");\r\n return { match: true, type };\r\n }\r\n};\r\n\r\n/**\r\n * Decode the given base64 uri.\r\n * @param uri The uri to decode\r\n * @returns The decoded base64 data.\r\n * @internal\r\n */\r\nexport function DecodeBase64UrlToBinary(uri: string): ArrayBuffer {\r\n return DecodeBase64ToBinary(uri.split(\",\")[1]);\r\n}\r\n\r\n/**\r\n * Decode the given base64 uri into a UTF-8 encoded string.\r\n * @param uri The uri to decode\r\n * @returns The decoded base64 data.\r\n * @internal\r\n */\r\nexport const DecodeBase64UrlToString = (uri: string): string => {\r\n return DecodeBase64ToString(uri.split(\",\")[1]);\r\n};\r\n\r\n/**\r\n * This will be executed automatically for UMD and es5.\r\n * If esm dev wants the side effects to execute they will have to run it manually\r\n * Once we build native modules those need to be exported.\r\n * @internal\r\n */\r\nconst initSideEffects = () => {\r\n AbstractEngine._FileToolsLoadImage = LoadImage;\r\n EngineFunctionContext.loadFile = LoadFile;\r\n _FunctionContainer.loadFile = LoadFile;\r\n};\r\n\r\ninitSideEffects();\r\n\r\n// deprecated\r\n\r\n/**\r\n * FileTools defined as any.\r\n * This should not be imported or used in future releases or in any module in the framework\r\n * @internal\r\n * @deprecated import the needed function from fileTools.ts\r\n */\r\nexport let FileTools: {\r\n DecodeBase64UrlToBinary: (uri: string) => ArrayBuffer;\r\n DecodeBase64UrlToString: (uri: string) => string;\r\n DefaultRetryStrategy: any;\r\n BaseUrl: any;\r\n CorsBehavior: any;\r\n PreprocessUrl: any;\r\n IsBase64DataUrl: (uri: string) => boolean;\r\n IsFileURL: () => boolean;\r\n LoadFile: (\r\n fileOrUrl: string | File,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest;\r\n LoadImage: (\r\n input: string | ArrayBuffer | Blob | ArrayBufferView,\r\n onLoad: (img: HTMLImageElement | ImageBitmap) => void,\r\n onError: (message?: string, exception?: any) => void,\r\n offlineProvider: Nullable<IOfflineProvider>,\r\n mimeType?: string,\r\n imageBitmapOptions?: ImageBitmapOptions\r\n ) => Nullable<HTMLImageElement>;\r\n ReadFile: (\r\n file: File,\r\n onSuccess: (data: any) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => any,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: ReadFileError) => void\r\n ) => IFileRequest;\r\n RequestFile: (\r\n url: string,\r\n onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void,\r\n onProgress?: (event: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: RequestFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest;\r\n SetCorsBehavior: (url: string | string[], element: { crossOrigin: string | null }) => void;\r\n};\r\n/**\r\n * @internal\r\n */\r\nexport const _injectLTSFileTools = (\r\n DecodeBase64UrlToBinary: (uri: string) => ArrayBuffer,\r\n DecodeBase64UrlToString: (uri: string) => string,\r\n FileToolsOptions: { DefaultRetryStrategy: any; BaseUrl: any; CorsBehavior: any; PreprocessUrl: any; CleanUrl: any },\r\n IsBase64DataUrl: (uri: string) => boolean,\r\n IsFileURL: () => boolean,\r\n LoadFile: (\r\n fileOrUrl: string | File,\r\n onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest,\r\n LoadImage: (\r\n input: string | ArrayBuffer | ArrayBufferView | Blob,\r\n onLoad: (img: HTMLImageElement | ImageBitmap) => void,\r\n onError: (message?: string, exception?: any) => void,\r\n offlineProvider: Nullable<IOfflineProvider>,\r\n mimeType?: string,\r\n imageBitmapOptions?: ImageBitmapOptions\r\n ) => Nullable<HTMLImageElement>,\r\n ReadFile: (\r\n file: File,\r\n onSuccess: (data: any) => void,\r\n onProgress?: (ev: ProgressEvent<EventTarget>) => any,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: ReadFileError) => void\r\n ) => IFileRequest,\r\n RequestFile: (\r\n url: string,\r\n onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void,\r\n onProgress?: (event: ProgressEvent<EventTarget>) => void,\r\n offlineProvider?: IOfflineProvider,\r\n useArrayBuffer?: boolean,\r\n onError?: (error: RequestFileError) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ) => IFileRequest,\r\n SetCorsBehavior: (url: string | string[], element: { crossOrigin: string | null }) => void\r\n) => {\r\n /**\r\n * Backwards compatibility.\r\n * @internal\r\n * @deprecated\r\n */\r\n FileTools = {\r\n DecodeBase64UrlToBinary,\r\n DecodeBase64UrlToString,\r\n DefaultRetryStrategy: FileToolsOptions.DefaultRetryStrategy,\r\n BaseUrl: FileToolsOptions.BaseUrl,\r\n CorsBehavior: FileToolsOptions.CorsBehavior,\r\n PreprocessUrl: FileToolsOptions.PreprocessUrl,\r\n IsBase64DataUrl,\r\n IsFileURL,\r\n LoadFile,\r\n LoadImage,\r\n ReadFile,\r\n RequestFile,\r\n SetCorsBehavior,\r\n };\r\n\r\n Object.defineProperty(FileTools, \"DefaultRetryStrategy\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.DefaultRetryStrategy;\r\n },\r\n set: function (this: null, value: (url: string, request: WebRequest, retryIndex: number) => number) {\r\n FileToolsOptions.DefaultRetryStrategy = value;\r\n },\r\n });\r\n\r\n Object.defineProperty(FileTools, \"BaseUrl\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.BaseUrl;\r\n },\r\n set: function (this: null, value: string) {\r\n FileToolsOptions.BaseUrl = value;\r\n },\r\n });\r\n\r\n Object.defineProperty(FileTools, \"PreprocessUrl\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.PreprocessUrl;\r\n },\r\n set: function (this: null, value: (url: string) => string) {\r\n FileToolsOptions.PreprocessUrl = value;\r\n },\r\n });\r\n\r\n Object.defineProperty(FileTools, \"CorsBehavior\", {\r\n get: function (this: null) {\r\n return FileToolsOptions.CorsBehavior;\r\n },\r\n set: function (this: null, value: string | ((url: string | string[]) => string)) {\r\n FileToolsOptions.CorsBehavior = value;\r\n },\r\n });\r\n};\r\n\r\n_injectLTSFileTools(DecodeBase64UrlToBinary, DecodeBase64UrlToString, FileToolsOptions, IsBase64DataUrl, IsFileURL, LoadFile, LoadImage, ReadFile, RequestFile, SetCorsBehavior);\r\n"]}
|
package/Misc/tools.d.ts
CHANGED
|
@@ -618,6 +618,7 @@ export declare class Tools {
|
|
|
618
618
|
*/
|
|
619
619
|
static readonly PerformanceConsoleLogLevel = 2;
|
|
620
620
|
private static _Performance;
|
|
621
|
+
private static readonly _NativePerformanceCounterHandles;
|
|
621
622
|
/**
|
|
622
623
|
* Sets the current performance log level
|
|
623
624
|
*/
|
|
@@ -628,6 +629,8 @@ export declare class Tools {
|
|
|
628
629
|
private static _EndUserMark;
|
|
629
630
|
private static _StartPerformanceConsole;
|
|
630
631
|
private static _EndPerformanceConsole;
|
|
632
|
+
private static _StartMarkNative;
|
|
633
|
+
private static _EndMarkNative;
|
|
631
634
|
/**
|
|
632
635
|
* Starts a performance counter
|
|
633
636
|
*/
|
package/Misc/tools.js
CHANGED
|
@@ -988,17 +988,32 @@ export class Tools {
|
|
|
988
988
|
*/
|
|
989
989
|
static set PerformanceLogLevel(level) {
|
|
990
990
|
if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
|
|
991
|
-
|
|
992
|
-
|
|
991
|
+
if (_native?.enablePerformanceLogging) {
|
|
992
|
+
_native.enablePerformanceLogging(1 /* NativeTraceLevel.Mark */);
|
|
993
|
+
Tools.StartPerformanceCounter = Tools._StartMarkNative;
|
|
994
|
+
Tools.EndPerformanceCounter = Tools._EndMarkNative;
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
Tools.StartPerformanceCounter = Tools._StartUserMark;
|
|
998
|
+
Tools.EndPerformanceCounter = Tools._EndUserMark;
|
|
999
|
+
}
|
|
993
1000
|
return;
|
|
994
1001
|
}
|
|
995
1002
|
if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
|
|
996
|
-
|
|
997
|
-
|
|
1003
|
+
if (_native?.enablePerformanceLogging) {
|
|
1004
|
+
_native.enablePerformanceLogging(2 /* NativeTraceLevel.Log */);
|
|
1005
|
+
Tools.StartPerformanceCounter = Tools._StartMarkNative;
|
|
1006
|
+
Tools.EndPerformanceCounter = Tools._EndMarkNative;
|
|
1007
|
+
}
|
|
1008
|
+
else {
|
|
1009
|
+
Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
|
|
1010
|
+
Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
|
|
1011
|
+
}
|
|
998
1012
|
return;
|
|
999
1013
|
}
|
|
1000
1014
|
Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
|
|
1001
1015
|
Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
|
|
1016
|
+
_native?.disablePerformanceLogging?.();
|
|
1002
1017
|
}
|
|
1003
1018
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1004
1019
|
static _StartPerformanceCounterDisabled(counterName, condition) { }
|
|
@@ -1039,6 +1054,29 @@ export class Tools {
|
|
|
1039
1054
|
Tools._EndUserMark(counterName, condition);
|
|
1040
1055
|
console.timeEnd(counterName);
|
|
1041
1056
|
}
|
|
1057
|
+
static _StartMarkNative(counterName, condition = true) {
|
|
1058
|
+
if (condition && _native?.startPerformanceCounter) {
|
|
1059
|
+
if (Tools._NativePerformanceCounterHandles.has(counterName)) {
|
|
1060
|
+
Tools.Warn(`Performance counter with name ${counterName} is already started.`);
|
|
1061
|
+
}
|
|
1062
|
+
else {
|
|
1063
|
+
const handle = _native.startPerformanceCounter(counterName);
|
|
1064
|
+
Tools._NativePerformanceCounterHandles.set(counterName, handle);
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
static _EndMarkNative(counterName, condition = true) {
|
|
1069
|
+
if (condition && _native?.endPerformanceCounter) {
|
|
1070
|
+
const handle = Tools._NativePerformanceCounterHandles.get(counterName);
|
|
1071
|
+
if (handle) {
|
|
1072
|
+
_native.endPerformanceCounter(handle);
|
|
1073
|
+
Tools._NativePerformanceCounterHandles.delete(counterName);
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
Tools.Warn(`Performance counter with name ${counterName} was not started.`);
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
}
|
|
1042
1080
|
/**
|
|
1043
1081
|
* Gets either window.performance.now() if supported or Date.now() else
|
|
1044
1082
|
*/
|
|
@@ -1217,6 +1255,7 @@ Tools.PerformanceUserMarkLogLevel = 1;
|
|
|
1217
1255
|
* Log performance to the console
|
|
1218
1256
|
*/
|
|
1219
1257
|
Tools.PerformanceConsoleLogLevel = 2;
|
|
1258
|
+
Tools._NativePerformanceCounterHandles = new Map();
|
|
1220
1259
|
/**
|
|
1221
1260
|
* Starts a performance counter
|
|
1222
1261
|
*/
|