babylonjs.serializers.module.d.ts 121 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626
  1. declare module "babylonjs-serializers/OBJ/objSerializer" {
  2. import { Mesh } from "babylonjs/Meshes/mesh";
  3. /**
  4. * Class for generating OBJ data from a Babylon scene.
  5. */
  6. export class OBJExport {
  7. /**
  8. * Exports the geometry of a Mesh array in .OBJ file format (text)
  9. * @param mesh defines the list of meshes to serialize
  10. * @param materials defines if materials should be exported
  11. * @param matlibname defines the name of the associated mtl file
  12. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  13. * @returns the OBJ content
  14. */
  15. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  16. /**
  17. * Exports the material(s) of a mesh in .MTL file format (text)
  18. * @param mesh defines the mesh to extract the material from
  19. * @returns the mtl content
  20. */
  21. static MTL(mesh: Mesh): string;
  22. }
  23. }
  24. declare module "babylonjs-serializers/OBJ/index" {
  25. export * from "babylonjs-serializers/OBJ/objSerializer";
  26. }
  27. declare module "babylonjs-serializers/glTF/glTFFileExporter" {
  28. /** @hidden */
  29. export var __IGLTFExporterExtension: number;
  30. /**
  31. * Interface for extending the exporter
  32. * @hidden
  33. */
  34. export interface IGLTFExporterExtension {
  35. /**
  36. * The name of this extension
  37. */
  38. readonly name: string;
  39. /**
  40. * Defines whether this extension is enabled
  41. */
  42. enabled: boolean;
  43. /**
  44. * Defines whether this extension is required
  45. */
  46. required: boolean;
  47. }
  48. }
  49. declare module "babylonjs-serializers/glTF/2.0/glTFExporterExtension" {
  50. import { ImageMimeType, IMeshPrimitive, INode, IMaterial, ITextureInfo } from "babylonjs-gltf2interface";
  51. import { Node } from "babylonjs/node";
  52. import { Nullable } from "babylonjs/types";
  53. import { Texture } from "babylonjs/Materials/Textures/texture";
  54. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55. import { IDisposable } from "babylonjs/scene";
  56. import { _BinaryWriter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
  57. import { IGLTFExporterExtension } from "babylonjs-serializers/glTF/glTFFileExporter";
  58. import { Material } from 'babylonjs/Materials/material';
  59. import { BaseTexture } from 'babylonjs/Materials/Textures/baseTexture';
  60. /** @hidden */
  61. export var __IGLTFExporterExtensionV2: number;
  62. /**
  63. * Interface for a glTF exporter extension
  64. * @hidden
  65. */
  66. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  67. /**
  68. * Define this method to modify the default behavior before exporting a texture
  69. * @param context The context when loading the asset
  70. * @param babylonTexture The Babylon.js texture
  71. * @param mimeType The mime-type of the generated image
  72. * @returns A promise that resolves with the exported texture
  73. */
  74. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  75. /**
  76. * Define this method to get notified when a texture info is created
  77. * @param context The context when loading the asset
  78. * @param textureInfo The glTF texture info
  79. * @param babylonTexture The Babylon.js texture
  80. */
  81. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82. /**
  83. * Define this method to modify the default behavior when exporting texture info
  84. * @param context The context when loading the asset
  85. * @param meshPrimitive glTF mesh primitive
  86. * @param babylonSubMesh Babylon submesh
  87. * @param binaryWriter glTF serializer binary writer instance
  88. * @returns nullable IMeshPrimitive promise
  89. */
  90. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  91. /**
  92. * Define this method to modify the default behavior when exporting a node
  93. * @param context The context when exporting the node
  94. * @param node glTF node
  95. * @param babylonNode BabylonJS node
  96. * @returns nullable INode promise
  97. */
  98. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  99. [key: number]: number;
  100. }): Promise<Nullable<INode>>;
  101. /**
  102. * Define this method to modify the default behavior when exporting a material
  103. * @param material glTF material
  104. * @param babylonMaterial BabylonJS material
  105. * @returns nullable IMaterial promise
  106. */
  107. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  108. /**
  109. * Define this method to return additional textures to export from a material
  110. * @param material glTF material
  111. * @param babylonMaterial BabylonJS material
  112. * @returns List of textures
  113. */
  114. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  115. /** Gets a boolean indicating that this extension was used */
  116. wasUsed: boolean;
  117. /** Gets a boolean indicating that this extension is required for the file to work */
  118. required: boolean;
  119. /**
  120. * Called after the exporter state changes to EXPORTING
  121. */
  122. onExporting?(): void;
  123. }
  124. }
  125. declare module "babylonjs-serializers/glTF/2.0/glTFMaterialExporter" {
  126. import { ITextureInfo, ImageMimeType, IMaterial, IMaterialPbrMetallicRoughness } from "babylonjs-gltf2interface";
  127. import { Nullable } from "babylonjs/types";
  128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  129. import { Material } from "babylonjs/Materials/material";
  130. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  131. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  132. import { PBRMetallicRoughnessMaterial } from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  133. import { _Exporter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
  134. /**
  135. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  136. * @hidden
  137. */
  138. export class _GLTFMaterialExporter {
  139. /**
  140. * Represents the dielectric specular values for R, G and B
  141. */
  142. private static readonly _DielectricSpecular;
  143. /**
  144. * Allows the maximum specular power to be defined for material calculations
  145. */
  146. private static readonly _MaxSpecularPower;
  147. /**
  148. * Mapping to store textures
  149. */
  150. private _textureMap;
  151. /**
  152. * Numeric tolerance value
  153. */
  154. private static readonly _Epsilon;
  155. /**
  156. * Reference to the glTF Exporter
  157. */
  158. private _exporter;
  159. constructor(exporter: _Exporter);
  160. /**
  161. * Specifies if two colors are approximately equal in value
  162. * @param color1 first color to compare to
  163. * @param color2 second color to compare to
  164. * @param epsilon threshold value
  165. */
  166. private static FuzzyEquals;
  167. /**
  168. * Gets the materials from a Babylon scene and converts them to glTF materials
  169. * @param scene babylonjs scene
  170. * @param mimeType texture mime type
  171. * @param images array of images
  172. * @param textures array of textures
  173. * @param materials array of materials
  174. * @param imageData mapping of texture names to base64 textures
  175. * @param hasTextureCoords specifies if texture coordinates are present on the material
  176. */
  177. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  178. /**
  179. * Makes a copy of the glTF material without the texture parameters
  180. * @param originalMaterial original glTF material
  181. * @returns glTF material without texture parameters
  182. */
  183. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  184. /**
  185. * Specifies if the material has any texture parameters present
  186. * @param material glTF Material
  187. * @returns boolean specifying if texture parameters are present
  188. */
  189. _hasTexturesPresent(material: IMaterial): boolean;
  190. /**
  191. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  192. * @param babylonStandardMaterial
  193. * @returns glTF Metallic Roughness Material representation
  194. */
  195. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  196. /**
  197. * Computes the metallic factor
  198. * @param diffuse diffused value
  199. * @param specular specular value
  200. * @param oneMinusSpecularStrength one minus the specular strength
  201. * @returns metallic value
  202. */
  203. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  204. /**
  205. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  206. * @param glTFMaterial glTF material
  207. * @param babylonMaterial Babylon material
  208. */
  209. private static _SetAlphaMode;
  210. /**
  211. * Converts a Babylon Standard Material to a glTF Material
  212. * @param babylonStandardMaterial BJS Standard Material
  213. * @param mimeType mime type to use for the textures
  214. * @param images array of glTF image interfaces
  215. * @param textures array of glTF texture interfaces
  216. * @param materials array of glTF material interfaces
  217. * @param imageData map of image file name to data
  218. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  219. */
  220. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  221. private _finishMaterial;
  222. /**
  223. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  224. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  225. * @param mimeType mime type to use for the textures
  226. * @param images array of glTF image interfaces
  227. * @param textures array of glTF texture interfaces
  228. * @param materials array of glTF material interfaces
  229. * @param imageData map of image file name to data
  230. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  231. */
  232. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  233. /**
  234. * Converts an image typed array buffer to a base64 image
  235. * @param buffer typed array buffer
  236. * @param width width of the image
  237. * @param height height of the image
  238. * @param mimeType mimetype of the image
  239. * @returns base64 image string
  240. */
  241. private _createBase64FromCanvasAsync;
  242. /**
  243. * Generates a white texture based on the specified width and height
  244. * @param width width of the texture in pixels
  245. * @param height height of the texture in pixels
  246. * @param scene babylonjs scene
  247. * @returns white texture
  248. */
  249. private _createWhiteTexture;
  250. /**
  251. * 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
  252. * @param texture1 first texture to resize
  253. * @param texture2 second texture to resize
  254. * @param scene babylonjs scene
  255. * @returns resized textures or null
  256. */
  257. private _resizeTexturesToSameDimensions;
  258. /**
  259. * Converts an array of pixels to a Float32Array
  260. * Throws an error if the pixel format is not supported
  261. * @param pixels - array buffer containing pixel values
  262. * @returns Float32 of pixels
  263. */
  264. private _convertPixelArrayToFloat32;
  265. /**
  266. * Convert Specular Glossiness Textures to Metallic Roughness
  267. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  268. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  269. * @param diffuseTexture texture used to store diffuse information
  270. * @param specularGlossinessTexture texture used to store specular and glossiness information
  271. * @param factors specular glossiness material factors
  272. * @param mimeType the mime type to use for the texture
  273. * @returns pbr metallic roughness interface or null
  274. */
  275. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  276. /**
  277. * Converts specular glossiness material properties to metallic roughness
  278. * @param specularGlossiness interface with specular glossiness material properties
  279. * @returns interface with metallic roughness material properties
  280. */
  281. private _convertSpecularGlossinessToMetallicRoughness;
  282. /**
  283. * Calculates the surface reflectance, independent of lighting conditions
  284. * @param color Color source to calculate brightness from
  285. * @returns number representing the perceived brightness, or zero if color is undefined
  286. */
  287. private _getPerceivedBrightness;
  288. /**
  289. * Returns the maximum color component value
  290. * @param color
  291. * @returns maximum color component value, or zero if color is null or undefined
  292. */
  293. private _getMaxComponent;
  294. /**
  295. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  296. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  297. * @param mimeType mime type to use for the textures
  298. * @param images array of glTF image interfaces
  299. * @param textures array of glTF texture interfaces
  300. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  301. * @param imageData map of image file name to data
  302. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  303. * @returns glTF PBR Metallic Roughness factors
  304. */
  305. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  306. private _getGLTFTextureSampler;
  307. private _getGLTFTextureWrapMode;
  308. private _getGLTFTextureWrapModesSampler;
  309. /**
  310. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  311. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  312. * @param mimeType mime type to use for the textures
  313. * @param images array of glTF image interfaces
  314. * @param textures array of glTF texture interfaces
  315. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  316. * @param imageData map of image file name to data
  317. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  318. * @returns glTF PBR Metallic Roughness factors
  319. */
  320. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  321. /**
  322. * Converts a Babylon PBR Base Material to a glTF Material
  323. * @param babylonPBRMaterial BJS PBR Base Material
  324. * @param mimeType mime type to use for the textures
  325. * @param images array of glTF image interfaces
  326. * @param textures array of glTF texture interfaces
  327. * @param materials array of glTF material interfaces
  328. * @param imageData map of image file name to data
  329. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  330. */
  331. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  332. private setMetallicRoughnessPbrMaterial;
  333. private getPixelsFromTexture;
  334. /**
  335. * Extracts a texture from a Babylon texture into file data and glTF data
  336. * @param babylonTexture Babylon texture to extract
  337. * @param mimeType Mime Type of the babylonTexture
  338. * @return glTF texture info, or null if the texture format is not supported
  339. */
  340. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  341. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  342. /**
  343. * Builds a texture from base64 string
  344. * @param base64Texture base64 texture string
  345. * @param baseTextureName Name to use for the texture
  346. * @param mimeType image mime type for the texture
  347. * @param images array of images
  348. * @param textures array of textures
  349. * @param imageData map of image data
  350. * @returns glTF texture info, or null if the texture format is not supported
  351. */
  352. private _getTextureInfoFromBase64;
  353. }
  354. }
  355. declare module "babylonjs-serializers/glTF/2.0/glTFData" {
  356. /**
  357. * Class for holding and downloading glTF file data
  358. */
  359. export class GLTFData {
  360. /**
  361. * Object which contains the file name as the key and its data as the value
  362. */
  363. glTFFiles: {
  364. [fileName: string]: string | Blob;
  365. };
  366. /**
  367. * Initializes the glTF file object
  368. */
  369. constructor();
  370. /**
  371. * Downloads the glTF data as files based on their names and data
  372. */
  373. downloadFiles(): void;
  374. }
  375. }
  376. declare module "babylonjs-serializers/glTF/2.0/glTFSerializer" {
  377. import { Node } from "babylonjs/node";
  378. import { Scene } from "babylonjs/scene";
  379. import { GLTFData } from "babylonjs-serializers/glTF/2.0/glTFData";
  380. /**
  381. * Holds a collection of exporter options and parameters
  382. */
  383. export interface IExportOptions {
  384. /**
  385. * Function which indicates whether a babylon node should be exported or not
  386. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  387. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  388. */
  389. shouldExportNode?(node: Node): boolean;
  390. /**
  391. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  392. * @param metadata source metadata to read from
  393. * @returns the data to store to glTF node extras
  394. */
  395. metadataSelector?(metadata: any): any;
  396. /**
  397. * The sample rate to bake animation curves
  398. */
  399. animationSampleRate?: number;
  400. /**
  401. * Begin serialization without waiting for the scene to be ready
  402. */
  403. exportWithoutWaitingForScene?: boolean;
  404. /**
  405. * Indicates if coordinate system swapping root nodes should be included in export
  406. */
  407. includeCoordinateSystemConversionNodes?: boolean;
  408. }
  409. /**
  410. * Class for generating glTF data from a Babylon scene.
  411. */
  412. export class GLTF2Export {
  413. /**
  414. * Exports the geometry of the scene to .gltf file format asynchronously
  415. * @param scene Babylon scene with scene hierarchy information
  416. * @param filePrefix File prefix to use when generating the glTF file
  417. * @param options Exporter options
  418. * @returns Returns an object with a .gltf file and associates texture names
  419. * as keys and their data and paths as values
  420. */
  421. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  422. private static _PreExportAsync;
  423. private static _PostExportAsync;
  424. /**
  425. * Exports the geometry of the scene to .glb file format asychronously
  426. * @param scene Babylon scene with scene hierarchy information
  427. * @param filePrefix File prefix to use when generating glb file
  428. * @param options Exporter options
  429. * @returns Returns an object with a .glb filename as key and data as value
  430. */
  431. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  432. }
  433. }
  434. declare module "babylonjs-serializers/glTF/2.0/glTFUtilities" {
  435. import { IBufferView, AccessorType, AccessorComponentType, IAccessor } from "babylonjs-gltf2interface";
  436. import { FloatArray, Nullable } from "babylonjs/types";
  437. import { Vector3, Vector4, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  438. /**
  439. * @hidden
  440. */
  441. export class _GLTFUtilities {
  442. /**
  443. * Creates a buffer view based on the supplied arguments
  444. * @param bufferIndex index value of the specified buffer
  445. * @param byteOffset byte offset value
  446. * @param byteLength byte length of the bufferView
  447. * @param byteStride byte distance between conequential elements
  448. * @param name name of the buffer view
  449. * @returns bufferView for glTF
  450. */
  451. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  452. /**
  453. * Creates an accessor based on the supplied arguments
  454. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  455. * @param name The name of the accessor
  456. * @param type The type of the accessor
  457. * @param componentType The datatype of components in the attribute
  458. * @param count The number of attributes referenced by this accessor
  459. * @param byteOffset The offset relative to the start of the bufferView in bytes
  460. * @param min Minimum value of each component in this attribute
  461. * @param max Maximum value of each component in this attribute
  462. * @returns accessor for glTF
  463. */
  464. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  465. /**
  466. * Calculates the minimum and maximum values of an array of position floats
  467. * @param positions Positions array of a mesh
  468. * @param vertexStart Starting vertex offset to calculate min and max values
  469. * @param vertexCount Number of vertices to check for min and max values
  470. * @returns min number array and max number array
  471. */
  472. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  473. min: number[];
  474. max: number[];
  475. };
  476. /**
  477. * Converts a new right-handed Vector3
  478. * @param vector vector3 array
  479. * @returns right-handed Vector3
  480. */
  481. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  482. /**
  483. * Converts a Vector3 to right-handed
  484. * @param vector Vector3 to convert to right-handed
  485. */
  486. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  487. /**
  488. * Converts a three element number array to right-handed
  489. * @param vector number array to convert to right-handed
  490. */
  491. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  492. /**
  493. * Converts a new right-handed Vector3
  494. * @param vector vector3 array
  495. * @returns right-handed Vector3
  496. */
  497. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  498. /**
  499. * Converts a Vector3 to right-handed
  500. * @param vector Vector3 to convert to right-handed
  501. */
  502. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  503. /**
  504. * Converts a three element number array to right-handed
  505. * @param vector number array to convert to right-handed
  506. */
  507. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  508. /**
  509. * Converts a Vector4 to right-handed
  510. * @param vector Vector4 to convert to right-handed
  511. */
  512. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  513. /**
  514. * Converts a Vector4 to right-handed
  515. * @param vector Vector4 to convert to right-handed
  516. */
  517. static _GetRightHandedArray4FromRef(vector: number[]): void;
  518. /**
  519. * Converts a Quaternion to right-handed
  520. * @param quaternion Source quaternion to convert to right-handed
  521. */
  522. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  523. /**
  524. * Converts a Quaternion to right-handed
  525. * @param quaternion Source quaternion to convert to right-handed
  526. */
  527. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  528. static _NormalizeTangentFromRef(tangent: Vector4): void;
  529. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  530. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  531. }
  532. }
  533. declare module "babylonjs-serializers/glTF/2.0/glTFExporter" {
  534. import { IBufferView, IAccessor, INode, IMaterial, ITexture, IImage, ISampler, ImageMimeType, IMeshPrimitive, IGLTF, AccessorComponentType, ITextureInfo, ISkin } from "babylonjs-gltf2interface";
  535. import { FloatArray, Nullable } from "babylonjs/types";
  536. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  537. import { Node } from "babylonjs/node";
  538. import { TransformNode } from "babylonjs/Meshes/transformNode";
  539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  540. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  541. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  542. import { Texture } from "babylonjs/Materials/Textures/texture";
  543. import { Material } from "babylonjs/Materials/material";
  544. import { Scene } from "babylonjs/scene";
  545. import { IGLTFExporterExtensionV2 } from "babylonjs-serializers/glTF/2.0/glTFExporterExtension";
  546. import { _GLTFMaterialExporter } from "babylonjs-serializers/glTF/2.0/glTFMaterialExporter";
  547. import { IExportOptions } from "babylonjs-serializers/glTF/2.0/glTFSerializer";
  548. import { GLTFData } from "babylonjs-serializers/glTF/2.0/glTFData";
  549. /**
  550. * Converts Babylon Scene into glTF 2.0.
  551. * @hidden
  552. */
  553. export class _Exporter {
  554. /**
  555. * Stores the glTF to export
  556. */
  557. _glTF: IGLTF;
  558. /**
  559. * Stores all generated buffer views, which represents views into the main glTF buffer data
  560. */
  561. _bufferViews: IBufferView[];
  562. /**
  563. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  564. */
  565. _accessors: IAccessor[];
  566. /**
  567. * Stores all the generated nodes, which contains transform and/or mesh information per node
  568. */
  569. _nodes: INode[];
  570. /**
  571. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  572. */
  573. private _scenes;
  574. /**
  575. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  576. */
  577. private _meshes;
  578. /**
  579. * Stores all the generated material information, which represents the appearance of each primitive
  580. */
  581. _materials: IMaterial[];
  582. _materialMap: {
  583. [materialID: number]: number;
  584. };
  585. /**
  586. * Stores all the generated texture information, which is referenced by glTF materials
  587. */
  588. _textures: ITexture[];
  589. /**
  590. * Stores all the generated image information, which is referenced by glTF textures
  591. */
  592. _images: IImage[];
  593. /**
  594. * Stores all the texture samplers
  595. */
  596. _samplers: ISampler[];
  597. /**
  598. * Stores all the generated glTF skins
  599. */
  600. _skins: ISkin[];
  601. /**
  602. * Stores all the generated animation samplers, which is referenced by glTF animations
  603. */
  604. /**
  605. * Stores the animations for glTF models
  606. */
  607. private _animations;
  608. /**
  609. * Stores the total amount of bytes stored in the glTF buffer
  610. */
  611. private _totalByteLength;
  612. /**
  613. * Stores a reference to the Babylon scene containing the source geometry and material information
  614. */
  615. _babylonScene: Scene;
  616. /**
  617. * Stores a map of the image data, where the key is the file name and the value
  618. * is the image data
  619. */
  620. _imageData: {
  621. [fileName: string]: {
  622. data: Uint8Array;
  623. mimeType: ImageMimeType;
  624. };
  625. };
  626. protected _orderedImageData: Array<{
  627. data: Uint8Array;
  628. mimeType: ImageMimeType;
  629. }>;
  630. /**
  631. * Stores a map of the unique id of a node to its index in the node array
  632. */
  633. _nodeMap: {
  634. [key: number]: number;
  635. };
  636. /**
  637. * Specifies if the source Babylon scene was left handed, and needed conversion.
  638. */
  639. _convertToRightHandedSystem: boolean;
  640. /**
  641. * Specifies if a Babylon node should be converted to right-handed on export
  642. */
  643. _convertToRightHandedSystemMap: {
  644. [nodeId: number]: boolean;
  645. };
  646. _includeCoordinateSystemConversionNodes: boolean;
  647. /**
  648. * Baked animation sample rate
  649. */
  650. private _animationSampleRate;
  651. private _options;
  652. private _localEngine;
  653. _glTFMaterialExporter: _GLTFMaterialExporter;
  654. private _extensions;
  655. private static _ExtensionNames;
  656. private static _ExtensionFactories;
  657. private _applyExtension;
  658. private _applyExtensions;
  659. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  660. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  661. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  662. [key: number]: number;
  663. }): Promise<Nullable<INode>>;
  664. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  665. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  666. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  667. private _forEachExtensions;
  668. private _extensionsOnExporting;
  669. /**
  670. * Load glTF serializer extensions
  671. */
  672. private _loadExtensions;
  673. /**
  674. * Creates a glTF Exporter instance, which can accept optional exporter options
  675. * @param babylonScene Babylon scene object
  676. * @param options Options to modify the behavior of the exporter
  677. */
  678. constructor(babylonScene: Scene, options?: IExportOptions);
  679. dispose(): void;
  680. /**
  681. * Registers a glTF exporter extension
  682. * @param name Name of the extension to export
  683. * @param factory The factory function that creates the exporter extension
  684. */
  685. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  686. /**
  687. * Un-registers an exporter extension
  688. * @param name The name fo the exporter extension
  689. * @returns A boolean indicating whether the extension has been un-registered
  690. */
  691. static UnregisterExtension(name: string): boolean;
  692. private reorderIndicesBasedOnPrimitiveMode;
  693. /**
  694. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  695. * clock-wise during export to glTF
  696. * @param submesh BabylonJS submesh
  697. * @param primitiveMode Primitive mode of the mesh
  698. * @param sideOrientation the winding order of the submesh
  699. * @param vertexBufferKind The type of vertex attribute
  700. * @param meshAttributeArray The vertex attribute data
  701. * @param byteOffset The offset to the binary data
  702. * @param binaryWriter The binary data for the glTF file
  703. * @param convertToRightHandedSystem Converts the values to right-handed
  704. */
  705. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  706. /**
  707. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  708. * clock-wise during export to glTF
  709. * @param submesh BabylonJS submesh
  710. * @param primitiveMode Primitive mode of the mesh
  711. * @param sideOrientation the winding order of the submesh
  712. * @param vertexBufferKind The type of vertex attribute
  713. * @param meshAttributeArray The vertex attribute data
  714. * @param byteOffset The offset to the binary data
  715. * @param binaryWriter The binary data for the glTF file
  716. * @param convertToRightHandedSystem Converts the values to right-handed
  717. */
  718. private reorderTriangleFillMode;
  719. /**
  720. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  721. * clock-wise during export to glTF
  722. * @param submesh BabylonJS submesh
  723. * @param primitiveMode Primitive mode of the mesh
  724. * @param sideOrientation the winding order of the submesh
  725. * @param vertexBufferKind The type of vertex attribute
  726. * @param meshAttributeArray The vertex attribute data
  727. * @param byteOffset The offset to the binary data
  728. * @param binaryWriter The binary data for the glTF file
  729. * @param convertToRightHandedSystem Converts the values to right-handed
  730. */
  731. private reorderTriangleStripDrawMode;
  732. /**
  733. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  734. * clock-wise during export to glTF
  735. * @param submesh BabylonJS submesh
  736. * @param primitiveMode Primitive mode of the mesh
  737. * @param sideOrientation the winding order of the submesh
  738. * @param vertexBufferKind The type of vertex attribute
  739. * @param meshAttributeArray The vertex attribute data
  740. * @param byteOffset The offset to the binary data
  741. * @param binaryWriter The binary data for the glTF file
  742. * @param convertToRightHandedSystem Converts the values to right-handed
  743. */
  744. private reorderTriangleFanMode;
  745. /**
  746. * Writes the vertex attribute data to binary
  747. * @param vertices The vertices to write to the binary writer
  748. * @param byteOffset The offset into the binary writer to overwrite binary data
  749. * @param vertexAttributeKind The vertex attribute type
  750. * @param meshAttributeArray The vertex attribute data
  751. * @param binaryWriter The writer containing the binary data
  752. * @param convertToRightHandedSystem Converts the values to right-handed
  753. */
  754. private writeVertexAttributeData;
  755. /**
  756. * Writes mesh attribute data to a data buffer
  757. * Returns the bytelength of the data
  758. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  759. * @param meshAttributeArray Array containing the attribute data
  760. * @param byteStride Specifies the space between data
  761. * @param binaryWriter The buffer to write the binary data to
  762. * @param convertToRightHandedSystem Converts the values to right-handed
  763. */
  764. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  765. /**
  766. * Writes mesh attribute data to a data buffer
  767. * Returns the bytelength of the data
  768. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  769. * @param meshAttributeArray Array containing the attribute data
  770. * @param byteStride Specifies the space between data
  771. * @param binaryWriter The buffer to write the binary data to
  772. * @param convertToRightHandedSystem Converts the values to right-handed
  773. */
  774. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  775. /**
  776. * Generates glTF json data
  777. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  778. * @param glTFPrefix Text to use when prefixing a glTF file
  779. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  780. * @returns json data as string
  781. */
  782. private generateJSON;
  783. /**
  784. * Generates data for .gltf and .bin files based on the glTF prefix string
  785. * @param glTFPrefix Text to use when prefixing a glTF file
  786. * @param dispose Dispose the exporter
  787. * @returns GLTFData with glTF file data
  788. */
  789. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  790. /**
  791. * Creates a binary buffer for glTF
  792. * @returns array buffer for binary data
  793. */
  794. private _generateBinaryAsync;
  795. /**
  796. * Pads the number to a multiple of 4
  797. * @param num number to pad
  798. * @returns padded number
  799. */
  800. private _getPadding;
  801. /**
  802. * @hidden
  803. */
  804. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  805. /**
  806. * Sets the TRS for each node
  807. * @param node glTF Node for storing the transformation data
  808. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  809. * @param convertToRightHandedSystem Converts the values to right-handed
  810. */
  811. private setNodeTransformation;
  812. private getVertexBufferFromMesh;
  813. /**
  814. * Creates a bufferview based on the vertices type for the Babylon mesh
  815. * @param kind Indicates the type of vertices data
  816. * @param componentType Indicates the numerical type used to store the data
  817. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  818. * @param binaryWriter The buffer to write the bufferview data to
  819. * @param convertToRightHandedSystem Converts the values to right-handed
  820. */
  821. private createBufferViewKind;
  822. /**
  823. * Creates a bufferview based on the vertices type for the Babylon mesh
  824. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  825. * @param babylonMorphTarget the morph target to be exported
  826. * @param binaryWriter The buffer to write the bufferview data to
  827. * @param convertToRightHandedSystem Converts the values to right-handed
  828. */
  829. private setMorphTargetAttributes;
  830. /**
  831. * The primitive mode of the Babylon mesh
  832. * @param babylonMesh The BabylonJS mesh
  833. */
  834. private getMeshPrimitiveMode;
  835. /**
  836. * Sets the primitive mode of the glTF mesh primitive
  837. * @param meshPrimitive glTF mesh primitive
  838. * @param primitiveMode The primitive mode
  839. */
  840. private setPrimitiveMode;
  841. /**
  842. * Sets the vertex attribute accessor based of the glTF mesh primitive
  843. * @param meshPrimitive glTF mesh primitive
  844. * @param attributeKind vertex attribute
  845. * @returns boolean specifying if uv coordinates are present
  846. */
  847. private setAttributeKind;
  848. /**
  849. * Sets data for the primitive attributes of each submesh
  850. * @param mesh glTF Mesh object to store the primitive attribute information
  851. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  852. * @param binaryWriter Buffer to write the attribute data to
  853. * @param convertToRightHandedSystem Converts the values to right-handed
  854. */
  855. private setPrimitiveAttributesAsync;
  856. /**
  857. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  858. * @param node The node to check
  859. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  860. */
  861. private isBabylonCoordinateSystemConvertingNode;
  862. /**
  863. * Creates a glTF scene based on the array of meshes
  864. * Returns the the total byte offset
  865. * @param babylonScene Babylon scene to get the mesh data from
  866. * @param binaryWriter Buffer to write binary data to
  867. */
  868. private createSceneAsync;
  869. /**
  870. * Creates a mapping of Node unique id to node index and handles animations
  871. * @param babylonScene Babylon Scene
  872. * @param nodes Babylon transform nodes
  873. * @param binaryWriter Buffer to write binary data to
  874. * @returns Node mapping of unique id to index
  875. */
  876. private createNodeMapAndAnimationsAsync;
  877. /**
  878. * Creates a glTF node from a Babylon mesh
  879. * @param babylonMesh Source Babylon mesh
  880. * @param binaryWriter Buffer for storing geometry data
  881. * @param convertToRightHandedSystem Converts the values to right-handed
  882. * @param nodeMap Node mapping of unique id to glTF node index
  883. * @returns glTF node
  884. */
  885. private createNodeAsync;
  886. /**
  887. * Creates a glTF skin from a Babylon skeleton
  888. * @param babylonScene Babylon Scene
  889. * @param nodes Babylon transform nodes
  890. * @param binaryWriter Buffer to write binary data to
  891. * @returns Node mapping of unique id to index
  892. */
  893. private createSkinsAsync;
  894. }
  895. /**
  896. * @hidden
  897. *
  898. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  899. */
  900. export class _BinaryWriter {
  901. /**
  902. * Array buffer which stores all binary data
  903. */
  904. private _arrayBuffer;
  905. /**
  906. * View of the array buffer
  907. */
  908. private _dataView;
  909. /**
  910. * byte offset of data in array buffer
  911. */
  912. private _byteOffset;
  913. /**
  914. * Initialize binary writer with an initial byte length
  915. * @param byteLength Initial byte length of the array buffer
  916. */
  917. constructor(byteLength: number);
  918. /**
  919. * Resize the array buffer to the specified byte length
  920. * @param byteLength
  921. */
  922. private resizeBuffer;
  923. /**
  924. * Get an array buffer with the length of the byte offset
  925. * @returns ArrayBuffer resized to the byte offset
  926. */
  927. getArrayBuffer(): ArrayBuffer;
  928. /**
  929. * Get the byte offset of the array buffer
  930. * @returns byte offset
  931. */
  932. getByteOffset(): number;
  933. /**
  934. * Stores an UInt8 in the array buffer
  935. * @param entry
  936. * @param byteOffset If defined, specifies where to set the value as an offset.
  937. */
  938. setUInt8(entry: number, byteOffset?: number): void;
  939. /**
  940. * Stores an UInt16 in the array buffer
  941. * @param entry
  942. * @param byteOffset If defined, specifies where to set the value as an offset.
  943. */
  944. setUInt16(entry: number, byteOffset?: number): void;
  945. /**
  946. * Gets an UInt32 in the array buffer
  947. * @param entry
  948. * @param byteOffset If defined, specifies where to set the value as an offset.
  949. */
  950. getUInt32(byteOffset: number): number;
  951. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  952. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  953. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  954. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  955. /**
  956. * Stores a Float32 in the array buffer
  957. * @param entry
  958. */
  959. setFloat32(entry: number, byteOffset?: number): void;
  960. /**
  961. * Stores an UInt32 in the array buffer
  962. * @param entry
  963. * @param byteOffset If defined, specifies where to set the value as an offset.
  964. */
  965. setUInt32(entry: number, byteOffset?: number): void;
  966. }
  967. }
  968. declare module "babylonjs-serializers/glTF/2.0/glTFAnimation" {
  969. import { AnimationSamplerInterpolation, AnimationChannelTargetPath, AccessorType, IAnimation, INode, IBufferView, IAccessor } from "babylonjs-gltf2interface";
  970. import { Node } from "babylonjs/node";
  971. import { Nullable } from "babylonjs/types";
  972. import { Animation } from "babylonjs/Animations/animation";
  973. import { TransformNode } from "babylonjs/Meshes/transformNode";
  974. import { Scene } from "babylonjs/scene";
  975. import { _BinaryWriter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
  976. /**
  977. * @hidden
  978. * Interface to store animation data.
  979. */
  980. export interface _IAnimationData {
  981. /**
  982. * Keyframe data.
  983. */
  984. inputs: number[];
  985. /**
  986. * Value data.
  987. */
  988. outputs: number[][];
  989. /**
  990. * Animation interpolation data.
  991. */
  992. samplerInterpolation: AnimationSamplerInterpolation;
  993. /**
  994. * Minimum keyframe value.
  995. */
  996. inputsMin: number;
  997. /**
  998. * Maximum keyframe value.
  999. */
  1000. inputsMax: number;
  1001. }
  1002. /**
  1003. * @hidden
  1004. */
  1005. export interface _IAnimationInfo {
  1006. /**
  1007. * The target channel for the animation
  1008. */
  1009. animationChannelTargetPath: AnimationChannelTargetPath;
  1010. /**
  1011. * The glTF accessor type for the data.
  1012. */
  1013. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  1014. /**
  1015. * Specifies if quaternions should be used.
  1016. */
  1017. useQuaternion: boolean;
  1018. }
  1019. /**
  1020. * @hidden
  1021. * Utility class for generating glTF animation data from BabylonJS.
  1022. */
  1023. export class _GLTFAnimation {
  1024. /**
  1025. * @ignore
  1026. *
  1027. * Creates glTF channel animation from BabylonJS animation.
  1028. * @param babylonTransformNode - BabylonJS mesh.
  1029. * @param animation - animation.
  1030. * @param animationChannelTargetPath - The target animation channel.
  1031. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  1032. * @param useQuaternion - Specifies if quaternions are used.
  1033. * @returns nullable IAnimationData
  1034. */
  1035. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  1036. private static _DeduceAnimationInfo;
  1037. /**
  1038. * @ignore
  1039. * Create node animations from the transform node animations
  1040. * @param babylonNode
  1041. * @param runtimeGLTFAnimation
  1042. * @param idleGLTFAnimations
  1043. * @param nodeMap
  1044. * @param nodes
  1045. * @param binaryWriter
  1046. * @param bufferViews
  1047. * @param accessors
  1048. * @param convertToRightHandedSystem
  1049. * @param animationSampleRate
  1050. */
  1051. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  1052. [key: number]: number;
  1053. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  1054. /**
  1055. * @ignore
  1056. * Create individual morph animations from the mesh's morph target animation tracks
  1057. * @param babylonNode
  1058. * @param runtimeGLTFAnimation
  1059. * @param idleGLTFAnimations
  1060. * @param nodeMap
  1061. * @param nodes
  1062. * @param binaryWriter
  1063. * @param bufferViews
  1064. * @param accessors
  1065. * @param convertToRightHandedSystem
  1066. * @param animationSampleRate
  1067. */
  1068. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  1069. [key: number]: number;
  1070. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  1071. /**
  1072. * @ignore
  1073. * Create node and morph animations from the animation groups
  1074. * @param babylonScene
  1075. * @param glTFAnimations
  1076. * @param nodeMap
  1077. * @param nodes
  1078. * @param binaryWriter
  1079. * @param bufferViews
  1080. * @param accessors
  1081. * @param convertToRightHandedSystemMap
  1082. * @param animationSampleRate
  1083. */
  1084. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  1085. [key: number]: number;
  1086. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  1087. [nodeId: number]: boolean;
  1088. }, animationSampleRate: number): void;
  1089. private static AddAnimation;
  1090. /**
  1091. * Create a baked animation
  1092. * @param babylonTransformNode BabylonJS mesh
  1093. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  1094. * @param animationChannelTargetPath animation target channel
  1095. * @param minFrame minimum animation frame
  1096. * @param maxFrame maximum animation frame
  1097. * @param fps frames per second of the animation
  1098. * @param inputs input key frames of the animation
  1099. * @param outputs output key frame data of the animation
  1100. * @param convertToRightHandedSystem converts the values to right-handed
  1101. * @param useQuaternion specifies if quaternions should be used
  1102. */
  1103. private static _CreateBakedAnimation;
  1104. private static _ConvertFactorToVector3OrQuaternion;
  1105. private static _SetInterpolatedValue;
  1106. /**
  1107. * Creates linear animation from the animation key frames
  1108. * @param babylonTransformNode BabylonJS mesh
  1109. * @param animation BabylonJS animation
  1110. * @param animationChannelTargetPath The target animation channel
  1111. * @param frameDelta The difference between the last and first frame of the animation
  1112. * @param inputs Array to store the key frame times
  1113. * @param outputs Array to store the key frame data
  1114. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  1115. * @param useQuaternion Specifies if quaternions are used in the animation
  1116. */
  1117. private static _CreateLinearOrStepAnimation;
  1118. /**
  1119. * Creates cubic spline animation from the animation key frames
  1120. * @param babylonTransformNode BabylonJS mesh
  1121. * @param animation BabylonJS animation
  1122. * @param animationChannelTargetPath The target animation channel
  1123. * @param frameDelta The difference between the last and first frame of the animation
  1124. * @param inputs Array to store the key frame times
  1125. * @param outputs Array to store the key frame data
  1126. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  1127. * @param useQuaternion Specifies if quaternions are used in the animation
  1128. */
  1129. private static _CreateCubicSplineAnimation;
  1130. private static _GetBasePositionRotationOrScale;
  1131. /**
  1132. * Adds a key frame value
  1133. * @param keyFrame
  1134. * @param animation
  1135. * @param outputs
  1136. * @param animationChannelTargetPath
  1137. * @param basePositionRotationOrScale
  1138. * @param convertToRightHandedSystem
  1139. * @param useQuaternion
  1140. */
  1141. private static _AddKeyframeValue;
  1142. /**
  1143. * Determine the interpolation based on the key frames
  1144. * @param keyFrames
  1145. * @param animationChannelTargetPath
  1146. * @param useQuaternion
  1147. */
  1148. private static _DeduceInterpolation;
  1149. /**
  1150. * Adds an input tangent or output tangent to the output data
  1151. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  1152. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  1153. * @param outputs The animation data by keyframe
  1154. * @param animationChannelTargetPath The target animation channel
  1155. * @param interpolation The interpolation type
  1156. * @param keyFrame The key frame with the animation data
  1157. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  1158. * @param useQuaternion Specifies if quaternions are used
  1159. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  1160. */
  1161. private static AddSplineTangent;
  1162. /**
  1163. * Get the minimum and maximum key frames' frame values
  1164. * @param keyFrames animation key frames
  1165. * @returns the minimum and maximum key frame value
  1166. */
  1167. private static calculateMinMaxKeyFrames;
  1168. }
  1169. }
  1170. declare module "babylonjs-serializers/glTF/2.0/shaders/textureTransform.fragment" {
  1171. /** @hidden */
  1172. export var textureTransformPixelShader: {
  1173. name: string;
  1174. shader: string;
  1175. };
  1176. }
  1177. declare module "babylonjs-serializers/glTF/2.0/Extensions/KHR_texture_transform" {
  1178. import { ImageMimeType, ITextureInfo } from "babylonjs-gltf2interface";
  1179. import { Texture } from "babylonjs/Materials/Textures/texture";
  1180. import { IGLTFExporterExtensionV2 } from "babylonjs-serializers/glTF/2.0/glTFExporterExtension";
  1181. import { _Exporter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
  1182. import "babylonjs-serializers/glTF/2.0/shaders/textureTransform.fragment";
  1183. /**
  1184. * @hidden
  1185. */
  1186. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  1187. private _recordedTextures;
  1188. /** Name of this extension */
  1189. readonly name: string;
  1190. /** Defines whether this extension is enabled */
  1191. enabled: boolean;
  1192. /** Defines whether this extension is required */
  1193. required: boolean;
  1194. /** Reference to the glTF exporter */
  1195. private _wasUsed;
  1196. constructor(exporter: _Exporter);
  1197. dispose(): void;
  1198. /** @hidden */
  1199. get wasUsed(): boolean;
  1200. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  1201. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  1202. /**
  1203. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  1204. * @param babylonTexture
  1205. * @param offset
  1206. * @param rotation
  1207. * @param scale
  1208. * @param scene
  1209. */
  1210. private _textureTransformTextureAsync;
  1211. }
  1212. }
  1213. declare module "babylonjs-serializers/glTF/2.0/Extensions/KHR_lights_punctual" {
  1214. import { Nullable } from "babylonjs/types";
  1215. import { Node } from "babylonjs/node";
  1216. import { INode } from "babylonjs-gltf2interface";
  1217. import { IGLTFExporterExtensionV2 } from "babylonjs-serializers/glTF/2.0/glTFExporterExtension";
  1218. import { _Exporter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
  1219. /**
  1220. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  1221. */
  1222. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  1223. /** The 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. /** Reference to the glTF exporter */
  1230. private _exporter;
  1231. private _lights;
  1232. /** @hidden */
  1233. constructor(exporter: _Exporter);
  1234. /** @hidden */
  1235. dispose(): void;
  1236. /** @hidden */
  1237. get wasUsed(): boolean;
  1238. /** @hidden */
  1239. onExporting(): void;
  1240. /**
  1241. * Define this method to modify the default behavior when exporting a node
  1242. * @param context The context when exporting the node
  1243. * @param node glTF node
  1244. * @param babylonNode BabylonJS node
  1245. * @param nodeMap Node mapping of unique id to glTF node index
  1246. * @returns nullable INode promise
  1247. */
  1248. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  1249. [key: number]: number;
  1250. }): Promise<Nullable<INode>>;
  1251. }
  1252. }
  1253. declare module "babylonjs-serializers/glTF/2.0/Extensions/KHR_materials_sheen" {
  1254. import { ITextureInfo, IMaterial } from "babylonjs-gltf2interface";
  1255. import { IGLTFExporterExtensionV2 } from "babylonjs-serializers/glTF/2.0/glTFExporterExtension";
  1256. import { _Exporter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
  1257. import { Material } from 'babylonjs/Materials/material';
  1258. import { Texture } from 'babylonjs/Materials/Textures/texture';
  1259. import { BaseTexture } from 'babylonjs/Materials/Textures/baseTexture';
  1260. /**
  1261. * @hidden
  1262. */
  1263. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  1264. /** Name of this extension */
  1265. readonly name: string;
  1266. /** Defines whether this extension is enabled */
  1267. enabled: boolean;
  1268. /** Defines whether this extension is required */
  1269. required: boolean;
  1270. /** Reference to the glTF exporter */
  1271. private _textureInfos;
  1272. private _exportedTextures;
  1273. private _wasUsed;
  1274. constructor(exporter: _Exporter);
  1275. dispose(): void;
  1276. /** @hidden */
  1277. get wasUsed(): boolean;
  1278. private _getTextureIndex;
  1279. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  1280. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  1281. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  1282. }
  1283. }
  1284. declare module "babylonjs-serializers/glTF/2.0/Extensions/KHR_materials_unlit" {
  1285. import { IMaterial } from "babylonjs-gltf2interface";
  1286. import { IGLTFExporterExtensionV2 } from "babylonjs-serializers/glTF/2.0/glTFExporterExtension";
  1287. import { _Exporter } from "babylonjs-serializers/glTF/2.0/glTFExporter";
  1288. import { Material } from 'babylonjs/Materials/material';
  1289. /**
  1290. * @hidden
  1291. */
  1292. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  1293. /** Name of this extension */
  1294. readonly name: string;
  1295. /** Defines whether this extension is enabled */
  1296. enabled: boolean;
  1297. /** Defines whether this extension is required */
  1298. required: boolean;
  1299. private _wasUsed;
  1300. constructor(exporter: _Exporter);
  1301. /** @hidden */
  1302. get wasUsed(): boolean;
  1303. dispose(): void;
  1304. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  1305. }
  1306. }
  1307. declare module "babylonjs-serializers/glTF/2.0/Extensions/index" {
  1308. export * from "babylonjs-serializers/glTF/2.0/Extensions/KHR_texture_transform";
  1309. export * from "babylonjs-serializers/glTF/2.0/Extensions/KHR_lights_punctual";
  1310. export * from "babylonjs-serializers/glTF/2.0/Extensions/KHR_materials_sheen";
  1311. export * from "babylonjs-serializers/glTF/2.0/Extensions/KHR_materials_unlit";
  1312. }
  1313. declare module "babylonjs-serializers/glTF/2.0/index" {
  1314. export * from "babylonjs-serializers/glTF/2.0/glTFAnimation";
  1315. export * from "babylonjs-serializers/glTF/2.0/glTFData";
  1316. export * from "babylonjs-serializers/glTF/2.0/glTFExporter";
  1317. export * from "babylonjs-serializers/glTF/2.0/glTFExporterExtension";
  1318. export * from "babylonjs-serializers/glTF/2.0/glTFMaterialExporter";
  1319. export * from "babylonjs-serializers/glTF/2.0/glTFSerializer";
  1320. export * from "babylonjs-serializers/glTF/2.0/glTFUtilities";
  1321. export * from "babylonjs-serializers/glTF/2.0/Extensions/index";
  1322. }
  1323. declare module "babylonjs-serializers/glTF/index" {
  1324. export * from "babylonjs-serializers/glTF/glTFFileExporter";
  1325. export * from "babylonjs-serializers/glTF/2.0/index";
  1326. }
  1327. declare module "babylonjs-serializers/stl/stlSerializer" {
  1328. import { Mesh } from "babylonjs/Meshes/mesh";
  1329. /**
  1330. * Class for generating STL data from a Babylon scene.
  1331. */
  1332. export class STLExport {
  1333. /**
  1334. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  1335. * @param meshes list defines the mesh to serialize
  1336. * @param download triggers the automatic download of the file.
  1337. * @param fileName changes the downloads fileName.
  1338. * @param binary changes the STL to a binary type.
  1339. * @param isLittleEndian toggle for binary type exporter.
  1340. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  1341. * @returns the STL as UTF8 string
  1342. */
  1343. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  1344. }
  1345. }
  1346. declare module "babylonjs-serializers/stl/index" {
  1347. export * from "babylonjs-serializers/stl/stlSerializer";
  1348. }
  1349. declare module "babylonjs-serializers/index" {
  1350. export * from "babylonjs-serializers/OBJ/index";
  1351. export * from "babylonjs-serializers/glTF/index";
  1352. export * from "babylonjs-serializers/stl/index";
  1353. }
  1354. declare module "babylonjs-serializers/legacy/legacy-glTF2Serializer" {
  1355. export * from "babylonjs-serializers/glTF/glTFFileExporter";
  1356. export * from "babylonjs-serializers/glTF/2.0/index";
  1357. }
  1358. declare module "babylonjs-serializers/legacy/legacy-objSerializer" {
  1359. export * from "babylonjs-serializers/OBJ/index";
  1360. }
  1361. declare module "babylonjs-serializers/legacy/legacy-stlSerializer" {
  1362. export * from "babylonjs-serializers/stl/index";
  1363. }
  1364. declare module "babylonjs-serializers/legacy/legacy" {
  1365. import "babylonjs-serializers/index";
  1366. export * from "babylonjs-serializers/legacy/legacy-glTF2Serializer";
  1367. export * from "babylonjs-serializers/legacy/legacy-objSerializer";
  1368. export * from "babylonjs-serializers/legacy/legacy-stlSerializer";
  1369. }
  1370. declare module "babylonjs-serializers" {
  1371. export * from "babylonjs-serializers/legacy/legacy";
  1372. }
  1373. declare module BABYLON {
  1374. /**
  1375. * Class for generating OBJ data from a Babylon scene.
  1376. */
  1377. export class OBJExport {
  1378. /**
  1379. * Exports the geometry of a Mesh array in .OBJ file format (text)
  1380. * @param mesh defines the list of meshes to serialize
  1381. * @param materials defines if materials should be exported
  1382. * @param matlibname defines the name of the associated mtl file
  1383. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  1384. * @returns the OBJ content
  1385. */
  1386. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  1387. /**
  1388. * Exports the material(s) of a mesh in .MTL file format (text)
  1389. * @param mesh defines the mesh to extract the material from
  1390. * @returns the mtl content
  1391. */
  1392. static MTL(mesh: Mesh): string;
  1393. }
  1394. }
  1395. declare module BABYLON {
  1396. /** @hidden */
  1397. export var __IGLTFExporterExtension: number;
  1398. /**
  1399. * Interface for extending the exporter
  1400. * @hidden
  1401. */
  1402. export interface IGLTFExporterExtension {
  1403. /**
  1404. * The name of this extension
  1405. */
  1406. readonly name: string;
  1407. /**
  1408. * Defines whether this extension is enabled
  1409. */
  1410. enabled: boolean;
  1411. /**
  1412. * Defines whether this extension is required
  1413. */
  1414. required: boolean;
  1415. }
  1416. }
  1417. declare module BABYLON.GLTF2.Exporter {
  1418. /** @hidden */
  1419. export var __IGLTFExporterExtensionV2: number;
  1420. /**
  1421. * Interface for a glTF exporter extension
  1422. * @hidden
  1423. */
  1424. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  1425. /**
  1426. * Define this method to modify the default behavior before exporting a texture
  1427. * @param context The context when loading the asset
  1428. * @param babylonTexture The Babylon.js texture
  1429. * @param mimeType The mime-type of the generated image
  1430. * @returns A promise that resolves with the exported texture
  1431. */
  1432. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  1433. /**
  1434. * Define this method to get notified when a texture info is created
  1435. * @param context The context when loading the asset
  1436. * @param textureInfo The glTF texture info
  1437. * @param babylonTexture The Babylon.js texture
  1438. */
  1439. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  1440. /**
  1441. * Define this method to modify the default behavior when exporting texture info
  1442. * @param context The context when loading the asset
  1443. * @param meshPrimitive glTF mesh primitive
  1444. * @param babylonSubMesh Babylon submesh
  1445. * @param binaryWriter glTF serializer binary writer instance
  1446. * @returns nullable IMeshPrimitive promise
  1447. */
  1448. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  1449. /**
  1450. * Define this method to modify the default behavior when exporting a node
  1451. * @param context The context when exporting the node
  1452. * @param node glTF node
  1453. * @param babylonNode BabylonJS node
  1454. * @returns nullable INode promise
  1455. */
  1456. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  1457. [key: number]: number;
  1458. }): Promise<Nullable<INode>>;
  1459. /**
  1460. * Define this method to modify the default behavior when exporting a material
  1461. * @param material glTF material
  1462. * @param babylonMaterial BabylonJS material
  1463. * @returns nullable IMaterial promise
  1464. */
  1465. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  1466. /**
  1467. * Define this method to return additional textures to export from a material
  1468. * @param material glTF material
  1469. * @param babylonMaterial BabylonJS material
  1470. * @returns List of textures
  1471. */
  1472. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  1473. /** Gets a boolean indicating that this extension was used */
  1474. wasUsed: boolean;
  1475. /** Gets a boolean indicating that this extension is required for the file to work */
  1476. required: boolean;
  1477. /**
  1478. * Called after the exporter state changes to EXPORTING
  1479. */
  1480. onExporting?(): void;
  1481. }
  1482. }
  1483. declare module BABYLON.GLTF2.Exporter {
  1484. /**
  1485. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  1486. * @hidden
  1487. */
  1488. export class _GLTFMaterialExporter {
  1489. /**
  1490. * Represents the dielectric specular values for R, G and B
  1491. */
  1492. private static readonly _DielectricSpecular;
  1493. /**
  1494. * Allows the maximum specular power to be defined for material calculations
  1495. */
  1496. private static readonly _MaxSpecularPower;
  1497. /**
  1498. * Mapping to store textures
  1499. */
  1500. private _textureMap;
  1501. /**
  1502. * Numeric tolerance value
  1503. */
  1504. private static readonly _Epsilon;
  1505. /**
  1506. * Reference to the glTF Exporter
  1507. */
  1508. private _exporter;
  1509. constructor(exporter: _Exporter);
  1510. /**
  1511. * Specifies if two colors are approximately equal in value
  1512. * @param color1 first color to compare to
  1513. * @param color2 second color to compare to
  1514. * @param epsilon threshold value
  1515. */
  1516. private static FuzzyEquals;
  1517. /**
  1518. * Gets the materials from a Babylon scene and converts them to glTF materials
  1519. * @param scene babylonjs scene
  1520. * @param mimeType texture mime type
  1521. * @param images array of images
  1522. * @param textures array of textures
  1523. * @param materials array of materials
  1524. * @param imageData mapping of texture names to base64 textures
  1525. * @param hasTextureCoords specifies if texture coordinates are present on the material
  1526. */
  1527. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  1528. /**
  1529. * Makes a copy of the glTF material without the texture parameters
  1530. * @param originalMaterial original glTF material
  1531. * @returns glTF material without texture parameters
  1532. */
  1533. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  1534. /**
  1535. * Specifies if the material has any texture parameters present
  1536. * @param material glTF Material
  1537. * @returns boolean specifying if texture parameters are present
  1538. */
  1539. _hasTexturesPresent(material: IMaterial): boolean;
  1540. /**
  1541. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  1542. * @param babylonStandardMaterial
  1543. * @returns glTF Metallic Roughness Material representation
  1544. */
  1545. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  1546. /**
  1547. * Computes the metallic factor
  1548. * @param diffuse diffused value
  1549. * @param specular specular value
  1550. * @param oneMinusSpecularStrength one minus the specular strength
  1551. * @returns metallic value
  1552. */
  1553. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  1554. /**
  1555. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  1556. * @param glTFMaterial glTF material
  1557. * @param babylonMaterial Babylon material
  1558. */
  1559. private static _SetAlphaMode;
  1560. /**
  1561. * Converts a Babylon Standard Material to a glTF Material
  1562. * @param babylonStandardMaterial BJS Standard Material
  1563. * @param mimeType mime type to use for the textures
  1564. * @param images array of glTF image interfaces
  1565. * @param textures array of glTF texture interfaces
  1566. * @param materials array of glTF material interfaces
  1567. * @param imageData map of image file name to data
  1568. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  1569. */
  1570. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  1571. private _finishMaterial;
  1572. /**
  1573. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  1574. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  1575. * @param mimeType mime type to use for the textures
  1576. * @param images array of glTF image interfaces
  1577. * @param textures array of glTF texture interfaces
  1578. * @param materials array of glTF material interfaces
  1579. * @param imageData map of image file name to data
  1580. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  1581. */
  1582. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  1583. /**
  1584. * Converts an image typed array buffer to a base64 image
  1585. * @param buffer typed array buffer
  1586. * @param width width of the image
  1587. * @param height height of the image
  1588. * @param mimeType mimetype of the image
  1589. * @returns base64 image string
  1590. */
  1591. private _createBase64FromCanvasAsync;
  1592. /**
  1593. * Generates a white texture based on the specified width and height
  1594. * @param width width of the texture in pixels
  1595. * @param height height of the texture in pixels
  1596. * @param scene babylonjs scene
  1597. * @returns white texture
  1598. */
  1599. private _createWhiteTexture;
  1600. /**
  1601. * 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
  1602. * @param texture1 first texture to resize
  1603. * @param texture2 second texture to resize
  1604. * @param scene babylonjs scene
  1605. * @returns resized textures or null
  1606. */
  1607. private _resizeTexturesToSameDimensions;
  1608. /**
  1609. * Converts an array of pixels to a Float32Array
  1610. * Throws an error if the pixel format is not supported
  1611. * @param pixels - array buffer containing pixel values
  1612. * @returns Float32 of pixels
  1613. */
  1614. private _convertPixelArrayToFloat32;
  1615. /**
  1616. * Convert Specular Glossiness Textures to Metallic Roughness
  1617. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  1618. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  1619. * @param diffuseTexture texture used to store diffuse information
  1620. * @param specularGlossinessTexture texture used to store specular and glossiness information
  1621. * @param factors specular glossiness material factors
  1622. * @param mimeType the mime type to use for the texture
  1623. * @returns pbr metallic roughness interface or null
  1624. */
  1625. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  1626. /**
  1627. * Converts specular glossiness material properties to metallic roughness
  1628. * @param specularGlossiness interface with specular glossiness material properties
  1629. * @returns interface with metallic roughness material properties
  1630. */
  1631. private _convertSpecularGlossinessToMetallicRoughness;
  1632. /**
  1633. * Calculates the surface reflectance, independent of lighting conditions
  1634. * @param color Color source to calculate brightness from
  1635. * @returns number representing the perceived brightness, or zero if color is undefined
  1636. */
  1637. private _getPerceivedBrightness;
  1638. /**
  1639. * Returns the maximum color component value
  1640. * @param color
  1641. * @returns maximum color component value, or zero if color is null or undefined
  1642. */
  1643. private _getMaxComponent;
  1644. /**
  1645. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  1646. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  1647. * @param mimeType mime type to use for the textures
  1648. * @param images array of glTF image interfaces
  1649. * @param textures array of glTF texture interfaces
  1650. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  1651. * @param imageData map of image file name to data
  1652. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  1653. * @returns glTF PBR Metallic Roughness factors
  1654. */
  1655. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  1656. private _getGLTFTextureSampler;
  1657. private _getGLTFTextureWrapMode;
  1658. private _getGLTFTextureWrapModesSampler;
  1659. /**
  1660. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  1661. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  1662. * @param mimeType mime type to use for the textures
  1663. * @param images array of glTF image interfaces
  1664. * @param textures array of glTF texture interfaces
  1665. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  1666. * @param imageData map of image file name to data
  1667. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  1668. * @returns glTF PBR Metallic Roughness factors
  1669. */
  1670. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  1671. /**
  1672. * Converts a Babylon PBR Base Material to a glTF Material
  1673. * @param babylonPBRMaterial BJS PBR Base Material
  1674. * @param mimeType mime type to use for the textures
  1675. * @param images array of glTF image interfaces
  1676. * @param textures array of glTF texture interfaces
  1677. * @param materials array of glTF material interfaces
  1678. * @param imageData map of image file name to data
  1679. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  1680. */
  1681. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  1682. private setMetallicRoughnessPbrMaterial;
  1683. private getPixelsFromTexture;
  1684. /**
  1685. * Extracts a texture from a Babylon texture into file data and glTF data
  1686. * @param babylonTexture Babylon texture to extract
  1687. * @param mimeType Mime Type of the babylonTexture
  1688. * @return glTF texture info, or null if the texture format is not supported
  1689. */
  1690. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  1691. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  1692. /**
  1693. * Builds a texture from base64 string
  1694. * @param base64Texture base64 texture string
  1695. * @param baseTextureName Name to use for the texture
  1696. * @param mimeType image mime type for the texture
  1697. * @param images array of images
  1698. * @param textures array of textures
  1699. * @param imageData map of image data
  1700. * @returns glTF texture info, or null if the texture format is not supported
  1701. */
  1702. private _getTextureInfoFromBase64;
  1703. }
  1704. }
  1705. declare module BABYLON {
  1706. /**
  1707. * Class for holding and downloading glTF file data
  1708. */
  1709. export class GLTFData {
  1710. /**
  1711. * Object which contains the file name as the key and its data as the value
  1712. */
  1713. glTFFiles: {
  1714. [fileName: string]: string | Blob;
  1715. };
  1716. /**
  1717. * Initializes the glTF file object
  1718. */
  1719. constructor();
  1720. /**
  1721. * Downloads the glTF data as files based on their names and data
  1722. */
  1723. downloadFiles(): void;
  1724. }
  1725. }
  1726. declare module BABYLON {
  1727. /**
  1728. * Holds a collection of exporter options and parameters
  1729. */
  1730. export interface IExportOptions {
  1731. /**
  1732. * Function which indicates whether a babylon node should be exported or not
  1733. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  1734. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  1735. */
  1736. shouldExportNode?(node: Node): boolean;
  1737. /**
  1738. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  1739. * @param metadata source metadata to read from
  1740. * @returns the data to store to glTF node extras
  1741. */
  1742. metadataSelector?(metadata: any): any;
  1743. /**
  1744. * The sample rate to bake animation curves
  1745. */
  1746. animationSampleRate?: number;
  1747. /**
  1748. * Begin serialization without waiting for the scene to be ready
  1749. */
  1750. exportWithoutWaitingForScene?: boolean;
  1751. /**
  1752. * Indicates if coordinate system swapping root nodes should be included in export
  1753. */
  1754. includeCoordinateSystemConversionNodes?: boolean;
  1755. }
  1756. /**
  1757. * Class for generating glTF data from a Babylon scene.
  1758. */
  1759. export class GLTF2Export {
  1760. /**
  1761. * Exports the geometry of the scene to .gltf file format asynchronously
  1762. * @param scene Babylon scene with scene hierarchy information
  1763. * @param filePrefix File prefix to use when generating the glTF file
  1764. * @param options Exporter options
  1765. * @returns Returns an object with a .gltf file and associates texture names
  1766. * as keys and their data and paths as values
  1767. */
  1768. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  1769. private static _PreExportAsync;
  1770. private static _PostExportAsync;
  1771. /**
  1772. * Exports the geometry of the scene to .glb file format asychronously
  1773. * @param scene Babylon scene with scene hierarchy information
  1774. * @param filePrefix File prefix to use when generating glb file
  1775. * @param options Exporter options
  1776. * @returns Returns an object with a .glb filename as key and data as value
  1777. */
  1778. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  1779. }
  1780. }
  1781. declare module BABYLON.GLTF2.Exporter {
  1782. /**
  1783. * @hidden
  1784. */
  1785. export class _GLTFUtilities {
  1786. /**
  1787. * Creates a buffer view based on the supplied arguments
  1788. * @param bufferIndex index value of the specified buffer
  1789. * @param byteOffset byte offset value
  1790. * @param byteLength byte length of the bufferView
  1791. * @param byteStride byte distance between conequential elements
  1792. * @param name name of the buffer view
  1793. * @returns bufferView for glTF
  1794. */
  1795. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  1796. /**
  1797. * Creates an accessor based on the supplied arguments
  1798. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  1799. * @param name The name of the accessor
  1800. * @param type The type of the accessor
  1801. * @param componentType The datatype of components in the attribute
  1802. * @param count The number of attributes referenced by this accessor
  1803. * @param byteOffset The offset relative to the start of the bufferView in bytes
  1804. * @param min Minimum value of each component in this attribute
  1805. * @param max Maximum value of each component in this attribute
  1806. * @returns accessor for glTF
  1807. */
  1808. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  1809. /**
  1810. * Calculates the minimum and maximum values of an array of position floats
  1811. * @param positions Positions array of a mesh
  1812. * @param vertexStart Starting vertex offset to calculate min and max values
  1813. * @param vertexCount Number of vertices to check for min and max values
  1814. * @returns min number array and max number array
  1815. */
  1816. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  1817. min: number[];
  1818. max: number[];
  1819. };
  1820. /**
  1821. * Converts a new right-handed Vector3
  1822. * @param vector vector3 array
  1823. * @returns right-handed Vector3
  1824. */
  1825. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  1826. /**
  1827. * Converts a Vector3 to right-handed
  1828. * @param vector Vector3 to convert to right-handed
  1829. */
  1830. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  1831. /**
  1832. * Converts a three element number array to right-handed
  1833. * @param vector number array to convert to right-handed
  1834. */
  1835. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  1836. /**
  1837. * Converts a new right-handed Vector3
  1838. * @param vector vector3 array
  1839. * @returns right-handed Vector3
  1840. */
  1841. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  1842. /**
  1843. * Converts a Vector3 to right-handed
  1844. * @param vector Vector3 to convert to right-handed
  1845. */
  1846. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  1847. /**
  1848. * Converts a three element number array to right-handed
  1849. * @param vector number array to convert to right-handed
  1850. */
  1851. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  1852. /**
  1853. * Converts a Vector4 to right-handed
  1854. * @param vector Vector4 to convert to right-handed
  1855. */
  1856. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  1857. /**
  1858. * Converts a Vector4 to right-handed
  1859. * @param vector Vector4 to convert to right-handed
  1860. */
  1861. static _GetRightHandedArray4FromRef(vector: number[]): void;
  1862. /**
  1863. * Converts a Quaternion to right-handed
  1864. * @param quaternion Source quaternion to convert to right-handed
  1865. */
  1866. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  1867. /**
  1868. * Converts a Quaternion to right-handed
  1869. * @param quaternion Source quaternion to convert to right-handed
  1870. */
  1871. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  1872. static _NormalizeTangentFromRef(tangent: Vector4): void;
  1873. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  1874. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  1875. }
  1876. }
  1877. declare module BABYLON.GLTF2.Exporter {
  1878. /**
  1879. * Converts Babylon Scene into glTF 2.0.
  1880. * @hidden
  1881. */
  1882. export class _Exporter {
  1883. /**
  1884. * Stores the glTF to export
  1885. */
  1886. _glTF: IGLTF;
  1887. /**
  1888. * Stores all generated buffer views, which represents views into the main glTF buffer data
  1889. */
  1890. _bufferViews: IBufferView[];
  1891. /**
  1892. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  1893. */
  1894. _accessors: IAccessor[];
  1895. /**
  1896. * Stores all the generated nodes, which contains transform and/or mesh information per node
  1897. */
  1898. _nodes: INode[];
  1899. /**
  1900. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  1901. */
  1902. private _scenes;
  1903. /**
  1904. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  1905. */
  1906. private _meshes;
  1907. /**
  1908. * Stores all the generated material information, which represents the appearance of each primitive
  1909. */
  1910. _materials: IMaterial[];
  1911. _materialMap: {
  1912. [materialID: number]: number;
  1913. };
  1914. /**
  1915. * Stores all the generated texture information, which is referenced by glTF materials
  1916. */
  1917. _textures: ITexture[];
  1918. /**
  1919. * Stores all the generated image information, which is referenced by glTF textures
  1920. */
  1921. _images: IImage[];
  1922. /**
  1923. * Stores all the texture samplers
  1924. */
  1925. _samplers: ISampler[];
  1926. /**
  1927. * Stores all the generated glTF skins
  1928. */
  1929. _skins: ISkin[];
  1930. /**
  1931. * Stores all the generated animation samplers, which is referenced by glTF animations
  1932. */
  1933. /**
  1934. * Stores the animations for glTF models
  1935. */
  1936. private _animations;
  1937. /**
  1938. * Stores the total amount of bytes stored in the glTF buffer
  1939. */
  1940. private _totalByteLength;
  1941. /**
  1942. * Stores a reference to the Babylon scene containing the source geometry and material information
  1943. */
  1944. _babylonScene: Scene;
  1945. /**
  1946. * Stores a map of the image data, where the key is the file name and the value
  1947. * is the image data
  1948. */
  1949. _imageData: {
  1950. [fileName: string]: {
  1951. data: Uint8Array;
  1952. mimeType: ImageMimeType;
  1953. };
  1954. };
  1955. protected _orderedImageData: Array<{
  1956. data: Uint8Array;
  1957. mimeType: ImageMimeType;
  1958. }>;
  1959. /**
  1960. * Stores a map of the unique id of a node to its index in the node array
  1961. */
  1962. _nodeMap: {
  1963. [key: number]: number;
  1964. };
  1965. /**
  1966. * Specifies if the source Babylon scene was left handed, and needed conversion.
  1967. */
  1968. _convertToRightHandedSystem: boolean;
  1969. /**
  1970. * Specifies if a Babylon node should be converted to right-handed on export
  1971. */
  1972. _convertToRightHandedSystemMap: {
  1973. [nodeId: number]: boolean;
  1974. };
  1975. _includeCoordinateSystemConversionNodes: boolean;
  1976. /**
  1977. * Baked animation sample rate
  1978. */
  1979. private _animationSampleRate;
  1980. private _options;
  1981. private _localEngine;
  1982. _glTFMaterialExporter: _GLTFMaterialExporter;
  1983. private _extensions;
  1984. private static _ExtensionNames;
  1985. private static _ExtensionFactories;
  1986. private _applyExtension;
  1987. private _applyExtensions;
  1988. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  1989. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  1990. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  1991. [key: number]: number;
  1992. }): Promise<Nullable<INode>>;
  1993. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  1994. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  1995. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  1996. private _forEachExtensions;
  1997. private _extensionsOnExporting;
  1998. /**
  1999. * Load glTF serializer extensions
  2000. */
  2001. private _loadExtensions;
  2002. /**
  2003. * Creates a glTF Exporter instance, which can accept optional exporter options
  2004. * @param babylonScene Babylon scene object
  2005. * @param options Options to modify the behavior of the exporter
  2006. */
  2007. constructor(babylonScene: Scene, options?: IExportOptions);
  2008. dispose(): void;
  2009. /**
  2010. * Registers a glTF exporter extension
  2011. * @param name Name of the extension to export
  2012. * @param factory The factory function that creates the exporter extension
  2013. */
  2014. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  2015. /**
  2016. * Un-registers an exporter extension
  2017. * @param name The name fo the exporter extension
  2018. * @returns A boolean indicating whether the extension has been un-registered
  2019. */
  2020. static UnregisterExtension(name: string): boolean;
  2021. private reorderIndicesBasedOnPrimitiveMode;
  2022. /**
  2023. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  2024. * clock-wise during export to glTF
  2025. * @param submesh BabylonJS submesh
  2026. * @param primitiveMode Primitive mode of the mesh
  2027. * @param sideOrientation the winding order of the submesh
  2028. * @param vertexBufferKind The type of vertex attribute
  2029. * @param meshAttributeArray The vertex attribute data
  2030. * @param byteOffset The offset to the binary data
  2031. * @param binaryWriter The binary data for the glTF file
  2032. * @param convertToRightHandedSystem Converts the values to right-handed
  2033. */
  2034. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  2035. /**
  2036. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  2037. * clock-wise during export to glTF
  2038. * @param submesh BabylonJS submesh
  2039. * @param primitiveMode Primitive mode of the mesh
  2040. * @param sideOrientation the winding order of the submesh
  2041. * @param vertexBufferKind The type of vertex attribute
  2042. * @param meshAttributeArray The vertex attribute data
  2043. * @param byteOffset The offset to the binary data
  2044. * @param binaryWriter The binary data for the glTF file
  2045. * @param convertToRightHandedSystem Converts the values to right-handed
  2046. */
  2047. private reorderTriangleFillMode;
  2048. /**
  2049. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  2050. * clock-wise during export to glTF
  2051. * @param submesh BabylonJS submesh
  2052. * @param primitiveMode Primitive mode of the mesh
  2053. * @param sideOrientation the winding order of the submesh
  2054. * @param vertexBufferKind The type of vertex attribute
  2055. * @param meshAttributeArray The vertex attribute data
  2056. * @param byteOffset The offset to the binary data
  2057. * @param binaryWriter The binary data for the glTF file
  2058. * @param convertToRightHandedSystem Converts the values to right-handed
  2059. */
  2060. private reorderTriangleStripDrawMode;
  2061. /**
  2062. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  2063. * clock-wise during export to glTF
  2064. * @param submesh BabylonJS submesh
  2065. * @param primitiveMode Primitive mode of the mesh
  2066. * @param sideOrientation the winding order of the submesh
  2067. * @param vertexBufferKind The type of vertex attribute
  2068. * @param meshAttributeArray The vertex attribute data
  2069. * @param byteOffset The offset to the binary data
  2070. * @param binaryWriter The binary data for the glTF file
  2071. * @param convertToRightHandedSystem Converts the values to right-handed
  2072. */
  2073. private reorderTriangleFanMode;
  2074. /**
  2075. * Writes the vertex attribute data to binary
  2076. * @param vertices The vertices to write to the binary writer
  2077. * @param byteOffset The offset into the binary writer to overwrite binary data
  2078. * @param vertexAttributeKind The vertex attribute type
  2079. * @param meshAttributeArray The vertex attribute data
  2080. * @param binaryWriter The writer containing the binary data
  2081. * @param convertToRightHandedSystem Converts the values to right-handed
  2082. */
  2083. private writeVertexAttributeData;
  2084. /**
  2085. * Writes mesh attribute data to a data buffer
  2086. * Returns the bytelength of the data
  2087. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  2088. * @param meshAttributeArray Array containing the attribute data
  2089. * @param byteStride Specifies the space between data
  2090. * @param binaryWriter The buffer to write the binary data to
  2091. * @param convertToRightHandedSystem Converts the values to right-handed
  2092. */
  2093. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  2094. /**
  2095. * Writes mesh attribute data to a data buffer
  2096. * Returns the bytelength of the data
  2097. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  2098. * @param meshAttributeArray Array containing the attribute data
  2099. * @param byteStride Specifies the space between data
  2100. * @param binaryWriter The buffer to write the binary data to
  2101. * @param convertToRightHandedSystem Converts the values to right-handed
  2102. */
  2103. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  2104. /**
  2105. * Generates glTF json data
  2106. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  2107. * @param glTFPrefix Text to use when prefixing a glTF file
  2108. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  2109. * @returns json data as string
  2110. */
  2111. private generateJSON;
  2112. /**
  2113. * Generates data for .gltf and .bin files based on the glTF prefix string
  2114. * @param glTFPrefix Text to use when prefixing a glTF file
  2115. * @param dispose Dispose the exporter
  2116. * @returns GLTFData with glTF file data
  2117. */
  2118. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  2119. /**
  2120. * Creates a binary buffer for glTF
  2121. * @returns array buffer for binary data
  2122. */
  2123. private _generateBinaryAsync;
  2124. /**
  2125. * Pads the number to a multiple of 4
  2126. * @param num number to pad
  2127. * @returns padded number
  2128. */
  2129. private _getPadding;
  2130. /**
  2131. * @hidden
  2132. */
  2133. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  2134. /**
  2135. * Sets the TRS for each node
  2136. * @param node glTF Node for storing the transformation data
  2137. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  2138. * @param convertToRightHandedSystem Converts the values to right-handed
  2139. */
  2140. private setNodeTransformation;
  2141. private getVertexBufferFromMesh;
  2142. /**
  2143. * Creates a bufferview based on the vertices type for the Babylon mesh
  2144. * @param kind Indicates the type of vertices data
  2145. * @param componentType Indicates the numerical type used to store the data
  2146. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  2147. * @param binaryWriter The buffer to write the bufferview data to
  2148. * @param convertToRightHandedSystem Converts the values to right-handed
  2149. */
  2150. private createBufferViewKind;
  2151. /**
  2152. * Creates a bufferview based on the vertices type for the Babylon mesh
  2153. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  2154. * @param babylonMorphTarget the morph target to be exported
  2155. * @param binaryWriter The buffer to write the bufferview data to
  2156. * @param convertToRightHandedSystem Converts the values to right-handed
  2157. */
  2158. private setMorphTargetAttributes;
  2159. /**
  2160. * The primitive mode of the Babylon mesh
  2161. * @param babylonMesh The BabylonJS mesh
  2162. */
  2163. private getMeshPrimitiveMode;
  2164. /**
  2165. * Sets the primitive mode of the glTF mesh primitive
  2166. * @param meshPrimitive glTF mesh primitive
  2167. * @param primitiveMode The primitive mode
  2168. */
  2169. private setPrimitiveMode;
  2170. /**
  2171. * Sets the vertex attribute accessor based of the glTF mesh primitive
  2172. * @param meshPrimitive glTF mesh primitive
  2173. * @param attributeKind vertex attribute
  2174. * @returns boolean specifying if uv coordinates are present
  2175. */
  2176. private setAttributeKind;
  2177. /**
  2178. * Sets data for the primitive attributes of each submesh
  2179. * @param mesh glTF Mesh object to store the primitive attribute information
  2180. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  2181. * @param binaryWriter Buffer to write the attribute data to
  2182. * @param convertToRightHandedSystem Converts the values to right-handed
  2183. */
  2184. private setPrimitiveAttributesAsync;
  2185. /**
  2186. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  2187. * @param node The node to check
  2188. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  2189. */
  2190. private isBabylonCoordinateSystemConvertingNode;
  2191. /**
  2192. * Creates a glTF scene based on the array of meshes
  2193. * Returns the the total byte offset
  2194. * @param babylonScene Babylon scene to get the mesh data from
  2195. * @param binaryWriter Buffer to write binary data to
  2196. */
  2197. private createSceneAsync;
  2198. /**
  2199. * Creates a mapping of Node unique id to node index and handles animations
  2200. * @param babylonScene Babylon Scene
  2201. * @param nodes Babylon transform nodes
  2202. * @param binaryWriter Buffer to write binary data to
  2203. * @returns Node mapping of unique id to index
  2204. */
  2205. private createNodeMapAndAnimationsAsync;
  2206. /**
  2207. * Creates a glTF node from a Babylon mesh
  2208. * @param babylonMesh Source Babylon mesh
  2209. * @param binaryWriter Buffer for storing geometry data
  2210. * @param convertToRightHandedSystem Converts the values to right-handed
  2211. * @param nodeMap Node mapping of unique id to glTF node index
  2212. * @returns glTF node
  2213. */
  2214. private createNodeAsync;
  2215. /**
  2216. * Creates a glTF skin from a Babylon skeleton
  2217. * @param babylonScene Babylon Scene
  2218. * @param nodes Babylon transform nodes
  2219. * @param binaryWriter Buffer to write binary data to
  2220. * @returns Node mapping of unique id to index
  2221. */
  2222. private createSkinsAsync;
  2223. }
  2224. /**
  2225. * @hidden
  2226. *
  2227. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  2228. */
  2229. export class _BinaryWriter {
  2230. /**
  2231. * Array buffer which stores all binary data
  2232. */
  2233. private _arrayBuffer;
  2234. /**
  2235. * View of the array buffer
  2236. */
  2237. private _dataView;
  2238. /**
  2239. * byte offset of data in array buffer
  2240. */
  2241. private _byteOffset;
  2242. /**
  2243. * Initialize binary writer with an initial byte length
  2244. * @param byteLength Initial byte length of the array buffer
  2245. */
  2246. constructor(byteLength: number);
  2247. /**
  2248. * Resize the array buffer to the specified byte length
  2249. * @param byteLength
  2250. */
  2251. private resizeBuffer;
  2252. /**
  2253. * Get an array buffer with the length of the byte offset
  2254. * @returns ArrayBuffer resized to the byte offset
  2255. */
  2256. getArrayBuffer(): ArrayBuffer;
  2257. /**
  2258. * Get the byte offset of the array buffer
  2259. * @returns byte offset
  2260. */
  2261. getByteOffset(): number;
  2262. /**
  2263. * Stores an UInt8 in the array buffer
  2264. * @param entry
  2265. * @param byteOffset If defined, specifies where to set the value as an offset.
  2266. */
  2267. setUInt8(entry: number, byteOffset?: number): void;
  2268. /**
  2269. * Stores an UInt16 in the array buffer
  2270. * @param entry
  2271. * @param byteOffset If defined, specifies where to set the value as an offset.
  2272. */
  2273. setUInt16(entry: number, byteOffset?: number): void;
  2274. /**
  2275. * Gets an UInt32 in the array buffer
  2276. * @param entry
  2277. * @param byteOffset If defined, specifies where to set the value as an offset.
  2278. */
  2279. getUInt32(byteOffset: number): number;
  2280. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  2281. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  2282. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  2283. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  2284. /**
  2285. * Stores a Float32 in the array buffer
  2286. * @param entry
  2287. */
  2288. setFloat32(entry: number, byteOffset?: number): void;
  2289. /**
  2290. * Stores an UInt32 in the array buffer
  2291. * @param entry
  2292. * @param byteOffset If defined, specifies where to set the value as an offset.
  2293. */
  2294. setUInt32(entry: number, byteOffset?: number): void;
  2295. }
  2296. }
  2297. declare module BABYLON.GLTF2.Exporter {
  2298. /**
  2299. * @hidden
  2300. * Interface to store animation data.
  2301. */
  2302. export interface _IAnimationData {
  2303. /**
  2304. * Keyframe data.
  2305. */
  2306. inputs: number[];
  2307. /**
  2308. * Value data.
  2309. */
  2310. outputs: number[][];
  2311. /**
  2312. * Animation interpolation data.
  2313. */
  2314. samplerInterpolation: AnimationSamplerInterpolation;
  2315. /**
  2316. * Minimum keyframe value.
  2317. */
  2318. inputsMin: number;
  2319. /**
  2320. * Maximum keyframe value.
  2321. */
  2322. inputsMax: number;
  2323. }
  2324. /**
  2325. * @hidden
  2326. */
  2327. export interface _IAnimationInfo {
  2328. /**
  2329. * The target channel for the animation
  2330. */
  2331. animationChannelTargetPath: AnimationChannelTargetPath;
  2332. /**
  2333. * The glTF accessor type for the data.
  2334. */
  2335. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  2336. /**
  2337. * Specifies if quaternions should be used.
  2338. */
  2339. useQuaternion: boolean;
  2340. }
  2341. /**
  2342. * @hidden
  2343. * Utility class for generating glTF animation data from BabylonJS.
  2344. */
  2345. export class _GLTFAnimation {
  2346. /**
  2347. * @ignore
  2348. *
  2349. * Creates glTF channel animation from BabylonJS animation.
  2350. * @param babylonTransformNode - BabylonJS mesh.
  2351. * @param animation - animation.
  2352. * @param animationChannelTargetPath - The target animation channel.
  2353. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  2354. * @param useQuaternion - Specifies if quaternions are used.
  2355. * @returns nullable IAnimationData
  2356. */
  2357. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  2358. private static _DeduceAnimationInfo;
  2359. /**
  2360. * @ignore
  2361. * Create node animations from the transform node animations
  2362. * @param babylonNode
  2363. * @param runtimeGLTFAnimation
  2364. * @param idleGLTFAnimations
  2365. * @param nodeMap
  2366. * @param nodes
  2367. * @param binaryWriter
  2368. * @param bufferViews
  2369. * @param accessors
  2370. * @param convertToRightHandedSystem
  2371. * @param animationSampleRate
  2372. */
  2373. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  2374. [key: number]: number;
  2375. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  2376. /**
  2377. * @ignore
  2378. * Create individual morph animations from the mesh's morph target animation tracks
  2379. * @param babylonNode
  2380. * @param runtimeGLTFAnimation
  2381. * @param idleGLTFAnimations
  2382. * @param nodeMap
  2383. * @param nodes
  2384. * @param binaryWriter
  2385. * @param bufferViews
  2386. * @param accessors
  2387. * @param convertToRightHandedSystem
  2388. * @param animationSampleRate
  2389. */
  2390. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  2391. [key: number]: number;
  2392. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  2393. /**
  2394. * @ignore
  2395. * Create node and morph animations from the animation groups
  2396. * @param babylonScene
  2397. * @param glTFAnimations
  2398. * @param nodeMap
  2399. * @param nodes
  2400. * @param binaryWriter
  2401. * @param bufferViews
  2402. * @param accessors
  2403. * @param convertToRightHandedSystemMap
  2404. * @param animationSampleRate
  2405. */
  2406. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  2407. [key: number]: number;
  2408. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  2409. [nodeId: number]: boolean;
  2410. }, animationSampleRate: number): void;
  2411. private static AddAnimation;
  2412. /**
  2413. * Create a baked animation
  2414. * @param babylonTransformNode BabylonJS mesh
  2415. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  2416. * @param animationChannelTargetPath animation target channel
  2417. * @param minFrame minimum animation frame
  2418. * @param maxFrame maximum animation frame
  2419. * @param fps frames per second of the animation
  2420. * @param inputs input key frames of the animation
  2421. * @param outputs output key frame data of the animation
  2422. * @param convertToRightHandedSystem converts the values to right-handed
  2423. * @param useQuaternion specifies if quaternions should be used
  2424. */
  2425. private static _CreateBakedAnimation;
  2426. private static _ConvertFactorToVector3OrQuaternion;
  2427. private static _SetInterpolatedValue;
  2428. /**
  2429. * Creates linear animation from the animation key frames
  2430. * @param babylonTransformNode BabylonJS mesh
  2431. * @param animation BabylonJS animation
  2432. * @param animationChannelTargetPath The target animation channel
  2433. * @param frameDelta The difference between the last and first frame of the animation
  2434. * @param inputs Array to store the key frame times
  2435. * @param outputs Array to store the key frame data
  2436. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  2437. * @param useQuaternion Specifies if quaternions are used in the animation
  2438. */
  2439. private static _CreateLinearOrStepAnimation;
  2440. /**
  2441. * Creates cubic spline animation from the animation key frames
  2442. * @param babylonTransformNode BabylonJS mesh
  2443. * @param animation BabylonJS animation
  2444. * @param animationChannelTargetPath The target animation channel
  2445. * @param frameDelta The difference between the last and first frame of the animation
  2446. * @param inputs Array to store the key frame times
  2447. * @param outputs Array to store the key frame data
  2448. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  2449. * @param useQuaternion Specifies if quaternions are used in the animation
  2450. */
  2451. private static _CreateCubicSplineAnimation;
  2452. private static _GetBasePositionRotationOrScale;
  2453. /**
  2454. * Adds a key frame value
  2455. * @param keyFrame
  2456. * @param animation
  2457. * @param outputs
  2458. * @param animationChannelTargetPath
  2459. * @param basePositionRotationOrScale
  2460. * @param convertToRightHandedSystem
  2461. * @param useQuaternion
  2462. */
  2463. private static _AddKeyframeValue;
  2464. /**
  2465. * Determine the interpolation based on the key frames
  2466. * @param keyFrames
  2467. * @param animationChannelTargetPath
  2468. * @param useQuaternion
  2469. */
  2470. private static _DeduceInterpolation;
  2471. /**
  2472. * Adds an input tangent or output tangent to the output data
  2473. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  2474. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  2475. * @param outputs The animation data by keyframe
  2476. * @param animationChannelTargetPath The target animation channel
  2477. * @param interpolation The interpolation type
  2478. * @param keyFrame The key frame with the animation data
  2479. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  2480. * @param useQuaternion Specifies if quaternions are used
  2481. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  2482. */
  2483. private static AddSplineTangent;
  2484. /**
  2485. * Get the minimum and maximum key frames' frame values
  2486. * @param keyFrames animation key frames
  2487. * @returns the minimum and maximum key frame value
  2488. */
  2489. private static calculateMinMaxKeyFrames;
  2490. }
  2491. }
  2492. declare module BABYLON.GLTF2.Exporter {
  2493. /** @hidden */
  2494. export var textureTransformPixelShader: {
  2495. name: string;
  2496. shader: string;
  2497. };
  2498. }
  2499. declare module BABYLON.GLTF2.Exporter.Extensions {
  2500. /**
  2501. * @hidden
  2502. */
  2503. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  2504. private _recordedTextures;
  2505. /** Name of this extension */
  2506. readonly name: string;
  2507. /** Defines whether this extension is enabled */
  2508. enabled: boolean;
  2509. /** Defines whether this extension is required */
  2510. required: boolean;
  2511. /** Reference to the glTF exporter */
  2512. private _wasUsed;
  2513. constructor(exporter: _Exporter);
  2514. dispose(): void;
  2515. /** @hidden */
  2516. get wasUsed(): boolean;
  2517. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  2518. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  2519. /**
  2520. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  2521. * @param babylonTexture
  2522. * @param offset
  2523. * @param rotation
  2524. * @param scale
  2525. * @param scene
  2526. */
  2527. private _textureTransformTextureAsync;
  2528. }
  2529. }
  2530. declare module BABYLON.GLTF2.Exporter.Extensions {
  2531. /**
  2532. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  2533. */
  2534. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  2535. /** The name of this extension. */
  2536. readonly name: string;
  2537. /** Defines whether this extension is enabled. */
  2538. enabled: boolean;
  2539. /** Defines whether this extension is required */
  2540. required: boolean;
  2541. /** Reference to the glTF exporter */
  2542. private _exporter;
  2543. private _lights;
  2544. /** @hidden */
  2545. constructor(exporter: _Exporter);
  2546. /** @hidden */
  2547. dispose(): void;
  2548. /** @hidden */
  2549. get wasUsed(): boolean;
  2550. /** @hidden */
  2551. onExporting(): void;
  2552. /**
  2553. * Define this method to modify the default behavior when exporting a node
  2554. * @param context The context when exporting the node
  2555. * @param node glTF node
  2556. * @param babylonNode BabylonJS node
  2557. * @param nodeMap Node mapping of unique id to glTF node index
  2558. * @returns nullable INode promise
  2559. */
  2560. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  2561. [key: number]: number;
  2562. }): Promise<Nullable<INode>>;
  2563. }
  2564. }
  2565. declare module BABYLON.GLTF2.Exporter.Extensions {
  2566. /**
  2567. * @hidden
  2568. */
  2569. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  2570. /** Name of this extension */
  2571. readonly name: string;
  2572. /** Defines whether this extension is enabled */
  2573. enabled: boolean;
  2574. /** Defines whether this extension is required */
  2575. required: boolean;
  2576. /** Reference to the glTF exporter */
  2577. private _textureInfos;
  2578. private _exportedTextures;
  2579. private _wasUsed;
  2580. constructor(exporter: _Exporter);
  2581. dispose(): void;
  2582. /** @hidden */
  2583. get wasUsed(): boolean;
  2584. private _getTextureIndex;
  2585. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  2586. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  2587. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  2588. }
  2589. }
  2590. declare module BABYLON.GLTF2.Exporter.Extensions {
  2591. /**
  2592. * @hidden
  2593. */
  2594. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  2595. /** Name of this extension */
  2596. readonly name: string;
  2597. /** Defines whether this extension is enabled */
  2598. enabled: boolean;
  2599. /** Defines whether this extension is required */
  2600. required: boolean;
  2601. private _wasUsed;
  2602. constructor(exporter: _Exporter);
  2603. /** @hidden */
  2604. get wasUsed(): boolean;
  2605. dispose(): void;
  2606. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  2607. }
  2608. }
  2609. declare module BABYLON {
  2610. /**
  2611. * Class for generating STL data from a Babylon scene.
  2612. */
  2613. export class STLExport {
  2614. /**
  2615. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  2616. * @param meshes list defines the mesh to serialize
  2617. * @param download triggers the automatic download of the file.
  2618. * @param fileName changes the downloads fileName.
  2619. * @param binary changes the STL to a binary type.
  2620. * @param isLittleEndian toggle for binary type exporter.
  2621. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  2622. * @returns the STL as UTF8 string
  2623. */
  2624. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  2625. }
  2626. }