@onerjs/core 8.54.1 → 8.54.3
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/animatable.core.js.map +1 -1
- package/AudioV2/abstractAudio/abstractSoundSource.d.ts +26 -0
- package/AudioV2/abstractAudio/abstractSoundSource.js.map +1 -1
- package/AudioV2/webAudio/webAudioEngine.js +2 -0
- package/AudioV2/webAudio/webAudioEngine.js.map +1 -1
- package/AudioV2/webAudio/webAudioSoundSource.d.ts +16 -0
- package/AudioV2/webAudio/webAudioSoundSource.js +43 -1
- package/AudioV2/webAudio/webAudioSoundSource.js.map +1 -1
- package/Bones/skeleton.functions.js +1 -1
- package/Bones/skeleton.functions.js.map +1 -1
- package/Cameras/inputMapper.js.map +1 -1
- package/Collisions/gpuPicker.js +7 -6
- package/Collisions/gpuPicker.js.map +1 -1
- package/Debug/physicsViewer.pure.js +1 -1
- package/Debug/physicsViewer.pure.js.map +1 -1
- package/Engines/Extensions/engine.alphaToCoverage.d.ts +6 -0
- package/Engines/Extensions/engine.alphaToCoverage.js +9 -0
- package/Engines/Extensions/engine.alphaToCoverage.js.map +1 -0
- package/Engines/Extensions/engine.alphaToCoverage.pure.d.ts +6 -0
- package/Engines/Extensions/engine.alphaToCoverage.pure.js +54 -0
- package/Engines/Extensions/engine.alphaToCoverage.pure.js.map +1 -0
- package/Engines/Extensions/engine.alphaToCoverage.types.d.ts +21 -0
- package/Engines/Extensions/engine.alphaToCoverage.types.js +2 -0
- package/Engines/Extensions/engine.alphaToCoverage.types.js.map +1 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.d.ts +6 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.js +9 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.js.map +1 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.pure.d.ts +7 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.pure.js +40 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.pure.js.map +1 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.types.d.ts +21 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.types.js +2 -0
- package/Engines/Extensions/engine.texture2DArrayImageSource.types.js.map +1 -0
- package/Engines/Extensions/index.d.ts +1 -0
- package/Engines/Extensions/index.js +1 -0
- package/Engines/Extensions/index.js.map +1 -1
- package/Engines/Extensions/pure.d.ts +2 -0
- package/Engines/Extensions/pure.js +2 -0
- package/Engines/Extensions/pure.js.map +1 -1
- package/Engines/Native/nativeHelpers.js +6 -4
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +1 -0
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.d.ts +6 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.js +9 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.js.map +1 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.d.ts +6 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.js +34 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.pure.js.map +1 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.d.ts +16 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.js +2 -0
- package/Engines/WebGPU/Extensions/engine.alphaToCoverage.types.js.map +1 -0
- package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.d.ts +6 -0
- package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.js +9 -0
- package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.js.map +1 -0
- package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.pure.d.ts +7 -0
- package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.pure.js +23 -0
- package/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.pure.js.map +1 -0
- package/Engines/WebGPU/Extensions/index.d.ts +1 -0
- package/Engines/WebGPU/Extensions/index.js +1 -0
- package/Engines/WebGPU/Extensions/index.js.map +1 -1
- package/Engines/WebGPU/Extensions/pure.d.ts +2 -0
- package/Engines/WebGPU/Extensions/pure.js +2 -0
- package/Engines/WebGPU/Extensions/pure.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js +0 -1
- package/Engines/WebGPU/webgpuCacheRenderPipeline.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +0 -15
- package/Engines/abstractEngine.pure.js +2 -23
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +32 -2
- package/Engines/engine.js +1 -0
- package/Engines/engine.js.map +1 -1
- package/Engines/engine.pure.js +1 -1
- package/Engines/engine.pure.js.map +1 -1
- package/Engines/thinEngine.pure.d.ts +0 -11
- package/Engines/thinEngine.pure.js +0 -19
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.js +4 -4
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/webgpuEngine.d.ts +2 -0
- package/Engines/webgpuEngine.js +2 -0
- package/Engines/webgpuEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +0 -5
- package/Engines/webgpuEngine.pure.js +1 -10
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.js +6 -0
- package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.d.ts +10 -0
- package/Loading/Plugins/babylonFileLoader.js +18 -0
- package/Loading/Plugins/babylonFileLoader.js.map +1 -1
- package/Loading/Plugins/babylonFileLoader.pure.js +10 -2
- package/Loading/Plugins/babylonFileLoader.pure.js.map +1 -1
- package/Loading/loadingScreen.pure.js +2 -0
- package/Loading/loadingScreen.pure.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/ambientOcclusionBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js +2 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.pure.js.map +1 -1
- package/Materials/Node/nodeMaterial.pure.d.ts +13 -5
- package/Materials/Node/nodeMaterial.pure.js +20 -2
- package/Materials/Node/nodeMaterial.pure.js.map +1 -1
- package/Materials/Textures/index.d.ts +1 -0
- package/Materials/Textures/index.js +1 -0
- package/Materials/Textures/index.js.map +1 -1
- package/Materials/Textures/ktx2decoderTypes.d.ts +14 -3
- package/Materials/Textures/ktx2decoderTypes.js +2 -0
- package/Materials/Textures/ktx2decoderTypes.js.map +1 -1
- package/Materials/Textures/pure.d.ts +1 -0
- package/Materials/Textures/pure.js +1 -0
- package/Materials/Textures/pure.js.map +1 -1
- package/Materials/Textures/rawTexture2DArray.functions.d.ts +95 -0
- package/Materials/Textures/rawTexture2DArray.functions.js +201 -0
- package/Materials/Textures/rawTexture2DArray.functions.js.map +1 -0
- package/Materials/Textures/renderTargetTexture.pure.js +7 -0
- package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
- package/Materials/material.pure.d.ts +1 -0
- package/Materials/material.pure.js +1 -0
- package/Materials/material.pure.js.map +1 -1
- package/Meshes/Builders/pure.d.ts +2 -2
- package/Meshes/Builders/pure.js +2 -2
- package/Meshes/Builders/pure.js.map +1 -1
- package/Meshes/Builders/textBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.d.ts +1 -83
- package/Meshes/Builders/tiledBoxBuilder.js +3 -215
- package/Meshes/Builders/tiledBoxBuilder.js.map +1 -1
- package/Meshes/Builders/tiledBoxBuilder.pure.d.ts +89 -0
- package/Meshes/Builders/tiledBoxBuilder.pure.js +229 -0
- package/Meshes/Builders/tiledBoxBuilder.pure.js.map +1 -0
- package/Meshes/Builders/tiledPlaneBuilder.d.ts +1 -79
- package/Meshes/Builders/tiledPlaneBuilder.js +3 -429
- package/Meshes/Builders/tiledPlaneBuilder.js.map +1 -1
- package/Meshes/Builders/tiledPlaneBuilder.pure.d.ts +85 -0
- package/Meshes/Builders/tiledPlaneBuilder.pure.js +442 -0
- package/Meshes/Builders/tiledPlaneBuilder.pure.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +13 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +15 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +29 -9
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/Node/Blocks/bevelBlock.pure.js.map +1 -1
- package/Meshes/meshBuilder.d.ts +21 -57
- package/Meshes/meshBuilder.js +21 -58
- package/Meshes/meshBuilder.js.map +1 -1
- package/Meshes/meshBuilder.pure.d.ts +58 -0
- package/Meshes/meshBuilder.pure.js +60 -0
- package/Meshes/meshBuilder.pure.js.map +1 -0
- package/Meshes/pure.d.ts +1 -1
- package/Meshes/pure.js +1 -1
- package/Meshes/pure.js.map +1 -1
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +10 -0
- package/Misc/khronosTextureContainer2.js +23 -12
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/perfCounter.d.ts +2 -0
- package/Misc/perfCounter.js +17 -2
- package/Misc/perfCounter.js.map +1 -1
- package/Misc/rgbdTextureTools.js +1 -1
- package/Misc/rgbdTextureTools.js.map +1 -1
- package/Misc/snapshotRenderingHelper.js +2 -1
- package/Misc/snapshotRenderingHelper.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Navigation/Plugins/recastJSPlugin.js +1 -1
- package/Navigation/Plugins/recastJSPlugin.js.map +1 -1
- package/Physics/v2/Plugins/havokPlugin.js +15 -0
- package/Physics/v2/Plugins/havokPlugin.js.map +1 -1
- package/Physics/v2/characterController.d.ts +17 -0
- package/Physics/v2/characterController.js +40 -0
- package/Physics/v2/characterController.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.pure.js.map +1 -1
- package/PostProcesses/thinSSAO2PostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.d.ts +3 -0
- package/PostProcesses/volumetricLightScatteringPostProcess.js +3 -0
- package/PostProcesses/volumetricLightScatteringPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +1 -0
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +25 -6
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.d.ts +3 -1
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js +25 -4
- package/Rendering/IBLShadows/iblShadowsAccumulationPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js +6 -5
- package/Rendering/IBLShadows/iblShadowsRenderPipeline.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.d.ts +3 -1
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js +16 -4
- package/Rendering/IBLShadows/iblShadowsSpatialBlurPass.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +6 -5
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.d.ts +3 -1
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js +16 -4
- package/Rendering/IBLShadows/iblShadowsVoxelTracingPass.js.map +1 -1
- package/Rendering/depthRenderer.d.ts +2 -0
- package/Rendering/depthRenderer.js +2 -0
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/depthRenderer.pure.js +3 -2
- package/Rendering/depthRenderer.pure.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderer.pure.js +6 -0
- package/Rendering/fluidRenderer/fluidRenderer.pure.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.js +5 -5
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js +6 -6
- package/Shaders/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/depthPrePass.js +2 -0
- package/ShadersWGSL/ShadersInclude/depthPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js +7 -8
- package/ShadersWGSL/ShadersInclude/openpbrDielectricReflectance.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +3 -0
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.fragment.js +3 -0
- package/ShadersWGSL/openpbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +3 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/volumetricLightScattering.fragment.d.ts +5 -0
- package/ShadersWGSL/volumetricLightScattering.fragment.js +20 -0
- package/ShadersWGSL/volumetricLightScattering.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightScatteringPass.fragment.d.ts +5 -0
- package/ShadersWGSL/volumetricLightScatteringPass.fragment.js +24 -0
- package/ShadersWGSL/volumetricLightScatteringPass.fragment.js.map +1 -0
- package/ShadersWGSL/volumetricLightScatteringPass.vertex.d.ts +5 -0
- package/ShadersWGSL/volumetricLightScatteringPass.vertex.js +67 -0
- package/ShadersWGSL/volumetricLightScatteringPass.vertex.js.map +1 -0
- package/SmartAssets/smartAssetManager.pure.js +9 -1
- package/SmartAssets/smartAssetManager.pure.js.map +1 -1
- package/States/alphaCullingState.d.ts +0 -9
- package/States/alphaCullingState.js +4 -31
- package/States/alphaCullingState.js.map +1 -1
- package/XR/features/WebXRBodyTracking.pure.d.ts +0 -28
- package/XR/features/WebXRBodyTracking.pure.js.map +1 -1
- package/XR/features/WebXRLayers.pure.js +4 -4
- package/XR/features/WebXRLayers.pure.js.map +1 -1
- package/node.d.ts +18 -1
- package/node.js +52 -1
- package/node.js.map +1 -1
- package/package.json +1 -1
- package/types.js.map +1 -1
|
@@ -20,6 +20,7 @@ export * from "./Procedurals/index.js";
|
|
|
20
20
|
export * from "./rawCubeTexture.js";
|
|
21
21
|
export * from "./rawTexture.js";
|
|
22
22
|
export * from "./rawTexture2DArray.js";
|
|
23
|
+
export * from "./rawTexture2DArray.functions.js";
|
|
23
24
|
export * from "./rawTexture3D.js";
|
|
24
25
|
export * from "./refractionTexture.js";
|
|
25
26
|
export * from "./renderTargetTexture.js";
|
|
@@ -21,6 +21,7 @@ export * from "./Procedurals/index.js";
|
|
|
21
21
|
export * from "./rawCubeTexture.js";
|
|
22
22
|
export * from "./rawTexture.js";
|
|
23
23
|
export * from "./rawTexture2DArray.js";
|
|
24
|
+
export * from "./rawTexture2DArray.functions.js";
|
|
24
25
|
export * from "./rawTexture3D.js";
|
|
25
26
|
export * from "./refractionTexture.js";
|
|
26
27
|
export * from "./renderTargetTexture.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,eAAe,CAAC;AAE9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;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C","sourcesContent":["/* eslint-disable @typescript-eslint/no-restricted-imports */\r\nexport * from \"./baseTexture\";\r\n\r\nexport * from \"./baseTexture.polynomial\";\r\nexport * from \"./colorGradingTexture\";\r\nexport * from \"./cubeTexture\";\r\nexport * from \"./dynamicTexture\";\r\nexport * from \"./equiRectangularCubeTexture\";\r\nexport * from \"./externalTexture\";\r\nexport * from \"./Filtering/hdrFiltering\";\r\nexport * from \"./envCubeTexture\";\r\nexport * from \"./hdrCubeTexture\";\r\nexport * from \"./exrCubeTexture\";\r\nexport * from \"./htmlElementTexture\";\r\nexport * from \"./HTML/index\";\r\nexport * from \"./internalTexture\";\r\nexport * from \"./Loaders/index\";\r\nexport * from \"./mirrorTexture\";\r\nexport * from \"./multiRenderTarget\";\r\nexport * from \"./Packer/index\";\r\nexport * from \"./Procedurals/index\";\r\nexport * from \"./rawCubeTexture\";\r\nexport * from \"./rawTexture\";\r\nexport * from \"./rawTexture2DArray\";\r\nexport * from \"./rawTexture3D\";\r\nexport * from \"./refractionTexture\";\r\nexport * from \"./renderTargetTexture\";\r\nexport * from \"./reflectionProbeTexture\";\r\nexport * from \"./textureMerger\";\r\nexport * from \"./textureSampler\";\r\nexport * from \"./textureProcessor\";\r\nexport * from \"./texture\";\r\nexport * from \"./thinTexture\";\r\nexport * from \"./thinRenderTargetTexture\";\r\nexport * from \"./videoTexture\";\r\nexport * from \"./ktx2decoderTypes\";\r\nexport * from \"./textureCreationOptions\";\r\n\r\n// Shaders for procedural textures\r\nexport * from \"../../ShadersWGSL/procedural.vertex\";\r\nexport * from \"../../Shaders/procedural.vertex\";\r\n\r\n// HDR filtering\r\nexport * from \"../../Shaders/hdrFiltering.vertex\";\r\nexport * from \"../../Shaders/hdrFiltering.fragment\";\r\nexport * from \"../../ShadersWGSL/hdrFiltering.vertex\";\r\nexport * from \"../../ShadersWGSL/hdrFiltering.fragment\";\r\nexport * from \"../../Shaders/hdrIrradianceFiltering.vertex\";\r\nexport * from \"../../Shaders/hdrIrradianceFiltering.fragment\";\r\nexport * from \"../../ShadersWGSL/hdrIrradianceFiltering.vertex\";\r\nexport * from \"../../ShadersWGSL/hdrIrradianceFiltering.fragment\";\r\n\r\n// HDR filtering shader includes (needed by external packages)\r\nexport * from \"../../ShadersWGSL/ShadersInclude/importanceSampling\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/pbrBRDFFunctions\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/hdrFilteringFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/importanceSampling\";\r\nexport * from \"../../Shaders/ShadersInclude/pbrBRDFFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/hdrFilteringFunctions\";\r\n\r\n// Intersection & LTC helper functions (needed by external packages)\r\nexport * from \"../../ShadersWGSL/ShadersInclude/clusteredLightingFunctions\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/intersectionFunctions\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/ltcHelperFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/clusteredLightingFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/intersectionFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/ltcHelperFunctions\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc,eAAe,CAAC;AAE9B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,C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@typescript-eslint/no-restricted-imports */\r\nexport * from \"./baseTexture\";\r\n\r\nexport * from \"./baseTexture.polynomial\";\r\nexport * from \"./colorGradingTexture\";\r\nexport * from \"./cubeTexture\";\r\nexport * from \"./dynamicTexture\";\r\nexport * from \"./equiRectangularCubeTexture\";\r\nexport * from \"./externalTexture\";\r\nexport * from \"./Filtering/hdrFiltering\";\r\nexport * from \"./envCubeTexture\";\r\nexport * from \"./hdrCubeTexture\";\r\nexport * from \"./exrCubeTexture\";\r\nexport * from \"./htmlElementTexture\";\r\nexport * from \"./HTML/index\";\r\nexport * from \"./internalTexture\";\r\nexport * from \"./Loaders/index\";\r\nexport * from \"./mirrorTexture\";\r\nexport * from \"./multiRenderTarget\";\r\nexport * from \"./Packer/index\";\r\nexport * from \"./Procedurals/index\";\r\nexport * from \"./rawCubeTexture\";\r\nexport * from \"./rawTexture\";\r\nexport * from \"./rawTexture2DArray\";\r\nexport * from \"./rawTexture2DArray.functions\";\r\nexport * from \"./rawTexture3D\";\r\nexport * from \"./refractionTexture\";\r\nexport * from \"./renderTargetTexture\";\r\nexport * from \"./reflectionProbeTexture\";\r\nexport * from \"./textureMerger\";\r\nexport * from \"./textureSampler\";\r\nexport * from \"./textureProcessor\";\r\nexport * from \"./texture\";\r\nexport * from \"./thinTexture\";\r\nexport * from \"./thinRenderTargetTexture\";\r\nexport * from \"./videoTexture\";\r\nexport * from \"./ktx2decoderTypes\";\r\nexport * from \"./textureCreationOptions\";\r\n\r\n// Shaders for procedural textures\r\nexport * from \"../../ShadersWGSL/procedural.vertex\";\r\nexport * from \"../../Shaders/procedural.vertex\";\r\n\r\n// HDR filtering\r\nexport * from \"../../Shaders/hdrFiltering.vertex\";\r\nexport * from \"../../Shaders/hdrFiltering.fragment\";\r\nexport * from \"../../ShadersWGSL/hdrFiltering.vertex\";\r\nexport * from \"../../ShadersWGSL/hdrFiltering.fragment\";\r\nexport * from \"../../Shaders/hdrIrradianceFiltering.vertex\";\r\nexport * from \"../../Shaders/hdrIrradianceFiltering.fragment\";\r\nexport * from \"../../ShadersWGSL/hdrIrradianceFiltering.vertex\";\r\nexport * from \"../../ShadersWGSL/hdrIrradianceFiltering.fragment\";\r\n\r\n// HDR filtering shader includes (needed by external packages)\r\nexport * from \"../../ShadersWGSL/ShadersInclude/importanceSampling\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/pbrBRDFFunctions\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/hdrFilteringFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/importanceSampling\";\r\nexport * from \"../../Shaders/ShadersInclude/pbrBRDFFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/hdrFilteringFunctions\";\r\n\r\n// Intersection & LTC helper functions (needed by external packages)\r\nexport * from \"../../ShadersWGSL/ShadersInclude/clusteredLightingFunctions\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/intersectionFunctions\";\r\nexport * from \"../../ShadersWGSL/ShadersInclude/ltcHelperFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/clusteredLightingFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/intersectionFunctions\";\r\nexport * from \"../../Shaders/ShadersInclude/ltcHelperFunctions\";\r\n"]}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare enum SourceTextureFormat {
|
|
2
2
|
ETC1S = 0,
|
|
3
|
-
UASTC4x4 = 1
|
|
3
|
+
UASTC4x4 = 1,
|
|
4
|
+
/** Uncompressed 8 bits per channel RGBA data, stored as-is in the container (no transcoding required) */
|
|
5
|
+
RGBA32 = 2
|
|
4
6
|
}
|
|
5
7
|
export declare enum TranscodeTarget {
|
|
6
8
|
ASTC_4X4_RGBA = 0,
|
|
@@ -95,9 +97,9 @@ export interface INode {
|
|
|
95
97
|
*/
|
|
96
98
|
export interface IDecisionTree {
|
|
97
99
|
/**
|
|
98
|
-
* textureFormat can be either UASTC or
|
|
100
|
+
* textureFormat can be either UASTC, ETC1S or RGBA32
|
|
99
101
|
*/
|
|
100
|
-
[textureFormat: string]: INode;
|
|
102
|
+
[textureFormat: string]: INode | ILeaf;
|
|
101
103
|
}
|
|
102
104
|
/**
|
|
103
105
|
* Result of the KTX2 decode function
|
|
@@ -119,8 +121,13 @@ export interface IDecodedData {
|
|
|
119
121
|
/**
|
|
120
122
|
* List of mipmap levels.
|
|
121
123
|
* The first element is the base level, the last element is the smallest mipmap level (if more than one mipmap level is present)
|
|
124
|
+
* For array textures (layerCount greater than 1), each level contributes layerCount consecutive entries, ordered by layer.
|
|
122
125
|
*/
|
|
123
126
|
mipmaps: Array<IMipmap>;
|
|
127
|
+
/**
|
|
128
|
+
* Number of array layers of the texture. 1 for a regular (non array) texture
|
|
129
|
+
*/
|
|
130
|
+
layerCount: number;
|
|
124
131
|
/**
|
|
125
132
|
* Whether the texture data is in gamma space or not
|
|
126
133
|
*/
|
|
@@ -154,6 +161,10 @@ export interface IMipmap {
|
|
|
154
161
|
* The height of the mipmap level
|
|
155
162
|
*/
|
|
156
163
|
height: number;
|
|
164
|
+
/**
|
|
165
|
+
* The array layer this mipmap level belongs to. 0 for a regular (non array) texture
|
|
166
|
+
*/
|
|
167
|
+
layerIndex: number;
|
|
157
168
|
}
|
|
158
169
|
/**
|
|
159
170
|
* The compressed texture formats supported by the browser
|
|
@@ -3,6 +3,8 @@ export var SourceTextureFormat;
|
|
|
3
3
|
SourceTextureFormat[SourceTextureFormat["ETC1S"] = 0] = "ETC1S";
|
|
4
4
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
5
5
|
SourceTextureFormat[SourceTextureFormat["UASTC4x4"] = 1] = "UASTC4x4";
|
|
6
|
+
/** Uncompressed 8 bits per channel RGBA data, stored as-is in the container (no transcoding required) */
|
|
7
|
+
SourceTextureFormat[SourceTextureFormat["RGBA32"] = 2] = "RGBA32";
|
|
6
8
|
})(SourceTextureFormat || (SourceTextureFormat = {}));
|
|
7
9
|
export var TranscodeTarget;
|
|
8
10
|
(function (TranscodeTarget) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ktx2decoderTypes.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/ktx2decoderTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"ktx2decoderTypes.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/ktx2decoderTypes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC3B,+DAAK,CAAA;IACL,gEAAgE;IAChE,qEAAQ,CAAA;IACR,yGAAyG;IACzG,iEAAM,CAAA;AACV,CAAC,EANW,mBAAmB,KAAnB,mBAAmB,QAM9B;AAED,MAAM,CAAN,IAAY,eAcX;AAdD,WAAY,eAAe;IACvB,uEAAa,CAAA;IACb,gEAAgE;IAChE,uEAA6B,CAAA;IAC7B,6DAAQ,CAAA;IACR,6DAAQ,CAAA;IACR,2DAAO,CAAA;IACP,uEAAa,CAAA;IACb,qEAAY,CAAA;IACZ,+DAAS,CAAA;IACT,6DAAQ,CAAA;IACR,yDAAM,CAAA;IACN,iDAAE,CAAA;IACF,oDAAG,CAAA;AACP,CAAC,EAdW,eAAe,KAAf,eAAe,QAc1B;AAED,MAAM,CAAN,IAAkB,YAcjB;AAdD,WAAkB,YAAY;IAC1B,uGAAuC,CAAA;IACvC,mGAAqC,CAAA;IACrC,mGAAqC,CAAA;IACrC,qGAAsC,CAAA;IACtC,2GAAyC,CAAA;IACzC,yGAAwC,CAAA;IACxC,6FAAkC,CAAA;IAClC,mFAA6B,CAAA;IAC7B,6FAAkC,CAAA;IAClC,iEAAoB,CAAA;IACpB,2DAAiB,CAAA;IACjB,gEAAgE;IAChE,6DAAkB,CAAA;AACtB,CAAC,EAdiB,YAAY,KAAZ,YAAY,QAc7B","sourcesContent":["export enum SourceTextureFormat {\r\n ETC1S,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n UASTC4x4,\r\n /** Uncompressed 8 bits per channel RGBA data, stored as-is in the container (no transcoding required) */\r\n RGBA32,\r\n}\r\n\r\nexport enum TranscodeTarget {\r\n ASTC_4X4_RGBA,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ASTC_4x4_RGBA = ASTC_4X4_RGBA,\r\n BC7_RGBA,\r\n BC3_RGBA,\r\n BC1_RGB,\r\n PVRTC1_4_RGBA,\r\n PVRTC1_4_RGB,\r\n ETC2_RGBA,\r\n ETC1_RGB,\r\n RGBA32,\r\n R8,\r\n RG8,\r\n}\r\n\r\nexport const enum EngineFormat {\r\n COMPRESSED_RGBA_BPTC_UNORM_EXT = 0x8e8c,\r\n COMPRESSED_RGBA_ASTC_4X4_KHR = 0x93b0,\r\n COMPRESSED_RGB_S3TC_DXT1_EXT = 0x83f0,\r\n COMPRESSED_RGBA_S3TC_DXT5_EXT = 0x83f3,\r\n COMPRESSED_RGBA_PVRTC_4BPPV1_IMG = 0x8c02,\r\n COMPRESSED_RGB_PVRTC_4BPPV1_IMG = 0x8c00,\r\n COMPRESSED_RGBA8_ETC2_EAC = 0x9278,\r\n COMPRESSED_RGB8_ETC2 = 0x9274,\r\n COMPRESSED_RGB_ETC1_WEBGL = 0x8d64,\r\n RGBA8Format = 0x8058,\r\n R8Format = 0x8229,\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n RG8Format = 0x822b,\r\n}\r\n\r\n/**\r\n * Leaf node of a decision tree\r\n * It defines the transcoding format to use to transcode the texture as well as the corresponding format to use at the engine level when creating the texture\r\n */\r\nexport interface ILeaf {\r\n /**\r\n * The format to transcode to\r\n */\r\n transcodeFormat: TranscodeTarget;\r\n\r\n /**\r\n * The format to use when creating the texture at the engine level after it has been transcoded to transcodeFormat\r\n */\r\n engineFormat: EngineFormat;\r\n\r\n /**\r\n * Whether the texture must be rounded to a multiple of 4 (should normally be the case for all compressed formats). Default: true\r\n */\r\n roundToMultiple4?: boolean;\r\n}\r\n\r\n/**\r\n * Regular node of a decision tree\r\n *\r\n * Each property (except for \"yes\" and \"no\"), if not empty, will be checked in order to determine the next node to select.\r\n * If all checks are successful, the \"yes\" node will be selected, else the \"no\" node will be selected.\r\n */\r\nexport interface INode {\r\n /**\r\n * The name of the capability to check. Can be one of the following:\r\n * astc\r\n * bptc\r\n * s3tc\r\n * pvrtc\r\n * etc2\r\n * etc1\r\n */\r\n cap?: string;\r\n\r\n /**\r\n * The name of the option to check from the options object passed to the KTX2 decode function. {@link IKTX2DecoderOptions}\r\n */\r\n option?: string;\r\n\r\n /**\r\n * Checks if alpha is present in the texture\r\n */\r\n alpha?: boolean;\r\n\r\n /**\r\n * Checks the currently selected transcoding format.\r\n */\r\n transcodeFormat?: TranscodeTarget | TranscodeTarget[];\r\n\r\n /**\r\n * Checks that the texture is a power of two\r\n */\r\n needsPowerOfTwo?: boolean;\r\n\r\n /**\r\n * The node to select if all checks are successful\r\n */\r\n yes?: INode | ILeaf;\r\n\r\n /**\r\n * The node to select if at least one check is not successful\r\n */\r\n no?: INode | ILeaf;\r\n}\r\n\r\n/**\r\n * Decision tree used to determine the transcoding format to use for a given source texture format\r\n */\r\nexport interface IDecisionTree {\r\n /**\r\n * textureFormat can be either UASTC, ETC1S or RGBA32\r\n */\r\n [textureFormat: string]: INode | ILeaf;\r\n}\r\n\r\n/**\r\n * Result of the KTX2 decode function\r\n */\r\nexport interface IDecodedData {\r\n /**\r\n * Width of the texture\r\n */\r\n width: number;\r\n\r\n /**\r\n * Height of the texture\r\n */\r\n height: number;\r\n\r\n /**\r\n * The format to use when creating the texture at the engine level\r\n * This corresponds to the engineFormat property of the leaf node of the decision tree\r\n */\r\n transcodedFormat: number;\r\n\r\n /**\r\n * List of mipmap levels.\r\n * The first element is the base level, the last element is the smallest mipmap level (if more than one mipmap level is present)\r\n * For array textures (layerCount greater than 1), each level contributes layerCount consecutive entries, ordered by layer.\r\n */\r\n mipmaps: Array<IMipmap>;\r\n\r\n /**\r\n * Number of array layers of the texture. 1 for a regular (non array) texture\r\n */\r\n layerCount: number;\r\n\r\n /**\r\n * Whether the texture data is in gamma space or not\r\n */\r\n isInGammaSpace: boolean;\r\n\r\n /**\r\n * Whether the texture has an alpha channel or not\r\n */\r\n hasAlpha: boolean;\r\n\r\n /**\r\n * The name of the transcoder used to transcode the texture\r\n */\r\n transcoderName: string;\r\n\r\n /**\r\n * The errors (if any) encountered during the decoding process\r\n */\r\n errors?: string;\r\n}\r\n\r\n/**\r\n * Defines a mipmap level\r\n */\r\nexport interface IMipmap {\r\n /**\r\n * The data of the mipmap level\r\n */\r\n data: Uint8Array | null;\r\n\r\n /**\r\n * The width of the mipmap level\r\n */\r\n width: number;\r\n\r\n /**\r\n * The height of the mipmap level\r\n */\r\n height: number;\r\n\r\n /**\r\n * The array layer this mipmap level belongs to. 0 for a regular (non array) texture\r\n */\r\n layerIndex: number;\r\n}\r\n\r\n/**\r\n * The compressed texture formats supported by the browser\r\n */\r\nexport interface ICompressedFormatCapabilities {\r\n /**\r\n * Whether the browser supports ASTC\r\n */\r\n astc?: boolean;\r\n\r\n /**\r\n * Whether the browser supports BPTC\r\n */\r\n bptc?: boolean;\r\n\r\n /**\r\n * Whether the browser supports S3TC\r\n */\r\n s3tc?: boolean;\r\n\r\n /**\r\n * Whether the browser supports PVRTC\r\n */\r\n pvrtc?: boolean;\r\n\r\n /**\r\n * Whether the browser supports ETC2\r\n */\r\n etc2?: boolean;\r\n\r\n /**\r\n * Whether the browser supports ETC1\r\n */\r\n etc1?: boolean;\r\n}\r\n\r\n/**\r\n * Options passed to the KTX2 decode function\r\n */\r\nexport interface IKTX2DecoderOptions {\r\n /** use RGBA format if ASTC and BC7 are not available as transcoded format */\r\n useRGBAIfASTCBC7NotAvailableWhenUASTC?: boolean;\r\n\r\n /** force to always use (uncompressed) RGBA for transcoded format */\r\n forceRGBA?: boolean;\r\n\r\n /** force to always use (uncompressed) R8 for transcoded format */\r\n forceR8?: boolean;\r\n\r\n /** force to always use (uncompressed) RG8 for transcoded format */\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n forceRG8?: boolean;\r\n\r\n /**\r\n * list of transcoders to bypass when looking for a suitable transcoder. The available transcoders are:\r\n * UniversalTranscoder_UASTC_ASTC\r\n * UniversalTranscoder_UASTC_BC7\r\n * UniversalTranscoder_UASTC_RGBA_UNORM\r\n * UniversalTranscoder_UASTC_RGBA_SRGB\r\n * UniversalTranscoder_UASTC_R8_UNORM\r\n * UniversalTranscoder_UASTC_RG8_UNORM\r\n * MSCTranscoder\r\n */\r\n bypassTranscoders?: string[];\r\n\r\n /**\r\n * Custom decision tree to apply after the default decision tree has selected a transcoding format.\r\n * Allows the user to override the default decision tree selection.\r\n * The decision tree can use the INode.transcodeFormat property to base its decision on the transcoding format selected by the default decision tree.\r\n */\r\n transcodeFormatDecisionTree?: IDecisionTree;\r\n}\r\n"]}
|
|
@@ -21,6 +21,7 @@ export * from "./Procedurals/pure.js";
|
|
|
21
21
|
export * from "./rawCubeTexture.js";
|
|
22
22
|
export * from "./rawTexture.js";
|
|
23
23
|
export * from "./rawTexture2DArray.js";
|
|
24
|
+
export * from "./rawTexture2DArray.functions.js";
|
|
24
25
|
export * from "./rawTexture3D.js";
|
|
25
26
|
export * from "./refractionTexture.js";
|
|
26
27
|
export * from "./renderTargetTexture.pure.js";
|
|
@@ -22,6 +22,7 @@ export * from "./Procedurals/pure.js";
|
|
|
22
22
|
export * from "./rawCubeTexture.js";
|
|
23
23
|
export * from "./rawTexture.js";
|
|
24
24
|
export * from "./rawTexture2DArray.js";
|
|
25
|
+
export * from "./rawTexture2DArray.functions.js";
|
|
25
26
|
export * from "./rawTexture3D.js";
|
|
26
27
|
export * from "./refractionTexture.js";
|
|
27
28
|
export * from "./renderTargetTexture.pure.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\n/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./baseTexture.pure\";\nexport * from \"./baseTexture.polynomial.pure\";\nexport * from \"./colorGradingTexture.pure\";\nexport * from \"./cubeTexture.pure\";\nexport * from \"./dynamicTexture.pure\";\nexport * from \"./equiRectangularCubeTexture.pure\";\nexport * from \"./externalTexture\";\nexport * from \"./Filtering/hdrFiltering\";\nexport * from \"./envCubeTexture.pure\";\nexport * from \"./hdrCubeTexture.pure\";\nexport * from \"./exrCubeTexture.pure\";\nexport * from \"./htmlElementTexture.pure\";\nexport * from \"./HTML/pure\";\nexport * from \"./internalTexture\";\nexport * from \"./Loaders/pure\";\nexport * from \"./mirrorTexture.pure\";\nexport * from \"./multiRenderTarget.pure\";\nexport * from \"./Packer/pure\";\nexport * from \"./Procedurals/pure\";\nexport * from \"./rawCubeTexture\";\nexport * from \"./rawTexture\";\nexport * from \"./rawTexture2DArray\";\nexport * from \"./rawTexture3D\";\nexport * from \"./refractionTexture\";\nexport * from \"./renderTargetTexture.pure\";\nexport * from \"./reflectionProbeTexture.pure\";\nexport * from \"./textureMerger\";\nexport * from \"./textureSampler\";\nexport * from \"./textureProcessor\";\nexport * from \"./texture.pure\";\nexport * from \"./thinTexture\";\nexport * from \"./thinRenderTargetTexture\";\nexport * from \"./videoTexture.pure\";\nexport * from \"./ktx2decoderTypes\";\nexport * from \"./textureCreationOptions\";\n"]}
|
|
1
|
+
{"version":3,"file":"pure.js","sourceRoot":"","sources":["../../../../../dev/core/src/Materials/Textures/pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,6DAA6D;AAC7D,cAAc,oBAAoB,CAAC;AACnC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mCAAmC,CAAC;AAClD,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,0BAA0B,CAAC","sourcesContent":["/** Pure barrel — re-exports only side-effect-free modules */\n/* eslint-disable @typescript-eslint/no-restricted-imports */\nexport * from \"./baseTexture.pure\";\nexport * from \"./baseTexture.polynomial.pure\";\nexport * from \"./colorGradingTexture.pure\";\nexport * from \"./cubeTexture.pure\";\nexport * from \"./dynamicTexture.pure\";\nexport * from \"./equiRectangularCubeTexture.pure\";\nexport * from \"./externalTexture\";\nexport * from \"./Filtering/hdrFiltering\";\nexport * from \"./envCubeTexture.pure\";\nexport * from \"./hdrCubeTexture.pure\";\nexport * from \"./exrCubeTexture.pure\";\nexport * from \"./htmlElementTexture.pure\";\nexport * from \"./HTML/pure\";\nexport * from \"./internalTexture\";\nexport * from \"./Loaders/pure\";\nexport * from \"./mirrorTexture.pure\";\nexport * from \"./multiRenderTarget.pure\";\nexport * from \"./Packer/pure\";\nexport * from \"./Procedurals/pure\";\nexport * from \"./rawCubeTexture\";\nexport * from \"./rawTexture\";\nexport * from \"./rawTexture2DArray\";\nexport * from \"./rawTexture2DArray.functions\";\nexport * from \"./rawTexture3D\";\nexport * from \"./refractionTexture\";\nexport * from \"./renderTargetTexture.pure\";\nexport * from \"./reflectionProbeTexture.pure\";\nexport * from \"./textureMerger\";\nexport * from \"./textureSampler\";\nexport * from \"./textureProcessor\";\nexport * from \"./texture.pure\";\nexport * from \"./thinTexture\";\nexport * from \"./thinRenderTargetTexture\";\nexport * from \"./videoTexture.pure\";\nexport * from \"./ktx2decoderTypes\";\nexport * from \"./textureCreationOptions\";\n"]}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { type ImageSource } from "../../types.js";
|
|
2
|
+
import { type Scene } from "../../scene.js";
|
|
3
|
+
import { RawTexture2DArray } from "./rawTexture2DArray.js";
|
|
4
|
+
/**
|
|
5
|
+
* These helpers populate 2D array texture layers from decoded image sources.
|
|
6
|
+
* They rely on the AbstractEngine.updateTextureArrayLayerFromImageSource engine extension, which is
|
|
7
|
+
* an opt-in side effect. Register it before use by importing the matching module for your backend:
|
|
8
|
+
* - WebGL2: import "../../Engines/Extensions/engine.texture2DArrayImageSource.js";
|
|
9
|
+
* - WebGPU: import "../../Engines/WebGPU/Extensions/engine.texture2DArrayImageSource.js";
|
|
10
|
+
* (the full Engine build does not register it by default to keep it out of every engine bundle).
|
|
11
|
+
*
|
|
12
|
+
* Consuming the result: the built-in way to sample a chosen layer is Node Material's Texture block,
|
|
13
|
+
* which exposes a `layer` input (feed it a Float) and samples the array at that layer for you — no
|
|
14
|
+
* custom shader code required. If you instead write your own shader, declare a `sampler2DArray`
|
|
15
|
+
* (GLSL) / `texture_2d_array<f32>` (WGSL) uniform and sample it with an explicit integer layer index;
|
|
16
|
+
* the classic StandardMaterial / PBRMaterial texture slots are plain 2D and cannot read an array layer.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Options controlling how an image source is uploaded into a 2D array texture layer.
|
|
20
|
+
*/
|
|
21
|
+
export interface IUploadImageToTexture2DArrayLayerOptions {
|
|
22
|
+
/** Defines if the source must be stored with the Y axis inverted (false by default) */
|
|
23
|
+
invertY?: boolean;
|
|
24
|
+
/** Defines if the source alpha must be premultiplied (false by default) */
|
|
25
|
+
premultiplyAlpha?: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Options controlling the creation of a 2D array texture from a list of image urls.
|
|
29
|
+
*/
|
|
30
|
+
export interface ICreateTexture2DArrayFromImageUrlsOptions extends IUploadImageToTexture2DArrayLayerOptions {
|
|
31
|
+
/** Defines if mip levels should be generated (true by default) */
|
|
32
|
+
generateMipMaps?: boolean;
|
|
33
|
+
/** Defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default) */
|
|
34
|
+
samplingMode?: number;
|
|
35
|
+
/** Defines the texture type (Constants.TEXTURETYPE_UNSIGNED_BYTE by default) */
|
|
36
|
+
textureType?: number;
|
|
37
|
+
/** Options forwarded to createImageBitmap when decoding each url */
|
|
38
|
+
imageBitmapOptions?: ImageBitmapOptions;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Uploads a decoded image source (ImageBitmap, canvas, video, image element...) into a single layer of a 2D array texture.
|
|
42
|
+
* This is the image-source counterpart to RawTexture2DArray.update, which only accepts raw bytes.
|
|
43
|
+
* @param texture defines the 2D array texture to upload into
|
|
44
|
+
* @param source defines the image source to upload
|
|
45
|
+
* @param layer defines the array layer to upload into
|
|
46
|
+
* @param options defines optional upload settings (invertY, premultiplyAlpha)
|
|
47
|
+
*/
|
|
48
|
+
export declare function UploadImageToTexture2DArrayLayer(texture: RawTexture2DArray, source: ImageSource, layer: number, options?: IUploadImageToTexture2DArrayLayerOptions): void;
|
|
49
|
+
/**
|
|
50
|
+
* Fetches an image from a url, decodes it and uploads it into a single layer of a 2D array texture.
|
|
51
|
+
* @param texture defines the 2D array texture to upload into
|
|
52
|
+
* @param url defines the url of the image to load
|
|
53
|
+
* @param layer defines the array layer to upload into
|
|
54
|
+
* @param options defines optional upload settings (invertY, premultiplyAlpha)
|
|
55
|
+
* @returns a promise resolved once the layer has been uploaded
|
|
56
|
+
*/
|
|
57
|
+
export declare function LoadImageToTexture2DArrayLayerAsync(texture: RawTexture2DArray, url: string, layer: number, options?: IUploadImageToTexture2DArrayLayerOptions): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Options controlling the creation of a 2D array texture from a KTX2 file.
|
|
60
|
+
*/
|
|
61
|
+
export interface ICreateTexture2DArrayFromKTX2Options {
|
|
62
|
+
/** Defines if mip levels should be generated (true by default) */
|
|
63
|
+
generateMipMaps?: boolean;
|
|
64
|
+
/** Defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default) */
|
|
65
|
+
samplingMode?: number;
|
|
66
|
+
/** Defines if the texture must be stored with the Y axis inverted (false by default) */
|
|
67
|
+
invertY?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates a 2D array texture from a single KTX2 file holding several array layers (layerCount greater than 1).
|
|
71
|
+
* This is the single-file counterpart to CreateTexture2DArrayFromImageUrlsAsync: rather than fetching one image
|
|
72
|
+
* per layer, the whole array travels in one container.
|
|
73
|
+
*
|
|
74
|
+
* The data is transcoded to uncompressed RGBA. Keeping the texture in its transcoded compressed form would
|
|
75
|
+
* require compressedTexImage3D support in the engine raw texture path, which does not exist yet, so the
|
|
76
|
+
* GPU cost here matches a plain RGBA array texture.
|
|
77
|
+
*
|
|
78
|
+
* Only the base mip level stored in the file is uploaded; when generateMipMaps is on, the remaining levels are
|
|
79
|
+
* regenerated by the engine. Uploading the file's own mip chain needs per-mip array uploads, which WebGL's
|
|
80
|
+
* updateRawTexture2DArray does not support today.
|
|
81
|
+
* @param scene defines the hosting scene
|
|
82
|
+
* @param data defines the url of the KTX2 file, or its already fetched content
|
|
83
|
+
* @param options defines optional creation settings
|
|
84
|
+
* @returns a promise resolved with the created RawTexture2DArray
|
|
85
|
+
*/
|
|
86
|
+
export declare function CreateTexture2DArrayFromKTX2Async(scene: Scene, data: string | ArrayBufferView, options?: ICreateTexture2DArrayFromKTX2Options): Promise<RawTexture2DArray>;
|
|
87
|
+
/**
|
|
88
|
+
* Creates a 2D array texture and fills each layer from a list of image urls.
|
|
89
|
+
* All images must share the same dimensions.
|
|
90
|
+
* @param scene defines the hosting scene
|
|
91
|
+
* @param urls defines the url of the image for each layer (at least one)
|
|
92
|
+
* @param options defines optional creation and upload settings
|
|
93
|
+
* @returns a promise resolved with the created RawTexture2DArray
|
|
94
|
+
*/
|
|
95
|
+
export declare function CreateTexture2DArrayFromImageUrlsAsync(scene: Scene, urls: readonly [string, ...string[]], options?: ICreateTexture2DArrayFromImageUrlsOptions): Promise<RawTexture2DArray>;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
|
|
2
|
+
import { _IsSideEffectImplemented, _WarnImport } from "../../Misc/devTools.js";
|
|
3
|
+
import { RawTexture2DArray } from "./rawTexture2DArray.js";
|
|
4
|
+
/**
|
|
5
|
+
* Uploads a decoded image source (ImageBitmap, canvas, video, image element...) into a single layer of a 2D array texture.
|
|
6
|
+
* This is the image-source counterpart to RawTexture2DArray.update, which only accepts raw bytes.
|
|
7
|
+
* @param texture defines the 2D array texture to upload into
|
|
8
|
+
* @param source defines the image source to upload
|
|
9
|
+
* @param layer defines the array layer to upload into
|
|
10
|
+
* @param options defines optional upload settings (invertY, premultiplyAlpha)
|
|
11
|
+
*/
|
|
12
|
+
export function UploadImageToTexture2DArrayLayer(texture, source, layer, options) {
|
|
13
|
+
const internalTexture = texture.getInternalTexture();
|
|
14
|
+
if (!internalTexture) {
|
|
15
|
+
throw new Error("Cannot upload to a 2D array texture that has no internal texture.");
|
|
16
|
+
}
|
|
17
|
+
if (!Number.isInteger(layer) || layer < 0 || layer >= texture.depth) {
|
|
18
|
+
throw new Error(`Layer ${layer} is out of range for a 2D array texture with ${texture.depth} layers.`);
|
|
19
|
+
}
|
|
20
|
+
const scene = texture.getScene();
|
|
21
|
+
if (!scene) {
|
|
22
|
+
throw new Error("Cannot upload to a 2D array texture that is not attached to a scene.");
|
|
23
|
+
}
|
|
24
|
+
const engine = scene.getEngine();
|
|
25
|
+
// updateTextureArrayLayerFromImageSource is an opt-in engine extension. When the consumer never
|
|
26
|
+
// imported it, the augmented method is missing, so fail early with the standard side-effect import
|
|
27
|
+
// message (matching the engine.rawTexture family) instead of a generic "is not a function" error.
|
|
28
|
+
if (!_IsSideEffectImplemented(engine.updateTextureArrayLayerFromImageSource)) {
|
|
29
|
+
throw _WarnImport("engine.texture2DArrayImageSource");
|
|
30
|
+
}
|
|
31
|
+
engine.updateTextureArrayLayerFromImageSource(internalTexture, source, layer, options?.invertY ?? false, options?.premultiplyAlpha ?? false);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Fetches an image from a url, decodes it and uploads it into a single layer of a 2D array texture.
|
|
35
|
+
* @param texture defines the 2D array texture to upload into
|
|
36
|
+
* @param url defines the url of the image to load
|
|
37
|
+
* @param layer defines the array layer to upload into
|
|
38
|
+
* @param options defines optional upload settings (invertY, premultiplyAlpha)
|
|
39
|
+
* @returns a promise resolved once the layer has been uploaded
|
|
40
|
+
*/
|
|
41
|
+
export async function LoadImageToTexture2DArrayLayerAsync(texture, url, layer, options) {
|
|
42
|
+
const response = await fetch(url);
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new Error(`Failed to fetch image "${url}": ${response.status} ${response.statusText}`);
|
|
45
|
+
}
|
|
46
|
+
const blob = await response.blob();
|
|
47
|
+
const bitmap = await createImageBitmap(blob);
|
|
48
|
+
try {
|
|
49
|
+
UploadImageToTexture2DArrayLayer(texture, bitmap, layer, options);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
bitmap.close();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Creates a 2D array texture from a single KTX2 file holding several array layers (layerCount greater than 1).
|
|
57
|
+
* This is the single-file counterpart to CreateTexture2DArrayFromImageUrlsAsync: rather than fetching one image
|
|
58
|
+
* per layer, the whole array travels in one container.
|
|
59
|
+
*
|
|
60
|
+
* The data is transcoded to uncompressed RGBA. Keeping the texture in its transcoded compressed form would
|
|
61
|
+
* require compressedTexImage3D support in the engine raw texture path, which does not exist yet, so the
|
|
62
|
+
* GPU cost here matches a plain RGBA array texture.
|
|
63
|
+
*
|
|
64
|
+
* Only the base mip level stored in the file is uploaded; when generateMipMaps is on, the remaining levels are
|
|
65
|
+
* regenerated by the engine. Uploading the file's own mip chain needs per-mip array uploads, which WebGL's
|
|
66
|
+
* updateRawTexture2DArray does not support today.
|
|
67
|
+
* @param scene defines the hosting scene
|
|
68
|
+
* @param data defines the url of the KTX2 file, or its already fetched content
|
|
69
|
+
* @param options defines optional creation settings
|
|
70
|
+
* @returns a promise resolved with the created RawTexture2DArray
|
|
71
|
+
*/
|
|
72
|
+
export async function CreateTexture2DArrayFromKTX2Async(scene, data, options) {
|
|
73
|
+
let buffer;
|
|
74
|
+
if (typeof data === "string") {
|
|
75
|
+
const response = await fetch(data);
|
|
76
|
+
if (!response.ok) {
|
|
77
|
+
throw new Error(`Failed to fetch KTX2 file "${data}": ${response.status} ${response.statusText}`);
|
|
78
|
+
}
|
|
79
|
+
buffer = new Uint8Array(await response.arrayBuffer());
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
buffer = data;
|
|
83
|
+
}
|
|
84
|
+
const { KhronosTextureContainer2 } = await import("../../Misc/khronosTextureContainer2.js");
|
|
85
|
+
if (!KhronosTextureContainer2.IsValid(buffer)) {
|
|
86
|
+
throw new Error("The provided data is not a valid KTX2 file.");
|
|
87
|
+
}
|
|
88
|
+
const container = new KhronosTextureContainer2(scene.getEngine());
|
|
89
|
+
// forceRGBA: the transcoded compressed formats cannot be uploaded to an array texture yet (see above).
|
|
90
|
+
const decodedData = await container._decodeAsync(buffer, { forceRGBA: true });
|
|
91
|
+
if (decodedData.errors) {
|
|
92
|
+
throw new Error("Failed to decode the KTX2 file. " + decodedData.errors);
|
|
93
|
+
}
|
|
94
|
+
const layerCount = Math.max(decodedData.layerCount ?? 1, 1);
|
|
95
|
+
// mipmaps are ordered level by level, and within a level layer by layer, so the base level occupies
|
|
96
|
+
// the first layerCount entries and its layers are already in ascending order.
|
|
97
|
+
const baseLevel = decodedData.mipmaps.slice(0, layerCount);
|
|
98
|
+
if (baseLevel.length !== layerCount) {
|
|
99
|
+
throw new Error(`Failed to decode the KTX2 file: expected ${layerCount} layers for the base mip level but got ${baseLevel.length}.`);
|
|
100
|
+
}
|
|
101
|
+
// Every layer of a level shares the level's dimensions, and forceRGBA above means each one must be exactly
|
|
102
|
+
// width * height * 4 bytes. RawTexture2DArray takes all the layers as one flat buffer and cannot detect a
|
|
103
|
+
// short or mismatched layer, so validate here rather than uploading malformed data.
|
|
104
|
+
const { width, height } = baseLevel[0];
|
|
105
|
+
const expectedLayerByteLength = width * height * 4;
|
|
106
|
+
for (const mipmap of baseLevel) {
|
|
107
|
+
if (!mipmap.data) {
|
|
108
|
+
throw new Error(`Failed to decode the KTX2 file: layer ${mipmap.layerIndex} of the base mip level is empty.`);
|
|
109
|
+
}
|
|
110
|
+
if (mipmap.width !== width || mipmap.height !== height) {
|
|
111
|
+
throw new Error(`Failed to decode the KTX2 file: layer ${mipmap.layerIndex} of the base mip level is ${mipmap.width}x${mipmap.height} but layer 0 is ${width}x${height}.`);
|
|
112
|
+
}
|
|
113
|
+
if (mipmap.data.byteLength !== expectedLayerByteLength) {
|
|
114
|
+
throw new Error(`Failed to decode the KTX2 file: layer ${mipmap.layerIndex} of the base mip level holds ${mipmap.data.byteLength} bytes but ${expectedLayerByteLength} were expected.`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// A 2D array texture is uploaded as a single buffer holding every layer back to back.
|
|
118
|
+
const textureData = new Uint8Array(expectedLayerByteLength * layerCount);
|
|
119
|
+
let byteOffset = 0;
|
|
120
|
+
for (const mipmap of baseLevel) {
|
|
121
|
+
textureData.set(mipmap.data, byteOffset);
|
|
122
|
+
byteOffset += mipmap.data.byteLength;
|
|
123
|
+
}
|
|
124
|
+
return new RawTexture2DArray(textureData, width, height, layerCount, 5, scene, options?.generateMipMaps ?? true, options?.invertY ?? false, options?.samplingMode, 0);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Creates a 2D array texture and fills each layer from a list of image urls.
|
|
128
|
+
* All images must share the same dimensions.
|
|
129
|
+
* @param scene defines the hosting scene
|
|
130
|
+
* @param urls defines the url of the image for each layer (at least one)
|
|
131
|
+
* @param options defines optional creation and upload settings
|
|
132
|
+
* @returns a promise resolved with the created RawTexture2DArray
|
|
133
|
+
*/
|
|
134
|
+
export async function CreateTexture2DArrayFromImageUrlsAsync(scene, urls, options) {
|
|
135
|
+
// allSettled (not all): a rejected fetch/decode must not leak the layers that
|
|
136
|
+
// already decoded. Promise.all rejects on the first failure and never enters the
|
|
137
|
+
// try/finally below, orphaning every ImageBitmap that resolved. Close the
|
|
138
|
+
// fulfilled ones here, then rethrow the original failure.
|
|
139
|
+
const results = await Promise.allSettled(urls.map(async (url) => {
|
|
140
|
+
const response = await fetch(url);
|
|
141
|
+
if (!response.ok) {
|
|
142
|
+
throw new Error(`Failed to fetch image "${url}": ${response.status} ${response.statusText}`);
|
|
143
|
+
}
|
|
144
|
+
return await createImageBitmap(await response.blob(), options?.imageBitmapOptions);
|
|
145
|
+
}));
|
|
146
|
+
const firstRejection = results.find((result) => result.status === "rejected");
|
|
147
|
+
if (firstRejection) {
|
|
148
|
+
for (const result of results) {
|
|
149
|
+
if (result.status === "fulfilled") {
|
|
150
|
+
result.value.close();
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
throw firstRejection.reason;
|
|
154
|
+
}
|
|
155
|
+
const bitmaps = results.filter((result) => result.status === "fulfilled").map((result) => result.value);
|
|
156
|
+
try {
|
|
157
|
+
const width = bitmaps[0].width;
|
|
158
|
+
const height = bitmaps[0].height;
|
|
159
|
+
for (let index = 1; index < bitmaps.length; index++) {
|
|
160
|
+
const bitmap = bitmaps[index];
|
|
161
|
+
if (bitmap.width !== width || bitmap.height !== height) {
|
|
162
|
+
throw new Error(`All images must share the same dimensions. Image at index ${index} is ${bitmap.width}x${bitmap.height}, expected ${width}x${height}.`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const texture = new RawTexture2DArray(null, width, height, bitmaps.length, 5, scene, options?.generateMipMaps ?? true, options?.invertY ?? false, options?.samplingMode, options?.textureType);
|
|
166
|
+
try {
|
|
167
|
+
const uploadOptions = {
|
|
168
|
+
invertY: options?.invertY ?? false,
|
|
169
|
+
premultiplyAlpha: options?.premultiplyAlpha ?? false,
|
|
170
|
+
};
|
|
171
|
+
// updateTextureArrayLayerFromImageSource rebuilds the whole mip chain on each upload when mips
|
|
172
|
+
// are enabled. Uploading N layers that way is O(N) redundant mip generation, so suppress it
|
|
173
|
+
// per-layer and let only the final upload regenerate the mips once — a single generateMipmap
|
|
174
|
+
// covers every layer of the array.
|
|
175
|
+
const internalTexture = texture.getInternalTexture();
|
|
176
|
+
const generateMipMaps = internalTexture?.generateMipMaps ?? false;
|
|
177
|
+
if (internalTexture && generateMipMaps) {
|
|
178
|
+
internalTexture.generateMipMaps = false;
|
|
179
|
+
}
|
|
180
|
+
for (let layer = 0; layer < bitmaps.length; layer++) {
|
|
181
|
+
if (internalTexture && generateMipMaps && layer === bitmaps.length - 1) {
|
|
182
|
+
internalTexture.generateMipMaps = true;
|
|
183
|
+
}
|
|
184
|
+
UploadImageToTexture2DArrayLayer(texture, bitmaps[layer], layer, uploadOptions);
|
|
185
|
+
}
|
|
186
|
+
return texture;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
// A layer upload can throw (out-of-range layer, missing engine extension, backend upload
|
|
190
|
+
// failure). Dispose the freshly allocated GPU texture so it does not leak, then rethrow.
|
|
191
|
+
texture.dispose();
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
finally {
|
|
196
|
+
for (let index = 0; index < bitmaps.length; index++) {
|
|
197
|
+
bitmaps[index].close();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=rawTexture2DArray.functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rawTexture2DArray.functions.js","sourceRoot":"","sources":["../../../../../d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,MAAM,GAAG,CAAC,EAAE,CAAC;oBACrE,eAAe,CAAC,eAAe,GAAG,IAAI,CAAC;gBAC3C,CAAC;gBACD,gCAAgC,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;YACpF,CAAC;YAED,OAAO,OAAO,CAAC;QACnB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,yFAAyF;YACzF,yFAAyF;YACzF,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,KAAK,CAAC;QAChB,CAAC;IACL,CAAC;YAAS,CAAC;QACP,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;YAClD,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,CAAC;QAC3B,CAAC;IACL,CAAC;AACL,CAAC","sourcesContent":["import { type ImageSource } from \"../../types\";\r\nimport { type Scene } from \"../../scene\";\r\nimport { Constants } from \"../../Engines/constants\";\r\nimport { _IsSideEffectImplemented, _WarnImport } from \"../../Misc/devTools\";\r\nimport { RawTexture2DArray } from \"./rawTexture2DArray\";\r\n\r\n/**\r\n * These helpers populate 2D array texture layers from decoded image sources.\r\n * They rely on the AbstractEngine.updateTextureArrayLayerFromImageSource engine extension, which is\r\n * an opt-in side effect. Register it before use by importing the matching module for your backend:\r\n * - WebGL2: import \"core/Engines/Extensions/engine.texture2DArrayImageSource\";\r\n * - WebGPU: import \"core/Engines/WebGPU/Extensions/engine.texture2DArrayImageSource\";\r\n * (the full Engine build does not register it by default to keep it out of every engine bundle).\r\n *\r\n * Consuming the result: the built-in way to sample a chosen layer is Node Material's Texture block,\r\n * which exposes a `layer` input (feed it a Float) and samples the array at that layer for you — no\r\n * custom shader code required. If you instead write your own shader, declare a `sampler2DArray`\r\n * (GLSL) / `texture_2d_array<f32>` (WGSL) uniform and sample it with an explicit integer layer index;\r\n * the classic StandardMaterial / PBRMaterial texture slots are plain 2D and cannot read an array layer.\r\n */\r\n\r\n/**\r\n * Options controlling how an image source is uploaded into a 2D array texture layer.\r\n */\r\nexport interface IUploadImageToTexture2DArrayLayerOptions {\r\n /** Defines if the source must be stored with the Y axis inverted (false by default) */\r\n invertY?: boolean;\r\n /** Defines if the source alpha must be premultiplied (false by default) */\r\n premultiplyAlpha?: boolean;\r\n}\r\n\r\n/**\r\n * Options controlling the creation of a 2D array texture from a list of image urls.\r\n */\r\nexport interface ICreateTexture2DArrayFromImageUrlsOptions extends IUploadImageToTexture2DArrayLayerOptions {\r\n /** Defines if mip levels should be generated (true by default) */\r\n generateMipMaps?: boolean;\r\n /** Defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default) */\r\n samplingMode?: number;\r\n /** Defines the texture type (Constants.TEXTURETYPE_UNSIGNED_BYTE by default) */\r\n textureType?: number;\r\n /** Options forwarded to createImageBitmap when decoding each url */\r\n imageBitmapOptions?: ImageBitmapOptions;\r\n}\r\n\r\n/**\r\n * Uploads a decoded image source (ImageBitmap, canvas, video, image element...) into a single layer of a 2D array texture.\r\n * This is the image-source counterpart to RawTexture2DArray.update, which only accepts raw bytes.\r\n * @param texture defines the 2D array texture to upload into\r\n * @param source defines the image source to upload\r\n * @param layer defines the array layer to upload into\r\n * @param options defines optional upload settings (invertY, premultiplyAlpha)\r\n */\r\nexport function UploadImageToTexture2DArrayLayer(texture: RawTexture2DArray, source: ImageSource, layer: number, options?: IUploadImageToTexture2DArrayLayerOptions): void {\r\n const internalTexture = texture.getInternalTexture();\r\n if (!internalTexture) {\r\n throw new Error(\"Cannot upload to a 2D array texture that has no internal texture.\");\r\n }\r\n\r\n if (!Number.isInteger(layer) || layer < 0 || layer >= texture.depth) {\r\n throw new Error(`Layer ${layer} is out of range for a 2D array texture with ${texture.depth} layers.`);\r\n }\r\n\r\n const scene = texture.getScene();\r\n if (!scene) {\r\n throw new Error(\"Cannot upload to a 2D array texture that is not attached to a scene.\");\r\n }\r\n\r\n const engine = scene.getEngine();\r\n // updateTextureArrayLayerFromImageSource is an opt-in engine extension. When the consumer never\r\n // imported it, the augmented method is missing, so fail early with the standard side-effect import\r\n // message (matching the engine.rawTexture family) instead of a generic \"is not a function\" error.\r\n if (!_IsSideEffectImplemented(engine.updateTextureArrayLayerFromImageSource)) {\r\n throw _WarnImport(\"engine.texture2DArrayImageSource\");\r\n }\r\n\r\n engine.updateTextureArrayLayerFromImageSource(internalTexture, source, layer, options?.invertY ?? false, options?.premultiplyAlpha ?? false);\r\n}\r\n\r\n/**\r\n * Fetches an image from a url, decodes it and uploads it into a single layer of a 2D array texture.\r\n * @param texture defines the 2D array texture to upload into\r\n * @param url defines the url of the image to load\r\n * @param layer defines the array layer to upload into\r\n * @param options defines optional upload settings (invertY, premultiplyAlpha)\r\n * @returns a promise resolved once the layer has been uploaded\r\n */\r\nexport async function LoadImageToTexture2DArrayLayerAsync(\r\n texture: RawTexture2DArray,\r\n url: string,\r\n layer: number,\r\n options?: IUploadImageToTexture2DArrayLayerOptions\r\n): Promise<void> {\r\n const response = await fetch(url);\r\n if (!response.ok) {\r\n throw new Error(`Failed to fetch image \"${url}\": ${response.status} ${response.statusText}`);\r\n }\r\n const blob = await response.blob();\r\n const bitmap = await createImageBitmap(blob);\r\n try {\r\n UploadImageToTexture2DArrayLayer(texture, bitmap, layer, options);\r\n } finally {\r\n bitmap.close();\r\n }\r\n}\r\n\r\n/**\r\n * Options controlling the creation of a 2D array texture from a KTX2 file.\r\n */\r\nexport interface ICreateTexture2DArrayFromKTX2Options {\r\n /** Defines if mip levels should be generated (true by default) */\r\n generateMipMaps?: boolean;\r\n /** Defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default) */\r\n samplingMode?: number;\r\n /** Defines if the texture must be stored with the Y axis inverted (false by default) */\r\n invertY?: boolean;\r\n}\r\n\r\n/**\r\n * Creates a 2D array texture from a single KTX2 file holding several array layers (layerCount greater than 1).\r\n * This is the single-file counterpart to CreateTexture2DArrayFromImageUrlsAsync: rather than fetching one image\r\n * per layer, the whole array travels in one container.\r\n *\r\n * The data is transcoded to uncompressed RGBA. Keeping the texture in its transcoded compressed form would\r\n * require compressedTexImage3D support in the engine raw texture path, which does not exist yet, so the\r\n * GPU cost here matches a plain RGBA array texture.\r\n *\r\n * Only the base mip level stored in the file is uploaded; when generateMipMaps is on, the remaining levels are\r\n * regenerated by the engine. Uploading the file's own mip chain needs per-mip array uploads, which WebGL's\r\n * updateRawTexture2DArray does not support today.\r\n * @param scene defines the hosting scene\r\n * @param data defines the url of the KTX2 file, or its already fetched content\r\n * @param options defines optional creation settings\r\n * @returns a promise resolved with the created RawTexture2DArray\r\n */\r\nexport async function CreateTexture2DArrayFromKTX2Async(scene: Scene, data: string | ArrayBufferView, options?: ICreateTexture2DArrayFromKTX2Options): Promise<RawTexture2DArray> {\r\n let buffer: ArrayBufferView;\r\n if (typeof data === \"string\") {\r\n const response = await fetch(data);\r\n if (!response.ok) {\r\n throw new Error(`Failed to fetch KTX2 file \"${data}\": ${response.status} ${response.statusText}`);\r\n }\r\n buffer = new Uint8Array(await response.arrayBuffer());\r\n } else {\r\n buffer = data;\r\n }\r\n\r\n const { KhronosTextureContainer2 } = await import(\"../../Misc/khronosTextureContainer2\");\r\n\r\n if (!KhronosTextureContainer2.IsValid(buffer)) {\r\n throw new Error(\"The provided data is not a valid KTX2 file.\");\r\n }\r\n\r\n const container = new KhronosTextureContainer2(scene.getEngine());\r\n\r\n // forceRGBA: the transcoded compressed formats cannot be uploaded to an array texture yet (see above).\r\n const decodedData = await container._decodeAsync(buffer, { forceRGBA: true });\r\n\r\n if (decodedData.errors) {\r\n throw new Error(\"Failed to decode the KTX2 file. \" + decodedData.errors);\r\n }\r\n\r\n const layerCount = Math.max(decodedData.layerCount ?? 1, 1);\r\n // mipmaps are ordered level by level, and within a level layer by layer, so the base level occupies\r\n // the first layerCount entries and its layers are already in ascending order.\r\n const baseLevel = decodedData.mipmaps.slice(0, layerCount);\r\n\r\n if (baseLevel.length !== layerCount) {\r\n throw new Error(`Failed to decode the KTX2 file: expected ${layerCount} layers for the base mip level but got ${baseLevel.length}.`);\r\n }\r\n\r\n // Every layer of a level shares the level's dimensions, and forceRGBA above means each one must be exactly\r\n // width * height * 4 bytes. RawTexture2DArray takes all the layers as one flat buffer and cannot detect a\r\n // short or mismatched layer, so validate here rather than uploading malformed data.\r\n const { width, height } = baseLevel[0];\r\n const expectedLayerByteLength = width * height * 4;\r\n\r\n for (const mipmap of baseLevel) {\r\n if (!mipmap.data) {\r\n throw new Error(`Failed to decode the KTX2 file: layer ${mipmap.layerIndex} of the base mip level is empty.`);\r\n }\r\n if (mipmap.width !== width || mipmap.height !== height) {\r\n throw new Error(\r\n `Failed to decode the KTX2 file: layer ${mipmap.layerIndex} of the base mip level is ${mipmap.width}x${mipmap.height} but layer 0 is ${width}x${height}.`\r\n );\r\n }\r\n if (mipmap.data.byteLength !== expectedLayerByteLength) {\r\n throw new Error(\r\n `Failed to decode the KTX2 file: layer ${mipmap.layerIndex} of the base mip level holds ${mipmap.data.byteLength} bytes but ${expectedLayerByteLength} were expected.`\r\n );\r\n }\r\n }\r\n\r\n // A 2D array texture is uploaded as a single buffer holding every layer back to back.\r\n const textureData = new Uint8Array(expectedLayerByteLength * layerCount);\r\n let byteOffset = 0;\r\n for (const mipmap of baseLevel) {\r\n textureData.set(mipmap.data!, byteOffset);\r\n byteOffset += mipmap.data!.byteLength;\r\n }\r\n\r\n return new RawTexture2DArray(\r\n textureData,\r\n width,\r\n height,\r\n layerCount,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n scene,\r\n options?.generateMipMaps ?? true,\r\n options?.invertY ?? false,\r\n options?.samplingMode,\r\n Constants.TEXTURETYPE_UNSIGNED_BYTE\r\n );\r\n}\r\n\r\n/**\r\n * Creates a 2D array texture and fills each layer from a list of image urls.\r\n * All images must share the same dimensions.\r\n * @param scene defines the hosting scene\r\n * @param urls defines the url of the image for each layer (at least one)\r\n * @param options defines optional creation and upload settings\r\n * @returns a promise resolved with the created RawTexture2DArray\r\n */\r\nexport async function CreateTexture2DArrayFromImageUrlsAsync(\r\n scene: Scene,\r\n urls: readonly [string, ...string[]],\r\n options?: ICreateTexture2DArrayFromImageUrlsOptions\r\n): Promise<RawTexture2DArray> {\r\n // allSettled (not all): a rejected fetch/decode must not leak the layers that\r\n // already decoded. Promise.all rejects on the first failure and never enters the\r\n // try/finally below, orphaning every ImageBitmap that resolved. Close the\r\n // fulfilled ones here, then rethrow the original failure.\r\n const results = await Promise.allSettled(\r\n urls.map(async (url) => {\r\n const response = await fetch(url);\r\n if (!response.ok) {\r\n throw new Error(`Failed to fetch image \"${url}\": ${response.status} ${response.statusText}`);\r\n }\r\n return await createImageBitmap(await response.blob(), options?.imageBitmapOptions);\r\n })\r\n );\r\n\r\n const firstRejection = results.find((result): result is PromiseRejectedResult => result.status === \"rejected\");\r\n if (firstRejection) {\r\n for (const result of results) {\r\n if (result.status === \"fulfilled\") {\r\n result.value.close();\r\n }\r\n }\r\n throw firstRejection.reason;\r\n }\r\n\r\n const bitmaps = results.filter((result): result is PromiseFulfilledResult<ImageBitmap> => result.status === \"fulfilled\").map((result) => result.value) as [\r\n ImageBitmap,\r\n ...ImageBitmap[],\r\n ];\r\n\r\n try {\r\n const width = bitmaps[0].width;\r\n const height = bitmaps[0].height;\r\n\r\n for (let index = 1; index < bitmaps.length; index++) {\r\n const bitmap = bitmaps[index];\r\n if (bitmap.width !== width || bitmap.height !== height) {\r\n throw new Error(`All images must share the same dimensions. Image at index ${index} is ${bitmap.width}x${bitmap.height}, expected ${width}x${height}.`);\r\n }\r\n }\r\n\r\n const texture = new RawTexture2DArray(\r\n null,\r\n width,\r\n height,\r\n bitmaps.length,\r\n Constants.TEXTUREFORMAT_RGBA,\r\n scene,\r\n options?.generateMipMaps ?? true,\r\n options?.invertY ?? false,\r\n options?.samplingMode,\r\n options?.textureType\r\n );\r\n\r\n try {\r\n const uploadOptions: IUploadImageToTexture2DArrayLayerOptions = {\r\n invertY: options?.invertY ?? false,\r\n premultiplyAlpha: options?.premultiplyAlpha ?? false,\r\n };\r\n\r\n // updateTextureArrayLayerFromImageSource rebuilds the whole mip chain on each upload when mips\r\n // are enabled. Uploading N layers that way is O(N) redundant mip generation, so suppress it\r\n // per-layer and let only the final upload regenerate the mips once — a single generateMipmap\r\n // covers every layer of the array.\r\n const internalTexture = texture.getInternalTexture();\r\n const generateMipMaps = internalTexture?.generateMipMaps ?? false;\r\n if (internalTexture && generateMipMaps) {\r\n internalTexture.generateMipMaps = false;\r\n }\r\n\r\n for (let layer = 0; layer < bitmaps.length; layer++) {\r\n if (internalTexture && generateMipMaps && layer === bitmaps.length - 1) {\r\n internalTexture.generateMipMaps = true;\r\n }\r\n UploadImageToTexture2DArrayLayer(texture, bitmaps[layer], layer, uploadOptions);\r\n }\r\n\r\n return texture;\r\n } catch (error) {\r\n // A layer upload can throw (out-of-range layer, missing engine extension, backend upload\r\n // failure). Dispose the freshly allocated GPU texture so it does not leak, then rethrow.\r\n texture.dispose();\r\n throw error;\r\n }\r\n } finally {\r\n for (let index = 0; index < bitmaps.length; index++) {\r\n bitmaps[index].close();\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -5,6 +5,7 @@ import { Texture } from "../../Materials/Textures/texture.pure.js";
|
|
|
5
5
|
import { PostProcessManager } from "../../PostProcesses/postProcessManager.js";
|
|
6
6
|
|
|
7
7
|
import { FloorPOT, NearestPOT } from "../../Misc/tools.functions.js";
|
|
8
|
+
import { RegisterAbstractEngineTexture } from "../../Engines/AbstractEngine/abstractEngine.texture.pure.js";
|
|
8
9
|
import { Logger } from "../../Misc/logger.js";
|
|
9
10
|
import { ObjectRenderer } from "../../Rendering/objectRenderer.js";
|
|
10
11
|
import { Effect } from "../effect.pure.js";
|
|
@@ -999,6 +1000,12 @@ export function RegisterRenderTargetTexture() {
|
|
|
999
1000
|
return;
|
|
1000
1001
|
}
|
|
1001
1002
|
_Registered = true;
|
|
1003
|
+
// Depth-stencil render targets (shadow maps, RTT depth, etc.) call
|
|
1004
|
+
// AbstractEngine.createDepthStencilTexture, which is only installed by the
|
|
1005
|
+
// abstractEngine.texture registration. This module imports the pure engine
|
|
1006
|
+
// (side-effect free), so pull the registration in here to guarantee the method
|
|
1007
|
+
// exists whenever a render target texture is used.
|
|
1008
|
+
RegisterAbstractEngineTexture();
|
|
1002
1009
|
/**
|
|
1003
1010
|
* Sets a depth stencil texture from a render target on the engine to be used in the shader.
|
|
1004
1011
|
* @param channel Name of the sampler variable.
|