@babylonjs/core 8.11.0 → 8.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cameras/arcRotateCamera.js +8 -0
- package/Cameras/arcRotateCamera.js.map +1 -1
- package/Cameras/targetCamera.js +2 -0
- package/Cameras/targetCamera.js.map +1 -1
- package/Collisions/gpuPicker.d.ts +4 -0
- package/Collisions/gpuPicker.js +6 -0
- package/Collisions/gpuPicker.js.map +1 -1
- package/Engines/abstractEngine.js +2 -2
- package/Engines/abstractEngine.js.map +1 -1
- package/Engines/constants.d.ts +4 -0
- package/Engines/constants.js +4 -0
- package/Engines/constants.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.d.ts +1 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js +2 -0
- package/FrameGraph/Node/Blocks/Rendering/baseShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.d.ts +6 -1
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js +29 -0
- package/FrameGraph/Node/Blocks/Rendering/csmShadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.d.ts +6 -0
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js +36 -9
- package/FrameGraph/Node/Blocks/Rendering/geometryRendererBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js +1 -0
- package/FrameGraph/Node/Blocks/Rendering/shadowGeneratorBlock.js.map +1 -1
- package/FrameGraph/Node/Blocks/inputBlock.js +1 -0
- package/FrameGraph/Node/Blocks/inputBlock.js.map +1 -1
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.d.ts +2 -0
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js +2 -0
- package/FrameGraph/Node/Types/nodeRenderGraphTypes.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.d.ts +23 -0
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js +126 -21
- package/FrameGraph/Tasks/Rendering/csmShadowGeneratorTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.d.ts +5 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +4 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.d.ts +2 -4
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js +4 -17
- package/FrameGraph/Tasks/Rendering/shadowGeneratorTask.js.map +1 -1
- package/FrameGraph/frameGraph.js +1 -1
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/frameGraphContext.d.ts +30 -0
- package/FrameGraph/frameGraphContext.js +47 -0
- package/FrameGraph/frameGraphContext.js.map +1 -1
- package/FrameGraph/frameGraphRenderContext.d.ts +1 -4
- package/FrameGraph/frameGraphRenderContext.js +2 -5
- package/FrameGraph/frameGraphRenderContext.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.d.ts +0 -1
- package/Lights/Shadows/cascadedShadowGenerator.js +0 -12
- package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js +4 -1
- package/Materials/Node/Blocks/Dual/clipPlanesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.d.ts +2 -3
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/currentScreenBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js +4 -1
- package/Materials/Node/Blocks/Dual/fogBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Dual/lightBlock.js +2 -2
- package/Materials/Node/Blocks/Dual/lightBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.d.ts +1 -2
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js +1 -1
- package/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js +3 -4
- package/Materials/Node/Blocks/Dual/smartFilterTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Dual/textureBlock.d.ts +2 -3
- package/Materials/Node/Blocks/Dual/textureBlock.js +2 -2
- package/Materials/Node/Blocks/Dual/textureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js +4 -1
- package/Materials/Node/Blocks/Fragment/TBNBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/fragCoordBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.d.ts +1 -2
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/fragmentOutputBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/frontFacingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js +1 -2
- package/Materials/Node/Blocks/Fragment/heightToNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/imageProcessingBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.d.ts +1 -2
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js +2 -2
- package/Materials/Node/Blocks/Fragment/screenSizeBlock.js.map +1 -1
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.d.ts +3 -3
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js +6 -3
- package/Materials/Node/Blocks/GaussianSplatting/gaussianSplattingBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/anisotropyBlock.d.ts +1 -2
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js +2 -4
- package/Materials/Node/Blocks/PBR/anisotropyBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/clearCoatBlock.d.ts +1 -2
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/clearCoatBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/iridescenceBlock.d.ts +2 -3
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/iridescenceBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.d.ts +1 -1
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js +5 -2
- package/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/reflectionBlock.d.ts +1 -2
- package/Materials/Node/Blocks/PBR/reflectionBlock.js +2 -2
- package/Materials/Node/Blocks/PBR/reflectionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/refractionBlock.d.ts +1 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/refractionBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/sheenBlock.d.ts +2 -3
- package/Materials/Node/Blocks/PBR/sheenBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/sheenBlock.js.map +1 -1
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.d.ts +2 -3
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js +1 -2
- package/Materials/Node/Blocks/PBR/subSurfaceBlock.js.map +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.d.ts +1 -2
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js +1 -1
- package/Materials/Node/Blocks/Particle/particleTextureBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/bonesBlock.d.ts +2 -2
- package/Materials/Node/Blocks/Vertex/bonesBlock.js +3 -3
- package/Materials/Node/Blocks/Vertex/bonesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.d.ts +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js +1 -1
- package/Materials/Node/Blocks/Vertex/instancesBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.d.ts +1 -2
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js +1 -1
- package/Materials/Node/Blocks/Vertex/lightInformationBlock.js.map +1 -1
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.d.ts +2 -2
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js +8 -2
- package/Materials/Node/Blocks/Vertex/morphTargetsBlock.js.map +1 -1
- package/Materials/Node/Blocks/transformBlock.d.ts +3 -3
- package/Materials/Node/Blocks/transformBlock.js +4 -5
- package/Materials/Node/Blocks/transformBlock.js.map +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.d.ts +1 -3
- package/Materials/Node/Blocks/triPlanarBlock.js +1 -1
- package/Materials/Node/Blocks/triPlanarBlock.js.map +1 -1
- package/Materials/Node/nodeMaterial.d.ts +1 -1
- package/Materials/Node/nodeMaterial.js +28 -42
- package/Materials/Node/nodeMaterial.js.map +1 -1
- package/Materials/Node/nodeMaterialBlock.d.ts +8 -12
- package/Materials/Node/nodeMaterialBlock.js +10 -12
- package/Materials/Node/nodeMaterialBlock.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildState.js +3 -1
- package/Materials/Node/nodeMaterialBuildState.js.map +1 -1
- package/Materials/Node/nodeMaterialBuildStateSharedData.d.ts +7 -3
- package/Materials/Node/nodeMaterialBuildStateSharedData.js +17 -6
- package/Materials/Node/nodeMaterialBuildStateSharedData.js.map +1 -1
- package/Materials/PBR/pbrBaseMaterial.d.ts +2 -0
- package/Materials/PBR/pbrBaseMaterial.js +11 -0
- package/Materials/PBR/pbrBaseMaterial.js.map +1 -1
- package/Materials/Textures/Loaders/exrTextureLoader.d.ts +10 -0
- package/Materials/Textures/Loaders/exrTextureLoader.js +28 -1
- package/Materials/Textures/Loaders/exrTextureLoader.js.map +1 -1
- package/Materials/materialHelper.functions.js +1 -1
- package/Materials/materialHelper.functions.js.map +1 -1
- package/Materials/materialHelper.geometryrendering.js +7 -0
- package/Materials/materialHelper.geometryrendering.js.map +1 -1
- package/Materials/standardMaterial.d.ts +2 -0
- package/Materials/standardMaterial.js +11 -0
- package/Materials/standardMaterial.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.d.ts +7 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js +11 -5
- package/Meshes/Node/Blocks/Textures/geometryTextureBlock.js.map +1 -1
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.d.ts +6 -0
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js +42 -4
- package/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.js.map +1 -1
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js +8 -0
- package/Meshes/Node/Blocks/geometryOptimizeBlock.js.map +1 -1
- package/Misc/environmentTextureTools.js +1 -1
- package/Misc/environmentTextureTools.js.map +1 -1
- package/Misc/minMaxReducer.d.ts +8 -6
- package/Misc/minMaxReducer.js +57 -90
- package/Misc/minMaxReducer.js.map +1 -1
- package/Misc/thinMinMaxReducer.d.ts +47 -0
- package/Misc/thinMinMaxReducer.js +148 -0
- package/Misc/thinMinMaxReducer.js.map +1 -0
- package/Particles/EmitterTypes/customParticleEmitter.d.ts +5 -0
- package/Particles/EmitterTypes/customParticleEmitter.js +9 -1
- package/Particles/EmitterTypes/customParticleEmitter.js.map +1 -1
- package/Particles/IParticleSystem.d.ts +4 -0
- package/Particles/IParticleSystem.js.map +1 -1
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.d.ts +75 -0
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.js +179 -0
- package/Particles/Node/Blocks/Conditions/particleConditionBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.d.ts +47 -0
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js +107 -0
- package/Particles/Node/Blocks/Emitters/boxShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.d.ts +46 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js +97 -0
- package/Particles/Node/Blocks/Emitters/createParticleBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/customShapeBlock.d.ts +39 -0
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js +84 -0
- package/Particles/Node/Blocks/Emitters/customShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.d.ts +48 -0
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js +120 -0
- package/Particles/Node/Blocks/Emitters/cylinderShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/index.d.ts +7 -0
- package/Particles/Node/Blocks/Emitters/index.js +8 -0
- package/Particles/Node/Blocks/Emitters/index.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.d.ts +39 -0
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js +86 -0
- package/Particles/Node/Blocks/Emitters/pointShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.d.ts +53 -0
- package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js +111 -0
- package/Particles/Node/Blocks/Emitters/setupSpriteSheetBlock.js.map +1 -0
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.d.ts +43 -0
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js +108 -0
- package/Particles/Node/Blocks/Emitters/sphereShapeBlock.js.map +1 -0
- package/Particles/Node/Blocks/Teleport/particleTeleportInBlock.d.ts +48 -0
- package/Particles/Node/Blocks/Teleport/particleTeleportInBlock.js +100 -0
- package/Particles/Node/Blocks/Teleport/particleTeleportInBlock.js.map +1 -0
- package/Particles/Node/Blocks/Teleport/particleTeleportOutBlock.d.ts +47 -0
- package/Particles/Node/Blocks/Teleport/particleTeleportOutBlock.js +82 -0
- package/Particles/Node/Blocks/Teleport/particleTeleportOutBlock.js.map +1 -0
- package/Particles/Node/Blocks/Triggers/particleTriggerBlock.d.ts +48 -0
- package/Particles/Node/Blocks/Triggers/particleTriggerBlock.js +133 -0
- package/Particles/Node/Blocks/Triggers/particleTriggerBlock.js.map +1 -0
- package/Particles/Node/Blocks/Triggers/triggerTools.d.ts +9 -0
- package/Particles/Node/Blocks/Triggers/triggerTools.js +16 -0
- package/Particles/Node/Blocks/Triggers/triggerTools.js.map +1 -0
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.d.ts +31 -0
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js +64 -0
- package/Particles/Node/Blocks/Update/basicPositionUpdateBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/basicSpriteUpdateBlock.d.ts +31 -0
- package/Particles/Node/Blocks/Update/basicSpriteUpdateBlock.js +63 -0
- package/Particles/Node/Blocks/Update/basicSpriteUpdateBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/updateAngleBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateAngleBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateAngleBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/updateColorBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateColorBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateColorBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/updateDirectionBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateDirectionBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateDirectionBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.d.ts +41 -0
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.js +102 -0
- package/Particles/Node/Blocks/Update/updateFlowMapBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/updatePositionBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updatePositionBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updatePositionBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/updateScaleBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateScaleBlock.js +73 -0
- package/Particles/Node/Blocks/Update/updateScaleBlock.js.map +1 -0
- package/Particles/Node/Blocks/Update/updateSpriteCellIndexBlock.d.ts +35 -0
- package/Particles/Node/Blocks/Update/updateSpriteCellIndexBlock.js +74 -0
- package/Particles/Node/Blocks/Update/updateSpriteCellIndexBlock.js.map +1 -0
- package/Particles/Node/Blocks/index.d.ts +27 -0
- package/Particles/Node/Blocks/index.js +29 -0
- package/Particles/Node/Blocks/index.js.map +1 -0
- package/Particles/Node/Blocks/particleConverterBlock.d.ts +85 -0
- package/Particles/Node/Blocks/particleConverterBlock.js +267 -0
- package/Particles/Node/Blocks/particleConverterBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleDebugBlock.d.ts +37 -0
- package/Particles/Node/Blocks/particleDebugBlock.js +109 -0
- package/Particles/Node/Blocks/particleDebugBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleElbowBlock.d.ts +27 -0
- package/Particles/Node/Blocks/particleElbowBlock.js +47 -0
- package/Particles/Node/Blocks/particleElbowBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleGradientBlock.d.ts +28 -0
- package/Particles/Node/Blocks/particleGradientBlock.js +118 -0
- package/Particles/Node/Blocks/particleGradientBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleGradientValueBlock.d.ts +32 -0
- package/Particles/Node/Blocks/particleGradientValueBlock.js +79 -0
- package/Particles/Node/Blocks/particleGradientValueBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleInputBlock.d.ts +87 -0
- package/Particles/Node/Blocks/particleInputBlock.js +279 -0
- package/Particles/Node/Blocks/particleInputBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleLerpBlock.d.ts +34 -0
- package/Particles/Node/Blocks/particleLerpBlock.js +92 -0
- package/Particles/Node/Blocks/particleLerpBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleMathBlock.d.ts +64 -0
- package/Particles/Node/Blocks/particleMathBlock.js +321 -0
- package/Particles/Node/Blocks/particleMathBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleRandomBlock.d.ts +52 -0
- package/Particles/Node/Blocks/particleRandomBlock.js +161 -0
- package/Particles/Node/Blocks/particleRandomBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleSourceTextureBlock.d.ts +65 -0
- package/Particles/Node/Blocks/particleSourceTextureBlock.js +173 -0
- package/Particles/Node/Blocks/particleSourceTextureBlock.js.map +1 -0
- package/Particles/Node/Blocks/particleTrigonometryBlock.d.ts +80 -0
- package/Particles/Node/Blocks/particleTrigonometryBlock.js +272 -0
- package/Particles/Node/Blocks/particleTrigonometryBlock.js.map +1 -0
- package/Particles/Node/Blocks/randomRangeBlock.d.ts +45 -0
- package/Particles/Node/Blocks/randomRangeBlock.js +151 -0
- package/Particles/Node/Blocks/randomRangeBlock.js.map +1 -0
- package/Particles/Node/Blocks/systemBlock.d.ts +71 -0
- package/Particles/Node/Blocks/systemBlock.js +193 -0
- package/Particles/Node/Blocks/systemBlock.js.map +1 -0
- package/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes.d.ts +39 -0
- package/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes.js +41 -0
- package/Particles/Node/Enums/nodeParticleBlockConnectionPointTypes.js.map +1 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.d.ts +31 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js +34 -0
- package/Particles/Node/Enums/nodeParticleContextualSources.js.map +1 -0
- package/Particles/Node/Enums/nodeParticleSystemSources.d.ts +13 -0
- package/Particles/Node/Enums/nodeParticleSystemSources.js +15 -0
- package/Particles/Node/Enums/nodeParticleSystemSources.js.map +1 -0
- package/Particles/Node/index.d.ts +8 -0
- package/Particles/Node/index.js +10 -0
- package/Particles/Node/index.js.map +1 -0
- package/Particles/Node/nodeParticleBlock.d.ts +154 -0
- package/Particles/Node/nodeParticleBlock.js +355 -0
- package/Particles/Node/nodeParticleBlock.js.map +1 -0
- package/Particles/Node/nodeParticleBlockConnectionPoint.d.ts +188 -0
- package/Particles/Node/nodeParticleBlockConnectionPoint.js +337 -0
- package/Particles/Node/nodeParticleBlockConnectionPoint.js.map +1 -0
- package/Particles/Node/nodeParticleBuildState.d.ts +89 -0
- package/Particles/Node/nodeParticleBuildState.js +170 -0
- package/Particles/Node/nodeParticleBuildState.js.map +1 -0
- package/Particles/Node/nodeParticleSystemSet.d.ts +120 -0
- package/Particles/Node/nodeParticleSystemSet.js +382 -0
- package/Particles/Node/nodeParticleSystemSet.js.map +1 -0
- package/Particles/Queue/executionQueue.d.ts +2 -0
- package/Particles/Queue/executionQueue.js +10 -0
- package/Particles/Queue/executionQueue.js.map +1 -1
- package/Particles/baseParticleSystem.d.ts +2 -1
- package/Particles/baseParticleSystem.js +1 -0
- package/Particles/baseParticleSystem.js.map +1 -1
- package/Particles/flowMap.d.ts +7 -0
- package/Particles/flowMap.js +32 -0
- package/Particles/flowMap.js.map +1 -1
- package/Particles/gpuParticleSystem.d.ts +4 -0
- package/Particles/gpuParticleSystem.js +4 -0
- package/Particles/gpuParticleSystem.js.map +1 -1
- package/Particles/index.d.ts +1 -0
- package/Particles/index.js +1 -0
- package/Particles/index.js.map +1 -1
- package/Particles/particleSystem.d.ts +12 -0
- package/Particles/particleSystem.js +22 -1
- package/Particles/particleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.d.ts +32 -11
- package/Particles/thinParticleSystem.js +62 -36
- package/Particles/thinParticleSystem.js.map +1 -1
- package/PostProcesses/postProcessManager.d.ts +2 -1
- package/PostProcesses/postProcessManager.js +3 -2
- package/PostProcesses/postProcessManager.js.map +1 -1
- package/Shaders/ShadersInclude/defaultUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/defaultUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/defaultVertexDeclaration.js +1 -0
- package/Shaders/ShadersInclude/defaultVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/lightFragment.js +5 -2
- package/Shaders/ShadersInclude/lightFragment.js.map +1 -1
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrBlockPrePass.js +3 -0
- package/Shaders/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
- package/Shaders/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/Shaders/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js +1 -0
- package/Shaders/ShadersInclude/pbrVertexDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/prePassDeclaration.js +3 -0
- package/Shaders/ShadersInclude/prePassDeclaration.js.map +1 -1
- package/Shaders/ShadersInclude/prePassVertex.js +3 -0
- package/Shaders/ShadersInclude/prePassVertex.js.map +1 -1
- package/Shaders/ShadersInclude/prePassVertexDeclaration.js +3 -0
- package/Shaders/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
- package/Shaders/default.fragment.js +3 -0
- package/Shaders/default.fragment.js.map +1 -1
- package/Shaders/minmaxRedux.fragment.js +13 -5
- package/Shaders/minmaxRedux.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/defaultUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/lightFragment.js +5 -2
- package/ShadersWGSL/ShadersInclude/lightFragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/morphTargetsVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js +3 -0
- package/ShadersWGSL/ShadersInclude/pbrBlockPrePass.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrDirectLightingFunctions.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js +1 -1
- package/ShadersWGSL/ShadersInclude/pbrUboDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/prePassDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertex.js +3 -0
- package/ShadersWGSL/ShadersInclude/prePassVertex.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js +3 -0
- package/ShadersWGSL/ShadersInclude/prePassVertexDeclaration.js.map +1 -1
- package/ShadersWGSL/default.fragment.js +3 -0
- package/ShadersWGSL/default.fragment.js.map +1 -1
- package/ShadersWGSL/minmaxRedux.fragment.js +14 -6
- package/ShadersWGSL/minmaxRedux.fragment.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +5 -0
- package/scene.js +8 -0
- package/scene.js.map +1 -1
|
@@ -44,6 +44,13 @@ export declare class GeometryTextureBlock extends NodeGeometryBlock {
|
|
|
44
44
|
* Remove stored data
|
|
45
45
|
*/
|
|
46
46
|
cleanData(): void;
|
|
47
|
+
/**
|
|
48
|
+
* Load the texture data from a Float32Array
|
|
49
|
+
* @param data defines the data to load
|
|
50
|
+
* @param width defines the width of the texture
|
|
51
|
+
* @param height defines the height of the texture
|
|
52
|
+
*/
|
|
53
|
+
loadTextureFromData(data: Float32Array, width: number, height: number): void;
|
|
47
54
|
/**
|
|
48
55
|
* Load the texture data
|
|
49
56
|
* @param imageFile defines the file to load data from
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { __decorate } from "../../../../tslib.es6.js";
|
|
2
1
|
import { RegisterClass } from "../../../../Misc/typeStore.js";
|
|
3
2
|
import { NodeGeometryBlockConnectionPointTypes } from "../../Enums/nodeGeometryConnectionPointTypes.js";
|
|
4
3
|
import { NodeGeometryBlock } from "../../nodeGeometryBlock.js";
|
|
5
4
|
import { TextureTools } from "../../../../Misc/textureTools.js";
|
|
6
|
-
import { editableInPropertyPage } from "../../../../Decorators/nodeDecorator.js";
|
|
7
5
|
/**
|
|
8
6
|
* Block used to load texture data
|
|
9
7
|
*/
|
|
@@ -85,6 +83,17 @@ export class GeometryTextureBlock extends NodeGeometryBlock {
|
|
|
85
83
|
cleanData() {
|
|
86
84
|
this._data = null;
|
|
87
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Load the texture data from a Float32Array
|
|
88
|
+
* @param data defines the data to load
|
|
89
|
+
* @param width defines the width of the texture
|
|
90
|
+
* @param height defines the height of the texture
|
|
91
|
+
*/
|
|
92
|
+
loadTextureFromData(data, width, height) {
|
|
93
|
+
this._data = data;
|
|
94
|
+
this._width = width;
|
|
95
|
+
this._height = height;
|
|
96
|
+
}
|
|
88
97
|
/**
|
|
89
98
|
* Load the texture data
|
|
90
99
|
* @param imageFile defines the file to load data from
|
|
@@ -178,8 +187,5 @@ export class GeometryTextureBlock extends NodeGeometryBlock {
|
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
189
|
}
|
|
181
|
-
__decorate([
|
|
182
|
-
editableInPropertyPage("Serialize cached data", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { embedded: true, notifiers: { rebuild: true } })
|
|
183
|
-
], GeometryTextureBlock.prototype, "serializedCachedData", void 0);
|
|
184
190
|
RegisterClass("BABYLON.GeometryTextureBlock", GeometryTextureBlock);
|
|
185
191
|
//# sourceMappingURL=geometryTextureBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryTextureBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Textures/geometryTextureBlock.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,yCAA+B;AACtD,OAAO,EAA0B,sBAAsB,EAAE,gDAAsC;AAC/F;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IAWvD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QApCR,UAAK,GAA2B,IAAI,CAAC;QAI7C;;WAEG;QAEI,yBAAoB,GAAG,KAAK,CAAC;QA8BhC,IAAI,CAAC,cAAc,CAAC,SAAS,EAAE,qCAAqC,CAAC,OAAO,CAAC,CAAC;IAClF,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,OAAO,sBAAsB,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,C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,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1C,mBAAmB,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtD,CAAC;QAED,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,MAAM,GAAG,mBAAmB,CAAC,KAAK,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,MAAM,CAAC;QAC1C,IAAI,mBAAmB,CAAC,IAAI,EAAE,CAAC;YAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,YAAY,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;YACxD,IAAI,CAAC,oBAAoB,GAAG,IAAI,CAAC;QACrC,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,oBAAoB,GAAG,CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QAC3E,CAAC;IACL,CAAC;CACJ;AA/LU;IADN,sBAAsB,CAAC,uBAAuB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;kEAC1G;AAiMxC,aAAa,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { INodeGeometryTextureData } from \"../../Interfaces/nodeGeometryTextureData\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { TextureTools } from \"core/Misc/textureTools\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\n/**\r\n * Block used to load texture data\r\n */\r\nexport class GeometryTextureBlock extends NodeGeometryBlock {\r\n private _data: Nullable<Float32Array> = null;\r\n private _width: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block should serialize its cached data\r\n */\r\n @editableInPropertyPage(\"Serialize cached data\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public serializedCachedData = false;\r\n\r\n /**\r\n * Gets the texture data\r\n */\r\n public get textureData(): Nullable<Float32Array> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets the texture width\r\n */\r\n public get textureWidth() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * Gets the texture height\r\n */\r\n public get textureHeight() {\r\n return this._height;\r\n }\r\n\r\n /**\r\n * Creates a new GeometryTextureBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerOutput(\"texture\", NodeGeometryBlockConnectionPointTypes.Texture);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GeometryTextureBlock\";\r\n }\r\n\r\n /**\r\n * Gets the texture component\r\n */\r\n public get texture(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private async _prepareImgToLoadAsync(url: string) {\r\n return await new Promise<void>((resolve, reject) => {\r\n const img = new Image();\r\n const canvas = document.createElement(\"canvas\");\r\n const ctx = canvas.getContext(\"2d\");\r\n\r\n img.onload = () => {\r\n canvas.width = img.width;\r\n canvas.height = img.height;\r\n\r\n ctx!.drawImage(img, 0, 0);\r\n\r\n const imageData = ctx!.getImageData(0, 0, img.width, img.height);\r\n const pixels = imageData.data;\r\n const floatArray = new Float32Array(pixels.length);\r\n\r\n for (let i = 0; i < pixels.length; i++) {\r\n floatArray[i] = pixels[i] / 255.0;\r\n }\r\n\r\n this._data = floatArray;\r\n this._width = img.width;\r\n this._height = img.height;\r\n resolve();\r\n };\r\n\r\n img.onerror = () => {\r\n this._data = null;\r\n reject(new Error(\"Failed to load image\"));\r\n };\r\n\r\n img.src = url;\r\n });\r\n }\r\n\r\n /**\r\n * Remove stored data\r\n */\r\n public cleanData() {\r\n this._data = null;\r\n }\r\n\r\n /**\r\n * Load the texture data\r\n * @param imageFile defines the file to load data from\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public async loadTextureFromFileAsync(imageFile: File) {\r\n return await this._prepareImgToLoadAsync(URL.createObjectURL(imageFile));\r\n }\r\n\r\n /**\r\n * Load the texture data\r\n * @param url defines the url to load data from\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public async loadTextureFromUrlAsync(url: string) {\r\n return await this._prepareImgToLoadAsync(url);\r\n }\r\n\r\n /**\r\n * Load the texture data\r\n * @param texture defines the source texture\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public async extractFromTextureAsync(texture: Texture) {\r\n return await new Promise<void>((resolve, reject) => {\r\n if (!texture.isReady()) {\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n texture.onLoadObservable.addOnce(async () => {\r\n try {\r\n await this.extractFromTextureAsync(texture);\r\n resolve();\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(e);\r\n }\r\n });\r\n return;\r\n }\r\n const size = texture.getSize();\r\n TextureTools.GetTextureDataAsync(texture, size.width, size.height)\r\n // eslint-disable-next-line github/no-then\r\n .then((data) => {\r\n const floatArray = new Float32Array(data.length);\r\n\r\n for (let i = 0; i < data.length; i++) {\r\n floatArray[i] = data[i] / 255.0;\r\n }\r\n this._data = floatArray;\r\n this._width = size.width;\r\n this._height = size.height;\r\n resolve();\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n });\r\n }\r\n\r\n protected override _buildBlock() {\r\n if (!this._data) {\r\n this.texture._storedValue = null;\r\n return;\r\n }\r\n\r\n const textureData: INodeGeometryTextureData = {\r\n data: this._data,\r\n width: this._width,\r\n height: this._height,\r\n };\r\n\r\n this.texture._storedValue = textureData;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.width = this._width;\r\n serializationObject.height = this._height;\r\n serializationObject.serializedCachedData = this.serializedCachedData;\r\n if (this._data && this.serializedCachedData) {\r\n serializationObject.data = Array.from(this._data);\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this._width = serializationObject.width;\r\n this._height = serializationObject.height;\r\n if (serializationObject.data) {\r\n this._data = new Float32Array(serializationObject.data);\r\n this.serializedCachedData = true;\r\n } else {\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTextureBlock\", GeometryTextureBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryTextureBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Textures/geometryTextureBlock.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AAErG,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,EAAE,YAAY,EAAE,yCAA+B;AACtD;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,iBAAiB;IAUvD;;OAEG;IACH,IAAW,WAAW;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAW,YAAY;QACnB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,IAAW,aAAa;QACpB,O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CAAC,CAAC,mBAAmB,CAAC,oBAAoB,CAAC;QAC3E,CAAC;IACL,CAAC;CACJ;AAED,aAAa,CAAC,8BAA8B,EAAE,oBAAoB,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { INodeGeometryTextureData } from \"../../Interfaces/nodeGeometryTextureData\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { TextureTools } from \"core/Misc/textureTools\";\r\n/**\r\n * Block used to load texture data\r\n */\r\nexport class GeometryTextureBlock extends NodeGeometryBlock {\r\n private _data: Nullable<Float32Array> = null;\r\n private _width: number;\r\n private _height: number;\r\n\r\n /**\r\n * Gets or sets a boolean indicating that this block should serialize its cached data\r\n */\r\n public serializedCachedData = false;\r\n\r\n /**\r\n * Gets the texture data\r\n */\r\n public get textureData(): Nullable<Float32Array> {\r\n return this._data;\r\n }\r\n\r\n /**\r\n * Gets the texture width\r\n */\r\n public get textureWidth() {\r\n return this._width;\r\n }\r\n\r\n /**\r\n * Gets the texture height\r\n */\r\n public get textureHeight() {\r\n return this._height;\r\n }\r\n\r\n /**\r\n * Creates a new GeometryTextureBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerOutput(\"texture\", NodeGeometryBlockConnectionPointTypes.Texture);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GeometryTextureBlock\";\r\n }\r\n\r\n /**\r\n * Gets the texture component\r\n */\r\n public get texture(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n private async _prepareImgToLoadAsync(url: string) {\r\n return await new Promise<void>((resolve, reject) => {\r\n const img = new Image();\r\n const canvas = document.createElement(\"canvas\");\r\n const ctx = canvas.getContext(\"2d\");\r\n\r\n img.onload = () => {\r\n canvas.width = img.width;\r\n canvas.height = img.height;\r\n\r\n ctx!.drawImage(img, 0, 0);\r\n\r\n const imageData = ctx!.getImageData(0, 0, img.width, img.height);\r\n const pixels = imageData.data;\r\n const floatArray = new Float32Array(pixels.length);\r\n\r\n for (let i = 0; i < pixels.length; i++) {\r\n floatArray[i] = pixels[i] / 255.0;\r\n }\r\n\r\n this._data = floatArray;\r\n this._width = img.width;\r\n this._height = img.height;\r\n resolve();\r\n };\r\n\r\n img.onerror = () => {\r\n this._data = null;\r\n reject(new Error(\"Failed to load image\"));\r\n };\r\n\r\n img.src = url;\r\n });\r\n }\r\n\r\n /**\r\n * Remove stored data\r\n */\r\n public cleanData() {\r\n this._data = null;\r\n }\r\n\r\n /**\r\n * Load the texture data from a Float32Array\r\n * @param data defines the data to load\r\n * @param width defines the width of the texture\r\n * @param height defines the height of the texture\r\n */\r\n public loadTextureFromData(data: Float32Array, width: number, height: number) {\r\n this._data = data;\r\n this._width = width;\r\n this._height = height;\r\n }\r\n\r\n /**\r\n * Load the texture data\r\n * @param imageFile defines the file to load data from\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public async loadTextureFromFileAsync(imageFile: File) {\r\n return await this._prepareImgToLoadAsync(URL.createObjectURL(imageFile));\r\n }\r\n\r\n /**\r\n * Load the texture data\r\n * @param url defines the url to load data from\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public async loadTextureFromUrlAsync(url: string) {\r\n return await this._prepareImgToLoadAsync(url);\r\n }\r\n\r\n /**\r\n * Load the texture data\r\n * @param texture defines the source texture\r\n * @returns a promise fulfilled when image data is loaded\r\n */\r\n public async extractFromTextureAsync(texture: Texture) {\r\n return await new Promise<void>((resolve, reject) => {\r\n if (!texture.isReady()) {\r\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\r\n texture.onLoadObservable.addOnce(async () => {\r\n try {\r\n await this.extractFromTextureAsync(texture);\r\n resolve();\r\n } catch (e) {\r\n // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors\r\n reject(e);\r\n }\r\n });\r\n return;\r\n }\r\n const size = texture.getSize();\r\n TextureTools.GetTextureDataAsync(texture, size.width, size.height)\r\n // eslint-disable-next-line github/no-then\r\n .then((data) => {\r\n const floatArray = new Float32Array(data.length);\r\n\r\n for (let i = 0; i < data.length; i++) {\r\n floatArray[i] = data[i] / 255.0;\r\n }\r\n this._data = floatArray;\r\n this._width = size.width;\r\n this._height = size.height;\r\n resolve();\r\n })\r\n // eslint-disable-next-line github/no-then\r\n .catch(reject);\r\n });\r\n }\r\n\r\n protected override _buildBlock() {\r\n if (!this._data) {\r\n this.texture._storedValue = null;\r\n return;\r\n }\r\n\r\n const textureData: INodeGeometryTextureData = {\r\n data: this._data,\r\n width: this._width,\r\n height: this._height,\r\n };\r\n\r\n this.texture._storedValue = textureData;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.width = this._width;\r\n serializationObject.height = this._height;\r\n serializationObject.serializedCachedData = this.serializedCachedData;\r\n if (this._data && this.serializedCachedData) {\r\n serializationObject.data = Array.from(this._data);\r\n }\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this._width = serializationObject.width;\r\n this._height = serializationObject.height;\r\n if (serializationObject.data) {\r\n this._data = new Float32Array(serializationObject.data);\r\n this.serializedCachedData = true;\r\n } else {\r\n this.serializedCachedData = !!serializationObject.serializedCachedData;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTextureBlock\", GeometryTextureBlock);\r\n"]}
|
|
@@ -8,6 +8,10 @@ export declare class GeometryTextureFetchBlock extends NodeGeometryBlock {
|
|
|
8
8
|
* Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1
|
|
9
9
|
*/
|
|
10
10
|
clampCoordinates: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1
|
|
13
|
+
*/
|
|
14
|
+
interpolation: boolean;
|
|
11
15
|
/**
|
|
12
16
|
* Creates a new GeometryTextureFetchBlock
|
|
13
17
|
* @param name defines the block name
|
|
@@ -51,6 +55,8 @@ export declare class GeometryTextureFetchBlock extends NodeGeometryBlock {
|
|
|
51
55
|
*/
|
|
52
56
|
get a(): NodeGeometryConnectionPoint;
|
|
53
57
|
private _repeatClamp;
|
|
58
|
+
private _lerp;
|
|
59
|
+
private _getPixel;
|
|
54
60
|
protected _buildBlock(): void;
|
|
55
61
|
protected _dumpPropertiesCode(): string;
|
|
56
62
|
/**
|
|
@@ -18,6 +18,10 @@ export class GeometryTextureFetchBlock extends NodeGeometryBlock {
|
|
|
18
18
|
* Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1
|
|
19
19
|
*/
|
|
20
20
|
this.clampCoordinates = true;
|
|
21
|
+
/**
|
|
22
|
+
* Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1
|
|
23
|
+
*/
|
|
24
|
+
this.interpolation = true;
|
|
21
25
|
this.registerInput("texture", NodeGeometryBlockConnectionPointTypes.Texture);
|
|
22
26
|
this.registerInput("coordinates", NodeGeometryBlockConnectionPointTypes.Vector2);
|
|
23
27
|
this.registerOutput("rgba", NodeGeometryBlockConnectionPointTypes.Vector4);
|
|
@@ -90,6 +94,13 @@ export class GeometryTextureFetchBlock extends NodeGeometryBlock {
|
|
|
90
94
|
return 1 - (Math.abs(num) % 1);
|
|
91
95
|
}
|
|
92
96
|
}
|
|
97
|
+
_lerp(a, b, t) {
|
|
98
|
+
return new Vector4(a.x * (1 - t) + b.x * t, a.y * (1 - t) + b.y * t, a.z * (1 - t) + b.z * t, a.w * (1 - t) + b.w * t);
|
|
99
|
+
}
|
|
100
|
+
_getPixel(ix, iy, data, width) {
|
|
101
|
+
const i = (iy * width + ix) * 4;
|
|
102
|
+
return new Vector4(data[i], data[i + 1], data[i + 2], data[i + 3]);
|
|
103
|
+
}
|
|
93
104
|
_buildBlock() {
|
|
94
105
|
const func = (state) => {
|
|
95
106
|
const textureData = this.texture.getConnectedValue(state);
|
|
@@ -102,10 +113,30 @@ export class GeometryTextureFetchBlock extends NodeGeometryBlock {
|
|
|
102
113
|
}
|
|
103
114
|
const u = this.clampCoordinates ? Math.max(0, Math.min(uv.x, 1.0)) : this._repeatClamp(uv.x);
|
|
104
115
|
const v = this.clampCoordinates ? Math.max(0, Math.min(uv.y, 1.0)) : this._repeatClamp(uv.y);
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
116
|
+
const width = textureData.width;
|
|
117
|
+
const height = textureData.height;
|
|
118
|
+
const data = textureData.data;
|
|
119
|
+
// Convert UV to texel space
|
|
120
|
+
const x = u * (width - 1);
|
|
121
|
+
const y = v * (height - 1);
|
|
122
|
+
if (this.interpolation) {
|
|
123
|
+
const x0 = Math.floor(x);
|
|
124
|
+
const y0 = Math.floor(y);
|
|
125
|
+
const x1 = Math.min(x0 + 1, width - 1);
|
|
126
|
+
const y1 = Math.min(y0 + 1, height - 1);
|
|
127
|
+
const dx = x - x0;
|
|
128
|
+
const dy = y - y0;
|
|
129
|
+
const c00 = this._getPixel(x0, y0, data, width);
|
|
130
|
+
const c10 = this._getPixel(x1, y0, data, width);
|
|
131
|
+
const c01 = this._getPixel(x0, y1, data, width);
|
|
132
|
+
const c11 = this._getPixel(x1, y1, data, width);
|
|
133
|
+
// Interpolate horizontally
|
|
134
|
+
const top = this._lerp(c00, c10, dx);
|
|
135
|
+
const bottom = this._lerp(c01, c11, dx);
|
|
136
|
+
// Interpolate vertically
|
|
137
|
+
return this._lerp(top, bottom, dy);
|
|
138
|
+
}
|
|
139
|
+
return this._getPixel(Math.floor(x), Math.floor(y), data, width);
|
|
109
140
|
};
|
|
110
141
|
this.rgba._storedFunction = (state) => {
|
|
111
142
|
return func(state);
|
|
@@ -142,15 +173,22 @@ export class GeometryTextureFetchBlock extends NodeGeometryBlock {
|
|
|
142
173
|
serialize() {
|
|
143
174
|
const serializationObject = super.serialize();
|
|
144
175
|
serializationObject.clampCoordinates = this.clampCoordinates;
|
|
176
|
+
serializationObject.interpolation = this.interpolation;
|
|
145
177
|
return serializationObject;
|
|
146
178
|
}
|
|
147
179
|
_deserialize(serializationObject) {
|
|
148
180
|
super._deserialize(serializationObject);
|
|
149
181
|
this.clampCoordinates = serializationObject.clampCoordinates;
|
|
182
|
+
if (serializationObject.clampCoordinates === undefined) {
|
|
183
|
+
this.interpolation = serializationObject.interpolation;
|
|
184
|
+
}
|
|
150
185
|
}
|
|
151
186
|
}
|
|
152
187
|
__decorate([
|
|
153
188
|
editableInPropertyPage("Clamp Coordinates", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { embedded: true, notifiers: { rebuild: true } })
|
|
154
189
|
], GeometryTextureFetchBlock.prototype, "clampCoordinates", void 0);
|
|
190
|
+
__decorate([
|
|
191
|
+
editableInPropertyPage("Interpolation", 0 /* PropertyTypeForEdition.Boolean */, "ADVANCED", { embedded: true, notifiers: { rebuild: true } })
|
|
192
|
+
], GeometryTextureFetchBlock.prototype, "interpolation", void 0);
|
|
155
193
|
RegisterClass("BABYLON.GeometryTextureFetchBlock", GeometryTextureFetchBlock);
|
|
156
194
|
//# sourceMappingURL=geometryTextureFetchBlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryTextureFetchBlock.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/Meshes/Node/Blocks/Textures/geometryTextureFetchBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAgB,yCAA+B;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CA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BAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;IACjE,CAAC;CACJ;AAtKU;IADN,sBAAsB,CAAC,mBAAmB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;mEAC3G;AAwKnC,aAAa,CAAC,mCAAmC,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { Vector4, type Vector2 } from \"core/Maths/math.vector\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { INodeGeometryTextureData } from \"../../Interfaces/nodeGeometryTextureData\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Block used to fetch a color from texture data\r\n */\r\nexport class GeometryTextureFetchBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1\r\n */\r\n @editableInPropertyPage(\"Clamp Coordinates\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public clampCoordinates = true;\r\n\r\n /**\r\n * Creates a new GeometryTextureFetchBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"texture\", NodeGeometryBlockConnectionPointTypes.Texture);\r\n this.registerInput(\"coordinates\", NodeGeometryBlockConnectionPointTypes.Vector2);\r\n this.registerOutput(\"rgba\", NodeGeometryBlockConnectionPointTypes.Vector4);\r\n this.registerOutput(\"rgb\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n this.registerOutput(\"r\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"g\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"b\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"a\", NodeGeometryBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GeometryTextureFetchBlock\";\r\n }\r\n\r\n /**\r\n * Gets the texture component\r\n */\r\n public get texture(): NodeGeometryConnectionPoint {\r\n return this.inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the coordinates component\r\n */\r\n public get coordinates(): NodeGeometryConnectionPoint {\r\n return this.inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the rgba component\r\n */\r\n public get rgba(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgb component\r\n */\r\n public get rgb(): NodeGeometryConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Gets the r component\r\n */\r\n public get r(): NodeGeometryConnectionPoint {\r\n return this._outputs[2];\r\n }\r\n\r\n /**\r\n * Gets the g component\r\n */\r\n public get g(): NodeGeometryConnectionPoint {\r\n return this._outputs[3];\r\n }\r\n\r\n /**\r\n * Gets the b component\r\n */\r\n public get b(): NodeGeometryConnectionPoint {\r\n return this._outputs[4];\r\n }\r\n\r\n /**\r\n * Gets the a component\r\n */\r\n public get a(): NodeGeometryConnectionPoint {\r\n return this._outputs[5];\r\n }\r\n\r\n private _repeatClamp(num: number) {\r\n if (num >= 0) {\r\n return num % 1;\r\n } else {\r\n return 1 - (Math.abs(num) % 1);\r\n }\r\n }\r\n\r\n protected override _buildBlock() {\r\n const func = (state: NodeGeometryBuildState) => {\r\n const textureData = this.texture.getConnectedValue(state) as INodeGeometryTextureData;\r\n if (!textureData || !textureData.data) {\r\n return null;\r\n }\r\n\r\n const uv = this.coordinates.getConnectedValue(state) as Vector2;\r\n\r\n if (!uv) {\r\n return null;\r\n }\r\n\r\n const u = this.clampCoordinates ? Math.max(0, Math.min(uv.x, 1.0)) : this._repeatClamp(uv.x);\r\n const v = this.clampCoordinates ? Math.max(0, Math.min(uv.y, 1.0)) : this._repeatClamp(uv.y);\r\n\r\n const x = Math.floor(u * (textureData.width - 1));\r\n const y = Math.floor(v * (textureData.height - 1));\r\n const index = x + textureData.width * y;\r\n\r\n return Vector4.FromArray(textureData.data, index * 4);\r\n };\r\n\r\n this.rgba._storedFunction = (state) => {\r\n return func(state);\r\n };\r\n\r\n this.rgb._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.toVector3() : null;\r\n };\r\n\r\n this.r._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.x : null;\r\n };\r\n\r\n this.g._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.y : null;\r\n };\r\n\r\n this.b._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.z : null;\r\n };\r\n\r\n this.a._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.w : null;\r\n };\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.clampCoordinates = ${this.clampCoordinates};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.clampCoordinates = this.clampCoordinates;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.clampCoordinates = serializationObject.clampCoordinates;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTextureFetchBlock\", GeometryTextureFetchBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryTextureFetchBlock.js","s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,CAAC,gBAAgB,GAAG,mBAAmB,CAAC,gBAAgB,CAAC;QAC7D,IAAI,mBAAmB,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;YACrD,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC,aAAa,CAAC;QAC3D,CAAC;IACL,CAAC;CACJ;AAlNU;IADN,sBAAsB,CAAC,mBAAmB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;mEAC3G;AAMxB;IADN,sBAAsB,CAAC,eAAe,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;gEAC1G;AA8MhC,aAAa,CAAC,mCAAmC,EAAE,yBAAyB,CAAC,CAAC","sourcesContent":["import { Vector4, type Vector2 } from \"core/Maths/math.vector\";\r\nimport { RegisterClass } from \"../../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../../Enums/nodeGeometryConnectionPointTypes\";\r\nimport type { INodeGeometryTextureData } from \"../../Interfaces/nodeGeometryTextureData\";\r\nimport { NodeGeometryBlock } from \"../../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../../nodeGeometryBlockConnectionPoint\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"core/Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../../nodeGeometryBuildState\";\r\n\r\n/**\r\n * Block used to fetch a color from texture data\r\n */\r\nexport class GeometryTextureFetchBlock extends NodeGeometryBlock {\r\n /**\r\n * Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1\r\n */\r\n @editableInPropertyPage(\"Clamp Coordinates\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public clampCoordinates = true;\r\n\r\n /**\r\n * Gets or sets a boolean indicating if coordinates should be clamped between 0 and 1\r\n */\r\n @editableInPropertyPage(\"Interpolation\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public interpolation = true;\r\n\r\n /**\r\n * Creates a new GeometryTextureFetchBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"texture\", NodeGeometryBlockConnectionPointTypes.Texture);\r\n this.registerInput(\"coordinates\", NodeGeometryBlockConnectionPointTypes.Vector2);\r\n this.registerOutput(\"rgba\", NodeGeometryBlockConnectionPointTypes.Vector4);\r\n this.registerOutput(\"rgb\", NodeGeometryBlockConnectionPointTypes.Vector3);\r\n this.registerOutput(\"r\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"g\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"b\", NodeGeometryBlockConnectionPointTypes.Float);\r\n this.registerOutput(\"a\", NodeGeometryBlockConnectionPointTypes.Float);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GeometryTextureFetchBlock\";\r\n }\r\n\r\n /**\r\n * Gets the texture component\r\n */\r\n public get texture(): NodeGeometryConnectionPoint {\r\n return this.inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the coordinates component\r\n */\r\n public get coordinates(): NodeGeometryConnectionPoint {\r\n return this.inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the rgba component\r\n */\r\n public get rgba(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n /**\r\n * Gets the rgb component\r\n */\r\n public get rgb(): NodeGeometryConnectionPoint {\r\n return this._outputs[1];\r\n }\r\n\r\n /**\r\n * Gets the r component\r\n */\r\n public get r(): NodeGeometryConnectionPoint {\r\n return this._outputs[2];\r\n }\r\n\r\n /**\r\n * Gets the g component\r\n */\r\n public get g(): NodeGeometryConnectionPoint {\r\n return this._outputs[3];\r\n }\r\n\r\n /**\r\n * Gets the b component\r\n */\r\n public get b(): NodeGeometryConnectionPoint {\r\n return this._outputs[4];\r\n }\r\n\r\n /**\r\n * Gets the a component\r\n */\r\n public get a(): NodeGeometryConnectionPoint {\r\n return this._outputs[5];\r\n }\r\n\r\n private _repeatClamp(num: number) {\r\n if (num >= 0) {\r\n return num % 1;\r\n } else {\r\n return 1 - (Math.abs(num) % 1);\r\n }\r\n }\r\n\r\n private _lerp(a: Vector4, b: Vector4, t: number) {\r\n return new Vector4(a.x * (1 - t) + b.x * t, a.y * (1 - t) + b.y * t, a.z * (1 - t) + b.z * t, a.w * (1 - t) + b.w * t);\r\n }\r\n\r\n private _getPixel(ix: number, iy: number, data: Float32Array, width: number): Vector4 {\r\n const i = (iy * width + ix) * 4;\r\n return new Vector4(data[i], data[i + 1], data[i + 2], data[i + 3]);\r\n }\r\n\r\n protected override _buildBlock() {\r\n const func = (state: NodeGeometryBuildState) => {\r\n const textureData = this.texture.getConnectedValue(state) as INodeGeometryTextureData;\r\n if (!textureData || !textureData.data) {\r\n return null;\r\n }\r\n\r\n const uv = this.coordinates.getConnectedValue(state) as Vector2;\r\n\r\n if (!uv) {\r\n return null;\r\n }\r\n\r\n const u = this.clampCoordinates ? Math.max(0, Math.min(uv.x, 1.0)) : this._repeatClamp(uv.x);\r\n const v = this.clampCoordinates ? Math.max(0, Math.min(uv.y, 1.0)) : this._repeatClamp(uv.y);\r\n const width = textureData.width;\r\n const height = textureData.height;\r\n const data = textureData.data;\r\n\r\n // Convert UV to texel space\r\n const x = u * (width - 1);\r\n const y = v * (height - 1);\r\n\r\n if (this.interpolation) {\r\n const x0 = Math.floor(x);\r\n const y0 = Math.floor(y);\r\n const x1 = Math.min(x0 + 1, width - 1);\r\n const y1 = Math.min(y0 + 1, height - 1);\r\n\r\n const dx = x - x0;\r\n const dy = y - y0;\r\n\r\n const c00 = this._getPixel(x0, y0, data, width);\r\n const c10 = this._getPixel(x1, y0, data, width);\r\n const c01 = this._getPixel(x0, y1, data, width);\r\n const c11 = this._getPixel(x1, y1, data, width);\r\n\r\n // Interpolate horizontally\r\n const top = this._lerp(c00, c10, dx);\r\n const bottom = this._lerp(c01, c11, dx);\r\n\r\n // Interpolate vertically\r\n return this._lerp(top, bottom, dy);\r\n }\r\n\r\n return this._getPixel(Math.floor(x), Math.floor(y), data, width);\r\n };\r\n\r\n this.rgba._storedFunction = (state) => {\r\n return func(state);\r\n };\r\n\r\n this.rgb._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.toVector3() : null;\r\n };\r\n\r\n this.r._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.x : null;\r\n };\r\n\r\n this.g._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.y : null;\r\n };\r\n\r\n this.b._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.z : null;\r\n };\r\n\r\n this.a._storedFunction = (state) => {\r\n const color = func(state) as Vector4;\r\n return color ? color.w : null;\r\n };\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n const codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.clampCoordinates = ${this.clampCoordinates};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.clampCoordinates = this.clampCoordinates;\r\n serializationObject.interpolation = this.interpolation;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.clampCoordinates = serializationObject.clampCoordinates;\r\n if (serializationObject.clampCoordinates === undefined) {\r\n this.interpolation = serializationObject.interpolation;\r\n }\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryTextureFetchBlock\", GeometryTextureFetchBlock);\r\n"]}
|
|
@@ -87,6 +87,7 @@ export class GeometryOptimizeBlock extends NodeGeometryBlock {
|
|
|
87
87
|
const vertexData = this.geometry.getConnectedValue(state);
|
|
88
88
|
const newPositions = [];
|
|
89
89
|
const newIndicesMap = {};
|
|
90
|
+
const newUVs = [];
|
|
90
91
|
state.pushExecutionContext(this);
|
|
91
92
|
state.pushGeometryContext(vertexData);
|
|
92
93
|
// Optimize positions
|
|
@@ -101,6 +102,9 @@ export class GeometryOptimizeBlock extends NodeGeometryBlock {
|
|
|
101
102
|
const x = vertexData.positions[index];
|
|
102
103
|
const y = vertexData.positions[index + 1];
|
|
103
104
|
const z = vertexData.positions[index + 2];
|
|
105
|
+
const uvIndex = (index / 3) * 2;
|
|
106
|
+
const u = vertexData.uvs ? vertexData.uvs[uvIndex] : 0;
|
|
107
|
+
const v = vertexData.uvs ? vertexData.uvs[uvIndex + 1] : 0;
|
|
104
108
|
// check if we already have it
|
|
105
109
|
let found = false;
|
|
106
110
|
for (let checkIndex = 0; checkIndex < newPositions.length; checkIndex += 3) {
|
|
@@ -115,10 +119,14 @@ export class GeometryOptimizeBlock extends NodeGeometryBlock {
|
|
|
115
119
|
if (!found) {
|
|
116
120
|
newIndicesMap[index / 3] = newPositions.length / 3;
|
|
117
121
|
newPositions.push(x, y, z);
|
|
122
|
+
newUVs.push(u, v);
|
|
118
123
|
}
|
|
119
124
|
}
|
|
120
125
|
const newVertexData = new VertexData();
|
|
121
126
|
newVertexData.positions = newPositions;
|
|
127
|
+
if (vertexData.uvs) {
|
|
128
|
+
newVertexData.uvs = newUVs;
|
|
129
|
+
}
|
|
122
130
|
const indices = vertexData.indices.map((index) => newIndicesMap[index]);
|
|
123
131
|
const newIndices = [];
|
|
124
132
|
if (this.optimizeFaces) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometryOptimizeBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryOptimizeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAA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,IAAI,CAAC,aAAa,CAAC;QAEvD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAEe,YAAY,CAAC,mBAAwB;QACjD,KAAK,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;QAExC,IAAI,CAAC,eAAe,GAAG,mBAAmB,CAAC,eAAe,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC,aAAa,CAAC;IAC3D,CAAC;CACJ;AAnNU;IADN,sBAAsB,CAAC,kBAAkB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;8DAC3G;AAMvB;IADN,sBAAsB,CAAC,SAAS,wCAAgC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;sDACrG;AAMlB;IADN,sBAAsB,CAAC,gBAAgB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC1G;AAyMjC,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport type { FloatArray } from \"../../../types\";\r\nimport { VertexData } from \"../../../Meshes/mesh.vertexData\";\r\nimport { WithinEpsilon } from \"../../../Maths/math.scalar.functions\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\nimport type { INodeGeometryExecutionContext } from \"../Interfaces/nodeGeometryExecutionContext\";\r\n/**\r\n * Block used to extract unique positions from a geometry\r\n */\r\nexport class GeometryOptimizeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _currentIndex: number;\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Define the epsilon used to compare similar positions\r\n */\r\n @editableInPropertyPage(\"Epsilon\", PropertyTypeForEdition.Float, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public epsilon = Epsilon;\r\n\r\n /**\r\n * Optimize faces (by removing duplicates)\r\n */\r\n @editableInPropertyPage(\"Optimize faces\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public optimizeFaces = false;\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Creates a new GeometryOptimizeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"selector\", NodeGeometryBlockConnectionPointTypes.Int, true);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GeometryOptimizeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the selector component\r\n */\r\n public get selector(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n if (!this.geometry.isConnected) {\r\n return null;\r\n }\r\n const vertexData = this.geometry.getConnectedValue(state);\r\n const newPositions: FloatArray = [];\r\n const newIndicesMap: { [key: number]: number } = {};\r\n state.pushExecutionContext(this);\r\n state.pushGeometryContext(vertexData);\r\n\r\n // Optimize positions\r\n for (let index = 0; index < vertexData.positions.length; index += 3) {\r\n this._currentIndex = index / 3;\r\n\r\n if (this.selector.isConnected) {\r\n const selector = this.selector.getConnectedValue(state);\r\n if (!selector) {\r\n continue;\r\n }\r\n }\r\n\r\n const x = vertexData.positions[index];\r\n const y = vertexData.positions[index + 1];\r\n const z = vertexData.positions[index + 2];\r\n\r\n // check if we already have it\r\n let found = false;\r\n for (let checkIndex = 0; checkIndex < newPositions.length; checkIndex += 3) {\r\n if (\r\n WithinEpsilon(x, newPositions[checkIndex], this.epsilon) &&\r\n WithinEpsilon(y, newPositions[checkIndex + 1], this.epsilon) &&\r\n WithinEpsilon(z, newPositions[checkIndex + 2], this.epsilon)\r\n ) {\r\n newIndicesMap[index / 3] = checkIndex / 3;\r\n found = true;\r\n continue;\r\n }\r\n }\r\n\r\n if (!found) {\r\n newIndicesMap[index / 3] = newPositions.length / 3;\r\n newPositions.push(x, y, z);\r\n }\r\n }\r\n const newVertexData = new VertexData();\r\n newVertexData.positions = newPositions;\r\n const indices: number[] = vertexData.indices.map((index: number) => newIndicesMap[index]);\r\n const newIndices: number[] = [];\r\n\r\n if (this.optimizeFaces) {\r\n // Optimize indices\r\n for (let index = 0; index < indices.length; index += 3) {\r\n const a = indices[index];\r\n const b = indices[index + 1];\r\n const c = indices[index + 2];\r\n\r\n if (a === b || b == c || c === a) {\r\n continue;\r\n }\r\n\r\n // check if we already have it\r\n let found = false;\r\n for (let checkIndex = 0; checkIndex < newIndices.length; checkIndex += 3) {\r\n if (a === newIndices[checkIndex] && b === newIndices[checkIndex + 1] && c === newIndices[checkIndex + 2]) {\r\n found = true;\r\n continue;\r\n }\r\n\r\n if (a === newIndices[checkIndex + 1] && b === newIndices[checkIndex + 2] && c === newIndices[checkIndex]) {\r\n found = true;\r\n continue;\r\n }\r\n\r\n if (a === newIndices[checkIndex + 2] && b === newIndices[checkIndex] && c === newIndices[checkIndex + 1]) {\r\n found = true;\r\n continue;\r\n }\r\n }\r\n\r\n if (!found) {\r\n newIndices.push(a, b, c);\r\n }\r\n }\r\n\r\n newVertexData.indices = newIndices;\r\n } else {\r\n newVertexData.indices = indices;\r\n }\r\n\r\n return newVertexData;\r\n };\r\n\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n codeString += `${this._codeVariableName}.epsilon = ${this.epsilon};\\n`;\r\n codeString += `${this._codeVariableName}.optimizeFaces = ${this.optimizeFaces ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n serializationObject.epsilon = this.epsilon;\r\n serializationObject.optimizeFaces = this.optimizeFaces;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n this.epsilon = serializationObject.epsilon;\r\n this.optimizeFaces = serializationObject.optimizeFaces;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryOptimizeBlock\", GeometryOptimizeBlock);\r\n"]}
|
|
1
|
+
{"version":3,"file":"geometryOptimizeBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/Meshes/Node/Blocks/geometryOptimizeBlock.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2CAA2C,CAAC;AAClG,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAA0B,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAGnG,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,iBAAiB;IAqBxD;;;OAGG;IACI,iBAAiB;QACpB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,qBAAqB;QACxB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACI,qBAAqB;QACxB,OAAO,CAAC,CAAC;IACb,CAAC;IAED;;;OAGG;IACH,YAAmB,IAAY;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;QAhDhB;;;WAGG;QAEI,oBAAe,GAAG,IAAI,CAAC;QAE9B;;WAEG;QAEI,YAAO,GA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G,mBAAmB,CAAC,eAAe,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,mBAAmB,CAAC,OAAO,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC,aAAa,CAAC;IAC3D,CAAC;CACJ;AA5NU;IADN,sBAAsB,CAAC,kBAAkB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;8DAC3G;AAMvB;IADN,sBAAsB,CAAC,SAAS,wCAAgC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;sDACrG;AAMlB;IADN,sBAAsB,CAAC,gBAAgB,0CAAkC,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC;4DAC1G;AAkNjC,aAAa,CAAC,+BAA+B,EAAE,qBAAqB,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { NodeGeometryBlockConnectionPointTypes } from \"../Enums/nodeGeometryConnectionPointTypes\";\r\nimport { NodeGeometryBlock } from \"../nodeGeometryBlock\";\r\nimport type { NodeGeometryConnectionPoint } from \"../nodeGeometryBlockConnectionPoint\";\r\nimport { PropertyTypeForEdition, editableInPropertyPage } from \"../../../Decorators/nodeDecorator\";\r\nimport type { NodeGeometryBuildState } from \"../nodeGeometryBuildState\";\r\nimport type { FloatArray } from \"../../../types\";\r\nimport { VertexData } from \"../../../Meshes/mesh.vertexData\";\r\nimport { WithinEpsilon } from \"../../../Maths/math.scalar.functions\";\r\nimport { Epsilon } from \"../../../Maths/math.constants\";\r\nimport type { INodeGeometryExecutionContext } from \"../Interfaces/nodeGeometryExecutionContext\";\r\n/**\r\n * Block used to extract unique positions from a geometry\r\n */\r\nexport class GeometryOptimizeBlock extends NodeGeometryBlock implements INodeGeometryExecutionContext {\r\n private _currentIndex: number;\r\n /**\r\n * Gets or sets a boolean indicating that this block can evaluate context\r\n * Build performance is improved when this value is set to false as the system will cache values instead of reevaluating everything per context change\r\n */\r\n @editableInPropertyPage(\"Evaluate context\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public evaluateContext = true;\r\n\r\n /**\r\n * Define the epsilon used to compare similar positions\r\n */\r\n @editableInPropertyPage(\"Epsilon\", PropertyTypeForEdition.Float, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public epsilon = Epsilon;\r\n\r\n /**\r\n * Optimize faces (by removing duplicates)\r\n */\r\n @editableInPropertyPage(\"Optimize faces\", PropertyTypeForEdition.Boolean, \"ADVANCED\", { embedded: true, notifiers: { rebuild: true } })\r\n public optimizeFaces = false;\r\n\r\n /**\r\n * Gets the current index in the current flow\r\n * @returns the current index\r\n */\r\n public getExecutionIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current loop index in the current flow\r\n * @returns the current loop index\r\n */\r\n public getExecutionLoopIndex(): number {\r\n return this._currentIndex;\r\n }\r\n\r\n /**\r\n * Gets the current face index in the current flow\r\n * @returns the current face index\r\n */\r\n public getExecutionFaceIndex(): number {\r\n return 0;\r\n }\r\n\r\n /**\r\n * Creates a new GeometryOptimizeBlock\r\n * @param name defines the block name\r\n */\r\n public constructor(name: string) {\r\n super(name);\r\n\r\n this.registerInput(\"geometry\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n this.registerInput(\"selector\", NodeGeometryBlockConnectionPointTypes.Int, true);\r\n this.registerOutput(\"output\", NodeGeometryBlockConnectionPointTypes.Geometry);\r\n }\r\n\r\n /**\r\n * Gets the current class name\r\n * @returns the class name\r\n */\r\n public override getClassName() {\r\n return \"GeometryOptimizeBlock\";\r\n }\r\n\r\n /**\r\n * Gets the geometry component\r\n */\r\n public get geometry(): NodeGeometryConnectionPoint {\r\n return this._inputs[0];\r\n }\r\n\r\n /**\r\n * Gets the selector component\r\n */\r\n public get selector(): NodeGeometryConnectionPoint {\r\n return this._inputs[1];\r\n }\r\n\r\n /**\r\n * Gets the output component\r\n */\r\n public get output(): NodeGeometryConnectionPoint {\r\n return this._outputs[0];\r\n }\r\n\r\n protected override _buildBlock(state: NodeGeometryBuildState) {\r\n const func = (state: NodeGeometryBuildState) => {\r\n if (!this.geometry.isConnected) {\r\n return null;\r\n }\r\n const vertexData = this.geometry.getConnectedValue(state);\r\n const newPositions: FloatArray = [];\r\n const newIndicesMap: { [key: number]: number } = {};\r\n const newUVs: FloatArray = [];\r\n state.pushExecutionContext(this);\r\n state.pushGeometryContext(vertexData);\r\n\r\n // Optimize positions\r\n for (let index = 0; index < vertexData.positions.length; index += 3) {\r\n this._currentIndex = index / 3;\r\n\r\n if (this.selector.isConnected) {\r\n const selector = this.selector.getConnectedValue(state);\r\n if (!selector) {\r\n continue;\r\n }\r\n }\r\n\r\n const x = vertexData.positions[index];\r\n const y = vertexData.positions[index + 1];\r\n const z = vertexData.positions[index + 2];\r\n\r\n const uvIndex = (index / 3) * 2;\r\n const u = vertexData.uvs ? vertexData.uvs[uvIndex] : 0;\r\n const v = vertexData.uvs ? vertexData.uvs[uvIndex + 1] : 0;\r\n\r\n // check if we already have it\r\n let found = false;\r\n for (let checkIndex = 0; checkIndex < newPositions.length; checkIndex += 3) {\r\n if (\r\n WithinEpsilon(x, newPositions[checkIndex], this.epsilon) &&\r\n WithinEpsilon(y, newPositions[checkIndex + 1], this.epsilon) &&\r\n WithinEpsilon(z, newPositions[checkIndex + 2], this.epsilon)\r\n ) {\r\n newIndicesMap[index / 3] = checkIndex / 3;\r\n found = true;\r\n continue;\r\n }\r\n }\r\n\r\n if (!found) {\r\n newIndicesMap[index / 3] = newPositions.length / 3;\r\n newPositions.push(x, y, z);\r\n newUVs.push(u, v);\r\n }\r\n }\r\n const newVertexData = new VertexData();\r\n newVertexData.positions = newPositions;\r\n if (vertexData.uvs) {\r\n newVertexData.uvs = newUVs;\r\n }\r\n const indices: number[] = vertexData.indices.map((index: number) => newIndicesMap[index]);\r\n const newIndices: number[] = [];\r\n\r\n if (this.optimizeFaces) {\r\n // Optimize indices\r\n for (let index = 0; index < indices.length; index += 3) {\r\n const a = indices[index];\r\n const b = indices[index + 1];\r\n const c = indices[index + 2];\r\n\r\n if (a === b || b == c || c === a) {\r\n continue;\r\n }\r\n\r\n // check if we already have it\r\n let found = false;\r\n for (let checkIndex = 0; checkIndex < newIndices.length; checkIndex += 3) {\r\n if (a === newIndices[checkIndex] && b === newIndices[checkIndex + 1] && c === newIndices[checkIndex + 2]) {\r\n found = true;\r\n continue;\r\n }\r\n\r\n if (a === newIndices[checkIndex + 1] && b === newIndices[checkIndex + 2] && c === newIndices[checkIndex]) {\r\n found = true;\r\n continue;\r\n }\r\n\r\n if (a === newIndices[checkIndex + 2] && b === newIndices[checkIndex] && c === newIndices[checkIndex + 1]) {\r\n found = true;\r\n continue;\r\n }\r\n }\r\n\r\n if (!found) {\r\n newIndices.push(a, b, c);\r\n }\r\n }\r\n\r\n newVertexData.indices = newIndices;\r\n } else {\r\n newVertexData.indices = indices;\r\n }\r\n\r\n return newVertexData;\r\n };\r\n\r\n state.restoreGeometryContext();\r\n state.restoreExecutionContext();\r\n\r\n if (this.evaluateContext) {\r\n this.output._storedFunction = func;\r\n } else {\r\n this.output._storedFunction = null;\r\n this.output._storedValue = func(state);\r\n }\r\n }\r\n\r\n protected override _dumpPropertiesCode() {\r\n let codeString = super._dumpPropertiesCode() + `${this._codeVariableName}.evaluateContext = ${this.evaluateContext ? \"true\" : \"false\"};\\n`;\r\n codeString += `${this._codeVariableName}.epsilon = ${this.epsilon};\\n`;\r\n codeString += `${this._codeVariableName}.optimizeFaces = ${this.optimizeFaces ? \"true\" : \"false\"};\\n`;\r\n return codeString;\r\n }\r\n\r\n /**\r\n * Serializes this block in a JSON representation\r\n * @returns the serialized block object\r\n */\r\n public override serialize(): any {\r\n const serializationObject = super.serialize();\r\n\r\n serializationObject.evaluateContext = this.evaluateContext;\r\n serializationObject.epsilon = this.epsilon;\r\n serializationObject.optimizeFaces = this.optimizeFaces;\r\n\r\n return serializationObject;\r\n }\r\n\r\n public override _deserialize(serializationObject: any) {\r\n super._deserialize(serializationObject);\r\n\r\n this.evaluateContext = serializationObject.evaluateContext;\r\n this.epsilon = serializationObject.epsilon;\r\n this.optimizeFaces = serializationObject.optimizeFaces;\r\n }\r\n}\r\n\r\nRegisterClass(\"BABYLON.GeometryOptimizeBlock\", GeometryOptimizeBlock);\r\n"]}
|
|
@@ -171,7 +171,7 @@ export async function CreateEnvTextureAsync(texture, options = {}) {
|
|
|
171
171
|
info.irradiance.irradianceTexture = {
|
|
172
172
|
size: irradianceTexture.getSize().width,
|
|
173
173
|
faces: [],
|
|
174
|
-
dominantDirection:
|
|
174
|
+
dominantDirection: irradianceTexture._dominantDirection?.asArray(),
|
|
175
175
|
};
|
|
176
176
|
for (let face = 0; face < 6; face++) {
|
|
177
177
|
const byteLength = diffuseTextures[face].byteLength;
|