@babylonjs/core 6.30.0 → 6.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Actions/action.js.map +1 -1
- package/Animations/animation.d.ts +8 -2
- package/Animations/animation.js +21 -13
- package/Animations/animation.js.map +1 -1
- package/Animations/runtimeAnimation.js +6 -15
- package/Animations/runtimeAnimation.js.map +1 -1
- package/Cameras/Inputs/freeCameraDeviceOrientationInput.js.map +1 -1
- package/Cameras/camera.js +1 -1
- package/Cameras/camera.js.map +1 -1
- package/Culling/ray.js +24 -24
- package/Culling/ray.js.map +1 -1
- package/Debug/skeletonViewer.d.ts +2 -2
- package/Debug/skeletonViewer.js +38 -12
- package/Debug/skeletonViewer.js.map +1 -1
- package/DeviceInput/InputDevices/deviceSource.js.map +1 -1
- package/DeviceInput/InputDevices/deviceTypes.js.map +1 -1
- package/DeviceInput/webDeviceInputSystem.js.map +1 -1
- package/Engines/Extensions/engine.views.d.ts +8 -5
- package/Engines/Extensions/engine.views.js +14 -8
- package/Engines/Extensions/engine.views.js.map +1 -1
- package/Engines/Processors/shaderCodeNode.js.map +1 -1
- package/Engines/WebGPU/Extensions/engine.multiRender.js +6 -3
- package/Engines/WebGPU/Extensions/engine.multiRender.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsGLSL.js.map +1 -1
- package/Engines/WebGPU/webgpuShaderProcessorsWGSL.js.map +1 -1
- package/Engines/WebGPU/webgpuTextureHelper.js.map +1 -1
- package/Engines/engine.d.ts +16 -1
- package/Engines/engine.js +1 -1
- package/Engines/engine.js.map +1 -1
- package/Engines/thinEngine.js +2 -2
- package/Engines/thinEngine.js.map +1 -1
- package/Engines/webgpuEngine.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js +12 -12
- package/FlowGraph/Blocks/Data/Math/flowGraphMatrixBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js +4 -4
- package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js +9 -9
- package/FlowGraph/Blocks/Data/Math/flowGraphVector2MathBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js +11 -11
- package/FlowGraph/Blocks/Data/Math/flowGraphVector3MathBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js +10 -10
- package/FlowGraph/Blocks/Data/Math/flowGraphVector4MathBlocks.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +2 -2
- package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCachedOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +4 -4
- package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js +1 -1
- package/FlowGraph/Blocks/Data/flowGraphConstantBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js +4 -4
- package/FlowGraph/Blocks/Data/flowGraphCoordinateTransformBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +2 -2
- package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +1 -1
- package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.d.ts +4 -4
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js +16 -6
- package/FlowGraph/Blocks/Event/flowGraphMeshPickEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +5 -1
- package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPauseAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.d.ts +17 -6
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +16 -9
- package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Animation/flowGraphStopAnimationBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphPlayAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/Audio/flowGraphStopAudioBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphBranchBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js +4 -4
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +8 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +5 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +4 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +1 -0
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +6 -1
- package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.d.ts +8 -12
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js +9 -19
- package/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js.map +1 -1
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +2 -2
- package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
- package/FlowGraph/flowGraphBlock.d.ts +2 -2
- package/FlowGraph/flowGraphBlock.js +20 -4
- package/FlowGraph/flowGraphBlock.js.map +1 -1
- package/FlowGraph/flowGraphContext.d.ts +4 -4
- package/FlowGraph/flowGraphContext.js +22 -40
- package/FlowGraph/flowGraphContext.js.map +1 -1
- package/FlowGraph/flowGraphPath.d.ts +27 -0
- package/FlowGraph/flowGraphPath.js +136 -0
- package/FlowGraph/flowGraphPath.js.map +1 -0
- package/FlowGraph/flowGraphPathComponent.d.ts +42 -0
- package/FlowGraph/flowGraphPathComponent.js +51 -0
- package/FlowGraph/flowGraphPathComponent.js.map +1 -0
- package/FlowGraph/index.d.ts +1 -0
- package/FlowGraph/index.js +1 -0
- package/FlowGraph/index.js.map +1 -1
- package/Gizmos/axisDragGizmo.d.ts +4 -2
- package/Gizmos/axisDragGizmo.js +18 -6
- package/Gizmos/axisDragGizmo.js.map +1 -1
- package/Gizmos/axisScaleGizmo.d.ts +2 -2
- package/Gizmos/axisScaleGizmo.js +1 -1
- package/Gizmos/axisScaleGizmo.js.map +1 -1
- package/Gizmos/planeDragGizmo.d.ts +4 -4
- package/Gizmos/planeDragGizmo.js +1 -1
- package/Gizmos/planeDragGizmo.js.map +1 -1
- package/Gizmos/planeRotationGizmo.d.ts +13 -7
- package/Gizmos/planeRotationGizmo.js +26 -10
- package/Gizmos/planeRotationGizmo.js.map +1 -1
- package/Lights/Shadows/shadowGenerator.d.ts +8 -0
- package/Lights/Shadows/shadowGenerator.js +12 -0
- package/Lights/Shadows/shadowGenerator.js.map +1 -1
- package/Loading/sceneLoader.js.map +1 -1
- package/Materials/GreasedLine/greasedLineSimpleMaterial.js.map +1 -1
- package/Materials/Node/Blocks/Fragment/perturbNormalBlock.js.map +1 -1
- package/Materials/Node/Blocks/Teleport/teleportInBlock.d.ts +6 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js +22 -0
- package/Materials/Node/Blocks/Teleport/teleportInBlock.js.map +1 -1
- package/Materials/Node/Blocks/modBlock.js +1 -0
- package/Materials/Node/Blocks/modBlock.js.map +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.d.ts +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js +1 -1
- package/Materials/Textures/Procedurals/proceduralTexture.js.map +1 -1
- package/Materials/Textures/multiRenderTarget.d.ts +14 -10
- package/Materials/Textures/multiRenderTarget.js +7 -5
- package/Materials/Textures/multiRenderTarget.js.map +1 -1
- package/Materials/imageProcessingConfiguration.d.ts +2 -2
- package/Materials/imageProcessingConfiguration.js +2 -2
- package/Materials/imageProcessingConfiguration.js.map +1 -1
- package/Maths/math.size.d.ts +6 -0
- package/Maths/math.size.js +8 -0
- package/Maths/math.size.js.map +1 -1
- package/Maths/math.vector.d.ts +5 -5
- package/Maths/math.vector.js +6 -5
- package/Maths/math.vector.js.map +1 -1
- package/Meshes/Builders/linesBuilder.js +4 -2
- package/Meshes/Builders/linesBuilder.js.map +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.d.ts +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js +1 -1
- package/Meshes/GreasedLine/greasedLineBaseMesh.js.map +1 -1
- package/Meshes/geometry.d.ts +8 -0
- package/Meshes/geometry.js +20 -1
- package/Meshes/geometry.js.map +1 -1
- package/Meshes/groundMesh.js +1 -1
- package/Meshes/groundMesh.js.map +1 -1
- package/Meshes/mesh.d.ts +8 -0
- package/Meshes/mesh.js +14 -2
- package/Meshes/mesh.js.map +1 -1
- package/Meshes/mesh.vertexData.js.map +1 -1
- package/Misc/dds.js.map +1 -1
- package/Misc/greasedLineTools.js.map +1 -1
- package/Misc/tools.js.map +1 -1
- package/Physics/physicsHelper.d.ts +1 -1
- package/Physics/physicsHelper.js +1 -1
- package/Physics/physicsHelper.js.map +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.d.ts +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js +1 -1
- package/PostProcesses/RenderPipeline/Pipelines/ssrRenderingPipeline.js.map +1 -1
- package/PostProcesses/bloomEffect.d.ts +1 -1
- package/PostProcesses/bloomEffect.js +1 -1
- package/PostProcesses/bloomEffect.js.map +1 -1
- package/PostProcesses/postProcess.d.ts +10 -2
- package/PostProcesses/postProcess.js +17 -7
- package/PostProcesses/postProcess.js.map +1 -1
- package/Rendering/depthPeelingRenderer.d.ts +5 -0
- package/Rendering/depthPeelingRenderer.js +33 -9
- package/Rendering/depthPeelingRenderer.js.map +1 -1
- package/Rendering/depthRenderer.js +9 -0
- package/Rendering/depthRenderer.js.map +1 -1
- package/Rendering/geometryBufferRenderer.d.ts +6 -3
- package/Rendering/geometryBufferRenderer.js +28 -10
- package/Rendering/geometryBufferRenderer.js.map +1 -1
- package/Rendering/geometryBufferRendererSceneComponent.d.ts +5 -2
- package/Rendering/geometryBufferRendererSceneComponent.js.map +1 -1
- package/Shaders/ShadersInclude/bonesDeclaration.js +1 -1
- package/Shaders/ShadersInclude/bonesDeclaration.js.map +1 -1
- package/Shaders/depth.vertex.d.ts +2 -0
- package/Shaders/depth.vertex.js +4 -0
- package/Shaders/depth.vertex.js.map +1 -1
- package/XR/features/WebXRAbstractFeature.d.ts +10 -1
- package/XR/features/WebXRAbstractFeature.js +13 -0
- package/XR/features/WebXRAbstractFeature.js.map +1 -1
- package/XR/features/WebXRLightEstimation.d.ts +5 -0
- package/XR/features/WebXRLightEstimation.js +14 -2
- package/XR/features/WebXRLightEstimation.js.map +1 -1
- package/XR/features/WebXRRawCameraAccess.d.ts +81 -0
- package/XR/features/WebXRRawCameraAccess.js +169 -0
- package/XR/features/WebXRRawCameraAccess.js.map +1 -0
- package/XR/features/index.d.ts +1 -0
- package/XR/features/index.js +1 -0
- package/XR/features/index.js.map +1 -1
- package/XR/webXRFeaturesManager.d.ts +13 -0
- package/XR/webXRFeaturesManager.js +4 -0
- package/XR/webXRFeaturesManager.js.map +1 -1
- package/package.json +1 -1
- package/scene.d.ts +1 -1
- package/scene.js +11 -6
- package/scene.js.map +1 -1
- package/types.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAgBhD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAoCzB,YAAY,MAAsC;QAnClD;;WAEG;QAEI,aAAQ,GAAG,UAAU,EAAE,CAAC;QAC/B;;WAEG;QACK,mBAAc,GAAqB,IAAI,GAAG,EAAE,CAAC;QACrD;;WAEG;QACK,wBAAmB,GAAqB,IAAI,GAAG,EAAE,CAAC;QAC1D;;WAEG;QACK,sBAAiB,GAAqB,IAAI,GAAG,EAAE,CAAC;QAKxD;;WAEG;QACK,mBAAc,GAAmC,EAAE,CAAC;QAC5D;;;WAGG;QACK,iBAAY,GAAG,CAAC,CAAC;QACzB;;WAEG;QACI,6BAAwB,GAA+B,IAAI,UAAU,EAAkB,CAAC;QAG3F,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IACjC,CAAC;IA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M,CAAC;IAClB,CAAC;CACJ;AAjRU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n * @experimental\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n}\r\n/**\r\n * @experimental\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * These are the variables defined by a user.\r\n */\r\n private _userVariables: Map<string, any> = new Map();\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: Map<string, any> = new Map();\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: Map<string, any> = new Map();\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name\r\n * @returns\r\n */\r\n public hasVariable(name: string) {\r\n return this._userVariables.has(name);\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name\r\n * @param value\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables.set(name, value);\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name\r\n * @returns\r\n */\r\n public getVariable(name: string): any {\r\n return this._userVariables.get(name);\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables.set(this._getUniqueIdPrefixedName(block, name), value);\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable(block: FlowGraphBlock, name: string, defaultValue?: any): any {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables.get(this._getUniqueIdPrefixedName(block, name));\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n this._executionVariables.delete(this._getUniqueIdPrefixedName(block, name));\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._executionVariables.has(this._getUniqueIdPrefixedName(block, name));\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return this._connectionValues.has(connectionPoint.uniqueId);\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues.set(connectionPoint.uniqueId, value);\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n return this._connectionValues.get(connectionPoint.uniqueId);\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n this._pendingBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n private _getEnclosedSubstring(subString: string): string {\r\n return `{${subString}}`;\r\n }\r\n\r\n /** @internal */\r\n public _getTargetFromPath(path: string, subString: string, block: FlowGraphBlock) {\r\n let finalPath = path;\r\n if (subString && path.indexOf(this._getEnclosedSubstring(subString)) !== -1) {\r\n const nodeToSub = block.getDataInput(subString);\r\n if (!nodeToSub) {\r\n throw new Error(`Invalid substitution input for substitution string ${subString}`);\r\n }\r\n const index = Math.floor(nodeToSub.getValue(this));\r\n if (isNaN(index)) {\r\n throw new Error(`Invalid substitution value for substitution string ${subString}`);\r\n }\r\n finalPath = path.replace(this._getEnclosedSubstring(subString), index.toString());\r\n }\r\n return this.getVariable(finalPath);\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n this._userVariables.forEach((value, key) => {\r\n valueSerializationFunction(key, value, serializationObject._userVariables);\r\n });\r\n serializationObject._connectionValues = {};\r\n this._connectionValues.forEach((value, key) => {\r\n valueSerializationFunction(key, value, serializationObject._connectionValues);\r\n });\r\n }\r\n\r\n public getClassName() {\r\n return \"FGContext\";\r\n }\r\n\r\n /**\r\n * Parses a context\r\n * @param serializationObject the object containing the context serialization values\r\n * @param graph the graph to which the context should belong\r\n * @param valueParseFunction a function to parse complex values\r\n * @returns\r\n */\r\n public static Parse(\r\n serializationObject: any = {},\r\n graph: FlowGraph,\r\n valueParseFunction: (key: string, serializationObject: any, scene: Scene) => any = defaultValueParseFunction\r\n ): FlowGraphContext {\r\n const result = graph.createContext();\r\n result.uniqueId = serializationObject.uniqueId;\r\n for (const key in serializationObject._userVariables) {\r\n const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);\r\n result._userVariables.set(key, value);\r\n }\r\n for (const key in serializationObject._connectionValues) {\r\n const value = valueParseFunction(key, serializationObject._connectionValues, result._configuration.scene);\r\n result._connectionValues.set(key, value);\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"flowGraphContext.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphContext.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAM1C,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,iBAAiB,CAAC;AAE/F,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAgBhD;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IAqCzB,YAAY,MAAsC;QApClD;;WAEG;QAEI,aAAQ,GAAG,UAAU,EAAE,CAAC;QAC/B;;;WAGG;QACI,mBAAc,GAA2B,EAAE,CAAC;QACnD;;WAEG;QACK,wBAAmB,GAA2B,EAAE,CAAC;QACzD;;WAEG;QACK,sBAAiB,GAA2B,EAAE,CAAC;QAKvD;;WAEG;QACK,mBAAc,GAAmC,EAAE,CAAC;QAC5D;;;WAGG;QACK,iBAAY,GAAG,CAAC,CAAC;QACzB;;WAEG;QACI,6BAAwB,GAA+B,IAAI,UAAU,EAAkB,CAAC;QAG3F,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,IAAY;QAC3B,OAAO,IAAI,IAAI,IAAI,CAAC,cAAc,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,IAAY,EAAE,KAAU;QACvC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,KAA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C;IAClB,CAAC;CACJ;AA7PU;IADN,SAAS,EAAE;kDACmB","sourcesContent":["import { serialize } from \"../Misc/decorators\";\r\nimport { RandomGUID } from \"../Misc/guid\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { FlowGraphAsyncExecutionBlock } from \"./flowGraphAsyncExecutionBlock\";\r\nimport type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraph } from \"./flowGraph\";\r\nimport { defaultValueParseFunction, defaultValueSerializationFunction } from \"./serialization\";\r\nimport type { FlowGraphCoordinator } from \"./flowGraphCoordinator\";\r\nimport { Observable } from \"../Misc/observable\";\r\n\r\n/**\r\n * Construction parameters for the context.\r\n * @experimental\r\n */\r\nexport interface IFlowGraphContextConfiguration {\r\n /**\r\n * The scene that the flow graph context belongs to.\r\n */\r\n readonly scene: Scene;\r\n /**\r\n * The event coordinator used by the flow graph context.\r\n */\r\n readonly coordinator: FlowGraphCoordinator;\r\n}\r\n/**\r\n * @experimental\r\n * The context represents the current state and execution of the flow graph.\r\n * It contains both user-defined variables, which are derived from\r\n * a more general variable definition, and execution variables that\r\n * are set by the blocks.\r\n */\r\nexport class FlowGraphContext {\r\n /**\r\n * A randomly generated GUID for each context.\r\n */\r\n @serialize()\r\n public uniqueId = RandomGUID();\r\n /**\r\n * @internal\r\n * These are the variables defined by a user.\r\n */\r\n public _userVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the blocks.\r\n */\r\n private _executionVariables: { [key: string]: any } = {};\r\n /**\r\n * These are the values for the data connection points\r\n */\r\n private _connectionValues: { [key: string]: any } = {};\r\n /**\r\n * These are the variables set by the graph.\r\n */\r\n private readonly _configuration: IFlowGraphContextConfiguration;\r\n /**\r\n * These are blocks that have currently pending tasks/listeners that need to be cleaned up.\r\n */\r\n private _pendingBlocks: FlowGraphAsyncExecutionBlock[] = [];\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n private _executionId = 0;\r\n /**\r\n * Observable that is triggered when a node is executed.\r\n */\r\n public onNodeExecutedObservable: Observable<FlowGraphBlock> = new Observable<FlowGraphBlock>();\r\n\r\n constructor(params: IFlowGraphContextConfiguration) {\r\n this._configuration = params;\r\n }\r\n\r\n /**\r\n * Check if a user-defined variable is defined.\r\n * @param name\r\n * @returns\r\n */\r\n public hasVariable(name: string) {\r\n return name in this._userVariables;\r\n }\r\n\r\n /**\r\n * Set a user-defined variable.\r\n * @param name\r\n * @param value\r\n */\r\n public setVariable(name: string, value: any) {\r\n this._userVariables[name] = value;\r\n }\r\n\r\n /**\r\n * Get a user-defined variable.\r\n * @param name\r\n * @returns\r\n */\r\n public getVariable(name: string): any {\r\n return this._userVariables[name];\r\n }\r\n\r\n private _getUniqueIdPrefixedName(obj: FlowGraphBlock, name: string): string {\r\n return `${obj.uniqueId}_${name}`;\r\n }\r\n\r\n /**\r\n * Set an internal execution variable\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public _setExecutionVariable(block: FlowGraphBlock, name: string, value: any) {\r\n this._executionVariables[this._getUniqueIdPrefixedName(block, name)] = value;\r\n }\r\n\r\n /**\r\n * Get an internal execution variable\r\n * @internal\r\n * @param name\r\n * @returns\r\n */\r\n public _getExecutionVariable(block: FlowGraphBlock, name: string, defaultValue?: any): any {\r\n if (this._hasExecutionVariable(block, name)) {\r\n return this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n } else {\r\n return defaultValue;\r\n }\r\n }\r\n\r\n /**\r\n * Delete an internal execution variable\r\n * @internal\r\n * @param block\r\n * @param name\r\n */\r\n public _deleteExecutionVariable(block: FlowGraphBlock, name: string) {\r\n delete this._executionVariables[this._getUniqueIdPrefixedName(block, name)];\r\n }\r\n\r\n /**\r\n * Check if an internal execution variable is defined\r\n * @internal\r\n * @param block\r\n * @param name\r\n * @returns\r\n */\r\n public _hasExecutionVariable(block: FlowGraphBlock, name: string) {\r\n return this._getUniqueIdPrefixedName(block, name) in this._executionVariables;\r\n }\r\n\r\n /**\r\n * Check if a connection value is defined\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _hasConnectionValue(connectionPoint: FlowGraphDataConnection<any>) {\r\n return connectionPoint.uniqueId in this._connectionValues;\r\n }\r\n\r\n /**\r\n * Set a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @param value\r\n */\r\n public _setConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>, value: T) {\r\n this._connectionValues[connectionPoint.uniqueId] = value;\r\n }\r\n\r\n /**\r\n * Get a connection value\r\n * @internal\r\n * @param connectionPoint\r\n * @returns\r\n */\r\n public _getConnectionValue<T>(connectionPoint: FlowGraphDataConnection<T>): T {\r\n return this._connectionValues[connectionPoint.uniqueId];\r\n }\r\n\r\n /**\r\n * Get the configuration\r\n * @internal\r\n * @param name\r\n * @param value\r\n */\r\n public get configuration() {\r\n return this._configuration;\r\n }\r\n\r\n /**\r\n * Add a block to the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _addPendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n this._pendingBlocks.push(block);\r\n }\r\n\r\n /**\r\n * Remove a block from the list of blocks that have pending tasks.\r\n * @internal\r\n * @param block\r\n */\r\n public _removePendingBlock(block: FlowGraphAsyncExecutionBlock) {\r\n const index = this._pendingBlocks.indexOf(block);\r\n if (index !== -1) {\r\n this._pendingBlocks.splice(index, 1);\r\n }\r\n }\r\n\r\n /**\r\n * Clear all pending blocks.\r\n * @internal\r\n */\r\n public _clearPendingBlocks() {\r\n for (const block of this._pendingBlocks) {\r\n block._cancelPendingTasks(this);\r\n }\r\n this._pendingBlocks.length = 0;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Function that notifies the node executed observable\r\n * @param node\r\n */\r\n public _notifyExecuteNode(node: FlowGraphBlock) {\r\n this.onNodeExecutedObservable.notifyObservers(node);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _increaseExecutionId() {\r\n this._executionId++;\r\n }\r\n /**\r\n * A monotonically increasing ID for each execution.\r\n * Incremented for every block executed.\r\n */\r\n public get executionId() {\r\n return this._executionId;\r\n }\r\n\r\n /**\r\n * Serializes a context\r\n * @param serializationObject the object to write the values in\r\n * @param valueSerializationFunction a function to serialize complex values\r\n */\r\n public serialize(serializationObject: any = {}, valueSerializationFunction: (key: string, value: any, serializationObject: any) => void = defaultValueSerializationFunction) {\r\n serializationObject.uniqueId = this.uniqueId;\r\n serializationObject._userVariables = {};\r\n for (const key in this._userVariables) {\r\n valueSerializationFunction(key, this._userVariables[key], serializationObject._userVariables);\r\n }\r\n serializationObject._connectionValues = {};\r\n for (const key in this._connectionValues) {\r\n valueSerializationFunction(key, this._connectionValues[key], serializationObject._connectionValues);\r\n }\r\n }\r\n\r\n public getClassName() {\r\n return \"FGContext\";\r\n }\r\n\r\n /**\r\n * Parses a context\r\n * @param serializationObject the object containing the context serialization values\r\n * @param graph the graph to which the context should belong\r\n * @param valueParseFunction a function to parse complex values\r\n * @returns\r\n */\r\n public static Parse(\r\n serializationObject: any = {},\r\n graph: FlowGraph,\r\n valueParseFunction: (key: string, serializationObject: any, scene: Scene) => any = defaultValueParseFunction\r\n ): FlowGraphContext {\r\n const result = graph.createContext();\r\n result.uniqueId = serializationObject.uniqueId;\r\n for (const key in serializationObject._userVariables) {\r\n const value = valueParseFunction(key, serializationObject._userVariables, result._configuration.scene);\r\n result._userVariables[key] = value;\r\n }\r\n for (const key in serializationObject._connectionValues) {\r\n const value = valueParseFunction(key, serializationObject._connectionValues, result._configuration.scene);\r\n result._connectionValues[key] = value;\r\n }\r\n\r\n return result;\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FlowGraphContext } from "./flowGraphContext";
|
|
2
|
+
export declare class FlowGraphPath {
|
|
3
|
+
private _path;
|
|
4
|
+
private _templateSubstitutions;
|
|
5
|
+
private _pathParts;
|
|
6
|
+
private _templateStrings;
|
|
7
|
+
/**
|
|
8
|
+
* Whether this path has any template strings in it.
|
|
9
|
+
*/
|
|
10
|
+
hasTemplateStrings: boolean;
|
|
11
|
+
constructor(path: string);
|
|
12
|
+
private _getPathPartsAndTemplateStrings;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the template strings in this path.
|
|
15
|
+
* @returns an array containing the template strings in this path.
|
|
16
|
+
*/
|
|
17
|
+
getTemplateStrings(): string[];
|
|
18
|
+
setTemplateSubstitution(template: string, value: number): void;
|
|
19
|
+
private _evaluateTemplates;
|
|
20
|
+
private _getFinalPath;
|
|
21
|
+
private _evaluatePath;
|
|
22
|
+
getProperty(context: FlowGraphContext): any;
|
|
23
|
+
setProperty(context: FlowGraphContext, value: any): void;
|
|
24
|
+
getClassName(): string;
|
|
25
|
+
serialize(serializationObject?: any): any;
|
|
26
|
+
Parse(serializationObject: any): FlowGraphPath;
|
|
27
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { RegisterClass } from "../Misc/typeStore.js";
|
|
2
|
+
// Path: /x/{y}/z/.../w
|
|
3
|
+
const PATH_REGEX = /([./])({?\w+}?)/g;
|
|
4
|
+
/*
|
|
5
|
+
* @experimental
|
|
6
|
+
* This class represents a path of type /x/{y}/z/.../w that is evaluated
|
|
7
|
+
* on a target object. The string between curly braces ({y} in the example)
|
|
8
|
+
* is a special template string that is replaced during runtime.
|
|
9
|
+
*/
|
|
10
|
+
export class FlowGraphPath {
|
|
11
|
+
constructor(path) {
|
|
12
|
+
this._templateSubstitutions = {}; // this is a map of template strings to values that are substituted during runtime
|
|
13
|
+
this._pathParts = []; // this is the path divided into parts, with each part being either a template string or a regular string
|
|
14
|
+
this._templateStrings = []; // this is the list of template strings in the path
|
|
15
|
+
/**
|
|
16
|
+
* Whether this path has any template strings in it.
|
|
17
|
+
*/
|
|
18
|
+
this.hasTemplateStrings = false;
|
|
19
|
+
this._path = path;
|
|
20
|
+
const { pathParts, templateStrings } = this._getPathPartsAndTemplateStrings(path);
|
|
21
|
+
this._pathParts = pathParts;
|
|
22
|
+
this._templateStrings = templateStrings;
|
|
23
|
+
this.hasTemplateStrings = templateStrings.length > 0;
|
|
24
|
+
}
|
|
25
|
+
_getPathPartsAndTemplateStrings(path) {
|
|
26
|
+
const allMatches = path.matchAll(PATH_REGEX);
|
|
27
|
+
const pathParts = [];
|
|
28
|
+
const templateStrings = [];
|
|
29
|
+
let nextMatch = allMatches.next();
|
|
30
|
+
while (!nextMatch.done) {
|
|
31
|
+
const singleMatch = nextMatch.value;
|
|
32
|
+
const [, separator, value] = singleMatch;
|
|
33
|
+
let valueWithoutBraces = value;
|
|
34
|
+
let isTemplate = false;
|
|
35
|
+
if (value.startsWith("{") && value.endsWith("}")) {
|
|
36
|
+
isTemplate = true;
|
|
37
|
+
valueWithoutBraces = value.slice(1, value.length - 1);
|
|
38
|
+
if (templateStrings.indexOf(valueWithoutBraces) === -1) {
|
|
39
|
+
templateStrings.push(valueWithoutBraces);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
pathParts.push({
|
|
43
|
+
value,
|
|
44
|
+
isTemplate,
|
|
45
|
+
valueWithoutBraces,
|
|
46
|
+
separator,
|
|
47
|
+
});
|
|
48
|
+
nextMatch = allMatches.next();
|
|
49
|
+
}
|
|
50
|
+
return { pathParts, templateStrings };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Gets the template strings in this path.
|
|
54
|
+
* @returns an array containing the template strings in this path.
|
|
55
|
+
*/
|
|
56
|
+
getTemplateStrings() {
|
|
57
|
+
return this._templateStrings;
|
|
58
|
+
}
|
|
59
|
+
setTemplateSubstitution(template, value) {
|
|
60
|
+
if (this._templateStrings.indexOf(template) === -1) {
|
|
61
|
+
throw new Error(`Template string ${template} does not exist in path ${this._path}`);
|
|
62
|
+
}
|
|
63
|
+
this._templateSubstitutions[template] = value;
|
|
64
|
+
}
|
|
65
|
+
_evaluateTemplates() {
|
|
66
|
+
for (const pathPart of this._pathParts) {
|
|
67
|
+
if (pathPart.isTemplate) {
|
|
68
|
+
const value = this._templateSubstitutions[pathPart.valueWithoutBraces];
|
|
69
|
+
if (value === undefined) {
|
|
70
|
+
throw new Error(`Template string ${pathPart.value} was not substituted`);
|
|
71
|
+
}
|
|
72
|
+
pathPart.replacedValue = value.toString();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
_getFinalPath() {
|
|
77
|
+
let finalPath = "";
|
|
78
|
+
for (const pathPart of this._pathParts) {
|
|
79
|
+
finalPath += pathPart.separator;
|
|
80
|
+
if (pathPart.isTemplate) {
|
|
81
|
+
finalPath += pathPart.replacedValue;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
finalPath += pathPart.value;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return finalPath;
|
|
88
|
+
}
|
|
89
|
+
/*
|
|
90
|
+
* Breaks the path into a chain of entities, for example,
|
|
91
|
+
* /x/y/z would be split into [context._userVariables.x, context._userVariables.x.y, context._userVariables.x.y.z],
|
|
92
|
+
* and the path that was split, i.e. /x/y/z, would be split into ["x", "y", "z"].
|
|
93
|
+
*/
|
|
94
|
+
_evaluatePath(context) {
|
|
95
|
+
this._evaluateTemplates();
|
|
96
|
+
const entityChain = [];
|
|
97
|
+
const splitPath = [];
|
|
98
|
+
let currentTarget = context._userVariables;
|
|
99
|
+
for (const pathPart of this._pathParts) {
|
|
100
|
+
if (currentTarget === undefined) {
|
|
101
|
+
throw new Error(`Could not find path ${this._getFinalPath()} in target context`);
|
|
102
|
+
}
|
|
103
|
+
const value = pathPart.isTemplate ? pathPart.replacedValue : pathPart.value;
|
|
104
|
+
if (!value) {
|
|
105
|
+
throw new Error(`Invalid path ${this._getFinalPath()}`);
|
|
106
|
+
}
|
|
107
|
+
currentTarget = currentTarget[value];
|
|
108
|
+
entityChain.push(currentTarget);
|
|
109
|
+
splitPath.push(value);
|
|
110
|
+
}
|
|
111
|
+
return { entityChain, splitPath };
|
|
112
|
+
}
|
|
113
|
+
getProperty(context) {
|
|
114
|
+
const { entityChain } = this._evaluatePath(context);
|
|
115
|
+
return entityChain[entityChain.length - 1];
|
|
116
|
+
}
|
|
117
|
+
setProperty(context, value) {
|
|
118
|
+
const { entityChain, splitPath } = this._evaluatePath(context);
|
|
119
|
+
const target = entityChain[entityChain.length - 2];
|
|
120
|
+
const property = splitPath[splitPath.length - 1];
|
|
121
|
+
target[property] = value;
|
|
122
|
+
}
|
|
123
|
+
getClassName() {
|
|
124
|
+
return "FGPath";
|
|
125
|
+
}
|
|
126
|
+
serialize(serializationObject = {}) {
|
|
127
|
+
serializationObject.path = this._path;
|
|
128
|
+
serializationObject.className = this.getClassName();
|
|
129
|
+
return serializationObject;
|
|
130
|
+
}
|
|
131
|
+
Parse(serializationObject) {
|
|
132
|
+
return new FlowGraphPath(serializationObject.path);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
RegisterClass("FGPath", FlowGraphPath);
|
|
136
|
+
//# sourceMappingURL=flowGraphPath.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowGraphPath.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphPath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAGlD,uBAAuB;AACvB,MAAM,UAAU,GAAG,kBAAkB,CAAC;AAStC;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAYtB,YAAY,IAAY;QAVhB,2BAAsB,GAE1B,EAAE,CAAC,CAAC,kFAAkF;QAClF,eAAU,GAAgB,EAAE,CAAC,CAAC,yGAAyG;QACvI,qBAAgB,GAAa,EAAE,CAAC,CAAC,mDAAmD;QAC5F;;WAEG;QACI,uBAAkB,GAAY,KAAK,CAAC;QAGvC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,+BAA+B,CAAC,IAAI,CAA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AAY;QACR,OAAO,QAAQ,CAAC;IACpB,CAAC;IAED,SAAS,CAAC,sBAA2B,EAAE;QACnC,mBAAmB,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC;QACtC,mBAAmB,CAAC,SAAS,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACpD,OAAO,mBAAmB,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,mBAAwB;QAC1B,OAAO,IAAI,aAAa,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACvD,CAAC;CACJ;AACD,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC","sourcesContent":["import { RegisterClass } from \"../Misc/typeStore\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\n\r\n// Path: /x/{y}/z/.../w\r\nconst PATH_REGEX = /([./])({?\\w+}?)/g;\r\n\r\ninterface IPathPart {\r\n value: string;\r\n isTemplate: boolean;\r\n valueWithoutBraces: string;\r\n replacedValue?: string;\r\n separator: string;\r\n}\r\n/*\r\n * @experimental\r\n * This class represents a path of type /x/{y}/z/.../w that is evaluated\r\n * on a target object. The string between curly braces ({y} in the example)\r\n * is a special template string that is replaced during runtime.\r\n */\r\nexport class FlowGraphPath {\r\n private _path: string;\r\n private _templateSubstitutions: {\r\n [key: string]: number;\r\n } = {}; // this is a map of template strings to values that are substituted during runtime\r\n private _pathParts: IPathPart[] = []; // this is the path divided into parts, with each part being either a template string or a regular string\r\n private _templateStrings: string[] = []; // this is the list of template strings in the path\r\n /**\r\n * Whether this path has any template strings in it.\r\n */\r\n public hasTemplateStrings: boolean = false;\r\n\r\n constructor(path: string) {\r\n this._path = path;\r\n const { pathParts, templateStrings } = this._getPathPartsAndTemplateStrings(path);\r\n this._pathParts = pathParts;\r\n this._templateStrings = templateStrings;\r\n this.hasTemplateStrings = templateStrings.length > 0;\r\n }\r\n\r\n private _getPathPartsAndTemplateStrings(path: string) {\r\n const allMatches = path.matchAll(PATH_REGEX);\r\n\r\n const pathParts = [];\r\n const templateStrings = [];\r\n let nextMatch = allMatches.next();\r\n while (!nextMatch.done) {\r\n const singleMatch = nextMatch.value;\r\n const [, separator, value] = singleMatch;\r\n let valueWithoutBraces = value;\r\n let isTemplate = false;\r\n if (value.startsWith(\"{\") && value.endsWith(\"}\")) {\r\n isTemplate = true;\r\n valueWithoutBraces = value.slice(1, value.length - 1);\r\n if (templateStrings.indexOf(valueWithoutBraces) === -1) {\r\n templateStrings.push(valueWithoutBraces);\r\n }\r\n }\r\n pathParts.push({\r\n value,\r\n isTemplate,\r\n valueWithoutBraces,\r\n separator,\r\n });\r\n nextMatch = allMatches.next();\r\n }\r\n return { pathParts, templateStrings };\r\n }\r\n\r\n /**\r\n * Gets the template strings in this path.\r\n * @returns an array containing the template strings in this path.\r\n */\r\n getTemplateStrings(): string[] {\r\n return this._templateStrings;\r\n }\r\n\r\n setTemplateSubstitution(template: string, value: number) {\r\n if (this._templateStrings.indexOf(template) === -1) {\r\n throw new Error(`Template string ${template} does not exist in path ${this._path}`);\r\n }\r\n this._templateSubstitutions[template] = value;\r\n }\r\n\r\n private _evaluateTemplates() {\r\n for (const pathPart of this._pathParts) {\r\n if (pathPart.isTemplate) {\r\n const value = this._templateSubstitutions[pathPart.valueWithoutBraces];\r\n if (value === undefined) {\r\n throw new Error(`Template string ${pathPart.value} was not substituted`);\r\n }\r\n pathPart.replacedValue = value.toString();\r\n }\r\n }\r\n }\r\n\r\n private _getFinalPath() {\r\n let finalPath = \"\";\r\n for (const pathPart of this._pathParts) {\r\n finalPath += pathPart.separator;\r\n if (pathPart.isTemplate) {\r\n finalPath += pathPart.replacedValue;\r\n } else {\r\n finalPath += pathPart.value;\r\n }\r\n }\r\n return finalPath;\r\n }\r\n\r\n /*\r\n * Breaks the path into a chain of entities, for example,\r\n * /x/y/z would be split into [context._userVariables.x, context._userVariables.x.y, context._userVariables.x.y.z],\r\n * and the path that was split, i.e. /x/y/z, would be split into [\"x\", \"y\", \"z\"].\r\n */\r\n private _evaluatePath(context: FlowGraphContext): { entityChain: any[]; splitPath: string[] } {\r\n this._evaluateTemplates();\r\n\r\n const entityChain = [];\r\n const splitPath = [];\r\n let currentTarget = context._userVariables;\r\n for (const pathPart of this._pathParts) {\r\n if (currentTarget === undefined) {\r\n throw new Error(`Could not find path ${this._getFinalPath()} in target context`);\r\n }\r\n const value = pathPart.isTemplate ? pathPart.replacedValue : pathPart.value;\r\n if (!value) {\r\n throw new Error(`Invalid path ${this._getFinalPath()}`);\r\n }\r\n currentTarget = currentTarget[value];\r\n entityChain.push(currentTarget);\r\n splitPath.push(value);\r\n }\r\n\r\n return { entityChain, splitPath };\r\n }\r\n\r\n getProperty(context: FlowGraphContext): any {\r\n const { entityChain } = this._evaluatePath(context);\r\n return entityChain[entityChain.length - 1];\r\n }\r\n\r\n setProperty(context: FlowGraphContext, value: any) {\r\n const { entityChain, splitPath } = this._evaluatePath(context);\r\n const target = entityChain[entityChain.length - 2];\r\n const property = splitPath[splitPath.length - 1];\r\n target[property] = value;\r\n }\r\n\r\n getClassName() {\r\n return \"FGPath\";\r\n }\r\n\r\n serialize(serializationObject: any = {}) {\r\n serializationObject.path = this._path;\r\n serializationObject.className = this.getClassName();\r\n return serializationObject;\r\n }\r\n\r\n Parse(serializationObject: any) {\r\n return new FlowGraphPath(serializationObject.path);\r\n }\r\n}\r\nRegisterClass(\"FGPath\", FlowGraphPath);\r\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { FlowGraphBlock } from "./flowGraphBlock";
|
|
2
|
+
import type { FlowGraphContext } from "./flowGraphContext";
|
|
3
|
+
import type { FlowGraphDataConnection } from "./flowGraphDataConnection";
|
|
4
|
+
import type { FlowGraphPath } from "./flowGraphPath";
|
|
5
|
+
/**
|
|
6
|
+
* This class represents a component that has a path and a series of numeric
|
|
7
|
+
* data inputs which fill in the template strings in the path.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FlowGraphPathComponent {
|
|
10
|
+
/**
|
|
11
|
+
* The path that this component is associated with.
|
|
12
|
+
*/
|
|
13
|
+
path: FlowGraphPath;
|
|
14
|
+
/**
|
|
15
|
+
* The list of numeric data inputs that fill in the template strings in the path.
|
|
16
|
+
*/
|
|
17
|
+
templateStringInputs: FlowGraphDataConnection<number>[];
|
|
18
|
+
/**
|
|
19
|
+
* The block that owns this component.
|
|
20
|
+
*/
|
|
21
|
+
ownerBlock: FlowGraphBlock;
|
|
22
|
+
constructor(path: FlowGraphPath, ownerBlock: FlowGraphBlock);
|
|
23
|
+
/**
|
|
24
|
+
* Get the inputs of all of the numeric data inputs and use them to fill in the
|
|
25
|
+
* template strings in the path.
|
|
26
|
+
* @param context the context to use to get the values of the numeric data inputs
|
|
27
|
+
* @returns the path with the template strings filled in
|
|
28
|
+
*/
|
|
29
|
+
substitutePath(context: FlowGraphContext): FlowGraphPath;
|
|
30
|
+
/**
|
|
31
|
+
* Substitutes the template strings in the path and gets the property on the target object.
|
|
32
|
+
* @param context
|
|
33
|
+
* @returns
|
|
34
|
+
*/
|
|
35
|
+
getProperty(context: FlowGraphContext): any;
|
|
36
|
+
/**
|
|
37
|
+
* Substitutes the template strings in the path and sets the property on the target object.
|
|
38
|
+
* @param context
|
|
39
|
+
* @param value
|
|
40
|
+
*/
|
|
41
|
+
setProperty(context: FlowGraphContext, value: any): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { RichTypeNumber } from "./flowGraphRichTypes.js";
|
|
2
|
+
/**
|
|
3
|
+
* This class represents a component that has a path and a series of numeric
|
|
4
|
+
* data inputs which fill in the template strings in the path.
|
|
5
|
+
*/
|
|
6
|
+
export class FlowGraphPathComponent {
|
|
7
|
+
constructor(path, ownerBlock) {
|
|
8
|
+
/**
|
|
9
|
+
* The list of numeric data inputs that fill in the template strings in the path.
|
|
10
|
+
*/
|
|
11
|
+
this.templateStringInputs = [];
|
|
12
|
+
this.path = path;
|
|
13
|
+
this.ownerBlock = ownerBlock;
|
|
14
|
+
for (const templateString of path.getTemplateStrings()) {
|
|
15
|
+
this.templateStringInputs.push(this.ownerBlock.registerDataInput(templateString, RichTypeNumber));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Get the inputs of all of the numeric data inputs and use them to fill in the
|
|
20
|
+
* template strings in the path.
|
|
21
|
+
* @param context the context to use to get the values of the numeric data inputs
|
|
22
|
+
* @returns the path with the template strings filled in
|
|
23
|
+
*/
|
|
24
|
+
substitutePath(context) {
|
|
25
|
+
for (const templateStringInput of this.templateStringInputs) {
|
|
26
|
+
const templateStringValue = templateStringInput.getValue(context);
|
|
27
|
+
const templateString = templateStringInput.name;
|
|
28
|
+
this.path.setTemplateSubstitution(templateString, templateStringValue);
|
|
29
|
+
}
|
|
30
|
+
return this.path;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Substitutes the template strings in the path and gets the property on the target object.
|
|
34
|
+
* @param context
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
getProperty(context) {
|
|
38
|
+
this.substitutePath(context);
|
|
39
|
+
return this.path.getProperty(context);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Substitutes the template strings in the path and sets the property on the target object.
|
|
43
|
+
* @param context
|
|
44
|
+
* @param value
|
|
45
|
+
*/
|
|
46
|
+
setProperty(context, value) {
|
|
47
|
+
this.substitutePath(context);
|
|
48
|
+
this.path.setProperty(context, value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=flowGraphPathComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowGraphPathComponent.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/flowGraphPathComponent.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAc/B,YAAY,IAAmB,EAAE,UAA0B;QAT3D;;WAEG;QACH,yBAAoB,GAAsC,EAAE,CAAC;QAOzD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,kBAAkB,EAAE,EAAE;YACpD,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC,CAAC;SACrG;IACL,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,OAAyB;QACpC,KAAK,MAAM,mBAAmB,IAAI,IAAI,CAAC,oBAAoB,EAAE;YACzD,MAAM,mBAAmB,GAAG,mBAAmB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;YAClE,MAAM,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC;YAChD,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,cAAc,EAAE,mBAAmB,CAAC,CAAC;SAC1E;QACD,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,OAAyB;QACjC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACH,WAAW,CAAC,OAAyB,EAAE,KAAU;QAC7C,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAC7B,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC1C,CAAC;CACJ","sourcesContent":["import type { FlowGraphBlock } from \"./flowGraphBlock\";\r\nimport type { FlowGraphContext } from \"./flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"./flowGraphDataConnection\";\r\nimport type { FlowGraphPath } from \"./flowGraphPath\";\r\nimport { RichTypeNumber } from \"./flowGraphRichTypes\";\r\n\r\n/**\r\n * This class represents a component that has a path and a series of numeric\r\n * data inputs which fill in the template strings in the path.\r\n */\r\nexport class FlowGraphPathComponent {\r\n /**\r\n * The path that this component is associated with.\r\n */\r\n path: FlowGraphPath;\r\n /**\r\n * The list of numeric data inputs that fill in the template strings in the path.\r\n */\r\n templateStringInputs: FlowGraphDataConnection<number>[] = [];\r\n /**\r\n * The block that owns this component.\r\n */\r\n ownerBlock: FlowGraphBlock;\r\n\r\n constructor(path: FlowGraphPath, ownerBlock: FlowGraphBlock) {\r\n this.path = path;\r\n this.ownerBlock = ownerBlock;\r\n for (const templateString of path.getTemplateStrings()) {\r\n this.templateStringInputs.push(this.ownerBlock.registerDataInput(templateString, RichTypeNumber));\r\n }\r\n }\r\n\r\n /**\r\n * Get the inputs of all of the numeric data inputs and use them to fill in the\r\n * template strings in the path.\r\n * @param context the context to use to get the values of the numeric data inputs\r\n * @returns the path with the template strings filled in\r\n */\r\n substitutePath(context: FlowGraphContext): FlowGraphPath {\r\n for (const templateStringInput of this.templateStringInputs) {\r\n const templateStringValue = templateStringInput.getValue(context);\r\n const templateString = templateStringInput.name;\r\n this.path.setTemplateSubstitution(templateString, templateStringValue);\r\n }\r\n return this.path;\r\n }\r\n\r\n /**\r\n * Substitutes the template strings in the path and gets the property on the target object.\r\n * @param context\r\n * @returns\r\n */\r\n getProperty(context: FlowGraphContext): any {\r\n this.substitutePath(context);\r\n return this.path.getProperty(context);\r\n }\r\n\r\n /**\r\n * Substitutes the template strings in the path and sets the property on the target object.\r\n * @param context\r\n * @param value\r\n */\r\n setProperty(context: FlowGraphContext, value: any) {\r\n this.substitutePath(context);\r\n this.path.setProperty(context, value);\r\n }\r\n}\r\n"]}
|
package/FlowGraph/index.d.ts
CHANGED
package/FlowGraph/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./flowGraphRichTypes.js";
|
|
|
7
7
|
export * from "./flowGraphContext.js";
|
|
8
8
|
export * from "./flowGraphCoordinator.js";
|
|
9
9
|
export * from "./flowGraphContextLogger.js";
|
|
10
|
+
export * from "./flowGraphPath.js";
|
|
10
11
|
// eslint-disable-next-line import/no-internal-modules
|
|
11
12
|
export * from "./Blocks/index.js";
|
|
12
13
|
//# sourceMappingURL=index.js.map
|
package/FlowGraph/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,sDAAsD;AACtD,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./flowGraph\";\r\nexport * from \"./flowGraphBlock\";\r\nexport * from \"./flowGraphSignalConnection\";\r\nexport * from \"./flowGraphExecutionBlock\";\r\nexport * from \"./flowGraphEventBlock\";\r\nexport * from \"./flowGraphRichTypes\";\r\nexport * from \"./flowGraphContext\";\r\nexport * from \"./flowGraphCoordinator\";\r\nexport * from \"./flowGraphContextLogger\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Blocks/index\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../dev/core/src/FlowGraph/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,sDAAsD;AACtD,cAAc,gBAAgB,CAAC","sourcesContent":["export * from \"./flowGraph\";\r\nexport * from \"./flowGraphBlock\";\r\nexport * from \"./flowGraphSignalConnection\";\r\nexport * from \"./flowGraphExecutionBlock\";\r\nexport * from \"./flowGraphEventBlock\";\r\nexport * from \"./flowGraphRichTypes\";\r\nexport * from \"./flowGraphContext\";\r\nexport * from \"./flowGraphCoordinator\";\r\nexport * from \"./flowGraphContextLogger\";\r\nexport * from \"./flowGraphPath\";\r\n// eslint-disable-next-line import/no-internal-modules\r\nexport * from \"./Blocks/index\";\r\n"]}
|
|
@@ -53,7 +53,7 @@ export declare class AxisDragGizmo extends Gizmo implements IAxisDragGizmo {
|
|
|
53
53
|
snapDistance: number;
|
|
54
54
|
/**
|
|
55
55
|
* Event that fires each time the gizmo snaps to a new location.
|
|
56
|
-
* * snapDistance is the
|
|
56
|
+
* * snapDistance is the change in distance
|
|
57
57
|
*/
|
|
58
58
|
onSnapObservable: Observable<{
|
|
59
59
|
snapDistance: number;
|
|
@@ -86,8 +86,10 @@ export declare class AxisDragGizmo extends Gizmo implements IAxisDragGizmo {
|
|
|
86
86
|
* @param gizmoLayer The utility layer the gizmo will be added to
|
|
87
87
|
* @param parent
|
|
88
88
|
* @param thickness display gizmo axis thickness
|
|
89
|
+
* @param hoverColor The color of the gizmo when hovering over and dragging
|
|
90
|
+
* @param disableColor The Color of the gizmo when its disabled
|
|
89
91
|
*/
|
|
90
|
-
constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
|
|
92
|
+
constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number, hoverColor?: Color3, disableColor?: Color3);
|
|
91
93
|
protected _attachedNodeChanged(value: Nullable<Node>): void;
|
|
92
94
|
/**
|
|
93
95
|
* If the gizmo is enabled
|
package/Gizmos/axisDragGizmo.js
CHANGED
|
@@ -29,8 +29,18 @@ export class AxisDragGizmo extends Gizmo {
|
|
|
29
29
|
*/
|
|
30
30
|
static _CreateArrow(scene, material, thickness = 1, isCollider = false) {
|
|
31
31
|
const arrow = new TransformNode("arrow", scene);
|
|
32
|
-
const cylinder = CreateCylinder("cylinder", {
|
|
33
|
-
|
|
32
|
+
const cylinder = CreateCylinder("cylinder", {
|
|
33
|
+
diameterTop: 0,
|
|
34
|
+
height: 0.075,
|
|
35
|
+
diameterBottom: 0.0375 * (1 + (thickness - 1) / 4),
|
|
36
|
+
tessellation: 96,
|
|
37
|
+
}, scene);
|
|
38
|
+
const line = CreateCylinder("cylinder", {
|
|
39
|
+
diameterTop: 0.005 * thickness,
|
|
40
|
+
height: 0.275,
|
|
41
|
+
diameterBottom: 0.005 * thickness,
|
|
42
|
+
tessellation: 96,
|
|
43
|
+
}, scene);
|
|
34
44
|
// Position arrow pointing in its drag axis
|
|
35
45
|
cylinder.parent = arrow;
|
|
36
46
|
cylinder.material = material;
|
|
@@ -64,8 +74,10 @@ export class AxisDragGizmo extends Gizmo {
|
|
|
64
74
|
* @param gizmoLayer The utility layer the gizmo will be added to
|
|
65
75
|
* @param parent
|
|
66
76
|
* @param thickness display gizmo axis thickness
|
|
77
|
+
* @param hoverColor The color of the gizmo when hovering over and dragging
|
|
78
|
+
* @param disableColor The Color of the gizmo when its disabled
|
|
67
79
|
*/
|
|
68
|
-
constructor(dragAxis, color = Color3.Gray(), gizmoLayer = UtilityLayerRenderer.DefaultUtilityLayer, parent = null, thickness = 1) {
|
|
80
|
+
constructor(dragAxis, color = Color3.Gray(), gizmoLayer = UtilityLayerRenderer.DefaultUtilityLayer, parent = null, thickness = 1, hoverColor = Color3.Yellow(), disableColor = Color3.Gray()) {
|
|
69
81
|
var _a;
|
|
70
82
|
super(gizmoLayer);
|
|
71
83
|
this._pointerObserver = null;
|
|
@@ -75,7 +87,7 @@ export class AxisDragGizmo extends Gizmo {
|
|
|
75
87
|
this.snapDistance = 0;
|
|
76
88
|
/**
|
|
77
89
|
* Event that fires each time the gizmo snaps to a new location.
|
|
78
|
-
* * snapDistance is the
|
|
90
|
+
* * snapDistance is the change in distance
|
|
79
91
|
*/
|
|
80
92
|
this.onSnapObservable = new Observable();
|
|
81
93
|
this._isEnabled = true;
|
|
@@ -87,9 +99,9 @@ export class AxisDragGizmo extends Gizmo {
|
|
|
87
99
|
this._coloredMaterial.diffuseColor = color;
|
|
88
100
|
this._coloredMaterial.specularColor = color.subtract(new Color3(0.1, 0.1, 0.1));
|
|
89
101
|
this._hoverMaterial = new StandardMaterial("", gizmoLayer.utilityLayerScene);
|
|
90
|
-
this._hoverMaterial.diffuseColor =
|
|
102
|
+
this._hoverMaterial.diffuseColor = hoverColor;
|
|
91
103
|
this._disableMaterial = new StandardMaterial("", gizmoLayer.utilityLayerScene);
|
|
92
|
-
this._disableMaterial.diffuseColor =
|
|
104
|
+
this._disableMaterial.diffuseColor = disableColor;
|
|
93
105
|
this._disableMaterial.alpha = 0.4;
|
|
94
106
|
// Build Mesh + Collider
|
|
95
107
|
const arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, this._coloredMaterial, thickness);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"axisDragGizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/axisDragGizmo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;A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,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;QACL,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport type { Node } from \"../node\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { GizmoAxisCache, IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { PositionGizmo } from \"./positionGizmo\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport { TmpVectors } from \"../Maths/math.vector\";\r\n/**\r\n * Interface for axis drag gizmo\r\n */\r\nexport interface IAxisDragGizmo extends IGizmo {\r\n /** Drag behavior responsible for the gizmos dragging interactions */\r\n dragBehavior: PointerDragBehavior;\r\n /** Drag distance in babylon units that the gizmo will snap to when dragged */\r\n snapDistance: number;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the change in distance\r\n */\r\n onSnapObservable: Observable<{ snapDistance: number }>;\r\n /** If the gizmo is enabled */\r\n isEnabled: boolean;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n coloredMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n hoverMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is disabled. typically grey.*/\r\n disableMaterial: StandardMaterial;\r\n}\r\n\r\n/**\r\n * Single axis drag gizmo\r\n */\r\nexport class AxisDragGizmo extends Gizmo implements IAxisDragGizmo {\r\n /**\r\n * Drag behavior responsible for the gizmos dragging interactions\r\n */\r\n public dragBehavior: PointerDragBehavior;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n /**\r\n * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)\r\n */\r\n public snapDistance = 0;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the the change in distance\r\n */\r\n public onSnapObservable = new Observable<{ snapDistance: number }>();\r\n\r\n protected _isEnabled: boolean = true;\r\n protected _parent: Nullable<PositionGizmo> = null;\r\n\r\n protected _gizmoMesh: Mesh;\r\n protected _coloredMaterial: StandardMaterial;\r\n protected _hoverMaterial: StandardMaterial;\r\n protected _disableMaterial: StandardMaterial;\r\n protected _dragging: boolean = false;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n public get coloredMaterial() {\r\n return this._coloredMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n public get hoverMaterial() {\r\n return this._hoverMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is disabled. typically grey.*/\r\n public get disableMaterial() {\r\n return this._disableMaterial;\r\n }\r\n /**\r\n * @internal\r\n */\r\n public static _CreateArrow(scene: Scene, material: StandardMaterial, thickness: number = 1, isCollider = false): TransformNode {\r\n const arrow = new TransformNode(\"arrow\", scene);\r\n const cylinder = CreateCylinder(\"cylinder\", { diameterTop: 0, height: 0.075, diameterBottom: 0.0375 * (1 + (thickness - 1) / 4), tessellation: 96 }, scene);\r\n const line = CreateCylinder(\"cylinder\", { diameterTop: 0.005 * thickness, height: 0.275, diameterBottom: 0.005 * thickness, tessellation: 96 }, scene);\r\n\r\n // Position arrow pointing in its drag axis\r\n cylinder.parent = arrow;\r\n cylinder.material = material;\r\n cylinder.rotation.x = Math.PI / 2;\r\n cylinder.position.z += 0.3;\r\n\r\n line.parent = arrow;\r\n line.material = material;\r\n line.position.z += 0.275 / 2;\r\n line.rotation.x = Math.PI / 2;\r\n\r\n if (isCollider) {\r\n line.visibility = 0;\r\n cylinder.visibility = 0;\r\n }\r\n return arrow;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode {\r\n const instance = new TransformNode(\"arrow\", scene);\r\n for (const mesh of arrow.getChildMeshes()) {\r\n const childInstance = (mesh as Mesh).createInstance(mesh.name);\r\n childInstance.parent = instance;\r\n }\r\n return instance;\r\n }\r\n\r\n /**\r\n * Creates an AxisDragGizmo\r\n * @param dragAxis The axis which the gizmo will be able to drag on\r\n * @param color The color of the gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n * @param parent\r\n * @param thickness display gizmo axis thickness\r\n */\r\n constructor(\r\n dragAxis: Vector3,\r\n color: Color3 = Color3.Gray(),\r\n gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer,\r\n parent: Nullable<PositionGizmo> = null,\r\n thickness: number = 1\r\n ) {\r\n super(gizmoLayer);\r\n this._parent = parent;\r\n\r\n // Create Material\r\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._coloredMaterial.diffuseColor = color;\r\n this._coloredMaterial.specularColor = color.subtract(new Color3(0.1, 0.1, 0.1));\r\n\r\n this._hoverMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._hoverMaterial.diffuseColor = Color3.Yellow();\r\n\r\n this._disableMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._disableMaterial.diffuseColor = Color3.Gray();\r\n this._disableMaterial.alpha = 0.4;\r\n\r\n // Build Mesh + Collider\r\n const arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, this._coloredMaterial, thickness);\r\n const collider = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, this._coloredMaterial, thickness + 4, true);\r\n\r\n // Add to Root Node\r\n this._gizmoMesh = new Mesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._gizmoMesh.addChild(arrow as Mesh);\r\n this._gizmoMesh.addChild(collider as Mesh);\r\n\r\n this._gizmoMesh.lookAt(this._rootMesh.position.add(dragAxis));\r\n this._gizmoMesh.scaling.scaleInPlace(1 / 3);\r\n this._gizmoMesh.parent = this._rootMesh;\r\n\r\n let currentSnapDragDistance = 0;\r\n const tmpSnapEvent = { snapDistance: 0 };\r\n // Add drag behavior to handle events when the gizmo is dragged\r\n this.dragBehavior = new PointerDragBehavior({ dragAxis: dragAxis });\r\n this.dragBehavior.moveAttached = false;\r\n this.dragBehavior.updateDragPlane = false;\r\n this._rootMesh.addBehavior(this.dragBehavior);\r\n\r\n this.dragBehavior.onDragObservable.add((event) => {\r\n if (this.attachedNode) {\r\n // Keep world translation and use it to update world transform\r\n // if the node has parent, the local transform properties (position, rotation, scale)\r\n // will be recomputed in _matrixChanged function\r\n\r\n let matrixChanged: boolean = false;\r\n // Snapping logic\r\n if (this.snapDistance == 0) {\r\n this.attachedNode.getWorldMatrix().getTranslationToRef(TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[2].addInPlace(event.delta);\r\n if (this.dragBehavior.validateDrag(TmpVectors.Vector3[2])) {\r\n if ((this.attachedNode as any).position) {\r\n // Required for nodes like lights\r\n (this.attachedNode as any).position.addInPlaceFromFloats(event.delta.x, event.delta.y, event.delta.z);\r\n }\r\n\r\n // use _worldMatrix to not force a matrix update when calling GetWorldMatrix especially with Cameras\r\n this.attachedNode.getWorldMatrix().addTranslationFromFloats(event.delta.x, event.delta.y, event.delta.z);\r\n this.attachedNode.updateCache();\r\n matrixChanged = true;\r\n }\r\n } else {\r\n currentSnapDragDistance += event.dragDistance;\r\n if (Math.abs(currentSnapDragDistance) > this.snapDistance) {\r\n const dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / this.snapDistance);\r\n currentSnapDragDistance = currentSnapDragDistance % this.snapDistance;\r\n event.delta.normalizeToRef(TmpVectors.Vector3[1]);\r\n TmpVectors.Vector3[1].scaleInPlace(this.snapDistance * dragSteps);\r\n\r\n this.attachedNode.getWorldMatrix().getTranslationToRef(TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[2].addInPlace(TmpVectors.Vector3[1]);\r\n if (this.dragBehavior.validateDrag(TmpVectors.Vector3[2])) {\r\n this.attachedNode.getWorldMatrix().addTranslationFromFloats(TmpVectors.Vector3[1].x, TmpVectors.Vector3[1].y, TmpVectors.Vector3[1].z);\r\n this.attachedNode.updateCache();\r\n tmpSnapEvent.snapDistance = this.snapDistance * dragSteps;\r\n this.onSnapObservable.notifyObservers(tmpSnapEvent);\r\n matrixChanged = true;\r\n }\r\n }\r\n }\r\n if (matrixChanged) {\r\n this._matrixChanged();\r\n }\r\n }\r\n });\r\n this.dragBehavior.onDragStartObservable.add(() => {\r\n this._dragging = true;\r\n });\r\n this.dragBehavior.onDragEndObservable.add(() => {\r\n this._dragging = false;\r\n });\r\n\r\n const light = gizmoLayer._getSharedGizmoLight();\r\n light.includedOnlyMeshes = light.includedOnlyMeshes.concat(this._rootMesh.getChildMeshes(false));\r\n\r\n const cache: GizmoAxisCache = {\r\n gizmoMeshes: arrow.getChildMeshes() as Mesh[],\r\n colliderMeshes: collider.getChildMeshes() as Mesh[],\r\n material: this._coloredMaterial,\r\n hoverMaterial: this._hoverMaterial,\r\n disableMaterial: this._disableMaterial,\r\n active: false,\r\n dragBehavior: this.dragBehavior,\r\n };\r\n this._parent?.addToAxisCache(collider as Mesh, cache);\r\n\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (this._customMeshSet) {\r\n return;\r\n }\r\n this._isHovered = !!(cache.colliderMeshes.indexOf(<Mesh>pointerInfo?.pickInfo?.pickedMesh) != -1);\r\n if (!this._parent) {\r\n const material = this.dragBehavior.enabled ? (this._isHovered || this._dragging ? this._hoverMaterial : this._coloredMaterial) : this._disableMaterial;\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, material);\r\n }\r\n });\r\n\r\n this.dragBehavior.onEnabledObservable.add((newState) => {\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, newState ? cache.material : cache.disableMaterial);\r\n });\r\n }\r\n protected _attachedNodeChanged(value: Nullable<Node>) {\r\n if (this.dragBehavior) {\r\n this.dragBehavior.enabled = value ? true : false;\r\n }\r\n }\r\n\r\n /**\r\n * If the gizmo is enabled\r\n */\r\n public set isEnabled(value: boolean) {\r\n this._isEnabled = value;\r\n if (!value) {\r\n this.attachedMesh = null;\r\n this.attachedNode = null;\r\n } else {\r\n if (this._parent) {\r\n this.attachedMesh = this._parent.attachedMesh;\r\n this.attachedNode = this._parent.attachedNode;\r\n }\r\n }\r\n }\r\n public get isEnabled(): boolean {\r\n return this._isEnabled;\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public dispose() {\r\n this.onSnapObservable.clear();\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n this.dragBehavior.detach();\r\n if (this._gizmoMesh) {\r\n this._gizmoMesh.dispose();\r\n }\r\n [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((matl) => {\r\n if (matl) {\r\n matl.dispose();\r\n }\r\n });\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"axisDragGizmo.js","sourceRoot":"","sources":["../../../../dev/core/src/Gizmos/axisDragGizmo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAE9E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACh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,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;YACjF,IAAI,IAAI,EAAE;gBACN,IAAI,CAAC,OAAO,EAAE,CAAC;aAClB;QACL,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,OAAO,EAAE,CAAC;IACpB,CAAC;CACJ","sourcesContent":["import type { Observer } from \"../Misc/observable\";\r\nimport { Observable } from \"../Misc/observable\";\r\nimport type { Nullable } from \"../types\";\r\nimport type { PointerInfo } from \"../Events/pointerEvents\";\r\nimport type { Vector3 } from \"../Maths/math.vector\";\r\nimport { TransformNode } from \"../Meshes/transformNode\";\r\nimport type { Node } from \"../node\";\r\nimport { Mesh } from \"../Meshes/mesh\";\r\nimport { CreateCylinder } from \"../Meshes/Builders/cylinderBuilder\";\r\nimport { PointerDragBehavior } from \"../Behaviors/Meshes/pointerDragBehavior\";\r\nimport type { GizmoAxisCache, IGizmo } from \"./gizmo\";\r\nimport { Gizmo } from \"./gizmo\";\r\nimport { UtilityLayerRenderer } from \"../Rendering/utilityLayerRenderer\";\r\nimport { StandardMaterial } from \"../Materials/standardMaterial\";\r\nimport type { Scene } from \"../scene\";\r\nimport type { PositionGizmo } from \"./positionGizmo\";\r\nimport { Color3 } from \"../Maths/math.color\";\r\nimport { TmpVectors } from \"../Maths/math.vector\";\r\n\r\n/**\r\n * Interface for axis drag gizmo\r\n */\r\nexport interface IAxisDragGizmo extends IGizmo {\r\n /** Drag behavior responsible for the gizmos dragging interactions */\r\n dragBehavior: PointerDragBehavior;\r\n /** Drag distance in babylon units that the gizmo will snap to when dragged */\r\n snapDistance: number;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the change in distance\r\n */\r\n onSnapObservable: Observable<{ snapDistance: number }>;\r\n /** If the gizmo is enabled */\r\n isEnabled: boolean;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n coloredMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n hoverMaterial: StandardMaterial;\r\n /** Material used to render when gizmo is disabled. typically grey.*/\r\n disableMaterial: StandardMaterial;\r\n}\r\n\r\n/**\r\n * Single axis drag gizmo\r\n */\r\nexport class AxisDragGizmo extends Gizmo implements IAxisDragGizmo {\r\n /**\r\n * Drag behavior responsible for the gizmos dragging interactions\r\n */\r\n public dragBehavior: PointerDragBehavior;\r\n protected _pointerObserver: Nullable<Observer<PointerInfo>> = null;\r\n /**\r\n * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)\r\n */\r\n public snapDistance = 0;\r\n /**\r\n * Event that fires each time the gizmo snaps to a new location.\r\n * * snapDistance is the change in distance\r\n */\r\n public onSnapObservable = new Observable<{ snapDistance: number }>();\r\n\r\n protected _isEnabled: boolean = true;\r\n protected _parent: Nullable<PositionGizmo> = null;\r\n\r\n protected _gizmoMesh: Mesh;\r\n protected _coloredMaterial: StandardMaterial;\r\n protected _hoverMaterial: StandardMaterial;\r\n protected _disableMaterial: StandardMaterial;\r\n protected _dragging: boolean = false;\r\n\r\n /** Default material used to render when gizmo is not disabled or hovered */\r\n public get coloredMaterial() {\r\n return this._coloredMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is hovered with mouse*/\r\n public get hoverMaterial() {\r\n return this._hoverMaterial;\r\n }\r\n\r\n /** Material used to render when gizmo is disabled. typically grey.*/\r\n public get disableMaterial() {\r\n return this._disableMaterial;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _CreateArrow(scene: Scene, material: StandardMaterial, thickness: number = 1, isCollider = false): TransformNode {\r\n const arrow = new TransformNode(\"arrow\", scene);\r\n const cylinder = CreateCylinder(\r\n \"cylinder\",\r\n {\r\n diameterTop: 0,\r\n height: 0.075,\r\n diameterBottom: 0.0375 * (1 + (thickness - 1) / 4),\r\n tessellation: 96,\r\n },\r\n scene\r\n );\r\n const line = CreateCylinder(\r\n \"cylinder\",\r\n {\r\n diameterTop: 0.005 * thickness,\r\n height: 0.275,\r\n diameterBottom: 0.005 * thickness,\r\n tessellation: 96,\r\n },\r\n scene\r\n );\r\n\r\n // Position arrow pointing in its drag axis\r\n cylinder.parent = arrow;\r\n cylinder.material = material;\r\n cylinder.rotation.x = Math.PI / 2;\r\n cylinder.position.z += 0.3;\r\n\r\n line.parent = arrow;\r\n line.material = material;\r\n line.position.z += 0.275 / 2;\r\n line.rotation.x = Math.PI / 2;\r\n\r\n if (isCollider) {\r\n line.visibility = 0;\r\n cylinder.visibility = 0;\r\n }\r\n return arrow;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode {\r\n const instance = new TransformNode(\"arrow\", scene);\r\n for (const mesh of arrow.getChildMeshes()) {\r\n const childInstance = (mesh as Mesh).createInstance(mesh.name);\r\n childInstance.parent = instance;\r\n }\r\n return instance;\r\n }\r\n\r\n /**\r\n * Creates an AxisDragGizmo\r\n * @param dragAxis The axis which the gizmo will be able to drag on\r\n * @param color The color of the gizmo\r\n * @param gizmoLayer The utility layer the gizmo will be added to\r\n * @param parent\r\n * @param thickness display gizmo axis thickness\r\n * @param hoverColor The color of the gizmo when hovering over and dragging\r\n * @param disableColor The Color of the gizmo when its disabled\r\n */\r\n constructor(\r\n dragAxis: Vector3,\r\n color: Color3 = Color3.Gray(),\r\n gizmoLayer: UtilityLayerRenderer = UtilityLayerRenderer.DefaultUtilityLayer,\r\n parent: Nullable<PositionGizmo> = null,\r\n thickness: number = 1,\r\n hoverColor: Color3 = Color3.Yellow(),\r\n disableColor: Color3 = Color3.Gray()\r\n ) {\r\n super(gizmoLayer);\r\n this._parent = parent;\r\n\r\n // Create Material\r\n this._coloredMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._coloredMaterial.diffuseColor = color;\r\n this._coloredMaterial.specularColor = color.subtract(new Color3(0.1, 0.1, 0.1));\r\n\r\n this._hoverMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._hoverMaterial.diffuseColor = hoverColor;\r\n\r\n this._disableMaterial = new StandardMaterial(\"\", gizmoLayer.utilityLayerScene);\r\n this._disableMaterial.diffuseColor = disableColor;\r\n this._disableMaterial.alpha = 0.4;\r\n\r\n // Build Mesh + Collider\r\n const arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, this._coloredMaterial, thickness);\r\n const collider = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, this._coloredMaterial, thickness + 4, true);\r\n\r\n // Add to Root Node\r\n this._gizmoMesh = new Mesh(\"\", gizmoLayer.utilityLayerScene);\r\n this._gizmoMesh.addChild(arrow as Mesh);\r\n this._gizmoMesh.addChild(collider as Mesh);\r\n\r\n this._gizmoMesh.lookAt(this._rootMesh.position.add(dragAxis));\r\n this._gizmoMesh.scaling.scaleInPlace(1 / 3);\r\n this._gizmoMesh.parent = this._rootMesh;\r\n\r\n let currentSnapDragDistance = 0;\r\n const tmpSnapEvent = { snapDistance: 0 };\r\n // Add drag behavior to handle events when the gizmo is dragged\r\n this.dragBehavior = new PointerDragBehavior({ dragAxis: dragAxis });\r\n this.dragBehavior.moveAttached = false;\r\n this.dragBehavior.updateDragPlane = false;\r\n this._rootMesh.addBehavior(this.dragBehavior);\r\n\r\n this.dragBehavior.onDragObservable.add((event) => {\r\n if (this.attachedNode) {\r\n // Keep world translation and use it to update world transform\r\n // if the node has parent, the local transform properties (position, rotation, scale)\r\n // will be recomputed in _matrixChanged function\r\n\r\n let matrixChanged: boolean = false;\r\n // Snapping logic\r\n if (this.snapDistance == 0) {\r\n this.attachedNode.getWorldMatrix().getTranslationToRef(TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[2].addInPlace(event.delta);\r\n if (this.dragBehavior.validateDrag(TmpVectors.Vector3[2])) {\r\n if ((this.attachedNode as any).position) {\r\n // Required for nodes like lights\r\n (this.attachedNode as any).position.addInPlaceFromFloats(event.delta.x, event.delta.y, event.delta.z);\r\n }\r\n\r\n // use _worldMatrix to not force a matrix update when calling GetWorldMatrix especially with Cameras\r\n this.attachedNode.getWorldMatrix().addTranslationFromFloats(event.delta.x, event.delta.y, event.delta.z);\r\n this.attachedNode.updateCache();\r\n matrixChanged = true;\r\n }\r\n } else {\r\n currentSnapDragDistance += event.dragDistance;\r\n if (Math.abs(currentSnapDragDistance) > this.snapDistance) {\r\n const dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / this.snapDistance);\r\n currentSnapDragDistance = currentSnapDragDistance % this.snapDistance;\r\n event.delta.normalizeToRef(TmpVectors.Vector3[1]);\r\n TmpVectors.Vector3[1].scaleInPlace(this.snapDistance * dragSteps);\r\n\r\n this.attachedNode.getWorldMatrix().getTranslationToRef(TmpVectors.Vector3[2]);\r\n TmpVectors.Vector3[2].addInPlace(TmpVectors.Vector3[1]);\r\n if (this.dragBehavior.validateDrag(TmpVectors.Vector3[2])) {\r\n this.attachedNode.getWorldMatrix().addTranslationFromFloats(TmpVectors.Vector3[1].x, TmpVectors.Vector3[1].y, TmpVectors.Vector3[1].z);\r\n this.attachedNode.updateCache();\r\n tmpSnapEvent.snapDistance = this.snapDistance * dragSteps;\r\n this.onSnapObservable.notifyObservers(tmpSnapEvent);\r\n matrixChanged = true;\r\n }\r\n }\r\n }\r\n if (matrixChanged) {\r\n this._matrixChanged();\r\n }\r\n }\r\n });\r\n this.dragBehavior.onDragStartObservable.add(() => {\r\n this._dragging = true;\r\n });\r\n this.dragBehavior.onDragEndObservable.add(() => {\r\n this._dragging = false;\r\n });\r\n\r\n const light = gizmoLayer._getSharedGizmoLight();\r\n light.includedOnlyMeshes = light.includedOnlyMeshes.concat(this._rootMesh.getChildMeshes(false));\r\n\r\n const cache: GizmoAxisCache = {\r\n gizmoMeshes: arrow.getChildMeshes() as Mesh[],\r\n colliderMeshes: collider.getChildMeshes() as Mesh[],\r\n material: this._coloredMaterial,\r\n hoverMaterial: this._hoverMaterial,\r\n disableMaterial: this._disableMaterial,\r\n active: false,\r\n dragBehavior: this.dragBehavior,\r\n };\r\n this._parent?.addToAxisCache(collider as Mesh, cache);\r\n\r\n this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add((pointerInfo) => {\r\n if (this._customMeshSet) {\r\n return;\r\n }\r\n this._isHovered = !!(cache.colliderMeshes.indexOf(<Mesh>pointerInfo?.pickInfo?.pickedMesh) != -1);\r\n if (!this._parent) {\r\n const material = this.dragBehavior.enabled ? (this._isHovered || this._dragging ? this._hoverMaterial : this._coloredMaterial) : this._disableMaterial;\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, material);\r\n }\r\n });\r\n\r\n this.dragBehavior.onEnabledObservable.add((newState) => {\r\n this._setGizmoMeshMaterial(cache.gizmoMeshes, newState ? cache.material : cache.disableMaterial);\r\n });\r\n }\r\n\r\n protected _attachedNodeChanged(value: Nullable<Node>) {\r\n if (this.dragBehavior) {\r\n this.dragBehavior.enabled = value ? true : false;\r\n }\r\n }\r\n\r\n /**\r\n * If the gizmo is enabled\r\n */\r\n public set isEnabled(value: boolean) {\r\n this._isEnabled = value;\r\n if (!value) {\r\n this.attachedMesh = null;\r\n this.attachedNode = null;\r\n } else {\r\n if (this._parent) {\r\n this.attachedMesh = this._parent.attachedMesh;\r\n this.attachedNode = this._parent.attachedNode;\r\n }\r\n }\r\n }\r\n\r\n public get isEnabled(): boolean {\r\n return this._isEnabled;\r\n }\r\n\r\n /**\r\n * Disposes of the gizmo\r\n */\r\n public dispose() {\r\n this.onSnapObservable.clear();\r\n this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);\r\n this.dragBehavior.detach();\r\n if (this._gizmoMesh) {\r\n this._gizmoMesh.dispose();\r\n }\r\n [this._coloredMaterial, this._hoverMaterial, this._disableMaterial].forEach((matl) => {\r\n if (matl) {\r\n matl.dispose();\r\n }\r\n });\r\n super.dispose();\r\n }\r\n}\r\n"]}
|
|
@@ -23,7 +23,7 @@ export interface IAxisScaleGizmo extends IGizmo {
|
|
|
23
23
|
snapDistance: number;
|
|
24
24
|
/**
|
|
25
25
|
* Event that fires each time the gizmo snaps to a new location.
|
|
26
|
-
* * snapDistance is the
|
|
26
|
+
* * snapDistance is the change in distance
|
|
27
27
|
*/
|
|
28
28
|
onSnapObservable: Observable<{
|
|
29
29
|
snapDistance: number;
|
|
@@ -58,7 +58,7 @@ export declare class AxisScaleGizmo extends Gizmo implements IAxisScaleGizmo {
|
|
|
58
58
|
snapDistance: number;
|
|
59
59
|
/**
|
|
60
60
|
* Event that fires each time the gizmo snaps to a new location.
|
|
61
|
-
* * snapDistance is the
|
|
61
|
+
* * snapDistance is the change in distance
|
|
62
62
|
*/
|
|
63
63
|
onSnapObservable: Observable<{
|
|
64
64
|
snapDistance: number;
|
package/Gizmos/axisScaleGizmo.js
CHANGED
|
@@ -42,7 +42,7 @@ export class AxisScaleGizmo extends Gizmo {
|
|
|
42
42
|
this.snapDistance = 0;
|
|
43
43
|
/**
|
|
44
44
|
* Event that fires each time the gizmo snaps to a new location.
|
|
45
|
-
* * snapDistance is the
|
|
45
|
+
* * snapDistance is the change in distance
|
|
46
46
|
*/
|
|
47
47
|
this.onSnapObservable = new Observable();
|
|
48
48
|
/**
|