babylonjs.serializers.d.ts 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168
  1. declare module BABYLON {
  2. /**
  3. * Class for generating OBJ data from a Babylon scene.
  4. */
  5. export class OBJExport {
  6. /**
  7. * Exports the geometry of a Mesh array in .OBJ file format (text)
  8. * @param mesh defines the list of meshes to serialize
  9. * @param materials defines if materials should be exported
  10. * @param matlibname defines the name of the associated mtl file
  11. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  12. * @returns the OBJ content
  13. */
  14. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  15. /**
  16. * Exports the material(s) of a mesh in .MTL file format (text)
  17. * @param mesh defines the mesh to extract the material from
  18. * @returns the mtl content
  19. */
  20. static MTL(mesh: Mesh): string;
  21. }
  22. }
  23. declare module BABYLON {
  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 BABYLON.GLTF2.Exporter {
  46. /** @hidden */
  47. export var __IGLTFExporterExtensionV2: number;
  48. /**
  49. * Interface for a glTF exporter extension
  50. * @hidden
  51. */
  52. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  53. /**
  54. * Define this method to modify the default behavior before exporting a texture
  55. * @param context The context when loading the asset
  56. * @param babylonTexture The Babylon.js texture
  57. * @param mimeType The mime-type of the generated image
  58. * @returns A promise that resolves with the exported texture
  59. */
  60. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  61. /**
  62. * Define this method to get notified when a texture info is created
  63. * @param context The context when loading the asset
  64. * @param textureInfo The glTF texture info
  65. * @param babylonTexture The Babylon.js texture
  66. */
  67. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  68. /**
  69. * Define this method to modify the default behavior when exporting texture info
  70. * @param context The context when loading the asset
  71. * @param meshPrimitive glTF mesh primitive
  72. * @param babylonSubMesh Babylon submesh
  73. * @param binaryWriter glTF serializer binary writer instance
  74. * @returns nullable IMeshPrimitive promise
  75. */
  76. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  77. /**
  78. * Define this method to modify the default behavior when exporting a node
  79. * @param context The context when exporting the node
  80. * @param node glTF node
  81. * @param babylonNode BabylonJS node
  82. * @returns nullable INode promise
  83. */
  84. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  85. /**
  86. * Define this method to modify the default behavior when exporting a material
  87. * @param material glTF material
  88. * @param babylonMaterial BabylonJS material
  89. * @returns nullable IMaterial promise
  90. */
  91. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  92. /**
  93. * Define this method to return additional textures to export from a material
  94. * @param material glTF material
  95. * @param babylonMaterial BabylonJS material
  96. * @returns List of textures
  97. */
  98. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  99. /** Gets a boolean indicating that this extension was used */
  100. wasUsed: boolean;
  101. /** Gets a boolean indicating that this extension is required for the file to work */
  102. required: boolean;
  103. /**
  104. * Called after the exporter state changes to EXPORTING
  105. */
  106. onExporting?(): void;
  107. }
  108. }
  109. declare module BABYLON.GLTF2.Exporter {
  110. /**
  111. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  112. * @hidden
  113. */
  114. export class _GLTFMaterialExporter {
  115. /**
  116. * Represents the dielectric specular values for R, G and B
  117. */
  118. private static readonly _DielectricSpecular;
  119. /**
  120. * Allows the maximum specular power to be defined for material calculations
  121. */
  122. private static readonly _MaxSpecularPower;
  123. /**
  124. * Mapping to store textures
  125. */
  126. private _textureMap;
  127. /**
  128. * Numeric tolerance value
  129. */
  130. private static readonly _Epsilon;
  131. /**
  132. * Reference to the glTF Exporter
  133. */
  134. private _exporter;
  135. constructor(exporter: _Exporter);
  136. /**
  137. * Specifies if two colors are approximately equal in value
  138. * @param color1 first color to compare to
  139. * @param color2 second color to compare to
  140. * @param epsilon threshold value
  141. */
  142. private static FuzzyEquals;
  143. /**
  144. * Gets the materials from a Babylon scene and converts them to glTF materials
  145. * @param scene babylonjs scene
  146. * @param mimeType texture mime type
  147. * @param images array of images
  148. * @param textures array of textures
  149. * @param materials array of materials
  150. * @param imageData mapping of texture names to base64 textures
  151. * @param hasTextureCoords specifies if texture coordinates are present on the material
  152. */
  153. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  154. /**
  155. * Makes a copy of the glTF material without the texture parameters
  156. * @param originalMaterial original glTF material
  157. * @returns glTF material without texture parameters
  158. */
  159. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  160. /**
  161. * Specifies if the material has any texture parameters present
  162. * @param material glTF Material
  163. * @returns boolean specifying if texture parameters are present
  164. */
  165. _hasTexturesPresent(material: IMaterial): boolean;
  166. /**
  167. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  168. * @param babylonStandardMaterial
  169. * @returns glTF Metallic Roughness Material representation
  170. */
  171. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  172. /**
  173. * Computes the metallic factor
  174. * @param diffuse diffused value
  175. * @param specular specular value
  176. * @param oneMinusSpecularStrength one minus the specular strength
  177. * @returns metallic value
  178. */
  179. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  180. /**
  181. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  182. * @param glTFMaterial glTF material
  183. * @param babylonMaterial Babylon material
  184. */
  185. private static _SetAlphaMode;
  186. /**
  187. * Converts a Babylon Standard Material to a glTF Material
  188. * @param babylonStandardMaterial BJS Standard Material
  189. * @param mimeType mime type to use for the textures
  190. * @param images array of glTF image interfaces
  191. * @param textures array of glTF texture interfaces
  192. * @param materials array of glTF material interfaces
  193. * @param imageData map of image file name to data
  194. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  195. */
  196. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  197. private _finishMaterial;
  198. /**
  199. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  200. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  201. * @param mimeType mime type to use for the textures
  202. * @param images array of glTF image interfaces
  203. * @param textures array of glTF texture interfaces
  204. * @param materials array of glTF material interfaces
  205. * @param imageData map of image file name to data
  206. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  207. */
  208. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  209. /**
  210. * Converts an image typed array buffer to a base64 image
  211. * @param buffer typed array buffer
  212. * @param width width of the image
  213. * @param height height of the image
  214. * @param mimeType mimetype of the image
  215. * @returns base64 image string
  216. */
  217. private _createBase64FromCanvasAsync;
  218. /**
  219. * Generates a white texture based on the specified width and height
  220. * @param width width of the texture in pixels
  221. * @param height height of the texture in pixels
  222. * @param scene babylonjs scene
  223. * @returns white texture
  224. */
  225. private _createWhiteTexture;
  226. /**
  227. * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null
  228. * @param texture1 first texture to resize
  229. * @param texture2 second texture to resize
  230. * @param scene babylonjs scene
  231. * @returns resized textures or null
  232. */
  233. private _resizeTexturesToSameDimensions;
  234. /**
  235. * Converts an array of pixels to a Float32Array
  236. * Throws an error if the pixel format is not supported
  237. * @param pixels - array buffer containing pixel values
  238. * @returns Float32 of pixels
  239. */
  240. private _convertPixelArrayToFloat32;
  241. /**
  242. * Convert Specular Glossiness Textures to Metallic Roughness
  243. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  244. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  245. * @param diffuseTexture texture used to store diffuse information
  246. * @param specularGlossinessTexture texture used to store specular and glossiness information
  247. * @param factors specular glossiness material factors
  248. * @param mimeType the mime type to use for the texture
  249. * @returns pbr metallic roughness interface or null
  250. */
  251. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  252. /**
  253. * Converts specular glossiness material properties to metallic roughness
  254. * @param specularGlossiness interface with specular glossiness material properties
  255. * @returns interface with metallic roughness material properties
  256. */
  257. private _convertSpecularGlossinessToMetallicRoughness;
  258. /**
  259. * Calculates the surface reflectance, independent of lighting conditions
  260. * @param color Color source to calculate brightness from
  261. * @returns number representing the perceived brightness, or zero if color is undefined
  262. */
  263. private _getPerceivedBrightness;
  264. /**
  265. * Returns the maximum color component value
  266. * @param color
  267. * @returns maximum color component value, or zero if color is null or undefined
  268. */
  269. private _getMaxComponent;
  270. /**
  271. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  272. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  273. * @param mimeType mime type to use for the textures
  274. * @param images array of glTF image interfaces
  275. * @param textures array of glTF texture interfaces
  276. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  277. * @param imageData map of image file name to data
  278. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  279. * @returns glTF PBR Metallic Roughness factors
  280. */
  281. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  282. private _getGLTFTextureSampler;
  283. private _getGLTFTextureWrapMode;
  284. private _getGLTFTextureWrapModesSampler;
  285. /**
  286. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  287. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  288. * @param mimeType mime type to use for the textures
  289. * @param images array of glTF image interfaces
  290. * @param textures array of glTF texture interfaces
  291. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  292. * @param imageData map of image file name to data
  293. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  294. * @returns glTF PBR Metallic Roughness factors
  295. */
  296. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  297. /**
  298. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  299. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  300. * @param mimeType mime type to use for the textures
  301. * @param images array of glTF image interfaces
  302. * @param textures array of glTF texture interfaces
  303. * @param materials array of glTF material interfaces
  304. * @param imageData map of image file name to data
  305. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  306. */
  307. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  308. private setMetallicRoughnessPbrMaterial;
  309. private getPixelsFromTexture;
  310. /**
  311. * Extracts a texture from a Babylon texture into file data and glTF data
  312. * @param babylonTexture Babylon texture to extract
  313. * @param mimeType Mime Type of the babylonTexture
  314. * @return glTF texture info, or null if the texture format is not supported
  315. */
  316. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  317. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  318. /**
  319. * Builds a texture from base64 string
  320. * @param base64Texture base64 texture string
  321. * @param baseTextureName Name to use for the texture
  322. * @param mimeType image mime type for the texture
  323. * @param images array of images
  324. * @param textures array of textures
  325. * @param imageData map of image data
  326. * @returns glTF texture info, or null if the texture format is not supported
  327. */
  328. private _getTextureInfoFromBase64;
  329. }
  330. }
  331. declare module BABYLON {
  332. /**
  333. * Class for holding and downloading glTF file data
  334. */
  335. export class GLTFData {
  336. /**
  337. * Object which contains the file name as the key and its data as the value
  338. */
  339. glTFFiles: {
  340. [fileName: string]: string | Blob;
  341. };
  342. /**
  343. * Initializes the glTF file object
  344. */
  345. constructor();
  346. /**
  347. * Downloads the glTF data as files based on their names and data
  348. */
  349. downloadFiles(): void;
  350. }
  351. }
  352. declare module BABYLON {
  353. /**
  354. * Holds a collection of exporter options and parameters
  355. */
  356. export interface IExportOptions {
  357. /**
  358. * Function which indicates whether a babylon node should be exported or not
  359. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  360. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  361. */
  362. shouldExportNode?(node: Node): boolean;
  363. /**
  364. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  365. * @param metadata source metadata to read from
  366. * @returns the data to store to glTF node extras
  367. */
  368. metadataSelector?(metadata: any): any;
  369. /**
  370. * The sample rate to bake animation curves
  371. */
  372. animationSampleRate?: number;
  373. /**
  374. * Begin serialization without waiting for the scene to be ready
  375. */
  376. exportWithoutWaitingForScene?: boolean;
  377. /**
  378. * Indicates if coordinate system swapping root nodes should be included in export
  379. */
  380. includeCoordinateSystemConversionNodes?: boolean;
  381. }
  382. /**
  383. * Class for generating glTF data from a Babylon scene.
  384. */
  385. export class GLTF2Export {
  386. /**
  387. * Exports the geometry of the scene to .gltf file format asynchronously
  388. * @param scene Babylon scene with scene hierarchy information
  389. * @param filePrefix File prefix to use when generating the glTF file
  390. * @param options Exporter options
  391. * @returns Returns an object with a .gltf file and associates texture names
  392. * as keys and their data and paths as values
  393. */
  394. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  395. private static _PreExportAsync;
  396. private static _PostExportAsync;
  397. /**
  398. * Exports the geometry of the scene to .glb file format asychronously
  399. * @param scene Babylon scene with scene hierarchy information
  400. * @param filePrefix File prefix to use when generating glb file
  401. * @param options Exporter options
  402. * @returns Returns an object with a .glb filename as key and data as value
  403. */
  404. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  405. }
  406. }
  407. declare module BABYLON.GLTF2.Exporter {
  408. /**
  409. * @hidden
  410. */
  411. export class _GLTFUtilities {
  412. /**
  413. * Creates a buffer view based on the supplied arguments
  414. * @param bufferIndex index value of the specified buffer
  415. * @param byteOffset byte offset value
  416. * @param byteLength byte length of the bufferView
  417. * @param byteStride byte distance between conequential elements
  418. * @param name name of the buffer view
  419. * @returns bufferView for glTF
  420. */
  421. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  422. /**
  423. * Creates an accessor based on the supplied arguments
  424. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  425. * @param name The name of the accessor
  426. * @param type The type of the accessor
  427. * @param componentType The datatype of components in the attribute
  428. * @param count The number of attributes referenced by this accessor
  429. * @param byteOffset The offset relative to the start of the bufferView in bytes
  430. * @param min Minimum value of each component in this attribute
  431. * @param max Maximum value of each component in this attribute
  432. * @returns accessor for glTF
  433. */
  434. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  435. /**
  436. * Calculates the minimum and maximum values of an array of position floats
  437. * @param positions Positions array of a mesh
  438. * @param vertexStart Starting vertex offset to calculate min and max values
  439. * @param vertexCount Number of vertices to check for min and max values
  440. * @returns min number array and max number array
  441. */
  442. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  443. min: number[];
  444. max: number[];
  445. };
  446. /**
  447. * Converts a new right-handed Vector3
  448. * @param vector vector3 array
  449. * @returns right-handed Vector3
  450. */
  451. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  452. /**
  453. * Converts a Vector3 to right-handed
  454. * @param vector Vector3 to convert to right-handed
  455. */
  456. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  457. /**
  458. * Converts a three element number array to right-handed
  459. * @param vector number array to convert to right-handed
  460. */
  461. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  462. /**
  463. * Converts a new right-handed Vector3
  464. * @param vector vector3 array
  465. * @returns right-handed Vector3
  466. */
  467. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  468. /**
  469. * Converts a Vector3 to right-handed
  470. * @param vector Vector3 to convert to right-handed
  471. */
  472. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  473. /**
  474. * Converts a three element number array to right-handed
  475. * @param vector number array to convert to right-handed
  476. */
  477. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  478. /**
  479. * Converts a Vector4 to right-handed
  480. * @param vector Vector4 to convert to right-handed
  481. */
  482. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  483. /**
  484. * Converts a Vector4 to right-handed
  485. * @param vector Vector4 to convert to right-handed
  486. */
  487. static _GetRightHandedArray4FromRef(vector: number[]): void;
  488. /**
  489. * Converts a Quaternion to right-handed
  490. * @param quaternion Source quaternion to convert to right-handed
  491. */
  492. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  493. /**
  494. * Converts a Quaternion to right-handed
  495. * @param quaternion Source quaternion to convert to right-handed
  496. */
  497. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  498. static _NormalizeTangentFromRef(tangent: Vector4): void;
  499. }
  500. }
  501. declare module BABYLON.GLTF2.Exporter {
  502. /**
  503. * Converts Babylon Scene into glTF 2.0.
  504. * @hidden
  505. */
  506. export class _Exporter {
  507. /**
  508. * Stores the glTF to export
  509. */
  510. _glTF: IGLTF;
  511. /**
  512. * Stores all generated buffer views, which represents views into the main glTF buffer data
  513. */
  514. _bufferViews: IBufferView[];
  515. /**
  516. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  517. */
  518. _accessors: IAccessor[];
  519. /**
  520. * Stores all the generated nodes, which contains transform and/or mesh information per node
  521. */
  522. private _nodes;
  523. /**
  524. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  525. */
  526. private _scenes;
  527. /**
  528. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  529. */
  530. private _meshes;
  531. /**
  532. * Stores all the generated material information, which represents the appearance of each primitive
  533. */
  534. _materials: IMaterial[];
  535. _materialMap: {
  536. [materialID: number]: number;
  537. };
  538. /**
  539. * Stores all the generated texture information, which is referenced by glTF materials
  540. */
  541. _textures: ITexture[];
  542. /**
  543. * Stores all the generated image information, which is referenced by glTF textures
  544. */
  545. _images: IImage[];
  546. /**
  547. * Stores all the texture samplers
  548. */
  549. _samplers: ISampler[];
  550. /**
  551. * Stores all the generated animation samplers, which is referenced by glTF animations
  552. */
  553. /**
  554. * Stores the animations for glTF models
  555. */
  556. private _animations;
  557. /**
  558. * Stores the total amount of bytes stored in the glTF buffer
  559. */
  560. private _totalByteLength;
  561. /**
  562. * Stores a reference to the Babylon scene containing the source geometry and material information
  563. */
  564. _babylonScene: Scene;
  565. /**
  566. * Stores a map of the image data, where the key is the file name and the value
  567. * is the image data
  568. */
  569. _imageData: {
  570. [fileName: string]: {
  571. data: Uint8Array;
  572. mimeType: ImageMimeType;
  573. };
  574. };
  575. /**
  576. * Stores a map of the unique id of a node to its index in the node array
  577. */
  578. private _nodeMap;
  579. /**
  580. * Specifies if the source Babylon scene was left handed, and needed conversion.
  581. */
  582. _convertToRightHandedSystem: boolean;
  583. /**
  584. * Specifies if a Babylon node should be converted to right-handed on export
  585. */
  586. _convertToRightHandedSystemMap: {
  587. [nodeId: number]: boolean;
  588. };
  589. _includeCoordinateSystemConversionNodes: boolean;
  590. /**
  591. * Baked animation sample rate
  592. */
  593. private _animationSampleRate;
  594. private _options;
  595. private _localEngine;
  596. _glTFMaterialExporter: _GLTFMaterialExporter;
  597. private _extensions;
  598. private static _ExtensionNames;
  599. private static _ExtensionFactories;
  600. private _applyExtension;
  601. private _applyExtensions;
  602. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  603. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  604. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  605. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  606. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  607. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  608. private _forEachExtensions;
  609. private _extensionsOnExporting;
  610. /**
  611. * Load glTF serializer extensions
  612. */
  613. private _loadExtensions;
  614. /**
  615. * Creates a glTF Exporter instance, which can accept optional exporter options
  616. * @param babylonScene Babylon scene object
  617. * @param options Options to modify the behavior of the exporter
  618. */
  619. constructor(babylonScene: Scene, options?: IExportOptions);
  620. dispose(): void;
  621. /**
  622. * Registers a glTF exporter extension
  623. * @param name Name of the extension to export
  624. * @param factory The factory function that creates the exporter extension
  625. */
  626. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  627. /**
  628. * Un-registers an exporter extension
  629. * @param name The name fo the exporter extension
  630. * @returns A boolean indicating whether the extension has been un-registered
  631. */
  632. static UnregisterExtension(name: string): boolean;
  633. /**
  634. * Lazy load a local engine
  635. */
  636. _getLocalEngine(): Engine;
  637. private reorderIndicesBasedOnPrimitiveMode;
  638. /**
  639. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  640. * clock-wise during export to glTF
  641. * @param submesh BabylonJS submesh
  642. * @param primitiveMode Primitive mode of the mesh
  643. * @param sideOrientation the winding order of the submesh
  644. * @param vertexBufferKind The type of vertex attribute
  645. * @param meshAttributeArray The vertex attribute data
  646. * @param byteOffset The offset to the binary data
  647. * @param binaryWriter The binary data for the glTF file
  648. * @param convertToRightHandedSystem Converts the values to right-handed
  649. */
  650. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  651. /**
  652. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  653. * clock-wise during export to glTF
  654. * @param submesh BabylonJS submesh
  655. * @param primitiveMode Primitive mode of the mesh
  656. * @param sideOrientation the winding order of the submesh
  657. * @param vertexBufferKind The type of vertex attribute
  658. * @param meshAttributeArray The vertex attribute data
  659. * @param byteOffset The offset to the binary data
  660. * @param binaryWriter The binary data for the glTF file
  661. * @param convertToRightHandedSystem Converts the values to right-handed
  662. */
  663. private reorderTriangleFillMode;
  664. /**
  665. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  666. * clock-wise during export to glTF
  667. * @param submesh BabylonJS submesh
  668. * @param primitiveMode Primitive mode of the mesh
  669. * @param sideOrientation the winding order of the submesh
  670. * @param vertexBufferKind The type of vertex attribute
  671. * @param meshAttributeArray The vertex attribute data
  672. * @param byteOffset The offset to the binary data
  673. * @param binaryWriter The binary data for the glTF file
  674. * @param convertToRightHandedSystem Converts the values to right-handed
  675. */
  676. private reorderTriangleStripDrawMode;
  677. /**
  678. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  679. * clock-wise during export to glTF
  680. * @param submesh BabylonJS submesh
  681. * @param primitiveMode Primitive mode of the mesh
  682. * @param sideOrientation the winding order of the submesh
  683. * @param vertexBufferKind The type of vertex attribute
  684. * @param meshAttributeArray The vertex attribute data
  685. * @param byteOffset The offset to the binary data
  686. * @param binaryWriter The binary data for the glTF file
  687. * @param convertToRightHandedSystem Converts the values to right-handed
  688. */
  689. private reorderTriangleFanMode;
  690. /**
  691. * Writes the vertex attribute data to binary
  692. * @param vertices The vertices to write to the binary writer
  693. * @param byteOffset The offset into the binary writer to overwrite binary data
  694. * @param vertexAttributeKind The vertex attribute type
  695. * @param meshAttributeArray The vertex attribute data
  696. * @param binaryWriter The writer containing the binary data
  697. * @param convertToRightHandedSystem Converts the values to right-handed
  698. */
  699. private writeVertexAttributeData;
  700. /**
  701. * Writes mesh attribute data to a data buffer
  702. * Returns the bytelength of the data
  703. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  704. * @param meshAttributeArray Array containing the attribute data
  705. * @param binaryWriter The buffer to write the binary data to
  706. * @param indices Used to specify the order of the vertex data
  707. * @param convertToRightHandedSystem Converts the values to right-handed
  708. */
  709. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  710. /**
  711. * Generates glTF json data
  712. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  713. * @param glTFPrefix Text to use when prefixing a glTF file
  714. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  715. * @returns json data as string
  716. */
  717. private generateJSON;
  718. /**
  719. * Generates data for .gltf and .bin files based on the glTF prefix string
  720. * @param glTFPrefix Text to use when prefixing a glTF file
  721. * @param dispose Dispose the exporter
  722. * @returns GLTFData with glTF file data
  723. */
  724. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  725. /**
  726. * Creates a binary buffer for glTF
  727. * @returns array buffer for binary data
  728. */
  729. private _generateBinaryAsync;
  730. /**
  731. * Pads the number to a multiple of 4
  732. * @param num number to pad
  733. * @returns padded number
  734. */
  735. private _getPadding;
  736. /**
  737. * @hidden
  738. */
  739. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  740. /**
  741. * Sets the TRS for each node
  742. * @param node glTF Node for storing the transformation data
  743. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  744. * @param convertToRightHandedSystem Converts the values to right-handed
  745. */
  746. private setNodeTransformation;
  747. private getVertexBufferFromMesh;
  748. /**
  749. * Creates a bufferview based on the vertices type for the Babylon mesh
  750. * @param kind Indicates the type of vertices data
  751. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  752. * @param binaryWriter The buffer to write the bufferview data to
  753. * @param convertToRightHandedSystem Converts the values to right-handed
  754. */
  755. private createBufferViewKind;
  756. /**
  757. * The primitive mode of the Babylon mesh
  758. * @param babylonMesh The BabylonJS mesh
  759. */
  760. private getMeshPrimitiveMode;
  761. /**
  762. * Sets the primitive mode of the glTF mesh primitive
  763. * @param meshPrimitive glTF mesh primitive
  764. * @param primitiveMode The primitive mode
  765. */
  766. private setPrimitiveMode;
  767. /**
  768. * Sets the vertex attribute accessor based of the glTF mesh primitive
  769. * @param meshPrimitive glTF mesh primitive
  770. * @param attributeKind vertex attribute
  771. * @returns boolean specifying if uv coordinates are present
  772. */
  773. private setAttributeKind;
  774. /**
  775. * Sets data for the primitive attributes of each submesh
  776. * @param mesh glTF Mesh object to store the primitive attribute information
  777. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  778. * @param binaryWriter Buffer to write the attribute data to
  779. * @param convertToRightHandedSystem Converts the values to right-handed
  780. */
  781. private setPrimitiveAttributesAsync;
  782. /**
  783. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  784. * @param node The node to check
  785. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  786. */
  787. private isBabylonCoordinateSystemConvertingNode;
  788. /**
  789. * Creates a glTF scene based on the array of meshes
  790. * Returns the the total byte offset
  791. * @param babylonScene Babylon scene to get the mesh data from
  792. * @param binaryWriter Buffer to write binary data to
  793. */
  794. private createSceneAsync;
  795. /**
  796. * Creates a mapping of Node unique id to node index and handles animations
  797. * @param babylonScene Babylon Scene
  798. * @param nodes Babylon transform nodes
  799. * @param binaryWriter Buffer to write binary data to
  800. * @returns Node mapping of unique id to index
  801. */
  802. private createNodeMapAndAnimationsAsync;
  803. /**
  804. * Creates a glTF node from a Babylon mesh
  805. * @param babylonMesh Source Babylon mesh
  806. * @param binaryWriter Buffer for storing geometry data
  807. * @param convertToRightHandedSystem Converts the values to right-handed
  808. * @returns glTF node
  809. */
  810. private createNodeAsync;
  811. }
  812. /**
  813. * @hidden
  814. *
  815. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  816. */
  817. export class _BinaryWriter {
  818. /**
  819. * Array buffer which stores all binary data
  820. */
  821. private _arrayBuffer;
  822. /**
  823. * View of the array buffer
  824. */
  825. private _dataView;
  826. /**
  827. * byte offset of data in array buffer
  828. */
  829. private _byteOffset;
  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. * Resize the array buffer to the specified byte length
  837. * @param byteLength
  838. */
  839. private resizeBuffer;
  840. /**
  841. * Get an array buffer with the length of the byte offset
  842. * @returns ArrayBuffer resized to the byte offset
  843. */
  844. getArrayBuffer(): ArrayBuffer;
  845. /**
  846. * Get the byte offset of the array buffer
  847. * @returns byte offset
  848. */
  849. getByteOffset(): number;
  850. /**
  851. * Stores an UInt8 in the array buffer
  852. * @param entry
  853. * @param byteOffset If defined, specifies where to set the value as an offset.
  854. */
  855. setUInt8(entry: number, byteOffset?: number): void;
  856. /**
  857. * Gets an UInt32 in the array buffer
  858. * @param entry
  859. * @param byteOffset If defined, specifies where to set the value as an offset.
  860. */
  861. getUInt32(byteOffset: number): number;
  862. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  863. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  864. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  865. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  866. /**
  867. * Stores a Float32 in the array buffer
  868. * @param entry
  869. */
  870. setFloat32(entry: number, byteOffset?: number): void;
  871. /**
  872. * Stores an UInt32 in the array buffer
  873. * @param entry
  874. * @param byteOffset If defined, specifies where to set the value as an offset.
  875. */
  876. setUInt32(entry: number, byteOffset?: number): void;
  877. }
  878. }
  879. declare module BABYLON.GLTF2.Exporter {
  880. /**
  881. * @hidden
  882. * Interface to store animation data.
  883. */
  884. export interface _IAnimationData {
  885. /**
  886. * Keyframe data.
  887. */
  888. inputs: number[];
  889. /**
  890. * Value data.
  891. */
  892. outputs: number[][];
  893. /**
  894. * Animation interpolation data.
  895. */
  896. samplerInterpolation: AnimationSamplerInterpolation;
  897. /**
  898. * Minimum keyframe value.
  899. */
  900. inputsMin: number;
  901. /**
  902. * Maximum keyframe value.
  903. */
  904. inputsMax: number;
  905. }
  906. /**
  907. * @hidden
  908. */
  909. export interface _IAnimationInfo {
  910. /**
  911. * The target channel for the animation
  912. */
  913. animationChannelTargetPath: AnimationChannelTargetPath;
  914. /**
  915. * The glTF accessor type for the data.
  916. */
  917. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  918. /**
  919. * Specifies if quaternions should be used.
  920. */
  921. useQuaternion: boolean;
  922. }
  923. /**
  924. * @hidden
  925. * Utility class for generating glTF animation data from BabylonJS.
  926. */
  927. export class _GLTFAnimation {
  928. /**
  929. * @ignore
  930. *
  931. * Creates glTF channel animation from BabylonJS animation.
  932. * @param babylonTransformNode - BabylonJS mesh.
  933. * @param animation - animation.
  934. * @param animationChannelTargetPath - The target animation channel.
  935. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  936. * @param useQuaternion - Specifies if quaternions are used.
  937. * @returns nullable IAnimationData
  938. */
  939. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  940. private static _DeduceAnimationInfo;
  941. /**
  942. * @ignore
  943. * Create node animations from the transform node animations
  944. * @param babylonNode
  945. * @param runtimeGLTFAnimation
  946. * @param idleGLTFAnimations
  947. * @param nodeMap
  948. * @param nodes
  949. * @param binaryWriter
  950. * @param bufferViews
  951. * @param accessors
  952. * @param convertToRightHandedSystem
  953. * @param animationSampleRate
  954. */
  955. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  956. [key: number]: number;
  957. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  958. /**
  959. * @ignore
  960. * Create node animations from the animation groups
  961. * @param babylonScene
  962. * @param glTFAnimations
  963. * @param nodeMap
  964. * @param nodes
  965. * @param binaryWriter
  966. * @param bufferViews
  967. * @param accessors
  968. * @param convertToRightHandedSystemMap
  969. * @param animationSampleRate
  970. */
  971. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  972. [key: number]: number;
  973. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  974. [nodeId: number]: boolean;
  975. }, animationSampleRate: number): void;
  976. private static AddAnimation;
  977. /**
  978. * Create a baked animation
  979. * @param babylonTransformNode BabylonJS mesh
  980. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  981. * @param animationChannelTargetPath animation target channel
  982. * @param minFrame minimum animation frame
  983. * @param maxFrame maximum animation frame
  984. * @param fps frames per second of the animation
  985. * @param inputs input key frames of the animation
  986. * @param outputs output key frame data of the animation
  987. * @param convertToRightHandedSystem converts the values to right-handed
  988. * @param useQuaternion specifies if quaternions should be used
  989. */
  990. private static _CreateBakedAnimation;
  991. private static _ConvertFactorToVector3OrQuaternion;
  992. private static _SetInterpolatedValue;
  993. /**
  994. * Creates linear animation from the animation key frames
  995. * @param babylonTransformNode BabylonJS mesh
  996. * @param animation BabylonJS animation
  997. * @param animationChannelTargetPath The target animation channel
  998. * @param frameDelta The difference between the last and first frame of the animation
  999. * @param inputs Array to store the key frame times
  1000. * @param outputs Array to store the key frame data
  1001. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  1002. * @param useQuaternion Specifies if quaternions are used in the animation
  1003. */
  1004. private static _CreateLinearOrStepAnimation;
  1005. /**
  1006. * Creates cubic spline animation from the animation key frames
  1007. * @param babylonTransformNode BabylonJS mesh
  1008. * @param animation BabylonJS animation
  1009. * @param animationChannelTargetPath The target animation channel
  1010. * @param frameDelta The difference between the last and first frame of the animation
  1011. * @param inputs Array to store the key frame times
  1012. * @param outputs Array to store the key frame data
  1013. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  1014. * @param useQuaternion Specifies if quaternions are used in the animation
  1015. */
  1016. private static _CreateCubicSplineAnimation;
  1017. private static _GetBasePositionRotationOrScale;
  1018. /**
  1019. * Adds a key frame value
  1020. * @param keyFrame
  1021. * @param animation
  1022. * @param outputs
  1023. * @param animationChannelTargetPath
  1024. * @param basePositionRotationOrScale
  1025. * @param convertToRightHandedSystem
  1026. * @param useQuaternion
  1027. */
  1028. private static _AddKeyframeValue;
  1029. /**
  1030. * Determine the interpolation based on the key frames
  1031. * @param keyFrames
  1032. * @param animationChannelTargetPath
  1033. * @param useQuaternion
  1034. */
  1035. private static _DeduceInterpolation;
  1036. /**
  1037. * Adds an input tangent or output tangent to the output data
  1038. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  1039. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  1040. * @param outputs The animation data by keyframe
  1041. * @param animationChannelTargetPath The target animation channel
  1042. * @param interpolation The interpolation type
  1043. * @param keyFrame The key frame with the animation data
  1044. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  1045. * @param useQuaternion Specifies if quaternions are used
  1046. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  1047. */
  1048. private static AddSplineTangent;
  1049. /**
  1050. * Get the minimum and maximum key frames' frame values
  1051. * @param keyFrames animation key frames
  1052. * @returns the minimum and maximum key frame value
  1053. */
  1054. private static calculateMinMaxKeyFrames;
  1055. }
  1056. }
  1057. declare module BABYLON.GLTF2.Exporter {
  1058. /** @hidden */
  1059. export var textureTransformPixelShader: {
  1060. name: string;
  1061. shader: string;
  1062. };
  1063. }
  1064. declare module BABYLON.GLTF2.Exporter.Extensions {
  1065. /**
  1066. * @hidden
  1067. */
  1068. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  1069. private _recordedTextures;
  1070. /** Name of this extension */
  1071. readonly name: string;
  1072. /** Defines whether this extension is enabled */
  1073. enabled: boolean;
  1074. /** Defines whether this extension is required */
  1075. required: boolean;
  1076. /** Reference to the glTF exporter */
  1077. private _wasUsed;
  1078. constructor(exporter: _Exporter);
  1079. dispose(): void;
  1080. /** @hidden */
  1081. get wasUsed(): boolean;
  1082. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  1083. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  1084. /**
  1085. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  1086. * @param babylonTexture
  1087. * @param offset
  1088. * @param rotation
  1089. * @param scale
  1090. * @param scene
  1091. */
  1092. private _textureTransformTextureAsync;
  1093. }
  1094. }
  1095. declare module BABYLON.GLTF2.Exporter.Extensions {
  1096. /**
  1097. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  1098. */
  1099. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  1100. /** The name of this extension. */
  1101. readonly name: string;
  1102. /** Defines whether this extension is enabled. */
  1103. enabled: boolean;
  1104. /** Defines whether this extension is required */
  1105. required: boolean;
  1106. /** Reference to the glTF exporter */
  1107. private _exporter;
  1108. private _lights;
  1109. /** @hidden */
  1110. constructor(exporter: _Exporter);
  1111. /** @hidden */
  1112. dispose(): void;
  1113. /** @hidden */
  1114. get wasUsed(): boolean;
  1115. /** @hidden */
  1116. onExporting(): void;
  1117. /**
  1118. * Define this method to modify the default behavior when exporting a node
  1119. * @param context The context when exporting the node
  1120. * @param node glTF node
  1121. * @param babylonNode BabylonJS node
  1122. * @returns nullable INode promise
  1123. */
  1124. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  1125. }
  1126. }
  1127. declare module BABYLON.GLTF2.Exporter.Extensions {
  1128. /**
  1129. * @hidden
  1130. */
  1131. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  1132. /** Name of this extension */
  1133. readonly name: string;
  1134. /** Defines whether this extension is enabled */
  1135. enabled: boolean;
  1136. /** Defines whether this extension is required */
  1137. required: boolean;
  1138. /** Reference to the glTF exporter */
  1139. private _textureInfos;
  1140. private _exportedTextures;
  1141. private _wasUsed;
  1142. constructor(exporter: _Exporter);
  1143. dispose(): void;
  1144. /** @hidden */
  1145. get wasUsed(): boolean;
  1146. private _getTextureIndex;
  1147. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  1148. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  1149. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  1150. }
  1151. }
  1152. declare module BABYLON {
  1153. /**
  1154. * Class for generating STL data from a Babylon scene.
  1155. */
  1156. export class STLExport {
  1157. /**
  1158. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  1159. * @param meshes list defines the mesh to serialize
  1160. * @param download triggers the automatic download of the file.
  1161. * @param fileName changes the downloads fileName.
  1162. * @param binary changes the STL to a binary type.
  1163. * @param isLittleEndian toggle for binary type exporter.
  1164. * @returns the STL as UTF8 string
  1165. */
  1166. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  1167. }
  1168. }