babylonjs.serializers.module.d.ts 58 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  1. /*BabylonJS serializers*/
  2. // Dependencies for this module:
  3. // ../../../../Tools/Gulp/babylonjs
  4. // ../../../../Tools/Gulp/babylonjs-gltf2interface
  5. declare module 'babylonjs-serializers' {
  6. export * from "babylonjs-serializers/src/OBJ";
  7. export * from "babylonjs-serializers/src/glTF";
  8. }
  9. declare module 'babylonjs-serializers/src/OBJ' {
  10. export * from "babylonjs-serializers/src/OBJ/objSerializer";
  11. }
  12. declare module 'babylonjs-serializers/src/glTF' {
  13. export * from "babylonjs-serializers/src/glTF/glTFFileExporter";
  14. export * from "babylonjs-serializers/src/glTF/2.0";
  15. }
  16. declare module 'babylonjs-serializers/src/OBJ/objSerializer' {
  17. import { Mesh } from "babylonjs";
  18. export class OBJExport {
  19. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  20. static MTL(mesh: Mesh): string;
  21. }
  22. }
  23. declare module 'babylonjs-serializers/src/glTF/glTFFileExporter' {
  24. /** @hidden */
  25. export var __IGLTFExporterExtension: number;
  26. /**
  27. * Interface for extending the exporter
  28. * @hidden
  29. */
  30. export interface IGLTFExporterExtension {
  31. /**
  32. * The name of this extension
  33. */
  34. readonly name: string;
  35. /**
  36. * Defines whether this extension is enabled
  37. */
  38. enabled: boolean;
  39. /**
  40. * Defines whether this extension is required
  41. */
  42. required: boolean;
  43. }
  44. }
  45. declare module 'babylonjs-serializers/src/glTF/2.0' {
  46. export * from "babylonjs-serializers/src/glTF/2.0/glTFAnimation";
  47. export * from "babylonjs-serializers/src/glTF/2.0/glTFData";
  48. export * from "babylonjs-serializers/src/glTF/2.0/glTFExporter";
  49. export * from "babylonjs-serializers/src/glTF/2.0/glTFExporterExtension";
  50. export * from "babylonjs-serializers/src/glTF/2.0/glTFMaterialExporter";
  51. export * from "babylonjs-serializers/src/glTF/2.0/glTFSerializer";
  52. export * from "babylonjs-serializers/src/glTF/2.0/glTFUtilities";
  53. }
  54. declare module 'babylonjs-serializers/src/glTF/2.0/glTFAnimation' {
  55. import { Animation, TransformNode, Nullable, Scene } from "babylonjs";
  56. import { AnimationSamplerInterpolation, AnimationChannelTargetPath, AccessorType, IAnimation, INode, IBufferView, IAccessor } from "babylonjs-gltf2interface";
  57. import { _BinaryWriter } from "babylonjs-serializers/src/glTF/2.0/glTFExporter";
  58. /**
  59. * @hidden
  60. * Interface to store animation data.
  61. */
  62. export interface _IAnimationData {
  63. /**
  64. * Keyframe data.
  65. */
  66. inputs: number[];
  67. /**
  68. * Value data.
  69. */
  70. outputs: number[][];
  71. /**
  72. * Animation interpolation data.
  73. */
  74. samplerInterpolation: AnimationSamplerInterpolation;
  75. /**
  76. * Minimum keyframe value.
  77. */
  78. inputsMin: number;
  79. /**
  80. * Maximum keyframe value.
  81. */
  82. inputsMax: number;
  83. }
  84. /**
  85. * @hidden
  86. */
  87. export interface _IAnimationInfo {
  88. /**
  89. * The target channel for the animation
  90. */
  91. animationChannelTargetPath: AnimationChannelTargetPath;
  92. /**
  93. * The glTF accessor type for the data.
  94. */
  95. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  96. /**
  97. * Specifies if quaternions should be used.
  98. */
  99. useQuaternion: boolean;
  100. }
  101. /**
  102. * @hidden
  103. * Utility class for generating glTF animation data from BabylonJS.
  104. */
  105. export class _GLTFAnimation {
  106. /**
  107. * @ignore
  108. *
  109. * Creates glTF channel animation from BabylonJS animation.
  110. * @param babylonTransformNode - BabylonJS mesh.
  111. * @param animation - animation.
  112. * @param animationChannelTargetPath - The target animation channel.
  113. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  114. * @param useQuaternion - Specifies if quaternions are used.
  115. * @returns nullable IAnimationData
  116. */
  117. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  118. /**
  119. * @ignore
  120. * Create node animations from the transform node animations
  121. * @param babylonTransformNode
  122. * @param runtimeGLTFAnimation
  123. * @param idleGLTFAnimations
  124. * @param nodeMap
  125. * @param nodes
  126. * @param binaryWriter
  127. * @param bufferViews
  128. * @param accessors
  129. * @param convertToRightHandedSystem
  130. */
  131. static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: TransformNode, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  132. [key: number]: number;
  133. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  134. /**
  135. * @ignore
  136. * Create node animations from the animation groups
  137. * @param babylonScene
  138. * @param glTFAnimations
  139. * @param nodeMap
  140. * @param nodes
  141. * @param binaryWriter
  142. * @param bufferViews
  143. * @param accessors
  144. * @param convertToRightHandedSystem
  145. */
  146. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  147. [key: number]: number;
  148. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  149. }
  150. }
  151. declare module 'babylonjs-serializers/src/glTF/2.0/glTFData' {
  152. /**
  153. * Class for holding and downloading glTF file data
  154. */
  155. export class GLTFData {
  156. /**
  157. * Object which contains the file name as the key and its data as the value
  158. */
  159. glTFFiles: {
  160. [fileName: string]: string | Blob;
  161. };
  162. /**
  163. * Initializes the glTF file object
  164. */
  165. constructor();
  166. /**
  167. * Downloads the glTF data as files based on their names and data
  168. */
  169. downloadFiles(): void;
  170. }
  171. }
  172. declare module 'babylonjs-serializers/src/glTF/2.0/glTFExporter' {
  173. import { Scene, Engine, Nullable, Texture, BaseTexture, SubMesh, FloatArray, Vector3, Vector4 } from "babylonjs";
  174. import { IBufferView, IAccessor, IMaterial, ITexture, IImage, ISampler, ImageMimeType, IMeshPrimitive } from "babylonjs-gltf2interface";
  175. import { IGLTFExporterExtensionV2 } from "babylonjs-serializers/src/glTF/2.0/glTFExporterExtension";
  176. import { _GLTFMaterialExporter } from "babylonjs-serializers/src/glTF/2.0/glTFMaterialExporter";
  177. import { IExportOptions } from "babylonjs-serializers/src/glTF/2.0/glTFSerializer";
  178. import { GLTFData } from "babylonjs-serializers/src/glTF/2.0/glTFData";
  179. /**
  180. * Converts Babylon Scene into glTF 2.0.
  181. * @hidden
  182. */
  183. export class _Exporter {
  184. /**
  185. * Stores all generated buffer views, which represents views into the main glTF buffer data
  186. */
  187. _bufferViews: IBufferView[];
  188. /**
  189. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  190. */
  191. _accessors: IAccessor[];
  192. /**
  193. * Stores all the generated material information, which represents the appearance of each primitive
  194. */
  195. _materials: IMaterial[];
  196. _materialMap: {
  197. [materialID: number]: number;
  198. };
  199. /**
  200. * Stores all the generated texture information, which is referenced by glTF materials
  201. */
  202. _textures: ITexture[];
  203. /**
  204. * Stores all the generated image information, which is referenced by glTF textures
  205. */
  206. _images: IImage[];
  207. /**
  208. * Stores all the texture samplers
  209. */
  210. _samplers: ISampler[];
  211. /**
  212. * Stores a map of the image data, where the key is the file name and the value
  213. * is the image data
  214. */
  215. _imageData: {
  216. [fileName: string]: {
  217. data: Uint8Array;
  218. mimeType: ImageMimeType;
  219. };
  220. };
  221. _glTFMaterialExporter: _GLTFMaterialExporter;
  222. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>;
  223. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  224. /**
  225. * Creates a glTF Exporter instance, which can accept optional exporter options
  226. * @param babylonScene Babylon scene object
  227. * @param options Options to modify the behavior of the exporter
  228. */
  229. constructor(babylonScene: Scene, options?: IExportOptions);
  230. /**
  231. * Registers a glTF exporter extension
  232. * @param name Name of the extension to export
  233. * @param factory The factory function that creates the exporter extension
  234. */
  235. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  236. /**
  237. * Un-registers an exporter extension
  238. * @param name The name fo the exporter extension
  239. * @returns A boolean indicating whether the extension has been un-registered
  240. */
  241. static UnregisterExtension(name: string): boolean;
  242. /**
  243. * Lazy load a local engine with premultiplied alpha set to false
  244. */
  245. _getLocalEngine(): Engine;
  246. /**
  247. * Writes mesh attribute data to a data buffer
  248. * Returns the bytelength of the data
  249. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  250. * @param meshAttributeArray Array containing the attribute data
  251. * @param binaryWriter The buffer to write the binary data to
  252. * @param indices Used to specify the order of the vertex data
  253. */
  254. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  255. /**
  256. * Generates data for .gltf and .bin files based on the glTF prefix string
  257. * @param glTFPrefix Text to use when prefixing a glTF file
  258. * @returns GLTFData with glTF file data
  259. */
  260. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  261. /**
  262. * Generates a glb file from the json and binary data
  263. * Returns an object with the glb file name as the key and data as the value
  264. * @param glTFPrefix
  265. * @returns object with glb filename as key and data as value
  266. */
  267. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  268. }
  269. /**
  270. * @hidden
  271. *
  272. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  273. */
  274. export class _BinaryWriter {
  275. /**
  276. * Initialize binary writer with an initial byte length
  277. * @param byteLength Initial byte length of the array buffer
  278. */
  279. constructor(byteLength: number);
  280. /**
  281. * Get an array buffer with the length of the byte offset
  282. * @returns ArrayBuffer resized to the byte offset
  283. */
  284. getArrayBuffer(): ArrayBuffer;
  285. /**
  286. * Get the byte offset of the array buffer
  287. * @returns byte offset
  288. */
  289. getByteOffset(): number;
  290. /**
  291. * Stores an UInt8 in the array buffer
  292. * @param entry
  293. * @param byteOffset If defined, specifies where to set the value as an offset.
  294. */
  295. setUInt8(entry: number, byteOffset?: number): void;
  296. /**
  297. * Gets an UInt32 in the array buffer
  298. * @param entry
  299. * @param byteOffset If defined, specifies where to set the value as an offset.
  300. */
  301. getUInt32(byteOffset: number): number;
  302. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  303. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  304. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  305. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  306. /**
  307. * Stores a Float32 in the array buffer
  308. * @param entry
  309. */
  310. setFloat32(entry: number, byteOffset?: number): void;
  311. /**
  312. * Stores an UInt32 in the array buffer
  313. * @param entry
  314. * @param byteOffset If defined, specifies where to set the value as an offset.
  315. */
  316. setUInt32(entry: number, byteOffset?: number): void;
  317. }
  318. }
  319. declare module 'babylonjs-serializers/src/glTF/2.0/glTFExporterExtension' {
  320. import { IDisposable, Texture, Nullable, SubMesh } from "babylonjs";
  321. import { ImageMimeType, IMeshPrimitive } from "babylonjs-gltf2interface";
  322. import { _BinaryWriter } from "babylonjs-serializers/src/glTF/2.0/glTFExporter";
  323. import { IGLTFExporterExtension } from "babylonjs-serializers/src/glTF/glTFFileExporter";
  324. /** @hidden */
  325. export var __IGLTFExporterExtensionV2: number;
  326. /**
  327. * Interface for a glTF exporter extension
  328. * @hidden
  329. */
  330. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  331. /**
  332. * Define this method to modify the default behavior before exporting a texture
  333. * @param context The context when loading the asset
  334. * @param babylonTexture The glTF texture info property
  335. * @param mimeType The mime-type of the generated image
  336. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  337. */
  338. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  339. /**
  340. * Define this method to modify the default behavior when exporting texture info
  341. * @param context The context when loading the asset
  342. * @param meshPrimitive glTF mesh primitive
  343. * @param babylonSubMesh Babylon submesh
  344. * @param binaryWriter glTF serializer binary writer instance
  345. */
  346. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  347. }
  348. }
  349. declare module 'babylonjs-serializers/src/glTF/2.0/glTFMaterialExporter' {
  350. import { Nullable, Material, StandardMaterial, PBRMetallicRoughnessMaterial, PBRMaterial, BaseTexture } from "babylonjs";
  351. import { ITextureInfo, ImageMimeType, IMaterial, IMaterialPbrMetallicRoughness, MaterialAlphaMode } from "babylonjs-gltf2interface";
  352. import { _Exporter } from "babylonjs-serializers/src/glTF/2.0/glTFExporter";
  353. /**
  354. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  355. * @hidden
  356. */
  357. export class _GLTFMaterialExporter {
  358. constructor(exporter: _Exporter);
  359. /**
  360. * Gets the materials from a Babylon scene and converts them to glTF materials
  361. * @param scene babylonjs scene
  362. * @param mimeType texture mime type
  363. * @param images array of images
  364. * @param textures array of textures
  365. * @param materials array of materials
  366. * @param imageData mapping of texture names to base64 textures
  367. * @param hasTextureCoords specifies if texture coordinates are present on the material
  368. */
  369. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  370. /**
  371. * Makes a copy of the glTF material without the texture parameters
  372. * @param originalMaterial original glTF material
  373. * @returns glTF material without texture parameters
  374. */
  375. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  376. /**
  377. * Specifies if the material has any texture parameters present
  378. * @param material glTF Material
  379. * @returns boolean specifying if texture parameters are present
  380. */
  381. _hasTexturesPresent(material: IMaterial): boolean;
  382. /**
  383. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  384. * @param babylonStandardMaterial
  385. * @returns glTF Metallic Roughness Material representation
  386. */
  387. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  388. /**
  389. * Computes the metallic factor
  390. * @param diffuse diffused value
  391. * @param specular specular value
  392. * @param oneMinusSpecularStrength one minus the specular strength
  393. * @returns metallic value
  394. */
  395. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  396. /**
  397. * Gets the glTF alpha mode from the Babylon Material
  398. * @param babylonMaterial Babylon Material
  399. * @returns The Babylon alpha mode value
  400. */
  401. _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  402. /**
  403. * Converts a Babylon Standard Material to a glTF Material
  404. * @param babylonStandardMaterial BJS Standard Material
  405. * @param mimeType mime type to use for the textures
  406. * @param images array of glTF image interfaces
  407. * @param textures array of glTF texture interfaces
  408. * @param materials array of glTF material interfaces
  409. * @param imageData map of image file name to data
  410. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  411. */
  412. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  413. /**
  414. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  415. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  416. * @param mimeType mime type to use for the textures
  417. * @param images array of glTF image interfaces
  418. * @param textures array of glTF texture interfaces
  419. * @param materials array of glTF material interfaces
  420. * @param imageData map of image file name to data
  421. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  422. */
  423. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  424. /**
  425. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  426. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  427. * @param mimeType mime type to use for the textures
  428. * @param images array of glTF image interfaces
  429. * @param textures array of glTF texture interfaces
  430. * @param materials array of glTF material interfaces
  431. * @param imageData map of image file name to data
  432. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  433. */
  434. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  435. /**
  436. * Extracts a texture from a Babylon texture into file data and glTF data
  437. * @param babylonTexture Babylon texture to extract
  438. * @param mimeType Mime Type of the babylonTexture
  439. * @return glTF texture info, or null if the texture format is not supported
  440. */
  441. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  442. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  443. }
  444. }
  445. declare module 'babylonjs-serializers/src/glTF/2.0/glTFSerializer' {
  446. import { TransformNode, Scene } from "babylonjs";
  447. import { GLTFData } from "babylonjs-serializers/src/glTF/2.0/glTFData";
  448. /**
  449. * Holds a collection of exporter options and parameters
  450. */
  451. export interface IExportOptions {
  452. /**
  453. * Function which indicates whether a babylon mesh should be exported or not
  454. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  455. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  456. */
  457. shouldExportTransformNode?(transformNode: TransformNode): boolean;
  458. /**
  459. * The sample rate to bake animation curves
  460. */
  461. animationSampleRate?: number;
  462. /**
  463. * Begin serialization without waiting for the scene to be ready
  464. */
  465. exportWithoutWaitingForScene?: boolean;
  466. }
  467. /**
  468. * Class for generating glTF data from a Babylon scene.
  469. */
  470. export class GLTF2Export {
  471. /**
  472. * Exports the geometry of the scene to .gltf file format asynchronously
  473. * @param scene Babylon scene with scene hierarchy information
  474. * @param filePrefix File prefix to use when generating the glTF file
  475. * @param options Exporter options
  476. * @returns Returns an object with a .gltf file and associates texture names
  477. * as keys and their data and paths as values
  478. */
  479. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  480. /**
  481. * Exports the geometry of the scene to .glb file format asychronously
  482. * @param scene Babylon scene with scene hierarchy information
  483. * @param filePrefix File prefix to use when generating glb file
  484. * @param options Exporter options
  485. * @returns Returns an object with a .glb filename as key and data as value
  486. */
  487. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  488. }
  489. }
  490. declare module 'babylonjs-serializers/src/glTF/2.0/glTFUtilities' {
  491. import { Nullable, FloatArray, Vector3, Vector4, Quaternion } from "babylonjs";
  492. import { IBufferView, AccessorType, AccessorComponentType, IAccessor } from "babylonjs-gltf2interface";
  493. /**
  494. * @hidden
  495. */
  496. export class _GLTFUtilities {
  497. /**
  498. * Creates a buffer view based on the supplied arguments
  499. * @param bufferIndex index value of the specified buffer
  500. * @param byteOffset byte offset value
  501. * @param byteLength byte length of the bufferView
  502. * @param byteStride byte distance between conequential elements
  503. * @param name name of the buffer view
  504. * @returns bufferView for glTF
  505. */
  506. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  507. /**
  508. * Creates an accessor based on the supplied arguments
  509. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  510. * @param name The name of the accessor
  511. * @param type The type of the accessor
  512. * @param componentType The datatype of components in the attribute
  513. * @param count The number of attributes referenced by this accessor
  514. * @param byteOffset The offset relative to the start of the bufferView in bytes
  515. * @param min Minimum value of each component in this attribute
  516. * @param max Maximum value of each component in this attribute
  517. * @returns accessor for glTF
  518. */
  519. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  520. /**
  521. * Calculates the minimum and maximum values of an array of position floats
  522. * @param positions Positions array of a mesh
  523. * @param vertexStart Starting vertex offset to calculate min and max values
  524. * @param vertexCount Number of vertices to check for min and max values
  525. * @returns min number array and max number array
  526. */
  527. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  528. min: number[];
  529. max: number[];
  530. };
  531. /**
  532. * Converts a new right-handed Vector3
  533. * @param vector vector3 array
  534. * @returns right-handed Vector3
  535. */
  536. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  537. /**
  538. * Converts a Vector3 to right-handed
  539. * @param vector Vector3 to convert to right-handed
  540. */
  541. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  542. /**
  543. * Converts a three element number array to right-handed
  544. * @param vector number array to convert to right-handed
  545. */
  546. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  547. /**
  548. * Converts a new right-handed Vector3
  549. * @param vector vector3 array
  550. * @returns right-handed Vector3
  551. */
  552. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  553. /**
  554. * Converts a Vector3 to right-handed
  555. * @param vector Vector3 to convert to right-handed
  556. */
  557. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  558. /**
  559. * Converts a three element number array to right-handed
  560. * @param vector number array to convert to right-handed
  561. */
  562. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  563. /**
  564. * Converts a Vector4 to right-handed
  565. * @param vector Vector4 to convert to right-handed
  566. */
  567. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  568. /**
  569. * Converts a Vector4 to right-handed
  570. * @param vector Vector4 to convert to right-handed
  571. */
  572. static _GetRightHandedArray4FromRef(vector: number[]): void;
  573. /**
  574. * Converts a Quaternion to right-handed
  575. * @param quaternion Source quaternion to convert to right-handed
  576. */
  577. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  578. /**
  579. * Converts a Quaternion to right-handed
  580. * @param quaternion Source quaternion to convert to right-handed
  581. */
  582. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  583. static _NormalizeTangentFromRef(tangent: Vector4): void;
  584. }
  585. }
  586. /*BabylonJS serializers*/
  587. // Dependencies for this module:
  588. // ../../../../Tools/Gulp/babylonjs
  589. // ../../../../Tools/Gulp/babylonjs-gltf2interface
  590. declare module BABYLON {
  591. export class OBJExport {
  592. static OBJ(mesh: BABYLON.Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  593. static MTL(mesh: BABYLON.Mesh): string;
  594. }
  595. }
  596. declare module BABYLON {
  597. /** @hidden */
  598. export var __IGLTFExporterExtension: number;
  599. /**
  600. * Interface for extending the exporter
  601. * @hidden
  602. */
  603. export interface IGLTFExporterExtension {
  604. /**
  605. * The name of this extension
  606. */
  607. readonly name: string;
  608. /**
  609. * Defines whether this extension is enabled
  610. */
  611. enabled: boolean;
  612. /**
  613. * Defines whether this extension is required
  614. */
  615. required: boolean;
  616. }
  617. }
  618. declare module BABYLON {
  619. /**
  620. * @hidden
  621. * Interface to store animation data.
  622. */
  623. export interface _IAnimationData {
  624. /**
  625. * Keyframe data.
  626. */
  627. inputs: number[];
  628. /**
  629. * Value data.
  630. */
  631. outputs: number[][];
  632. /**
  633. * BABYLON.Animation interpolation data.
  634. */
  635. samplerInterpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  636. /**
  637. * Minimum keyframe value.
  638. */
  639. inputsMin: number;
  640. /**
  641. * Maximum keyframe value.
  642. */
  643. inputsMax: number;
  644. }
  645. /**
  646. * @hidden
  647. */
  648. export interface _IAnimationInfo {
  649. /**
  650. * The target channel for the animation
  651. */
  652. animationChannelTargetPath: BABYLON.GLTF2.AnimationChannelTargetPath;
  653. /**
  654. * The glTF accessor type for the data.
  655. */
  656. dataAccessorType: BABYLON.GLTF2.AccessorType.VEC3 | BABYLON.GLTF2.AccessorType.VEC4;
  657. /**
  658. * Specifies if quaternions should be used.
  659. */
  660. useQuaternion: boolean;
  661. }
  662. /**
  663. * @hidden
  664. * Utility class for generating glTF animation data from BabylonJS.
  665. */
  666. export class _GLTFAnimation {
  667. /**
  668. * @ignore
  669. *
  670. * Creates glTF channel animation from BabylonJS animation.
  671. * @param babylonTransformNode - BabylonJS mesh.
  672. * @param animation - animation.
  673. * @param animationChannelTargetPath - The target animation channel.
  674. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  675. * @param useQuaternion - Specifies if quaternions are used.
  676. * @returns nullable IAnimationData
  677. */
  678. static _CreateNodeAnimation(babylonTransformNode: BABYLON.TransformNode, animation: BABYLON.Animation, animationChannelTargetPath: BABYLON.GLTF2.AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): BABYLON.Nullable<_IAnimationData>;
  679. /**
  680. * @ignore
  681. * Create node animations from the transform node animations
  682. * @param babylonTransformNode
  683. * @param runtimeGLTFAnimation
  684. * @param idleGLTFAnimations
  685. * @param nodeMap
  686. * @param nodes
  687. * @param binaryWriter
  688. * @param bufferViews
  689. * @param accessors
  690. * @param convertToRightHandedSystem
  691. */
  692. static _CreateNodeAnimationFromTransformNodeAnimations(babylonTransformNode: BABYLON.TransformNode, runtimeGLTFAnimation: BABYLON.GLTF2.IAnimation, idleGLTFAnimations: BABYLON.GLTF2.IAnimation[], nodeMap: {
  693. [key: number]: number;
  694. }, nodes: BABYLON.GLTF2.INode[], binaryWriter: _BinaryWriter, bufferViews: BABYLON.GLTF2.IBufferView[], accessors: BABYLON.GLTF2.IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  695. /**
  696. * @ignore
  697. * Create node animations from the animation groups
  698. * @param babylonScene
  699. * @param glTFAnimations
  700. * @param nodeMap
  701. * @param nodes
  702. * @param binaryWriter
  703. * @param bufferViews
  704. * @param accessors
  705. * @param convertToRightHandedSystem
  706. */
  707. static _CreateNodeAnimationFromAnimationGroups(babylonScene: BABYLON.Scene, glTFAnimations: BABYLON.GLTF2.IAnimation[], nodeMap: {
  708. [key: number]: number;
  709. }, nodes: BABYLON.GLTF2.INode[], binaryWriter: _BinaryWriter, bufferViews: BABYLON.GLTF2.IBufferView[], accessors: BABYLON.GLTF2.IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  710. }
  711. }
  712. declare module BABYLON {
  713. /**
  714. * Class for holding and downloading glTF file data
  715. */
  716. export class GLTFData {
  717. /**
  718. * Object which contains the file name as the key and its data as the value
  719. */
  720. glTFFiles: {
  721. [fileName: string]: string | Blob;
  722. };
  723. /**
  724. * Initializes the glTF file object
  725. */
  726. constructor();
  727. /**
  728. * Downloads the glTF data as files based on their names and data
  729. */
  730. downloadFiles(): void;
  731. }
  732. }
  733. declare module BABYLON {
  734. /**
  735. * Converts Babylon BABYLON.Scene into glTF 2.0.
  736. * @hidden
  737. */
  738. export class _Exporter {
  739. /**
  740. * Stores all generated buffer views, which represents views into the main glTF buffer data
  741. */
  742. _bufferViews: BABYLON.GLTF2.IBufferView[];
  743. /**
  744. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  745. */
  746. _accessors: BABYLON.GLTF2.IAccessor[];
  747. /**
  748. * Stores all the generated material information, which represents the appearance of each primitive
  749. */
  750. _materials: BABYLON.GLTF2.IMaterial[];
  751. _materialMap: {
  752. [materialID: number]: number;
  753. };
  754. /**
  755. * Stores all the generated texture information, which is referenced by glTF materials
  756. */
  757. _textures: BABYLON.GLTF2.ITexture[];
  758. /**
  759. * Stores all the generated image information, which is referenced by glTF textures
  760. */
  761. _images: BABYLON.GLTF2.IImage[];
  762. /**
  763. * Stores all the texture samplers
  764. */
  765. _samplers: BABYLON.GLTF2.ISampler[];
  766. /**
  767. * Stores a map of the image data, where the key is the file name and the value
  768. * is the image data
  769. */
  770. _imageData: {
  771. [fileName: string]: {
  772. data: Uint8Array;
  773. mimeType: BABYLON.GLTF2.ImageMimeType;
  774. };
  775. };
  776. _glTFMaterialExporter: _GLTFMaterialExporter;
  777. _extensionsPreExportTextureAsync(context: string, babylonTexture: BABYLON.Texture, mimeType: BABYLON.GLTF2.ImageMimeType): BABYLON.Nullable<Promise<BABYLON.BaseTexture>>;
  778. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: BABYLON.GLTF2.IMeshPrimitive, babylonSubMesh: BABYLON.SubMesh, binaryWriter: _BinaryWriter): BABYLON.Nullable<Promise<BABYLON.GLTF2.IMeshPrimitive>>;
  779. /**
  780. * Creates a glTF Exporter instance, which can accept optional exporter options
  781. * @param babylonScene Babylon scene object
  782. * @param options Options to modify the behavior of the exporter
  783. */
  784. constructor(babylonScene: BABYLON.Scene, options?: IExportOptions);
  785. /**
  786. * Registers a glTF exporter extension
  787. * @param name Name of the extension to export
  788. * @param factory The factory function that creates the exporter extension
  789. */
  790. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  791. /**
  792. * Un-registers an exporter extension
  793. * @param name The name fo the exporter extension
  794. * @returns A boolean indicating whether the extension has been un-registered
  795. */
  796. static UnregisterExtension(name: string): boolean;
  797. /**
  798. * Lazy load a local engine with premultiplied alpha set to false
  799. */
  800. _getLocalEngine(): BABYLON.Engine;
  801. /**
  802. * Writes mesh attribute data to a data buffer
  803. * Returns the bytelength of the data
  804. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  805. * @param meshAttributeArray Array containing the attribute data
  806. * @param binaryWriter The buffer to write the binary data to
  807. * @param indices Used to specify the order of the vertex data
  808. */
  809. writeAttributeData(vertexBufferKind: string, meshAttributeArray: BABYLON.FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  810. /**
  811. * Generates data for .gltf and .bin files based on the glTF prefix string
  812. * @param glTFPrefix Text to use when prefixing a glTF file
  813. * @returns GLTFData with glTF file data
  814. */
  815. _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  816. /**
  817. * Generates a glb file from the json and binary data
  818. * Returns an object with the glb file name as the key and data as the value
  819. * @param glTFPrefix
  820. * @returns object with glb filename as key and data as value
  821. */
  822. _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  823. }
  824. /**
  825. * @hidden
  826. *
  827. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  828. */
  829. export class _BinaryWriter {
  830. /**
  831. * Initialize binary writer with an initial byte length
  832. * @param byteLength Initial byte length of the array buffer
  833. */
  834. constructor(byteLength: number);
  835. /**
  836. * Get an array buffer with the length of the byte offset
  837. * @returns ArrayBuffer resized to the byte offset
  838. */
  839. getArrayBuffer(): ArrayBuffer;
  840. /**
  841. * Get the byte offset of the array buffer
  842. * @returns byte offset
  843. */
  844. getByteOffset(): number;
  845. /**
  846. * Stores an UInt8 in the array buffer
  847. * @param entry
  848. * @param byteOffset If defined, specifies where to set the value as an offset.
  849. */
  850. setUInt8(entry: number, byteOffset?: number): void;
  851. /**
  852. * Gets an UInt32 in the array buffer
  853. * @param entry
  854. * @param byteOffset If defined, specifies where to set the value as an offset.
  855. */
  856. getUInt32(byteOffset: number): number;
  857. getVector3Float32FromRef(vector3: BABYLON.Vector3, byteOffset: number): void;
  858. setVector3Float32FromRef(vector3: BABYLON.Vector3, byteOffset: number): void;
  859. getVector4Float32FromRef(vector4: BABYLON.Vector4, byteOffset: number): void;
  860. setVector4Float32FromRef(vector4: BABYLON.Vector4, byteOffset: number): void;
  861. /**
  862. * Stores a Float32 in the array buffer
  863. * @param entry
  864. */
  865. setFloat32(entry: number, byteOffset?: number): void;
  866. /**
  867. * Stores an UInt32 in the array buffer
  868. * @param entry
  869. * @param byteOffset If defined, specifies where to set the value as an offset.
  870. */
  871. setUInt32(entry: number, byteOffset?: number): void;
  872. }
  873. }
  874. declare module BABYLON {
  875. /** @hidden */
  876. export var __IGLTFExporterExtensionV2: number;
  877. /**
  878. * Interface for a glTF exporter extension
  879. * @hidden
  880. */
  881. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, BABYLON.IDisposable {
  882. /**
  883. * Define this method to modify the default behavior before exporting a texture
  884. * @param context The context when loading the asset
  885. * @param babylonTexture The glTF texture info property
  886. * @param mimeType The mime-type of the generated image
  887. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  888. */
  889. preExportTextureAsync?(context: string, babylonTexture: BABYLON.Texture, mimeType: BABYLON.GLTF2.ImageMimeType): BABYLON.Nullable<Promise<BABYLON.Texture>>;
  890. /**
  891. * Define this method to modify the default behavior when exporting texture info
  892. * @param context The context when loading the asset
  893. * @param meshPrimitive glTF mesh primitive
  894. * @param babylonSubMesh Babylon submesh
  895. * @param binaryWriter glTF serializer binary writer instance
  896. */
  897. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: BABYLON.GLTF2.IMeshPrimitive, babylonSubMesh: BABYLON.SubMesh, binaryWriter: _BinaryWriter): BABYLON.Nullable<Promise<BABYLON.GLTF2.IMeshPrimitive>>;
  898. }
  899. }
  900. declare module BABYLON {
  901. /**
  902. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  903. * @hidden
  904. */
  905. export class _GLTFMaterialExporter {
  906. constructor(exporter: _Exporter);
  907. /**
  908. * Gets the materials from a Babylon scene and converts them to glTF materials
  909. * @param scene babylonjs scene
  910. * @param mimeType texture mime type
  911. * @param images array of images
  912. * @param textures array of textures
  913. * @param materials array of materials
  914. * @param imageData mapping of texture names to base64 textures
  915. * @param hasTextureCoords specifies if texture coordinates are present on the material
  916. */
  917. _convertMaterialsToGLTFAsync(babylonMaterials: BABYLON.Material[], mimeType: BABYLON.GLTF2.ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  918. /**
  919. * Makes a copy of the glTF material without the texture parameters
  920. * @param originalMaterial original glTF material
  921. * @returns glTF material without texture parameters
  922. */
  923. _stripTexturesFromMaterial(originalMaterial: BABYLON.GLTF2.IMaterial): BABYLON.GLTF2.IMaterial;
  924. /**
  925. * Specifies if the material has any texture parameters present
  926. * @param material glTF BABYLON.Material
  927. * @returns boolean specifying if texture parameters are present
  928. */
  929. _hasTexturesPresent(material: BABYLON.GLTF2.IMaterial): boolean;
  930. /**
  931. * Converts a Babylon BABYLON.StandardMaterial to a glTF Metallic Roughness BABYLON.Material
  932. * @param babylonStandardMaterial
  933. * @returns glTF Metallic Roughness BABYLON.Material representation
  934. */
  935. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: BABYLON.StandardMaterial): BABYLON.GLTF2.IMaterialPbrMetallicRoughness;
  936. /**
  937. * Computes the metallic factor
  938. * @param diffuse diffused value
  939. * @param specular specular value
  940. * @param oneMinusSpecularStrength one minus the specular strength
  941. * @returns metallic value
  942. */
  943. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  944. /**
  945. * Gets the glTF alpha mode from the Babylon BABYLON.Material
  946. * @param babylonMaterial Babylon BABYLON.Material
  947. * @returns The Babylon alpha mode value
  948. */
  949. _getAlphaMode(babylonMaterial: BABYLON.Material): BABYLON.GLTF2.MaterialAlphaMode;
  950. /**
  951. * Converts a Babylon Standard BABYLON.Material to a glTF BABYLON.Material
  952. * @param babylonStandardMaterial BJS Standard BABYLON.Material
  953. * @param mimeType mime type to use for the textures
  954. * @param images array of glTF image interfaces
  955. * @param textures array of glTF texture interfaces
  956. * @param materials array of glTF material interfaces
  957. * @param imageData map of image file name to data
  958. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  959. */
  960. _convertStandardMaterialAsync(babylonStandardMaterial: BABYLON.StandardMaterial, mimeType: BABYLON.GLTF2.ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  961. /**
  962. * Converts a Babylon PBR Metallic Roughness BABYLON.Material to a glTF BABYLON.Material
  963. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness BABYLON.Material
  964. * @param mimeType mime type to use for the textures
  965. * @param images array of glTF image interfaces
  966. * @param textures array of glTF texture interfaces
  967. * @param materials array of glTF material interfaces
  968. * @param imageData map of image file name to data
  969. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  970. */
  971. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: BABYLON.PBRMetallicRoughnessMaterial, mimeType: BABYLON.GLTF2.ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  972. /**
  973. * Converts a Babylon PBR Metallic Roughness BABYLON.Material to a glTF BABYLON.Material
  974. * @param babylonPBRMaterial BJS PBR Metallic Roughness BABYLON.Material
  975. * @param mimeType mime type to use for the textures
  976. * @param images array of glTF image interfaces
  977. * @param textures array of glTF texture interfaces
  978. * @param materials array of glTF material interfaces
  979. * @param imageData map of image file name to data
  980. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  981. */
  982. _convertPBRMaterialAsync(babylonPBRMaterial: BABYLON.PBRMaterial, mimeType: BABYLON.GLTF2.ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  983. /**
  984. * Extracts a texture from a Babylon texture into file data and glTF data
  985. * @param babylonTexture Babylon texture to extract
  986. * @param mimeType Mime Type of the babylonTexture
  987. * @return glTF texture info, or null if the texture format is not supported
  988. */
  989. _exportTextureAsync(babylonTexture: BABYLON.BaseTexture, mimeType: BABYLON.GLTF2.ImageMimeType): Promise<BABYLON.Nullable<BABYLON.GLTF2.ITextureInfo>>;
  990. _exportTextureInfoAsync(babylonTexture: BABYLON.BaseTexture, mimeType: BABYLON.GLTF2.ImageMimeType): Promise<BABYLON.Nullable<BABYLON.GLTF2.ITextureInfo>>;
  991. }
  992. }
  993. declare module BABYLON {
  994. /**
  995. * Holds a collection of exporter options and parameters
  996. */
  997. export interface IExportOptions {
  998. /**
  999. * Function which indicates whether a babylon mesh should be exported or not
  1000. * @param transformNode source Babylon transform node. It is used to check whether it should be exported to glTF or not
  1001. * @returns boolean, which indicates whether the mesh should be exported (true) or not (false)
  1002. */
  1003. shouldExportTransformNode?(transformNode: BABYLON.TransformNode): boolean;
  1004. /**
  1005. * The sample rate to bake animation curves
  1006. */
  1007. animationSampleRate?: number;
  1008. /**
  1009. * Begin serialization without waiting for the scene to be ready
  1010. */
  1011. exportWithoutWaitingForScene?: boolean;
  1012. }
  1013. /**
  1014. * Class for generating glTF data from a Babylon scene.
  1015. */
  1016. export class GLTF2Export {
  1017. /**
  1018. * Exports the geometry of the scene to .gltf file format asynchronously
  1019. * @param scene Babylon scene with scene hierarchy information
  1020. * @param filePrefix File prefix to use when generating the glTF file
  1021. * @param options Exporter options
  1022. * @returns Returns an object with a .gltf file and associates texture names
  1023. * as keys and their data and paths as values
  1024. */
  1025. static GLTFAsync(scene: BABYLON.Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  1026. /**
  1027. * Exports the geometry of the scene to .glb file format asychronously
  1028. * @param scene Babylon scene with scene hierarchy information
  1029. * @param filePrefix File prefix to use when generating glb file
  1030. * @param options Exporter options
  1031. * @returns Returns an object with a .glb filename as key and data as value
  1032. */
  1033. static GLBAsync(scene: BABYLON.Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  1034. }
  1035. }
  1036. declare module BABYLON {
  1037. /**
  1038. * @hidden
  1039. */
  1040. export class _GLTFUtilities {
  1041. /**
  1042. * Creates a buffer view based on the supplied arguments
  1043. * @param bufferIndex index value of the specified buffer
  1044. * @param byteOffset byte offset value
  1045. * @param byteLength byte length of the bufferView
  1046. * @param byteStride byte distance between conequential elements
  1047. * @param name name of the buffer view
  1048. * @returns bufferView for glTF
  1049. */
  1050. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): BABYLON.GLTF2.IBufferView;
  1051. /**
  1052. * Creates an accessor based on the supplied arguments
  1053. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  1054. * @param name The name of the accessor
  1055. * @param type The type of the accessor
  1056. * @param componentType The datatype of components in the attribute
  1057. * @param count The number of attributes referenced by this accessor
  1058. * @param byteOffset The offset relative to the start of the bufferView in bytes
  1059. * @param min Minimum value of each component in this attribute
  1060. * @param max Maximum value of each component in this attribute
  1061. * @returns accessor for glTF
  1062. */
  1063. static _CreateAccessor(bufferviewIndex: number, name: string, type: BABYLON.GLTF2.AccessorType, componentType: BABYLON.GLTF2.AccessorComponentType, count: number, byteOffset: BABYLON.Nullable<number>, min: BABYLON.Nullable<number[]>, max: BABYLON.Nullable<number[]>): BABYLON.GLTF2.IAccessor;
  1064. /**
  1065. * Calculates the minimum and maximum values of an array of position floats
  1066. * @param positions Positions array of a mesh
  1067. * @param vertexStart Starting vertex offset to calculate min and max values
  1068. * @param vertexCount Number of vertices to check for min and max values
  1069. * @returns min number array and max number array
  1070. */
  1071. static _CalculateMinMaxPositions(positions: BABYLON.FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  1072. min: number[];
  1073. max: number[];
  1074. };
  1075. /**
  1076. * Converts a new right-handed BABYLON.Vector3
  1077. * @param vector vector3 array
  1078. * @returns right-handed BABYLON.Vector3
  1079. */
  1080. static _GetRightHandedPositionVector3(vector: BABYLON.Vector3): BABYLON.Vector3;
  1081. /**
  1082. * Converts a BABYLON.Vector3 to right-handed
  1083. * @param vector BABYLON.Vector3 to convert to right-handed
  1084. */
  1085. static _GetRightHandedPositionVector3FromRef(vector: BABYLON.Vector3): void;
  1086. /**
  1087. * Converts a three element number array to right-handed
  1088. * @param vector number array to convert to right-handed
  1089. */
  1090. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  1091. /**
  1092. * Converts a new right-handed BABYLON.Vector3
  1093. * @param vector vector3 array
  1094. * @returns right-handed BABYLON.Vector3
  1095. */
  1096. static _GetRightHandedNormalVector3(vector: BABYLON.Vector3): BABYLON.Vector3;
  1097. /**
  1098. * Converts a BABYLON.Vector3 to right-handed
  1099. * @param vector BABYLON.Vector3 to convert to right-handed
  1100. */
  1101. static _GetRightHandedNormalVector3FromRef(vector: BABYLON.Vector3): void;
  1102. /**
  1103. * Converts a three element number array to right-handed
  1104. * @param vector number array to convert to right-handed
  1105. */
  1106. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  1107. /**
  1108. * Converts a BABYLON.Vector4 to right-handed
  1109. * @param vector BABYLON.Vector4 to convert to right-handed
  1110. */
  1111. static _GetRightHandedVector4FromRef(vector: BABYLON.Vector4): void;
  1112. /**
  1113. * Converts a BABYLON.Vector4 to right-handed
  1114. * @param vector BABYLON.Vector4 to convert to right-handed
  1115. */
  1116. static _GetRightHandedArray4FromRef(vector: number[]): void;
  1117. /**
  1118. * Converts a BABYLON.Quaternion to right-handed
  1119. * @param quaternion Source quaternion to convert to right-handed
  1120. */
  1121. static _GetRightHandedQuaternionFromRef(quaternion: BABYLON.Quaternion): void;
  1122. /**
  1123. * Converts a BABYLON.Quaternion to right-handed
  1124. * @param quaternion Source quaternion to convert to right-handed
  1125. */
  1126. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  1127. static _NormalizeTangentFromRef(tangent: BABYLON.Vector4): void;
  1128. }
  1129. }