1 |
- {"ast":null,"code":"import { AdvancedTimer } from \"../../../../Misc/timer.js\";\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock.js\";\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes.js\";\nimport { Tools } from \"../../../../Misc/tools.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\n/**\n * @experimental\n * Block that provides two different output flows. One is started immediately once the block is executed,\n * and the other is executed after a set time. The timer for this block runs based on the scene's render loop.\n */\nexport class FlowGraphTimerBlock extends FlowGraphAsyncExecutionBlock {\n constructor(config) {\n super(config);\n this.timeout = this.registerDataInput(\"timeout\", RichTypeNumber);\n }\n _preparePendingTasks(context) {\n const currentTimeout = this.timeout.getValue(context);\n if (currentTimeout !== undefined && currentTimeout >= 0) {\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\n const scene = context.configuration.scene;\n const timer = new AdvancedTimer({\n timeout: currentTimeout,\n contextObservable: scene.onBeforeRenderObservable,\n onEnded: () => this._onEnded(timer, context)\n });\n timer.start();\n timers.push(timer);\n context._setExecutionVariable(this, \"runningTimers\", timers);\n }\n }\n /**\n * @internal\n */\n _execute(context) {\n this._startPendingTasks(context);\n this.out._activateSignal(context);\n }\n _onEnded(timer, context) {\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\n const index = timers.indexOf(timer);\n if (index !== -1) {\n timers.splice(index, 1);\n } else {\n Tools.Warn(\"FlowGraphTimerBlock: Timer ended but was not found in the running timers list\");\n }\n context._removePendingBlock(this);\n this.done._activateSignal(context);\n }\n _cancelPendingTasks(context) {\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\n for (const timer of timers) {\n timer.dispose();\n }\n context._deleteExecutionVariable(this, \"runningTimers\");\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return FlowGraphTimerBlock.ClassName;\n }\n}\n/**\n * the class name of the block.\n */\nFlowGraphTimerBlock.ClassName = \"FGTimerBlock\";\nRegisterClass(\"FGTimerBlock\", FlowGraphTimerBlock);","map":{"version":3,"names":["AdvancedTimer","FlowGraphAsyncExecutionBlock","RichTypeNumber","Tools","RegisterClass","FlowGraphTimerBlock","constructor","config","timeout","registerDataInput","_preparePendingTasks","context","currentTimeout","getValue","undefined","timers","_getExecutionVariable","scene","configuration","timer","contextObservable","onBeforeRenderObservable","onEnded","_onEnded","start","push","_setExecutionVariable","_execute","_startPendingTasks","out","_activateSignal","index","indexOf","splice","Warn","_removePendingBlock","done","_cancelPendingTasks","dispose","_deleteExecutionVariable","getClassName","ClassName"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock.js"],"sourcesContent":["import { AdvancedTimer } from \"../../../../Misc/timer.js\";\nimport { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock.js\";\nimport { RichTypeNumber } from \"../../../flowGraphRichTypes.js\";\nimport { Tools } from \"../../../../Misc/tools.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\n/**\n * @experimental\n * Block that provides two different output flows. One is started immediately once the block is executed,\n * and the other is executed after a set time. The timer for this block runs based on the scene's render loop.\n */\nexport class FlowGraphTimerBlock extends FlowGraphAsyncExecutionBlock {\n constructor(config) {\n super(config);\n this.timeout = this.registerDataInput(\"timeout\", RichTypeNumber);\n }\n _preparePendingTasks(context) {\n const currentTimeout = this.timeout.getValue(context);\n if (currentTimeout !== undefined && currentTimeout >= 0) {\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\n const scene = context.configuration.scene;\n const timer = new AdvancedTimer({\n timeout: currentTimeout,\n contextObservable: scene.onBeforeRenderObservable,\n onEnded: () => this._onEnded(timer, context),\n });\n timer.start();\n timers.push(timer);\n context._setExecutionVariable(this, \"runningTimers\", timers);\n }\n }\n /**\n * @internal\n */\n _execute(context) {\n this._startPendingTasks(context);\n this.out._activateSignal(context);\n }\n _onEnded(timer, context) {\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\n const index = timers.indexOf(timer);\n if (index !== -1) {\n timers.splice(index, 1);\n }\n else {\n Tools.Warn(\"FlowGraphTimerBlock: Timer ended but was not found in the running timers list\");\n }\n context._removePendingBlock(this);\n this.done._activateSignal(context);\n }\n _cancelPendingTasks(context) {\n const timers = context._getExecutionVariable(this, \"runningTimers\") || [];\n for (const timer of timers) {\n timer.dispose();\n }\n context._deleteExecutionVariable(this, \"runningTimers\");\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return FlowGraphTimerBlock.ClassName;\n }\n}\n/**\n * the class name of the block.\n */\nFlowGraphTimerBlock.ClassName = \"FGTimerBlock\";\nRegisterClass(\"FGTimerBlock\", FlowGraphTimerBlock);\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,2BAA2B;AACzD,SAASC,4BAA4B,QAAQ,0CAA0C;AACvF,SAASC,cAAc,QAAQ,gCAAgC;AAC/D,SAASC,KAAK,QAAQ,2BAA2B;AACjD,SAASC,aAAa,QAAQ,+BAA+B;AAC7D;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,SAASJ,4BAA4B,CAAC;EAClEK,WAAWA,CAACC,MAAM,EAAE;IAChB,KAAK,CAACA,MAAM,CAAC;IACb,IAAI,CAACC,OAAO,GAAG,IAAI,CAACC,iBAAiB,CAAC,SAAS,EAAEP,cAAc,CAAC;EACpE;EACAQ,oBAAoBA,CAACC,OAAO,EAAE;IAC1B,MAAMC,cAAc,GAAG,IAAI,CAACJ,OAAO,CAACK,QAAQ,CAACF,OAAO,CAAC;IACrD,IAAIC,cAAc,KAAKE,SAAS,IAAIF,cAAc,IAAI,CAAC,EAAE;MACrD,MAAMG,MAAM,GAAGJ,OAAO,CAACK,qBAAqB,CAAC,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE;MACzE,MAAMC,KAAK,GAAGN,OAAO,CAACO,aAAa,CAACD,KAAK;MACzC,MAAME,KAAK,GAAG,IAAInB,aAAa,CAAC;QAC5BQ,OAAO,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