1 |
- {"ast":null,"code":"import { __decorate } from \"../tslib.es6.js\";\nimport { serialize, expandToProperty, serializeAsTexture } from \"../Misc/decorators.js\";\nimport { Vector4 } from \"../Maths/math.vector.js\";\nimport { EngineStore } from \"../Engines/engineStore.js\";\nimport { SerializationHelper } from \"../Misc/decorators.serialization.js\";\n/**\n * This class is used to animate meshes using a baked vertex animation texture\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/baked_texture_animations\n * @since 5.0\n */\nexport class BakedVertexAnimationManager {\n /**\n * Creates a new BakedVertexAnimationManager\n * @param scene defines the current scene\n */\n constructor(scene) {\n this._texture = null;\n this._isEnabled = true;\n /**\n * Enable or disable the vertex animation manager\n */\n this.isEnabled = true;\n /**\n * The time counter, to pick the correct animation frame.\n */\n this.time = 0;\n scene = scene || EngineStore.LastCreatedScene;\n if (!scene) {\n return;\n }\n this._scene = scene;\n this.animationParameters = new Vector4(0, 0, 0, 30);\n }\n /** @internal */\n _markSubMeshesAsAttributesDirty() {\n for (const mesh of this._scene.meshes) {\n if (mesh.bakedVertexAnimationManager === this) {\n mesh._markSubMeshesAsAttributesDirty();\n }\n }\n }\n /**\n * Binds to the effect.\n * @param effect The effect to bind to.\n * @param useInstances True when it's an instance.\n */\n bind(effect, useInstances = false) {\n if (!this._texture || !this._isEnabled) {\n return;\n }\n const size = this._texture.getSize();\n effect.setFloat2(\"bakedVertexAnimationTextureSizeInverted\", 1.0 / size.width, 1.0 / size.height);\n effect.setFloat(\"bakedVertexAnimationTime\", this.time);\n if (!useInstances) {\n effect.setVector4(\"bakedVertexAnimationSettings\", this.animationParameters);\n }\n effect.setTexture(\"bakedVertexAnimationTexture\", this._texture);\n }\n /**\n * Clone the current manager\n * @returns a new BakedVertexAnimationManager\n */\n clone() {\n const copy = new BakedVertexAnimationManager(this._scene);\n this.copyTo(copy);\n return copy;\n }\n /**\n * Sets animation parameters.\n * @param startFrame The first frame of the animation.\n * @param endFrame The last frame of the animation.\n * @param offset The offset when starting the animation.\n * @param speedFramesPerSecond The frame rate.\n */\n setAnimationParameters(startFrame, endFrame, offset = 0, speedFramesPerSecond = 30) {\n this.animationParameters = new Vector4(startFrame, endFrame, offset, speedFramesPerSecond);\n }\n /**\n * Disposes the resources of the manager.\n * @param forceDisposeTextures - Forces the disposal of all textures.\n */\n dispose(forceDisposeTextures) {\n if (forceDisposeTextures) {\n var _this$_texture;\n (_this$_texture = this._texture) === null || _this$_texture === void 0 || _this$_texture.dispose();\n }\n }\n /**\n * Get the current class name useful for serialization or dynamic coding.\n * @returns \"BakedVertexAnimationManager\"\n */\n getClassName() {\n return \"BakedVertexAnimationManager\";\n }\n /**\n * Makes a duplicate of the current instance into another one.\n * @param vatMap define the instance where to copy the info\n */\n copyTo(vatMap) {\n SerializationHelper.Clone(() => vatMap, this);\n }\n /**\n * Serializes this vertex animation instance\n * @returns - An object with the serialized instance.\n */\n serialize() {\n return SerializationHelper.Serialize(this);\n }\n /**\n * Parses a vertex animation setting from a serialized object.\n * @param source - Serialized object.\n * @param scene Defines the scene we are parsing for\n * @param rootUrl Defines the rootUrl to load from\n */\n parse(source, scene, rootUrl) {\n SerializationHelper.Parse(() => this, source, scene, rootUrl);\n }\n}\n__decorate([serializeAsTexture(), expandToProperty(\"_markSubMeshesAsAttributesDirty\")], BakedVertexAnimationManager.prototype, \"texture\", void 0);\n__decorate([serialize(), expandToProperty(\"_markSubMeshesAsAttributesDirty\")], BakedVertexAnimationManager.prototype, \"isEnabled\", void 0);\n__decorate([serialize()], BakedVertexAnimationManager.prototype, \"animationParameters\", void 0);\n__decorate([serialize()], BakedVertexAnimationManager.prototype, \"time\", void 0);","map":{"version":3,"names":["__decorate","serialize","expandToProperty","serializeAsTexture","Vector4","EngineStore","SerializationHelper","BakedVertexAnimationManager","constructor","scene","_texture","_isEnabled","isEnabled","time","LastCreatedScene","_scene","animationParameters","_markSubMeshesAsAttributesDirty","mesh","meshes","bakedVertexAnimationManager","bind","effect","useInstances","size","getSize","setFloat2","width","height","setFloat","setVector4","setTexture","clone","copy","copyTo","setAnimationParameters","startFrame","endFrame","offset","speedFramesPerSecond","dispose","forceDisposeTextures","_this$_texture","getClassName","vatMap","Clone","Serialize","parse","source","rootUrl","Parse","prototype"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/BakedVertexAnimation/bakedVertexAnimationManager.js"],"sourcesContent":["import { __decorate } from \"../tslib.es6.js\";\nimport { serialize, expandToProperty, serializeAsTexture } from \"../Misc/decorators.js\";\nimport { Vector4 } from \"../Maths/math.vector.js\";\nimport { EngineStore } from \"../Engines/engineStore.js\";\nimport { SerializationHelper } from \"../Misc/decorators.serialization.js\";\n/**\n * This class is used to animate meshes using a baked vertex animation texture\n * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/baked_texture_animations\n * @since 5.0\n */\nexport class BakedVertexAnimationManager {\n /**\n * Creates a new BakedVertexAnimationManager\n * @param scene defines the current scene\n */\n constructor(scene) {\n this._texture = null;\n this._isEnabled = true;\n /**\n * Enable or disable the vertex animation manager\n */\n this.isEnabled = true;\n /**\n * The time counter, to pick the correct animation frame.\n */\n this.time = 0;\n scene = scene || EngineStore.LastCreatedScene;\n if (!scene) {\n return;\n }\n this._scene = scene;\n this.animationParameters = new Vector4(0, 0, 0, 30);\n }\n /** @internal */\n _markSubMeshesAsAttributesDirty() {\n for (const mesh of this._scene.meshes) {\n if (mesh.bakedVertexAnimationManager === this) {\n mesh._markSubMeshesAsAttributesDirty();\n }\n }\n }\n /**\n * Binds to the effect.\n * @param effect The effect to bind to.\n * @param useInstances True when it's an instance.\n */\n bind(effect, useInstances = false) {\n if (!this._texture || !this._isEnabled) {\n return;\n }\n const size = this._texture.getSize();\n effect.setFloat2(\"bakedVertexAnimationTextureSizeInverted\", 1.0 / size.width, 1.0 / size.height);\n effect.setFloat(\"bakedVertexAnimationTime\", this.time);\n if (!useInstances) {\n effect.setVector4(\"bakedVertexAnimationSettings\", this.animationParameters);\n }\n effect.setTexture(\"bakedVertexAnimationTexture\", this._texture);\n }\n /**\n * Clone the current manager\n * @returns a new BakedVertexAnimationManager\n */\n clone() {\n const copy = new BakedVertexAnimationManager(this._scene);\n this.copyTo(copy);\n return copy;\n }\n /**\n * Sets animation parameters.\n * @param startFrame The first frame of the animation.\n * @param endFrame The last frame of the animation.\n * @param offset The offset when starting the animation.\n * @param speedFramesPerSecond The frame rate.\n */\n setAnimationParameters(startFrame, endFrame, offset = 0, speedFramesPerSecond = 30) {\n this.animationParameters = new Vector4(startFrame, endFrame, offset, speedFramesPerSecond);\n }\n /**\n * Disposes the resources of the manager.\n * @param forceDisposeTextures - Forces the disposal of all textures.\n */\n dispose(forceDisposeTextures) {\n if (forceDisposeTextures) {\n this._texture?.dispose();\n }\n }\n /**\n * Get the current class name useful for serialization or dynamic coding.\n * @returns \"BakedVertexAnimationManager\"\n */\n getClassName() {\n return \"BakedVertexAnimationManager\";\n }\n /**\n * Makes a duplicate of the current instance into another one.\n * @param vatMap define the instance where to copy the info\n */\n copyTo(vatMap) {\n SerializationHelper.Clone(() => vatMap, this);\n }\n /**\n * Serializes this vertex animation instance\n * @returns - An object with the serialized instance.\n */\n serialize() {\n return SerializationHelper.Serialize(this);\n }\n /**\n * Parses a vertex animation setting from a serialized object.\n * @param source - Serialized object.\n * @param scene Defines the scene we are parsing for\n * @param rootUrl Defines the rootUrl to load from\n */\n parse(source, scene, rootUrl) {\n SerializationHelper.Parse(() => this, source, scene, rootUrl);\n }\n}\n__decorate([\n serializeAsTexture(),\n expandToProperty(\"_markSubMeshesAsAttributesDirty\")\n], BakedVertexAnimationManager.prototype, \"texture\", void 0);\n__decorate([\n serialize(),\n expandToProperty(\"_markSubMeshesAsAttributesDirty\")\n], BakedVertexAnimationManager.prototype, \"isEnabled\", void 0);\n__decorate([\n serialize()\n], BakedVertexAnimationManager.prototype, \"animationParameters\", void 0);\n__decorate([\n serialize()\n], BakedVertexAnimationManager.prototype, \"time\", void 0);\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,iBAAiB;AA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