babylonjs.loaders.module.d.ts 154 KB

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