vertexAnimationBaker.d.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import type { AnimationRange } from "../Animations/animationRange";
  2. import { RawTexture } from "../Materials/Textures/rawTexture";
  3. import type { Mesh } from "../Meshes/mesh";
  4. import type { Scene } from "../scene";
  5. import { Skeleton } from "../Bones/skeleton.js";
  6. /**
  7. * Class to bake vertex animation textures.
  8. * @since 5.0
  9. */
  10. export declare class VertexAnimationBaker {
  11. private _scene;
  12. private _mesh;
  13. private _skeleton;
  14. /**
  15. * Create a new VertexAnimationBaker object which can help baking animations into a texture.
  16. * @param scene Defines the scene the VAT belongs to
  17. * @param meshOrSkeleton Defines the skeleton or the mesh from which to retrieve the skeleton from.
  18. */
  19. constructor(scene: Scene, meshOrSkeleton: Mesh | Skeleton);
  20. /**
  21. * Bakes the animation into the texture. This should be called once, when the
  22. * scene starts, so the VAT is generated and associated to the mesh.
  23. * @param ranges Defines the ranges in the animation that will be baked.
  24. * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.
  25. */
  26. bakeVertexData(ranges: AnimationRange[]): Promise<Float32Array>;
  27. /**
  28. * Runs an animation frame and stores its vertex data
  29. *
  30. * @param vertexData The array to save data to.
  31. * @param frameIndex Current frame in the skeleton animation to render.
  32. * @param textureIndex Current index of the texture data.
  33. */
  34. private _executeAnimationFrame;
  35. /**
  36. * Builds a vertex animation texture given the vertexData in an array.
  37. * @param vertexData The vertex animation data. You can generate it with bakeVertexData().
  38. * @returns The vertex animation texture to be used with BakedVertexAnimationManager.
  39. */
  40. textureFromBakedVertexData(vertexData: Float32Array): RawTexture;
  41. /**
  42. * Serializes our vertexData to an object, with a nice string for the vertexData.
  43. * @param vertexData The vertex array data.
  44. * @returns This object serialized to a JS dict.
  45. */
  46. serializeBakedVertexDataToObject(vertexData: Float32Array): Record<string, any>;
  47. /**
  48. * Loads previously baked data.
  49. * @param data The object as serialized by serializeBakedVertexDataToObject()
  50. * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.
  51. */
  52. loadBakedVertexDataFromObject(data: Record<string, any>): Float32Array;
  53. /**
  54. * Serializes our vertexData to a JSON string, with a nice string for the vertexData.
  55. * Should be called right after bakeVertexData().
  56. * @param vertexData The vertex array data.
  57. * @returns This object serialized to a safe string.
  58. */
  59. serializeBakedVertexDataToJSON(vertexData: Float32Array): string;
  60. /**
  61. * Loads previously baked data in string format.
  62. * @param json The json string as serialized by serializeBakedVertexDataToJSON().
  63. * @returns The array of matrix transforms for each vertex (columns) and frame (rows), as a Float32Array.
  64. */
  65. loadBakedVertexDataFromJSON(json: string): Float32Array;
  66. }