babylonjs.serializers.module.d.ts 121 KB

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