babylonjs.serializers.d.ts 56 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  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. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  503. }
  504. }
  505. declare module BABYLON.GLTF2.Exporter {
  506. /**
  507. * Converts Babylon Scene into glTF 2.0.
  508. * @hidden
  509. */
  510. export class _Exporter {
  511. /**
  512. * Stores the glTF to export
  513. */
  514. _glTF: IGLTF;
  515. /**
  516. * Stores all generated buffer views, which represents views into the main glTF buffer data
  517. */
  518. _bufferViews: IBufferView[];
  519. /**
  520. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  521. */
  522. _accessors: IAccessor[];
  523. /**
  524. * Stores all the generated nodes, which contains transform and/or mesh information per node
  525. */
  526. _nodes: INode[];
  527. /**
  528. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  529. */
  530. private _scenes;
  531. /**
  532. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  533. */
  534. private _meshes;
  535. /**
  536. * Stores all the generated material information, which represents the appearance of each primitive
  537. */
  538. _materials: IMaterial[];
  539. _materialMap: {
  540. [materialID: number]: number;
  541. };
  542. /**
  543. * Stores all the generated texture information, which is referenced by glTF materials
  544. */
  545. _textures: ITexture[];
  546. /**
  547. * Stores all the generated image information, which is referenced by glTF textures
  548. */
  549. _images: IImage[];
  550. /**
  551. * Stores all the texture samplers
  552. */
  553. _samplers: ISampler[];
  554. /**
  555. * Stores all the generated glTF skins
  556. */
  557. _skins: ISkin[];
  558. /**
  559. * Stores all the generated animation samplers, which is referenced by glTF animations
  560. */
  561. /**
  562. * Stores the animations for glTF models
  563. */
  564. private _animations;
  565. /**
  566. * Stores the total amount of bytes stored in the glTF buffer
  567. */
  568. private _totalByteLength;
  569. /**
  570. * Stores a reference to the Babylon scene containing the source geometry and material information
  571. */
  572. _babylonScene: Scene;
  573. /**
  574. * Stores a map of the image data, where the key is the file name and the value
  575. * is the image data
  576. */
  577. _imageData: {
  578. [fileName: string]: {
  579. data: Uint8Array;
  580. mimeType: ImageMimeType;
  581. };
  582. };
  583. /**
  584. * Stores a map of the unique id of a node to its index in the node array
  585. */
  586. _nodeMap: {
  587. [key: number]: number;
  588. };
  589. /**
  590. * Specifies if the source Babylon scene was left handed, and needed conversion.
  591. */
  592. _convertToRightHandedSystem: boolean;
  593. /**
  594. * Specifies if a Babylon node should be converted to right-handed on export
  595. */
  596. _convertToRightHandedSystemMap: {
  597. [nodeId: number]: boolean;
  598. };
  599. _includeCoordinateSystemConversionNodes: boolean;
  600. /**
  601. * Baked animation sample rate
  602. */
  603. private _animationSampleRate;
  604. private _options;
  605. private _localEngine;
  606. _glTFMaterialExporter: _GLTFMaterialExporter;
  607. private _extensions;
  608. private static _ExtensionNames;
  609. private static _ExtensionFactories;
  610. private _applyExtension;
  611. private _applyExtensions;
  612. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  613. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  614. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  615. [key: number]: number;
  616. }): Promise<Nullable<INode>>;
  617. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  618. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  619. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  620. private _forEachExtensions;
  621. private _extensionsOnExporting;
  622. /**
  623. * Load glTF serializer extensions
  624. */
  625. private _loadExtensions;
  626. /**
  627. * Creates a glTF Exporter instance, which can accept optional exporter options
  628. * @param babylonScene Babylon scene object
  629. * @param options Options to modify the behavior of the exporter
  630. */
  631. constructor(babylonScene: Scene, options?: IExportOptions);
  632. dispose(): void;
  633. /**
  634. * Registers a glTF exporter extension
  635. * @param name Name of the extension to export
  636. * @param factory The factory function that creates the exporter extension
  637. */
  638. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  639. /**
  640. * Un-registers an exporter extension
  641. * @param name The name fo the exporter extension
  642. * @returns A boolean indicating whether the extension has been un-registered
  643. */
  644. static UnregisterExtension(name: string): boolean;
  645. /**
  646. * Lazy load a local engine
  647. */
  648. _getLocalEngine(): Engine;
  649. private reorderIndicesBasedOnPrimitiveMode;
  650. /**
  651. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  652. * clock-wise during export to glTF
  653. * @param submesh BabylonJS submesh
  654. * @param primitiveMode Primitive mode of the mesh
  655. * @param sideOrientation the winding order of the submesh
  656. * @param vertexBufferKind The type of vertex attribute
  657. * @param meshAttributeArray The vertex attribute data
  658. * @param byteOffset The offset to the binary data
  659. * @param binaryWriter The binary data for the glTF file
  660. * @param convertToRightHandedSystem Converts the values to right-handed
  661. */
  662. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  663. /**
  664. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  665. * clock-wise during export to glTF
  666. * @param submesh BabylonJS submesh
  667. * @param primitiveMode Primitive mode of the mesh
  668. * @param sideOrientation the winding order of the submesh
  669. * @param vertexBufferKind The type of vertex attribute
  670. * @param meshAttributeArray The vertex attribute data
  671. * @param byteOffset The offset to the binary data
  672. * @param binaryWriter The binary data for the glTF file
  673. * @param convertToRightHandedSystem Converts the values to right-handed
  674. */
  675. private reorderTriangleFillMode;
  676. /**
  677. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  678. * clock-wise during export to glTF
  679. * @param submesh BabylonJS submesh
  680. * @param primitiveMode Primitive mode of the mesh
  681. * @param sideOrientation the winding order of the submesh
  682. * @param vertexBufferKind The type of vertex attribute
  683. * @param meshAttributeArray The vertex attribute data
  684. * @param byteOffset The offset to the binary data
  685. * @param binaryWriter The binary data for the glTF file
  686. * @param convertToRightHandedSystem Converts the values to right-handed
  687. */
  688. private reorderTriangleStripDrawMode;
  689. /**
  690. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  691. * clock-wise during export to glTF
  692. * @param submesh BabylonJS submesh
  693. * @param primitiveMode Primitive mode of the mesh
  694. * @param sideOrientation the winding order of the submesh
  695. * @param vertexBufferKind The type of vertex attribute
  696. * @param meshAttributeArray The vertex attribute data
  697. * @param byteOffset The offset to the binary data
  698. * @param binaryWriter The binary data for the glTF file
  699. * @param convertToRightHandedSystem Converts the values to right-handed
  700. */
  701. private reorderTriangleFanMode;
  702. /**
  703. * Writes the vertex attribute data to binary
  704. * @param vertices The vertices to write to the binary writer
  705. * @param byteOffset The offset into the binary writer to overwrite binary data
  706. * @param vertexAttributeKind The vertex attribute type
  707. * @param meshAttributeArray The vertex attribute data
  708. * @param binaryWriter The writer containing the binary data
  709. * @param convertToRightHandedSystem Converts the values to right-handed
  710. */
  711. private writeVertexAttributeData;
  712. /**
  713. * Writes mesh attribute data to a data buffer
  714. * Returns the bytelength of the data
  715. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  716. * @param meshAttributeArray Array containing the attribute data
  717. * @param byteStride Specifies the space between data
  718. * @param binaryWriter The buffer to write the binary data to
  719. * @param convertToRightHandedSystem Converts the values to right-handed
  720. */
  721. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  722. /**
  723. * Writes mesh attribute data to a data buffer
  724. * Returns the bytelength of the data
  725. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  726. * @param meshAttributeArray Array containing the attribute data
  727. * @param byteStride Specifies the space between data
  728. * @param binaryWriter The buffer to write the binary data to
  729. * @param convertToRightHandedSystem Converts the values to right-handed
  730. */
  731. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  732. /**
  733. * Generates glTF json data
  734. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  735. * @param glTFPrefix Text to use when prefixing a glTF file
  736. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  737. * @returns json data as string
  738. */
  739. private generateJSON;
  740. /**
  741. * Generates data for .gltf and .bin files based on the glTF prefix string
  742. * @param glTFPrefix Text to use when prefixing a glTF file
  743. * @param dispose Dispose the exporter
  744. * @returns GLTFData with glTF file data
  745. */
  746. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  747. /**
  748. * Creates a binary buffer for glTF
  749. * @returns array buffer for binary data
  750. */
  751. private _generateBinaryAsync;
  752. /**
  753. * Pads the number to a multiple of 4
  754. * @param num number to pad
  755. * @returns padded number
  756. */
  757. private _getPadding;
  758. /**
  759. * @hidden
  760. */
  761. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  762. /**
  763. * Sets the TRS for each node
  764. * @param node glTF Node for storing the transformation data
  765. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  766. * @param convertToRightHandedSystem Converts the values to right-handed
  767. */
  768. private setNodeTransformation;
  769. private getVertexBufferFromMesh;
  770. /**
  771. * Creates a bufferview based on the vertices type for the Babylon mesh
  772. * @param kind Indicates the type of vertices data
  773. * @param componentType Indicates the numerical type used to store the data
  774. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  775. * @param binaryWriter The buffer to write the bufferview data to
  776. * @param convertToRightHandedSystem Converts the values to right-handed
  777. */
  778. private createBufferViewKind;
  779. /**
  780. * Creates a bufferview based on the vertices type for the Babylon mesh
  781. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  782. * @param babylonMorphTarget the morph target to be exported
  783. * @param binaryWriter The buffer to write the bufferview data to
  784. * @param convertToRightHandedSystem Converts the values to right-handed
  785. */
  786. private setMorphTargetAttributes;
  787. /**
  788. * The primitive mode of the Babylon mesh
  789. * @param babylonMesh The BabylonJS mesh
  790. */
  791. private getMeshPrimitiveMode;
  792. /**
  793. * Sets the primitive mode of the glTF mesh primitive
  794. * @param meshPrimitive glTF mesh primitive
  795. * @param primitiveMode The primitive mode
  796. */
  797. private setPrimitiveMode;
  798. /**
  799. * Sets the vertex attribute accessor based of the glTF mesh primitive
  800. * @param meshPrimitive glTF mesh primitive
  801. * @param attributeKind vertex attribute
  802. * @returns boolean specifying if uv coordinates are present
  803. */
  804. private setAttributeKind;
  805. /**
  806. * Sets data for the primitive attributes of each submesh
  807. * @param mesh glTF Mesh object to store the primitive attribute information
  808. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  809. * @param binaryWriter Buffer to write the attribute data to
  810. * @param convertToRightHandedSystem Converts the values to right-handed
  811. */
  812. private setPrimitiveAttributesAsync;
  813. /**
  814. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  815. * @param node The node to check
  816. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  817. */
  818. private isBabylonCoordinateSystemConvertingNode;
  819. /**
  820. * Creates a glTF scene based on the array of meshes
  821. * Returns the the total byte offset
  822. * @param babylonScene Babylon scene to get the mesh data from
  823. * @param binaryWriter Buffer to write binary data to
  824. */
  825. private createSceneAsync;
  826. /**
  827. * Creates a mapping of Node unique id to node index and handles animations
  828. * @param babylonScene Babylon Scene
  829. * @param nodes Babylon transform nodes
  830. * @param binaryWriter Buffer to write binary data to
  831. * @returns Node mapping of unique id to index
  832. */
  833. private createNodeMapAndAnimationsAsync;
  834. /**
  835. * Creates a glTF node from a Babylon mesh
  836. * @param babylonMesh Source Babylon mesh
  837. * @param binaryWriter Buffer for storing geometry data
  838. * @param convertToRightHandedSystem Converts the values to right-handed
  839. * @param nodeMap Node mapping of unique id to glTF node index
  840. * @returns glTF node
  841. */
  842. private createNodeAsync;
  843. /**
  844. * Creates a glTF skin from a Babylon skeleton
  845. * @param babylonScene Babylon Scene
  846. * @param nodes Babylon transform nodes
  847. * @param binaryWriter Buffer to write binary data to
  848. * @returns Node mapping of unique id to index
  849. */
  850. private createSkinsAsync;
  851. }
  852. /**
  853. * @hidden
  854. *
  855. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  856. */
  857. export class _BinaryWriter {
  858. /**
  859. * Array buffer which stores all binary data
  860. */
  861. private _arrayBuffer;
  862. /**
  863. * View of the array buffer
  864. */
  865. private _dataView;
  866. /**
  867. * byte offset of data in array buffer
  868. */
  869. private _byteOffset;
  870. /**
  871. * Initialize binary writer with an initial byte length
  872. * @param byteLength Initial byte length of the array buffer
  873. */
  874. constructor(byteLength: number);
  875. /**
  876. * Resize the array buffer to the specified byte length
  877. * @param byteLength
  878. */
  879. private resizeBuffer;
  880. /**
  881. * Get an array buffer with the length of the byte offset
  882. * @returns ArrayBuffer resized to the byte offset
  883. */
  884. getArrayBuffer(): ArrayBuffer;
  885. /**
  886. * Get the byte offset of the array buffer
  887. * @returns byte offset
  888. */
  889. getByteOffset(): number;
  890. /**
  891. * Stores an UInt8 in the array buffer
  892. * @param entry
  893. * @param byteOffset If defined, specifies where to set the value as an offset.
  894. */
  895. setUInt8(entry: number, byteOffset?: number): void;
  896. /**
  897. * Stores an UInt16 in the array buffer
  898. * @param entry
  899. * @param byteOffset If defined, specifies where to set the value as an offset.
  900. */
  901. setUInt16(entry: number, byteOffset?: number): void;
  902. /**
  903. * Gets an UInt32 in the array buffer
  904. * @param entry
  905. * @param byteOffset If defined, specifies where to set the value as an offset.
  906. */
  907. getUInt32(byteOffset: number): number;
  908. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  909. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  910. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  911. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  912. /**
  913. * Stores a Float32 in the array buffer
  914. * @param entry
  915. */
  916. setFloat32(entry: number, byteOffset?: number): void;
  917. /**
  918. * Stores an UInt32 in the array buffer
  919. * @param entry
  920. * @param byteOffset If defined, specifies where to set the value as an offset.
  921. */
  922. setUInt32(entry: number, byteOffset?: number): void;
  923. }
  924. }
  925. declare module BABYLON.GLTF2.Exporter {
  926. /**
  927. * @hidden
  928. * Interface to store animation data.
  929. */
  930. export interface _IAnimationData {
  931. /**
  932. * Keyframe data.
  933. */
  934. inputs: number[];
  935. /**
  936. * Value data.
  937. */
  938. outputs: number[][];
  939. /**
  940. * Animation interpolation data.
  941. */
  942. samplerInterpolation: AnimationSamplerInterpolation;
  943. /**
  944. * Minimum keyframe value.
  945. */
  946. inputsMin: number;
  947. /**
  948. * Maximum keyframe value.
  949. */
  950. inputsMax: number;
  951. }
  952. /**
  953. * @hidden
  954. */
  955. export interface _IAnimationInfo {
  956. /**
  957. * The target channel for the animation
  958. */
  959. animationChannelTargetPath: AnimationChannelTargetPath;
  960. /**
  961. * The glTF accessor type for the data.
  962. */
  963. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  964. /**
  965. * Specifies if quaternions should be used.
  966. */
  967. useQuaternion: boolean;
  968. }
  969. /**
  970. * @hidden
  971. * Utility class for generating glTF animation data from BabylonJS.
  972. */
  973. export class _GLTFAnimation {
  974. /**
  975. * @ignore
  976. *
  977. * Creates glTF channel animation from BabylonJS animation.
  978. * @param babylonTransformNode - BabylonJS mesh.
  979. * @param animation - animation.
  980. * @param animationChannelTargetPath - The target animation channel.
  981. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  982. * @param useQuaternion - Specifies if quaternions are used.
  983. * @returns nullable IAnimationData
  984. */
  985. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  986. private static _DeduceAnimationInfo;
  987. /**
  988. * @ignore
  989. * Create node animations from the transform node animations
  990. * @param babylonNode
  991. * @param runtimeGLTFAnimation
  992. * @param idleGLTFAnimations
  993. * @param nodeMap
  994. * @param nodes
  995. * @param binaryWriter
  996. * @param bufferViews
  997. * @param accessors
  998. * @param convertToRightHandedSystem
  999. * @param animationSampleRate
  1000. */
  1001. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  1002. [key: number]: number;
  1003. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  1004. /**
  1005. * @ignore
  1006. * Create individual morph animations from the mesh's morph target animation tracks
  1007. * @param babylonNode
  1008. * @param runtimeGLTFAnimation
  1009. * @param idleGLTFAnimations
  1010. * @param nodeMap
  1011. * @param nodes
  1012. * @param binaryWriter
  1013. * @param bufferViews
  1014. * @param accessors
  1015. * @param convertToRightHandedSystem
  1016. * @param animationSampleRate
  1017. */
  1018. static _CreateMorphTargetAnimationFromMorphTargets(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  1019. [key: number]: number;
  1020. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  1021. /**
  1022. * @ignore
  1023. * Create node and morph animations from the animation groups
  1024. * @param babylonScene
  1025. * @param glTFAnimations
  1026. * @param nodeMap
  1027. * @param nodes
  1028. * @param binaryWriter
  1029. * @param bufferViews
  1030. * @param accessors
  1031. * @param convertToRightHandedSystemMap
  1032. * @param animationSampleRate
  1033. */
  1034. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  1035. [key: number]: number;
  1036. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  1037. [nodeId: number]: boolean;
  1038. }, animationSampleRate: number): void;
  1039. private static AddAnimation;
  1040. /**
  1041. * Create a baked animation
  1042. * @param babylonTransformNode BabylonJS mesh
  1043. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  1044. * @param animationChannelTargetPath animation target channel
  1045. * @param minFrame minimum animation frame
  1046. * @param maxFrame maximum animation frame
  1047. * @param fps frames per second of the animation
  1048. * @param inputs input key frames of the animation
  1049. * @param outputs output key frame data of the animation
  1050. * @param convertToRightHandedSystem converts the values to right-handed
  1051. * @param useQuaternion specifies if quaternions should be used
  1052. */
  1053. private static _CreateBakedAnimation;
  1054. private static _ConvertFactorToVector3OrQuaternion;
  1055. private static _SetInterpolatedValue;
  1056. /**
  1057. * Creates linear animation from the animation key frames
  1058. * @param babylonTransformNode BabylonJS mesh
  1059. * @param animation BabylonJS animation
  1060. * @param animationChannelTargetPath The target animation channel
  1061. * @param frameDelta The difference between the last and first frame of the animation
  1062. * @param inputs Array to store the key frame times
  1063. * @param outputs Array to store the key frame data
  1064. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  1065. * @param useQuaternion Specifies if quaternions are used in the animation
  1066. */
  1067. private static _CreateLinearOrStepAnimation;
  1068. /**
  1069. * Creates cubic spline animation from the animation key frames
  1070. * @param babylonTransformNode BabylonJS mesh
  1071. * @param animation BabylonJS animation
  1072. * @param animationChannelTargetPath The target animation channel
  1073. * @param frameDelta The difference between the last and first frame of the animation
  1074. * @param inputs Array to store the key frame times
  1075. * @param outputs Array to store the key frame data
  1076. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  1077. * @param useQuaternion Specifies if quaternions are used in the animation
  1078. */
  1079. private static _CreateCubicSplineAnimation;
  1080. private static _GetBasePositionRotationOrScale;
  1081. /**
  1082. * Adds a key frame value
  1083. * @param keyFrame
  1084. * @param animation
  1085. * @param outputs
  1086. * @param animationChannelTargetPath
  1087. * @param basePositionRotationOrScale
  1088. * @param convertToRightHandedSystem
  1089. * @param useQuaternion
  1090. */
  1091. private static _AddKeyframeValue;
  1092. /**
  1093. * Determine the interpolation based on the key frames
  1094. * @param keyFrames
  1095. * @param animationChannelTargetPath
  1096. * @param useQuaternion
  1097. */
  1098. private static _DeduceInterpolation;
  1099. /**
  1100. * Adds an input tangent or output tangent to the output data
  1101. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  1102. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  1103. * @param outputs The animation data by keyframe
  1104. * @param animationChannelTargetPath The target animation channel
  1105. * @param interpolation The interpolation type
  1106. * @param keyFrame The key frame with the animation data
  1107. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  1108. * @param useQuaternion Specifies if quaternions are used
  1109. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  1110. */
  1111. private static AddSplineTangent;
  1112. /**
  1113. * Get the minimum and maximum key frames' frame values
  1114. * @param keyFrames animation key frames
  1115. * @returns the minimum and maximum key frame value
  1116. */
  1117. private static calculateMinMaxKeyFrames;
  1118. }
  1119. }
  1120. declare module BABYLON.GLTF2.Exporter {
  1121. /** @hidden */
  1122. export var textureTransformPixelShader: {
  1123. name: string;
  1124. shader: string;
  1125. };
  1126. }
  1127. declare module BABYLON.GLTF2.Exporter.Extensions {
  1128. /**
  1129. * @hidden
  1130. */
  1131. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  1132. private _recordedTextures;
  1133. /** Name of this extension */
  1134. readonly name: string;
  1135. /** Defines whether this extension is enabled */
  1136. enabled: boolean;
  1137. /** Defines whether this extension is required */
  1138. required: boolean;
  1139. /** Reference to the glTF exporter */
  1140. private _wasUsed;
  1141. constructor(exporter: _Exporter);
  1142. dispose(): void;
  1143. /** @hidden */
  1144. get wasUsed(): boolean;
  1145. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  1146. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  1147. /**
  1148. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  1149. * @param babylonTexture
  1150. * @param offset
  1151. * @param rotation
  1152. * @param scale
  1153. * @param scene
  1154. */
  1155. private _textureTransformTextureAsync;
  1156. }
  1157. }
  1158. declare module BABYLON.GLTF2.Exporter.Extensions {
  1159. /**
  1160. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  1161. */
  1162. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  1163. /** The name of this extension. */
  1164. readonly name: string;
  1165. /** Defines whether this extension is enabled. */
  1166. enabled: boolean;
  1167. /** Defines whether this extension is required */
  1168. required: boolean;
  1169. /** Reference to the glTF exporter */
  1170. private _exporter;
  1171. private _lights;
  1172. /** @hidden */
  1173. constructor(exporter: _Exporter);
  1174. /** @hidden */
  1175. dispose(): void;
  1176. /** @hidden */
  1177. get wasUsed(): boolean;
  1178. /** @hidden */
  1179. onExporting(): void;
  1180. /**
  1181. * Define this method to modify the default behavior when exporting a node
  1182. * @param context The context when exporting the node
  1183. * @param node glTF node
  1184. * @param babylonNode BabylonJS node
  1185. * @param nodeMap Node mapping of unique id to glTF node index
  1186. * @returns nullable INode promise
  1187. */
  1188. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  1189. [key: number]: number;
  1190. }): Promise<Nullable<INode>>;
  1191. }
  1192. }
  1193. declare module BABYLON.GLTF2.Exporter.Extensions {
  1194. /**
  1195. * @hidden
  1196. */
  1197. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  1198. /** Name of this extension */
  1199. readonly name: string;
  1200. /** Defines whether this extension is enabled */
  1201. enabled: boolean;
  1202. /** Defines whether this extension is required */
  1203. required: boolean;
  1204. /** Reference to the glTF exporter */
  1205. private _textureInfos;
  1206. private _exportedTextures;
  1207. private _wasUsed;
  1208. constructor(exporter: _Exporter);
  1209. dispose(): void;
  1210. /** @hidden */
  1211. get wasUsed(): boolean;
  1212. private _getTextureIndex;
  1213. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  1214. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  1215. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  1216. }
  1217. }
  1218. declare module BABYLON.GLTF2.Exporter.Extensions {
  1219. /**
  1220. * @hidden
  1221. */
  1222. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  1223. /** Name of this extension */
  1224. readonly name: string;
  1225. /** Defines whether this extension is enabled */
  1226. enabled: boolean;
  1227. /** Defines whether this extension is required */
  1228. required: boolean;
  1229. private _wasUsed;
  1230. constructor(exporter: _Exporter);
  1231. /** @hidden */
  1232. get wasUsed(): boolean;
  1233. dispose(): void;
  1234. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  1235. }
  1236. }
  1237. declare module BABYLON {
  1238. /**
  1239. * Class for generating STL data from a Babylon scene.
  1240. */
  1241. export class STLExport {
  1242. /**
  1243. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  1244. * @param meshes list defines the mesh to serialize
  1245. * @param download triggers the automatic download of the file.
  1246. * @param fileName changes the downloads fileName.
  1247. * @param binary changes the STL to a binary type.
  1248. * @param isLittleEndian toggle for binary type exporter.
  1249. * @returns the STL as UTF8 string
  1250. */
  1251. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  1252. }
  1253. }