thinSprite.d.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import type { IVector3Like, IColor4Like } from "../Maths/math.like";
  2. import type { Nullable } from "../types";
  3. /**
  4. * ThinSprite Class used to represent a thin sprite
  5. * This is the base class for sprites but can also directly be used with ThinEngine
  6. * @see https://doc.babylonjs.com/features/featuresDeepDive/sprites
  7. */
  8. export declare class ThinSprite {
  9. /** Gets or sets the cell index in the sprite sheet */
  10. cellIndex: number;
  11. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12. cellRef: string;
  13. /** Gets or sets the current world position */
  14. position: IVector3Like;
  15. /** Gets or sets the main color */
  16. color: IColor4Like;
  17. /** Gets or sets the width */
  18. width: number;
  19. /** Gets or sets the height */
  20. height: number;
  21. /** Gets or sets rotation angle */
  22. angle: number;
  23. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  24. invertU: boolean;
  25. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  26. invertV: boolean;
  27. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  28. isVisible: boolean;
  29. /**
  30. * Returns a boolean indicating if the animation is started
  31. */
  32. get animationStarted(): boolean;
  33. /** Gets the initial key for the animation (setting it will restart the animation) */
  34. get fromIndex(): number;
  35. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  36. get toIndex(): number;
  37. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  38. get loopAnimation(): boolean;
  39. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  40. get delay(): number;
  41. /** @internal */
  42. _xOffset: number;
  43. /** @internal */
  44. _yOffset: number;
  45. /** @internal */
  46. _xSize: number;
  47. /** @internal */
  48. _ySize: number;
  49. private _animationStarted;
  50. protected _loopAnimation: boolean;
  51. protected _fromIndex: number;
  52. protected _toIndex: number;
  53. protected _delay: number;
  54. private _direction;
  55. private _time;
  56. private _onBaseAnimationEnd;
  57. /**
  58. * Creates a new Thin Sprite
  59. */
  60. constructor();
  61. /**
  62. * Starts an animation
  63. * @param from defines the initial key
  64. * @param to defines the end key
  65. * @param loop defines if the animation must loop
  66. * @param delay defines the start delay (in ms)
  67. * @param onAnimationEnd defines a callback for when the animation ends
  68. */
  69. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  70. /** Stops current animation (if any) */
  71. stopAnimation(): void;
  72. /**
  73. * @internal
  74. */
  75. _animate(deltaTime: number): void;
  76. }