babylonjs.serializers.d.ts 54 KB

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