a72e2541c55e37e26ac122fcd9762162dac30caf857c749b8ec2b6b59a097c38.json 14 KB

1
  1. {"ast":null,"code":"import { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock.js\";\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { FlowGraphPathConverterComponent } from \"../../../flowGraphPathConverterComponent.js\";\n/**\n * @experimental\n * A block that plays an animation on an animatable object.\n */\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\n constructor(\n /**\n * the configuration of the block\n */\n config) {\n super(config);\n this.config = config;\n this.templateTargetComponent = new FlowGraphPathConverterComponent(config.targetPath, this);\n this.templateAnimationComponent = new FlowGraphPathConverterComponent(config.animationPath, this);\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\n this.from = this.registerDataInput(\"from\", RichTypeNumber);\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\n this.runningAnimatable = this.registerDataOutput(\"runningAnimatable\", RichTypeAny);\n }\n /**\n * @internal\n * @param context\n */\n _preparePendingTasks(context) {\n var _context$_getExecutio;\n const targetAccessor = this.templateTargetComponent.getAccessor(this.config.pathConverter, context);\n const targetValue = targetAccessor.info.getObject(targetAccessor.object);\n const animationAccessor = this.templateAnimationComponent.getAccessor(this.config.pathConverter, context);\n const animationValue = animationAccessor.info.get(animationAccessor.object);\n if (!targetValue || !animationValue) {\n throw new Error(\"Cannot play animation without target or animation\");\n }\n const contextAnimatables = (_context$_getExecutio = context._getExecutionVariable(this, \"runningAnimatables\")) !== null && _context$_getExecutio !== void 0 ? _context$_getExecutio : [];\n // was an animation started on this target already and was just paused? if so, we can unpause it.\n const existingAnimatable = this.runningAnimatable.getValue(context);\n if (existingAnimatable && existingAnimatable.paused) {\n existingAnimatable.restart();\n } else {\n const scene = context.configuration.scene;\n const animatable = scene.beginDirectAnimation(targetValue, [animationValue], this.from.getValue(context), this.to.getValue(context), this.loop.getValue(context), this.speed.getValue(context), () => this._onAnimationEnd(animatable, context));\n this.runningAnimatable.setValue(animatable, context);\n contextAnimatables.push(animatable);\n }\n context._setExecutionVariable(this, \"runningAnimatables\", contextAnimatables);\n }\n _execute(context) {\n this._startPendingTasks(context);\n this.out._activateSignal(context);\n }\n _onAnimationEnd(animatable, context) {\n var _context$_getExecutio2;\n const contextAnims = (_context$_getExecutio2 = context._getExecutionVariable(this, \"runningAnimatables\")) !== null && _context$_getExecutio2 !== void 0 ? _context$_getExecutio2 : [];\n const index = contextAnims.indexOf(animatable);\n if (index !== -1) {\n contextAnims.splice(index, 1);\n }\n context._removePendingBlock(this);\n this.done._activateSignal(context);\n }\n /**\n * @internal\n * Stop any currently running animations.\n */\n _cancelPendingTasks(context) {\n var _context$_getExecutio3;\n const contextAnims = (_context$_getExecutio3 = context._getExecutionVariable(this, \"runningAnimatables\")) !== null && _context$_getExecutio3 !== void 0 ? _context$_getExecutio3 : [];\n for (const anim of contextAnims) {\n anim.stop();\n }\n context._deleteExecutionVariable(this, \"runningAnimatables\");\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return FlowGraphPlayAnimationBlock.ClassName;\n }\n /**\n * Serializes the block to a JSON object.\n * @param serializationObject the object to serialize to.\n */\n serialize(serializationObject = {}) {\n super.serialize(serializationObject);\n serializationObject.config.targetPath = this.config.targetPath;\n serializationObject.config.animationPath = this.config.animationPath;\n }\n}\n/**\n * Class name of the block.\n */\nFlowGraphPlayAnimationBlock.ClassName = \"FGPlayAnimationBlock\";\nRegisterClass(FlowGraphPlayAnimationBlock.ClassName, FlowGraphPlayAnimationBlock);","map":{"version":3,"names":["FlowGraphAsyncExecutionBlock","RichTypeAny","RichTypeNumber","RichTypeBoolean","RegisterClass","FlowGraphPathConverterComponent","FlowGraphPlayAnimationBlock","constructor","config","templateTargetComponent","targetPath","templateAnimationComponent","animationPath","speed","registerDataInput","loop","from","to","runningAnimatable","registerDataOutput","_preparePendingTasks","context","_context$_getExecutio","targetAccessor","getAccessor","pathConverter","targetValue","info","getObject","object","animationAccessor","animationValue","get","Error","contextAnimatables","_getExecutionVariable","existingAnimatable","getValue","paused","restart","scene","configuration","animatable","beginDirectAnimation","_onAnimationEnd","setValue","push","_setExecutionVariable","_execute","_startPendingTasks","out","_activateSignal","_context$_getExecutio2","contextAnims","index","indexOf","splice","_removePendingBlock","done","_cancelPendingTasks","_context$_getExecutio3","anim","stop","_deleteExecutionVariable","getClassName","ClassName","serialize","serializationObject"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/FlowGraph/Blocks/Execution/Animation/flowGraphPlayAnimationBlock.js"],"sourcesContent":["import { FlowGraphAsyncExecutionBlock } from \"../../../flowGraphAsyncExecutionBlock.js\";\nimport { RichTypeAny, RichTypeNumber, RichTypeBoolean } from \"../../../flowGraphRichTypes.js\";\nimport { RegisterClass } from \"../../../../Misc/typeStore.js\";\nimport { FlowGraphPathConverterComponent } from \"../../../flowGraphPathConverterComponent.js\";\n/**\n * @experimental\n * A block that plays an animation on an animatable object.\n */\nexport class FlowGraphPlayAnimationBlock extends FlowGraphAsyncExecutionBlock {\n constructor(\n /**\n * the configuration of the block\n */\n config) {\n super(config);\n this.config = config;\n this.templateTargetComponent = new FlowGraphPathConverterComponent(config.targetPath, this);\n this.templateAnimationComponent = new FlowGraphPathConverterComponent(config.animationPath, this);\n this.speed = this.registerDataInput(\"speed\", RichTypeNumber);\n this.loop = this.registerDataInput(\"loop\", RichTypeBoolean);\n this.from = this.registerDataInput(\"from\", RichTypeNumber);\n this.to = this.registerDataInput(\"to\", RichTypeNumber);\n this.runningAnimatable = this.registerDataOutput(\"runningAnimatable\", RichTypeAny);\n }\n /**\n * @internal\n * @param context\n */\n _preparePendingTasks(context) {\n const targetAccessor = this.templateTargetComponent.getAccessor(this.config.pathConverter, context);\n const targetValue = targetAccessor.info.getObject(targetAccessor.object);\n const animationAccessor = this.templateAnimationComponent.getAccessor(this.config.pathConverter, context);\n const animationValue = animationAccessor.info.get(animationAccessor.object);\n if (!targetValue || !animationValue) {\n throw new Error(\"Cannot play animation without target or animation\");\n }\n const contextAnimatables = context._getExecutionVariable(this, \"runningAnimatables\") ?? [];\n // was an animation started on this target already and was just paused? if so, we can unpause it.\n const existingAnimatable = this.runningAnimatable.getValue(context);\n if (existingAnimatable && existingAnimatable.paused) {\n existingAnimatable.restart();\n }\n else {\n const scene = context.configuration.scene;\n const animatable = scene.beginDirectAnimation(targetValue, [animationValue], this.from.getValue(context), this.to.getValue(context), this.loop.getValue(context), this.speed.getValue(context), () => this._onAnimationEnd(animatable, context));\n this.runningAnimatable.setValue(animatable, context);\n contextAnimatables.push(animatable);\n }\n context._setExecutionVariable(this, \"runningAnimatables\", contextAnimatables);\n }\n _execute(context) {\n this._startPendingTasks(context);\n this.out._activateSignal(context);\n }\n _onAnimationEnd(animatable, context) {\n const contextAnims = context._getExecutionVariable(this, \"runningAnimatables\") ?? [];\n const index = contextAnims.indexOf(animatable);\n if (index !== -1) {\n contextAnims.splice(index, 1);\n }\n context._removePendingBlock(this);\n this.done._activateSignal(context);\n }\n /**\n * @internal\n * Stop any currently running animations.\n */\n _cancelPendingTasks(context) {\n const contextAnims = context._getExecutionVariable(this, \"runningAnimatables\") ?? [];\n for (const anim of contextAnims) {\n anim.stop();\n }\n context._deleteExecutionVariable(this, \"runningAnimatables\");\n }\n /**\n * @returns class name of the block.\n */\n getClassName() {\n return FlowGraphPlayAnimationBlock.ClassName;\n }\n /**\n * Serializes the block to a JSON object.\n * @param serializationObject the object to serialize to.\n */\n serialize(serializationObject = {}) {\n super.serialize(serializationObject);\n serializationObject.config.targetPath = this.config.targetPath;\n serializationObject.config.animationPath = this.config.animationPath;\n }\n}\n/**\n * Class name of the block.\n */\nFlowGraphPlayAnimationBlock.ClassName = \"FGPlayAnimationBlock\";\nRegisterClass(FlowGraphPlayAnimationBlock.ClassName, FlowGraphPlayAnimationB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