@babylonjs/core 6.21.2 → 6.21.4

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.
Files changed (123) hide show
  1. package/Animations/animatable.d.ts +4 -0
  2. package/Animations/animatable.js +6 -0
  3. package/Animations/animatable.js.map +1 -1
  4. package/Animations/animationGroup.d.ts +9 -0
  5. package/Animations/animationGroup.js +14 -0
  6. package/Animations/animationGroup.js.map +1 -1
  7. package/Buffers/buffer.d.ts +31 -2
  8. package/Buffers/buffer.js +100 -65
  9. package/Buffers/buffer.js.map +1 -1
  10. package/Engines/engine.d.ts +5 -0
  11. package/Engines/thinEngine.js +2 -2
  12. package/Engines/thinEngine.js.map +1 -1
  13. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.d.ts +59 -0
  14. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js +86 -0
  15. package/FlowGraph/Blocks/Data/Logic/flowGraphBitwiseBlocks.js.map +1 -0
  16. package/FlowGraph/Blocks/Data/Logic/index.d.ts +2 -0
  17. package/FlowGraph/Blocks/Data/Logic/index.js +3 -0
  18. package/FlowGraph/Blocks/Data/Logic/index.js.map +1 -0
  19. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.d.ts +2 -1
  20. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js +6 -2
  21. package/FlowGraph/Blocks/Data/Math/flowGraphNumberMathBlocks.js.map +1 -1
  22. package/FlowGraph/Blocks/Data/Math/index.d.ts +4 -0
  23. package/FlowGraph/Blocks/Data/Math/index.js +5 -0
  24. package/FlowGraph/Blocks/Data/Math/index.js.map +1 -0
  25. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js +1 -1
  26. package/FlowGraph/Blocks/Data/flowGraphBinaryOperationBlock.js.map +1 -1
  27. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js +1 -1
  28. package/FlowGraph/Blocks/Data/flowGraphConditionalDataBlock.js.map +1 -1
  29. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.d.ts +2 -1
  30. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js +2 -2
  31. package/FlowGraph/Blocks/Data/flowGraphConstantOperationBlock.js.map +1 -1
  32. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.d.ts +1 -8
  33. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js +2 -5
  34. package/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js.map +1 -1
  35. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js +1 -1
  36. package/FlowGraph/Blocks/Data/flowGraphUnaryOperationBlock.js.map +1 -1
  37. package/FlowGraph/Blocks/Data/index.d.ts +2 -4
  38. package/FlowGraph/Blocks/Data/index.js +4 -4
  39. package/FlowGraph/Blocks/Data/index.js.map +1 -1
  40. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js +1 -1
  41. package/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock.js.map +1 -1
  42. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js +1 -3
  43. package/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js.map +1 -1
  44. package/FlowGraph/Blocks/Execution/{flowGraphConditionalBlock.d.ts → ControlFlow/flowGraphConditionalBlock.d.ts} +5 -5
  45. package/FlowGraph/Blocks/Execution/{flowGraphConditionalBlock.js → ControlFlow/flowGraphConditionalBlock.js} +3 -3
  46. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphConditionalBlock.js.map +1 -0
  47. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.d.ts +20 -0
  48. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js +26 -0
  49. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphCounterBlock.js.map +1 -0
  50. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.d.ts +24 -0
  51. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js +30 -0
  52. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDebounceBlock.js.map +1 -0
  53. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.d.ts +24 -0
  54. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js +27 -0
  55. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js.map +1 -0
  56. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.d.ts +24 -0
  57. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js +27 -0
  58. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphFlipFlopBlock.js.map +1 -0
  59. package/FlowGraph/Blocks/Execution/{flowGraphForLoopBlock.d.ts → ControlFlow/flowGraphForLoopBlock.d.ts} +4 -4
  60. package/FlowGraph/Blocks/Execution/{flowGraphForLoopBlock.js → ControlFlow/flowGraphForLoopBlock.js} +4 -5
  61. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphForLoopBlock.js.map +1 -0
  62. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.d.ts +51 -0
  63. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js +77 -0
  64. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphMultiGateBlock.js.map +1 -0
  65. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.d.ts +31 -0
  66. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js +32 -0
  67. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSwitchBlock.js.map +1 -0
  68. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.d.ts +24 -0
  69. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js +31 -0
  70. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphThrottleBlock.js.map +1 -0
  71. package/FlowGraph/Blocks/Execution/{flowGraphTimerBlock.d.ts → ControlFlow/flowGraphTimerBlock.d.ts} +5 -9
  72. package/FlowGraph/Blocks/Execution/{flowGraphTimerBlock.js → ControlFlow/flowGraphTimerBlock.js} +5 -9
  73. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js.map +1 -0
  74. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.d.ts +32 -0
  75. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js +62 -0
  76. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWaitAllBlock.js.map +1 -0
  77. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.d.ts +31 -0
  78. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js +27 -0
  79. package/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock.js.map +1 -0
  80. package/FlowGraph/Blocks/Execution/ControlFlow/index.d.ts +12 -0
  81. package/FlowGraph/Blocks/Execution/ControlFlow/index.js +13 -0
  82. package/FlowGraph/Blocks/Execution/ControlFlow/index.js.map +1 -0
  83. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js +0 -1
  84. package/FlowGraph/Blocks/Execution/flowGraphLogBlock.js.map +1 -1
  85. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.d.ts +1 -5
  86. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js +3 -8
  87. package/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js.map +1 -1
  88. package/FlowGraph/Blocks/Execution/index.d.ts +1 -3
  89. package/FlowGraph/Blocks/Execution/index.js +2 -3
  90. package/FlowGraph/Blocks/Execution/index.js.map +1 -1
  91. package/FlowGraph/flowGraphConnection.d.ts +4 -0
  92. package/FlowGraph/flowGraphConnection.js +5 -0
  93. package/FlowGraph/flowGraphConnection.js.map +1 -1
  94. package/FlowGraph/flowGraphContext.d.ts +42 -2
  95. package/FlowGraph/flowGraphContext.js +58 -6
  96. package/FlowGraph/flowGraphContext.js.map +1 -1
  97. package/FlowGraph/flowGraphDataConnection.d.ts +19 -2
  98. package/FlowGraph/flowGraphDataConnection.js +29 -5
  99. package/FlowGraph/flowGraphDataConnection.js.map +1 -1
  100. package/FlowGraph/flowGraphExecutionBlock.d.ts +1 -1
  101. package/FlowGraph/flowGraphExecutionBlock.js.map +1 -1
  102. package/FlowGraph/flowGraphSignalConnection.js +1 -1
  103. package/FlowGraph/flowGraphSignalConnection.js.map +1 -1
  104. package/Lights/Shadows/cascadedShadowGenerator.js +1 -1
  105. package/Lights/Shadows/cascadedShadowGenerator.js.map +1 -1
  106. package/Materials/Textures/equiRectangularCubeTexture.js +2 -0
  107. package/Materials/Textures/equiRectangularCubeTexture.js.map +1 -1
  108. package/Materials/Textures/texture.js +2 -2
  109. package/Materials/Textures/texture.js.map +1 -1
  110. package/Meshes/Compression/dracoCompression.js +28 -13
  111. package/Meshes/Compression/dracoCompression.js.map +1 -1
  112. package/Misc/fileTools.js +2 -2
  113. package/Misc/fileTools.js.map +1 -1
  114. package/Misc/webRequest.d.ts +5 -0
  115. package/Misc/webRequest.js +7 -0
  116. package/Misc/webRequest.js.map +1 -1
  117. package/XR/features/WebXRPlaneDetector.d.ts +8 -0
  118. package/XR/features/WebXRPlaneDetector.js +13 -0
  119. package/XR/features/WebXRPlaneDetector.js.map +1 -1
  120. package/package.json +1 -1
  121. package/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.js.map +0 -1
  122. package/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.js.map +0 -1
  123. package/FlowGraph/Blocks/Execution/flowGraphTimerBlock.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"WebXRPlaneDetector.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRPlaneDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,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AAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,oBAAoB,EAAE;gBACpD,GAAG,CAAC,4BAA4B,EAAE,CAAC;aACtC;YACD,KAAK,CAAC,oBAAoB,GAAG,GAAG,CAAC;YACjC,IAAI,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE;gBAC/B,GAAG,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC,cAAc,EAAE,EAAE,GAAG,CAAC,CAAC;aAC1E;SACJ;QAED,OAAoB,KAAK,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACK,sBAAsB,CAAC,OAAgB;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YAClD,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,OAAO,KAAK,OAAO,EAAE;gBAC7C,OAAO,CAAC,CAAC;aACZ;SACJ;QACD,OAAO,CAAC,CAAC,CAAC;IACd,CAAC;;AAlLD;;GAEG;AACoB,uBAAI,GAAG,gBAAgB,CAAC,eAAe,AAAnC,CAAoC;AAC/D;;;;GAIG;AACoB,0BAAO,GAAG,CAAC,AAAJ,CAAK;AA4KvC,qBAAqB;AACrB,oBAAoB,CAAC,eAAe,CAChC,kBAAkB,CAAC,IAAI,EACvB,CAAC,gBAAgB,EAAE,OAAO,EAAE,EAAE;IAC1B,OAAO,GAAG,EAAE,CAAC,IAAI,kBAAkB,CAAC,gBAAgB,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC,EACD,kBAAkB,CAAC,OAAO,CAC7B,CAAC","sourcesContent":["import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Vector3, Matrix } from \"../../Maths/math.vector\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\n\r\ndeclare const XRPlane: XRPlane;\r\n\r\n/**\r\n * Options used in the plane detector module\r\n */\r\nexport interface IWebXRPlaneDetectorOptions {\r\n /**\r\n * The node to use to transform the local results to world coordinates\r\n */\r\n worldParentNode?: TransformNode;\r\n /**\r\n * If set to true a reference of the created planes will be kept until the next session starts\r\n * If not defined, planes will be removed from the array when the feature is detached or the session ended.\r\n */\r\n doNotRemovePlanesOnSessionEnded?: boolean;\r\n /**\r\n * Preferred detector configuration, not all preferred options will be supported by all platforms.\r\n */\r\n preferredDetectorOptions?: XRGeometryDetectorOptions;\r\n}\r\n\r\n/**\r\n * A babylon interface for a WebXR plane.\r\n * A Plane is actually a polygon, built from N points in space\r\n *\r\n * Supported in chrome 79, not supported in canary 81 ATM\r\n */\r\nexport interface IWebXRPlane {\r\n /**\r\n * a babylon-assigned ID for this polygon\r\n */\r\n id: number;\r\n /**\r\n * an array of vector3 points in babylon space. right/left hand system is taken into account.\r\n */\r\n polygonDefinition: Array<Vector3>;\r\n /**\r\n * A transformation matrix to apply on the mesh that will be built using the polygonDefinition\r\n * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module\r\n */\r\n transformationMatrix: Matrix;\r\n /**\r\n * the native xr-plane object\r\n */\r\n xrPlane: XRPlane;\r\n}\r\n\r\nlet planeIdProvider = 0;\r\n\r\n/**\r\n * The plane detector is used to detect planes in the real world when in AR\r\n * For more information see https://github.com/immersive-web/real-world-geometry/\r\n */\r\nexport class WebXRPlaneDetector extends WebXRAbstractFeature {\r\n private _detectedPlanes: Array<IWebXRPlane> = [];\r\n private _enabled: boolean = false;\r\n private _lastFrameDetected: XRPlaneSet = new Set();\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.PLANE_DETECTION;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /**\r\n * Observers registered here will be executed when a new plane was added to the session\r\n */\r\n public onPlaneAddedObservable: Observable<IWebXRPlane> = new Observable();\r\n /**\r\n * Observers registered here will be executed when a plane is no longer detected in the session\r\n */\r\n public onPlaneRemovedObservable: Observable<IWebXRPlane> = new Observable();\r\n /**\r\n * Observers registered here will be executed when an existing plane updates (for example - expanded)\r\n * This can execute N times every frame\r\n */\r\n public onPlaneUpdatedObservable: Observable<IWebXRPlane> = new Observable();\r\n\r\n /**\r\n * construct a new Plane Detector\r\n * @param _xrSessionManager an instance of xr Session manager\r\n * @param _options configuration to use when constructing this feature\r\n */\r\n constructor(_xrSessionManager: WebXRSessionManager, private _options: IWebXRPlaneDetectorOptions = {}) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"plane-detection\";\r\n if (this._xrSessionManager.session) {\r\n this._init();\r\n } else {\r\n this._xrSessionManager.onXRSessionInit.addOnce(() => {\r\n this._init();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n\r\n if (!this._options.doNotRemovePlanesOnSessionEnded) {\r\n while (this._detectedPlanes.length) {\r\n const toRemove = this._detectedPlanes.pop();\r\n if (toRemove) {\r\n this.onPlaneRemovedObservable.notifyObservers(toRemove);\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispose this feature and all of the resources attached\r\n */\r\n public dispose(): void {\r\n super.dispose();\r\n this.onPlaneAddedObservable.clear();\r\n this.onPlaneRemovedObservable.clear();\r\n this.onPlaneUpdatedObservable.clear();\r\n }\r\n\r\n /**\r\n * Check if the needed objects are defined.\r\n * This does not mean that the feature is enabled, but that the objects needed are well defined.\r\n */\r\n public isCompatible(): boolean {\r\n return typeof XRPlane !== \"undefined\";\r\n }\r\n\r\n protected _onXRFrame(frame: XRFrame) {\r\n if (!this.attached || !this._enabled || !frame) {\r\n return;\r\n }\r\n\r\n const detectedPlanes = frame.detectedPlanes || frame.worldInformation?.detectedPlanes;\r\n if (detectedPlanes) {\r\n // remove all planes that are not currently detected in the frame\r\n for (let planeIdx = 0; planeIdx < this._detectedPlanes.length; planeIdx++) {\r\n const plane = this._detectedPlanes[planeIdx];\r\n if (!detectedPlanes.has(plane.xrPlane)) {\r\n this._detectedPlanes.splice(planeIdx--, 1);\r\n this.onPlaneRemovedObservable.notifyObservers(plane);\r\n }\r\n }\r\n\r\n // now check for new ones\r\n detectedPlanes.forEach((xrPlane) => {\r\n if (!this._lastFrameDetected.has(xrPlane)) {\r\n const newPlane: Partial<IWebXRPlane> = {\r\n id: planeIdProvider++,\r\n xrPlane: xrPlane,\r\n polygonDefinition: [],\r\n };\r\n const plane = this._updatePlaneWithXRPlane(xrPlane, newPlane, frame);\r\n this._detectedPlanes.push(plane);\r\n this.onPlaneAddedObservable.notifyObservers(plane);\r\n } else {\r\n // updated?\r\n if (xrPlane.lastChangedTime === this._xrSessionManager.currentTimestamp) {\r\n const index = this._findIndexInPlaneArray(xrPlane);\r\n const plane = this._detectedPlanes[index];\r\n this._updatePlaneWithXRPlane(xrPlane, plane, frame);\r\n this.onPlaneUpdatedObservable.notifyObservers(plane);\r\n }\r\n }\r\n });\r\n this._lastFrameDetected = detectedPlanes;\r\n }\r\n }\r\n\r\n private _init() {\r\n const internalInit = () => {\r\n this._enabled = true;\r\n if (this._detectedPlanes.length) {\r\n this._detectedPlanes.length = 0;\r\n }\r\n };\r\n\r\n // Only supported by BabylonNative\r\n if (!!this._xrSessionManager.isNative && !!this._options.preferredDetectorOptions && !!this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions) {\r\n this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions(this._options.preferredDetectorOptions);\r\n }\r\n\r\n if (!this._xrSessionManager.session.updateWorldTrackingState) {\r\n internalInit();\r\n return;\r\n }\r\n this._xrSessionManager.session.updateWorldTrackingState({ planeDetectionState: { enabled: true } });\r\n internalInit();\r\n }\r\n\r\n private _updatePlaneWithXRPlane(xrPlane: XRPlane, plane: Partial<IWebXRPlane>, xrFrame: XRFrame): IWebXRPlane {\r\n plane.polygonDefinition = xrPlane.polygon.map((xrPoint) => {\r\n const rightHandedSystem = this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;\r\n return new Vector3(xrPoint.x, xrPoint.y, xrPoint.z * rightHandedSystem);\r\n });\r\n // matrix\r\n const pose = xrFrame.getPose(xrPlane.planeSpace, this._xrSessionManager.referenceSpace);\r\n if (pose) {\r\n const mat = plane.transformationMatrix || new Matrix();\r\n Matrix.FromArrayToRef(pose.transform.matrix, 0, mat);\r\n if (!this._xrSessionManager.scene.useRightHandedSystem) {\r\n mat.toggleModelMatrixHandInPlace();\r\n }\r\n plane.transformationMatrix = mat;\r\n if (this._options.worldParentNode) {\r\n mat.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), mat);\r\n }\r\n }\r\n\r\n return <IWebXRPlane>plane;\r\n }\r\n\r\n /**\r\n * avoiding using Array.find for global support.\r\n * @param xrPlane the plane to find in the array\r\n */\r\n private _findIndexInPlaneArray(xrPlane: XRPlane) {\r\n for (let i = 0; i < this._detectedPlanes.length; ++i) {\r\n if (this._detectedPlanes[i].xrPlane === xrPlane) {\r\n return i;\r\n }\r\n }\r\n return -1;\r\n }\r\n}\r\n\r\n//register the plugin\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRPlaneDetector.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRPlaneDetector(xrSessionManager, options);\r\n },\r\n WebXRPlaneDetector.Version\r\n);\r\n"]}
1
+ {"version":3,"file":"WebXRPlaneDetector.js","sourceRoot":"","sources":["../../../../../dev/core/src/XR/features/WebXRPlaneDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGjF,OAAO,EAAE,UAAU,EAAE,M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,CAAC","sourcesContent":["import { WebXRFeaturesManager, WebXRFeatureName } from \"../webXRFeaturesManager\";\r\nimport type { TransformNode } from \"../../Meshes/transformNode\";\r\nimport type { WebXRSessionManager } from \"../webXRSessionManager\";\r\nimport { Observable } from \"../../Misc/observable\";\r\nimport { Vector3, Matrix } from \"../../Maths/math.vector\";\r\nimport { WebXRAbstractFeature } from \"./WebXRAbstractFeature\";\r\n\r\ndeclare const XRPlane: XRPlane;\r\n\r\n/**\r\n * Options used in the plane detector module\r\n */\r\nexport interface IWebXRPlaneDetectorOptions {\r\n /**\r\n * The node to use to transform the local results to world coordinates\r\n */\r\n worldParentNode?: TransformNode;\r\n /**\r\n * If set to true a reference of the created planes will be kept until the next session starts\r\n * If not defined, planes will be removed from the array when the feature is detached or the session ended.\r\n */\r\n doNotRemovePlanesOnSessionEnded?: boolean;\r\n /**\r\n * Preferred detector configuration, not all preferred options will be supported by all platforms.\r\n */\r\n preferredDetectorOptions?: XRGeometryDetectorOptions;\r\n}\r\n\r\n/**\r\n * A babylon interface for a WebXR plane.\r\n * A Plane is actually a polygon, built from N points in space\r\n *\r\n * Supported in chrome 79, not supported in canary 81 ATM\r\n */\r\nexport interface IWebXRPlane {\r\n /**\r\n * a babylon-assigned ID for this polygon\r\n */\r\n id: number;\r\n /**\r\n * an array of vector3 points in babylon space. right/left hand system is taken into account.\r\n */\r\n polygonDefinition: Array<Vector3>;\r\n /**\r\n * A transformation matrix to apply on the mesh that will be built using the polygonDefinition\r\n * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module\r\n */\r\n transformationMatrix: Matrix;\r\n /**\r\n * the native xr-plane object\r\n */\r\n xrPlane: XRPlane;\r\n}\r\n\r\nlet planeIdProvider = 0;\r\n\r\n/**\r\n * The plane detector is used to detect planes in the real world when in AR\r\n * For more information see https://github.com/immersive-web/real-world-geometry/\r\n */\r\nexport class WebXRPlaneDetector extends WebXRAbstractFeature {\r\n private _detectedPlanes: Array<IWebXRPlane> = [];\r\n private _enabled: boolean = false;\r\n private _lastFrameDetected: XRPlaneSet = new Set();\r\n\r\n /**\r\n * The module's name\r\n */\r\n public static readonly Name = WebXRFeatureName.PLANE_DETECTION;\r\n /**\r\n * The (Babylon) version of this module.\r\n * This is an integer representing the implementation version.\r\n * This number does not correspond to the WebXR specs version\r\n */\r\n public static readonly Version = 1;\r\n\r\n /**\r\n * Observers registered here will be executed when a new plane was added to the session\r\n */\r\n public onPlaneAddedObservable: Observable<IWebXRPlane> = new Observable();\r\n /**\r\n * Observers registered here will be executed when a plane is no longer detected in the session\r\n */\r\n public onPlaneRemovedObservable: Observable<IWebXRPlane> = new Observable();\r\n /**\r\n * Observers registered here will be executed when an existing plane updates (for example - expanded)\r\n * This can execute N times every frame\r\n */\r\n public onPlaneUpdatedObservable: Observable<IWebXRPlane> = new Observable();\r\n\r\n /**\r\n * construct a new Plane Detector\r\n * @param _xrSessionManager an instance of xr Session manager\r\n * @param _options configuration to use when constructing this feature\r\n */\r\n constructor(_xrSessionManager: WebXRSessionManager, private _options: IWebXRPlaneDetectorOptions = {}) {\r\n super(_xrSessionManager);\r\n this.xrNativeFeatureName = \"plane-detection\";\r\n if (this._xrSessionManager.session) {\r\n this._init();\r\n } else {\r\n this._xrSessionManager.onXRSessionInit.addOnce(() => {\r\n this._init();\r\n });\r\n }\r\n }\r\n\r\n /**\r\n * detach this feature.\r\n * Will usually be called by the features manager\r\n *\r\n * @returns true if successful.\r\n */\r\n public detach(): boolean {\r\n if (!super.detach()) {\r\n return false;\r\n }\r\n\r\n if (!this._options.doNotRemovePlanesOnSessionEnded) {\r\n while (this._detectedPlanes.length) {\r\n const toRemove = this._detectedPlanes.pop();\r\n if (toRemove) {\r\n this.onPlaneRemovedObservable.notifyObservers(toRemove);\r\n }\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Dispose this feature and all of the resources attached\r\n */\r\n public dispose(): void {\r\n super.dispose();\r\n this.onPlaneAddedObservable.clear();\r\n this.onPlaneRemovedObservable.clear();\r\n this.onPlaneUpdatedObservable.clear();\r\n }\r\n\r\n /**\r\n * Check if the needed objects are defined.\r\n * This does not mean that the feature is enabled, but that the objects needed are well defined.\r\n */\r\n public isCompatible(): boolean {\r\n return typeof XRPlane !== \"undefined\";\r\n }\r\n\r\n /**\r\n * Enable room capture mode.\r\n * When enabled and supported by the system,\r\n * the detectedPlanes array will be populated with the detected room boundaries\r\n * @see https://immersive-web.github.io/real-world-geometry/plane-detection.html#dom-xrsession-initiateroomcapture\r\n * @returns true if plane detection is enabled and supported. Will reject if not supported.\r\n */\r\n public async initiateRoomCapture(): Promise<void> {\r\n if (this._xrSessionManager.session.initiateRoomCapture) {\r\n return this._xrSessionManager.session.initiateRoomCapture();\r\n }\r\n return Promise.reject(\"initiateRoomCapture is not supported on this session\");\r\n }\r\n\r\n protected _onXRFrame(frame: XRFrame) {\r\n if (!this.attached || !this._enabled || !frame) {\r\n return;\r\n }\r\n\r\n const detectedPlanes = frame.detectedPlanes || frame.worldInformation?.detectedPlanes;\r\n if (detectedPlanes) {\r\n // remove all planes that are not currently detected in the frame\r\n for (let planeIdx = 0; planeIdx < this._detectedPlanes.length; planeIdx++) {\r\n const plane = this._detectedPlanes[planeIdx];\r\n if (!detectedPlanes.has(plane.xrPlane)) {\r\n this._detectedPlanes.splice(planeIdx--, 1);\r\n this.onPlaneRemovedObservable.notifyObservers(plane);\r\n }\r\n }\r\n\r\n // now check for new ones\r\n detectedPlanes.forEach((xrPlane) => {\r\n if (!this._lastFrameDetected.has(xrPlane)) {\r\n const newPlane: Partial<IWebXRPlane> = {\r\n id: planeIdProvider++,\r\n xrPlane: xrPlane,\r\n polygonDefinition: [],\r\n };\r\n const plane = this._updatePlaneWithXRPlane(xrPlane, newPlane, frame);\r\n this._detectedPlanes.push(plane);\r\n this.onPlaneAddedObservable.notifyObservers(plane);\r\n } else {\r\n // updated?\r\n if (xrPlane.lastChangedTime === this._xrSessionManager.currentTimestamp) {\r\n const index = this._findIndexInPlaneArray(xrPlane);\r\n const plane = this._detectedPlanes[index];\r\n this._updatePlaneWithXRPlane(xrPlane, plane, frame);\r\n this.onPlaneUpdatedObservable.notifyObservers(plane);\r\n }\r\n }\r\n });\r\n this._lastFrameDetected = detectedPlanes;\r\n }\r\n }\r\n\r\n private _init() {\r\n const internalInit = () => {\r\n this._enabled = true;\r\n if (this._detectedPlanes.length) {\r\n this._detectedPlanes.length = 0;\r\n }\r\n };\r\n\r\n // Only supported by BabylonNative\r\n if (!!this._xrSessionManager.isNative && !!this._options.preferredDetectorOptions && !!this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions) {\r\n this._xrSessionManager.session.trySetPreferredPlaneDetectorOptions(this._options.preferredDetectorOptions);\r\n }\r\n\r\n if (!this._xrSessionManager.session.updateWorldTrackingState) {\r\n internalInit();\r\n return;\r\n }\r\n this._xrSessionManager.session.updateWorldTrackingState({ planeDetectionState: { enabled: true } });\r\n internalInit();\r\n }\r\n\r\n private _updatePlaneWithXRPlane(xrPlane: XRPlane, plane: Partial<IWebXRPlane>, xrFrame: XRFrame): IWebXRPlane {\r\n plane.polygonDefinition = xrPlane.polygon.map((xrPoint) => {\r\n const rightHandedSystem = this._xrSessionManager.scene.useRightHandedSystem ? 1 : -1;\r\n return new Vector3(xrPoint.x, xrPoint.y, xrPoint.z * rightHandedSystem);\r\n });\r\n // matrix\r\n const pose = xrFrame.getPose(xrPlane.planeSpace, this._xrSessionManager.referenceSpace);\r\n if (pose) {\r\n const mat = plane.transformationMatrix || new Matrix();\r\n Matrix.FromArrayToRef(pose.transform.matrix, 0, mat);\r\n if (!this._xrSessionManager.scene.useRightHandedSystem) {\r\n mat.toggleModelMatrixHandInPlace();\r\n }\r\n plane.transformationMatrix = mat;\r\n if (this._options.worldParentNode) {\r\n mat.multiplyToRef(this._options.worldParentNode.getWorldMatrix(), mat);\r\n }\r\n }\r\n\r\n return <IWebXRPlane>plane;\r\n }\r\n\r\n /**\r\n * avoiding using Array.find for global support.\r\n * @param xrPlane the plane to find in the array\r\n */\r\n private _findIndexInPlaneArray(xrPlane: XRPlane) {\r\n for (let i = 0; i < this._detectedPlanes.length; ++i) {\r\n if (this._detectedPlanes[i].xrPlane === xrPlane) {\r\n return i;\r\n }\r\n }\r\n return -1;\r\n }\r\n}\r\n\r\n//register the plugin\r\nWebXRFeaturesManager.AddWebXRFeature(\r\n WebXRPlaneDetector.Name,\r\n (xrSessionManager, options) => {\r\n return () => new WebXRPlaneDetector(xrSessionManager, options);\r\n },\r\n WebXRPlaneDetector.Version\r\n);\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs/core",
3
- "version": "6.21.2",
3
+ "version": "6.21.4",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
6
  "types": "index.d.ts",
@@ -1 +0,0 @@
1
- {"version":3,"file":"flowGraphConditionalBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphConditionalBlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGxE;;;GAGG;AACH,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;IAclE;QACI,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;QAEvE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACnD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;IACzD,CAAC;IAEM,QAAQ,CAAC,OAAyB;QACrC,IAAI,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;YAClC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SACxC;aAAM;YACH,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;SACzC;IACL,CAAC;CACJ","sourcesContent":["import { RichTypeBoolean } from \"../../flowGraphRichTypes\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { FlowGraphExecutionBlock } from \"../../flowGraphExecutionBlock\";\r\nimport type { FlowGraphSignalConnection } from \"../../flowGraphSignalConnection\";\r\n\r\n/**\r\n * @experimental\r\n * A block that evaluates a condition and executes one of two branches.\r\n */\r\nexport class FlowGraphConditionalBlock extends FlowGraphExecutionBlock {\r\n /**\r\n * Input connection: The condition to evaluate.\r\n */\r\n public readonly condition: FlowGraphDataConnection<boolean>;\r\n /**\r\n * Output connection: The branch to execute if the condition is true.\r\n */\r\n public readonly onTrue: FlowGraphSignalConnection;\r\n /**\r\n * Output connection: The branch to execute if the condition is false.\r\n */\r\n public readonly onFalse: FlowGraphSignalConnection;\r\n\r\n constructor() {\r\n super();\r\n\r\n this.condition = this._registerDataInput(\"condition\", RichTypeBoolean);\r\n\r\n this.onTrue = this._registerSignalOutput(\"onTrue\");\r\n this.onFalse = this._registerSignalOutput(\"onFalse\");\r\n }\r\n\r\n public _execute(context: FlowGraphContext): void {\r\n if (this.condition.getValue(context)) {\r\n this.onTrue._activateSignal(context);\r\n } else {\r\n this.onFalse._activateSignal(context);\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"flowGraphForLoopBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphForLoopBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iCAAiC,EAAE,mDAAyD;AAErG,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D;;;GAGG;AACH,MAAM,OAAO,qBAAsB,SAAQ,iCAAiC;IA0BxE;QACI,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,UAA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,CAAC,OAAyB;QACrC,MAAM,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QACzC,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QACpD,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC1D,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACJ","sourcesContent":["import type { FlowGraphSignalConnection } from \"../../flowGraphSignalConnection\";\r\nimport type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport { FlowGraphWithOnDoneExecutionBlock } from \"core/FlowGraph/flowGraphWithOnDoneExecutionBlock\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { RichTypeNumber } from \"../../flowGraphRichTypes\";\r\n\r\n/**\r\n * @experimental\r\n * Block that executes an action in a loop.\r\n */\r\nexport class FlowGraphForLoopBlock extends FlowGraphWithOnDoneExecutionBlock {\r\n /**\r\n * Input connection: The start index of the loop.\r\n */\r\n public readonly startIndex: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The end index of the loop.\r\n */\r\n public readonly endIndex: FlowGraphDataConnection<number>;\r\n /**\r\n * Input connection: The step of the loop.\r\n */\r\n public readonly step: FlowGraphDataConnection<number>;\r\n /**\r\n * Output connection: The current index of the loop.\r\n */\r\n public readonly index: FlowGraphDataConnection<number>;\r\n /**\r\n * Output connection: The signal that is activated when the loop body is executed.\r\n */\r\n public readonly onLoop: FlowGraphSignalConnection;\r\n /**\r\n * Output connection: The signal that is activated when the loop is done.\r\n */\r\n public readonly onDone: FlowGraphSignalConnection;\r\n\r\n public constructor() {\r\n super();\r\n\r\n this.startIndex = this._registerDataInput(\"startIndex\", RichTypeNumber);\r\n this.endIndex = this._registerDataInput(\"endIndex\", RichTypeNumber);\r\n this.step = this._registerDataInput(\"step\", RichTypeNumber);\r\n this.step.value = 1;\r\n\r\n this.index = this._registerDataOutput(\"index\", RichTypeNumber);\r\n this.onLoop = this._registerSignalOutput(\"onLoop\");\r\n this.onDone = this._registerSignalOutput(\"onDone\");\r\n }\r\n\r\n private _executeLoop(context: FlowGraphContext) {\r\n let index = context._getExecutionVariable(this, \"index\");\r\n const endIndex = context._getExecutionVariable(this, \"endIndex\");\r\n if (index < endIndex) {\r\n this.index.value = index;\r\n this.onLoop._activateSignal(context);\r\n const step = context._getExecutionVariable(this, \"step\");\r\n index += step;\r\n context._setExecutionVariable(this, \"index\", index);\r\n this._executeLoop(context);\r\n } else {\r\n this.onDone._activateSignal(context);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext): void {\r\n const index = this.startIndex.getValue(context);\r\n const endIndex = this.endIndex.getValue(context);\r\n const step = this.step.getValue(context);\r\n context._setExecutionVariable(this, \"index\", index);\r\n context._setExecutionVariable(this, \"endIndex\", endIndex);\r\n context._setExecutionVariable(this, \"step\", step);\r\n this._executeLoop(context);\r\n }\r\n}\r\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"flowGraphTimerBlock.js","sourceRoot":"","sources":["../../../../../../dev/core/src/FlowGraph/Blocks/Execution/flowGraphTimerBlock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM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O,CAAC,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAEO,QAAQ,CAAC,KAAoB,EAAE,OAAyB;QAC5D,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC;QAC1E,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;YACd,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;SAC3B;aAAM;YACH,KAAK,CAAC,IAAI,CAAC,+EAA+E,CAAC,CAAC;SAC/F;QACD,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAEM,mBAAmB,CAAC,OAAyB;QAChD,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC;QAC1E,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE;YACxB,KAAK,CAAC,OAAO,EAAE,CAAC;SACnB;QACD,OAAO,CAAC,wBAAwB,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;IAC5D,CAAC;CACJ","sourcesContent":["import type { FlowGraphDataConnection } from \"../../flowGraphDataConnection\";\r\nimport type { FlowGraphSignalConnection } from \"../../flowGraphSignalConnection\";\r\nimport { AdvancedTimer } from \"../../../Misc/timer\";\r\nimport type { FlowGraphContext } from \"../../flowGraphContext\";\r\nimport { FlowGraphAsyncExecutionBlock } from \"../../flowGraphAsyncExecutionBlock\";\r\nimport { RichTypeNumber } from \"../../flowGraphRichTypes\";\r\nimport { Tools } from \"../../../Misc/tools\";\r\n\r\nexport interface IFlowGraphTimerBlockParameters {\r\n timeout?: number;\r\n}\r\n\r\n/**\r\n * @experimental\r\n * question: is this doc understandable enough? accepting suggestions\r\n * Block that provides two different output flows. One is started immediately once the block is executed,\r\n * and the other is executed after a set time. The timer for this block runs based on the scene's render loop.\r\n */\r\nexport class FlowGraphTimerBlock extends FlowGraphAsyncExecutionBlock {\r\n /**\r\n * Input connection: The timeout of the timer.\r\n */\r\n public readonly timeout: FlowGraphDataConnection<number>;\r\n /**\r\n * Output connection: The signal that is activated when the timer is done.\r\n * This signal is activated asynchronically.\r\n */\r\n public readonly onTimerDone: FlowGraphSignalConnection;\r\n\r\n constructor(parameters?: IFlowGraphTimerBlockParameters) {\r\n super();\r\n\r\n this.timeout = this._registerDataInput(\"timeout\", RichTypeNumber);\r\n if (parameters?.timeout !== undefined) {\r\n this.timeout.value = parameters.timeout;\r\n }\r\n this.onTimerDone = this._registerSignalOutput(\"onTimerDone\");\r\n }\r\n\r\n public _preparePendingTasks(context: FlowGraphContext): void {\r\n const currentTimeout = this.timeout.getValue(context);\r\n\r\n if (currentTimeout !== undefined && currentTimeout >= 0) {\r\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\r\n const scene = context.graphVariables.scene;\r\n const timer: AdvancedTimer = new AdvancedTimer({\r\n timeout: currentTimeout,\r\n contextObservable: scene.onBeforeRenderObservable,\r\n onEnded: () => this._onEnded(timer, context),\r\n });\r\n timer.start();\r\n\r\n timers.push(timer);\r\n context._setExecutionVariable(this, \"runningTimers\", timers);\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _execute(context: FlowGraphContext) {\r\n this._startPendingTasks(context);\r\n this.onDone._activateSignal(context);\r\n }\r\n\r\n private _onEnded(timer: AdvancedTimer, context: FlowGraphContext) {\r\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\r\n const index = timers.indexOf(timer);\r\n if (index !== -1) {\r\n timers.splice(index, 1);\r\n } else {\r\n Tools.Warn(\"FlowGraphTimerBlock: Timer ended but was not found in the running timers list\");\r\n }\r\n context._removePendingBlock(this);\r\n this.onTimerDone._activateSignal(context);\r\n }\r\n\r\n public _cancelPendingTasks(context: FlowGraphContext): void {\r\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\r\n for (const timer of timers) {\r\n timer.dispose();\r\n }\r\n context._deleteExecutionVariable(this, \"runningTimers\");\r\n }\r\n}\r\n"]}