fcf8351f5ad2162ad78e61efadcdf29c11e5af0c28ab523d53cbd1a52a274a8b.json 11 KB

1
  1. {"ast":null,"code":"/**\n * ThinSprite Class used to represent a thin sprite\n * This is the base class for sprites but can also directly be used with ThinEngine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/sprites\n */\nexport class ThinSprite {\n /**\n * Returns a boolean indicating if the animation is started\n */\n get animationStarted() {\n return this._animationStarted;\n }\n /** Gets the initial key for the animation (setting it will restart the animation) */\n get fromIndex() {\n return this._fromIndex;\n }\n /** Gets or sets the end key for the animation (setting it will restart the animation) */\n get toIndex() {\n return this._toIndex;\n }\n /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */\n get loopAnimation() {\n return this._loopAnimation;\n }\n /** Gets or sets the delay between cell changes (setting it will restart the animation) */\n get delay() {\n return Math.max(this._delay, 1);\n }\n /**\n * Creates a new Thin Sprite\n */\n constructor() {\n /** Gets or sets the width */\n this.width = 1.0;\n /** Gets or sets the height */\n this.height = 1.0;\n /** Gets or sets rotation angle */\n this.angle = 0;\n /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */\n this.invertU = false;\n /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */\n this.invertV = false;\n /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */\n this.isVisible = true;\n this._animationStarted = false;\n this._loopAnimation = false;\n this._fromIndex = 0;\n this._toIndex = 0;\n this._delay = 0;\n this._direction = 1;\n this._time = 0;\n this._onBaseAnimationEnd = null;\n this.position = {\n x: 1.0,\n y: 1.0,\n z: 1.0\n };\n this.color = {\n r: 1.0,\n g: 1.0,\n b: 1.0,\n a: 1.0\n };\n }\n /**\n * Starts an animation\n * @param from defines the initial key\n * @param to defines the end key\n * @param loop defines if the animation must loop\n * @param delay defines the start delay (in ms)\n * @param onAnimationEnd defines a callback for when the animation ends\n */\n playAnimation(from, to, loop, delay, onAnimationEnd) {\n this._fromIndex = from;\n this._toIndex = to;\n this._loopAnimation = loop;\n this._delay = delay || 1;\n this._animationStarted = true;\n this._onBaseAnimationEnd = onAnimationEnd;\n if (from < to) {\n this._direction = 1;\n } else {\n this._direction = -1;\n this._toIndex = from;\n this._fromIndex = to;\n }\n this.cellIndex = from;\n this._time = 0;\n }\n /** Stops current animation (if any) */\n stopAnimation() {\n this._animationStarted = false;\n }\n /**\n * @internal\n */\n _animate(deltaTime) {\n if (!this._animationStarted) {\n return;\n }\n this._time += deltaTime;\n if (this._time > this._delay) {\n this._time = this._time % this._delay;\n this.cellIndex += this._direction;\n if (this._direction > 0 && this.cellIndex > this._toIndex || this._direction < 0 && this.cellIndex < this._fromIndex) {\n if (this._loopAnimation) {\n this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex;\n } else {\n this.cellIndex = this._toIndex;\n this._animationStarted = false;\n if (this._onBaseAnimationEnd) {\n this._onBaseAnimationEnd();\n }\n }\n }\n }\n }\n}","map":{"version":3,"names":["ThinSprite","animationStarted","_animationStarted","fromIndex","_fromIndex","toIndex","_toIndex","loopAnimation","_loopAnimation","delay","Math","max","_delay","constructor","width","height","angle","invertU","invertV","isVisible","_direction","_time","_onBaseAnimationEnd","position","x","y","z","color","r","g","b","a","playAnimation","from","to","loop","onAnimationEnd","cellIndex","stopAnimation","_animate","deltaTime"],"sources":["F:/workspace/202226701027/huinongbao-app/node_modules/@babylonjs/core/Sprites/thinSprite.js"],"sourcesContent":["/**\n * ThinSprite Class used to represent a thin sprite\n * This is the base class for sprites but can also directly be used with ThinEngine\n * @see https://doc.babylonjs.com/features/featuresDeepDive/sprites\n */\nexport class ThinSprite {\n /**\n * Returns a boolean indicating if the animation is started\n */\n get animationStarted() {\n return this._animationStarted;\n }\n /** Gets the initial key for the animation (setting it will restart the animation) */\n get fromIndex() {\n return this._fromIndex;\n }\n /** Gets or sets the end key for the animation (setting it will restart the animation) */\n get toIndex() {\n return this._toIndex;\n }\n /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */\n get loopAnimation() {\n return this._loopAnimation;\n }\n /** Gets or sets the delay between cell changes (setting it will restart the animation) */\n get delay() {\n return Math.max(this._delay, 1);\n }\n /**\n * Creates a new Thin Sprite\n */\n constructor() {\n /** Gets or sets the width */\n this.width = 1.0;\n /** Gets or sets the height */\n this.height = 1.0;\n /** Gets or sets rotation angle */\n this.angle = 0;\n /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */\n this.invertU = false;\n /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */\n this.invertV = false;\n /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */\n this.isVisible = true;\n this._animationStarted = false;\n this._loopAnimation = false;\n this._fromIndex = 0;\n this._toIndex = 0;\n this._delay = 0;\n this._direction = 1;\n this._time = 0;\n this._onBaseAnimationEnd = null;\n this.position = { x: 1.0, y: 1.0, z: 1.0 };\n this.color = { r: 1.0, g: 1.0, b: 1.0, a: 1.0 };\n }\n /**\n * Starts an animation\n * @param from defines the initial key\n * @param to defines the end key\n * @param loop defines if the animation must loop\n * @param delay defines the start delay (in ms)\n * @param onAnimationEnd defines a callback for when the animation ends\n */\n playAnimation(from, to, loop, delay, onAnimationEnd) {\n this._fromIndex = from;\n this._toIndex = to;\n this._loopAnimation = loop;\n this._delay = delay || 1;\n this._animationStarted = true;\n this._onBaseAnimationEnd = onAnimationEnd;\n if (from < to) {\n this._direction = 1;\n }\n else {\n this._direction = -1;\n this._toIndex = from;\n this._fromIndex = to;\n }\n this.cellIndex = from;\n this._time = 0;\n }\n /** Stops current animation (if any) */\n stopAnimation() {\n this._animationStarted = false;\n }\n /**\n * @internal\n */\n _animate(deltaTime) {\n if (!this._animationStarted) {\n return;\n }\n this._time += deltaTime;\n if (this._time > this._delay) {\n this._time = this._time % this._delay;\n this.cellIndex += this._direction;\n if ((this._direction > 0 && this.cellIndex > this._toIndex) || (this._direction < 0 && this.cellIndex < this._fromIndex)) {\n if (this._loopAnimation) {\n this.cellIndex = this._direction > 0 ? this._fromIndex : this._toIndex;\n }\n else {\n this.cellIndex = this._toIndex;\n this._animationStarted = false;\n if (this._onBaseAnimationEnd) {\n this._onBaseAnimationEnd();\n }\n }\n }\n }\n }\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,UAAU,CAAC;EACpB;AACJ;AACA;EACI,IAAIC,gBAAgBA,CAAA,EAAG;IACnB,OAAO,IAAI,CAACC,iBAAiB;EACjC;EACA;EACA,IAAIC,SAASA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACC,UAAU;EAC1B;EACA;EACA,IAAIC,OAAOA,CAAA,EAAG;IACV,OAAO,IAAI,CAACC,QAAQ;EACxB;EACA;EACA,IAAIC,aAAaA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACC,cAAc;EAC9B;EACA;EACA,IAAIC,KAAKA,CAAA,EAAG;IACR,OAAOC,IAAI,CAACC,GAAG,CAAC,IAAI,CAACC,MAAM,EAAE,CAAC,CAAC;EACnC;EACA;AACJ;AACA;EACIC,WAAWA,CAAA,EAAG;IACV;IACA,IAAI,CAACC,KAAK,GAAG,GAAG;IAChB;IACA,IAAI,CAACC,MAAM,GAAG,GAAG;IACjB;IACA,IAAI,CAACC,KAAK,GAAG,CAAC;IACd;IACA,IAAI,CAACC,OAAO,GAAG,KAAK;IACpB;IACA,IAAI,CAACC,OAAO,GAAG,KAAK;IACpB;IACA,IAAI,CAACC,SAAS,GAAG,IAAI;IACrB,IAAI,CAACjB,iBAAiB,GAAG,KAAK;IAC9B,IAAI,CAACM,cAAc,GAAG,KAAK;IAC3B,IAAI,CAACJ,UAAU,GAAG,CAAC;IACnB,IAAI,CAACE,QAAQ,GAAG,CAAC;IACjB,IAAI,CAACM,MAAM,GAAG,CAAC;IACf,IAAI,CAACQ,UAAU,GAAG,CAAC;IACnB,IAAI,CAACC,KAAK,GAAG,CAAC;IACd,IAAI,CAACC,mBAAmB,GAAG,IAAI;IAC/B,IAAI,CAACC,QAAQ,GAAG;MAAEC,CAAC,EAAE,GAAG;MAAEC,CAAC,EAA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