1 |
- {"ast":null,"code":"import { Action } from \"./action.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { Observable } from \"../Misc/observable.js\";\nimport { Color3 } from \"../Maths/math.color.js\";\nimport { Vector3, Matrix, Quaternion } from \"../Maths/math.vector.js\";\nimport { Animation } from \"../Animations/animation.js\";\nimport { RegisterClass } from \"../Misc/typeStore.js\";\n/**\n * This defines an action responsible to change the value of a property\n * by interpolating between its current value and the newly set one once triggered.\n * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions\n */\nexport class InterpolateValueAction extends Action {\n /**\n * Instantiate the action\n * @param triggerOptions defines the trigger options\n * @param target defines the object containing the value to interpolate\n * @param propertyPath defines the path to the property in the target object\n * @param value defines the target value at the end of the interpolation\n * @param duration defines the time it will take for the property to interpolate to the value.\n * @param condition defines the trigger related conditions\n * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered\n * @param onInterpolationDone defines a callback raised once the interpolation animation has been done\n */\n constructor(triggerOptions, target, propertyPath, value, duration = 1000, condition, stopOtherAnimations, onInterpolationDone) {\n super(triggerOptions, condition);\n /**\n * Defines the time it will take for the property to interpolate to the value.\n */\n this.duration = 1000;\n /**\n * Observable triggered once the interpolation animation has been done.\n */\n this.onInterpolationDoneObservable = new Observable();\n this.propertyPath = propertyPath;\n this.value = value;\n this.duration = duration;\n this.stopOtherAnimations = stopOtherAnimations;\n this.onInterpolationDone = onInterpolationDone;\n this._target = this._effectiveTarget = target;\n }\n /** @internal */\n _prepare() {\n this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);\n this._property = this._getProperty(this.propertyPath);\n }\n /**\n * Execute the action starts the value interpolation.\n */\n execute() {\n const scene = this._actionManager.getScene();\n const keys = [{\n frame: 0,\n value: this._effectiveTarget[this._property]\n }, {\n frame: 100,\n value: this.value\n }];\n let dataType;\n if (typeof this.value === \"number\") {\n dataType = Animation.ANIMATIONTYPE_FLOAT;\n } else if (this.value instanceof Color3) {\n dataType = Animation.ANIMATIONTYPE_COLOR3;\n } else if (this.value instanceof Vector3) {\n dataType = Animation.ANIMATIONTYPE_VECTOR3;\n } else if (this.value instanceof Matrix) {\n dataType = Animation.ANIMATIONTYPE_MATRIX;\n } else if (this.value instanceof Quaternion) {\n dataType = Animation.ANIMATIONTYPE_QUATERNION;\n } else {\n Logger.Warn(\"InterpolateValueAction: Unsupported type (\" + typeof this.value + \")\");\n return;\n }\n const animation = new Animation(\"InterpolateValueAction\", this._property, 100 * (1000.0 / this.duration), dataType, Animation.ANIMATIONLOOPMODE_CONSTANT);\n animation.setKeys(keys);\n if (this.stopOtherAnimations) {\n scene.stopAnimation(this._effectiveTarget);\n }\n const wrapper = () => {\n this.onInterpolationDoneObservable.notifyObservers(this);\n if (this.onInterpolationDone) {\n this.onInterpolationDone();\n }\n };\n scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);\n }\n /**\n * Serializes the actions and its related information.\n * @param parent defines the object to serialize in\n * @returns the serialized object\n */\n serialize(parent) {\n return super._serialize({\n name: \"InterpolateValueAction\",\n properties: [Action._GetTargetProperty(this._target), {\n name: \"propertyPath\",\n value: this.propertyPath\n }, {\n name: \"value\",\n value: Action._SerializeValueAsString(this.value)\n }, {\n name: \"duration\",\n value: Action._SerializeValueAsString(this.duration)\n }, {\n name: \"stopOtherAnimations\",\n value: Action._SerializeValueAsString(this.stopOtherAnimations) || false\n }]\n }, parent);\n }\n}\nRegisterClass(\"BABYLON.InterpolateValueAction\", InterpolateValueAction);","map":{"version":3,"names":["Action","Logger","Observable","Color3","Vector3","Matrix","Quaternion","Animation","RegisterClass","InterpolateValueAction","constructor","triggerOptions","target","propertyPath","value","duration","condition","stopOtherAnimations","onInterpolationDone","onInterpolationDoneObservable","_target","_effectiveTarget","_prepare","_getEffectiveTarget","_property","_getProperty","execute","scene","_actionManager","getScene","keys","frame","dataType","ANIMATIONTYPE_FLOAT","ANIMATIONTYPE_COLOR3","ANIMATIONTYPE_VECTOR3","ANIMATIONTYPE_MATRIX","ANIMATIONTYPE_QUATERNION","Warn","animation","ANIMATIONLOOPMODE_CONSTANT","setKeys","stopAnimation","wrapper","notifyObservers","beginDirectAnimation","serialize","parent","_serialize","name","properties","_GetTargetProperty","_SerializeValueAsString"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Actions/interpolateValueAction.js"],"sourcesContent":["import { Action } from \"./action.js\";\nimport { Logger } from \"../Misc/logger.js\";\nimport { Observable } from \"../Misc/observable.js\";\nimport { Color3 } from \"../Maths/math.color.js\";\nimport { Vector3, Matrix, Quaternion } from \"../Maths/math.vector.js\";\nimport { Animation } from \"../Animations/animation.js\";\nimport { RegisterClass } from \"../Misc/typeStore.js\";\n/**\n * This defines an action responsible to change the value of a property\n * by interpolating between its current value and the newly set one once triggered.\n * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions\n */\nexport class InterpolateValueAction extends Action {\n /**\n * Instantiate the action\n * @param triggerOptions defines the trigger options\n * @param target defines the object containing the value to interpolate\n * @param propertyPath defines the path to the property in the target object\n * @param value defines the target value at the end of the interpolation\n * @param duration defines the time it will take for the property to interpolate to the value.\n * @param condition defines the trigger related conditions\n * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered\n * @param onInterpolationDone defines a callback raised once the interpolation animation has been done\n */\n constructor(triggerOptions, target, propertyPath, value, duration = 1000, condition, stopOtherAnimations, onInterpolationDone) {\n super(triggerOptions, condition);\n /**\n * Defines the time it will take for the property to interpolate to the value.\n */\n this.duration = 1000;\n /**\n * Observable triggered once the interpolation animation has been done.\n */\n this.onInterpolationDoneObservable = new Observable();\n this.propertyPath = propertyPath;\n this.value = value;\n this.duration = duration;\n this.stopOtherAnimations = stopOtherAnimations;\n this.onInterpolationDone = onInterpolationDone;\n this._target = this._effectiveTarget = target;\n }\n /** @internal */\n _prepare() {\n this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);\n this._property = this._getProperty(this.propertyPath);\n }\n /**\n * Execute the action starts the value interpolation.\n */\n execute() {\n const scene = this._actionManager.getScene();\n const keys = [\n {\n frame: 0,\n value: this._effectiveTarget[this._property],\n },\n {\n frame: 100,\n value: this.value,\n },\n ];\n let dataType;\n if (typeof this.value === \"number\") {\n dataType = Animation.ANIMATIONTYPE_FLOAT;\n }\n else if (this.value instanceof Color3) {\n dataType = Animation.ANIMATIONTYPE_COLOR3;\n }\n else if (this.value instanceof Vector3) {\n dataType = Animation.ANIMATIONTYPE_VECTOR3;\n }\n else if (this.value instanceof Matrix) {\n dataType = Animation.ANIMATIONTYPE_MATRIX;\n }\n else if (this.value instanceof Quaternion) {\n dataType = Animation.ANIMATIONTYPE_QUATERNION;\n }\n else {\n Logger.Warn(\"InterpolateValueAction: Unsupported type (\" + typeof this.value + \")\");\n return;\n }\n const animation = new Animation(\"InterpolateValueAction\", this._property, 100 * (1000.0 / this.duration), dataType, Animation.ANIMATIONLOOPMODE_CONSTANT);\n animation.setKeys(keys);\n if (this.stopOtherAnimations) {\n scene.stopAnimation(this._effectiveTarget);\n }\n const wrapper = () => {\n this.onInterpolationDoneObservable.notifyObservers(this);\n if (this.onInterpolationDone) {\n this.onInterpolationDone();\n }\n };\n scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);\n }\n /**\n * Serializes the actions and its related information.\n * @param parent defines the object to serialize in\n * @returns the serialized object\n */\n serialize(parent) {\n return super._serialize({\n name: \"InterpolateValueAction\",\n properties: [\n Action._GetTargetProperty(this._target),\n { name: \"propertyPath\", value: this.propertyPath },\n { name: \"value\", value: Action._SerializeValueAsString(this.value) },\n { name: \"duration\", value: Action._SerializeValueAsString(this.duration) },\n { name: \"stopOtherAnimations\", value: Action._SerializeValueAsString(this.stopOtherAnimations) || false },\n ],\n }, parent);\n }\n}\nRegisterClass(\"BABYLON.InterpolateValueAction\", InterpolateValueAction);\n"],"mappings":"AAAA,SAASA,MAAM,QAAQ,aAAa;AACpC,SAASC,MAAM,QAAQ,mBAAmB;AAC1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