babylonjs.serializers.module.d.ts 96 KB

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