babylonjs.loaders.module.d.ts 154 KB

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