@onerjs/core 9.0.1 → 9.0.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/animationGroup.pure.js.map +1 -1
- package/Buffers/buffer.pure.js +4 -0
- package/Buffers/buffer.pure.js.map +1 -1
- package/Cameras/camera.pure.d.ts +14 -0
- package/Cameras/camera.pure.js +15 -0
- package/Cameras/camera.pure.js.map +1 -1
- package/Compute/computeShader.pure.d.ts +2 -1
- package/Compute/computeShader.pure.js +29 -10
- package/Compute/computeShader.pure.js.map +1 -1
- package/Culling/ray.core.js +22 -9
- package/Culling/ray.core.js.map +1 -1
- package/Engines/IDrawContext.d.ts +2 -0
- package/Engines/IDrawContext.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +55 -4
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +1 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +5 -1
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/Processors/shaderCodeInliner.d.ts +2 -0
- package/Engines/Processors/shaderCodeInliner.js +251 -6
- package/Engines/Processors/shaderCodeInliner.js.map +1 -1
- package/Engines/Processors/shaderProcessor.js +10 -1
- package/Engines/Processors/shaderProcessor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js +12 -0
- package/Engines/WebGPU/Extensions/engine.debugging.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js +0 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.pure.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.query.pure.js +5 -0
- package/Engines/WebGPU/Extensions/engine.query.pure.js.map +1 -1
- package/Engines/WebGPU/webgpuBufferManager.js +7 -0
- package/Engines/WebGPU/webgpuBufferManager.js.map +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.d.ts +1 -1
- package/Engines/WebGPU/webgpuCacheTextureView.js +20 -8
- package/Engines/WebGPU/webgpuCacheTextureView.js.map +1 -1
- package/Engines/WebGPU/webgpuDrawContext.d.ts +2 -0
- package/Engines/WebGPU/webgpuDrawContext.js +6 -0
- package/Engines/WebGPU/webgpuDrawContext.js.map +1 -1
- package/Engines/WebGPU/webgpuQuerySet.d.ts +3 -3
- package/Engines/WebGPU/webgpuQuerySet.js +23 -9
- package/Engines/WebGPU/webgpuQuerySet.js.map +1 -1
- package/Engines/WebGPU/webgpuRenderPassCommandStream.d.ts +156 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js +323 -0
- package/Engines/WebGPU/webgpuRenderPassCommandStream.js.map +1 -0
- package/Engines/WebGPU/webgpuTextureManager.d.ts +1 -1
- package/Engines/WebGPU/webgpuTextureManager.js +4 -3
- package/Engines/WebGPU/webgpuTextureManager.js.map +1 -1
- package/Engines/WebGPU/webgpuTimestampQuery.d.ts +3 -1
- package/Engines/WebGPU/webgpuTimestampQuery.js +9 -6
- package/Engines/WebGPU/webgpuTimestampQuery.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +2 -0
- package/Engines/abstractEngine.pure.js +14 -5
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/constants.d.ts +6 -0
- package/Engines/constants.js +6 -0
- package/Engines/constants.js.map +1 -1
- package/Engines/engine.d.ts +198 -24
- package/Engines/pure.d.ts +1 -0
- package/Engines/pure.js +1 -0
- package/Engines/pure.js.map +1 -1
- package/Engines/renderCommandBatcher.pure.d.ts +16 -0
- package/Engines/renderCommandBatcher.pure.js +24 -0
- package/Engines/renderCommandBatcher.pure.js.map +1 -0
- package/Engines/thinEngine.functions.js +3 -2
- package/Engines/thinEngine.functions.js.map +1 -1
- package/Engines/thinEngine.pure.js +18 -2
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +10 -7
- package/Engines/thinNativeEngine.pure.js +117 -46
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/thinWebGPUEngine.d.ts +8 -0
- package/Engines/thinWebGPUEngine.js +11 -0
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +60 -1
- package/Engines/webgpuEngine.pure.js +238 -42
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphGetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Data/Audio/flowGraphIsSoundPlayingBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.d.ts +5 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js +8 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.d.ts +77 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js +141 -0
- package/FlowGraph/Blocks/Event/flowGraphMeshIntersectionEventBlock.pure.js.map +1 -0
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.d.ts +5 -3
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js +38 -7
- package/FlowGraph/Blocks/Event/flowGraphSoundEndedEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/index.d.ts +1 -0
- package/FlowGraph/Blocks/Event/index.js +1 -0
- package/FlowGraph/Blocks/Event/index.js.map +1 -1
- package/FlowGraph/Blocks/Event/pure.d.ts +1 -0
- package/FlowGraph/Blocks/Event/pure.js +1 -0
- package/FlowGraph/Blocks/Event/pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPauseSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlaySoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphSetSoundVolumeBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.d.ts +3 -3
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js +2 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopSoundBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/allBlocks.pure.js +2 -0
- package/FlowGraph/Blocks/allBlocks.pure.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockFactory.js +2 -0
- package/FlowGraph/Blocks/flowGraphBlockFactory.js.map +1 -1
- package/FlowGraph/Blocks/flowGraphBlockNames.d.ts +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js +1 -0
- package/FlowGraph/Blocks/flowGraphBlockNames.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +12 -1
- package/FlowGraph/flowGraph.js +38 -0
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphCoordinator.d.ts +44 -0
- package/FlowGraph/flowGraphCoordinator.js +141 -0
- package/FlowGraph/flowGraphCoordinator.js.map +1 -1
- package/FlowGraph/flowGraphDataConnection.pure.js +41 -14
- package/FlowGraph/flowGraphDataConnection.pure.js.map +1 -1
- package/FlowGraph/flowGraphParser.js +105 -5
- package/FlowGraph/flowGraphParser.js.map +1 -1
- package/FlowGraph/flowGraphSoundAssets.d.ts +40 -0
- package/FlowGraph/flowGraphSoundAssets.js +33 -0
- package/FlowGraph/flowGraphSoundAssets.js.map +1 -0
- package/FlowGraph/index.d.ts +1 -0
- package/FlowGraph/index.js +1 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/pure.d.ts +1 -0
- package/FlowGraph/pure.js +1 -0
- package/FlowGraph/pure.js.map +1 -1
- package/FlowGraph/serialization.d.ts +8 -0
- package/FlowGraph/serialization.js +31 -12
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +25 -0
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/FrameGraph/Tasks/PostProcesses/taaTask.js +2 -0
- package/FrameGraph/Tasks/PostProcesses/taaTask.js.map +1 -1
- package/Instrumentation/engineInstrumentation.d.ts +1 -0
- package/Instrumentation/engineInstrumentation.js +25 -6
- package/Instrumentation/engineInstrumentation.js.map +1 -1
- package/Lights/Clustered/clusteredLightContainer.pure.js +2 -0
- package/Lights/Clustered/clusteredLightContainer.pure.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.d.ts +36 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.js +202 -27
- package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
- package/Lights/directionalLight.pure.d.ts +24 -10
- package/Lights/directionalLight.pure.js +29 -11
- package/Lights/directionalLight.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +4 -4
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/Input/inputBlock.pure.js +4 -0
- package/Materials/Node/Blocks/Input/inputBlock.pure.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.d.ts +9 -0
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js +23 -3
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.pure.js.map +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js +1 -1
- package/Materials/PBR/openpbrMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.pure.d.ts +9 -0
- package/Materials/PBR/pbrBaseMaterial.pure.js +60 -1
- package/Materials/PBR/pbrBaseMaterial.pure.js.map +1 -1
- package/Materials/PBR/pbrBaseSimpleMaterial.d.ts +11 -0
- package/Materials/PBR/pbrBaseSimpleMaterial.js +21 -2
- package/Materials/PBR/pbrBaseSimpleMaterial.js.map +1 -1
- package/Materials/PBR/pbrMaterial.pure.d.ts +12 -0
- package/Materials/PBR/pbrMaterial.pure.js +23 -3
- package/Materials/PBR/pbrMaterial.pure.js.map +1 -1
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.d.ts +1 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js +10 -0
- package/Materials/Textures/Filtering/hdrIrradianceFiltering.js.map +1 -1
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.d.ts +5 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js +7 -0
- package/Materials/Textures/HTML/htmlInCanvasPolyfill.js.map +1 -1
- package/Materials/Textures/HTML/htmlInteractionManager.d.ts +9 -3
- package/Materials/Textures/HTML/htmlInteractionManager.js +64 -5
- package/Materials/Textures/HTML/htmlInteractionManager.js.map +1 -1
- package/Materials/Textures/HTML/htmlTexture.d.ts +11 -11
- package/Materials/Textures/HTML/htmlTexture.js +106 -65
- package/Materials/Textures/HTML/htmlTexture.js.map +1 -1
- package/Materials/Textures/Loaders/internalTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/internalTextureLoader.js.map +1 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.d.ts +2 -1
- package/Materials/Textures/Loaders/ktxTextureLoader.js +4 -50
- package/Materials/Textures/Loaders/ktxTextureLoader.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +10 -0
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/dynamicTexture.pure.js +6 -0
- package/Materials/Textures/dynamicTexture.pure.js.map +1 -1
- package/Materials/Textures/ktx2encoderTypes.d.ts +51 -0
- package/Materials/Textures/ktx2encoderTypes.js +2 -0
- package/Materials/Textures/ktx2encoderTypes.js.map +1 -0
- package/Materials/Textures/renderTargetTexture.pure.js +10 -2
- package/Materials/Textures/renderTargetTexture.pure.js.map +1 -1
- package/Materials/Textures/texture.pure.js +7 -1
- package/Materials/Textures/texture.pure.js.map +1 -1
- package/Materials/Textures/textureMerger.d.ts +11 -0
- package/Materials/Textures/textureMerger.js +34 -19
- package/Materials/Textures/textureMerger.js.map +1 -1
- package/Materials/Textures/textureProcessor.d.ts +145 -0
- package/Materials/Textures/textureProcessor.js +445 -45
- package/Materials/Textures/textureProcessor.js.map +1 -1
- package/Materials/Textures/textureSampling.functions.d.ts +41 -0
- package/Materials/Textures/textureSampling.functions.js +82 -0
- package/Materials/Textures/textureSampling.functions.js.map +1 -0
- package/Materials/drawWrapper.d.ts +8 -0
- package/Materials/drawWrapper.js +19 -0
- package/Materials/drawWrapper.js.map +1 -1
- package/Materials/effect.pure.d.ts +6 -0
- package/Materials/effect.pure.js +28 -6
- package/Materials/effect.pure.js.map +1 -1
- package/Materials/effect.webgl.functions.pure.js +1 -1
- package/Materials/effect.webgl.functions.pure.js.map +1 -1
- package/Materials/material.pure.d.ts +5 -0
- package/Materials/material.pure.js +9 -2
- package/Materials/material.pure.js.map +1 -1
- package/Materials/materialFlags.d.ts +6 -0
- package/Materials/materialFlags.js +14 -0
- package/Materials/materialFlags.js.map +1 -1
- package/Materials/materialHelper.functions.d.ts +2 -1
- package/Materials/materialHelper.functions.js +36 -2
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.js +19 -16
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/materialPluginManager.pure.js +12 -8
- package/Materials/materialPluginManager.pure.js.map +1 -1
- package/Materials/prePassConfiguration.js +19 -16
- package/Materials/prePassConfiguration.js.map +1 -1
- package/Materials/shaderMaterial.pure.js +19 -6
- package/Materials/shaderMaterial.pure.js.map +1 -1
- package/Materials/shadowDepthWrapper.d.ts +6 -0
- package/Materials/shadowDepthWrapper.js +17 -0
- package/Materials/shadowDepthWrapper.js.map +1 -1
- package/Meshes/Compression/dracoCodec.d.ts +14 -0
- package/Meshes/Compression/dracoCodec.js +22 -0
- package/Meshes/Compression/dracoCodec.js.map +1 -1
- package/Meshes/Compression/dracoDecoder.d.ts +1 -0
- package/Meshes/Compression/dracoDecoder.js +27 -0
- package/Meshes/Compression/dracoDecoder.js.map +1 -1
- package/Meshes/Compression/dracoEncoder.d.ts +1 -0
- package/Meshes/Compression/dracoEncoder.js +8 -0
- package/Meshes/Compression/dracoEncoder.js.map +1 -1
- package/Meshes/Compression/meshoptCompression.d.ts +1 -0
- package/Meshes/Compression/meshoptCompression.js +9 -0
- package/Meshes/Compression/meshoptCompression.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.d.ts +415 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js +912 -0
- package/Meshes/GaussianSplatting/gaussianSplattingGpuSorter.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +3 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +40 -9
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +112 -8
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +696 -74
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.js +12 -4
- package/Meshes/abstractMesh.pure.js.map +1 -1
- package/Meshes/geometry.d.ts +5 -0
- package/Meshes/geometry.js +25 -0
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/index.d.ts +1 -0
- package/Meshes/index.js +1 -0
- package/Meshes/index.js.map +1 -1
- package/Meshes/mesh.pure.d.ts +7 -0
- package/Meshes/mesh.pure.js +18 -13
- package/Meshes/mesh.pure.js.map +1 -1
- package/Meshes/pure.d.ts +1 -0
- package/Meshes/pure.js +1 -0
- package/Meshes/pure.js.map +1 -1
- package/Meshes/subMesh.pure.d.ts +3 -0
- package/Meshes/subMesh.pure.js +26 -0
- package/Meshes/subMesh.pure.js.map +1 -1
- package/Meshes/thinInstanceMesh.pure.js +5 -3
- package/Meshes/thinInstanceMesh.pure.js.map +1 -1
- package/Misc/index.d.ts +1 -0
- package/Misc/index.js +1 -0
- package/Misc/index.js.map +1 -1
- package/Misc/khronosTextureContainer2.d.ts +3 -2
- package/Misc/khronosTextureContainer2.js +24 -6
- package/Misc/khronosTextureContainer2.js.map +1 -1
- package/Misc/khronosTextureContainer2Encoder.d.ts +166 -0
- package/Misc/khronosTextureContainer2Encoder.js +556 -0
- package/Misc/khronosTextureContainer2Encoder.js.map +1 -0
- package/Misc/khronosTextureContainer2EncoderWorker.d.ts +61 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js +55 -0
- package/Misc/khronosTextureContainer2EncoderWorker.js.map +1 -0
- package/Misc/pure.d.ts +1 -0
- package/Misc/pure.js +1 -0
- package/Misc/pure.js.map +1 -1
- package/Misc/textureFormat.functions.d.ts +6 -0
- package/Misc/textureFormat.functions.js +54 -0
- package/Misc/textureFormat.functions.js.map +1 -0
- package/Misc/textureTools.d.ts +6 -2
- package/Misc/textureTools.js +100 -42
- package/Misc/textureTools.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.d.ts +1 -1
- package/Particles/Node/Blocks/systemBlock.pure.js +6 -3
- package/Particles/Node/Blocks/systemBlock.pure.js.map +1 -1
- package/Particles/computeShaderParticleSystem.pure.js +5 -0
- package/Particles/computeShaderParticleSystem.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +2 -0
- package/Particles/gpuParticleSystem.pure.js +25 -1
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Particles/solidParticle.d.ts +5 -0
- package/Particles/solidParticle.js +5 -0
- package/Particles/solidParticle.js.map +1 -1
- package/Particles/solidParticleSystem.d.ts +10 -0
- package/Particles/solidParticleSystem.js +72 -13
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.pure.js +4 -0
- package/Particles/thinParticleSystem.pure.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.d.ts +27 -6
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js +60 -5
- package/PostProcesses/RenderPipeline/Pipelines/taaMaterialManager.pure.js.map +1 -1
- package/PostProcesses/thinTAAPostProcess.d.ts +1 -0
- package/PostProcesses/thinTAAPostProcess.js +17 -1
- package/PostProcesses/thinTAAPostProcess.js.map +1 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.d.ts +2 -1
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js +6 -5
- package/PostProcesses/volumetricLightScatteringPostProcess.pure.js.map +1 -1
- package/Rendering/boundingBoxRenderer.pure.js +2 -3
- package/Rendering/boundingBoxRenderer.pure.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.js +8 -2
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/objectRenderer.d.ts +1 -0
- package/Rendering/objectRenderer.js +14 -0
- package/Rendering/objectRenderer.js.map +1 -1
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/Shaders/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js +1 -1
- package/Shaders/ShadersInclude/bumpVertex.js.map +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/Shaders/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js +5 -1
- package/Shaders/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/helperFunctions.js +2 -2
- package/Shaders/ShadersInclude/helperFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/Shaders/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js +6 -0
- package/Shaders/ShadersInclude/openpbrVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/Shaders/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/Shaders/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/Shaders/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js +7 -1
- package/Shaders/ShadersInclude/pbrFragmentDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrIBLFunctions.js +12 -0
- package/Shaders/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/geometry.vertex.js +6 -6
- package/Shaders/geometry.vertex.js.map +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js +1 -1
- package/Shaders/gpuUpdateParticles.vertex.js.map +1 -1
- package/Shaders/lod.fragment.js +15 -2
- package/Shaders/lod.fragment.js.map +1 -1
- package/Shaders/lod3D.fragment.js +15 -2
- package/Shaders/lod3D.fragment.js.map +1 -1
- package/Shaders/lodCube.fragment.js +15 -2
- package/Shaders/lodCube.fragment.js.map +1 -1
- package/Shaders/openpbr.vertex.js +2 -0
- package/Shaders/openpbr.vertex.js.map +1 -1
- package/Shaders/pbr.fragment.js +12 -1
- package/Shaders/pbr.fragment.js.map +1 -1
- package/Shaders/pbr.vertex.js +2 -0
- package/Shaders/pbr.vertex.js.map +1 -1
- package/Shaders/textureMerger.fragment.js +28 -0
- package/Shaders/textureMerger.fragment.js.map +1 -1
- package/Shaders/textureProcessor.fragment.js +26 -4
- package/Shaders/textureProcessor.fragment.js.map +1 -1
- package/Shaders/volumetricLightScattering.fragment.js +1 -1
- package/Shaders/volumetricLightScattering.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/bumpFragmentMainFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/bumpVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/hdrFilteringFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/helperFunctions.js +2 -2
- package/ShadersWGSL/ShadersInclude/helperFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +44 -2
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js +17 -3
- package/ShadersWGSL/ShadersInclude/lightUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js +12 -1
- package/ShadersWGSL/ShadersInclude/lightVxUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js +1 -1
- package/ShadersWGSL/ShadersInclude/openpbrBackgroundTransmission.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js +11 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockFinalLitComponents.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js +9 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockNormalFinal.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockReflectance.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrClusteredLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingSetupFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js +1 -0
- package/ShadersWGSL/ShadersInclude/pbrFragmentSamplersDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js +8 -0
- package/ShadersWGSL/ShadersInclude/pbrIBLFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertex.js +2 -2
- package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js +3 -1
- package/ShadersWGSL/ShadersInclude/sceneUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js +16 -0
- package/ShadersWGSL/ShadersInclude/shadowsVertex.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +4 -4
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/default.vertex.js +1 -1
- package/ShadersWGSL/default.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js +3 -3
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js +1 -1
- package/ShadersWGSL/gpuUpdateParticles.compute.js.map +1 -1
- package/ShadersWGSL/gsSortCount.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortCount.compute.js +19 -0
- package/ShadersWGSL/gsSortCount.compute.js.map +1 -0
- package/ShadersWGSL/gsSortKeys.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortKeys.compute.js +49 -0
- package/ShadersWGSL/gsSortKeys.compute.js.map +1 -0
- package/ShadersWGSL/gsSortOutput.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortOutput.compute.js +28 -0
- package/ShadersWGSL/gsSortOutput.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanLocal.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js +23 -0
- package/ShadersWGSL/gsSortScanLocal.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScanSums.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScanSums.compute.js +19 -0
- package/ShadersWGSL/gsSortScanSums.compute.js.map +1 -0
- package/ShadersWGSL/gsSortScatter.compute.d.ts +5 -0
- package/ShadersWGSL/gsSortScatter.compute.js +33 -0
- package/ShadersWGSL/gsSortScatter.compute.js.map +1 -0
- package/ShadersWGSL/lod.fragment.js +14 -2
- package/ShadersWGSL/lod.fragment.js.map +1 -1
- package/ShadersWGSL/lod3D.fragment.js +14 -2
- package/ShadersWGSL/lod3D.fragment.js.map +1 -1
- package/ShadersWGSL/lodCube.fragment.js +14 -2
- package/ShadersWGSL/lodCube.fragment.js.map +1 -1
- package/ShadersWGSL/openpbr.vertex.js +3 -1
- package/ShadersWGSL/openpbr.vertex.js.map +1 -1
- package/ShadersWGSL/pbr.fragment.js +11 -0
- package/ShadersWGSL/pbr.fragment.js.map +1 -1
- package/ShadersWGSL/pbr.vertex.js +3 -1
- package/ShadersWGSL/pbr.vertex.js.map +1 -1
- package/ShadersWGSL/textureMerger.fragment.js +40 -4
- package/ShadersWGSL/textureMerger.fragment.js.map +1 -1
- package/ShadersWGSL/textureProcessor.fragment.js +26 -4
- package/ShadersWGSL/textureProcessor.fragment.js.map +1 -1
- package/Sprites/spriteRenderer.js +15 -5
- package/Sprites/spriteRenderer.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +23 -1
- package/scene.pure.js +83 -1
- package/scene.pure.js.map +1 -1
|
@@ -6,6 +6,7 @@ import { Observable } from "../../../Misc/observable.pure.js";
|
|
|
6
6
|
import { Logger } from "../../../Misc/logger.js";
|
|
7
7
|
import { IsWindowObjectExist } from "../../../Misc/domManagement.js";
|
|
8
8
|
import { RegisterEnginesExtensionsEngineDynamicTexture } from "../../../Engines/Extensions/engine.dynamicTexture.pure.js";
|
|
9
|
+
import { _IsHtmlInCanvasPolyfillInstalled } from "./htmlInCanvasPolyfill.js";
|
|
9
10
|
let _HasWarnedAboutMissingApi = false;
|
|
10
11
|
function _WarnMissingApi(apiName) {
|
|
11
12
|
if (_HasWarnedAboutMissingApi) {
|
|
@@ -29,7 +30,7 @@ function _WarnUploadFailure(error) {
|
|
|
29
30
|
}
|
|
30
31
|
_HasWarnedAboutUploadFailure = true;
|
|
31
32
|
const message = error instanceof Error ? error.message : String(error);
|
|
32
|
-
Logger.Warn(`HTML-in-Canvas: the native upload failed (${message}). The element must be
|
|
33
|
+
Logger.Warn(`HTML-in-Canvas: the native upload failed (${message}). The element must be drawable inside the engine's rendering canvas with content="drawable" (or layoutsubtree on older implementations), and the first upload must wait for a paint event.`);
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Detects whether the engine can upload an HTML element through the native (or polyfilled) WICG
|
|
@@ -40,10 +41,10 @@ function _WarnUploadFailure(error) {
|
|
|
40
41
|
export function IsHtmlInCanvasUploadSupported(engine) {
|
|
41
42
|
if (engine.isWebGPU) {
|
|
42
43
|
const queue = engine._device?.queue;
|
|
43
|
-
return !!queue && typeof queue.copyElementImageToTexture === "function";
|
|
44
|
+
return !!queue && (typeof queue.drawElementImageToTexture === "function" || typeof queue.copyElementImageToTexture === "function");
|
|
44
45
|
}
|
|
45
46
|
const gl = engine._gl;
|
|
46
|
-
return !!gl && typeof gl.texElementImage2D === "function";
|
|
47
|
+
return !!gl && (typeof gl.texElementSubImage2D === "function" || typeof gl.texElementImage2D === "function");
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Uploads a live HTML element (or a captured ElementImage) into an existing 2D texture using the WICG
|
|
@@ -51,9 +52,9 @@ export function IsHtmlInCanvasUploadSupported(engine) {
|
|
|
51
52
|
*
|
|
52
53
|
* This is a side-effect-free helper - it is only reachable when {@link HtmlTexture} (or a direct caller)
|
|
53
54
|
* is imported, so it adds nothing to bundles that do not use it. It relies on
|
|
54
|
-
* `WebGLRenderingContext.
|
|
55
|
-
*
|
|
56
|
-
* three-html-render polyfill.
|
|
55
|
+
* `WebGLRenderingContext.texElementSubImage2D` (WebGL) or `GPUQueue.drawElementImageToTexture` (WebGPU),
|
|
56
|
+
* with support for their older `texElementImage2D` / `copyElementImageToTexture` counterparts, including
|
|
57
|
+
* the three-html-render polyfill.
|
|
57
58
|
* @param engine defines the engine that owns the texture
|
|
58
59
|
* @param texture defines the internal texture to update
|
|
59
60
|
* @param element defines the source HTML element (or captured ElementImage) to upload
|
|
@@ -70,13 +71,9 @@ export function UploadHtmlElementToTexture(engine, texture, element, invertY = t
|
|
|
70
71
|
}
|
|
71
72
|
return _UploadHtmlElementToWebGLTexture(engine, texture, element, invertY, config);
|
|
72
73
|
}
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
// three-html-render polyfill) still ship the legacy texImage2D-shaped overload
|
|
77
|
-
// texElementImage2D(target, level, internalformat, format, type, element). We prefer the new form and
|
|
78
|
-
// fall back to the legacy one when the implementation rejects it for the wrong number of arguments. The
|
|
79
|
-
// detected shape is cached so we only pay the failed call once.
|
|
74
|
+
// Before texElementSubImage2D, the proposal used two incompatible texElementImage2D signatures.
|
|
75
|
+
// Prefer the shorter form and fall back to the texImage2D-shaped overload used by older Chrome builds
|
|
76
|
+
// and three-html-render when the implementation rejects the argument count.
|
|
80
77
|
let _UseLegacyTexElementImage2D = false;
|
|
81
78
|
function _CallTexElementImage2D(gl, internalFormat, element, config) {
|
|
82
79
|
if (!_UseLegacyTexElementImage2D) {
|
|
@@ -99,45 +96,55 @@ function _CallTexElementImage2D(gl, internalFormat, element, config) {
|
|
|
99
96
|
gl.texElementImage2D(gl.TEXTURE_2D, 0, internalFormat, gl.RGBA, gl.UNSIGNED_BYTE, element);
|
|
100
97
|
}
|
|
101
98
|
function _UploadHtmlElementToWebGLTexture(engine, texture, element, invertY, config) {
|
|
102
|
-
// texElementImage2D is provided either natively (behind a flag) or by the three-html-render polyfill.
|
|
103
99
|
// Engines without a WebGL context (e.g. NullEngine) have no _gl and are handled by this guard.
|
|
104
100
|
const gl = engine._gl;
|
|
105
|
-
if (!gl || typeof gl.texElementImage2D !== "function") {
|
|
106
|
-
_WarnMissingApi("texElementImage2D");
|
|
101
|
+
if (!gl || (typeof gl.texElementSubImage2D !== "function" && typeof gl.texElementImage2D !== "function")) {
|
|
102
|
+
_WarnMissingApi("texElementSubImage2D / texElementImage2D");
|
|
107
103
|
return false;
|
|
108
104
|
}
|
|
109
105
|
// texElementImage2D requires a *sized* internal format (RGBA8, SRGB8_ALPHA8, RGBA16F or RGBA32F);
|
|
110
106
|
// the unsized gl.RGBA returned by _getInternalFormat is rejected.
|
|
111
|
-
const
|
|
107
|
+
const type = texture.type === -1 ? 0 : texture.type;
|
|
108
|
+
const internalFormat = engine._getRGBABufferInternalSizedFormat(type, texture.format, texture._useSRGBBuffer);
|
|
112
109
|
const wasPreviouslyBound = engine._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
|
|
113
110
|
engine._unpackFlipY(invertY);
|
|
114
111
|
try {
|
|
115
|
-
|
|
112
|
+
if (typeof gl.texElementSubImage2D === "function" && !(_IsHtmlInCanvasPolyfillInstalled() && typeof gl.texElementImage2D === "function")) {
|
|
113
|
+
// Unlike texElementImage2D, the current API updates existing storage rather than defining it.
|
|
114
|
+
if (!texture.isReady) {
|
|
115
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, texture.width, texture.height, 0, engine._getInternalFormat(texture.format), engine._getWebGLTextureType(type), null);
|
|
116
|
+
}
|
|
117
|
+
gl.texElementSubImage2D(gl.TEXTURE_2D, 0, 0, 0, element, config ?? { width: texture.width, height: texture.height });
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
_CallTexElementImage2D(gl, internalFormat, element, config);
|
|
121
|
+
}
|
|
116
122
|
if (texture.generateMipMaps) {
|
|
117
123
|
gl.generateMipmap(gl.TEXTURE_2D);
|
|
118
124
|
}
|
|
119
|
-
if (!wasPreviouslyBound) {
|
|
120
|
-
engine._bindTextureDirectly(gl.TEXTURE_2D, null);
|
|
121
|
-
}
|
|
122
125
|
texture.invertY = invertY;
|
|
123
126
|
texture.isReady = true;
|
|
124
127
|
return true;
|
|
125
128
|
}
|
|
126
129
|
catch (error) {
|
|
127
130
|
// Reaching here means the snapshot upload failed - usually a real misconfiguration (the element is
|
|
128
|
-
// not
|
|
131
|
+
// not drawable in the rendering canvas), though a stray call before
|
|
129
132
|
// the first paint snapshot can also throw. Either way we must NOT disable the texture, so a later
|
|
130
133
|
// paint-driven update can still succeed; we surface a one-time diagnostic to help debugging.
|
|
131
134
|
_WarnUploadFailure(error);
|
|
132
135
|
return false;
|
|
133
136
|
}
|
|
137
|
+
finally {
|
|
138
|
+
if (!wasPreviouslyBound) {
|
|
139
|
+
engine._bindTextureDirectly(gl.TEXTURE_2D, null);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
134
142
|
}
|
|
135
143
|
function _UploadHtmlElementToWebGPUTexture(engine, texture, element, invertY, config) {
|
|
136
|
-
// copyElementImageToTexture is provided either natively (behind a flag) or by the three-html-render polyfill.
|
|
137
144
|
const device = engine._device;
|
|
138
145
|
const queue = device && device.queue;
|
|
139
|
-
if (!device || !queue || typeof queue.copyElementImageToTexture !== "function") {
|
|
140
|
-
_WarnMissingApi("GPUQueue.copyElementImageToTexture");
|
|
146
|
+
if (!device || !queue || (typeof queue.drawElementImageToTexture !== "function" && typeof queue.copyElementImageToTexture !== "function")) {
|
|
147
|
+
_WarnMissingApi("GPUQueue.drawElementImageToTexture / GPUQueue.copyElementImageToTexture");
|
|
141
148
|
return false;
|
|
142
149
|
}
|
|
143
150
|
const gpuTexture = texture._hardwareTexture?.underlyingResource;
|
|
@@ -145,22 +152,40 @@ function _UploadHtmlElementToWebGPUTexture(engine, texture, element, invertY, co
|
|
|
145
152
|
return false;
|
|
146
153
|
}
|
|
147
154
|
try {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
source
|
|
153
|
-
|
|
155
|
+
if (_IsHtmlInCanvasPolyfillInstalled() && typeof queue.copyElementImageToTexture === "function") {
|
|
156
|
+
queue.copyElementImageToTexture(element, config?.width ?? texture.width, config?.height ?? texture.height, { texture: gpuTexture });
|
|
157
|
+
}
|
|
158
|
+
else if (typeof queue.drawElementImageToTexture === "function") {
|
|
159
|
+
const source = { source: element };
|
|
160
|
+
if (config) {
|
|
161
|
+
source.sourceX = config.sx;
|
|
162
|
+
source.sourceY = config.sy;
|
|
163
|
+
source.sourceWidth = config.swidth;
|
|
164
|
+
source.sourceHeight = config.sheight;
|
|
165
|
+
}
|
|
166
|
+
queue.drawElementImageToTexture(source, {
|
|
167
|
+
texture: gpuTexture,
|
|
168
|
+
size: { width: config?.width ?? texture.width, height: config?.height ?? texture.height },
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
const source = { source: element };
|
|
173
|
+
if (config) {
|
|
174
|
+
source.sx = config.sx;
|
|
175
|
+
source.sy = config.sy;
|
|
176
|
+
source.swidth = config.swidth;
|
|
177
|
+
source.sheight = config.sheight;
|
|
178
|
+
}
|
|
179
|
+
queue.copyElementImageToTexture(source, {
|
|
180
|
+
destination: { texture: gpuTexture },
|
|
181
|
+
width: config?.width ?? texture.width,
|
|
182
|
+
height: config?.height ?? texture.height,
|
|
183
|
+
});
|
|
154
184
|
}
|
|
155
|
-
queue.copyElementImageToTexture(source, {
|
|
156
|
-
destination: { texture: gpuTexture },
|
|
157
|
-
width: config?.width ?? texture.width,
|
|
158
|
-
height: config?.height ?? texture.height,
|
|
159
|
-
});
|
|
160
185
|
if (texture.generateMipMaps) {
|
|
161
186
|
engine._generateMipmaps(texture);
|
|
162
187
|
}
|
|
163
|
-
// The WICG
|
|
188
|
+
// The WICG element upload APIs have no flipY option; the destination orientation is
|
|
164
189
|
// determined by the source. We record the requested value for downstream sampling conventions.
|
|
165
190
|
texture.invertY = invertY;
|
|
166
191
|
texture.isReady = true;
|
|
@@ -168,7 +193,7 @@ function _UploadHtmlElementToWebGPUTexture(engine, texture, element, invertY, co
|
|
|
168
193
|
}
|
|
169
194
|
catch (error) {
|
|
170
195
|
// Reaching here means the snapshot upload failed - usually a real misconfiguration (the element is
|
|
171
|
-
// not
|
|
196
|
+
// not drawable in the rendering canvas), though a stray call before
|
|
172
197
|
// the first paint snapshot can also throw. Either way we must NOT disable the texture, so a later
|
|
173
198
|
// paint-driven update can still succeed; we surface a one-time diagnostic to help debugging.
|
|
174
199
|
_WarnUploadFailure(error);
|
|
@@ -179,11 +204,10 @@ function _UploadHtmlElementToWebGPUTexture(engine, texture, element, invertY, co
|
|
|
179
204
|
* A texture whose content is rendered from a live HTML element using the WICG HTML-in-Canvas API
|
|
180
205
|
* (https://github.com/WICG/html-in-canvas).
|
|
181
206
|
*
|
|
182
|
-
* The element is hosted as a child of the engine's rendering canvas (
|
|
183
|
-
* the browser can lay it out and snapshot it
|
|
184
|
-
*
|
|
185
|
-
* `
|
|
186
|
-
* available either natively (behind chrome://flags/#canvas-draw-element) or via the three-html-render
|
|
207
|
+
* The element is hosted as a drawable child of the engine's rendering canvas (marked `content="drawable"`,
|
|
208
|
+
* or `layoutsubtree` on older implementations) so the browser can lay it out and snapshot it.
|
|
209
|
+
* Content is uploaded through `WebGLRenderingContext.texElementSubImage2D` (WebGL) or
|
|
210
|
+
* `GPUQueue.drawElementImageToTexture` (WebGPU), with support for older browsers and the three-html-render
|
|
187
211
|
* polyfill (https://github.com/repalash/three-html-render). When neither is present, a built-in SVG
|
|
188
212
|
* `<foreignObject>` fallback is used instead (see `useSvgFallback`).
|
|
189
213
|
*
|
|
@@ -208,6 +232,8 @@ export class HtmlTexture extends BaseTexture {
|
|
|
208
232
|
this._originalParent = null;
|
|
209
233
|
this._originalNextSibling = null;
|
|
210
234
|
this._addedInert = false;
|
|
235
|
+
this._addedDrawable = false;
|
|
236
|
+
this._updateRequested = false;
|
|
211
237
|
this.element = element;
|
|
212
238
|
this._textureMatrix = Matrix.Identity();
|
|
213
239
|
if (!element || (!options.engine && !options.scene)) {
|
|
@@ -232,23 +258,23 @@ export class HtmlTexture extends BaseTexture {
|
|
|
232
258
|
this.wrapV = 0;
|
|
233
259
|
this.anisotropicFilteringLevel = 1;
|
|
234
260
|
this.host = this._createHost();
|
|
235
|
-
//
|
|
236
|
-
//
|
|
237
|
-
// first one and, when auto-update is disabled, detach after that first refresh. A non-canvas helper
|
|
238
|
-
// host never emits `paint`, so this listener is simply never invoked there.
|
|
261
|
+
// Native uploads need an initial paint snapshot. Keep the listener for explicit requests even when
|
|
262
|
+
// auto-update is disabled; helper div hosts never emit paint.
|
|
239
263
|
if (this.host) {
|
|
264
|
+
let hasPainted = false;
|
|
240
265
|
this._paintHandler = (event) => {
|
|
241
266
|
// A single `paint` event covers every changed child of the shared rendering canvas. When the
|
|
242
267
|
// browser reports which elements changed, skip the upload unless ours is among them, so that
|
|
243
268
|
// multiple HTML textures hosted on the same canvas don't all re-upload on every unrelated change.
|
|
244
|
-
if (
|
|
269
|
+
if (!autoUpdate && !this._updateRequested && hasPainted) {
|
|
245
270
|
return;
|
|
246
271
|
}
|
|
247
|
-
this.
|
|
248
|
-
|
|
249
|
-
this.host.removeEventListener("paint", this._paintHandler);
|
|
250
|
-
this._paintHandler = null;
|
|
272
|
+
if (!this._updateRequested && event.changedElements && !event.changedElements.some((changed) => this.element === changed || this.element.contains(changed))) {
|
|
273
|
+
return;
|
|
251
274
|
}
|
|
275
|
+
this._updateRequested = false;
|
|
276
|
+
hasPainted = true;
|
|
277
|
+
this.update();
|
|
252
278
|
};
|
|
253
279
|
this.host.addEventListener("paint", this._paintHandler);
|
|
254
280
|
}
|
|
@@ -262,15 +288,21 @@ export class HtmlTexture extends BaseTexture {
|
|
|
262
288
|
// into the host (the element must be a direct child of the host to be captured and laid out).
|
|
263
289
|
this._originalParent = this.element.parentNode;
|
|
264
290
|
this._originalNextSibling = this.element.nextSibling;
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
// that canvas: it is the only one whose context can snapshot the element via texElementImage2D /
|
|
269
|
-
// copyElementImageToTexture. A separate canvas would lay the element out but could never be captured
|
|
270
|
-
// into the engine's texture (this is why nothing rendered on the native path before).
|
|
291
|
+
// Older WICG implementations require a direct canvas child; current implementations require a
|
|
292
|
+
// drawable descendant and content="drawable" on the same canvas whose context performs the upload.
|
|
293
|
+
// A separate canvas cannot supply snapshots to the engine's context.
|
|
271
294
|
const renderingCanvas = this._getEngine()?.getRenderingCanvas() ?? null;
|
|
272
295
|
if (renderingCanvas) {
|
|
273
|
-
renderingCanvas.
|
|
296
|
+
if (typeof renderingCanvas.content === "string" && !_IsHtmlInCanvasPolyfillInstalled()) {
|
|
297
|
+
renderingCanvas.content = "drawable";
|
|
298
|
+
this._addedDrawable = !this.element.hasAttribute("drawable");
|
|
299
|
+
if (this._addedDrawable) {
|
|
300
|
+
this.element.setAttribute("drawable", "");
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
renderingCanvas.layoutSubtree = true;
|
|
305
|
+
}
|
|
274
306
|
// `layoutsubtree` opts children into hit testing; mark ours inert so it never steals pointer events
|
|
275
307
|
// from the canvas (e.g. camera controls). Synthetic event dispatch still reaches inert elements, so
|
|
276
308
|
// HtmlRaycastInteractionManager keeps working; HtmlInteractionManager clears it to enable native input.
|
|
@@ -316,15 +348,16 @@ export class HtmlTexture extends BaseTexture {
|
|
|
316
348
|
return this._textureMatrix;
|
|
317
349
|
}
|
|
318
350
|
/**
|
|
319
|
-
* Requests
|
|
320
|
-
*
|
|
321
|
-
* when the WICG API is not available.
|
|
351
|
+
* Requests a texture refresh in sync with the host canvas's next paint event, even when auto-update is
|
|
352
|
+
* disabled. Updates immediately when the engine's WICG upload API is not available.
|
|
322
353
|
*/
|
|
323
354
|
requestUpdate() {
|
|
324
|
-
//
|
|
325
|
-
//
|
|
355
|
+
// A browser can expose requestPaint without an upload API supported by this engine. In that case
|
|
356
|
+
// do not wait for native paint: update() must still reach the SVG fallback or the missing-API warning.
|
|
357
|
+
const engine = this._getEngine();
|
|
326
358
|
const canvasHost = this.host;
|
|
327
|
-
if (canvasHost && typeof canvasHost.requestPaint === "function") {
|
|
359
|
+
if (engine && IsHtmlInCanvasUploadSupported(engine) && canvasHost && typeof canvasHost.requestPaint === "function") {
|
|
360
|
+
this._updateRequested = true;
|
|
328
361
|
canvasHost.requestPaint();
|
|
329
362
|
}
|
|
330
363
|
else {
|
|
@@ -427,6 +460,14 @@ export class HtmlTexture extends BaseTexture {
|
|
|
427
460
|
this.element.removeAttribute("inert");
|
|
428
461
|
this._addedInert = false;
|
|
429
462
|
}
|
|
463
|
+
if (this._addedDrawable) {
|
|
464
|
+
this.element.removeAttribute("drawable");
|
|
465
|
+
this._addedDrawable = false;
|
|
466
|
+
}
|
|
467
|
+
// The polyfill redirects children into a helper host and tracks removals through this API.
|
|
468
|
+
if (this.element.parentNode === this.host) {
|
|
469
|
+
this.host.removeChild(this.element);
|
|
470
|
+
}
|
|
430
471
|
// Restore the element to where the caller had it before we re-parented it into the host, rather
|
|
431
472
|
// than silently deleting their node from the document.
|
|
432
473
|
if (this._originalParent) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"htmlTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/HTML/htmlTexture.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAG9H,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,6CAA6C,EAAE,MAAM,wDAAwD,CAAC;AASvH,IAAI,yBAAyB,GAAG,KAAK,CAAC;AAEtC,SAAS,eAAe,CAAC,OAAe;IACpC,IAAI,yBAAyB,EAAE,CAAC;QAC5B,OAAO;IACX,CAAC;IACD,yBAAyB,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,IAAI,CACP,mBAAmB,OAAO,iJA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AC;gBACjB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,CAAC;QACL,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;;AAnSuB,2BAAe,GAAyH;IAC5J,eAAe,EAAE,KAAK;IACtB,YAAY,EAAE,SAAS,CAAC,6BAA6B;IACrD,MAAM,EAAE,SAAS,CAAC,kBAAkB;IACpC,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;CACvB,AANsC,CAMrC","sourcesContent":["/** This module has no top-level side effects: the engine extension it depends on is registered lazily from the constructor */\n\nimport { type Nullable } from \"../../../types\";\nimport { BaseTexture } from \"../baseTexture.pure\";\nimport { Constants } from \"../../../Engines/constants\";\nimport { Matrix } from \"../../../Maths/math.vector.pure\";\nimport { Observable } from \"../../../Misc/observable.pure\";\nimport { Logger } from \"../../../Misc/logger\";\nimport { IsWindowObjectExist } from \"../../../Misc/domManagement\";\nimport { RegisterEnginesExtensionsEngineDynamicTexture } from \"../../../Engines/Extensions/engine.dynamicTexture.pure\";\n\nimport { type AbstractEngine } from \"../../../Engines/abstractEngine.pure\";\nimport { type ThinEngine } from \"../../../Engines/thinEngine.pure\";\nimport { type WebGPUEngine } from \"../../../Engines/webgpuEngine.pure\";\nimport { type WebGPUHardwareTexture } from \"../../../Engines/WebGPU/webgpuHardwareTexture\";\nimport { type InternalTexture } from \"../internalTexture\";\nimport { type Scene } from \"../../../scene.pure\";\n\nlet _HasWarnedAboutMissingApi = false;\n\nfunction _WarnMissingApi(apiName: string): void {\n if (_HasWarnedAboutMissingApi) {\n return;\n }\n _HasWarnedAboutMissingApi = true;\n Logger.Warn(\n `HTML-in-Canvas: ${apiName} is not available. Enable chrome://flags/#canvas-draw-element, the built-in SVG fallback, or the three-html-render polyfill to use HtmlTexture.`\n );\n}\n\nlet _HasWarnedAboutSvgFallback = false;\n\nfunction _WarnSvgFallback(): void {\n if (_HasWarnedAboutSvgFallback) {\n return;\n }\n _HasWarnedAboutSvgFallback = true;\n Logger.Warn(\"HTML-in-Canvas: the SVG fallback could not rasterize the element. This usually means it references cross-origin or external resources, which taint the snapshot.\");\n}\n\nlet _HasWarnedAboutUploadFailure = false;\n\nfunction _WarnUploadFailure(error: unknown): void {\n if (_HasWarnedAboutUploadFailure) {\n return;\n }\n _HasWarnedAboutUploadFailure = true;\n const message = error instanceof Error ? error.message : String(error);\n Logger.Warn(\n `HTML-in-Canvas: the native upload failed (${message}). The element must be a direct child of the engine's rendering canvas, which must carry the \\`layoutsubtree\\` attribute, and the upload must run during a paint event.`\n );\n}\n\n/**\n * Detects whether the engine can upload an HTML element through the native (or polyfilled) WICG\n * HTML-in-Canvas API, without emitting any warning. Used to decide whether the SVG fallback is needed.\n * @param engine defines the engine to test\n * @returns true when the WICG upload API is available for this engine\n */\nexport function IsHtmlInCanvasUploadSupported(engine: AbstractEngine): boolean {\n if (engine.isWebGPU) {\n const queue = (engine as WebGPUEngine)._device?.queue;\n return !!queue && typeof queue.copyElementImageToTexture === \"function\";\n }\n\n const gl = (engine as ThinEngine)._gl as Nullable<WebGL2RenderingContext>;\n return !!gl && typeof gl.texElementImage2D === \"function\";\n}\n\n/**\n * Uploads a live HTML element (or a captured ElementImage) into an existing 2D texture using the WICG\n * HTML-in-Canvas API (https://github.com/WICG/html-in-canvas).\n *\n * This is a side-effect-free helper - it is only reachable when {@link HtmlTexture} (or a direct caller)\n * is imported, so it adds nothing to bundles that do not use it. It relies on\n * `WebGLRenderingContext.texElementImage2D` (WebGL) or `GPUQueue.copyElementImageToTexture` (WebGPU),\n * available either natively (behind chrome://flags/#canvas-draw-element) or through the\n * three-html-render polyfill.\n * @param engine defines the engine that owns the texture\n * @param texture defines the internal texture to update\n * @param element defines the source HTML element (or captured ElementImage) to upload\n * @param invertY defines if data must be stored with Y axis inverted (true by default)\n * @param config defines an optional source rectangle and sizing configuration\n * @returns true if the upload succeeded, false otherwise (e.g. the API is unavailable)\n */\nexport function UploadHtmlElementToTexture(\n engine: AbstractEngine,\n texture: Nullable<InternalTexture>,\n element: Element | ElementImage,\n invertY: boolean = true,\n config?: WebGLCopyElementImageConfig\n): boolean {\n if (!texture || texture._isDisabled) {\n return false;\n }\n\n if (engine.isWebGPU) {\n return _UploadHtmlElementToWebGPUTexture(engine as WebGPUEngine, texture, element, invertY, config);\n }\n\n return _UploadHtmlElementToWebGLTexture(engine as ThinEngine, texture, element, invertY, config);\n}\n\n// The texElementImage2D signature was changed mid-flight in the WICG proposal (see\n// https://github.com/WICG/html-in-canvas#idl-changes): the current spec form is\n// texElementImage2D(target, internalformat, element, config?), but older Chrome Canary builds (and the\n// three-html-render polyfill) still ship the legacy texImage2D-shaped overload\n// texElementImage2D(target, level, internalformat, format, type, element). We prefer the new form and\n// fall back to the legacy one when the implementation rejects it for the wrong number of arguments. The\n// detected shape is cached so we only pay the failed call once.\nlet _UseLegacyTexElementImage2D = false;\n\nfunction _CallTexElementImage2D(gl: WebGL2RenderingContext, internalFormat: number, element: Element | ElementImage, config?: WebGLCopyElementImageConfig): void {\n if (!_UseLegacyTexElementImage2D) {\n try {\n gl.texElementImage2D(gl.TEXTURE_2D, internalFormat, element, config);\n return;\n } catch (error) {\n // Only a wrong-arity TypeError means we are talking to the legacy signature; anything else\n // (e.g. the element is not a canvas child) is a genuine upload failure and must propagate.\n // Native rejects the new form with \"N arguments required, but only M present\"; the\n // three-html-render polyfill rejects it with \"unexpected argument count N\".\n if (!(error instanceof TypeError) || !/arguments required|argument count/.test((error as Error).message)) {\n throw error;\n }\n _UseLegacyTexElementImage2D = true;\n }\n }\n\n // Legacy overload: texElementImage2D(target, level, internalformat, format, type, element).\n gl.texElementImage2D(gl.TEXTURE_2D, 0, internalFormat, gl.RGBA, gl.UNSIGNED_BYTE, element);\n}\n\nfunction _UploadHtmlElementToWebGLTexture(\n engine: ThinEngine,\n texture: InternalTexture,\n element: Element | ElementImage,\n invertY: boolean,\n config?: WebGLCopyElementImageConfig\n): boolean {\n // texElementImage2D is provided either natively (behind a flag) or by the three-html-render polyfill.\n // Engines without a WebGL context (e.g. NullEngine) have no _gl and are handled by this guard.\n const gl = engine._gl as Nullable<WebGL2RenderingContext>;\n if (!gl || typeof gl.texElementImage2D !== \"function\") {\n _WarnMissingApi(\"texElementImage2D\");\n return false;\n }\n\n // texElementImage2D requires a *sized* internal format (RGBA8, SRGB8_ALPHA8, RGBA16F or RGBA32F);\n // the unsized gl.RGBA returned by _getInternalFormat is rejected.\n const internalFormat = engine._getRGBABufferInternalSizedFormat(texture.type, texture.format, texture._useSRGBBuffer);\n const wasPreviouslyBound = engine._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\n engine._unpackFlipY(invertY);\n\n try {\n _CallTexElementImage2D(gl, internalFormat, element, config);\n\n if (texture.generateMipMaps) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n\n if (!wasPreviouslyBound) {\n engine._bindTextureDirectly(gl.TEXTURE_2D, null);\n }\n\n texture.invertY = invertY;\n texture.isReady = true;\n return true;\n } catch (error) {\n // Reaching here means the snapshot upload failed - usually a real misconfiguration (the element is\n // not a child of the rendering canvas, or `layoutsubtree` is missing), though a stray call before\n // the first paint snapshot can also throw. Either way we must NOT disable the texture, so a later\n // paint-driven update can still succeed; we surface a one-time diagnostic to help debugging.\n _WarnUploadFailure(error);\n return false;\n }\n}\n\nfunction _UploadHtmlElementToWebGPUTexture(\n engine: WebGPUEngine,\n texture: InternalTexture,\n element: Element | ElementImage,\n invertY: boolean,\n config?: WebGLCopyElementImageConfig\n): boolean {\n // copyElementImageToTexture is provided either natively (behind a flag) or by the three-html-render polyfill.\n const device = engine._device;\n const queue = device && device.queue;\n if (!device || !queue || typeof queue.copyElementImageToTexture !== \"function\") {\n _WarnMissingApi(\"GPUQueue.copyElementImageToTexture\");\n return false;\n }\n\n const gpuTexture = (texture._hardwareTexture as Nullable<WebGPUHardwareTexture>)?.underlyingResource;\n if (!gpuTexture) {\n return false;\n }\n\n try {\n const source: GPUCopyElementImageSource = { source: element };\n if (config) {\n source.sx = config.sx;\n source.sy = config.sy;\n source.swidth = config.swidth;\n source.sheight = config.sheight;\n }\n\n queue.copyElementImageToTexture(source, {\n destination: { texture: gpuTexture },\n width: config?.width ?? texture.width,\n height: config?.height ?? texture.height,\n });\n\n if (texture.generateMipMaps) {\n engine._generateMipmaps(texture);\n }\n\n // The WICG copyElementImageToTexture API has no flipY option; the destination orientation is\n // determined by the source. We record the requested value for downstream sampling conventions.\n texture.invertY = invertY;\n texture.isReady = true;\n return true;\n } catch (error) {\n // Reaching here means the snapshot upload failed - usually a real misconfiguration (the element is\n // not a child of the rendering canvas, or `layoutsubtree` is missing), though a stray call before\n // the first paint snapshot can also throw. Either way we must NOT disable the texture, so a later\n // paint-driven update can still succeed; we surface a one-time diagnostic to help debugging.\n _WarnUploadFailure(error);\n return false;\n }\n}\n\n/**\n * Defines the options used to create an {@link HtmlTexture}.\n */\nexport interface IHtmlTextureOptions {\n /** Defines the width of the texture in pixels (defaults to the element's offset width, then 256). */\n width?: number;\n /** Defines the height of the texture in pixels (defaults to the element's offset height, then 256). */\n height?: number;\n /** Defines whether mip maps should be created or not (default: false). */\n generateMipMaps?: boolean;\n /** Defines the sampling mode of the texture (default: TEXTURE_BILINEAR_SAMPLINGMODE). */\n samplingMode?: number;\n /** Defines the associated texture format (default: TEXTUREFORMAT_RGBA). */\n format?: number;\n /** Defines whether the texture is automatically updated when the host canvas emits a paint event (default: true). */\n autoUpdate?: boolean;\n /**\n * Defines whether to fall back to an SVG `<foreignObject>` rasterization when the native WICG\n * HTML-in-Canvas API is unavailable (default: true). The fallback works in any browser but only\n * captures same-origin, inline-styled content as a static snapshot (see the documentation for caveats).\n */\n useSvgFallback?: boolean;\n /** Defines the engine instance to use the texture with. Not mandatory if a scene is provided. */\n engine?: Nullable<AbstractEngine>;\n /** Defines the scene the texture belongs to. Not mandatory if an engine is provided. */\n scene?: Nullable<Scene>;\n}\n\n/**\n * A texture whose content is rendered from a live HTML element using the WICG HTML-in-Canvas API\n * (https://github.com/WICG/html-in-canvas).\n *\n * The element is hosted as a child of the engine's rendering canvas (which is marked `layoutsubtree`) so\n * the browser can lay it out and snapshot it; the WICG API requires the source element to be a direct\n * child of the canvas whose context performs the upload. Content is uploaded through\n * `WebGLRenderingContext.texElementImage2D` (WebGL) or `GPUQueue.copyElementImageToTexture` (WebGPU),\n * available either natively (behind chrome://flags/#canvas-draw-element) or via the three-html-render\n * polyfill (https://github.com/repalash/three-html-render). When neither is present, a built-in SVG\n * `<foreignObject>` fallback is used instead (see `useSvgFallback`).\n *\n * As with {@link HtmlElementTexture}, updates are not automatic unless `autoUpdate` is enabled; in\n * that case the texture refreshes whenever the host canvas reports a paint change.\n */\nexport class HtmlTexture extends BaseTexture {\n /**\n * The HTML element rendered into the texture.\n */\n public readonly element: HTMLElement;\n\n /**\n * The element that hosts {@link element} in the document. This is the engine's rendering canvas when one\n * is available (required by the WICG API, which can only capture the element from that canvas), or a\n * hidden helper `<div>` otherwise - in which case only the SVG fallback can render.\n */\n public readonly host: Nullable<HTMLElement>;\n\n /**\n * Observable triggered once the texture has been rendered for the first time.\n */\n public onLoadObservable: Observable<HtmlTexture> = new Observable<HtmlTexture>();\n\n private static readonly _DefaultOptions: Required<Pick<IHtmlTextureOptions, \"generateMipMaps\" | \"samplingMode\" | \"format\" | \"autoUpdate\" | \"useSvgFallback\">> = {\n generateMipMaps: false,\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\n format: Constants.TEXTUREFORMAT_RGBA,\n autoUpdate: true,\n useSvgFallback: true,\n };\n\n private readonly _format: number;\n private readonly _generateMipMaps: boolean;\n private readonly _samplingMode: number;\n private readonly _useSvgFallback: boolean;\n private readonly _textureMatrix: Matrix;\n private _paintHandler: Nullable<(event: PaintEvent) => void> = null;\n private _ownsHost: boolean = false;\n private _originalParent: Nullable<Node & ParentNode> = null;\n private _originalNextSibling: Nullable<ChildNode> = null;\n private _addedInert: boolean = false;\n private _width: number;\n private _height: number;\n\n /**\n * Instantiates an HtmlTexture from an HTML element.\n * @param name Defines the name of the texture\n * @param element Defines the HTML element to render into the texture\n * @param options Defines the texture creation options\n */\n constructor(name: string, element: HTMLElement, options: IHtmlTextureOptions) {\n super(options.scene || options.engine);\n\n this.element = element;\n this._textureMatrix = Matrix.Identity();\n\n if (!element || (!options.engine && !options.scene)) {\n this.host = null;\n this._width = 0;\n this._height = 0;\n this._format = HtmlTexture._DefaultOptions.format;\n this._generateMipMaps = HtmlTexture._DefaultOptions.generateMipMaps;\n this._samplingMode = HtmlTexture._DefaultOptions.samplingMode;\n this._useSvgFallback = HtmlTexture._DefaultOptions.useSvgFallback;\n return;\n }\n\n this._generateMipMaps = options.generateMipMaps ?? HtmlTexture._DefaultOptions.generateMipMaps;\n this._samplingMode = options.samplingMode ?? HtmlTexture._DefaultOptions.samplingMode;\n this._format = options.format ?? HtmlTexture._DefaultOptions.format;\n this._useSvgFallback = options.useSvgFallback ?? HtmlTexture._DefaultOptions.useSvgFallback;\n const autoUpdate = options.autoUpdate ?? HtmlTexture._DefaultOptions.autoUpdate;\n\n this._width = options.width || element.offsetWidth || 256;\n this._height = options.height || element.offsetHeight || 256;\n\n this.name = name;\n this.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\n this.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\n this.anisotropicFilteringLevel = 1;\n\n this.host = this._createHost();\n\n // The native WICG API has no content until the first paint snapshot is recorded, so the initial\n // upload must happen from a paint event. The rendering canvas emits `paint`; listen for at least the\n // first one and, when auto-update is disabled, detach after that first refresh. A non-canvas helper\n // host never emits `paint`, so this listener is simply never invoked there.\n if (this.host) {\n this._paintHandler = (event: PaintEvent) => {\n // A single `paint` event covers every changed child of the shared rendering canvas. When the\n // browser reports which elements changed, skip the upload unless ours is among them, so that\n // multiple HTML textures hosted on the same canvas don't all re-upload on every unrelated change.\n if (event.changedElements && !event.changedElements.some((changed) => this.element === changed || this.element.contains(changed))) {\n return;\n }\n this.update();\n if (!autoUpdate && this._paintHandler && this.host) {\n this.host.removeEventListener(\"paint\", this._paintHandler as EventListener);\n this._paintHandler = null;\n }\n };\n this.host.addEventListener(\"paint\", this._paintHandler as EventListener);\n }\n\n this._createInternalTexture();\n }\n\n private _createHost(): Nullable<HTMLElement> {\n if (!IsWindowObjectExist() || typeof document === \"undefined\") {\n return null;\n }\n\n // Remember where the caller had the element so dispose() can put it back: we are about to re-parent it\n // into the host (the element must be a direct child of the host to be captured and laid out).\n this._originalParent = this.element.parentNode;\n this._originalNextSibling = this.element.nextSibling;\n\n // Per the WICG spec, the source element must be a *direct child* of the same canvas whose WebGL/WebGPU\n // context performs the upload, and that canvas must opt its subtree into layout via `layoutsubtree`.\n // The engine already owns our texture through its rendering canvas, so the element has to live inside\n // that canvas: it is the only one whose context can snapshot the element via texElementImage2D /\n // copyElementImageToTexture. A separate canvas would lay the element out but could never be captured\n // into the engine's texture (this is why nothing rendered on the native path before).\n const renderingCanvas = this._getEngine()?.getRenderingCanvas() ?? null;\n if (renderingCanvas) {\n renderingCanvas.layoutSubtree = true;\n // `layoutsubtree` opts children into hit testing; mark ours inert so it never steals pointer events\n // from the canvas (e.g. camera controls). Synthetic event dispatch still reaches inert elements, so\n // HtmlRaycastInteractionManager keeps working; HtmlInteractionManager clears it to enable native input.\n this._addedInert = !this.element.hasAttribute(\"inert\");\n this.element.setAttribute(\"inert\", \"\");\n renderingCanvas.appendChild(this.element);\n this._ownsHost = false;\n return renderingCanvas;\n }\n\n // No rendering canvas (e.g. NullEngine / offscreen): the native upload paths cannot run, because they\n // capture from the engine's canvas and there is none. Only the SVG fallback renders here, and it builds\n // from the element's serialized markup rather than from a canvas - so a host *canvas* would buy nothing.\n // Host the element in a hidden, off-screen <div> purely so it is laid out in the document (giving\n // correct measured sizes); there is no canvas to capture into on this path.\n const host = document.createElement(\"div\");\n host.style.position = \"absolute\";\n host.style.left = \"-99999px\";\n host.style.top = \"0px\";\n host.style.pointerEvents = \"none\";\n host.setAttribute(\"aria-hidden\", \"true\");\n\n host.appendChild(this.element);\n document.body.appendChild(host);\n this._ownsHost = true;\n\n return host;\n }\n\n private _createInternalTexture(): void {\n const engine = this._getEngine();\n if (engine) {\n // createDynamicTexture is an engine extension; register it lazily (idempotent) so this module stays free of top-level side effects.\n RegisterEnginesExtensionsEngineDynamicTexture();\n this._texture = engine.createDynamicTexture(this._width, this._height, this._generateMipMaps, this._samplingMode);\n this._texture.format = this._format;\n }\n\n // Trigger the initial render. On the native path this requests a paint so the first upload happens\n // once a snapshot exists (calling the WICG API before the first snapshot throws); otherwise the\n // SVG fallback (or a direct update) renders immediately.\n this.requestUpdate();\n }\n\n /**\n * @returns the texture matrix used in most of the material.\n */\n public override getTextureMatrix(): Matrix {\n return this._textureMatrix;\n }\n\n /**\n * Requests the host canvas to emit a paint event on the next rendering update. When auto-update is\n * enabled, this triggers a texture refresh in sync with the DOM. Falls back to an immediate update\n * when the WICG API is not available.\n */\n public requestUpdate(): void {\n // `requestPaint` only exists on a WICG-capable rendering canvas; the helper <div> host has no such\n // method, so fall back to an immediate update there.\n const canvasHost = this.host as Nullable<HTMLCanvasElement>;\n if (canvasHost && typeof canvasHost.requestPaint === \"function\") {\n canvasHost.requestPaint();\n } else {\n this.update();\n }\n }\n\n /**\n * Updates the content of the texture from the current state of the HTML element.\n * @param invertY Defines whether the texture should be inverted on Y (true by default)\n */\n public update(invertY: boolean = true): void {\n const engine = this._getEngine();\n if (this._texture == null || engine == null) {\n return;\n }\n\n // When the native WICG upload API is unavailable, render through the SVG <foreignObject> fallback\n // (unless it was explicitly disabled, in which case the upload helper emits a one-time warning).\n if (this._useSvgFallback && !IsHtmlInCanvasUploadSupported(engine)) {\n this._updateFromSvgFallback(engine, invertY);\n return;\n }\n\n const wasReady = this.isReady();\n\n UploadHtmlElementToTexture(engine, this._texture, this.element, invertY);\n\n if (!wasReady && this.isReady()) {\n this.onLoadObservable.notifyObservers(this);\n }\n }\n\n /**\n * Renders the element through an SVG `<foreignObject>` snapshot and uploads it to the texture. This\n * fallback works in any browser but only captures same-origin, inline-styled content as a static image.\n * @param engine defines the engine that owns the texture\n * @param invertY defines whether the texture should be inverted on Y\n */\n private _updateFromSvgFallback(engine: AbstractEngine, invertY: boolean): void {\n if (typeof document === \"undefined\" || typeof Image === \"undefined\" || typeof XMLSerializer === \"undefined\") {\n return;\n }\n\n const svgUrl = this._buildSvgDataUrl();\n if (!svgUrl) {\n return;\n }\n\n const image = new Image();\n image.onload = () => {\n if (this._texture == null) {\n return;\n }\n const wasReady = this.isReady();\n try {\n engine.updateDynamicTexture(this._texture, image, invertY, false, this._format);\n } catch {\n _WarnSvgFallback();\n return;\n }\n if (!wasReady && this.isReady()) {\n this.onLoadObservable.notifyObservers(this);\n }\n };\n image.onerror = () => {\n _WarnSvgFallback();\n };\n image.src = svgUrl;\n }\n\n /**\n * Serializes the element into an SVG `<foreignObject>` data URL sized to the texture.\n * @returns a data URL, or null if serialization failed\n */\n private _buildSvgDataUrl(): Nullable<string> {\n try {\n const clone = this.element.cloneNode(true) as HTMLElement;\n clone.setAttribute(\"xmlns\", \"http://www.w3.org/1999/xhtml\");\n const serialized = new XMLSerializer().serializeToString(clone);\n const svg =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${this._width}\" height=\"${this._height}\">` +\n `<foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">${serialized}</foreignObject>` +\n `</svg>`;\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n } catch {\n return null;\n }\n }\n\n /**\n * Gets the current class name of the texture useful for serialization or dynamic coding.\n * @returns \"HtmlTexture\"\n */\n public override getClassName(): string {\n return \"HtmlTexture\";\n }\n\n /**\n * Dispose the texture and release its associated resources.\n */\n public override dispose(): void {\n if (this.host) {\n if (this._paintHandler) {\n this.host.removeEventListener(\"paint\", this._paintHandler as EventListener);\n this._paintHandler = null;\n }\n // Remove the `inert` attribute we added so the caller gets the element back as they passed it.\n if (this._addedInert) {\n this.element.removeAttribute(\"inert\");\n this._addedInert = false;\n }\n // Restore the element to where the caller had it before we re-parented it into the host, rather\n // than silently deleting their node from the document.\n if (this._originalParent) {\n const reference = this._originalNextSibling && this._originalNextSibling.parentNode === this._originalParent ? this._originalNextSibling : null;\n this._originalParent.insertBefore(this.element, reference);\n } else {\n this.element.remove();\n }\n // Remove the helper host we created (never the engine's borrowed rendering canvas).\n if (this._ownsHost) {\n this.host.remove();\n }\n }\n\n this.onLoadObservable.clear();\n super.dispose();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"htmlTexture.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/HTML/htmlTexture.ts"],"names":[],"mappings":"AAAA,8HAA8H;AAG9H,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,6CAA6C,EAAE,MAAM,wDAAwD,CAAC;AACvH,OAAO,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAS1E,IAAI,yBAAyB,GAAG,KAAK,CAAC;AAEtC,SAAS,eAAe,CAAC,OAAe;IACpC,IAAI,yBAAyB,EAAE,CAAC;QAC5B,OAAO;IACX,CAAC;IACD,yBAAyB,GAAG,IAAI,CAAC;IACjC,MAAM,CAAC,IAAI,CACP,mBAAmB,OAAO,iJAAiJ,CAC9K,CAAC;AACN,CAAC;AAED,IAAI,0BAA0B,GAAG,KAAK,CAAC;AAEvC,SAAS,gBAAgB;IACrB,IAAI,0BAA0B,EAAE,CAAC;QAC7B,OAAO;IACX,CAAC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AAI,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACJ,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1B,CAAC;YACD,oFAAoF;YACpF,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACjB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACvB,CAAC;QACL,CAAC;QAED,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,CAAC;QAC9B,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;;AAnTuB,2BAAe,GAAyH;IAC5J,eAAe,EAAE,KAAK;IACtB,YAAY,EAAE,SAAS,CAAC,6BAA6B;IACrD,MAAM,EAAE,SAAS,CAAC,kBAAkB;IACpC,UAAU,EAAE,IAAI;IAChB,cAAc,EAAE,IAAI;CACvB,AANsC,CAMrC","sourcesContent":["/** This module has no top-level side effects: the engine extension it depends on is registered lazily from the constructor */\n\nimport { type Nullable } from \"../../../types\";\nimport { BaseTexture } from \"../baseTexture.pure\";\nimport { Constants } from \"../../../Engines/constants\";\nimport { Matrix } from \"../../../Maths/math.vector.pure\";\nimport { Observable } from \"../../../Misc/observable.pure\";\nimport { Logger } from \"../../../Misc/logger\";\nimport { IsWindowObjectExist } from \"../../../Misc/domManagement\";\nimport { RegisterEnginesExtensionsEngineDynamicTexture } from \"../../../Engines/Extensions/engine.dynamicTexture.pure\";\nimport { _IsHtmlInCanvasPolyfillInstalled } from \"./htmlInCanvasPolyfill\";\n\nimport { type AbstractEngine } from \"../../../Engines/abstractEngine.pure\";\nimport { type ThinEngine } from \"../../../Engines/thinEngine.pure\";\nimport { type WebGPUEngine } from \"../../../Engines/webgpuEngine.pure\";\nimport { type WebGPUHardwareTexture } from \"../../../Engines/WebGPU/webgpuHardwareTexture\";\nimport { type InternalTexture } from \"../internalTexture\";\nimport { type Scene } from \"../../../scene.pure\";\n\nlet _HasWarnedAboutMissingApi = false;\n\nfunction _WarnMissingApi(apiName: string): void {\n if (_HasWarnedAboutMissingApi) {\n return;\n }\n _HasWarnedAboutMissingApi = true;\n Logger.Warn(\n `HTML-in-Canvas: ${apiName} is not available. Enable chrome://flags/#canvas-draw-element, the built-in SVG fallback, or the three-html-render polyfill to use HtmlTexture.`\n );\n}\n\nlet _HasWarnedAboutSvgFallback = false;\n\nfunction _WarnSvgFallback(): void {\n if (_HasWarnedAboutSvgFallback) {\n return;\n }\n _HasWarnedAboutSvgFallback = true;\n Logger.Warn(\"HTML-in-Canvas: the SVG fallback could not rasterize the element. This usually means it references cross-origin or external resources, which taint the snapshot.\");\n}\n\nlet _HasWarnedAboutUploadFailure = false;\n\nfunction _WarnUploadFailure(error: unknown): void {\n if (_HasWarnedAboutUploadFailure) {\n return;\n }\n _HasWarnedAboutUploadFailure = true;\n const message = error instanceof Error ? error.message : String(error);\n Logger.Warn(\n `HTML-in-Canvas: the native upload failed (${message}). The element must be drawable inside the engine's rendering canvas with content=\"drawable\" (or layoutsubtree on older implementations), and the first upload must wait for a paint event.`\n );\n}\n\n/**\n * Detects whether the engine can upload an HTML element through the native (or polyfilled) WICG\n * HTML-in-Canvas API, without emitting any warning. Used to decide whether the SVG fallback is needed.\n * @param engine defines the engine to test\n * @returns true when the WICG upload API is available for this engine\n */\nexport function IsHtmlInCanvasUploadSupported(engine: AbstractEngine): boolean {\n if (engine.isWebGPU) {\n const queue = (engine as WebGPUEngine)._device?.queue;\n return !!queue && (typeof queue.drawElementImageToTexture === \"function\" || typeof queue.copyElementImageToTexture === \"function\");\n }\n\n const gl = (engine as ThinEngine)._gl as Nullable<WebGL2RenderingContext>;\n return !!gl && (typeof gl.texElementSubImage2D === \"function\" || typeof gl.texElementImage2D === \"function\");\n}\n\n/**\n * Uploads a live HTML element (or a captured ElementImage) into an existing 2D texture using the WICG\n * HTML-in-Canvas API (https://github.com/WICG/html-in-canvas).\n *\n * This is a side-effect-free helper - it is only reachable when {@link HtmlTexture} (or a direct caller)\n * is imported, so it adds nothing to bundles that do not use it. It relies on\n * `WebGLRenderingContext.texElementSubImage2D` (WebGL) or `GPUQueue.drawElementImageToTexture` (WebGPU),\n * with support for their older `texElementImage2D` / `copyElementImageToTexture` counterparts, including\n * the three-html-render polyfill.\n * @param engine defines the engine that owns the texture\n * @param texture defines the internal texture to update\n * @param element defines the source HTML element (or captured ElementImage) to upload\n * @param invertY defines if data must be stored with Y axis inverted (true by default)\n * @param config defines an optional source rectangle and sizing configuration\n * @returns true if the upload succeeded, false otherwise (e.g. the API is unavailable)\n */\nexport function UploadHtmlElementToTexture(\n engine: AbstractEngine,\n texture: Nullable<InternalTexture>,\n element: Element | ElementImage,\n invertY: boolean = true,\n config?: WebGLCopyElementImageConfig\n): boolean {\n if (!texture || texture._isDisabled) {\n return false;\n }\n\n if (engine.isWebGPU) {\n return _UploadHtmlElementToWebGPUTexture(engine as WebGPUEngine, texture, element, invertY, config);\n }\n\n return _UploadHtmlElementToWebGLTexture(engine as ThinEngine, texture, element, invertY, config);\n}\n\n// Before texElementSubImage2D, the proposal used two incompatible texElementImage2D signatures.\n// Prefer the shorter form and fall back to the texImage2D-shaped overload used by older Chrome builds\n// and three-html-render when the implementation rejects the argument count.\nlet _UseLegacyTexElementImage2D = false;\n\nfunction _CallTexElementImage2D(gl: WebGL2RenderingContext, internalFormat: number, element: Element | ElementImage, config?: WebGLCopyElementImageConfig): void {\n if (!_UseLegacyTexElementImage2D) {\n try {\n gl.texElementImage2D(gl.TEXTURE_2D, internalFormat, element, config);\n return;\n } catch (error) {\n // Only a wrong-arity TypeError means we are talking to the legacy signature; anything else\n // (e.g. the element is not a canvas child) is a genuine upload failure and must propagate.\n // Native rejects the new form with \"N arguments required, but only M present\"; the\n // three-html-render polyfill rejects it with \"unexpected argument count N\".\n if (!(error instanceof TypeError) || !/arguments required|argument count/.test((error as Error).message)) {\n throw error;\n }\n _UseLegacyTexElementImage2D = true;\n }\n }\n\n // Legacy overload: texElementImage2D(target, level, internalformat, format, type, element).\n gl.texElementImage2D(gl.TEXTURE_2D, 0, internalFormat, gl.RGBA, gl.UNSIGNED_BYTE, element);\n}\n\nfunction _UploadHtmlElementToWebGLTexture(\n engine: ThinEngine,\n texture: InternalTexture,\n element: Element | ElementImage,\n invertY: boolean,\n config?: WebGLCopyElementImageConfig\n): boolean {\n // Engines without a WebGL context (e.g. NullEngine) have no _gl and are handled by this guard.\n const gl = engine._gl as Nullable<WebGL2RenderingContext>;\n if (!gl || (typeof gl.texElementSubImage2D !== \"function\" && typeof gl.texElementImage2D !== \"function\")) {\n _WarnMissingApi(\"texElementSubImage2D / texElementImage2D\");\n return false;\n }\n\n // texElementImage2D requires a *sized* internal format (RGBA8, SRGB8_ALPHA8, RGBA16F or RGBA32F);\n // the unsized gl.RGBA returned by _getInternalFormat is rejected.\n const type = texture.type === -1 ? Constants.TEXTURETYPE_UNSIGNED_BYTE : texture.type;\n const internalFormat = engine._getRGBABufferInternalSizedFormat(type, texture.format, texture._useSRGBBuffer);\n const wasPreviouslyBound = engine._bindTextureDirectly(gl.TEXTURE_2D, texture, true);\n engine._unpackFlipY(invertY);\n\n try {\n if (typeof gl.texElementSubImage2D === \"function\" && !(_IsHtmlInCanvasPolyfillInstalled() && typeof gl.texElementImage2D === \"function\")) {\n // Unlike texElementImage2D, the current API updates existing storage rather than defining it.\n if (!texture.isReady) {\n gl.texImage2D(\n gl.TEXTURE_2D,\n 0,\n internalFormat,\n texture.width,\n texture.height,\n 0,\n engine._getInternalFormat(texture.format),\n engine._getWebGLTextureType(type),\n null\n );\n }\n gl.texElementSubImage2D(gl.TEXTURE_2D, 0, 0, 0, element, config ?? { width: texture.width, height: texture.height });\n } else {\n _CallTexElementImage2D(gl, internalFormat, element, config);\n }\n\n if (texture.generateMipMaps) {\n gl.generateMipmap(gl.TEXTURE_2D);\n }\n\n texture.invertY = invertY;\n texture.isReady = true;\n return true;\n } catch (error) {\n // Reaching here means the snapshot upload failed - usually a real misconfiguration (the element is\n // not drawable in the rendering canvas), though a stray call before\n // the first paint snapshot can also throw. Either way we must NOT disable the texture, so a later\n // paint-driven update can still succeed; we surface a one-time diagnostic to help debugging.\n _WarnUploadFailure(error);\n return false;\n } finally {\n if (!wasPreviouslyBound) {\n engine._bindTextureDirectly(gl.TEXTURE_2D, null);\n }\n }\n}\n\nfunction _UploadHtmlElementToWebGPUTexture(\n engine: WebGPUEngine,\n texture: InternalTexture,\n element: Element | ElementImage,\n invertY: boolean,\n config?: WebGLCopyElementImageConfig\n): boolean {\n const device = engine._device;\n const queue = device && device.queue;\n if (!device || !queue || (typeof queue.drawElementImageToTexture !== \"function\" && typeof queue.copyElementImageToTexture !== \"function\")) {\n _WarnMissingApi(\"GPUQueue.drawElementImageToTexture / GPUQueue.copyElementImageToTexture\");\n return false;\n }\n\n const gpuTexture = (texture._hardwareTexture as Nullable<WebGPUHardwareTexture>)?.underlyingResource;\n if (!gpuTexture) {\n return false;\n }\n\n try {\n if (_IsHtmlInCanvasPolyfillInstalled() && typeof queue.copyElementImageToTexture === \"function\") {\n queue.copyElementImageToTexture(element, config?.width ?? texture.width, config?.height ?? texture.height, { texture: gpuTexture });\n } else if (typeof queue.drawElementImageToTexture === \"function\") {\n const source: GPUDrawElementImageSource = { source: element };\n if (config) {\n source.sourceX = config.sx;\n source.sourceY = config.sy;\n source.sourceWidth = config.swidth;\n source.sourceHeight = config.sheight;\n }\n queue.drawElementImageToTexture(source, {\n texture: gpuTexture,\n size: { width: config?.width ?? texture.width, height: config?.height ?? texture.height },\n });\n } else {\n const source: GPUCopyElementImageSource = { source: element };\n if (config) {\n source.sx = config.sx;\n source.sy = config.sy;\n source.swidth = config.swidth;\n source.sheight = config.sheight;\n }\n queue.copyElementImageToTexture(source, {\n destination: { texture: gpuTexture },\n width: config?.width ?? texture.width,\n height: config?.height ?? texture.height,\n });\n }\n\n if (texture.generateMipMaps) {\n engine._generateMipmaps(texture);\n }\n\n // The WICG element upload APIs have no flipY option; the destination orientation is\n // determined by the source. We record the requested value for downstream sampling conventions.\n texture.invertY = invertY;\n texture.isReady = true;\n return true;\n } catch (error) {\n // Reaching here means the snapshot upload failed - usually a real misconfiguration (the element is\n // not drawable in the rendering canvas), though a stray call before\n // the first paint snapshot can also throw. Either way we must NOT disable the texture, so a later\n // paint-driven update can still succeed; we surface a one-time diagnostic to help debugging.\n _WarnUploadFailure(error);\n return false;\n }\n}\n\n/**\n * Defines the options used to create an {@link HtmlTexture}.\n */\nexport interface IHtmlTextureOptions {\n /** Defines the width of the texture in pixels (defaults to the element's offset width, then 256). */\n width?: number;\n /** Defines the height of the texture in pixels (defaults to the element's offset height, then 256). */\n height?: number;\n /** Defines whether mip maps should be created or not (default: false). */\n generateMipMaps?: boolean;\n /** Defines the sampling mode of the texture (default: TEXTURE_BILINEAR_SAMPLINGMODE). */\n samplingMode?: number;\n /** Defines the associated texture format (default: TEXTUREFORMAT_RGBA). */\n format?: number;\n /** Defines whether the texture is automatically updated when the host canvas emits a paint event (default: true). */\n autoUpdate?: boolean;\n /**\n * Defines whether to fall back to an SVG `<foreignObject>` rasterization when the native WICG\n * HTML-in-Canvas API is unavailable (default: true). The fallback works in any browser but only\n * captures same-origin, inline-styled content as a static snapshot (see the documentation for caveats).\n */\n useSvgFallback?: boolean;\n /** Defines the engine instance to use the texture with. Not mandatory if a scene is provided. */\n engine?: Nullable<AbstractEngine>;\n /** Defines the scene the texture belongs to. Not mandatory if an engine is provided. */\n scene?: Nullable<Scene>;\n}\n\n/**\n * A texture whose content is rendered from a live HTML element using the WICG HTML-in-Canvas API\n * (https://github.com/WICG/html-in-canvas).\n *\n * The element is hosted as a drawable child of the engine's rendering canvas (marked `content=\"drawable\"`,\n * or `layoutsubtree` on older implementations) so the browser can lay it out and snapshot it.\n * Content is uploaded through `WebGLRenderingContext.texElementSubImage2D` (WebGL) or\n * `GPUQueue.drawElementImageToTexture` (WebGPU), with support for older browsers and the three-html-render\n * polyfill (https://github.com/repalash/three-html-render). When neither is present, a built-in SVG\n * `<foreignObject>` fallback is used instead (see `useSvgFallback`).\n *\n * As with {@link HtmlElementTexture}, updates are not automatic unless `autoUpdate` is enabled; in\n * that case the texture refreshes whenever the host canvas reports a paint change.\n */\nexport class HtmlTexture extends BaseTexture {\n /**\n * The HTML element rendered into the texture.\n */\n public readonly element: HTMLElement;\n\n /**\n * The element that hosts {@link element} in the document. This is the engine's rendering canvas when one\n * is available (required by the WICG API, which can only capture the element from that canvas), or a\n * hidden helper `<div>` otherwise - in which case only the SVG fallback can render.\n */\n public readonly host: Nullable<HTMLElement>;\n\n /**\n * Observable triggered once the texture has been rendered for the first time.\n */\n public onLoadObservable: Observable<HtmlTexture> = new Observable<HtmlTexture>();\n\n private static readonly _DefaultOptions: Required<Pick<IHtmlTextureOptions, \"generateMipMaps\" | \"samplingMode\" | \"format\" | \"autoUpdate\" | \"useSvgFallback\">> = {\n generateMipMaps: false,\n samplingMode: Constants.TEXTURE_BILINEAR_SAMPLINGMODE,\n format: Constants.TEXTUREFORMAT_RGBA,\n autoUpdate: true,\n useSvgFallback: true,\n };\n\n private readonly _format: number;\n private readonly _generateMipMaps: boolean;\n private readonly _samplingMode: number;\n private readonly _useSvgFallback: boolean;\n private readonly _textureMatrix: Matrix;\n private _paintHandler: Nullable<(event: CanvasPaintEvent) => void> = null;\n private _ownsHost: boolean = false;\n private _originalParent: Nullable<Node & ParentNode> = null;\n private _originalNextSibling: Nullable<ChildNode> = null;\n private _addedInert: boolean = false;\n private _addedDrawable: boolean = false;\n private _updateRequested: boolean = false;\n private _width: number;\n private _height: number;\n\n /**\n * Instantiates an HtmlTexture from an HTML element.\n * @param name Defines the name of the texture\n * @param element Defines the HTML element to render into the texture\n * @param options Defines the texture creation options\n */\n constructor(name: string, element: HTMLElement, options: IHtmlTextureOptions) {\n super(options.scene || options.engine);\n\n this.element = element;\n this._textureMatrix = Matrix.Identity();\n\n if (!element || (!options.engine && !options.scene)) {\n this.host = null;\n this._width = 0;\n this._height = 0;\n this._format = HtmlTexture._DefaultOptions.format;\n this._generateMipMaps = HtmlTexture._DefaultOptions.generateMipMaps;\n this._samplingMode = HtmlTexture._DefaultOptions.samplingMode;\n this._useSvgFallback = HtmlTexture._DefaultOptions.useSvgFallback;\n return;\n }\n\n this._generateMipMaps = options.generateMipMaps ?? HtmlTexture._DefaultOptions.generateMipMaps;\n this._samplingMode = options.samplingMode ?? HtmlTexture._DefaultOptions.samplingMode;\n this._format = options.format ?? HtmlTexture._DefaultOptions.format;\n this._useSvgFallback = options.useSvgFallback ?? HtmlTexture._DefaultOptions.useSvgFallback;\n const autoUpdate = options.autoUpdate ?? HtmlTexture._DefaultOptions.autoUpdate;\n\n this._width = options.width || element.offsetWidth || 256;\n this._height = options.height || element.offsetHeight || 256;\n\n this.name = name;\n this.wrapU = Constants.TEXTURE_CLAMP_ADDRESSMODE;\n this.wrapV = Constants.TEXTURE_CLAMP_ADDRESSMODE;\n this.anisotropicFilteringLevel = 1;\n\n this.host = this._createHost();\n\n // Native uploads need an initial paint snapshot. Keep the listener for explicit requests even when\n // auto-update is disabled; helper div hosts never emit paint.\n if (this.host) {\n let hasPainted = false;\n this._paintHandler = (event: CanvasPaintEvent) => {\n // A single `paint` event covers every changed child of the shared rendering canvas. When the\n // browser reports which elements changed, skip the upload unless ours is among them, so that\n // multiple HTML textures hosted on the same canvas don't all re-upload on every unrelated change.\n if (!autoUpdate && !this._updateRequested && hasPainted) {\n return;\n }\n if (!this._updateRequested && event.changedElements && !event.changedElements.some((changed) => this.element === changed || this.element.contains(changed))) {\n return;\n }\n this._updateRequested = false;\n hasPainted = true;\n this.update();\n };\n this.host.addEventListener(\"paint\", this._paintHandler as EventListener);\n }\n\n this._createInternalTexture();\n }\n\n private _createHost(): Nullable<HTMLElement> {\n if (!IsWindowObjectExist() || typeof document === \"undefined\") {\n return null;\n }\n\n // Remember where the caller had the element so dispose() can put it back: we are about to re-parent it\n // into the host (the element must be a direct child of the host to be captured and laid out).\n this._originalParent = this.element.parentNode;\n this._originalNextSibling = this.element.nextSibling;\n\n // Older WICG implementations require a direct canvas child; current implementations require a\n // drawable descendant and content=\"drawable\" on the same canvas whose context performs the upload.\n // A separate canvas cannot supply snapshots to the engine's context.\n const renderingCanvas = this._getEngine()?.getRenderingCanvas() ?? null;\n if (renderingCanvas) {\n if (typeof renderingCanvas.content === \"string\" && !_IsHtmlInCanvasPolyfillInstalled()) {\n renderingCanvas.content = \"drawable\";\n this._addedDrawable = !this.element.hasAttribute(\"drawable\");\n if (this._addedDrawable) {\n this.element.setAttribute(\"drawable\", \"\");\n }\n } else {\n renderingCanvas.layoutSubtree = true;\n }\n // `layoutsubtree` opts children into hit testing; mark ours inert so it never steals pointer events\n // from the canvas (e.g. camera controls). Synthetic event dispatch still reaches inert elements, so\n // HtmlRaycastInteractionManager keeps working; HtmlInteractionManager clears it to enable native input.\n this._addedInert = !this.element.hasAttribute(\"inert\");\n this.element.setAttribute(\"inert\", \"\");\n renderingCanvas.appendChild(this.element);\n this._ownsHost = false;\n return renderingCanvas;\n }\n\n // No rendering canvas (e.g. NullEngine / offscreen): the native upload paths cannot run, because they\n // capture from the engine's canvas and there is none. Only the SVG fallback renders here, and it builds\n // from the element's serialized markup rather than from a canvas - so a host *canvas* would buy nothing.\n // Host the element in a hidden, off-screen <div> purely so it is laid out in the document (giving\n // correct measured sizes); there is no canvas to capture into on this path.\n const host = document.createElement(\"div\");\n host.style.position = \"absolute\";\n host.style.left = \"-99999px\";\n host.style.top = \"0px\";\n host.style.pointerEvents = \"none\";\n host.setAttribute(\"aria-hidden\", \"true\");\n\n host.appendChild(this.element);\n document.body.appendChild(host);\n this._ownsHost = true;\n\n return host;\n }\n\n private _createInternalTexture(): void {\n const engine = this._getEngine();\n if (engine) {\n // createDynamicTexture is an engine extension; register it lazily (idempotent) so this module stays free of top-level side effects.\n RegisterEnginesExtensionsEngineDynamicTexture();\n this._texture = engine.createDynamicTexture(this._width, this._height, this._generateMipMaps, this._samplingMode);\n this._texture.format = this._format;\n }\n\n // Trigger the initial render. On the native path this requests a paint so the first upload happens\n // once a snapshot exists (calling the WICG API before the first snapshot throws); otherwise the\n // SVG fallback (or a direct update) renders immediately.\n this.requestUpdate();\n }\n\n /**\n * @returns the texture matrix used in most of the material.\n */\n public override getTextureMatrix(): Matrix {\n return this._textureMatrix;\n }\n\n /**\n * Requests a texture refresh in sync with the host canvas's next paint event, even when auto-update is\n * disabled. Updates immediately when the engine's WICG upload API is not available.\n */\n public requestUpdate(): void {\n // A browser can expose requestPaint without an upload API supported by this engine. In that case\n // do not wait for native paint: update() must still reach the SVG fallback or the missing-API warning.\n const engine = this._getEngine();\n const canvasHost = this.host as Nullable<HTMLCanvasElement>;\n if (engine && IsHtmlInCanvasUploadSupported(engine) && canvasHost && typeof canvasHost.requestPaint === \"function\") {\n this._updateRequested = true;\n canvasHost.requestPaint();\n } else {\n this.update();\n }\n }\n\n /**\n * Updates the content of the texture from the current state of the HTML element.\n * @param invertY Defines whether the texture should be inverted on Y (true by default)\n */\n public update(invertY: boolean = true): void {\n const engine = this._getEngine();\n if (this._texture == null || engine == null) {\n return;\n }\n\n // When the native WICG upload API is unavailable, render through the SVG <foreignObject> fallback\n // (unless it was explicitly disabled, in which case the upload helper emits a one-time warning).\n if (this._useSvgFallback && !IsHtmlInCanvasUploadSupported(engine)) {\n this._updateFromSvgFallback(engine, invertY);\n return;\n }\n\n const wasReady = this.isReady();\n\n UploadHtmlElementToTexture(engine, this._texture, this.element, invertY);\n\n if (!wasReady && this.isReady()) {\n this.onLoadObservable.notifyObservers(this);\n }\n }\n\n /**\n * Renders the element through an SVG `<foreignObject>` snapshot and uploads it to the texture. This\n * fallback works in any browser but only captures same-origin, inline-styled content as a static image.\n * @param engine defines the engine that owns the texture\n * @param invertY defines whether the texture should be inverted on Y\n */\n private _updateFromSvgFallback(engine: AbstractEngine, invertY: boolean): void {\n if (typeof document === \"undefined\" || typeof Image === \"undefined\" || typeof XMLSerializer === \"undefined\") {\n return;\n }\n\n const svgUrl = this._buildSvgDataUrl();\n if (!svgUrl) {\n return;\n }\n\n const image = new Image();\n image.onload = () => {\n if (this._texture == null) {\n return;\n }\n const wasReady = this.isReady();\n try {\n engine.updateDynamicTexture(this._texture, image, invertY, false, this._format);\n } catch {\n _WarnSvgFallback();\n return;\n }\n if (!wasReady && this.isReady()) {\n this.onLoadObservable.notifyObservers(this);\n }\n };\n image.onerror = () => {\n _WarnSvgFallback();\n };\n image.src = svgUrl;\n }\n\n /**\n * Serializes the element into an SVG `<foreignObject>` data URL sized to the texture.\n * @returns a data URL, or null if serialization failed\n */\n private _buildSvgDataUrl(): Nullable<string> {\n try {\n const clone = this.element.cloneNode(true) as HTMLElement;\n clone.setAttribute(\"xmlns\", \"http://www.w3.org/1999/xhtml\");\n const serialized = new XMLSerializer().serializeToString(clone);\n const svg =\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${this._width}\" height=\"${this._height}\">` +\n `<foreignObject x=\"0\" y=\"0\" width=\"100%\" height=\"100%\">${serialized}</foreignObject>` +\n `</svg>`;\n return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(svg)}`;\n } catch {\n return null;\n }\n }\n\n /**\n * Gets the current class name of the texture useful for serialization or dynamic coding.\n * @returns \"HtmlTexture\"\n */\n public override getClassName(): string {\n return \"HtmlTexture\";\n }\n\n /**\n * Dispose the texture and release its associated resources.\n */\n public override dispose(): void {\n if (this.host) {\n if (this._paintHandler) {\n this.host.removeEventListener(\"paint\", this._paintHandler as EventListener);\n this._paintHandler = null;\n }\n // Remove the `inert` attribute we added so the caller gets the element back as they passed it.\n if (this._addedInert) {\n this.element.removeAttribute(\"inert\");\n this._addedInert = false;\n }\n if (this._addedDrawable) {\n this.element.removeAttribute(\"drawable\");\n this._addedDrawable = false;\n }\n // The polyfill redirects children into a helper host and tracks removals through this API.\n if (this.element.parentNode === this.host) {\n this.host.removeChild(this.element);\n }\n // Restore the element to where the caller had it before we re-parented it into the host, rather\n // than silently deleting their node from the document.\n if (this._originalParent) {\n const reference = this._originalNextSibling && this._originalNextSibling.parentNode === this._originalParent ? this._originalNextSibling : null;\n this._originalParent.insertBefore(this.element, reference);\n } else {\n this.element.remove();\n }\n // Remove the helper host we created (never the engine's borrowed rendering canvas).\n if (this._ownsHost) {\n this.host.remove();\n }\n }\n\n this.onLoadObservable.clear();\n super.dispose();\n }\n}\n"]}
|
|
@@ -24,6 +24,7 @@ export interface IInternalTextureLoader {
|
|
|
24
24
|
* @param texture defines the BabylonJS internal texture
|
|
25
25
|
* @param callback defines the method to call once ready to upload
|
|
26
26
|
* @param options options to be passed to the loader
|
|
27
|
+
* @param ownsData defines whether nothing else holds data (the engine loaded it from the texture's url, with no offline provider), so its buffer can be transferred
|
|
27
28
|
*/
|
|
28
|
-
loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
|
|
29
|
+
loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any, ownsData?: boolean): void;
|
|
29
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internalTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/internalTextureLoader.ts"],"names":[],"mappings":"","sourcesContent":["import { type Nullable } from \"../../../types\";\r\nimport { type InternalTexture } from \"../internalTexture\";\r\n\r\n/**\r\n * This represents the required contract to create a new type of texture loader.\r\n */\r\nexport interface IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n supportCascades: boolean;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param createPolynomials will be true if polynomials have been requested\r\n * @param onLoad defines the callback to trigger once the texture is ready\r\n * @param onError defines the callback to trigger in case of error\r\n * @param options options to be passed to the loader\r\n */\r\n loadCubeData(\r\n data: ArrayBufferView | ArrayBufferView[],\r\n texture: InternalTexture,\r\n createPolynomials: boolean,\r\n onLoad: Nullable<(data?: any) => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>,\r\n options?: any\r\n ): void;\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n * @param options options to be passed to the loader\r\n */\r\n loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void,\r\n options?: any\r\n ): void;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"internalTextureLoader.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Materials/Textures/Loaders/internalTextureLoader.ts"],"names":[],"mappings":"","sourcesContent":["import { type Nullable } from \"../../../types\";\r\nimport { type InternalTexture } from \"../internalTexture\";\r\n\r\n/**\r\n * This represents the required contract to create a new type of texture loader.\r\n */\r\nexport interface IInternalTextureLoader {\r\n /**\r\n * Defines whether the loader supports cascade loading the different faces.\r\n */\r\n supportCascades: boolean;\r\n\r\n /**\r\n * Uploads the cube texture data to the WebGL texture. It has already been bound.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param createPolynomials will be true if polynomials have been requested\r\n * @param onLoad defines the callback to trigger once the texture is ready\r\n * @param onError defines the callback to trigger in case of error\r\n * @param options options to be passed to the loader\r\n */\r\n loadCubeData(\r\n data: ArrayBufferView | ArrayBufferView[],\r\n texture: InternalTexture,\r\n createPolynomials: boolean,\r\n onLoad: Nullable<(data?: any) => void>,\r\n onError: Nullable<(message?: string, exception?: any) => void>,\r\n options?: any\r\n ): void;\r\n\r\n /**\r\n * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.\r\n * @param data contains the texture data\r\n * @param texture defines the BabylonJS internal texture\r\n * @param callback defines the method to call once ready to upload\r\n * @param options options to be passed to the loader\r\n * @param ownsData defines whether nothing else holds data (the engine loaded it from the texture's url, with no offline provider), so its buffer can be transferred\r\n */\r\n loadData(\r\n data: ArrayBufferView,\r\n texture: InternalTexture,\r\n callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void,\r\n options?: any,\r\n ownsData?: boolean\r\n ): void;\r\n}\r\n"]}
|
|
@@ -24,6 +24,7 @@ export declare class _KTXTextureLoader implements IInternalTextureLoader {
|
|
|
24
24
|
* @param texture defines the BabylonJS internal texture
|
|
25
25
|
* @param callback defines the method to call once ready to upload
|
|
26
26
|
* @param options
|
|
27
|
+
* @param ownsData defines whether nothing else holds data, so its buffer can be transferred
|
|
27
28
|
*/
|
|
28
|
-
loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
|
|
29
|
+
loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any, ownsData?: boolean): void;
|
|
29
30
|
}
|