babylon.glTFSerializer.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. /// <reference path="../../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON {
  3. export class GLTF2Export {
  4. /**
  5. * Exports the geometry of a Mesh array in .gltf file format.
  6. * If glb is set to true, exports as .glb.
  7. * @param meshes
  8. * @param materials
  9. *
  10. * @returns {[fileName: string]: string | Blob} Returns an object with a .gltf, .glb and associates textures
  11. * as keys and their data and paths as values.
  12. */
  13. public static GLTF(scene: BABYLON.Scene, filename: string): _GLTFData {
  14. let glTFPrefix = filename.replace(/\.[^/.]+$/, "");
  15. let gltfGenerator = new _GLTF2Exporter(scene);
  16. return gltfGenerator._generateGLTF(glTFPrefix);
  17. }
  18. /**
  19. *
  20. * @param meshes
  21. * @param filename
  22. *
  23. * @returns {[fileName: string]: string | Blob} Returns an object with a .glb filename as key and data as value
  24. */
  25. public static GLB(scene: BABYLON.Scene, filename: string): _GLTFData {
  26. let glTFPrefix = filename.replace(/\.[^/.]+$/, "");
  27. let gltfGenerator = new _GLTF2Exporter(scene);
  28. return gltfGenerator._generateGLB(glTFPrefix);
  29. }
  30. }
  31. }