@onerjs/core 9.0.0 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Animations/animationGroup.pure.js.map +1 -1
- package/Cameras/targetCamera.pure.js +6 -1
- package/Cameras/targetCamera.pure.js.map +1 -1
- package/Engines/Native/nativeHardwareTexture.d.ts +8 -1
- package/Engines/Native/nativeHardwareTexture.js +7 -0
- package/Engines/Native/nativeHardwareTexture.js.map +1 -1
- package/Engines/Native/nativeHelpers.js +56 -1
- package/Engines/Native/nativeHelpers.js.map +1 -1
- package/Engines/Native/nativeInterfaces.d.ts +37 -8
- package/Engines/Native/nativeInterfaces.js.map +1 -1
- package/Engines/Native/nativeRenderTargetWrapper.d.ts +40 -0
- package/Engines/Native/nativeRenderTargetWrapper.js +265 -5
- package/Engines/Native/nativeRenderTargetWrapper.js.map +1 -1
- package/Engines/Processors/shaderCodeCursor.d.ts +1 -0
- package/Engines/Processors/shaderCodeCursor.js +40 -3
- package/Engines/Processors/shaderCodeCursor.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.renderTarget.pure.js +1 -0
- package/Engines/WebGPU/Extensions/engine.renderTarget.pure.js.map +1 -1
- package/Engines/abstractEngine.pure.d.ts +15 -1
- package/Engines/abstractEngine.pure.js +12 -4
- package/Engines/abstractEngine.pure.js.map +1 -1
- package/Engines/engine.pure.d.ts +0 -1
- package/Engines/engine.pure.js +0 -7
- package/Engines/engine.pure.js.map +1 -1
- package/Engines/nativeEngine.pure.js +1 -1
- package/Engines/nativeEngine.pure.js.map +1 -1
- package/Engines/thinEngine.pure.d.ts +1 -0
- package/Engines/thinEngine.pure.js +13 -2
- package/Engines/thinEngine.pure.js.map +1 -1
- package/Engines/thinNativeEngine.pure.d.ts +217 -17
- package/Engines/thinNativeEngine.pure.js +1431 -164
- package/Engines/thinNativeEngine.pure.js.map +1 -1
- package/Engines/thinWebGPUEngine.js +6 -1
- package/Engines/thinWebGPUEngine.js.map +1 -1
- package/Engines/webgpuEngine.pure.d.ts +12 -1
- package/Engines/webgpuEngine.pure.js +8 -0
- package/Engines/webgpuEngine.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.d.ts +10 -0
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js +24 -12
- package/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.d.ts +7 -0
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.js +43 -0
- package/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.d.ts +16 -4
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js +20 -6
- package/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.js +3 -3
- package/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.d.ts +7 -7
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js +52 -35
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.d.ts +12 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js +8 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCancelDelayBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js +4 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.d.ts +12 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.js +5 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.pure.d.ts +2 -0
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.pure.js +14 -2
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.pure.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.pure.d.ts +5 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.pure.js +23 -8
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.pure.js.map +1 -1
- package/FlowGraph/CustomTypes/flowGraphInteger.pure.d.ts +5 -0
- package/FlowGraph/CustomTypes/flowGraphInteger.pure.js +7 -0
- package/FlowGraph/CustomTypes/flowGraphInteger.pure.js.map +1 -1
- package/FlowGraph/CustomTypes/flowGraphMatrix.d.ts +10 -0
- package/FlowGraph/CustomTypes/flowGraphMatrix.js +14 -0
- package/FlowGraph/CustomTypes/flowGraphMatrix.js.map +1 -1
- package/FlowGraph/flowGraph.d.ts +2 -1
- package/FlowGraph/flowGraph.js +3 -2
- package/FlowGraph/flowGraph.js.map +1 -1
- package/FlowGraph/flowGraphAnimationHelpers.d.ts +24 -0
- package/FlowGraph/flowGraphAnimationHelpers.js +21 -0
- package/FlowGraph/flowGraphAnimationHelpers.js.map +1 -0
- package/FlowGraph/flowGraphContext.js +1 -0
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphValidator.js +0 -4
- package/FlowGraph/flowGraphValidator.js.map +1 -1
- package/FlowGraph/index.d.ts +2 -0
- package/FlowGraph/index.js +2 -0
- package/FlowGraph/index.js.map +1 -1
- package/FlowGraph/pure.d.ts +2 -0
- package/FlowGraph/pure.js +2 -0
- package/FlowGraph/pure.js.map +1 -1
- package/FlowGraph/serialization.d.ts +2 -2
- package/FlowGraph/serialization.js +2 -2
- package/FlowGraph/serialization.js.map +1 -1
- package/FlowGraph/typeDefinitions.d.ts +1 -1
- package/FlowGraph/typeDefinitions.js.map +1 -1
- package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.d.ts +1 -0
- package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.js +4 -0
- package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.js.map +1 -0
- package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.pure.d.ts +54 -0
- package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.pure.js +155 -0
- package/FrameGraph/Node/Blocks/Textures/minMaxReducerBlock.pure.js.map +1 -0
- package/FrameGraph/Node/Blocks/Textures/pure.d.ts +1 -0
- package/FrameGraph/Node/Blocks/Textures/pure.js +1 -0
- package/FrameGraph/Node/Blocks/Textures/pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/allBlocks.pure.js +2 -0
- package/FrameGraph/Node/Blocks/allBlocks.pure.js.map +1 -1
- package/FrameGraph/Node/Blocks/index.d.ts +1 -0
- package/FrameGraph/Node/Blocks/index.js +1 -0
- package/FrameGraph/Node/Blocks/index.js.map +1 -1
- package/FrameGraph/Node/Blocks/pure.d.ts +1 -0
- package/FrameGraph/Node/Blocks/pure.js +1 -0
- package/FrameGraph/Node/Blocks/pure.js.map +1 -1
- package/FrameGraph/Tasks/Misc/minMaxReducerTask.d.ts +62 -0
- package/FrameGraph/Tasks/Misc/minMaxReducerTask.js +159 -0
- package/FrameGraph/Tasks/Misc/minMaxReducerTask.js.map +1 -0
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js +3 -1
- package/FrameGraph/Tasks/Rendering/geometryRendererTask.js.map +1 -1
- package/FrameGraph/frameGraph.d.ts +4 -0
- package/FrameGraph/frameGraph.js +14 -0
- package/FrameGraph/frameGraph.js.map +1 -1
- package/FrameGraph/index.d.ts +1 -0
- package/FrameGraph/index.js +1 -0
- package/FrameGraph/index.js.map +1 -1
- package/FrameGraph/pure.d.ts +1 -0
- package/FrameGraph/pure.js +1 -0
- package/FrameGraph/pure.js.map +1 -1
- package/Inputs/scene.inputManager.js +1 -1
- package/Inputs/scene.inputManager.js.map +1 -1
- package/Lights/Clustered/clusteredLightingSceneComponent.pure.d.ts +5 -0
- package/Lights/Clustered/clusteredLightingSceneComponent.pure.js +22 -1
- package/Lights/Clustered/clusteredLightingSceneComponent.pure.js.map +1 -1
- package/Lights/Shadows/cascadedShadowGenerator.pure.js +7 -3
- package/Lights/Shadows/cascadedShadowGenerator.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.d.ts +7 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.js +8 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.pure.d.ts +54 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.pure.js +81 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingBlitMaterial.pure.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.d.ts +7 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.js +8 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.pure.d.ts +60 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.pure.js +90 -0
- package/Materials/GaussianSplatting/gaussianPointSplattingDepthBlitMaterial.pure.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.d.ts +31 -0
- package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js +98 -0
- package/Materials/GaussianSplatting/gaussianSplattingDebugMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingGpuPickingMaterialPlugin.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js +2 -2
- package/Materials/GaussianSplatting/gaussianSplattingMaterial.pure.js.map +1 -1
- package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.d.ts +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.js +4 -0
- package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.pure.d.ts +83 -0
- package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.pure.js +191 -0
- package/Materials/GaussianSplatting/gaussianSplattingOverdrawMaterialPlugin.pure.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.d.ts +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.js +4 -0
- package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.js.map +1 -0
- package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.pure.d.ts +62 -0
- package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.pure.js +125 -0
- package/Materials/GaussianSplatting/gaussianSplattingSizeMaterialPlugin.pure.js.map +1 -0
- package/Materials/GaussianSplatting/pure.d.ts +4 -0
- package/Materials/GaussianSplatting/pure.js +4 -0
- package/Materials/GaussianSplatting/pure.js.map +1 -1
- package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.d.ts +1 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js +12 -0
- package/Materials/Node/Blocks/Dual/imageSourceBlock.pure.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.pure.d.ts +1 -0
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js +31 -7
- package/Materials/Textures/Procedurals/proceduralTexture.pure.js.map +1 -1
- package/Materials/Textures/mirrorTexture.pure.js +3 -1
- package/Materials/Textures/mirrorTexture.pure.js.map +1 -1
- package/Materials/Textures/texture.pure.js +1 -1
- package/Materials/Textures/texture.pure.js.map +1 -1
- package/Materials/effectRenderer.pure.d.ts +4 -0
- package/Materials/effectRenderer.pure.js +3 -2
- package/Materials/effectRenderer.pure.js.map +1 -1
- package/Materials/index.d.ts +4 -0
- package/Materials/index.js +4 -0
- package/Materials/index.js.map +1 -1
- package/Materials/material.pure.js +25 -12
- package/Materials/material.pure.js.map +1 -1
- package/Materials/pure.d.ts +4 -0
- package/Materials/pure.js +4 -0
- package/Materials/pure.js.map +1 -1
- package/Materials/standardMaterial.pure.d.ts +8 -0
- package/Materials/standardMaterial.pure.js +24 -2
- package/Materials/standardMaterial.pure.js.map +1 -1
- package/Meshes/Builders/polygonBuilder.pure.js +1 -1
- package/Meshes/Builders/polygonBuilder.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianPointSplattingController.d.ts +8 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingController.js +11 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingController.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingController.pure.d.ts +231 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingController.pure.js +1212 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingController.pure.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.d.ts +14 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.js +15 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.pure.d.ts +285 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.pure.js +812 -0
- package/Meshes/GaussianSplatting/gaussianPointSplattingRenderer.pure.js.map +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.d.ts +1 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js +2 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.d.ts +160 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js +219 -0
- package/Meshes/GaussianSplatting/gaussianSplattingMesh.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.d.ts +32 -4
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js +114 -21
- package/Meshes/GaussianSplatting/gaussianSplattingMeshBase.pure.js.map +1 -1
- package/Meshes/GaussianSplatting/pure.d.ts +2 -0
- package/Meshes/GaussianSplatting/pure.js +2 -0
- package/Meshes/GaussianSplatting/pure.js.map +1 -1
- package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js +25 -11
- package/Meshes/Node/Blocks/booleanGeometryBlock.pure.js.map +1 -1
- package/Meshes/abstractMesh.pure.d.ts +12 -0
- package/Meshes/abstractMesh.pure.js +32 -0
- package/Meshes/abstractMesh.pure.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/pure.d.ts +1 -0
- package/Meshes/pure.js +1 -0
- package/Meshes/pure.js.map +1 -1
- package/Meshes/subMesh.pure.d.ts +11 -2
- package/Meshes/subMesh.pure.js +20 -5
- package/Meshes/subMesh.pure.js.map +1 -1
- package/Meshes/thinInstanceMesh.pure.js +1 -0
- package/Meshes/thinInstanceMesh.pure.js.map +1 -1
- package/Misc/andOrNotEvaluator.js +4 -0
- package/Misc/andOrNotEvaluator.js.map +1 -1
- package/Misc/minMaxReducer.pure.d.ts +6 -0
- package/Misc/minMaxReducer.pure.js +10 -0
- package/Misc/minMaxReducer.pure.js.map +1 -1
- package/Misc/thinMinMaxReducer.d.ts +19 -2
- package/Misc/thinMinMaxReducer.js +74 -21
- package/Misc/thinMinMaxReducer.js.map +1 -1
- package/Misc/tools.pure.js +1 -1
- package/Misc/tools.pure.js.map +1 -1
- package/Particles/Node/Blocks/Update/updateNoiseBlock.pure.js +19 -7
- package/Particles/Node/Blocks/Update/updateNoiseBlock.pure.js.map +1 -1
- package/Particles/Node/Blocks/particleSourceTextureBlock.pure.js +3 -2
- package/Particles/Node/Blocks/particleSourceTextureBlock.pure.js.map +1 -1
- package/Particles/gpuParticleSystem.pure.d.ts +2 -0
- package/Particles/gpuParticleSystem.pure.js +12 -4
- package/Particles/gpuParticleSystem.pure.js.map +1 -1
- package/Particles/particle.js +3 -2
- package/Particles/particle.js.map +1 -1
- package/Particles/solidParticleSystem.js +7 -1
- package/Particles/solidParticleSystem.js.map +1 -1
- package/Particles/thinParticleSystem.function.d.ts +6 -0
- package/Particles/thinParticleSystem.function.js +144 -88
- package/Particles/thinParticleSystem.function.js.map +1 -1
- package/Particles/thinParticleSystem.pure.d.ts +6 -0
- package/Particles/thinParticleSystem.pure.js +70 -9
- package/Particles/thinParticleSystem.pure.js.map +1 -1
- package/Physics/v2/ragdoll.d.ts +2 -4
- package/Physics/v2/ragdoll.js +11 -4
- package/Physics/v2/ragdoll.js.map +1 -1
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.d.ts +12 -0
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js +43 -18
- package/Rendering/IBLShadows/iblShadowsVoxelRenderer.pure.js.map +1 -1
- package/Rendering/depthRenderer.pure.d.ts +9 -0
- package/Rendering/depthRenderer.pure.js +12 -0
- package/Rendering/depthRenderer.pure.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObject.d.ts +4 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js +6 -0
- package/Rendering/fluidRenderer/fluidRenderingObject.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.d.ts +4 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js +8 -0
- package/Rendering/fluidRenderer/fluidRenderingObjectParticleSystem.js.map +1 -1
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js +3 -0
- package/Rendering/fluidRenderer/fluidRenderingTargetRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.pure.js +4 -1
- package/Rendering/geometryBufferRenderer.pure.js.map +1 -1
- package/Rendering/prePassRenderer.pure.js +3 -3
- package/Rendering/prePassRenderer.pure.js.map +1 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js +3 -1
- package/Shaders/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js +27 -3
- package/Shaders/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/Shaders/ShadersInclude/oitDeclaration.js +1 -1
- package/Shaders/ShadersInclude/oitDeclaration.js.map +1 -1
- package/Shaders/minmaxRedux.fragment.js +6 -1
- package/Shaders/minmaxRedux.fragment.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianPointSplatting.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/gaussianPointSplatting.js +65 -0
- package/ShadersWGSL/ShadersInclude/gaussianPointSplatting.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/gaussianPointSplattingScan.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/gaussianPointSplattingScan.js +17 -0
- package/ShadersWGSL/ShadersInclude/gaussianPointSplattingScan.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.d.ts +1 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js +6 -78
- package/ShadersWGSL/ShadersInclude/gaussianSplatting.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js +2 -2
- package/ShadersWGSL/ShadersInclude/gaussianSplattingFragmentDeclaration.js.map +1 -1
- package/ShadersWGSL/ShadersInclude/gaussianSplattingShared.d.ts +5 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingShared.js +79 -0
- package/ShadersWGSL/ShadersInclude/gaussianSplattingShared.js.map +1 -0
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js +27 -3
- package/ShadersWGSL/ShadersInclude/lightsFragmentFunctions.js.map +1 -1
- package/ShadersWGSL/gaussianPointSplattingBlit.fragment.d.ts +5 -0
- package/ShadersWGSL/gaussianPointSplattingBlit.fragment.js +22 -0
- package/ShadersWGSL/gaussianPointSplattingBlit.fragment.js.map +1 -0
- package/ShadersWGSL/gaussianPointSplattingBlit.vertex.d.ts +5 -0
- package/ShadersWGSL/gaussianPointSplattingBlit.vertex.js +19 -0
- package/ShadersWGSL/gaussianPointSplattingBlit.vertex.js.map +1 -0
- package/ShadersWGSL/gaussianPointSplattingDepthBlit.fragment.d.ts +5 -0
- package/ShadersWGSL/gaussianPointSplattingDepthBlit.fragment.js +21 -0
- package/ShadersWGSL/gaussianPointSplattingDepthBlit.fragment.js.map +1 -0
- package/ShadersWGSL/gaussianSplatting.vertex.js +2 -1
- package/ShadersWGSL/gaussianSplatting.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js +2 -1
- package/ShadersWGSL/gaussianSplattingDepth.vertex.js.map +1 -1
- package/ShadersWGSL/gaussianSplattingVoxel.vertex.js +2 -1
- package/ShadersWGSL/gaussianSplattingVoxel.vertex.js.map +1 -1
- package/ShadersWGSL/gpsHiZBuild.compute.d.ts +5 -0
- package/ShadersWGSL/gpsHiZBuild.compute.js +16 -0
- package/ShadersWGSL/gpsHiZBuild.compute.js.map +1 -0
- package/ShadersWGSL/gpsPartition.compute.d.ts +5 -0
- package/ShadersWGSL/gpsPartition.compute.js +27 -0
- package/ShadersWGSL/gpsPartition.compute.js.map +1 -0
- package/ShadersWGSL/gpsPreprocess.compute.d.ts +5 -0
- package/ShadersWGSL/gpsPreprocess.compute.js +86 -0
- package/ShadersWGSL/gpsPreprocess.compute.js.map +1 -0
- package/ShadersWGSL/gpsResolve.compute.d.ts +5 -0
- package/ShadersWGSL/gpsResolve.compute.js +41 -0
- package/ShadersWGSL/gpsResolve.compute.js.map +1 -0
- package/ShadersWGSL/gpsScanAdd.compute.d.ts +5 -0
- package/ShadersWGSL/gpsScanAdd.compute.js +22 -0
- package/ShadersWGSL/gpsScanAdd.compute.js.map +1 -0
- package/ShadersWGSL/gpsScanBlocks.compute.d.ts +5 -0
- package/ShadersWGSL/gpsScanBlocks.compute.js +23 -0
- package/ShadersWGSL/gpsScanBlocks.compute.js.map +1 -0
- package/ShadersWGSL/gpsScanSums.compute.d.ts +5 -0
- package/ShadersWGSL/gpsScanSums.compute.js +30 -0
- package/ShadersWGSL/gpsScanSums.compute.js.map +1 -0
- package/ShadersWGSL/gpsSplat.compute.d.ts +5 -0
- package/ShadersWGSL/gpsSplat.compute.js +37 -0
- package/ShadersWGSL/gpsSplat.compute.js.map +1 -0
- package/ShadersWGSL/minmaxRedux.fragment.js +20 -3
- package/ShadersWGSL/minmaxRedux.fragment.js.map +1 -1
- package/XR/features/WebXRSpaceWarp.pure.js +2 -1
- package/XR/features/WebXRSpaceWarp.pure.js.map +1 -1
- package/assetContainer.d.ts +1 -0
- package/assetContainer.js +5 -1
- package/assetContainer.js.map +1 -1
- package/package.json +1 -1
- package/scene.pure.d.ts +13 -2
- package/scene.pure.js +28 -4
- package/scene.pure.js.map +1 -1
|
@@ -9,6 +9,7 @@ import { type IPathToObjectConverter } from "../../../../ObjectModel/objectModel
|
|
|
9
9
|
import { type Animation } from "../../../../Animations/animation.pure.js";
|
|
10
10
|
import { type EasingFunction } from "../../../../Animations/easing.js";
|
|
11
11
|
import { FlowGraphCachedOperationBlock } from "../flowGraphCachedOperationBlock.js";
|
|
12
|
+
import { type IAnimatable } from "../../../../Animations/animatable.interface.js";
|
|
12
13
|
/**
|
|
13
14
|
* Configuration for the JSON pointer parser block.
|
|
14
15
|
*/
|
|
@@ -25,6 +26,11 @@ export interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGrap
|
|
|
25
26
|
* Whether to output the value of the property.
|
|
26
27
|
*/
|
|
27
28
|
outputValue?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Expected property value type for writes. When provided, writes require a mutable accessor
|
|
31
|
+
* with the matching type; vector/color and vector4/quaternion representations are equivalent.
|
|
32
|
+
*/
|
|
33
|
+
valueType?: string;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
30
36
|
* This block will take a JSON pointer and parse it to get the value from the JSON object.
|
|
@@ -56,6 +62,10 @@ export declare class FlowGraphJsonPointerParserBlock<P extends any, O extends Fl
|
|
|
56
62
|
* Output connection: A function that can be used to get the interpolation animation property info.
|
|
57
63
|
*/
|
|
58
64
|
readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Output connection: Targets supplied by the animation builder, in the same order as its generated animations.
|
|
67
|
+
*/
|
|
68
|
+
readonly animationTargets: FlowGraphDataConnection<IAnimatable[] | undefined>;
|
|
59
69
|
/**
|
|
60
70
|
* The component with the templated inputs for the provided path.
|
|
61
71
|
*/
|
|
@@ -23,6 +23,7 @@ export class FlowGraphJsonPointerParserBlock extends FlowGraphCachedOperationBlo
|
|
|
23
23
|
this.setterFunction = this.registerDataOutput("setFunction", RichTypeAny, this._setPropertyValue.bind(this));
|
|
24
24
|
this.getterFunction = this.registerDataOutput("getFunction", RichTypeAny, this._getPropertyValue.bind(this));
|
|
25
25
|
this.generateAnimationsFunction = this.registerDataOutput("generateAnimationsFunction", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));
|
|
26
|
+
this.animationTargets = this.registerDataOutput("animationTargets", RichTypeAny);
|
|
26
27
|
this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);
|
|
27
28
|
}
|
|
28
29
|
_doOperation(context) {
|
|
@@ -31,7 +32,7 @@ export class FlowGraphJsonPointerParserBlock extends FlowGraphCachedOperationBlo
|
|
|
31
32
|
// one validating a delay handle against the runtime active-delay set, can resolve.
|
|
32
33
|
const value = accessorContainer.info.get(accessorContainer.object, undefined, context);
|
|
33
34
|
const object = accessorContainer.info.getTarget?.(accessorContainer.object);
|
|
34
|
-
const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);
|
|
35
|
+
const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object) ?? accessorContainer.info.interpolation?.[0]?.name;
|
|
35
36
|
if (!object) {
|
|
36
37
|
throw new Error("Object is undefined");
|
|
37
38
|
}
|
|
@@ -46,6 +47,12 @@ export class FlowGraphJsonPointerParserBlock extends FlowGraphCachedOperationBlo
|
|
|
46
47
|
_setPropertyValue(_target, _propertyName, value, context) {
|
|
47
48
|
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
|
|
48
49
|
const type = accessorContainer.info.type;
|
|
50
|
+
if (this.config.valueType !== undefined) {
|
|
51
|
+
const valueType = type === "Color3" ? "Vector3" : type === "Color4" || type === "Quaternion" ? "Vector4" : type;
|
|
52
|
+
if (valueType !== this.config.valueType || accessorContainer.info.isReadOnly || !accessorContainer.info.set) {
|
|
53
|
+
throw new Error(`Property is not writable with value type ${this.config.valueType}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
49
56
|
if (type.startsWith("Color")) {
|
|
50
57
|
value = ToColor(value, type);
|
|
51
58
|
}
|
|
@@ -68,8 +75,16 @@ export class FlowGraphJsonPointerParserBlock extends FlowGraphCachedOperationBlo
|
|
|
68
75
|
}
|
|
69
76
|
_getInterpolationAnimationPropertyInfo(_target, _propertyName, context) {
|
|
70
77
|
const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);
|
|
71
|
-
|
|
78
|
+
if (this.config.valueType !== undefined) {
|
|
79
|
+
const type = accessorContainer.info.type;
|
|
80
|
+
const valueType = type === "Color3" ? "Vector3" : type === "Color4" || type === "Quaternion" ? "Vector4" : type;
|
|
81
|
+
if (valueType !== this.config.valueType || accessorContainer.info.isReadOnly || !accessorContainer.info.interpolation?.length) {
|
|
82
|
+
throw new Error(`Property is not interpolatable with value type ${this.config.valueType}`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return (keys, fps, _animationType, easingFunction) => {
|
|
72
86
|
const animations = [];
|
|
87
|
+
const targets = [];
|
|
73
88
|
// make sure keys are of the right type (in case of float3 color/vector)
|
|
74
89
|
const type = accessorContainer.info.type;
|
|
75
90
|
if (type.startsWith("Color")) {
|
|
@@ -83,24 +98,21 @@ export class FlowGraphJsonPointerParserBlock extends FlowGraphCachedOperationBlo
|
|
|
83
98
|
accessorContainer.info.interpolation?.forEach((info, index) => {
|
|
84
99
|
const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || "Animation-interpolation-" + index;
|
|
85
100
|
// generate the keys based on interpolation info
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
frame: key.frame,
|
|
92
|
-
value: info.getValue(undefined, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
}
|
|
101
|
+
// Metadata also converts units/components when the animation types match.
|
|
102
|
+
const newKeys = keys.map((key) => ({
|
|
103
|
+
frame: key.frame,
|
|
104
|
+
value: info.getValue(accessorContainer.object, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),
|
|
105
|
+
}));
|
|
96
106
|
const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);
|
|
97
107
|
for (const animation of animationData) {
|
|
98
108
|
if (easingFunction) {
|
|
99
109
|
animation.babylonAnimation.setEasingFunction(easingFunction);
|
|
100
110
|
}
|
|
101
111
|
animations.push(animation.babylonAnimation);
|
|
112
|
+
targets.push(animation.babylonAnimatable);
|
|
102
113
|
}
|
|
103
114
|
});
|
|
115
|
+
this.animationTargets.setValue(targets, context);
|
|
104
116
|
return animations;
|
|
105
117
|
};
|
|
106
118
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphJsonPointerParserBlock.pure.js","sourceR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,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,uCAAuC;IACnD,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,gFAAwC,+BAA+B,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport { type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { type FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection.pure\";\nimport { FlowGraphPathConverterComponent } from \"core/FlowGraph/flowGraphPathConverterComponent\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes.pure\";\nimport { type IObjectAccessor } from \"core/FlowGraph/typeDefinitions\";\nimport { type IPathToObjectConverter } from \"core/ObjectModel/objectModelInterfaces\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { type Animation } from \"core/Animations/animation.pure\";\nimport { type EasingFunction } from \"core/Animations/easing\";\nimport { Vector3, Vector4 } from \"core/Maths/math.vector.pure\";\nimport { Color3, Color4 } from \"core/Maths/math.color.pure\";\nimport { FlowGraphCachedOperationBlock } from \"../flowGraphCachedOperationBlock\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * Configuration for the JSON pointer parser block.\n */\nexport interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The JSON pointer to parse.\n */\n jsonPointer: string;\n /**\n * The path converter to use to convert the path to an object accessor.\n */\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\n\n /**\n * Whether to output the value of the property.\n */\n outputValue?: boolean;\n}\n\n/**\n * This block will take a JSON pointer and parse it to get the value from the JSON object.\n * The output is an object and a property name.\n * Optionally, the block can also output the value of the property. This is configurable.\n */\nexport class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Output connection: The object that contains the property.\n */\n public readonly object: FlowGraphDataConnection<O>;\n\n /**\n * Output connection: The property name.\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Output connection: A function that can be used to update the value of the property.\n */\n public readonly setterFunction: FlowGraphDataConnection<(target: O, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n /**\n * Output connection: A function that can be used to get the value of the property.\n */\n public readonly getterFunction: FlowGraphDataConnection<(target: O, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Output connection: A function that can be used to get the interpolation animation property info.\n */\n public readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;\n\n /**\n * The component with the templated inputs for the provided path.\n */\n public readonly templateComponent: FlowGraphPathConverterComponent;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphJsonPointerParserBlockConfiguration\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataOutput(\"object\", RichTypeAny);\n this.propertyName = this.registerDataOutput(\"propertyName\", RichTypeAny);\n this.setterFunction = this.registerDataOutput(\"setFunction\", RichTypeAny, this._setPropertyValue.bind(this));\n this.getterFunction = this.registerDataOutput(\"getFunction\", RichTypeAny, this._getPropertyValue.bind(this));\n this.generateAnimationsFunction = this.registerDataOutput(\"generateAnimationsFunction\", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));\n this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);\n }\n\n public override _doOperation(context: FlowGraphContext): P {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n // Pass the context as the accessor payload so context-aware object-model accessors, such as\n // one validating a delay handle against the runtime active-delay set, can resolve.\n const value = accessorContainer.info.get(accessorContainer.object, undefined, context) as P;\n const object = accessorContainer.info.getTarget?.(accessorContainer.object);\n const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object);\n if (!object) {\n throw new Error(\"Object is undefined\");\n } else {\n this.object.setValue(object, context);\n if (propertyName) {\n this.propertyName.setValue(propertyName, context);\n }\n }\n return value;\n }\n\n private _setPropertyValue(_target: O, _propertyName: string, value: P, context: FlowGraphContext): void {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n value = ToColor(value as Vector4, type) as unknown as P;\n }\n // Unwrap FlowGraphInteger to plain number for numeric setters\n if (typeof (value as any)?.value === \"number\" && (value as any)?.getClassName?.() === \"FlowGraphInteger\") {\n value = (value as any).value as unknown as P;\n }\n accessorContainer.info.set?.(value, accessorContainer.object);\n }\n\n private _getPropertyValue(_target: O, _propertyName: string, context: FlowGraphContext): P | undefined {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n // Pass the context as the accessor payload (see _doOperation) so context-aware accessors\n // can resolve.\n const value = accessorContainer.info.get(accessorContainer.object, undefined, context);\n if (type.startsWith(\"Color\")) {\n return FromColor(value as Color3 | Color4) as unknown as P;\n }\n return value as P | undefined;\n }\n\n private _getInterpolationAnimationPropertyInfo(\n _target: O,\n _propertyName: string,\n context: FlowGraphContext\n ): (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation[] {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n return (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => {\n const animations: Animation[] = [];\n // make sure keys are of the right type (in case of float3 color/vector)\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n keys = keys.map((key) => {\n return {\n frame: key.frame,\n value: ToColor(key.value, type),\n };\n });\n }\n accessorContainer.info.interpolation?.forEach((info, index) => {\n const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || \"Animation-interpolation-\" + index;\n // generate the keys based on interpolation info\n let newKeys: any[] = keys;\n if (animationType !== info.type) {\n // convert the keys to the right type\n newKeys = keys.map((key) => {\n return {\n frame: key.frame,\n value: info.getValue(undefined, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),\n };\n });\n }\n const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);\n for (const animation of animationData) {\n if (easingFunction) {\n animation.babylonAnimation.setEasingFunction(easingFunction);\n }\n animations.push(animation.babylonAnimation);\n }\n });\n\n return animations;\n };\n }\n\n /**\n * Gets the class name of this block\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.JsonPointerParser;\n }\n}\n\nfunction ToColor(value: any, expectedValue: string) {\n if (value.getClassName().startsWith(\"Color\")) {\n return value as unknown as Color3 | Color4;\n }\n if (expectedValue === \"Color3\") {\n return new Color3(value.x, value.y, value.z);\n } else if (expectedValue === \"Color4\") {\n return new Color4(value.x, value.y, value.z, value.w);\n }\n return value;\n}\n\nfunction FromColor(value: Color3 | Color4): Vector3 | Vector4 {\n if (value instanceof Color3) {\n return new Vector3(value.r, value.g, value.b);\n } else if (value instanceof Color4) {\n return new Vector4(value.r, value.g, value.b, value.a);\n }\n throw new Error(\"Invalid color type\");\n}\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphJsonPointerParserBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphJsonPointerParserBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.JsonPointerParser, FlowGraphJsonPointerParserBlock);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphJsonPointerParserBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Data/Transformers/flowGraphJsonPointerParserBlock.pure.ts"],"names":[],"mappings":"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,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AAC1C,CAAC;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,uCAAuC;IACnD,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,gFAAwC,+BAA+B,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport { type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { type FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection.pure\";\nimport { FlowGraphPathConverterComponent } from \"core/FlowGraph/flowGraphPathConverterComponent\";\nimport { RichTypeAny } from \"core/FlowGraph/flowGraphRichTypes.pure\";\nimport { type IObjectAccessor } from \"core/FlowGraph/typeDefinitions\";\nimport { type IPathToObjectConverter } from \"core/ObjectModel/objectModelInterfaces\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { type Animation } from \"core/Animations/animation.pure\";\nimport { type EasingFunction } from \"core/Animations/easing\";\nimport { Vector3, Vector4 } from \"core/Maths/math.vector.pure\";\nimport { Color3, Color4 } from \"core/Maths/math.color.pure\";\nimport { FlowGraphCachedOperationBlock } from \"../flowGraphCachedOperationBlock\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\nimport { type IAnimatable } from \"core/Animations/animatable.interface\";\n\n/**\n * Configuration for the JSON pointer parser block.\n */\nexport interface IFlowGraphJsonPointerParserBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The JSON pointer to parse.\n */\n jsonPointer: string;\n /**\n * The path converter to use to convert the path to an object accessor.\n */\n pathConverter: IPathToObjectConverter<IObjectAccessor>;\n\n /**\n * Whether to output the value of the property.\n */\n outputValue?: boolean;\n\n /**\n * Expected property value type for writes. When provided, writes require a mutable accessor\n * with the matching type; vector/color and vector4/quaternion representations are equivalent.\n */\n valueType?: string;\n}\n\n/**\n * This block will take a JSON pointer and parse it to get the value from the JSON object.\n * The output is an object and a property name.\n * Optionally, the block can also output the value of the property. This is configurable.\n */\nexport class FlowGraphJsonPointerParserBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Output connection: The object that contains the property.\n */\n public readonly object: FlowGraphDataConnection<O>;\n\n /**\n * Output connection: The property name.\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Output connection: A function that can be used to update the value of the property.\n */\n public readonly setterFunction: FlowGraphDataConnection<(target: O, propertyName: string, value: P, context: FlowGraphContext) => void>;\n\n /**\n * Output connection: A function that can be used to get the value of the property.\n */\n public readonly getterFunction: FlowGraphDataConnection<(target: O, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Output connection: A function that can be used to get the interpolation animation property info.\n */\n public readonly generateAnimationsFunction: FlowGraphDataConnection<() => (keys: any[], fps: number, easingFunction?: EasingFunction) => Animation[]>;\n\n /**\n * Output connection: Targets supplied by the animation builder, in the same order as its generated animations.\n */\n public readonly animationTargets: FlowGraphDataConnection<IAnimatable[] | undefined>;\n\n /**\n * The component with the templated inputs for the provided path.\n */\n public readonly templateComponent: FlowGraphPathConverterComponent;\n\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphJsonPointerParserBlockConfiguration\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataOutput(\"object\", RichTypeAny);\n this.propertyName = this.registerDataOutput(\"propertyName\", RichTypeAny);\n this.setterFunction = this.registerDataOutput(\"setFunction\", RichTypeAny, this._setPropertyValue.bind(this));\n this.getterFunction = this.registerDataOutput(\"getFunction\", RichTypeAny, this._getPropertyValue.bind(this));\n this.generateAnimationsFunction = this.registerDataOutput(\"generateAnimationsFunction\", RichTypeAny, this._getInterpolationAnimationPropertyInfo.bind(this));\n this.animationTargets = this.registerDataOutput(\"animationTargets\", RichTypeAny);\n this.templateComponent = new FlowGraphPathConverterComponent(config.jsonPointer, this);\n }\n\n public override _doOperation(context: FlowGraphContext): P {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n // Pass the context as the accessor payload so context-aware object-model accessors, such as\n // one validating a delay handle against the runtime active-delay set, can resolve.\n const value = accessorContainer.info.get(accessorContainer.object, undefined, context) as P;\n const object = accessorContainer.info.getTarget?.(accessorContainer.object);\n const propertyName = accessorContainer.info.getPropertyName?.[0](accessorContainer.object) ?? accessorContainer.info.interpolation?.[0]?.name;\n if (!object) {\n throw new Error(\"Object is undefined\");\n } else {\n this.object.setValue(object, context);\n if (propertyName) {\n this.propertyName.setValue(propertyName, context);\n }\n }\n return value;\n }\n\n private _setPropertyValue(_target: O, _propertyName: string, value: P, context: FlowGraphContext): void {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n if (this.config.valueType !== undefined) {\n const valueType = type === \"Color3\" ? \"Vector3\" : type === \"Color4\" || type === \"Quaternion\" ? \"Vector4\" : type;\n if (valueType !== this.config.valueType || accessorContainer.info.isReadOnly || !accessorContainer.info.set) {\n throw new Error(`Property is not writable with value type ${this.config.valueType}`);\n }\n }\n if (type.startsWith(\"Color\")) {\n value = ToColor(value as Vector4, type) as unknown as P;\n }\n // Unwrap FlowGraphInteger to plain number for numeric setters\n if (typeof (value as any)?.value === \"number\" && (value as any)?.getClassName?.() === \"FlowGraphInteger\") {\n value = (value as any).value as unknown as P;\n }\n accessorContainer.info.set?.(value, accessorContainer.object);\n }\n\n private _getPropertyValue(_target: O, _propertyName: string, context: FlowGraphContext): P | undefined {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n const type = accessorContainer.info.type;\n // Pass the context as the accessor payload (see _doOperation) so context-aware accessors\n // can resolve.\n const value = accessorContainer.info.get(accessorContainer.object, undefined, context);\n if (type.startsWith(\"Color\")) {\n return FromColor(value as Color3 | Color4) as unknown as P;\n }\n return value as P | undefined;\n }\n\n private _getInterpolationAnimationPropertyInfo(\n _target: O,\n _propertyName: string,\n context: FlowGraphContext\n ): (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation[] {\n const accessorContainer = this.templateComponent.getAccessor(this.config.pathConverter, context);\n if (this.config.valueType !== undefined) {\n const type = accessorContainer.info.type;\n const valueType = type === \"Color3\" ? \"Vector3\" : type === \"Color4\" || type === \"Quaternion\" ? \"Vector4\" : type;\n if (valueType !== this.config.valueType || accessorContainer.info.isReadOnly || !accessorContainer.info.interpolation?.length) {\n throw new Error(`Property is not interpolatable with value type ${this.config.valueType}`);\n }\n }\n return (keys: any[], fps: number, _animationType: number, easingFunction?: EasingFunction) => {\n const animations: Animation[] = [];\n const targets: IAnimatable[] = [];\n // make sure keys are of the right type (in case of float3 color/vector)\n const type = accessorContainer.info.type;\n if (type.startsWith(\"Color\")) {\n keys = keys.map((key) => {\n return {\n frame: key.frame,\n value: ToColor(key.value, type),\n };\n });\n }\n accessorContainer.info.interpolation?.forEach((info, index) => {\n const name = accessorContainer.info.getPropertyName?.[index](accessorContainer.object) || \"Animation-interpolation-\" + index;\n // generate the keys based on interpolation info\n // Metadata also converts units/components when the animation types match.\n const newKeys = keys.map((key) => ({\n frame: key.frame,\n value: info.getValue(accessorContainer.object, key.value.asArray ? key.value.asArray() : [key.value], 0, 1),\n }));\n const animationData = info.buildAnimations(accessorContainer.object, name, 60, newKeys);\n for (const animation of animationData) {\n if (easingFunction) {\n animation.babylonAnimation.setEasingFunction(easingFunction);\n }\n animations.push(animation.babylonAnimation);\n targets.push(animation.babylonAnimatable);\n }\n });\n\n this.animationTargets.setValue(targets, context);\n return animations;\n };\n }\n\n /**\n * Gets the class name of this block\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.JsonPointerParser;\n }\n}\n\nfunction ToColor(value: any, expectedValue: string) {\n if (value.getClassName().startsWith(\"Color\")) {\n return value as unknown as Color3 | Color4;\n }\n if (expectedValue === \"Color3\") {\n return new Color3(value.x, value.y, value.z);\n } else if (expectedValue === \"Color4\") {\n return new Color4(value.x, value.y, value.z, value.w);\n }\n return value;\n}\n\nfunction FromColor(value: Color3 | Color4): Vector3 | Vector4 {\n if (value instanceof Color3) {\n return new Vector3(value.r, value.g, value.b);\n } else if (value instanceof Color4) {\n return new Vector4(value.r, value.g, value.b, value.a);\n }\n throw new Error(\"Invalid color type\");\n}\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphJsonPointerParserBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphJsonPointerParserBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.JsonPointerParser, FlowGraphJsonPointerParserBlock);\n}\n"]}
|
|
@@ -20,6 +20,12 @@ export interface IFlowGraphGetPropertyBlockConfiguration<O extends FlowGraphAsse
|
|
|
20
20
|
* If true, the block will reset the output to the default value when the target asset is undefined.
|
|
21
21
|
*/
|
|
22
22
|
resetToDefaultWhenUndefined?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Optional value copied for each failed resolution and returned alongside isValid=false.
|
|
25
|
+
* Scalars are retained, cloneable values use clone(), and arrays/plain records are copied recursively.
|
|
26
|
+
* Other objects must support structured cloning.
|
|
27
|
+
*/
|
|
28
|
+
invalidValue?: unknown;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* This block will deliver a property of an asset, based on the property name and an input asset.
|
|
@@ -63,6 +69,7 @@ export declare class FlowGraphGetPropertyBlock<P extends any, O extends FlowGrap
|
|
|
63
69
|
*/
|
|
64
70
|
_doOperation(context: FlowGraphContext): P | undefined;
|
|
65
71
|
private _getPropertyValue;
|
|
72
|
+
protected _getInvalidOutputValue(context: FlowGraphContext): P;
|
|
66
73
|
/**
|
|
67
74
|
* Returns the class name of this block.
|
|
68
75
|
* @returns the class name
|
|
@@ -2,6 +2,43 @@
|
|
|
2
2
|
import { RichTypeAny, RichTypeString } from "../../flowGraphRichTypes.pure.js";
|
|
3
3
|
import { FlowGraphCachedOperationBlock } from "./flowGraphCachedOperationBlock.js";
|
|
4
4
|
import { RegisterClass } from "../../../Misc/typeStore.js";
|
|
5
|
+
function CloneInvalidValue(value, copies) {
|
|
6
|
+
if (value === null || (typeof value !== "object" && typeof value !== "function")) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
const clonedValues = copies ?? new Map();
|
|
10
|
+
if (clonedValues.has(value)) {
|
|
11
|
+
return clonedValues.get(value);
|
|
12
|
+
}
|
|
13
|
+
const clone = value.clone;
|
|
14
|
+
if (typeof clone === "function") {
|
|
15
|
+
const result = clone.call(value);
|
|
16
|
+
clonedValues.set(value, result);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
const prototype = Object.getPrototypeOf(value);
|
|
20
|
+
if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) {
|
|
21
|
+
const result = structuredClone(value);
|
|
22
|
+
clonedValues.set(value, result);
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
const result = Array.isArray(value) ? new Array(value.length) : Object.create(prototype);
|
|
26
|
+
clonedValues.set(value, result);
|
|
27
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
28
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
29
|
+
if ("value" in descriptor) {
|
|
30
|
+
descriptor.value = CloneInvalidValue(descriptor.value, clonedValues);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
descriptor.value = CloneInvalidValue(Reflect.get(value, key), clonedValues);
|
|
34
|
+
delete descriptor.get;
|
|
35
|
+
delete descriptor.set;
|
|
36
|
+
descriptor.writable = true;
|
|
37
|
+
}
|
|
38
|
+
Object.defineProperty(result, key, descriptor);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
5
42
|
/**
|
|
6
43
|
* This block will deliver a property of an asset, based on the property name and an input asset.
|
|
7
44
|
* The property name can include dots ("."), which will be interpreted as a path to the property.
|
|
@@ -55,6 +92,12 @@ export class FlowGraphGetPropertyBlock extends FlowGraphCachedOperationBlock {
|
|
|
55
92
|
}
|
|
56
93
|
return value;
|
|
57
94
|
}
|
|
95
|
+
_getInvalidOutputValue(context) {
|
|
96
|
+
if (Object.prototype.hasOwnProperty.call(this.config, "invalidValue")) {
|
|
97
|
+
return CloneInvalidValue(this.config.invalidValue);
|
|
98
|
+
}
|
|
99
|
+
return super._getInvalidOutputValue(context);
|
|
100
|
+
}
|
|
58
101
|
/**
|
|
59
102
|
* Returns the class name of this block.
|
|
60
103
|
* @returns the class name
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphGetPropertyBlock.pure.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAM7D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAErF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAsBpD;;;;;;;GAOG;AACH,MAAM,OAAO,yBAAuE,SAAQ,6BAAgC;IAiBxH;;;OAGG;IACH;IACI;;OAEG;IACa,MAAkD;QAElE,KAAK,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAFX,WAAM,GAAN,MAAM,CAA4C;QAGlE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QAC3E,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,cAAc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C3C,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,iCAAiC;IAC7C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,oEAAkC,yBAAyB,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type AssetType, type FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport { type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { type FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection.pure\";\nimport { RichTypeAny, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes.pure\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\nimport { FlowGraphCachedOperationBlock } from \"./flowGraphCachedOperationBlock\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * Configuration for the FlowGraphGetPropertyBlock.\n */\nexport interface IFlowGraphGetPropertyBlockConfiguration<O extends FlowGraphAssetType> extends IFlowGraphBlockConfiguration {\n /**\n * The name of the property that will be set\n */\n propertyName?: string;\n\n /**\n * The target asset from which the property will be retrieved\n */\n object?: AssetType<O>;\n\n /**\n * If true, the block will reset the output to the default value when the target asset is undefined.\n */\n resetToDefaultWhenUndefined?: boolean;\n}\n\n/**\n * This block will deliver a property of an asset, based on the property name and an input asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will deliver the x component of the position of the mesh.\n *\n * Note that it is recommended to input the object on which you are working on (i.e. a material) rather than providing a mesh as object and then getting the material from it.\n */\nexport class FlowGraphGetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Input connection: The asset from which the property will be retrieved\n */\n public readonly object: FlowGraphDataConnection<AssetType<O>>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Input connection: A function that can be used to get the value of the property.\n * This will be used if defined, instead of the default get function.\n */\n public readonly customGetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Constructs a new FlowGraphGetPropertyBlock.\n * @param config - the configuration of the block\n */\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphGetPropertyBlockConfiguration<O>\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.object);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeString, config.propertyName);\n this.customGetFunction = this.registerDataInput(\"customGetFunction\", RichTypeAny);\n }\n\n /**\n * Retrieves the property value from the target object.\n * @param context - the flow graph context\n * @returns the property value, or undefined if the target or property name is not set\n */\n public override _doOperation(context: FlowGraphContext): P | undefined {\n const getter = this.customGetFunction.getValue(context);\n let value;\n if (getter) {\n value = getter(this.object.getValue(context), this.propertyName.getValue(context), context);\n } else {\n const target = this.object.getValue(context);\n const propertyName = this.propertyName.getValue(context);\n value = target && propertyName ? this._getPropertyValue(target, propertyName) : undefined;\n }\n return value;\n }\n\n private _getPropertyValue(target: AssetType<O>, propertyName: string): P | undefined {\n const path = propertyName.split(\".\");\n let value: any = target;\n for (const prop of path) {\n value = value[prop];\n if (value === undefined) {\n return;\n }\n }\n return value as P;\n }\n\n /**\n * Returns the class name of this block.\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.GetProperty;\n }\n}\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphGetPropertyBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphGetPropertyBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.GetProperty, FlowGraphGetPropertyBlock);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphGetPropertyBlock.pure.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAM7D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAErF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,SAAS,iBAAiB,CAAC,KAAc,EAAE,MAA6B;IACpE,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC,EAAE,CAAC;QAC/E,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,YAAY,GAAG,MAAM,IAAI,IAAI,GAAG,EAAmB,CAAC;IAC1D,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,OAAO,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;IACD,MAAM,KAAK,GAAI,KAAmC,CAAC,KAAK,CAAC;IACzD,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAChC,OAAO,MAAM,CAAC;IAClB,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,SAAS,KAAK,MAAM,CAAC,SAAS,IAAI,SAAS,KAAK,IAAI,EAAE,CAAC;QAChF,MAAM,MAAM,GAAY,eAAe,CAAC,KAAK,CAAC,CAAC;QAC/C,YAAY,CAAC,GAAG,CAAC,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,EAAE,CAAC;gBACtB,OAAO;YACX,CAAC;QACL,CAAC;QACD,OAAO,KAAU,CAAC;IACtB,CAAC;IAEkB,sBAAsB,CAAC,OAAyB;QAC/D,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC;YACpE,OAAO,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAM,CAAC;QAC5D,CAAC;QACD,OAAO,KAAK,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAED;;;OAGG;IACa,YAAY;QACxB,yEAAuC;IAC3C,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,iCAAiC;IAC7C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,oEAAkC,yBAAyB,CAAC,CAAC;AAC9E,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type AssetType, type FlowGraphAssetType } from \"core/FlowGraph/flowGraphAssetsContext\";\nimport { type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { type FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection.pure\";\nimport { RichTypeAny, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes.pure\";\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\nimport { FlowGraphCachedOperationBlock } from \"./flowGraphCachedOperationBlock\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\nfunction CloneInvalidValue(value: unknown, copies?: Map<object, unknown>): unknown {\n if (value === null || (typeof value !== \"object\" && typeof value !== \"function\")) {\n return value;\n }\n const clonedValues = copies ?? new Map<object, unknown>();\n if (clonedValues.has(value)) {\n return clonedValues.get(value);\n }\n const clone = (value as { clone?: () => unknown }).clone;\n if (typeof clone === \"function\") {\n const result = clone.call(value);\n clonedValues.set(value, result);\n return result;\n }\n const prototype = Object.getPrototypeOf(value);\n if (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) {\n const result: unknown = structuredClone(value);\n clonedValues.set(value, result);\n return result;\n }\n const result: object = Array.isArray(value) ? new Array(value.length) : Object.create(prototype);\n clonedValues.set(value, result);\n for (const key of Reflect.ownKeys(value)) {\n const descriptor = Object.getOwnPropertyDescriptor(value, key)!;\n if (\"value\" in descriptor) {\n descriptor.value = CloneInvalidValue(descriptor.value, clonedValues);\n } else {\n descriptor.value = CloneInvalidValue(Reflect.get(value, key), clonedValues);\n delete descriptor.get;\n delete descriptor.set;\n descriptor.writable = true;\n }\n Object.defineProperty(result, key, descriptor);\n }\n return result;\n}\n\n/**\n * Configuration for the FlowGraphGetPropertyBlock.\n */\nexport interface IFlowGraphGetPropertyBlockConfiguration<O extends FlowGraphAssetType> extends IFlowGraphBlockConfiguration {\n /**\n * The name of the property that will be set\n */\n propertyName?: string;\n\n /**\n * The target asset from which the property will be retrieved\n */\n object?: AssetType<O>;\n\n /**\n * If true, the block will reset the output to the default value when the target asset is undefined.\n */\n resetToDefaultWhenUndefined?: boolean;\n\n /**\n * Optional value copied for each failed resolution and returned alongside isValid=false.\n * Scalars are retained, cloneable values use clone(), and arrays/plain records are copied recursively.\n * Other objects must support structured cloning.\n */\n invalidValue?: unknown;\n}\n\n/**\n * This block will deliver a property of an asset, based on the property name and an input asset.\n * The property name can include dots (\".\"), which will be interpreted as a path to the property.\n *\n * For example, with an input of a mesh asset, the property name \"position.x\" will deliver the x component of the position of the mesh.\n *\n * Note that it is recommended to input the object on which you are working on (i.e. a material) rather than providing a mesh as object and then getting the material from it.\n */\nexport class FlowGraphGetPropertyBlock<P extends any, O extends FlowGraphAssetType> extends FlowGraphCachedOperationBlock<P> {\n /**\n * Input connection: The asset from which the property will be retrieved\n */\n public readonly object: FlowGraphDataConnection<AssetType<O>>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string>;\n\n /**\n * Input connection: A function that can be used to get the value of the property.\n * This will be used if defined, instead of the default get function.\n */\n public readonly customGetFunction: FlowGraphDataConnection<(target: AssetType<O>, propertyName: string, context: FlowGraphContext) => P | undefined>;\n\n /**\n * Constructs a new FlowGraphGetPropertyBlock.\n * @param config - the configuration of the block\n */\n constructor(\n /**\n * the configuration of the block\n */\n public override config: IFlowGraphGetPropertyBlockConfiguration<O>\n ) {\n super(RichTypeAny, config);\n this.object = this.registerDataInput(\"object\", RichTypeAny, config.object);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeString, config.propertyName);\n this.customGetFunction = this.registerDataInput(\"customGetFunction\", RichTypeAny);\n }\n\n /**\n * Retrieves the property value from the target object.\n * @param context - the flow graph context\n * @returns the property value, or undefined if the target or property name is not set\n */\n public override _doOperation(context: FlowGraphContext): P | undefined {\n const getter = this.customGetFunction.getValue(context);\n let value;\n if (getter) {\n value = getter(this.object.getValue(context), this.propertyName.getValue(context), context);\n } else {\n const target = this.object.getValue(context);\n const propertyName = this.propertyName.getValue(context);\n value = target && propertyName ? this._getPropertyValue(target, propertyName) : undefined;\n }\n return value;\n }\n\n private _getPropertyValue(target: AssetType<O>, propertyName: string): P | undefined {\n const path = propertyName.split(\".\");\n let value: any = target;\n for (const prop of path) {\n value = value[prop];\n if (value === undefined) {\n return;\n }\n }\n return value as P;\n }\n\n protected override _getInvalidOutputValue(context: FlowGraphContext): P {\n if (Object.prototype.hasOwnProperty.call(this.config, \"invalidValue\")) {\n return CloneInvalidValue(this.config.invalidValue) as P;\n }\n return super._getInvalidOutputValue(context);\n }\n\n /**\n * Returns the class name of this block.\n * @returns the class name\n */\n public override getClassName(): string {\n return FlowGraphBlockNames.GetProperty;\n }\n}\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphGetPropertyBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphGetPropertyBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.GetProperty, FlowGraphGetPropertyBlock);\n}\n"]}
|
|
@@ -3,12 +3,20 @@ import { FlowGraphEventBlock } from "../../flowGraphEventBlock.js";
|
|
|
3
3
|
import { type FlowGraphContext } from "../../flowGraphContext.js";
|
|
4
4
|
import { type FlowGraphDataConnection } from "../../flowGraphDataConnection.pure.js";
|
|
5
5
|
import { FlowGraphEventType } from "../../flowGraphEventType.js";
|
|
6
|
+
import { type IFlowGraphBlockConfiguration } from "../../flowGraphBlock.js";
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for the scene tick event.
|
|
9
|
+
*/
|
|
10
|
+
export interface IFlowGraphSceneTickEventBlockConfiguration extends IFlowGraphBlockConfiguration {
|
|
11
|
+
/** Whether elapsed time starts at the first tick, whose delta time remains NaN. Defaults to false. */
|
|
12
|
+
useFirstTickAsStart?: boolean;
|
|
13
|
+
}
|
|
6
14
|
/**
|
|
7
15
|
* Payload for the scene tick event.
|
|
8
16
|
*/
|
|
9
17
|
export interface IFlowGraphOnTickEventPayload {
|
|
10
18
|
/**
|
|
11
|
-
*
|
|
19
|
+
* The scene's accumulated time in seconds before the current frame interval.
|
|
12
20
|
*/
|
|
13
21
|
timeSinceStart: number;
|
|
14
22
|
/**
|
|
@@ -21,11 +29,11 @@ export interface IFlowGraphOnTickEventPayload {
|
|
|
21
29
|
*/
|
|
22
30
|
export declare class FlowGraphSceneTickEventBlock extends FlowGraphEventBlock {
|
|
23
31
|
/**
|
|
24
|
-
*
|
|
32
|
+
* Time in seconds since the scene started, or since the first tick when useFirstTickAsStart is enabled.
|
|
25
33
|
*/
|
|
26
34
|
readonly timeSinceStart: FlowGraphDataConnection<number>;
|
|
27
35
|
/**
|
|
28
|
-
*
|
|
36
|
+
* Time in seconds since the last frame. Remains NaN on the first opted-in tick.
|
|
29
37
|
*/
|
|
30
38
|
readonly deltaTime: FlowGraphDataConnection<number>;
|
|
31
39
|
/**
|
|
@@ -37,7 +45,11 @@ export declare class FlowGraphSceneTickEventBlock extends FlowGraphEventBlock {
|
|
|
37
45
|
readonly type: FlowGraphEventType;
|
|
38
46
|
/** @returns the shared scene-tick event key */
|
|
39
47
|
get eventKey(): string;
|
|
40
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Creates a scene tick event block.
|
|
50
|
+
* @param config optional clock behavior
|
|
51
|
+
*/
|
|
52
|
+
constructor(config?: IFlowGraphSceneTickEventBlockConfiguration);
|
|
41
53
|
_updateOutputs(context: FlowGraphContext): void;
|
|
42
54
|
/**
|
|
43
55
|
* @internal
|
|
@@ -12,11 +12,15 @@ export class FlowGraphSceneTickEventBlock extends FlowGraphEventBlock {
|
|
|
12
12
|
get eventKey() {
|
|
13
13
|
return EventKey;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Creates a scene tick event block.
|
|
17
|
+
* @param config optional clock behavior
|
|
18
|
+
*/
|
|
19
|
+
constructor(config) {
|
|
20
|
+
super(config);
|
|
17
21
|
this.type = "SceneBeforeRender" /* FlowGraphEventType.SceneBeforeRender */;
|
|
18
|
-
this.timeSinceStart = this.registerDataOutput("timeSinceStart", RichTypeNumber);
|
|
19
|
-
this.deltaTime = this.registerDataOutput("deltaTime", RichTypeNumber);
|
|
22
|
+
this.timeSinceStart = this.registerDataOutput("timeSinceStart", RichTypeNumber, config?.useFirstTickAsStart ? NaN : 0);
|
|
23
|
+
this.deltaTime = this.registerDataOutput("deltaTime", RichTypeNumber, config?.useFirstTickAsStart ? NaN : 0);
|
|
20
24
|
this.eventRef = this.registerDataOutput("event", RichTypeString);
|
|
21
25
|
}
|
|
22
26
|
_updateOutputs(context) {
|
|
@@ -32,8 +36,18 @@ export class FlowGraphSceneTickEventBlock extends FlowGraphEventBlock {
|
|
|
32
36
|
* @internal
|
|
33
37
|
*/
|
|
34
38
|
_executeEvent(context, payload) {
|
|
35
|
-
this.
|
|
36
|
-
|
|
39
|
+
if (this.config?.useFirstTickAsStart) {
|
|
40
|
+
const firstTick = context._getGlobalContextVariable("firstTickPayload", payload);
|
|
41
|
+
context._setGlobalContextVariable("firstTickPayload", firstTick);
|
|
42
|
+
// The scene counter advances after dispatch; elapsed time uses the current tick's interval instead of the first one.
|
|
43
|
+
const elapsedTime = payload.timeSinceStart - firstTick.timeSinceStart + payload.deltaTime - firstTick.deltaTime;
|
|
44
|
+
this.timeSinceStart.setValue(payload === firstTick ? 0 : elapsedTime, context);
|
|
45
|
+
this.deltaTime.setValue(payload === firstTick ? NaN : payload.deltaTime, context);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.timeSinceStart.setValue(payload.timeSinceStart, context);
|
|
49
|
+
this.deltaTime.setValue(payload.deltaTime, context);
|
|
50
|
+
}
|
|
37
51
|
this.eventRef.setValue(context.getEventReference(EventKey), context);
|
|
38
52
|
this._execute(context);
|
|
39
53
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphSceneTickEventBlock.pure.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAIxF,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"flowGraphSceneTickEventBlock.pure.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAE7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAIxF,OAAO,EA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AW,GAAG,OAAO,CAAC,cAAc,GAAG,SAAS,CAAC,cAAc,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;YAChH,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAC/E,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACtF,CAAC;aAAM,CAAC;YACJ,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;YAC9D,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACvB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACa,mBAAmB,CAAC,QAA0B;QAC1D,QAAQ;IACZ,CAAC;IAED;;OAEG;IACa,YAAY;QACxB,+EAA0C;IAC9C,CAAC;CACJ;AAED,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,oCAAoC;IAChD,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,0EAAqC,4BAA4B,CAAC,CAAC;AACpF,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\r\n\r\nimport { FlowGraphEventBlock } from \"../../flowGraphEventBlock\";\r\nimport { type FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\r\nimport { RichTypeNumber, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes.pure\";\r\nimport { type FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection.pure\";\r\nimport { FlowGraphBlockNames } from \"../flowGraphBlockNames\";\r\nimport { FlowGraphEventType } from \"core/FlowGraph/flowGraphEventType\";\r\nimport { RegisterClass } from \"../../../Misc/typeStore\";\r\nimport { type IFlowGraphBlockConfiguration } from \"../../flowGraphBlock\";\r\n\r\n/**\r\n * Configuration for the scene tick event.\r\n */\r\nexport interface IFlowGraphSceneTickEventBlockConfiguration extends IFlowGraphBlockConfiguration {\r\n /** Whether elapsed time starts at the first tick, whose delta time remains NaN. Defaults to false. */\r\n useFirstTickAsStart?: boolean;\r\n}\r\n\r\n/** Event source key used to build this block's event reference. */\r\nconst EventKey = \"sceneTick\";\r\n\r\n/**\r\n * Payload for the scene tick event.\r\n */\r\nexport interface IFlowGraphOnTickEventPayload {\r\n /**\r\n * The scene's accumulated time in seconds before the current frame interval.\r\n */\r\n timeSinceStart: number;\r\n /**\r\n * the time in seconds since the last frame.\r\n */\r\n deltaTime: number;\r\n}\r\n\r\n/**\r\n * Block that triggers on scene tick (before each render).\r\n */\r\nexport class FlowGraphSceneTickEventBlock extends FlowGraphEventBlock {\r\n /**\r\n * Time in seconds since the scene started, or since the first tick when useFirstTickAsStart is enabled.\r\n */\r\n public readonly timeSinceStart: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Time in seconds since the last frame. Remains NaN on the first opted-in tick.\r\n */\r\n public readonly deltaTime: FlowGraphDataConnection<number>;\r\n\r\n /**\r\n * Output: the opaque reference identifying this event source.\r\n * All instances of this block share the same reference, so comparing the `event` output of two\r\n * of them for equality succeeds. The reference format is owned by the host environment.\r\n */\r\n public readonly eventRef: FlowGraphDataConnection<string>;\r\n\r\n public override readonly type: FlowGraphEventType = FlowGraphEventType.SceneBeforeRender;\r\n /** @returns the shared scene-tick event key */\r\n public override get eventKey(): string {\r\n return EventKey;\r\n }\r\n\r\n /**\r\n * Creates a scene tick event block.\r\n * @param config optional clock behavior\r\n */\r\n constructor(config?: IFlowGraphSceneTickEventBlockConfiguration) {\r\n super(config);\r\n this.timeSinceStart = this.registerDataOutput(\"timeSinceStart\", RichTypeNumber, config?.useFirstTickAsStart ? NaN : 0);\r\n this.deltaTime = this.registerDataOutput(\"deltaTime\", RichTypeNumber, config?.useFirstTickAsStart ? NaN : 0);\r\n this.eventRef = this.registerDataOutput(\"event\", RichTypeString);\r\n }\r\n\r\n public override _updateOutputs(context: FlowGraphContext): void {\r\n this.eventRef.setValue(context.getEventReference(EventKey), context);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _preparePendingTasks(_context: FlowGraphContext): void {\r\n // no-op\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _executeEvent(context: FlowGraphContext, payload: IFlowGraphOnTickEventPayload): boolean {\r\n if (this.config?.useFirstTickAsStart) {\r\n const firstTick = context._getGlobalContextVariable(\"firstTickPayload\", payload);\r\n context._setGlobalContextVariable(\"firstTickPayload\", firstTick);\r\n // The scene counter advances after dispatch; elapsed time uses the current tick's interval instead of the first one.\r\n const elapsedTime = payload.timeSinceStart - firstTick.timeSinceStart + payload.deltaTime - firstTick.deltaTime;\r\n this.timeSinceStart.setValue(payload === firstTick ? 0 : elapsedTime, context);\r\n this.deltaTime.setValue(payload === firstTick ? NaN : payload.deltaTime, context);\r\n } else {\r\n this.timeSinceStart.setValue(payload.timeSinceStart, context);\r\n this.deltaTime.setValue(payload.deltaTime, context);\r\n }\r\n this.eventRef.setValue(context.getEventReference(EventKey), context);\r\n this._execute(context);\r\n return true;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public override _cancelPendingTasks(_context: FlowGraphContext) {\r\n // no-op\r\n }\r\n\r\n /**\r\n * @returns class name of the block.\r\n */\r\n public override getClassName(): string {\r\n return FlowGraphBlockNames.SceneTickEvent;\r\n }\r\n}\r\n\r\nlet _Registered = false;\r\n/**\r\n * Register side effects for flowGraphSceneTickEventBlock.\r\n * Safe to call multiple times; only the first call has an effect.\r\n */\r\nexport function RegisterFlowGraphSceneTickEventBlock(): void {\r\n if (_Registered) {\r\n return;\r\n }\r\n _Registered = true;\r\n\r\n RegisterClass(FlowGraphBlockNames.SceneTickEvent, FlowGraphSceneTickEventBlock);\r\n}\r\n"]}
|
|
@@ -65,16 +65,16 @@ export class FlowGraphInterpolationBlock extends FlowGraphBlock {
|
|
|
65
65
|
const type = this.initialValue.richType;
|
|
66
66
|
const keys = [];
|
|
67
67
|
// add initial value
|
|
68
|
-
const currentValue = this.initialValue.getValue(context)
|
|
68
|
+
const currentValue = this.initialValue.getValue(context) ?? type.defaultValue;
|
|
69
69
|
keys.push({ frame: 0, value: currentValue });
|
|
70
70
|
const numberOfKeyFrames = this.config?.numberOfKeyFrames ?? 1;
|
|
71
71
|
for (let i = 1; i < numberOfKeyFrames + 1; i++) {
|
|
72
72
|
const duration = this.keyFrames[i].duration?.getValue(context);
|
|
73
73
|
let value = this.keyFrames[i].value?.getValue(context);
|
|
74
74
|
if (i === numberOfKeyFrames - 1) {
|
|
75
|
-
value = value
|
|
75
|
+
value = value ?? type.defaultValue;
|
|
76
76
|
}
|
|
77
|
-
if (duration !== undefined && value) {
|
|
77
|
+
if (duration !== undefined && value !== undefined && value !== null) {
|
|
78
78
|
// convert duration to frames, based on 60 fps
|
|
79
79
|
keys.push({ frame: duration * 60, value });
|
|
80
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphInterpolationBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAqC,MAAM,+BAA+B,CAAC;AAGlG,OAAO,EAAuB,0BAA0B,EAAE,0B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,IAAI,CAAC;IAEnB,aAAa,6EAAyC,2BAA2B,CAAC,CAAC;AACvF,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type EasingFunction } from \"core/Animations/easing\";\nimport { Constants } from \"core/Engines/constants\";\nimport { FlowGraphBlock, type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { type FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection.pure\";\nimport { type FlowGraphTypes, getRichTypeByAnimationType, getRichTypeByFlowGraphType, RichTypeAny, RichTypeNumber, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes.pure\";\nimport { type Animation, AnimationCreateAnimation } from \"core/Animations/animation.pure\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * Configuration for the interpolation block.\n */\nexport interface IFlowGraphInterpolationBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The number of keyframes to interpolate between.\n * Will default to 1 if not provided (i.e. from currentValue to a provided value in the time provided)\n */\n keyFramesCount?: number;\n\n /**\n * The duration of the interpolation.\n */\n duration?: number;\n\n /**\n * The name of the property that will be interpolated.\n */\n propertyName?: string | string[];\n\n /**\n * The type of the animation to create.\n * Default is ANIMATIONTYPE_FLOAT\n * This cannot be changed after construction, so make sure to pass the right value.\n */\n animationType?: number | FlowGraphTypes;\n}\n\n/**\n * This block is responsible for interpolating between two values.\n * The babylon concept used is Animation, and it is the output of this block.\n *\n * Note that values will be parsed when the in connection is triggered. until then changing the value will not trigger a new interpolation.\n *\n * Internally this block uses the Animation class.\n *\n * Note that if the interpolation is already running a signal will be sent to stop the animation group running it.\n */\nexport class FlowGraphInterpolationBlock<T> extends FlowGraphBlock {\n /**\n * Input connection: The value to interpolate from.\n * Optional. If not provided, the current value will be used.\n * Note that if provided, every time the animation is created this value will be used!\n */\n public readonly initialValue: FlowGraphDataConnection<T>;\n\n /**\n * Input connection: The value to interpolate to.\n * Optional. This can also be set using the KeyFrames input!\n * If provided it will be set to the last keyframe value.\n */\n public readonly endValue: FlowGraphDataConnection<T>;\n\n /**\n * output connection: The animation that will be created when in is triggered.\n */\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\n\n /**\n * Input connection: An optional easing function to use for the interpolation.\n */\n public readonly easingFunction: FlowGraphDataConnection<EasingFunction>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string | string[]>;\n\n /**\n * If provided, this function will be used to create the animation object(s).\n */\n public readonly customBuildAnimation: FlowGraphDataConnection<\n (target: any, propertname: any, context: FlowGraphContext) => (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation | Animation[]\n >;\n\n /**\n * The keyframes to interpolate between.\n * Each keyframe has a duration input and a value input.\n */\n public readonly keyFrames: {\n duration: FlowGraphDataConnection<number>;\n value: FlowGraphDataConnection<T>;\n }[] = [];\n\n constructor(config: IFlowGraphInterpolationBlockConfiguration = {}) {\n super(config);\n const type =\n typeof config?.animationType === \"string\"\n ? getRichTypeByFlowGraphType(config.animationType)\n : getRichTypeByAnimationType(config?.animationType ?? Constants.ANIMATIONTYPE_FLOAT);\n\n const numberOfKeyFrames = config?.keyFramesCount ?? 1;\n const duration = this.registerDataInput(`duration_0`, RichTypeNumber, 0);\n const value = this.registerDataInput(`value_0`, type);\n this.keyFrames.push({ duration, value });\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.registerDataInput(`duration_${i}`, RichTypeNumber, i === numberOfKeyFrames ? config.duration : undefined);\n const value = this.registerDataInput(`value_${i}`, type);\n this.keyFrames.push({ duration, value });\n }\n this.initialValue = this.keyFrames[0].value;\n this.endValue = this.keyFrames[numberOfKeyFrames].value;\n this.easingFunction = this.registerDataInput(\"easingFunction\", RichTypeAny);\n this.animation = this.registerDataOutput(\"animation\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeString, config?.propertyName);\n this.customBuildAnimation = this.registerDataInput(\"customBuildAnimation\", RichTypeAny);\n }\n\n public override _updateOutputs(context: FlowGraphContext): void {\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\n const propertyName = this.propertyName.getValue(context);\n const easingFunction = this.easingFunction.getValue(context);\n const animation = this._createAnimation(context, propertyName, easingFunction);\n // If an old animation exists, it will be ignored here.\n // This is because if the animation is running and they both have the same target, the old will be stopped.\n // This doesn't happen here, it happens in the play animation block.\n this.animation.setValue(animation, context);\n // to make sure no 2 interpolations are running on the same target, we will mark the animation in the context\n if (Array.isArray(animation)) {\n for (const anim of animation) {\n interpolationAnimations.push(anim.uniqueId);\n }\n } else {\n interpolationAnimations.push(animation.uniqueId);\n }\n context._setGlobalContextVariable(\"interpolationAnimations\", interpolationAnimations);\n }\n\n private _createAnimation(context: FlowGraphContext, propertyName: string | string[], easingFunction: EasingFunction): Animation | Animation[] {\n const type = this.initialValue.richType;\n const keys: { frame: number; value: T }[] = [];\n // add initial value\n const currentValue = this.initialValue.getValue(context) || type.defaultValue;\n keys.push({ frame: 0, value: currentValue });\n const numberOfKeyFrames = this.config?.numberOfKeyFrames ?? 1;\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.keyFrames[i].duration?.getValue(context);\n let value = this.keyFrames[i].value?.getValue(context);\n if (i === numberOfKeyFrames - 1) {\n value = value || type.defaultValue;\n }\n if (duration !== undefined && value) {\n // convert duration to frames, based on 60 fps\n keys.push({ frame: duration * 60, value });\n }\n }\n const customBuildAnimation = this.customBuildAnimation.getValue(context);\n if (customBuildAnimation) {\n return customBuildAnimation(null, null, context)(keys, 60, type.animationType, easingFunction);\n }\n if (typeof propertyName === \"string\") {\n const animation = AnimationCreateAnimation(propertyName, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return [animation];\n } else {\n const animations = propertyName.map((name) => {\n const animation = AnimationCreateAnimation(name, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return animation;\n });\n return animations;\n }\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.ValueInterpolation;\n }\n}\n\n// #L54P2C\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphInterpolationBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphInterpolationBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.ValueInterpolation, FlowGraphInterpolationBlock);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphInterpolationBlock.pure.js","sourceRoot":"","sources":["../../../../../../../dev/core/src/FlowGraph/Blocks/Execution/Animation/flowGraphInterpolationBlock.pure.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAG7D,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAqC,MAAM,+BAA+B,CAAC;AAGlG,OAAO,EAAuB,0BAA0B,EAAE,0BAA0B,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAClL,OAAO,EAAkB,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAE1F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA8BpD;;;;;;;;;GASG;AACH,MAAM,OAAO,2BAA+B,SAAQ,cAAc;IA8C9D,YAAY,SAAoD,EAAE;QAC9D,KAAK,CAAC,MAAM,CAAC,CAAC;QAVlB;;;WAGG;QACa,cAAS,GAGnB,EAAE,CAAC;QAIL,MAAM,IAAI,GACN,OAAO,MAAM,EAAE,aAAa,KAAK,QAAQ;YACrC,CAAC,CAAC,0BAA0B,CAAC,MAAM,CAAC,aAAa,CAAC;YAClD,CAAC,CAAC,0BAA0B,CAAC,MAAM,EAAE,aAAa,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAE7F,MAAM,iBAAiB,GAAG,MAAM,EAAE,cAAc,IAAI,CAAC,CAAC;QACtD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AAc,CAAC,CAAC;YACjG,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;YACxB,OAAO,CAAC,SAAS,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACJ,MAAM,UAAU,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;gBACzC,MAAM,SAAS,GAAG,wBAAwB,CAAC,IAAI,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,cAAc,CAAC,CAAC;gBACzF,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACxB,OAAO,SAAS,CAAC;YACrB,CAAC,CAAC,CAAC;YACH,OAAO,UAAU,CAAC;QACtB,CAAC;IACL,CAAC;IAEe,YAAY;QACxB,kFAA8C;IAClD,CAAC;CACJ;AAED,UAAU;AAEV,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB;;;GAGG;AACH,MAAM,UAAU,mCAAmC;IAC/C,IAAI,WAAW,EAAE,CAAC;QACd,OAAO;IACX,CAAC;IACD,WAAW,GAAG,IAAI,CAAC;IAEnB,aAAa,6EAAyC,2BAA2B,CAAC,CAAC;AACvF,CAAC","sourcesContent":["/** This file must only contain pure code and pure imports */\n\nimport { type EasingFunction } from \"core/Animations/easing\";\nimport { Constants } from \"core/Engines/constants\";\nimport { FlowGraphBlock, type IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\nimport { type FlowGraphContext } from \"core/FlowGraph/flowGraphContext\";\nimport { type FlowGraphDataConnection } from \"core/FlowGraph/flowGraphDataConnection.pure\";\nimport { type FlowGraphTypes, getRichTypeByAnimationType, getRichTypeByFlowGraphType, RichTypeAny, RichTypeNumber, RichTypeString } from \"core/FlowGraph/flowGraphRichTypes.pure\";\nimport { type Animation, AnimationCreateAnimation } from \"core/Animations/animation.pure\";\nimport { FlowGraphBlockNames } from \"../../flowGraphBlockNames\";\nimport { RegisterClass } from \"core/Misc/typeStore\";\n\n/**\n * Configuration for the interpolation block.\n */\nexport interface IFlowGraphInterpolationBlockConfiguration extends IFlowGraphBlockConfiguration {\n /**\n * The number of keyframes to interpolate between.\n * Will default to 1 if not provided (i.e. from currentValue to a provided value in the time provided)\n */\n keyFramesCount?: number;\n\n /**\n * The duration of the interpolation.\n */\n duration?: number;\n\n /**\n * The name of the property that will be interpolated.\n */\n propertyName?: string | string[];\n\n /**\n * The type of the animation to create.\n * Default is ANIMATIONTYPE_FLOAT\n * This cannot be changed after construction, so make sure to pass the right value.\n */\n animationType?: number | FlowGraphTypes;\n}\n\n/**\n * This block is responsible for interpolating between two values.\n * The babylon concept used is Animation, and it is the output of this block.\n *\n * Note that values will be parsed when the in connection is triggered. until then changing the value will not trigger a new interpolation.\n *\n * Internally this block uses the Animation class.\n *\n * Note that if the interpolation is already running a signal will be sent to stop the animation group running it.\n */\nexport class FlowGraphInterpolationBlock<T> extends FlowGraphBlock {\n /**\n * Input connection: The value to interpolate from.\n * Optional. If not provided, the current value will be used.\n * Note that if provided, every time the animation is created this value will be used!\n */\n public readonly initialValue: FlowGraphDataConnection<T>;\n\n /**\n * Input connection: The value to interpolate to.\n * Optional. This can also be set using the KeyFrames input!\n * If provided it will be set to the last keyframe value.\n */\n public readonly endValue: FlowGraphDataConnection<T>;\n\n /**\n * output connection: The animation that will be created when in is triggered.\n */\n public readonly animation: FlowGraphDataConnection<Animation | Animation[]>;\n\n /**\n * Input connection: An optional easing function to use for the interpolation.\n */\n public readonly easingFunction: FlowGraphDataConnection<EasingFunction>;\n\n /**\n * Input connection: The name of the property that will be set\n */\n public readonly propertyName: FlowGraphDataConnection<string | string[]>;\n\n /**\n * If provided, this function will be used to create the animation object(s).\n */\n public readonly customBuildAnimation: FlowGraphDataConnection<\n (target: any, propertname: any, context: FlowGraphContext) => (keys: any[], fps: number, animationType: number, easingFunction?: EasingFunction) => Animation | Animation[]\n >;\n\n /**\n * The keyframes to interpolate between.\n * Each keyframe has a duration input and a value input.\n */\n public readonly keyFrames: {\n duration: FlowGraphDataConnection<number>;\n value: FlowGraphDataConnection<T>;\n }[] = [];\n\n constructor(config: IFlowGraphInterpolationBlockConfiguration = {}) {\n super(config);\n const type =\n typeof config?.animationType === \"string\"\n ? getRichTypeByFlowGraphType(config.animationType)\n : getRichTypeByAnimationType(config?.animationType ?? Constants.ANIMATIONTYPE_FLOAT);\n\n const numberOfKeyFrames = config?.keyFramesCount ?? 1;\n const duration = this.registerDataInput(`duration_0`, RichTypeNumber, 0);\n const value = this.registerDataInput(`value_0`, type);\n this.keyFrames.push({ duration, value });\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.registerDataInput(`duration_${i}`, RichTypeNumber, i === numberOfKeyFrames ? config.duration : undefined);\n const value = this.registerDataInput(`value_${i}`, type);\n this.keyFrames.push({ duration, value });\n }\n this.initialValue = this.keyFrames[0].value;\n this.endValue = this.keyFrames[numberOfKeyFrames].value;\n this.easingFunction = this.registerDataInput(\"easingFunction\", RichTypeAny);\n this.animation = this.registerDataOutput(\"animation\", RichTypeAny);\n this.propertyName = this.registerDataInput(\"propertyName\", RichTypeString, config?.propertyName);\n this.customBuildAnimation = this.registerDataInput(\"customBuildAnimation\", RichTypeAny);\n }\n\n public override _updateOutputs(context: FlowGraphContext): void {\n const interpolationAnimations = context._getGlobalContextVariable(\"interpolationAnimations\", []) as number[];\n const propertyName = this.propertyName.getValue(context);\n const easingFunction = this.easingFunction.getValue(context);\n const animation = this._createAnimation(context, propertyName, easingFunction);\n // If an old animation exists, it will be ignored here.\n // This is because if the animation is running and they both have the same target, the old will be stopped.\n // This doesn't happen here, it happens in the play animation block.\n this.animation.setValue(animation, context);\n // to make sure no 2 interpolations are running on the same target, we will mark the animation in the context\n if (Array.isArray(animation)) {\n for (const anim of animation) {\n interpolationAnimations.push(anim.uniqueId);\n }\n } else {\n interpolationAnimations.push(animation.uniqueId);\n }\n context._setGlobalContextVariable(\"interpolationAnimations\", interpolationAnimations);\n }\n\n private _createAnimation(context: FlowGraphContext, propertyName: string | string[], easingFunction: EasingFunction): Animation | Animation[] {\n const type = this.initialValue.richType;\n const keys: { frame: number; value: T }[] = [];\n // add initial value\n const currentValue = this.initialValue.getValue(context) ?? type.defaultValue;\n keys.push({ frame: 0, value: currentValue });\n const numberOfKeyFrames = this.config?.numberOfKeyFrames ?? 1;\n for (let i = 1; i < numberOfKeyFrames + 1; i++) {\n const duration = this.keyFrames[i].duration?.getValue(context);\n let value = this.keyFrames[i].value?.getValue(context);\n if (i === numberOfKeyFrames - 1) {\n value = value ?? type.defaultValue;\n }\n if (duration !== undefined && value !== undefined && value !== null) {\n // convert duration to frames, based on 60 fps\n keys.push({ frame: duration * 60, value });\n }\n }\n const customBuildAnimation = this.customBuildAnimation.getValue(context);\n if (customBuildAnimation) {\n return customBuildAnimation(null, null, context)(keys, 60, type.animationType, easingFunction);\n }\n if (typeof propertyName === \"string\") {\n const animation = AnimationCreateAnimation(propertyName, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return [animation];\n } else {\n const animations = propertyName.map((name) => {\n const animation = AnimationCreateAnimation(name, type.animationType, 60, easingFunction);\n animation.setKeys(keys);\n return animation;\n });\n return animations;\n }\n }\n\n public override getClassName(): string {\n return FlowGraphBlockNames.ValueInterpolation;\n }\n}\n\n// #L54P2C\n\nlet _Registered = false;\n/**\n * Register side effects for flowGraphInterpolationBlock.\n * Safe to call multiple times; only the first call has an effect.\n */\nexport function RegisterFlowGraphInterpolationBlock(): void {\n if (_Registered) {\n return;\n }\n _Registered = true;\n\n RegisterClass(FlowGraphBlockNames.ValueInterpolation, FlowGraphInterpolationBlock);\n}\n"]}
|
|
@@ -5,6 +5,8 @@ import { FlowGraphAsyncExecutionBlock } from "../../../flowGraphAsyncExecutionBl
|
|
|
5
5
|
import { type IFlowGraphBlockConfiguration } from "../../../flowGraphBlock.js";
|
|
6
6
|
import { AnimationGroup } from "../../../../Animations/animationGroup.pure.js";
|
|
7
7
|
import { type Animation } from "../../../../Animations/animation.pure.js";
|
|
8
|
+
import { type IAnimatable } from "../../../../Animations/animatable.interface.js";
|
|
9
|
+
export { RemoveFlowGraphAnimationGroupObservers } from "../../../flowGraphAnimationHelpers.js";
|
|
8
10
|
/**
|
|
9
11
|
* Configuration for playing an animation.
|
|
10
12
|
*/
|
|
@@ -14,13 +16,6 @@ export interface IFlowGraphPlayAnimationBlockConfiguration extends IFlowGraphBlo
|
|
|
14
16
|
*/
|
|
15
17
|
useVirtualTimeline?: boolean;
|
|
16
18
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Removes observers owned by the play block that started an animation group.
|
|
19
|
-
* @param context active FlowGraph context
|
|
20
|
-
* @param animationGroup animation group being replaced or stopped
|
|
21
|
-
* @returns the owning play block, when one was registered
|
|
22
|
-
*/
|
|
23
|
-
export declare function RemoveFlowGraphAnimationGroupObservers(context: FlowGraphContext, animationGroup: AnimationGroup): FlowGraphPlayAnimationBlock | undefined;
|
|
24
19
|
/**
|
|
25
20
|
* @experimental
|
|
26
21
|
* A block that plays an animation on an animatable object.
|
|
@@ -67,6 +62,11 @@ export declare class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecution
|
|
|
67
62
|
* Input: If provided this animation will be used. Priority will be given to the animation group input.
|
|
68
63
|
*/
|
|
69
64
|
readonly animation: FlowGraphDataConnection<Animation | Animation[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Input connection: Optional targets matching the animation array in order.
|
|
67
|
+
* When supplied, these replace the single object target. Ignored when animationGroup is supplied.
|
|
68
|
+
*/
|
|
69
|
+
readonly animationTargets: FlowGraphDataConnection<IAnimatable[] | undefined>;
|
|
70
70
|
/**
|
|
71
71
|
* Input connection: The target object that will be animated. If animation group is provided this input will be ignored.
|
|
72
72
|
*/
|