babylonjs.loaders.module.d.ts 162 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619
  1. /*BabylonJS Loaders*/
  2. // Dependencies for this module:
  3. // ../../../../Tools/Gulp/babylonjs
  4. // ../../../../Tools/Gulp/babylonjs-gltf2interface
  5. declare module 'babylonjs-loaders' {
  6. export * from "babylonjs-loaders/src/glTF";
  7. export * from "babylonjs-loaders/src/OBJ";
  8. export * from "babylonjs-loaders/src/STL";
  9. }
  10. declare module 'babylonjs-loaders/src/glTF' {
  11. export * from "babylonjs-loaders/src/glTF/glTFFileLoader";
  12. import * as GLTF1 from "babylonjs-loaders/src/glTF/1.0";
  13. import * as GLTF2 from "babylonjs-loaders/src/glTF/2.0";
  14. export { GLTF1, GLTF2 };
  15. }
  16. declare module 'babylonjs-loaders/src/OBJ' {
  17. export * from "babylonjs-loaders/src/OBJ/objFileLoader";
  18. }
  19. declare module 'babylonjs-loaders/src/STL' {
  20. export * from "babylonjs-loaders/src/STL/stlFileLoader";
  21. }
  22. declare module 'babylonjs-loaders/src/glTF/glTFFileLoader' {
  23. import { IDisposable, Nullable, Scene, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory, Observable, SceneLoaderProgressEvent, AbstractMesh, IParticleSystem, Skeleton, AnimationGroup, BaseTexture, Material, Camera, ISceneLoaderPluginExtensions, ISceneLoaderPlugin, AssetContainer } from "babylonjs";
  24. import { IGLTFValidationResults } from "babylonjs-gltf2interface";
  25. /**
  26. * Mode that determines the coordinate system to use.
  27. */
  28. export enum GLTFLoaderCoordinateSystemMode {
  29. /**
  30. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  31. */
  32. AUTO = 0,
  33. /**
  34. * Sets the useRightHandedSystem flag on the scene.
  35. */
  36. FORCE_RIGHT_HANDED = 1
  37. }
  38. /**
  39. * Mode that determines what animations will start.
  40. */
  41. export enum GLTFLoaderAnimationStartMode {
  42. /**
  43. * No animation will start.
  44. */
  45. NONE = 0,
  46. /**
  47. * The first animation will start.
  48. */
  49. FIRST = 1,
  50. /**
  51. * All animations will start.
  52. */
  53. ALL = 2
  54. }
  55. /**
  56. * Interface that contains the data for the glTF asset.
  57. */
  58. export interface IGLTFLoaderData {
  59. /**
  60. * Object that represents the glTF JSON.
  61. */
  62. json: Object;
  63. /**
  64. * The BIN chunk of a binary glTF.
  65. */
  66. bin: Nullable<ArrayBufferView>;
  67. }
  68. /**
  69. * Interface for extending the loader.
  70. */
  71. export interface IGLTFLoaderExtension {
  72. /**
  73. * The name of this extension.
  74. */
  75. readonly name: string;
  76. /**
  77. * Defines whether this extension is enabled.
  78. */
  79. enabled: boolean;
  80. }
  81. /**
  82. * Loader state.
  83. */
  84. export enum GLTFLoaderState {
  85. /**
  86. * The asset is loading.
  87. */
  88. LOADING = 0,
  89. /**
  90. * The asset is ready for rendering.
  91. */
  92. READY = 1,
  93. /**
  94. * The asset is completely loaded.
  95. */
  96. COMPLETE = 2
  97. }
  98. /** @hidden */
  99. export interface IGLTFLoader extends IDisposable {
  100. readonly state: Nullable<GLTFLoaderState>;
  101. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  102. meshes: AbstractMesh[];
  103. particleSystems: IParticleSystem[];
  104. skeletons: Skeleton[];
  105. animationGroups: AnimationGroup[];
  106. }>;
  107. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  108. }
  109. /**
  110. * File loader for loading glTF files into a scene.
  111. */
  112. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  113. /** @hidden */
  114. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  115. /** @hidden */
  116. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  117. /**
  118. * Raised when the asset has been parsed
  119. */
  120. onParsedObservable: Observable<IGLTFLoaderData>;
  121. /**
  122. * Raised when the asset has been parsed
  123. */
  124. onParsed: (loaderData: IGLTFLoaderData) => void;
  125. /**
  126. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  127. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  128. * Defaults to true.
  129. * @hidden
  130. */
  131. static IncrementalLoading: boolean;
  132. /**
  133. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  134. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  135. * @hidden
  136. */
  137. static HomogeneousCoordinates: boolean;
  138. /**
  139. * The coordinate system mode. Defaults to AUTO.
  140. */
  141. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  142. /**
  143. * The animation start mode. Defaults to FIRST.
  144. */
  145. animationStartMode: GLTFLoaderAnimationStartMode;
  146. /**
  147. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  148. */
  149. compileMaterials: boolean;
  150. /**
  151. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  152. */
  153. useClipPlane: boolean;
  154. /**
  155. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  156. */
  157. compileShadowGenerators: boolean;
  158. /**
  159. * Defines if the Alpha blended materials are only applied as coverage.
  160. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  161. * If true, no extra effects are applied to transparent pixels.
  162. */
  163. transparencyAsCoverage: boolean;
  164. /**
  165. * Function called before loading a url referenced by the asset.
  166. */
  167. preprocessUrlAsync: (url: string) => Promise<string>;
  168. /**
  169. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  170. */
  171. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  172. /**
  173. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  174. */
  175. onMeshLoaded: (mesh: AbstractMesh) => void;
  176. /**
  177. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  178. */
  179. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  180. /**
  181. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  182. */
  183. onTextureLoaded: (texture: BaseTexture) => void;
  184. /**
  185. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  186. */
  187. readonly onMaterialLoadedObservable: Observable<Material>;
  188. /**
  189. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  190. */
  191. onMaterialLoaded: (material: Material) => void;
  192. /**
  193. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  194. */
  195. readonly onCameraLoadedObservable: Observable<Camera>;
  196. /**
  197. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  198. */
  199. onCameraLoaded: (camera: Camera) => void;
  200. /**
  201. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  202. * For assets with LODs, raised when all of the LODs are complete.
  203. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  204. */
  205. readonly onCompleteObservable: Observable<void>;
  206. /**
  207. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  208. * For assets with LODs, raised when all of the LODs are complete.
  209. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  210. */
  211. onComplete: () => void;
  212. /**
  213. * Observable raised when an error occurs.
  214. */
  215. readonly onErrorObservable: Observable<any>;
  216. /**
  217. * Callback raised when an error occurs.
  218. */
  219. onError: (reason: any) => void;
  220. /**
  221. * Observable raised after the loader is disposed.
  222. */
  223. readonly onDisposeObservable: Observable<void>;
  224. /**
  225. * Callback raised after the loader is disposed.
  226. */
  227. onDispose: () => void;
  228. /**
  229. * Observable raised after a loader extension is created.
  230. * Set additional options for a loader extension in this event.
  231. */
  232. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  233. /**
  234. * Callback raised after a loader extension is created.
  235. */
  236. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  237. /**
  238. * Defines if the loader logging is enabled.
  239. */
  240. loggingEnabled: boolean;
  241. /**
  242. * Defines if the loader should capture performance counters.
  243. */
  244. capturePerformanceCounters: boolean;
  245. /**
  246. * Defines if the loader should validate the asset.
  247. */
  248. validate: boolean;
  249. /**
  250. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  251. */
  252. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  253. /**
  254. * Callback raised after a loader extension is created.
  255. */
  256. onValidated: (results: IGLTFValidationResults) => void;
  257. /**
  258. * Name of the loader ("gltf")
  259. */
  260. name: string;
  261. /**
  262. * Supported file extensions of the loader (.gltf, .glb)
  263. */
  264. extensions: ISceneLoaderPluginExtensions;
  265. /**
  266. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  267. */
  268. dispose(): void;
  269. /** @hidden */
  270. _clear(): void;
  271. /**
  272. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  273. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  274. * @param scene the scene the meshes should be added to
  275. * @param data the glTF data to load
  276. * @param rootUrl root url to load from
  277. * @param onProgress event that fires when loading progress has occured
  278. * @param fileName Defines the name of the file to load
  279. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  280. */
  281. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  282. meshes: AbstractMesh[];
  283. particleSystems: IParticleSystem[];
  284. skeletons: Skeleton[];
  285. animationGroups: AnimationGroup[];
  286. }>;
  287. /**
  288. * Imports all objects from the loaded glTF data and adds them to the scene
  289. * @param scene the scene the objects should be added to
  290. * @param data the glTF data to load
  291. * @param rootUrl root url to load from
  292. * @param onProgress event that fires when loading progress has occured
  293. * @param fileName Defines the name of the file to load
  294. * @returns a promise which completes when objects have been loaded to the scene
  295. */
  296. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  297. /**
  298. * Load into an asset container.
  299. * @param scene The scene to load into
  300. * @param data The data to import
  301. * @param rootUrl The root url for scene and resources
  302. * @param onProgress The callback when the load progresses
  303. * @param fileName Defines the name of the file to load
  304. * @returns The loaded asset container
  305. */
  306. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  307. /**
  308. * If the data string can be loaded directly.
  309. * @param data string contianing the file data
  310. * @returns if the data can be loaded directly
  311. */
  312. canDirectLoad(data: string): boolean;
  313. /**
  314. * Rewrites a url by combining a root url and response url.
  315. */
  316. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  317. /**
  318. * Instantiates a glTF file loader plugin.
  319. * @returns the created plugin
  320. */
  321. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  322. /**
  323. * The loader state or null if the loader is not active.
  324. */
  325. readonly loaderState: Nullable<GLTFLoaderState>;
  326. /**
  327. * Returns a promise that resolves when the asset is completely loaded.
  328. * @returns a promise that resolves when the asset is completely loaded.
  329. */
  330. whenCompleteAsync(): Promise<void>;
  331. /** @hidden */
  332. _log: (message: string) => void;
  333. /** @hidden */
  334. _logOpen(message: string): void;
  335. /** @hidden */
  336. _logClose(): void;
  337. /** @hidden */
  338. _startPerformanceCounter: (counterName: string) => void;
  339. /** @hidden */
  340. _endPerformanceCounter: (counterName: string) => void;
  341. }
  342. }
  343. declare module 'babylonjs-loaders/src/glTF/1.0' {
  344. export * from "babylonjs-loaders/src/glTF/1.0/glTFBinaryExtension";
  345. export * from "babylonjs-loaders/src/glTF/1.0/glTFLoader";
  346. export * from "babylonjs-loaders/src/glTF/1.0/glTFLoaderExtension";
  347. export * from "babylonjs-loaders/src/glTF/1.0/glTFLoaderInterfaces";
  348. export * from "babylonjs-loaders/src/glTF/1.0/glTFLoaderUtils";
  349. export * from "babylonjs-loaders/src/glTF/1.0/glTFMaterialsCommonExtension";
  350. }
  351. declare module 'babylonjs-loaders/src/glTF/2.0' {
  352. export * from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  353. export * from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  354. export * from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  355. export * from "babylonjs-loaders/src/glTF/2.0/Extensions";
  356. }
  357. declare module 'babylonjs-loaders/src/OBJ/objFileLoader' {
  358. import { StandardMaterial, Scene, ISceneLoaderPluginAsync, SceneLoaderProgressEvent, AbstractMesh, IParticleSystem, Skeleton, AnimationGroup, AssetContainer } from "babylonjs";
  359. /**
  360. * Class reading and parsing the MTL file bundled with the obj file.
  361. */
  362. export class MTLFileLoader {
  363. /**
  364. * All material loaded from the mtl will be set here
  365. */
  366. materials: StandardMaterial[];
  367. /**
  368. * This function will read the mtl file and create each material described inside
  369. * This function could be improve by adding :
  370. * -some component missing (Ni, Tf...)
  371. * -including the specific options available
  372. *
  373. * @param scene defines the scene the material will be created in
  374. * @param data defines the mtl data to parse
  375. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  376. */
  377. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  378. }
  379. /**
  380. * OBJ file type loader.
  381. * This is a babylon scene loader plugin.
  382. */
  383. export class OBJFileLoader implements ISceneLoaderPluginAsync {
  384. /**
  385. * Defines if UVs are optimized by default during load.
  386. */
  387. static OPTIMIZE_WITH_UV: boolean;
  388. /**
  389. * Defines if Y is inverted by default during load.
  390. */
  391. static INVERT_Y: boolean;
  392. /**
  393. * Defines the name of the plugin.
  394. */
  395. name: string;
  396. /**
  397. * Defines the extension the plugin is able to load.
  398. */
  399. extensions: string;
  400. /** @hidden */
  401. obj: RegExp;
  402. /** @hidden */
  403. group: RegExp;
  404. /** @hidden */
  405. mtllib: RegExp;
  406. /** @hidden */
  407. usemtl: RegExp;
  408. /** @hidden */
  409. smooth: RegExp;
  410. /** @hidden */
  411. vertexPattern: RegExp;
  412. /** @hidden */
  413. normalPattern: RegExp;
  414. /** @hidden */
  415. uvPattern: RegExp;
  416. /** @hidden */
  417. facePattern1: RegExp;
  418. /** @hidden */
  419. facePattern2: RegExp;
  420. /** @hidden */
  421. facePattern3: RegExp;
  422. /** @hidden */
  423. facePattern4: RegExp;
  424. /** @hidden */
  425. facePattern5: RegExp;
  426. /**
  427. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  428. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  429. * @param scene the scene the meshes should be added to
  430. * @param data the glTF data to load
  431. * @param rootUrl root url to load from
  432. * @param onProgress event that fires when loading progress has occured
  433. * @param fileName Defines the name of the file to load
  434. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  435. */
  436. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  437. meshes: AbstractMesh[];
  438. particleSystems: IParticleSystem[];
  439. skeletons: Skeleton[];
  440. animationGroups: AnimationGroup[];
  441. }>;
  442. /**
  443. * Imports all objects from the loaded glTF data and adds them to the scene
  444. * @param scene the scene the objects should be added to
  445. * @param data the glTF data to load
  446. * @param rootUrl root url to load from
  447. * @param onProgress event that fires when loading progress has occured
  448. * @param fileName Defines the name of the file to load
  449. * @returns a promise which completes when objects have been loaded to the scene
  450. */
  451. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  452. /**
  453. * Load into an asset container.
  454. * @param scene The scene to load into
  455. * @param data The data to import
  456. * @param rootUrl The root url for scene and resources
  457. * @param onProgress The callback when the load progresses
  458. * @param fileName Defines the name of the file to load
  459. * @returns The loaded asset container
  460. */
  461. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  462. }
  463. }
  464. declare module 'babylonjs-loaders/src/STL/stlFileLoader' {
  465. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions, Scene, Nullable, AbstractMesh, IParticleSystem, Skeleton, AssetContainer } from "babylonjs";
  466. /**
  467. * STL file type loader.
  468. * This is a babylon scene loader plugin.
  469. */
  470. export class STLFileLoader implements ISceneLoaderPlugin {
  471. /** @hidden */
  472. solidPattern: RegExp;
  473. /** @hidden */
  474. facetsPattern: RegExp;
  475. /** @hidden */
  476. normalPattern: RegExp;
  477. /** @hidden */
  478. vertexPattern: RegExp;
  479. /**
  480. * Defines the name of the plugin.
  481. */
  482. name: string;
  483. /**
  484. * Defines the extensions the stl loader is able to load.
  485. * force data to come in as an ArrayBuffer
  486. * we'll convert to string if it looks like it's an ASCII .stl
  487. */
  488. extensions: ISceneLoaderPluginExtensions;
  489. /**
  490. * Import meshes into a scene.
  491. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  492. * @param scene The scene to import into
  493. * @param data The data to import
  494. * @param rootUrl The root url for scene and resources
  495. * @param meshes The meshes array to import into
  496. * @param particleSystems The particle systems array to import into
  497. * @param skeletons The skeletons array to import into
  498. * @param onError The callback when import fails
  499. * @returns True if successful or false otherwise
  500. */
  501. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  502. /**
  503. * Load into a scene.
  504. * @param scene The scene to load into
  505. * @param data The data to import
  506. * @param rootUrl The root url for scene and resources
  507. * @param onError The callback when import fails
  508. * @returns true if successful or false otherwise
  509. */
  510. load(scene: Scene, data: any, rootUrl: string): boolean;
  511. /**
  512. * Load into an asset container.
  513. * @param scene The scene to load into
  514. * @param data The data to import
  515. * @param rootUrl The root url for scene and resources
  516. * @param onError The callback when import fails
  517. * @returns The loaded asset container
  518. */
  519. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  520. }
  521. }
  522. declare module 'babylonjs-loaders/src/glTF/1.0/glTFBinaryExtension' {
  523. import { GLTFLoaderExtension } from "babylonjs-loaders/src/glTF/1.0/glTFLoaderExtension";
  524. import { Scene } from "babylonjs";
  525. import { IGLTFLoaderData } from "babylonjs-loaders/src/glTF/glTFFileLoader";
  526. import { IGLTFRuntime } from "babylonjs-loaders/src/glTF/1.0/glTFLoaderInterfaces";
  527. /** @hidden */
  528. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  529. constructor();
  530. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  531. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  532. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  533. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  534. }
  535. }
  536. declare module 'babylonjs-loaders/src/glTF/1.0/glTFLoader' {
  537. import { IGLTFRuntime } from "babylonjs-loaders/src/glTF/1.0/glTFLoaderInterfaces";
  538. import { Nullable, Skeleton, Material, AbstractMesh, Texture, Scene, SceneLoaderProgressEvent, IParticleSystem, AnimationGroup } from "babylonjs";
  539. import { IGLTFLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/src/glTF/glTFFileLoader";
  540. import { GLTFLoaderExtension } from "babylonjs-loaders/src/glTF/1.0/glTFLoaderExtension";
  541. /**
  542. * Implementation of the base glTF spec
  543. * @hidden
  544. */
  545. export class GLTFLoaderBase {
  546. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  547. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  548. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  549. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  550. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  551. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  552. }
  553. /**
  554. * glTF V1 Loader
  555. * @hidden
  556. */
  557. export class GLTFLoader implements IGLTFLoader {
  558. static Extensions: {
  559. [name: string]: GLTFLoaderExtension;
  560. };
  561. static RegisterExtension(extension: GLTFLoaderExtension): void;
  562. state: Nullable<GLTFLoaderState>;
  563. dispose(): void;
  564. /**
  565. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  566. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  567. * @param scene the scene the meshes should be added to
  568. * @param data gltf data containing information of the meshes in a loaded file
  569. * @param rootUrl root url to load from
  570. * @param onProgress event that fires when loading progress has occured
  571. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  572. */
  573. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  574. meshes: AbstractMesh[];
  575. particleSystems: IParticleSystem[];
  576. skeletons: Skeleton[];
  577. animationGroups: AnimationGroup[];
  578. }>;
  579. /**
  580. * Imports all objects from a loaded gltf file and adds them to the scene
  581. * @param scene the scene the objects should be added to
  582. * @param data gltf data containing information of the meshes in a loaded file
  583. * @param rootUrl root url to load from
  584. * @param onProgress event that fires when loading progress has occured
  585. * @returns a promise which completes when objects have been loaded to the scene
  586. */
  587. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  588. }
  589. }
  590. declare module 'babylonjs-loaders/src/glTF/1.0/glTFLoaderExtension' {
  591. import { Scene, Texture, Material } from "babylonjs";
  592. import { IGLTFLoaderData } from "babylonjs-loaders/src/glTF/glTFFileLoader";
  593. import { IGLTFRuntime } from "babylonjs-loaders/src/glTF/1.0/glTFLoaderInterfaces";
  594. /** @hidden */
  595. export abstract class GLTFLoaderExtension {
  596. constructor(name: string);
  597. readonly name: string;
  598. /**
  599. * Defines an override for loading the runtime
  600. * Return true to stop further extensions from loading the runtime
  601. */
  602. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  603. /**
  604. * Defines an onverride for creating gltf runtime
  605. * Return true to stop further extensions from creating the runtime
  606. */
  607. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  608. /**
  609. * Defines an override for loading buffers
  610. * Return true to stop further extensions from loading this buffer
  611. */
  612. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  613. /**
  614. * Defines an override for loading texture buffers
  615. * Return true to stop further extensions from loading this texture data
  616. */
  617. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  618. /**
  619. * Defines an override for creating textures
  620. * Return true to stop further extensions from loading this texture
  621. */
  622. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  623. /**
  624. * Defines an override for loading shader strings
  625. * Return true to stop further extensions from loading this shader data
  626. */
  627. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  628. /**
  629. * Defines an override for loading materials
  630. * Return true to stop further extensions from loading this material
  631. */
  632. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  633. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  634. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  635. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  636. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  637. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  638. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  639. }
  640. }
  641. declare module 'babylonjs-loaders/src/glTF/1.0/glTFLoaderInterfaces' {
  642. import { Texture, Skeleton, Scene, Bone, Node } from "babylonjs";
  643. /**
  644. * Enums
  645. * @hidden
  646. */
  647. export enum EComponentType {
  648. BYTE = 5120,
  649. UNSIGNED_BYTE = 5121,
  650. SHORT = 5122,
  651. UNSIGNED_SHORT = 5123,
  652. FLOAT = 5126
  653. }
  654. /** @hidden */
  655. export enum EShaderType {
  656. FRAGMENT = 35632,
  657. VERTEX = 35633
  658. }
  659. /** @hidden */
  660. export enum EParameterType {
  661. BYTE = 5120,
  662. UNSIGNED_BYTE = 5121,
  663. SHORT = 5122,
  664. UNSIGNED_SHORT = 5123,
  665. INT = 5124,
  666. UNSIGNED_INT = 5125,
  667. FLOAT = 5126,
  668. FLOAT_VEC2 = 35664,
  669. FLOAT_VEC3 = 35665,
  670. FLOAT_VEC4 = 35666,
  671. INT_VEC2 = 35667,
  672. INT_VEC3 = 35668,
  673. INT_VEC4 = 35669,
  674. BOOL = 35670,
  675. BOOL_VEC2 = 35671,
  676. BOOL_VEC3 = 35672,
  677. BOOL_VEC4 = 35673,
  678. FLOAT_MAT2 = 35674,
  679. FLOAT_MAT3 = 35675,
  680. FLOAT_MAT4 = 35676,
  681. SAMPLER_2D = 35678
  682. }
  683. /** @hidden */
  684. export enum ETextureWrapMode {
  685. CLAMP_TO_EDGE = 33071,
  686. MIRRORED_REPEAT = 33648,
  687. REPEAT = 10497
  688. }
  689. /** @hidden */
  690. export enum ETextureFilterType {
  691. NEAREST = 9728,
  692. LINEAR = 9728,
  693. NEAREST_MIPMAP_NEAREST = 9984,
  694. LINEAR_MIPMAP_NEAREST = 9985,
  695. NEAREST_MIPMAP_LINEAR = 9986,
  696. LINEAR_MIPMAP_LINEAR = 9987
  697. }
  698. /** @hidden */
  699. export enum ETextureFormat {
  700. ALPHA = 6406,
  701. RGB = 6407,
  702. RGBA = 6408,
  703. LUMINANCE = 6409,
  704. LUMINANCE_ALPHA = 6410
  705. }
  706. /** @hidden */
  707. export enum ECullingType {
  708. FRONT = 1028,
  709. BACK = 1029,
  710. FRONT_AND_BACK = 1032
  711. }
  712. /** @hidden */
  713. export enum EBlendingFunction {
  714. ZERO = 0,
  715. ONE = 1,
  716. SRC_COLOR = 768,
  717. ONE_MINUS_SRC_COLOR = 769,
  718. DST_COLOR = 774,
  719. ONE_MINUS_DST_COLOR = 775,
  720. SRC_ALPHA = 770,
  721. ONE_MINUS_SRC_ALPHA = 771,
  722. DST_ALPHA = 772,
  723. ONE_MINUS_DST_ALPHA = 773,
  724. CONSTANT_COLOR = 32769,
  725. ONE_MINUS_CONSTANT_COLOR = 32770,
  726. CONSTANT_ALPHA = 32771,
  727. ONE_MINUS_CONSTANT_ALPHA = 32772,
  728. SRC_ALPHA_SATURATE = 776
  729. }
  730. /** @hidden */
  731. export interface IGLTFProperty {
  732. extensions?: {
  733. [key: string]: any;
  734. };
  735. extras?: Object;
  736. }
  737. /** @hidden */
  738. export interface IGLTFChildRootProperty extends IGLTFProperty {
  739. name?: string;
  740. }
  741. /** @hidden */
  742. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  743. bufferView: string;
  744. byteOffset: number;
  745. byteStride: number;
  746. count: number;
  747. type: string;
  748. componentType: EComponentType;
  749. max?: number[];
  750. min?: number[];
  751. name?: string;
  752. }
  753. /** @hidden */
  754. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  755. buffer: string;
  756. byteOffset: number;
  757. byteLength: number;
  758. byteStride: number;
  759. target?: number;
  760. }
  761. /** @hidden */
  762. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  763. uri: string;
  764. byteLength?: number;
  765. type?: string;
  766. }
  767. /** @hidden */
  768. export interface IGLTFShader extends IGLTFChildRootProperty {
  769. uri: string;
  770. type: EShaderType;
  771. }
  772. /** @hidden */
  773. export interface IGLTFProgram extends IGLTFChildRootProperty {
  774. attributes: string[];
  775. fragmentShader: string;
  776. vertexShader: string;
  777. }
  778. /** @hidden */
  779. export interface IGLTFTechniqueParameter {
  780. type: number;
  781. count?: number;
  782. semantic?: string;
  783. node?: string;
  784. value?: number | boolean | string | Array<any>;
  785. source?: string;
  786. babylonValue?: any;
  787. }
  788. /** @hidden */
  789. export interface IGLTFTechniqueCommonProfile {
  790. lightingModel: string;
  791. texcoordBindings: Object;
  792. parameters?: Array<any>;
  793. }
  794. /** @hidden */
  795. export interface IGLTFTechniqueStatesFunctions {
  796. blendColor?: number[];
  797. blendEquationSeparate?: number[];
  798. blendFuncSeparate?: number[];
  799. colorMask: boolean[];
  800. cullFace: number[];
  801. }
  802. /** @hidden */
  803. export interface IGLTFTechniqueStates {
  804. enable: number[];
  805. functions: IGLTFTechniqueStatesFunctions;
  806. }
  807. /** @hidden */
  808. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  809. parameters: {
  810. [key: string]: IGLTFTechniqueParameter;
  811. };
  812. program: string;
  813. attributes: {
  814. [key: string]: string;
  815. };
  816. uniforms: {
  817. [key: string]: string;
  818. };
  819. states: IGLTFTechniqueStates;
  820. }
  821. /** @hidden */
  822. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  823. technique?: string;
  824. values: string[];
  825. }
  826. /** @hidden */
  827. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  828. attributes: {
  829. [key: string]: string;
  830. };
  831. indices: string;
  832. material: string;
  833. mode?: number;
  834. }
  835. /** @hidden */
  836. export interface IGLTFMesh extends IGLTFChildRootProperty {
  837. primitives: IGLTFMeshPrimitive[];
  838. }
  839. /** @hidden */
  840. export interface IGLTFImage extends IGLTFChildRootProperty {
  841. uri: string;
  842. }
  843. /** @hidden */
  844. export interface IGLTFSampler extends IGLTFChildRootProperty {
  845. magFilter?: number;
  846. minFilter?: number;
  847. wrapS?: number;
  848. wrapT?: number;
  849. }
  850. /** @hidden */
  851. export interface IGLTFTexture extends IGLTFChildRootProperty {
  852. sampler: string;
  853. source: string;
  854. format?: ETextureFormat;
  855. internalFormat?: ETextureFormat;
  856. target?: number;
  857. type?: number;
  858. babylonTexture?: Texture;
  859. }
  860. /** @hidden */
  861. export interface IGLTFAmbienLight {
  862. color?: number[];
  863. }
  864. /** @hidden */
  865. export interface IGLTFDirectionalLight {
  866. color?: number[];
  867. }
  868. /** @hidden */
  869. export interface IGLTFPointLight {
  870. color?: number[];
  871. constantAttenuation?: number;
  872. linearAttenuation?: number;
  873. quadraticAttenuation?: number;
  874. }
  875. /** @hidden */
  876. export interface IGLTFSpotLight {
  877. color?: number[];
  878. constantAttenuation?: number;
  879. fallOfAngle?: number;
  880. fallOffExponent?: number;
  881. linearAttenuation?: number;
  882. quadraticAttenuation?: number;
  883. }
  884. /** @hidden */
  885. export interface IGLTFLight extends IGLTFChildRootProperty {
  886. type: string;
  887. }
  888. /** @hidden */
  889. export interface IGLTFCameraOrthographic {
  890. xmag: number;
  891. ymag: number;
  892. zfar: number;
  893. znear: number;
  894. }
  895. /** @hidden */
  896. export interface IGLTFCameraPerspective {
  897. aspectRatio: number;
  898. yfov: number;
  899. zfar: number;
  900. znear: number;
  901. }
  902. /** @hidden */
  903. export interface IGLTFCamera extends IGLTFChildRootProperty {
  904. type: string;
  905. }
  906. /** @hidden */
  907. export interface IGLTFAnimationChannelTarget {
  908. id: string;
  909. path: string;
  910. }
  911. /** @hidden */
  912. export interface IGLTFAnimationChannel {
  913. sampler: string;
  914. target: IGLTFAnimationChannelTarget;
  915. }
  916. /** @hidden */
  917. export interface IGLTFAnimationSampler {
  918. input: string;
  919. output: string;
  920. interpolation?: string;
  921. }
  922. /** @hidden */
  923. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  924. channels?: IGLTFAnimationChannel[];
  925. parameters?: {
  926. [key: string]: string;
  927. };
  928. samplers?: {
  929. [key: string]: IGLTFAnimationSampler;
  930. };
  931. }
  932. /** @hidden */
  933. export interface IGLTFNodeInstanceSkin {
  934. skeletons: string[];
  935. skin: string;
  936. meshes: string[];
  937. }
  938. /** @hidden */
  939. export interface IGLTFSkins extends IGLTFChildRootProperty {
  940. bindShapeMatrix: number[];
  941. inverseBindMatrices: string;
  942. jointNames: string[];
  943. babylonSkeleton?: Skeleton;
  944. }
  945. /** @hidden */
  946. export interface IGLTFNode extends IGLTFChildRootProperty {
  947. camera?: string;
  948. children: string[];
  949. skin?: string;
  950. jointName?: string;
  951. light?: string;
  952. matrix: number[];
  953. mesh?: string;
  954. meshes?: string[];
  955. rotation?: number[];
  956. scale?: number[];
  957. translation?: number[];
  958. babylonNode?: Node;
  959. }
  960. /** @hidden */
  961. export interface IGLTFScene extends IGLTFChildRootProperty {
  962. nodes: string[];
  963. }
  964. /** @hidden */
  965. export interface IGLTFRuntime {
  966. extensions: {
  967. [key: string]: any;
  968. };
  969. accessors: {
  970. [key: string]: IGLTFAccessor;
  971. };
  972. buffers: {
  973. [key: string]: IGLTFBuffer;
  974. };
  975. bufferViews: {
  976. [key: string]: IGLTFBufferView;
  977. };
  978. meshes: {
  979. [key: string]: IGLTFMesh;
  980. };
  981. lights: {
  982. [key: string]: IGLTFLight;
  983. };
  984. cameras: {
  985. [key: string]: IGLTFCamera;
  986. };
  987. nodes: {
  988. [key: string]: IGLTFNode;
  989. };
  990. images: {
  991. [key: string]: IGLTFImage;
  992. };
  993. textures: {
  994. [key: string]: IGLTFTexture;
  995. };
  996. shaders: {
  997. [key: string]: IGLTFShader;
  998. };
  999. programs: {
  1000. [key: string]: IGLTFProgram;
  1001. };
  1002. samplers: {
  1003. [key: string]: IGLTFSampler;
  1004. };
  1005. techniques: {
  1006. [key: string]: IGLTFTechnique;
  1007. };
  1008. materials: {
  1009. [key: string]: IGLTFMaterial;
  1010. };
  1011. animations: {
  1012. [key: string]: IGLTFAnimation;
  1013. };
  1014. skins: {
  1015. [key: string]: IGLTFSkins;
  1016. };
  1017. currentScene?: Object;
  1018. scenes: {
  1019. [key: string]: IGLTFScene;
  1020. };
  1021. extensionsUsed: string[];
  1022. extensionsRequired?: string[];
  1023. buffersCount: number;
  1024. shaderscount: number;
  1025. scene: Scene;
  1026. rootUrl: string;
  1027. loadedBufferCount: number;
  1028. loadedBufferViews: {
  1029. [name: string]: ArrayBufferView;
  1030. };
  1031. loadedShaderCount: number;
  1032. importOnlyMeshes: boolean;
  1033. importMeshesNames?: string[];
  1034. dummyNodes: Node[];
  1035. }
  1036. /** @hidden */
  1037. export interface INodeToRoot {
  1038. bone: Bone;
  1039. node: IGLTFNode;
  1040. id: string;
  1041. }
  1042. /** @hidden */
  1043. export interface IJointNode {
  1044. node: IGLTFNode;
  1045. id: string;
  1046. }
  1047. }
  1048. declare module 'babylonjs-loaders/src/glTF/1.0/glTFLoaderUtils' {
  1049. import { Scene, ShaderMaterial, Effect, Node } from "babylonjs";
  1050. import { IGLTFTechniqueParameter, IGLTFAccessor, ETextureFilterType, IGLTFRuntime, IGLTFBufferView, EComponentType } from "babylonjs-loaders/src/glTF/1.0/glTFLoaderInterfaces";
  1051. /**
  1052. * Utils functions for GLTF
  1053. * @hidden
  1054. */
  1055. export class GLTFUtils {
  1056. /**
  1057. * Sets the given "parameter" matrix
  1058. * @param scene: the Scene object
  1059. * @param source: the source node where to pick the matrix
  1060. * @param parameter: the GLTF technique parameter
  1061. * @param uniformName: the name of the shader's uniform
  1062. * @param shaderMaterial: the shader material
  1063. */
  1064. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  1065. /**
  1066. * Sets the given "parameter" matrix
  1067. * @param shaderMaterial: the shader material
  1068. * @param uniform: the name of the shader's uniform
  1069. * @param value: the value of the uniform
  1070. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  1071. */
  1072. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  1073. /**
  1074. * Returns the wrap mode of the texture
  1075. * @param mode: the mode value
  1076. */
  1077. static GetWrapMode(mode: number): number;
  1078. /**
  1079. * Returns the byte stride giving an accessor
  1080. * @param accessor: the GLTF accessor objet
  1081. */
  1082. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  1083. /**
  1084. * Returns the texture filter mode giving a mode value
  1085. * @param mode: the filter mode value
  1086. */
  1087. static GetTextureFilterMode(mode: number): ETextureFilterType;
  1088. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  1089. /**
  1090. * Returns a buffer from its accessor
  1091. * @param gltfRuntime: the GLTF runtime
  1092. * @param accessor: the GLTF accessor
  1093. */
  1094. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  1095. /**
  1096. * Decodes a buffer view into a string
  1097. * @param view: the buffer view
  1098. */
  1099. static DecodeBufferToText(view: ArrayBufferView): string;
  1100. /**
  1101. * Returns the default material of gltf. Related to
  1102. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  1103. * @param scene: the Babylon.js scene
  1104. */
  1105. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  1106. }
  1107. }
  1108. declare module 'babylonjs-loaders/src/glTF/1.0/glTFMaterialsCommonExtension' {
  1109. import { GLTFLoaderExtension } from "babylonjs-loaders/src/glTF/1.0";
  1110. import { IGLTFRuntime } from "babylonjs-loaders/src/glTF/1.0/glTFLoaderInterfaces";
  1111. import { Material } from "babylonjs";
  1112. /** @hidden */
  1113. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  1114. constructor();
  1115. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  1116. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  1117. }
  1118. }
  1119. declare module 'babylonjs-loaders/src/glTF/2.0/glTFLoader' {
  1120. import { Scene, Nullable, Mesh, Material, SceneLoaderProgressEvent, AbstractMesh, IParticleSystem, Skeleton, AnimationGroup, Camera, BaseTexture } from "babylonjs";
  1121. import { IProperty } from "babylonjs-gltf2interface";
  1122. import { IGLTF, INode, IScene, ICamera, IAnimation, IBufferView, IMaterial, ITextureInfo, IImage, IArrayItem } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1123. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1124. import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/src/glTF/glTFFileLoader";
  1125. /**
  1126. * Helper class for working with arrays when loading the glTF asset
  1127. */
  1128. export class ArrayItem {
  1129. /**
  1130. * Gets an item from the given array.
  1131. * @param context The context when loading the asset
  1132. * @param array The array to get the item from
  1133. * @param index The index to the array
  1134. * @returns The array item
  1135. */
  1136. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1137. /**
  1138. * Assign an `index` field to each item of the given array.
  1139. * @param array The array of items
  1140. */
  1141. static Assign(array?: IArrayItem[]): void;
  1142. }
  1143. /**
  1144. * The glTF 2.0 loader
  1145. */
  1146. export class GLTFLoader implements IGLTFLoader {
  1147. /** The glTF object parsed from the JSON. */
  1148. gltf: IGLTF;
  1149. /** The Babylon scene when loading the asset. */
  1150. babylonScene: Scene;
  1151. /** @hidden */
  1152. _completePromises: Promise<any>[];
  1153. /**
  1154. * Registers a loader extension.
  1155. * @param name The name of the loader extension.
  1156. * @param factory The factory function that creates the loader extension.
  1157. */
  1158. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1159. /**
  1160. * Unregisters a loader extension.
  1161. * @param name The name of the loader extenion.
  1162. * @returns A boolean indicating whether the extension has been unregistered
  1163. */
  1164. static UnregisterExtension(name: string): boolean;
  1165. /**
  1166. * Gets the loader state.
  1167. */
  1168. readonly state: Nullable<GLTFLoaderState>;
  1169. /** @hidden */
  1170. constructor(parent: GLTFFileLoader);
  1171. /** @hidden */
  1172. dispose(): void;
  1173. /** @hidden */
  1174. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1175. meshes: AbstractMesh[];
  1176. particleSystems: IParticleSystem[];
  1177. skeletons: Skeleton[];
  1178. animationGroups: AnimationGroup[];
  1179. }>;
  1180. /** @hidden */
  1181. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1182. /**
  1183. * Loads a glTF scene.
  1184. * @param context The context when loading the asset
  1185. * @param scene The glTF scene property
  1186. * @returns A promise that resolves when the load is complete
  1187. */
  1188. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  1189. /**
  1190. * Loads a glTF node.
  1191. * @param context The context when loading the asset
  1192. * @param node The glTF node property
  1193. * @param assign A function called synchronously after parsing the glTF properties
  1194. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1195. */
  1196. loadNodeAsync(context: string, node: INode, assign?: (babylonMesh: Mesh) => void): Promise<Mesh>;
  1197. /**
  1198. * Loads a glTF camera.
  1199. * @param context The context when loading the asset
  1200. * @param camera The glTF camera property
  1201. * @param assign A function called synchronously after parsing the glTF properties
  1202. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1203. */
  1204. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1205. /**
  1206. * Loads a glTF animation.
  1207. * @param context The context when loading the asset
  1208. * @param animation The glTF animation property
  1209. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1210. */
  1211. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  1212. /**
  1213. * Loads a glTF buffer view.
  1214. * @param context The context when loading the asset
  1215. * @param bufferView The glTF buffer view property
  1216. * @returns A promise that resolves with the loaded data when the load is complete
  1217. */
  1218. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1219. /** @hidden */
  1220. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1221. /**
  1222. * Creates a Babylon material from a glTF material.
  1223. * @param context The context when loading the asset
  1224. * @param material The glTF material property
  1225. * @param babylonDrawMode The draw mode for the Babylon material
  1226. * @returns The Babylon material
  1227. */
  1228. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1229. /**
  1230. * Loads properties from a glTF material into a Babylon material.
  1231. * @param context The context when loading the asset
  1232. * @param material The glTF material property
  1233. * @param babylonMaterial The Babylon material
  1234. * @returns A promise that resolves when the load is complete
  1235. */
  1236. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1237. /**
  1238. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1239. * @param context The context when loading the asset
  1240. * @param material The glTF material property
  1241. * @param babylonMaterial The Babylon material
  1242. * @returns A promise that resolves when the load is complete
  1243. */
  1244. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1245. /**
  1246. * Loads the alpha properties from a glTF material into a Babylon material.
  1247. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1248. * @param context The context when loading the asset
  1249. * @param material The glTF material property
  1250. * @param babylonMaterial The Babylon material
  1251. */
  1252. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1253. /**
  1254. * Loads a glTF texture info.
  1255. * @param context The context when loading the asset
  1256. * @param textureInfo The glTF texture info property
  1257. * @param assign A function called synchronously after parsing the glTF properties
  1258. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1259. */
  1260. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1261. /**
  1262. * Loads a glTF image.
  1263. * @param context The context when loading the asset
  1264. * @param image The glTF image property
  1265. * @returns A promise that resolves with the loaded data when the load is complete
  1266. */
  1267. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1268. /**
  1269. * Loads a glTF uri.
  1270. * @param context The context when loading the asset
  1271. * @param uri The base64 or relative uri
  1272. * @returns A promise that resolves with the loaded data when the load is complete
  1273. */
  1274. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  1275. /**
  1276. * Helper method called by a loader extension to load an glTF extension.
  1277. * @param context The context when loading the asset
  1278. * @param property The glTF property to load the extension from
  1279. * @param extensionName The name of the extension to load
  1280. * @param actionAsync The action to run
  1281. * @returns The promise returned by actionAsync or null if the extension does not exist
  1282. */
  1283. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1284. /**
  1285. * Helper method called by a loader extension to load a glTF extra.
  1286. * @param context The context when loading the asset
  1287. * @param property The glTF property to load the extra from
  1288. * @param extensionName The name of the extension to load
  1289. * @param actionAsync The action to run
  1290. * @returns The promise returned by actionAsync or null if the extra does not exist
  1291. */
  1292. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1293. /**
  1294. * Increments the indentation level and logs a message.
  1295. * @param message The message to log
  1296. */
  1297. logOpen(message: string): void;
  1298. /**
  1299. * Decrements the indentation level.
  1300. */
  1301. logClose(): void;
  1302. /**
  1303. * Logs a message
  1304. * @param message The message to log
  1305. */
  1306. log(message: string): void;
  1307. /**
  1308. * Starts a performance counter.
  1309. * @param counterName The name of the performance counter
  1310. */
  1311. startPerformanceCounter(counterName: string): void;
  1312. /**
  1313. * Ends a performance counter.
  1314. * @param counterName The name of the performance counter
  1315. */
  1316. endPerformanceCounter(counterName: string): void;
  1317. }
  1318. }
  1319. declare module 'babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension' {
  1320. import { IDisposable, Nullable, Mesh, Camera, Geometry, Material, BaseTexture, AnimationGroup } from "babylonjs";
  1321. import { IScene, INode, ICamera, IMeshPrimitive, IMaterial, ITextureInfo, IAnimation } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1322. import { IGLTFLoaderExtension as IGLTFBaseLoaderExtension } from "babylonjs-loaders/src/glTF/glTFFileLoader";
  1323. /** @hidden */
  1324. export var __IGLTFLoaderExtension: number;
  1325. /**
  1326. * Interface for a glTF loader extension.
  1327. */
  1328. export interface IGLTFLoaderExtension extends IGLTFBaseLoaderExtension, IDisposable {
  1329. /**
  1330. * Called after the loader state changes to LOADING.
  1331. */
  1332. onLoading?(): void;
  1333. /**
  1334. * Called after the loader state changes to READY.
  1335. */
  1336. onReady?(): void;
  1337. /**
  1338. * Define this method to modify the default behavior when loading scenes.
  1339. * @param context The context when loading the asset
  1340. * @param scene The glTF scene property
  1341. * @returns A promise that resolves when the load is complete or null if not handled
  1342. */
  1343. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  1344. /**
  1345. * Define this method to modify the default behavior when loading nodes.
  1346. * @param context The context when loading the asset
  1347. * @param node The glTF node property
  1348. * @param assign A function called synchronously after parsing the glTF properties
  1349. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
  1350. */
  1351. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1352. /**
  1353. * Define this method to modify the default behavior when loading cameras.
  1354. * @param context The context when loading the asset
  1355. * @param camera The glTF camera property
  1356. * @param assign A function called synchronously after parsing the glTF properties
  1357. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1358. */
  1359. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1360. /**
  1361. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1362. * @param context The context when loading the asset
  1363. * @param primitive The glTF mesh primitive property
  1364. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1365. */
  1366. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1367. /**
  1368. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1369. * @param context The context when loading the asset
  1370. * @param material The glTF material property
  1371. * @param assign A function called synchronously after parsing the glTF properties
  1372. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1373. */
  1374. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1375. /**
  1376. * Define this method to modify the default behavior when creating materials.
  1377. * @param context The context when loading the asset
  1378. * @param material The glTF material property
  1379. * @param babylonDrawMode The draw mode for the Babylon material
  1380. * @returns The Babylon material or null if not handled
  1381. */
  1382. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1383. /**
  1384. * Define this method to modify the default behavior when loading material properties.
  1385. * @param context The context when loading the asset
  1386. * @param material The glTF material property
  1387. * @param babylonMaterial The Babylon material
  1388. * @returns A promise that resolves when the load is complete or null if not handled
  1389. */
  1390. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1391. /**
  1392. * Define this method to modify the default behavior when loading texture infos.
  1393. * @param context The context when loading the asset
  1394. * @param textureInfo The glTF texture info property
  1395. * @param assign A function called synchronously after parsing the glTF properties
  1396. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1397. */
  1398. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1399. /**
  1400. * Define this method to modify the default behavior when loading animations.
  1401. * @param context The context when loading the asset
  1402. * @param animation The glTF animation property
  1403. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1404. */
  1405. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1406. /**
  1407. * Define this method to modify the default behavior when loading uris.
  1408. * @param context The context when loading the asset
  1409. * @param uri The uri to load
  1410. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1411. */
  1412. _loadUriAsync?(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1413. }
  1414. }
  1415. declare module 'babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces' {
  1416. import { VertexBuffer, Buffer, AnimationGroup, Material, AbstractMesh, Mesh, Bone, Skeleton } from "babylonjs";
  1417. import * as IGLTF2 from "babylonjs-gltf2interface";
  1418. /** @hidden */
  1419. export var __IGLTFLoaderInterfacesV2: number;
  1420. /**
  1421. * Loader interface with an index field.
  1422. */
  1423. export interface IArrayItem {
  1424. /**
  1425. * The index of this item in the array.
  1426. */
  1427. index: number;
  1428. }
  1429. /**
  1430. * Loader interface with additional members.
  1431. */
  1432. export interface IAccessor extends IGLTF2.IAccessor, IArrayItem {
  1433. /** @hidden */
  1434. _data?: Promise<ArrayBufferView>;
  1435. /** @hidden */
  1436. _babylonVertexBuffer?: Promise<VertexBuffer>;
  1437. }
  1438. /**
  1439. * Loader interface with additional members.
  1440. */
  1441. export interface IAnimationChannel extends IGLTF2.IAnimationChannel, IArrayItem {
  1442. }
  1443. /** @hidden */
  1444. export interface _IAnimationSamplerData {
  1445. input: Float32Array;
  1446. interpolation: IGLTF2.AnimationSamplerInterpolation;
  1447. output: Float32Array;
  1448. }
  1449. /**
  1450. * Loader interface with additional members.
  1451. */
  1452. export interface IAnimationSampler extends IGLTF2.IAnimationSampler, IArrayItem {
  1453. /** @hidden */
  1454. _data?: Promise<_IAnimationSamplerData>;
  1455. }
  1456. /**
  1457. * Loader interface with additional members.
  1458. */
  1459. export interface IAnimation extends IGLTF2.IAnimation, IArrayItem {
  1460. channels: IAnimationChannel[];
  1461. samplers: IAnimationSampler[];
  1462. /** @hidden */
  1463. _babylonAnimationGroup?: AnimationGroup;
  1464. }
  1465. /**
  1466. * Loader interface with additional members.
  1467. */
  1468. export interface IBuffer extends IGLTF2.IBuffer, IArrayItem {
  1469. /** @hidden */
  1470. _data?: Promise<ArrayBufferView>;
  1471. }
  1472. /**
  1473. * Loader interface with additional members.
  1474. */
  1475. export interface IBufferView extends IGLTF2.IBufferView, IArrayItem {
  1476. /** @hidden */
  1477. _data?: Promise<ArrayBufferView>;
  1478. /** @hidden */
  1479. _babylonBuffer?: Promise<Buffer>;
  1480. }
  1481. /**
  1482. * Loader interface with additional members.
  1483. */
  1484. export interface ICamera extends IGLTF2.ICamera, IArrayItem {
  1485. }
  1486. /**
  1487. * Loader interface with additional members.
  1488. */
  1489. export interface IImage extends IGLTF2.IImage, IArrayItem {
  1490. /** @hidden */
  1491. _data?: Promise<ArrayBufferView>;
  1492. }
  1493. /**
  1494. * Loader interface with additional members.
  1495. */
  1496. export interface IMaterialNormalTextureInfo extends IGLTF2.IMaterialNormalTextureInfo, IGLTF2.ITextureInfo {
  1497. }
  1498. /**
  1499. * Loader interface with additional members.
  1500. */
  1501. export interface IMaterialOcclusionTextureInfo extends IGLTF2.IMaterialOcclusionTextureInfo, IGLTF2.ITextureInfo {
  1502. }
  1503. /**
  1504. * Loader interface with additional members.
  1505. */
  1506. export interface IMaterialPbrMetallicRoughness extends IGLTF2.IMaterialPbrMetallicRoughness {
  1507. baseColorTexture?: ITextureInfo;
  1508. metallicRoughnessTexture?: ITextureInfo;
  1509. }
  1510. /**
  1511. * Loader interface with additional members.
  1512. */
  1513. export interface IMaterial extends IGLTF2.IMaterial, IArrayItem {
  1514. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  1515. normalTexture?: IMaterialNormalTextureInfo;
  1516. occlusionTexture?: IMaterialOcclusionTextureInfo;
  1517. emissiveTexture?: ITextureInfo;
  1518. /** @hidden */
  1519. _babylonData?: {
  1520. [drawMode: number]: {
  1521. material: Material;
  1522. meshes: AbstractMesh[];
  1523. promise: Promise<void>;
  1524. };
  1525. };
  1526. }
  1527. /**
  1528. * Loader interface with additional members.
  1529. */
  1530. export interface IMesh extends IGLTF2.IMesh, IArrayItem {
  1531. primitives: IMeshPrimitive[];
  1532. }
  1533. /**
  1534. * Loader interface with additional members.
  1535. */
  1536. export interface IMeshPrimitive extends IGLTF2.IMeshPrimitive, IArrayItem {
  1537. }
  1538. /**
  1539. * Loader interface with additional members.
  1540. */
  1541. export interface INode extends IGLTF2.INode, IArrayItem {
  1542. /**
  1543. * The parent glTF node.
  1544. */
  1545. parent?: INode;
  1546. /** @hidden */
  1547. _babylonMesh?: Mesh;
  1548. /** @hidden */
  1549. _primitiveBabylonMeshes?: Mesh[];
  1550. /** @hidden */
  1551. _babylonBones?: Bone[];
  1552. /** @hidden */
  1553. _numMorphTargets?: number;
  1554. }
  1555. /** @hidden */
  1556. export interface _ISamplerData {
  1557. noMipMaps: boolean;
  1558. samplingMode: number;
  1559. wrapU: number;
  1560. wrapV: number;
  1561. }
  1562. /**
  1563. * Loader interface with additional members.
  1564. */
  1565. export interface ISampler extends IGLTF2.ISampler, IArrayItem {
  1566. /** @hidden */
  1567. _data?: _ISamplerData;
  1568. }
  1569. /**
  1570. * Loader interface with additional members.
  1571. */
  1572. export interface IScene extends IGLTF2.IScene, IArrayItem {
  1573. }
  1574. /**
  1575. * Loader interface with additional members.
  1576. */
  1577. export interface ISkin extends IGLTF2.ISkin, IArrayItem {
  1578. /** @hidden */
  1579. _babylonSkeleton?: Skeleton;
  1580. /** @hidden */
  1581. _promise?: Promise<void>;
  1582. }
  1583. /**
  1584. * Loader interface with additional members.
  1585. */
  1586. export interface ITexture extends IGLTF2.ITexture, IArrayItem {
  1587. }
  1588. /**
  1589. * Loader interface with additional members.
  1590. */
  1591. export interface ITextureInfo extends IGLTF2.ITextureInfo {
  1592. }
  1593. /**
  1594. * Loader interface with additional members.
  1595. */
  1596. export interface IGLTF extends IGLTF2.IGLTF {
  1597. accessors?: IAccessor[];
  1598. animations?: IAnimation[];
  1599. buffers?: IBuffer[];
  1600. bufferViews?: IBufferView[];
  1601. cameras?: ICamera[];
  1602. images?: IImage[];
  1603. materials?: IMaterial[];
  1604. meshes?: IMesh[];
  1605. nodes?: INode[];
  1606. samplers?: ISampler[];
  1607. scenes?: IScene[];
  1608. skins?: ISkin[];
  1609. textures?: ITexture[];
  1610. }
  1611. }
  1612. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions' {
  1613. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/EXT_lights_image_based";
  1614. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  1615. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/KHR_lights_punctual";
  1616. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  1617. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/KHR_materials_unlit";
  1618. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/KHR_texture_transform";
  1619. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter";
  1620. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_lod";
  1621. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh";
  1622. export * from "babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors";
  1623. }
  1624. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/EXT_lights_image_based' {
  1625. import { Nullable } from "babylonjs";
  1626. import { IScene } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1627. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1628. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1629. /**
  1630. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  1631. */
  1632. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1633. /** The name of this extension. */
  1634. readonly name: string;
  1635. /** Defines whether this extension is enabled. */
  1636. enabled: boolean;
  1637. /** @hidden */
  1638. constructor(loader: GLTFLoader);
  1639. /** @hidden */
  1640. dispose(): void;
  1641. /** @hidden */
  1642. onLoading(): void;
  1643. /** @hidden */
  1644. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1645. }
  1646. }
  1647. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression' {
  1648. import { Geometry, Mesh, Nullable } from "babylonjs";
  1649. import { IMeshPrimitive } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1650. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1651. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1652. /**
  1653. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1654. */
  1655. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1656. /** The name of this extension. */
  1657. readonly name: string;
  1658. /** Defines whether this extension is enabled. */
  1659. enabled: boolean;
  1660. /** @hidden */
  1661. constructor(loader: GLTFLoader);
  1662. /** @hidden */
  1663. dispose(): void;
  1664. /** @hidden */
  1665. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1666. }
  1667. }
  1668. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/KHR_lights_punctual' {
  1669. import { Mesh, Nullable } from "babylonjs";
  1670. import { INode } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1671. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1672. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1673. /**
  1674. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  1675. */
  1676. export class KHR_lights implements IGLTFLoaderExtension {
  1677. /** The name of this extension. */
  1678. readonly name: string;
  1679. /** Defines whether this extension is enabled. */
  1680. enabled: boolean;
  1681. /** @hidden */
  1682. constructor(loader: GLTFLoader);
  1683. /** @hidden */
  1684. dispose(): void;
  1685. /** @hidden */
  1686. onLoading(): void;
  1687. /** @hidden */
  1688. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1689. }
  1690. }
  1691. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness' {
  1692. import { Material, Nullable } from "babylonjs";
  1693. import { IMaterial } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1694. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1695. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1696. /**
  1697. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1698. */
  1699. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1700. /** The name of this extension. */
  1701. readonly name: string;
  1702. /** Defines whether this extension is enabled. */
  1703. enabled: boolean;
  1704. /** @hidden */
  1705. constructor(loader: GLTFLoader);
  1706. /** @hidden */
  1707. dispose(): void;
  1708. /** @hidden */
  1709. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1710. }
  1711. }
  1712. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/KHR_materials_unlit' {
  1713. import { Material, Nullable } from "babylonjs";
  1714. import { IMaterial } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1715. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1716. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1717. /**
  1718. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1719. */
  1720. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1721. /** The name of this extension. */
  1722. readonly name: string;
  1723. /** Defines whether this extension is enabled. */
  1724. enabled: boolean;
  1725. /** @hidden */
  1726. constructor(loader: GLTFLoader);
  1727. /** @hidden */
  1728. dispose(): void;
  1729. /** @hidden */
  1730. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1731. }
  1732. }
  1733. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/KHR_texture_transform' {
  1734. import { BaseTexture, Nullable } from "babylonjs";
  1735. import { ITextureInfo } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1736. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1737. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1738. /**
  1739. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1740. */
  1741. export class KHR_texture_transform implements IGLTFLoaderExtension {
  1742. /** The name of this extension. */
  1743. readonly name: string;
  1744. /** Defines whether this extension is enabled. */
  1745. enabled: boolean;
  1746. /** @hidden */
  1747. constructor(loader: GLTFLoader);
  1748. /** @hidden */
  1749. dispose(): void;
  1750. /** @hidden */
  1751. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1752. }
  1753. }
  1754. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter' {
  1755. import { Nullable, Mesh, AnimationGroup } from "babylonjs";
  1756. import { IScene, INode, IAnimation } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1757. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1758. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1759. /**
  1760. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1761. */
  1762. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1763. /** The name of this extension. */
  1764. readonly name: string;
  1765. /** Defines whether this extension is enabled. */
  1766. enabled: boolean;
  1767. /** @hidden */
  1768. constructor(loader: GLTFLoader);
  1769. /** @hidden */
  1770. dispose(): void;
  1771. /** @hidden */
  1772. onLoading(): void;
  1773. /** @hidden */
  1774. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1775. /** @hidden */
  1776. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1777. /** @hidden */
  1778. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1779. }
  1780. }
  1781. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_lod' {
  1782. import { Observable, Nullable, Mesh, Material } from "babylonjs";
  1783. import { INode, IMaterial } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1784. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1785. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1786. /**
  1787. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1788. */
  1789. export class MSFT_lod implements IGLTFLoaderExtension {
  1790. /** The name of this extension. */
  1791. readonly name: string;
  1792. /** Defines whether this extension is enabled. */
  1793. enabled: boolean;
  1794. /**
  1795. * Maximum number of LODs to load, starting from the lowest LOD.
  1796. */
  1797. maxLODsToLoad: number;
  1798. /**
  1799. * Observable raised when all node LODs of one level are loaded.
  1800. * The event data is the index of the loaded LOD starting from zero.
  1801. * Dispose the loader to cancel the loading of the next level of LODs.
  1802. */
  1803. onNodeLODsLoadedObservable: Observable<number>;
  1804. /**
  1805. * Observable raised when all material LODs of one level are loaded.
  1806. * The event data is the index of the loaded LOD starting from zero.
  1807. * Dispose the loader to cancel the loading of the next level of LODs.
  1808. */
  1809. onMaterialLODsLoadedObservable: Observable<number>;
  1810. /** @hidden */
  1811. constructor(loader: GLTFLoader);
  1812. /** @hidden */
  1813. dispose(): void;
  1814. /** @hidden */
  1815. onReady(): void;
  1816. /** @hidden */
  1817. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: Mesh) => void): Nullable<Promise<Mesh>>;
  1818. /** @hidden */
  1819. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1820. /** @hidden */
  1821. _loadUriAsync(context: string, uri: string): Nullable<Promise<ArrayBufferView>>;
  1822. }
  1823. }
  1824. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh' {
  1825. import { Material, Nullable } from "babylonjs";
  1826. import { IMaterial } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1827. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1828. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1829. /** @hidden */
  1830. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1831. readonly name: string;
  1832. enabled: boolean;
  1833. constructor(loader: GLTFLoader);
  1834. dispose(): void;
  1835. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1836. }
  1837. }
  1838. declare module 'babylonjs-loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors' {
  1839. import { Material, Nullable } from "babylonjs";
  1840. import { IMaterial } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderInterfaces";
  1841. import { IGLTFLoaderExtension } from "babylonjs-loaders/src/glTF/2.0/glTFLoaderExtension";
  1842. import { GLTFLoader } from "babylonjs-loaders/src/glTF/2.0/glTFLoader";
  1843. /** @hidden */
  1844. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1845. readonly name: string;
  1846. enabled: boolean;
  1847. constructor(loader: GLTFLoader);
  1848. dispose(): void;
  1849. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1850. }
  1851. }
  1852. /*BabylonJS Loaders*/
  1853. // Dependencies for this module:
  1854. // ../../../../Tools/Gulp/babylonjs
  1855. // ../../../../Tools/Gulp/babylonjs-gltf2interface
  1856. declare module BABYLON {
  1857. /**
  1858. * Mode that determines the coordinate system to use.
  1859. */
  1860. export enum GLTFLoaderCoordinateSystemMode {
  1861. /**
  1862. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  1863. */
  1864. AUTO = 0,
  1865. /**
  1866. * Sets the useRightHandedSystem flag on the scene.
  1867. */
  1868. FORCE_RIGHT_HANDED = 1
  1869. }
  1870. /**
  1871. * Mode that determines what animations will start.
  1872. */
  1873. export enum GLTFLoaderAnimationStartMode {
  1874. /**
  1875. * No animation will start.
  1876. */
  1877. NONE = 0,
  1878. /**
  1879. * The first animation will start.
  1880. */
  1881. FIRST = 1,
  1882. /**
  1883. * All animations will start.
  1884. */
  1885. ALL = 2
  1886. }
  1887. /**
  1888. * Interface that contains the data for the glTF asset.
  1889. */
  1890. export interface IGLTFLoaderData {
  1891. /**
  1892. * Object that represents the glTF JSON.
  1893. */
  1894. json: Object;
  1895. /**
  1896. * The BIN chunk of a binary glTF.
  1897. */
  1898. bin: BABYLON.Nullable<ArrayBufferView>;
  1899. }
  1900. /**
  1901. * Interface for extending the loader.
  1902. */
  1903. export interface IGLTFLoaderExtension {
  1904. /**
  1905. * The name of this extension.
  1906. */
  1907. readonly name: string;
  1908. /**
  1909. * Defines whether this extension is enabled.
  1910. */
  1911. enabled: boolean;
  1912. }
  1913. /**
  1914. * Loader state.
  1915. */
  1916. export enum GLTFLoaderState {
  1917. /**
  1918. * The asset is loading.
  1919. */
  1920. LOADING = 0,
  1921. /**
  1922. * The asset is ready for rendering.
  1923. */
  1924. READY = 1,
  1925. /**
  1926. * The asset is completely loaded.
  1927. */
  1928. COMPLETE = 2
  1929. }
  1930. /** @hidden */
  1931. export interface IGLTFLoader extends BABYLON.IDisposable {
  1932. readonly state: BABYLON.Nullable<GLTFLoaderState>;
  1933. importMeshAsync: (meshesNames: any, scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  1934. meshes: BABYLON.AbstractMesh[];
  1935. particleSystems: BABYLON.IParticleSystem[];
  1936. skeletons: BABYLON.Skeleton[];
  1937. animationGroups: BABYLON.AnimationGroup[];
  1938. }>;
  1939. loadAsync: (scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  1940. }
  1941. /**
  1942. * File loader for loading glTF files into a scene.
  1943. */
  1944. export class GLTFFileLoader implements BABYLON.IDisposable, BABYLON.ISceneLoaderPluginAsync, BABYLON.ISceneLoaderPluginFactory {
  1945. /** @hidden */
  1946. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  1947. /** @hidden */
  1948. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  1949. /**
  1950. * Raised when the asset has been parsed
  1951. */
  1952. onParsedObservable: BABYLON.Observable<IGLTFLoaderData>;
  1953. /**
  1954. * Raised when the asset has been parsed
  1955. */
  1956. onParsed: (loaderData: IGLTFLoaderData) => void;
  1957. /**
  1958. * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.
  1959. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  1960. * Defaults to true.
  1961. * @hidden
  1962. */
  1963. static IncrementalLoading: boolean;
  1964. /**
  1965. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  1966. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  1967. * @hidden
  1968. */
  1969. static HomogeneousCoordinates: boolean;
  1970. /**
  1971. * The coordinate system mode. Defaults to AUTO.
  1972. */
  1973. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  1974. /**
  1975. * The animation start mode. Defaults to FIRST.
  1976. */
  1977. animationStartMode: GLTFLoaderAnimationStartMode;
  1978. /**
  1979. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  1980. */
  1981. compileMaterials: boolean;
  1982. /**
  1983. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  1984. */
  1985. useClipPlane: boolean;
  1986. /**
  1987. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  1988. */
  1989. compileShadowGenerators: boolean;
  1990. /**
  1991. * Defines if the Alpha blended materials are only applied as coverage.
  1992. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  1993. * If true, no extra effects are applied to transparent pixels.
  1994. */
  1995. transparencyAsCoverage: boolean;
  1996. /**
  1997. * Function called before loading a url referenced by the asset.
  1998. */
  1999. preprocessUrlAsync: (url: string) => Promise<string>;
  2000. /**
  2001. * BABYLON.Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2002. */
  2003. readonly onMeshLoadedObservable: BABYLON.Observable<BABYLON.AbstractMesh>;
  2004. /**
  2005. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2006. */
  2007. onMeshLoaded: (mesh: BABYLON.AbstractMesh) => void;
  2008. /**
  2009. * BABYLON.Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  2010. */
  2011. readonly onTextureLoadedObservable: BABYLON.Observable<BABYLON.BaseTexture>;
  2012. /**
  2013. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  2014. */
  2015. onTextureLoaded: (texture: BABYLON.BaseTexture) => void;
  2016. /**
  2017. * BABYLON.Observable raised when the loader creates a material after parsing the glTF properties of the material.
  2018. */
  2019. readonly onMaterialLoadedObservable: BABYLON.Observable<BABYLON.Material>;
  2020. /**
  2021. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  2022. */
  2023. onMaterialLoaded: (material: BABYLON.Material) => void;
  2024. /**
  2025. * BABYLON.Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  2026. */
  2027. readonly onCameraLoadedObservable: BABYLON.Observable<BABYLON.Camera>;
  2028. /**
  2029. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  2030. */
  2031. onCameraLoaded: (camera: BABYLON.Camera) => void;
  2032. /**
  2033. * BABYLON.Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  2034. * For assets with LODs, raised when all of the LODs are complete.
  2035. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2036. */
  2037. readonly onCompleteObservable: BABYLON.Observable<void>;
  2038. /**
  2039. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  2040. * For assets with LODs, raised when all of the LODs are complete.
  2041. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2042. */
  2043. onComplete: () => void;
  2044. /**
  2045. * BABYLON.Observable raised when an error occurs.
  2046. */
  2047. readonly onErrorObservable: BABYLON.Observable<any>;
  2048. /**
  2049. * Callback raised when an error occurs.
  2050. */
  2051. onError: (reason: any) => void;
  2052. /**
  2053. * BABYLON.Observable raised after the loader is disposed.
  2054. */
  2055. readonly onDisposeObservable: BABYLON.Observable<void>;
  2056. /**
  2057. * Callback raised after the loader is disposed.
  2058. */
  2059. onDispose: () => void;
  2060. /**
  2061. * BABYLON.Observable raised after a loader extension is created.
  2062. * Set additional options for a loader extension in this event.
  2063. */
  2064. readonly onExtensionLoadedObservable: BABYLON.Observable<IGLTFLoaderExtension>;
  2065. /**
  2066. * Callback raised after a loader extension is created.
  2067. */
  2068. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  2069. /**
  2070. * Defines if the loader logging is enabled.
  2071. */
  2072. loggingEnabled: boolean;
  2073. /**
  2074. * Defines if the loader should capture performance counters.
  2075. */
  2076. capturePerformanceCounters: boolean;
  2077. /**
  2078. * Defines if the loader should validate the asset.
  2079. */
  2080. validate: boolean;
  2081. /**
  2082. * BABYLON.Observable raised after validation when validate is set to true. The event data is the result of the validation.
  2083. */
  2084. readonly onValidatedObservable: BABYLON.Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  2085. /**
  2086. * Callback raised after a loader extension is created.
  2087. */
  2088. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  2089. /**
  2090. * Name of the loader ("gltf")
  2091. */
  2092. name: string;
  2093. /**
  2094. * Supported file extensions of the loader (.gltf, .glb)
  2095. */
  2096. extensions: BABYLON.ISceneLoaderPluginExtensions;
  2097. /**
  2098. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  2099. */
  2100. dispose(): void;
  2101. /** @hidden */
  2102. _clear(): void;
  2103. /**
  2104. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  2105. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2106. * @param scene the scene the meshes should be added to
  2107. * @param data the glTF data to load
  2108. * @param rootUrl root url to load from
  2109. * @param onProgress event that fires when loading progress has occured
  2110. * @param fileName Defines the name of the file to load
  2111. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2112. */
  2113. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: any, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2114. meshes: BABYLON.AbstractMesh[];
  2115. particleSystems: BABYLON.IParticleSystem[];
  2116. skeletons: BABYLON.Skeleton[];
  2117. animationGroups: BABYLON.AnimationGroup[];
  2118. }>;
  2119. /**
  2120. * Imports all objects from the loaded glTF data and adds them to the scene
  2121. * @param scene the scene the objects should be added to
  2122. * @param data the glTF data to load
  2123. * @param rootUrl root url to load from
  2124. * @param onProgress event that fires when loading progress has occured
  2125. * @param fileName Defines the name of the file to load
  2126. * @returns a promise which completes when objects have been loaded to the scene
  2127. */
  2128. loadAsync(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2129. /**
  2130. * Load into an asset container.
  2131. * @param scene The scene to load into
  2132. * @param data The data to import
  2133. * @param rootUrl The root url for scene and resources
  2134. * @param onProgress The callback when the load progresses
  2135. * @param fileName Defines the name of the file to load
  2136. * @returns The loaded asset container
  2137. */
  2138. loadAssetContainerAsync(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<BABYLON.AssetContainer>;
  2139. /**
  2140. * If the data string can be loaded directly.
  2141. * @param data string contianing the file data
  2142. * @returns if the data can be loaded directly
  2143. */
  2144. canDirectLoad(data: string): boolean;
  2145. /**
  2146. * Rewrites a url by combining a root url and response url.
  2147. */
  2148. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  2149. /**
  2150. * Instantiates a glTF file loader plugin.
  2151. * @returns the created plugin
  2152. */
  2153. createPlugin(): BABYLON.ISceneLoaderPlugin | BABYLON.ISceneLoaderPluginAsync;
  2154. /**
  2155. * The loader state or null if the loader is not active.
  2156. */
  2157. readonly loaderState: BABYLON.Nullable<GLTFLoaderState>;
  2158. /**
  2159. * Returns a promise that resolves when the asset is completely loaded.
  2160. * @returns a promise that resolves when the asset is completely loaded.
  2161. */
  2162. whenCompleteAsync(): Promise<void>;
  2163. /** @hidden */
  2164. _log: (message: string) => void;
  2165. /** @hidden */
  2166. _logOpen(message: string): void;
  2167. /** @hidden */
  2168. _logClose(): void;
  2169. /** @hidden */
  2170. _startPerformanceCounter: (counterName: string) => void;
  2171. /** @hidden */
  2172. _endPerformanceCounter: (counterName: string) => void;
  2173. }
  2174. }
  2175. declare module BABYLON {
  2176. /**
  2177. * Class reading and parsing the MTL file bundled with the obj file.
  2178. */
  2179. export class MTLFileLoader {
  2180. /**
  2181. * All material loaded from the mtl will be set here
  2182. */
  2183. materials: BABYLON.StandardMaterial[];
  2184. /**
  2185. * This function will read the mtl file and create each material described inside
  2186. * This function could be improve by adding :
  2187. * -some component missing (Ni, Tf...)
  2188. * -including the specific options available
  2189. *
  2190. * @param scene defines the scene the material will be created in
  2191. * @param data defines the mtl data to parse
  2192. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  2193. */
  2194. parseMTL(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string): void;
  2195. }
  2196. /**
  2197. * OBJ file type loader.
  2198. * This is a babylon scene loader plugin.
  2199. */
  2200. export class OBJFileLoader implements BABYLON.ISceneLoaderPluginAsync {
  2201. /**
  2202. * Defines if UVs are optimized by default during load.
  2203. */
  2204. static OPTIMIZE_WITH_UV: boolean;
  2205. /**
  2206. * Defines if Y is inverted by default during load.
  2207. */
  2208. static INVERT_Y: boolean;
  2209. /**
  2210. * Defines the name of the plugin.
  2211. */
  2212. name: string;
  2213. /**
  2214. * Defines the extension the plugin is able to load.
  2215. */
  2216. extensions: string;
  2217. /** @hidden */
  2218. obj: RegExp;
  2219. /** @hidden */
  2220. group: RegExp;
  2221. /** @hidden */
  2222. mtllib: RegExp;
  2223. /** @hidden */
  2224. usemtl: RegExp;
  2225. /** @hidden */
  2226. smooth: RegExp;
  2227. /** @hidden */
  2228. vertexPattern: RegExp;
  2229. /** @hidden */
  2230. normalPattern: RegExp;
  2231. /** @hidden */
  2232. uvPattern: RegExp;
  2233. /** @hidden */
  2234. facePattern1: RegExp;
  2235. /** @hidden */
  2236. facePattern2: RegExp;
  2237. /** @hidden */
  2238. facePattern3: RegExp;
  2239. /** @hidden */
  2240. facePattern4: RegExp;
  2241. /** @hidden */
  2242. facePattern5: RegExp;
  2243. /**
  2244. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  2245. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2246. * @param scene the scene the meshes should be added to
  2247. * @param data the glTF data to load
  2248. * @param rootUrl root url to load from
  2249. * @param onProgress event that fires when loading progress has occured
  2250. * @param fileName Defines the name of the file to load
  2251. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2252. */
  2253. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: any, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2254. meshes: BABYLON.AbstractMesh[];
  2255. particleSystems: BABYLON.IParticleSystem[];
  2256. skeletons: BABYLON.Skeleton[];
  2257. animationGroups: BABYLON.AnimationGroup[];
  2258. }>;
  2259. /**
  2260. * Imports all objects from the loaded glTF data and adds them to the scene
  2261. * @param scene the scene the objects should be added to
  2262. * @param data the glTF data to load
  2263. * @param rootUrl root url to load from
  2264. * @param onProgress event that fires when loading progress has occured
  2265. * @param fileName Defines the name of the file to load
  2266. * @returns a promise which completes when objects have been loaded to the scene
  2267. */
  2268. loadAsync(scene: BABYLON.Scene, data: string, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2269. /**
  2270. * Load into an asset container.
  2271. * @param scene The scene to load into
  2272. * @param data The data to import
  2273. * @param rootUrl The root url for scene and resources
  2274. * @param onProgress The callback when the load progresses
  2275. * @param fileName Defines the name of the file to load
  2276. * @returns The loaded asset container
  2277. */
  2278. loadAssetContainerAsync(scene: BABYLON.Scene, data: string, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<BABYLON.AssetContainer>;
  2279. }
  2280. }
  2281. declare module BABYLON {
  2282. /**
  2283. * STL file type loader.
  2284. * This is a babylon scene loader plugin.
  2285. */
  2286. export class STLFileLoader implements BABYLON.ISceneLoaderPlugin {
  2287. /** @hidden */
  2288. solidPattern: RegExp;
  2289. /** @hidden */
  2290. facetsPattern: RegExp;
  2291. /** @hidden */
  2292. normalPattern: RegExp;
  2293. /** @hidden */
  2294. vertexPattern: RegExp;
  2295. /**
  2296. * Defines the name of the plugin.
  2297. */
  2298. name: string;
  2299. /**
  2300. * Defines the extensions the stl loader is able to load.
  2301. * force data to come in as an ArrayBuffer
  2302. * we'll convert to string if it looks like it's an ASCII .stl
  2303. */
  2304. extensions: BABYLON.ISceneLoaderPluginExtensions;
  2305. /**
  2306. * Import meshes into a scene.
  2307. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2308. * @param scene The scene to import into
  2309. * @param data The data to import
  2310. * @param rootUrl The root url for scene and resources
  2311. * @param meshes The meshes array to import into
  2312. * @param particleSystems The particle systems array to import into
  2313. * @param skeletons The skeletons array to import into
  2314. * @param onError The callback when import fails
  2315. * @returns True if successful or false otherwise
  2316. */
  2317. importMesh(meshesNames: any, scene: BABYLON.Scene, data: any, rootUrl: string, meshes: BABYLON.Nullable<BABYLON.AbstractMesh[]>, particleSystems: BABYLON.Nullable<BABYLON.IParticleSystem[]>, skeletons: BABYLON.Nullable<BABYLON.Skeleton[]>): boolean;
  2318. /**
  2319. * Load into a scene.
  2320. * @param scene The scene to load into
  2321. * @param data The data to import
  2322. * @param rootUrl The root url for scene and resources
  2323. * @param onError The callback when import fails
  2324. * @returns true if successful or false otherwise
  2325. */
  2326. load(scene: BABYLON.Scene, data: any, rootUrl: string): boolean;
  2327. /**
  2328. * Load into an asset container.
  2329. * @param scene The scene to load into
  2330. * @param data The data to import
  2331. * @param rootUrl The root url for scene and resources
  2332. * @param onError The callback when import fails
  2333. * @returns The loaded asset container
  2334. */
  2335. loadAssetContainer(scene: BABYLON.Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): BABYLON.AssetContainer;
  2336. }
  2337. }
  2338. declare module BABYLON.GLTF1 {
  2339. /** @hidden */
  2340. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  2341. constructor();
  2342. loadRuntimeAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  2343. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  2344. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  2345. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  2346. }
  2347. }
  2348. declare module BABYLON.GLTF1 {
  2349. /**
  2350. * Implementation of the base glTF spec
  2351. * @hidden
  2352. */
  2353. export class GLTFLoaderBase {
  2354. static CreateRuntime(parsedData: any, scene: BABYLON.Scene, rootUrl: string): IGLTFRuntime;
  2355. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  2356. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: BABYLON.Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  2357. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: BABYLON.Nullable<ArrayBufferView>, onSuccess: (texture: BABYLON.Texture) => void, onError: (message: string) => void): void;
  2358. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  2359. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): void;
  2360. }
  2361. /**
  2362. * glTF V1 Loader
  2363. * @hidden
  2364. */
  2365. export class GLTFLoader implements IGLTFLoader {
  2366. static Extensions: {
  2367. [name: string]: GLTFLoaderExtension;
  2368. };
  2369. static RegisterExtension(extension: GLTFLoaderExtension): void;
  2370. state: BABYLON.Nullable<GLTFLoaderState>;
  2371. dispose(): void;
  2372. /**
  2373. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  2374. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2375. * @param scene the scene the meshes should be added to
  2376. * @param data gltf data containing information of the meshes in a loaded file
  2377. * @param rootUrl root url to load from
  2378. * @param onProgress event that fires when loading progress has occured
  2379. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2380. */
  2381. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void): Promise<{
  2382. meshes: BABYLON.AbstractMesh[];
  2383. particleSystems: BABYLON.IParticleSystem[];
  2384. skeletons: BABYLON.Skeleton[];
  2385. animationGroups: BABYLON.AnimationGroup[];
  2386. }>;
  2387. /**
  2388. * Imports all objects from a loaded gltf file and adds them to the scene
  2389. * @param scene the scene the objects should be added to
  2390. * @param data gltf data containing information of the meshes in a loaded file
  2391. * @param rootUrl root url to load from
  2392. * @param onProgress event that fires when loading progress has occured
  2393. * @returns a promise which completes when objects have been loaded to the scene
  2394. */
  2395. loadAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void): Promise<void>;
  2396. }
  2397. }
  2398. declare module BABYLON.GLTF1 {
  2399. /** @hidden */
  2400. export abstract class GLTFLoaderExtension {
  2401. constructor(name: string);
  2402. readonly name: string;
  2403. /**
  2404. * Defines an override for loading the runtime
  2405. * Return true to stop further extensions from loading the runtime
  2406. */
  2407. loadRuntimeAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  2408. /**
  2409. * Defines an onverride for creating gltf runtime
  2410. * Return true to stop further extensions from creating the runtime
  2411. */
  2412. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  2413. /**
  2414. * Defines an override for loading buffers
  2415. * Return true to stop further extensions from loading this buffer
  2416. */
  2417. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  2418. /**
  2419. * Defines an override for loading texture buffers
  2420. * Return true to stop further extensions from loading this texture data
  2421. */
  2422. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  2423. /**
  2424. * Defines an override for creating textures
  2425. * Return true to stop further extensions from loading this texture
  2426. */
  2427. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: BABYLON.Texture) => void, onError: (message: string) => void): boolean;
  2428. /**
  2429. * Defines an override for loading shader strings
  2430. * Return true to stop further extensions from loading this shader data
  2431. */
  2432. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  2433. /**
  2434. * Defines an override for loading materials
  2435. * Return true to stop further extensions from loading this material
  2436. */
  2437. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): boolean;
  2438. static LoadRuntimeAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  2439. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  2440. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  2441. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: BABYLON.Texture) => void, onError: (message: string) => void): void;
  2442. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  2443. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): void;
  2444. }
  2445. }
  2446. declare module BABYLON.GLTF1 {
  2447. /**
  2448. * Enums
  2449. * @hidden
  2450. */
  2451. export enum EComponentType {
  2452. BYTE = 5120,
  2453. UNSIGNED_BYTE = 5121,
  2454. SHORT = 5122,
  2455. UNSIGNED_SHORT = 5123,
  2456. FLOAT = 5126
  2457. }
  2458. /** @hidden */
  2459. export enum EShaderType {
  2460. FRAGMENT = 35632,
  2461. VERTEX = 35633
  2462. }
  2463. /** @hidden */
  2464. export enum EParameterType {
  2465. BYTE = 5120,
  2466. UNSIGNED_BYTE = 5121,
  2467. SHORT = 5122,
  2468. UNSIGNED_SHORT = 5123,
  2469. INT = 5124,
  2470. UNSIGNED_INT = 5125,
  2471. FLOAT = 5126,
  2472. FLOAT_VEC2 = 35664,
  2473. FLOAT_VEC3 = 35665,
  2474. FLOAT_VEC4 = 35666,
  2475. INT_VEC2 = 35667,
  2476. INT_VEC3 = 35668,
  2477. INT_VEC4 = 35669,
  2478. BOOL = 35670,
  2479. BOOL_VEC2 = 35671,
  2480. BOOL_VEC3 = 35672,
  2481. BOOL_VEC4 = 35673,
  2482. FLOAT_MAT2 = 35674,
  2483. FLOAT_MAT3 = 35675,
  2484. FLOAT_MAT4 = 35676,
  2485. SAMPLER_2D = 35678
  2486. }
  2487. /** @hidden */
  2488. export enum ETextureWrapMode {
  2489. CLAMP_TO_EDGE = 33071,
  2490. MIRRORED_REPEAT = 33648,
  2491. REPEAT = 10497
  2492. }
  2493. /** @hidden */
  2494. export enum ETextureFilterType {
  2495. NEAREST = 9728,
  2496. LINEAR = 9728,
  2497. NEAREST_MIPMAP_NEAREST = 9984,
  2498. LINEAR_MIPMAP_NEAREST = 9985,
  2499. NEAREST_MIPMAP_LINEAR = 9986,
  2500. LINEAR_MIPMAP_LINEAR = 9987
  2501. }
  2502. /** @hidden */
  2503. export enum ETextureFormat {
  2504. ALPHA = 6406,
  2505. RGB = 6407,
  2506. RGBA = 6408,
  2507. LUMINANCE = 6409,
  2508. LUMINANCE_ALPHA = 6410
  2509. }
  2510. /** @hidden */
  2511. export enum ECullingType {
  2512. FRONT = 1028,
  2513. BACK = 1029,
  2514. FRONT_AND_BACK = 1032
  2515. }
  2516. /** @hidden */
  2517. export enum EBlendingFunction {
  2518. ZERO = 0,
  2519. ONE = 1,
  2520. SRC_COLOR = 768,
  2521. ONE_MINUS_SRC_COLOR = 769,
  2522. DST_COLOR = 774,
  2523. ONE_MINUS_DST_COLOR = 775,
  2524. SRC_ALPHA = 770,
  2525. ONE_MINUS_SRC_ALPHA = 771,
  2526. DST_ALPHA = 772,
  2527. ONE_MINUS_DST_ALPHA = 773,
  2528. CONSTANT_COLOR = 32769,
  2529. ONE_MINUS_CONSTANT_COLOR = 32770,
  2530. CONSTANT_ALPHA = 32771,
  2531. ONE_MINUS_CONSTANT_ALPHA = 32772,
  2532. SRC_ALPHA_SATURATE = 776
  2533. }
  2534. /** @hidden */
  2535. export interface IGLTFProperty {
  2536. extensions?: {
  2537. [key: string]: any;
  2538. };
  2539. extras?: Object;
  2540. }
  2541. /** @hidden */
  2542. export interface IGLTFChildRootProperty extends IGLTFProperty {
  2543. name?: string;
  2544. }
  2545. /** @hidden */
  2546. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  2547. bufferView: string;
  2548. byteOffset: number;
  2549. byteStride: number;
  2550. count: number;
  2551. type: string;
  2552. componentType: EComponentType;
  2553. max?: number[];
  2554. min?: number[];
  2555. name?: string;
  2556. }
  2557. /** @hidden */
  2558. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  2559. buffer: string;
  2560. byteOffset: number;
  2561. byteLength: number;
  2562. byteStride: number;
  2563. target?: number;
  2564. }
  2565. /** @hidden */
  2566. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  2567. uri: string;
  2568. byteLength?: number;
  2569. type?: string;
  2570. }
  2571. /** @hidden */
  2572. export interface IGLTFShader extends IGLTFChildRootProperty {
  2573. uri: string;
  2574. type: EShaderType;
  2575. }
  2576. /** @hidden */
  2577. export interface IGLTFProgram extends IGLTFChildRootProperty {
  2578. attributes: string[];
  2579. fragmentShader: string;
  2580. vertexShader: string;
  2581. }
  2582. /** @hidden */
  2583. export interface IGLTFTechniqueParameter {
  2584. type: number;
  2585. count?: number;
  2586. semantic?: string;
  2587. node?: string;
  2588. value?: number | boolean | string | Array<any>;
  2589. source?: string;
  2590. babylonValue?: any;
  2591. }
  2592. /** @hidden */
  2593. export interface IGLTFTechniqueCommonProfile {
  2594. lightingModel: string;
  2595. texcoordBindings: Object;
  2596. parameters?: Array<any>;
  2597. }
  2598. /** @hidden */
  2599. export interface IGLTFTechniqueStatesFunctions {
  2600. blendColor?: number[];
  2601. blendEquationSeparate?: number[];
  2602. blendFuncSeparate?: number[];
  2603. colorMask: boolean[];
  2604. cullFace: number[];
  2605. }
  2606. /** @hidden */
  2607. export interface IGLTFTechniqueStates {
  2608. enable: number[];
  2609. functions: IGLTFTechniqueStatesFunctions;
  2610. }
  2611. /** @hidden */
  2612. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  2613. parameters: {
  2614. [key: string]: IGLTFTechniqueParameter;
  2615. };
  2616. program: string;
  2617. attributes: {
  2618. [key: string]: string;
  2619. };
  2620. uniforms: {
  2621. [key: string]: string;
  2622. };
  2623. states: IGLTFTechniqueStates;
  2624. }
  2625. /** @hidden */
  2626. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  2627. technique?: string;
  2628. values: string[];
  2629. }
  2630. /** @hidden */
  2631. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  2632. attributes: {
  2633. [key: string]: string;
  2634. };
  2635. indices: string;
  2636. material: string;
  2637. mode?: number;
  2638. }
  2639. /** @hidden */
  2640. export interface IGLTFMesh extends IGLTFChildRootProperty {
  2641. primitives: IGLTFMeshPrimitive[];
  2642. }
  2643. /** @hidden */
  2644. export interface IGLTFImage extends IGLTFChildRootProperty {
  2645. uri: string;
  2646. }
  2647. /** @hidden */
  2648. export interface IGLTFSampler extends IGLTFChildRootProperty {
  2649. magFilter?: number;
  2650. minFilter?: number;
  2651. wrapS?: number;
  2652. wrapT?: number;
  2653. }
  2654. /** @hidden */
  2655. export interface IGLTFTexture extends IGLTFChildRootProperty {
  2656. sampler: string;
  2657. source: string;
  2658. format?: ETextureFormat;
  2659. internalFormat?: ETextureFormat;
  2660. target?: number;
  2661. type?: number;
  2662. babylonTexture?: BABYLON.Texture;
  2663. }
  2664. /** @hidden */
  2665. export interface IGLTFAmbienLight {
  2666. color?: number[];
  2667. }
  2668. /** @hidden */
  2669. export interface IGLTFDirectionalLight {
  2670. color?: number[];
  2671. }
  2672. /** @hidden */
  2673. export interface IGLTFPointLight {
  2674. color?: number[];
  2675. constantAttenuation?: number;
  2676. linearAttenuation?: number;
  2677. quadraticAttenuation?: number;
  2678. }
  2679. /** @hidden */
  2680. export interface IGLTFSpotLight {
  2681. color?: number[];
  2682. constantAttenuation?: number;
  2683. fallOfAngle?: number;
  2684. fallOffExponent?: number;
  2685. linearAttenuation?: number;
  2686. quadraticAttenuation?: number;
  2687. }
  2688. /** @hidden */
  2689. export interface IGLTFLight extends IGLTFChildRootProperty {
  2690. type: string;
  2691. }
  2692. /** @hidden */
  2693. export interface IGLTFCameraOrthographic {
  2694. xmag: number;
  2695. ymag: number;
  2696. zfar: number;
  2697. znear: number;
  2698. }
  2699. /** @hidden */
  2700. export interface IGLTFCameraPerspective {
  2701. aspectRatio: number;
  2702. yfov: number;
  2703. zfar: number;
  2704. znear: number;
  2705. }
  2706. /** @hidden */
  2707. export interface IGLTFCamera extends IGLTFChildRootProperty {
  2708. type: string;
  2709. }
  2710. /** @hidden */
  2711. export interface IGLTFAnimationChannelTarget {
  2712. id: string;
  2713. path: string;
  2714. }
  2715. /** @hidden */
  2716. export interface IGLTFAnimationChannel {
  2717. sampler: string;
  2718. target: IGLTFAnimationChannelTarget;
  2719. }
  2720. /** @hidden */
  2721. export interface IGLTFAnimationSampler {
  2722. input: string;
  2723. output: string;
  2724. interpolation?: string;
  2725. }
  2726. /** @hidden */
  2727. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  2728. channels?: IGLTFAnimationChannel[];
  2729. parameters?: {
  2730. [key: string]: string;
  2731. };
  2732. samplers?: {
  2733. [key: string]: IGLTFAnimationSampler;
  2734. };
  2735. }
  2736. /** @hidden */
  2737. export interface IGLTFNodeInstanceSkin {
  2738. skeletons: string[];
  2739. skin: string;
  2740. meshes: string[];
  2741. }
  2742. /** @hidden */
  2743. export interface IGLTFSkins extends IGLTFChildRootProperty {
  2744. bindShapeMatrix: number[];
  2745. inverseBindMatrices: string;
  2746. jointNames: string[];
  2747. babylonSkeleton?: BABYLON.Skeleton;
  2748. }
  2749. /** @hidden */
  2750. export interface IGLTFNode extends IGLTFChildRootProperty {
  2751. camera?: string;
  2752. children: string[];
  2753. skin?: string;
  2754. jointName?: string;
  2755. light?: string;
  2756. matrix: number[];
  2757. mesh?: string;
  2758. meshes?: string[];
  2759. rotation?: number[];
  2760. scale?: number[];
  2761. translation?: number[];
  2762. babylonNode?: BABYLON.Node;
  2763. }
  2764. /** @hidden */
  2765. export interface IGLTFScene extends IGLTFChildRootProperty {
  2766. nodes: string[];
  2767. }
  2768. /** @hidden */
  2769. export interface IGLTFRuntime {
  2770. extensions: {
  2771. [key: string]: any;
  2772. };
  2773. accessors: {
  2774. [key: string]: IGLTFAccessor;
  2775. };
  2776. buffers: {
  2777. [key: string]: IGLTFBuffer;
  2778. };
  2779. bufferViews: {
  2780. [key: string]: IGLTFBufferView;
  2781. };
  2782. meshes: {
  2783. [key: string]: IGLTFMesh;
  2784. };
  2785. lights: {
  2786. [key: string]: IGLTFLight;
  2787. };
  2788. cameras: {
  2789. [key: string]: IGLTFCamera;
  2790. };
  2791. nodes: {
  2792. [key: string]: IGLTFNode;
  2793. };
  2794. images: {
  2795. [key: string]: IGLTFImage;
  2796. };
  2797. textures: {
  2798. [key: string]: IGLTFTexture;
  2799. };
  2800. shaders: {
  2801. [key: string]: IGLTFShader;
  2802. };
  2803. programs: {
  2804. [key: string]: IGLTFProgram;
  2805. };
  2806. samplers: {
  2807. [key: string]: IGLTFSampler;
  2808. };
  2809. techniques: {
  2810. [key: string]: IGLTFTechnique;
  2811. };
  2812. materials: {
  2813. [key: string]: IGLTFMaterial;
  2814. };
  2815. animations: {
  2816. [key: string]: IGLTFAnimation;
  2817. };
  2818. skins: {
  2819. [key: string]: IGLTFSkins;
  2820. };
  2821. currentScene?: Object;
  2822. scenes: {
  2823. [key: string]: IGLTFScene;
  2824. };
  2825. extensionsUsed: string[];
  2826. extensionsRequired?: string[];
  2827. buffersCount: number;
  2828. shaderscount: number;
  2829. scene: BABYLON.Scene;
  2830. rootUrl: string;
  2831. loadedBufferCount: number;
  2832. loadedBufferViews: {
  2833. [name: string]: ArrayBufferView;
  2834. };
  2835. loadedShaderCount: number;
  2836. importOnlyMeshes: boolean;
  2837. importMeshesNames?: string[];
  2838. dummyNodes: BABYLON.Node[];
  2839. }
  2840. /** @hidden */
  2841. export interface INodeToRoot {
  2842. bone: BABYLON.Bone;
  2843. node: IGLTFNode;
  2844. id: string;
  2845. }
  2846. /** @hidden */
  2847. export interface IJointNode {
  2848. node: IGLTFNode;
  2849. id: string;
  2850. }
  2851. }
  2852. declare module BABYLON.GLTF1 {
  2853. /**
  2854. * Utils functions for GLTF
  2855. * @hidden
  2856. */
  2857. export class GLTFUtils {
  2858. /**
  2859. * Sets the given "parameter" matrix
  2860. * @param scene: the BABYLON.Scene object
  2861. * @param source: the source node where to pick the matrix
  2862. * @param parameter: the GLTF technique parameter
  2863. * @param uniformName: the name of the shader's uniform
  2864. * @param shaderMaterial: the shader material
  2865. */
  2866. static SetMatrix(scene: BABYLON.Scene, source: BABYLON.Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: BABYLON.ShaderMaterial | BABYLON.Effect): void;
  2867. /**
  2868. * Sets the given "parameter" matrix
  2869. * @param shaderMaterial: the shader material
  2870. * @param uniform: the name of the shader's uniform
  2871. * @param value: the value of the uniform
  2872. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  2873. */
  2874. static SetUniform(shaderMaterial: BABYLON.ShaderMaterial | BABYLON.Effect, uniform: string, value: any, type: number): boolean;
  2875. /**
  2876. * Returns the wrap mode of the texture
  2877. * @param mode: the mode value
  2878. */
  2879. static GetWrapMode(mode: number): number;
  2880. /**
  2881. * Returns the byte stride giving an accessor
  2882. * @param accessor: the GLTF accessor objet
  2883. */
  2884. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  2885. /**
  2886. * Returns the texture filter mode giving a mode value
  2887. * @param mode: the filter mode value
  2888. */
  2889. static GetTextureFilterMode(mode: number): ETextureFilterType;
  2890. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  2891. /**
  2892. * Returns a buffer from its accessor
  2893. * @param gltfRuntime: the GLTF runtime
  2894. * @param accessor: the GLTF accessor
  2895. */
  2896. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  2897. /**
  2898. * Decodes a buffer view into a string
  2899. * @param view: the buffer view
  2900. */
  2901. static DecodeBufferToText(view: ArrayBufferView): string;
  2902. /**
  2903. * Returns the default material of gltf. Related to
  2904. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  2905. * @param scene: the Babylon.js scene
  2906. */
  2907. static GetDefaultMaterial(scene: BABYLON.Scene): BABYLON.ShaderMaterial;
  2908. }
  2909. }
  2910. declare module BABYLON.GLTF1 {
  2911. /** @hidden */
  2912. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  2913. constructor();
  2914. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  2915. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: BABYLON.Material) => void, onError: (message: string) => void): boolean;
  2916. }
  2917. }
  2918. declare module BABYLON.GLTF2 {
  2919. /**
  2920. * Helper class for working with arrays when loading the glTF asset
  2921. */
  2922. export class ArrayItem {
  2923. /**
  2924. * Gets an item from the given array.
  2925. * @param context The context when loading the asset
  2926. * @param array The array to get the item from
  2927. * @param index The index to the array
  2928. * @returns The array item
  2929. */
  2930. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  2931. /**
  2932. * Assign an `index` field to each item of the given array.
  2933. * @param array The array of items
  2934. */
  2935. static Assign(array?: IArrayItem[]): void;
  2936. }
  2937. /**
  2938. * The glTF 2.0 loader
  2939. */
  2940. export class GLTFLoader implements IGLTFLoader {
  2941. /** The glTF object parsed from the JSON. */
  2942. gltf: IGLTF;
  2943. /** The Babylon scene when loading the asset. */
  2944. babylonScene: BABYLON.Scene;
  2945. /** @hidden */
  2946. _completePromises: Promise<any>[];
  2947. /**
  2948. * Registers a loader extension.
  2949. * @param name The name of the loader extension.
  2950. * @param factory The factory function that creates the loader extension.
  2951. */
  2952. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  2953. /**
  2954. * Unregisters a loader extension.
  2955. * @param name The name of the loader extenion.
  2956. * @returns A boolean indicating whether the extension has been unregistered
  2957. */
  2958. static UnregisterExtension(name: string): boolean;
  2959. /**
  2960. * Gets the loader state.
  2961. */
  2962. readonly state: BABYLON.Nullable<GLTFLoaderState>;
  2963. /** @hidden */
  2964. constructor(parent: GLTFFileLoader);
  2965. /** @hidden */
  2966. dispose(): void;
  2967. /** @hidden */
  2968. importMeshAsync(meshesNames: any, scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2969. meshes: BABYLON.AbstractMesh[];
  2970. particleSystems: BABYLON.IParticleSystem[];
  2971. skeletons: BABYLON.Skeleton[];
  2972. animationGroups: BABYLON.AnimationGroup[];
  2973. }>;
  2974. /** @hidden */
  2975. loadAsync(scene: BABYLON.Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: BABYLON.SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2976. /**
  2977. * Loads a glTF scene.
  2978. * @param context The context when loading the asset
  2979. * @param scene The glTF scene property
  2980. * @returns A promise that resolves when the load is complete
  2981. */
  2982. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  2983. /**
  2984. * Loads a glTF node.
  2985. * @param context The context when loading the asset
  2986. * @param node The glTF node property
  2987. * @param assign A function called synchronously after parsing the glTF properties
  2988. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  2989. */
  2990. loadNodeAsync(context: string, node: INode, assign?: (babylonMesh: BABYLON.Mesh) => void): Promise<BABYLON.Mesh>;
  2991. /**
  2992. * Loads a glTF camera.
  2993. * @param context The context when loading the asset
  2994. * @param camera The glTF camera property
  2995. * @param assign A function called synchronously after parsing the glTF properties
  2996. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  2997. */
  2998. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: BABYLON.Camera) => void): Promise<BABYLON.Camera>;
  2999. /**
  3000. * Loads a glTF animation.
  3001. * @param context The context when loading the asset
  3002. * @param animation The glTF animation property
  3003. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  3004. */
  3005. loadAnimationAsync(context: string, animation: IAnimation): Promise<BABYLON.AnimationGroup>;
  3006. /**
  3007. * Loads a glTF buffer view.
  3008. * @param context The context when loading the asset
  3009. * @param bufferView The glTF buffer view property
  3010. * @returns A promise that resolves with the loaded data when the load is complete
  3011. */
  3012. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  3013. /** @hidden */
  3014. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: BABYLON.Mesh, babylonDrawMode: number, assign?: (babylonMaterial: BABYLON.Material) => void): Promise<BABYLON.Material>;
  3015. /**
  3016. * Creates a Babylon material from a glTF material.
  3017. * @param context The context when loading the asset
  3018. * @param material The glTF material property
  3019. * @param babylonDrawMode The draw mode for the Babylon material
  3020. * @returns The Babylon material
  3021. */
  3022. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): BABYLON.Material;
  3023. /**
  3024. * Loads properties from a glTF material into a Babylon material.
  3025. * @param context The context when loading the asset
  3026. * @param material The glTF material property
  3027. * @param babylonMaterial The Babylon material
  3028. * @returns A promise that resolves when the load is complete
  3029. */
  3030. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): Promise<void>;
  3031. /**
  3032. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  3033. * @param context The context when loading the asset
  3034. * @param material The glTF material property
  3035. * @param babylonMaterial The Babylon material
  3036. * @returns A promise that resolves when the load is complete
  3037. */
  3038. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): Promise<void>;
  3039. /**
  3040. * Loads the alpha properties from a glTF material into a Babylon material.
  3041. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  3042. * @param context The context when loading the asset
  3043. * @param material The glTF material property
  3044. * @param babylonMaterial The Babylon material
  3045. */
  3046. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): void;
  3047. /**
  3048. * Loads a glTF texture info.
  3049. * @param context The context when loading the asset
  3050. * @param textureInfo The glTF texture info property
  3051. * @param assign A function called synchronously after parsing the glTF properties
  3052. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  3053. */
  3054. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BABYLON.BaseTexture) => void): Promise<BABYLON.BaseTexture>;
  3055. /**
  3056. * Loads a glTF image.
  3057. * @param context The context when loading the asset
  3058. * @param image The glTF image property
  3059. * @returns A promise that resolves with the loaded data when the load is complete
  3060. */
  3061. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  3062. /**
  3063. * Loads a glTF uri.
  3064. * @param context The context when loading the asset
  3065. * @param uri The base64 or relative uri
  3066. * @returns A promise that resolves with the loaded data when the load is complete
  3067. */
  3068. loadUriAsync(context: string, uri: string): Promise<ArrayBufferView>;
  3069. /**
  3070. * Helper method called by a loader extension to load an glTF extension.
  3071. * @param context The context when loading the asset
  3072. * @param property The glTF property to load the extension from
  3073. * @param extensionName The name of the extension to load
  3074. * @param actionAsync The action to run
  3075. * @returns The promise returned by actionAsync or null if the extension does not exist
  3076. */
  3077. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: BABYLON.GLTF2.IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => BABYLON.Nullable<Promise<TResult>>): BABYLON.Nullable<Promise<TResult>>;
  3078. /**
  3079. * Helper method called by a loader extension to load a glTF extra.
  3080. * @param context The context when loading the asset
  3081. * @param property The glTF property to load the extra from
  3082. * @param extensionName The name of the extension to load
  3083. * @param actionAsync The action to run
  3084. * @returns The promise returned by actionAsync or null if the extra does not exist
  3085. */
  3086. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: BABYLON.GLTF2.IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => BABYLON.Nullable<Promise<TResult>>): BABYLON.Nullable<Promise<TResult>>;
  3087. /**
  3088. * Increments the indentation level and logs a message.
  3089. * @param message The message to log
  3090. */
  3091. logOpen(message: string): void;
  3092. /**
  3093. * Decrements the indentation level.
  3094. */
  3095. logClose(): void;
  3096. /**
  3097. * Logs a message
  3098. * @param message The message to log
  3099. */
  3100. log(message: string): void;
  3101. /**
  3102. * Starts a performance counter.
  3103. * @param counterName The name of the performance counter
  3104. */
  3105. startPerformanceCounter(counterName: string): void;
  3106. /**
  3107. * Ends a performance counter.
  3108. * @param counterName The name of the performance counter
  3109. */
  3110. endPerformanceCounter(counterName: string): void;
  3111. }
  3112. }
  3113. declare module BABYLON.GLTF2 {
  3114. /** @hidden */
  3115. export var __IGLTFLoaderExtension: number;
  3116. /**
  3117. * Interface for a glTF loader extension.
  3118. */
  3119. export interface IGLTFLoaderExtension extends IGLTFBaseLoaderExtension, BABYLON.IDisposable {
  3120. /**
  3121. * Called after the loader state changes to LOADING.
  3122. */
  3123. onLoading?(): void;
  3124. /**
  3125. * Called after the loader state changes to READY.
  3126. */
  3127. onReady?(): void;
  3128. /**
  3129. * Define this method to modify the default behavior when loading scenes.
  3130. * @param context The context when loading the asset
  3131. * @param scene The glTF scene property
  3132. * @returns A promise that resolves when the load is complete or null if not handled
  3133. */
  3134. loadSceneAsync?(context: string, scene: IScene): BABYLON.Nullable<Promise<void>>;
  3135. /**
  3136. * Define this method to modify the default behavior when loading nodes.
  3137. * @param context The context when loading the asset
  3138. * @param node The glTF node property
  3139. * @param assign A function called synchronously after parsing the glTF properties
  3140. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete or null if not handled
  3141. */
  3142. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  3143. /**
  3144. * Define this method to modify the default behavior when loading cameras.
  3145. * @param context The context when loading the asset
  3146. * @param camera The glTF camera property
  3147. * @param assign A function called synchronously after parsing the glTF properties
  3148. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  3149. */
  3150. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: BABYLON.Camera) => void): BABYLON.Nullable<Promise<BABYLON.Camera>>;
  3151. /**
  3152. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  3153. * @param context The context when loading the asset
  3154. * @param primitive The glTF mesh primitive property
  3155. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  3156. */
  3157. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: BABYLON.Mesh): BABYLON.Nullable<Promise<BABYLON.Geometry>>;
  3158. /**
  3159. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  3160. * @param context The context when loading the asset
  3161. * @param material The glTF material property
  3162. * @param assign A function called synchronously after parsing the glTF properties
  3163. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  3164. */
  3165. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: BABYLON.Mesh, babylonDrawMode: number, assign: (babylonMaterial: BABYLON.Material) => void): BABYLON.Nullable<Promise<BABYLON.Material>>;
  3166. /**
  3167. * Define this method to modify the default behavior when creating materials.
  3168. * @param context The context when loading the asset
  3169. * @param material The glTF material property
  3170. * @param babylonDrawMode The draw mode for the Babylon material
  3171. * @returns The Babylon material or null if not handled
  3172. */
  3173. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): BABYLON.Nullable<BABYLON.Material>;
  3174. /**
  3175. * Define this method to modify the default behavior when loading material properties.
  3176. * @param context The context when loading the asset
  3177. * @param material The glTF material property
  3178. * @param babylonMaterial The Babylon material
  3179. * @returns A promise that resolves when the load is complete or null if not handled
  3180. */
  3181. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  3182. /**
  3183. * Define this method to modify the default behavior when loading texture infos.
  3184. * @param context The context when loading the asset
  3185. * @param textureInfo The glTF texture info property
  3186. * @param assign A function called synchronously after parsing the glTF properties
  3187. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  3188. */
  3189. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BABYLON.BaseTexture) => void): BABYLON.Nullable<Promise<BABYLON.BaseTexture>>;
  3190. /**
  3191. * Define this method to modify the default behavior when loading animations.
  3192. * @param context The context when loading the asset
  3193. * @param animation The glTF animation property
  3194. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  3195. */
  3196. loadAnimationAsync?(context: string, animation: IAnimation): BABYLON.Nullable<Promise<BABYLON.AnimationGroup>>;
  3197. /**
  3198. * Define this method to modify the default behavior when loading uris.
  3199. * @param context The context when loading the asset
  3200. * @param uri The uri to load
  3201. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3202. */
  3203. _loadUriAsync?(context: string, uri: string): BABYLON.Nullable<Promise<ArrayBufferView>>;
  3204. }
  3205. }
  3206. declare module BABYLON.GLTF2 {
  3207. /** @hidden */
  3208. export var __IGLTFLoaderInterfacesV2: number;
  3209. /**
  3210. * Loader interface with an index field.
  3211. */
  3212. export interface IArrayItem {
  3213. /**
  3214. * The index of this item in the array.
  3215. */
  3216. index: number;
  3217. }
  3218. /**
  3219. * Loader interface with additional members.
  3220. */
  3221. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3222. /** @hidden */
  3223. _data?: Promise<ArrayBufferView>;
  3224. /** @hidden */
  3225. _babylonVertexBuffer?: Promise<BABYLON.VertexBuffer>;
  3226. }
  3227. /**
  3228. * Loader interface with additional members.
  3229. */
  3230. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3231. }
  3232. /** @hidden */
  3233. export interface _IAnimationSamplerData {
  3234. input: Float32Array;
  3235. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3236. output: Float32Array;
  3237. }
  3238. /**
  3239. * Loader interface with additional members.
  3240. */
  3241. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3242. /** @hidden */
  3243. _data?: Promise<_IAnimationSamplerData>;
  3244. }
  3245. /**
  3246. * Loader interface with additional members.
  3247. */
  3248. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3249. channels: IAnimationChannel[];
  3250. samplers: IAnimationSampler[];
  3251. /** @hidden */
  3252. _babylonAnimationGroup?: BABYLON.AnimationGroup;
  3253. }
  3254. /**
  3255. * Loader interface with additional members.
  3256. */
  3257. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3258. /** @hidden */
  3259. _data?: Promise<ArrayBufferView>;
  3260. }
  3261. /**
  3262. * Loader interface with additional members.
  3263. */
  3264. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3265. /** @hidden */
  3266. _data?: Promise<ArrayBufferView>;
  3267. /** @hidden */
  3268. _babylonBuffer?: Promise<BABYLON.Buffer>;
  3269. }
  3270. /**
  3271. * Loader interface with additional members.
  3272. */
  3273. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3274. }
  3275. /**
  3276. * Loader interface with additional members.
  3277. */
  3278. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3279. /** @hidden */
  3280. _data?: Promise<ArrayBufferView>;
  3281. }
  3282. /**
  3283. * Loader interface with additional members.
  3284. */
  3285. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, BABYLON.GLTF2.ITextureInfo {
  3286. }
  3287. /**
  3288. * Loader interface with additional members.
  3289. */
  3290. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, BABYLON.GLTF2.ITextureInfo {
  3291. }
  3292. /**
  3293. * Loader interface with additional members.
  3294. */
  3295. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3296. baseColorTexture?: ITextureInfo;
  3297. metallicRoughnessTexture?: ITextureInfo;
  3298. }
  3299. /**
  3300. * Loader interface with additional members.
  3301. */
  3302. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3303. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3304. normalTexture?: IMaterialNormalTextureInfo;
  3305. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3306. emissiveTexture?: ITextureInfo;
  3307. /** @hidden */
  3308. _babylonData?: {
  3309. [drawMode: number]: {
  3310. material: BABYLON.Material;
  3311. meshes: BABYLON.AbstractMesh[];
  3312. promise: Promise<void>;
  3313. };
  3314. };
  3315. }
  3316. /**
  3317. * Loader interface with additional members.
  3318. */
  3319. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3320. primitives: IMeshPrimitive[];
  3321. }
  3322. /**
  3323. * Loader interface with additional members.
  3324. */
  3325. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3326. }
  3327. /**
  3328. * Loader interface with additional members.
  3329. */
  3330. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  3331. /**
  3332. * The parent glTF node.
  3333. */
  3334. parent?: INode;
  3335. /** @hidden */
  3336. _babylonMesh?: BABYLON.Mesh;
  3337. /** @hidden */
  3338. _primitiveBabylonMeshes?: BABYLON.Mesh[];
  3339. /** @hidden */
  3340. _babylonBones?: BABYLON.Bone[];
  3341. /** @hidden */
  3342. _numMorphTargets?: number;
  3343. }
  3344. /** @hidden */
  3345. export interface _ISamplerData {
  3346. noMipMaps: boolean;
  3347. samplingMode: number;
  3348. wrapU: number;
  3349. wrapV: number;
  3350. }
  3351. /**
  3352. * Loader interface with additional members.
  3353. */
  3354. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  3355. /** @hidden */
  3356. _data?: _ISamplerData;
  3357. }
  3358. /**
  3359. * Loader interface with additional members.
  3360. */
  3361. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  3362. }
  3363. /**
  3364. * Loader interface with additional members.
  3365. */
  3366. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  3367. /** @hidden */
  3368. _babylonSkeleton?: BABYLON.Skeleton;
  3369. /** @hidden */
  3370. _promise?: Promise<void>;
  3371. }
  3372. /**
  3373. * Loader interface with additional members.
  3374. */
  3375. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  3376. }
  3377. /**
  3378. * Loader interface with additional members.
  3379. */
  3380. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  3381. }
  3382. /**
  3383. * Loader interface with additional members.
  3384. */
  3385. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  3386. accessors?: IAccessor[];
  3387. animations?: IAnimation[];
  3388. buffers?: IBuffer[];
  3389. bufferViews?: IBufferView[];
  3390. cameras?: ICamera[];
  3391. images?: IImage[];
  3392. materials?: IMaterial[];
  3393. meshes?: IMesh[];
  3394. nodes?: INode[];
  3395. samplers?: ISampler[];
  3396. scenes?: IScene[];
  3397. skins?: ISkin[];
  3398. textures?: ITexture[];
  3399. }
  3400. }
  3401. declare module BABYLON.GLTF2 {
  3402. /**
  3403. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  3404. */
  3405. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  3406. /** The name of this extension. */
  3407. readonly name: string;
  3408. /** Defines whether this extension is enabled. */
  3409. enabled: boolean;
  3410. /** @hidden */
  3411. constructor(loader: GLTFLoader);
  3412. /** @hidden */
  3413. dispose(): void;
  3414. /** @hidden */
  3415. onLoading(): void;
  3416. /** @hidden */
  3417. loadSceneAsync(context: string, scene: IScene): BABYLON.Nullable<Promise<void>>;
  3418. }
  3419. }
  3420. declare module BABYLON.GLTF2 {
  3421. /**
  3422. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  3423. */
  3424. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  3425. /** The name of this extension. */
  3426. readonly name: string;
  3427. /** Defines whether this extension is enabled. */
  3428. enabled: boolean;
  3429. /** @hidden */
  3430. constructor(loader: GLTFLoader);
  3431. /** @hidden */
  3432. dispose(): void;
  3433. /** @hidden */
  3434. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: BABYLON.Mesh): BABYLON.Nullable<Promise<BABYLON.Geometry>>;
  3435. }
  3436. }
  3437. declare module BABYLON.GLTF2 {
  3438. /**
  3439. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  3440. */
  3441. export class KHR_lights implements IGLTFLoaderExtension {
  3442. /** The name of this extension. */
  3443. readonly name: string;
  3444. /** Defines whether this extension is enabled. */
  3445. enabled: boolean;
  3446. /** @hidden */
  3447. constructor(loader: GLTFLoader);
  3448. /** @hidden */
  3449. dispose(): void;
  3450. /** @hidden */
  3451. onLoading(): void;
  3452. /** @hidden */
  3453. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  3454. }
  3455. }
  3456. declare module BABYLON.GLTF2 {
  3457. /**
  3458. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  3459. */
  3460. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  3461. /** The name of this extension. */
  3462. readonly name: string;
  3463. /** Defines whether this extension is enabled. */
  3464. enabled: boolean;
  3465. /** @hidden */
  3466. constructor(loader: GLTFLoader);
  3467. /** @hidden */
  3468. dispose(): void;
  3469. /** @hidden */
  3470. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  3471. }
  3472. }
  3473. declare module BABYLON.GLTF2 {
  3474. /**
  3475. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  3476. */
  3477. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  3478. /** The name of this extension. */
  3479. readonly name: string;
  3480. /** Defines whether this extension is enabled. */
  3481. enabled: boolean;
  3482. /** @hidden */
  3483. constructor(loader: GLTFLoader);
  3484. /** @hidden */
  3485. dispose(): void;
  3486. /** @hidden */
  3487. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  3488. }
  3489. }
  3490. declare module BABYLON.GLTF2 {
  3491. /**
  3492. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  3493. */
  3494. export class KHR_texture_transform implements IGLTFLoaderExtension {
  3495. /** The name of this extension. */
  3496. readonly name: string;
  3497. /** Defines whether this extension is enabled. */
  3498. enabled: boolean;
  3499. /** @hidden */
  3500. constructor(loader: GLTFLoader);
  3501. /** @hidden */
  3502. dispose(): void;
  3503. /** @hidden */
  3504. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BABYLON.BaseTexture) => void): BABYLON.Nullable<Promise<BABYLON.BaseTexture>>;
  3505. }
  3506. }
  3507. declare module BABYLON.GLTF2 {
  3508. /**
  3509. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  3510. */
  3511. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  3512. /** The name of this extension. */
  3513. readonly name: string;
  3514. /** Defines whether this extension is enabled. */
  3515. enabled: boolean;
  3516. /** @hidden */
  3517. constructor(loader: GLTFLoader);
  3518. /** @hidden */
  3519. dispose(): void;
  3520. /** @hidden */
  3521. onLoading(): void;
  3522. /** @hidden */
  3523. loadSceneAsync(context: string, scene: IScene): BABYLON.Nullable<Promise<void>>;
  3524. /** @hidden */
  3525. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  3526. /** @hidden */
  3527. loadAnimationAsync(context: string, animation: IAnimation): BABYLON.Nullable<Promise<BABYLON.AnimationGroup>>;
  3528. }
  3529. }
  3530. declare module BABYLON.GLTF2 {
  3531. /**
  3532. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  3533. */
  3534. export class MSFT_lod implements IGLTFLoaderExtension {
  3535. /** The name of this extension. */
  3536. readonly name: string;
  3537. /** Defines whether this extension is enabled. */
  3538. enabled: boolean;
  3539. /**
  3540. * Maximum number of LODs to load, starting from the lowest LOD.
  3541. */
  3542. maxLODsToLoad: number;
  3543. /**
  3544. * BABYLON.Observable raised when all node LODs of one level are loaded.
  3545. * The event data is the index of the loaded LOD starting from zero.
  3546. * Dispose the loader to cancel the loading of the next level of LODs.
  3547. */
  3548. onNodeLODsLoadedObservable: BABYLON.Observable<number>;
  3549. /**
  3550. * BABYLON.Observable raised when all material LODs of one level are loaded.
  3551. * The event data is the index of the loaded LOD starting from zero.
  3552. * Dispose the loader to cancel the loading of the next level of LODs.
  3553. */
  3554. onMaterialLODsLoadedObservable: BABYLON.Observable<number>;
  3555. /** @hidden */
  3556. constructor(loader: GLTFLoader);
  3557. /** @hidden */
  3558. dispose(): void;
  3559. /** @hidden */
  3560. onReady(): void;
  3561. /** @hidden */
  3562. loadNodeAsync(context: string, node: INode, assign: (babylonMesh: BABYLON.Mesh) => void): BABYLON.Nullable<Promise<BABYLON.Mesh>>;
  3563. /** @hidden */
  3564. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: BABYLON.Mesh, babylonDrawMode: number, assign: (babylonMaterial: BABYLON.Material) => void): BABYLON.Nullable<Promise<BABYLON.Material>>;
  3565. /** @hidden */
  3566. _loadUriAsync(context: string, uri: string): BABYLON.Nullable<Promise<ArrayBufferView>>;
  3567. }
  3568. }
  3569. declare module BABYLON.GLTF2 {
  3570. /** @hidden */
  3571. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  3572. readonly name: string;
  3573. enabled: boolean;
  3574. constructor(loader: GLTFLoader);
  3575. dispose(): void;
  3576. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  3577. }
  3578. }
  3579. declare module BABYLON.GLTF2 {
  3580. /** @hidden */
  3581. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  3582. readonly name: string;
  3583. enabled: boolean;
  3584. constructor(loader: GLTFLoader);
  3585. dispose(): void;
  3586. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: BABYLON.Material): BABYLON.Nullable<Promise<void>>;
  3587. }
  3588. }