babylonjs.loaders.module.d.ts 190 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581
  1. declare module "babylonjs-loaders/glTF/glTFFileLoader" {
  2. import * as GLTF2 from "babylonjs-gltf2interface";
  3. import { Nullable } from "babylonjs/types";
  4. import { Observable } from "babylonjs/Misc/observable";
  5. import { Camera } from "babylonjs/Cameras/camera";
  6. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  7. import { Skeleton } from "babylonjs/Bones/skeleton";
  8. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  9. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  10. import { Material } from "babylonjs/Materials/material";
  11. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12. import { ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  13. import { AssetContainer } from "babylonjs/assetContainer";
  14. import { Scene, IDisposable } from "babylonjs/scene";
  15. import { WebRequest } from "babylonjs/Misc/webRequest";
  16. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  17. import { IDataBuffer } from 'babylonjs/Misc/dataReader';
  18. /**
  19. * Mode that determines the coordinate system to use.
  20. */
  21. export enum GLTFLoaderCoordinateSystemMode {
  22. /**
  23. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  24. */
  25. AUTO = 0,
  26. /**
  27. * Sets the useRightHandedSystem flag on the scene.
  28. */
  29. FORCE_RIGHT_HANDED = 1
  30. }
  31. /**
  32. * Mode that determines what animations will start.
  33. */
  34. export enum GLTFLoaderAnimationStartMode {
  35. /**
  36. * No animation will start.
  37. */
  38. NONE = 0,
  39. /**
  40. * The first animation will start.
  41. */
  42. FIRST = 1,
  43. /**
  44. * All animations will start.
  45. */
  46. ALL = 2
  47. }
  48. /**
  49. * Interface that contains the data for the glTF asset.
  50. */
  51. export interface IGLTFLoaderData {
  52. /**
  53. * The object that represents the glTF JSON.
  54. */
  55. json: Object;
  56. /**
  57. * The BIN chunk of a binary glTF.
  58. */
  59. bin: Nullable<IDataBuffer>;
  60. }
  61. /**
  62. * Interface for extending the loader.
  63. */
  64. export interface IGLTFLoaderExtension {
  65. /**
  66. * The name of this extension.
  67. */
  68. readonly name: string;
  69. /**
  70. * Defines whether this extension is enabled.
  71. */
  72. enabled: boolean;
  73. /**
  74. * Defines the order of this extension.
  75. * The loader sorts the extensions using these values when loading.
  76. */
  77. order?: number;
  78. }
  79. /**
  80. * Loader state.
  81. */
  82. export enum GLTFLoaderState {
  83. /**
  84. * The asset is loading.
  85. */
  86. LOADING = 0,
  87. /**
  88. * The asset is ready for rendering.
  89. */
  90. READY = 1,
  91. /**
  92. * The asset is completely loaded.
  93. */
  94. COMPLETE = 2
  95. }
  96. /** @hidden */
  97. export interface IGLTFLoader extends IDisposable {
  98. readonly state: Nullable<GLTFLoaderState>;
  99. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  100. meshes: AbstractMesh[];
  101. particleSystems: IParticleSystem[];
  102. skeletons: Skeleton[];
  103. animationGroups: AnimationGroup[];
  104. }>;
  105. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  106. }
  107. /**
  108. * File loader for loading glTF files into a scene.
  109. */
  110. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  111. /** @hidden */
  112. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  113. /** @hidden */
  114. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  115. /**
  116. * Raised when the asset has been parsed
  117. */
  118. onParsedObservable: Observable<IGLTFLoaderData>;
  119. private _onParsedObserver;
  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. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  165. * Enabling will disable offline support and glTF validator.
  166. * Defaults to false.
  167. */
  168. useRangeRequests: boolean;
  169. /**
  170. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  171. */
  172. createInstances: boolean;
  173. /**
  174. * Function called before loading a url referenced by the asset.
  175. */
  176. preprocessUrlAsync: (url: string) => Promise<string>;
  177. /**
  178. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  179. */
  180. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  181. private _onMeshLoadedObserver;
  182. /**
  183. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  184. */
  185. onMeshLoaded: (mesh: AbstractMesh) => void;
  186. /**
  187. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  188. */
  189. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  190. private _onTextureLoadedObserver;
  191. /**
  192. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  193. */
  194. onTextureLoaded: (texture: BaseTexture) => void;
  195. /**
  196. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  197. */
  198. readonly onMaterialLoadedObservable: Observable<Material>;
  199. private _onMaterialLoadedObserver;
  200. /**
  201. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  202. */
  203. onMaterialLoaded: (material: Material) => void;
  204. /**
  205. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  206. */
  207. readonly onCameraLoadedObservable: Observable<Camera>;
  208. private _onCameraLoadedObserver;
  209. /**
  210. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  211. */
  212. onCameraLoaded: (camera: Camera) => void;
  213. /**
  214. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  215. * For assets with LODs, raised when all of the LODs are complete.
  216. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  217. */
  218. readonly onCompleteObservable: Observable<void>;
  219. private _onCompleteObserver;
  220. /**
  221. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  222. * For assets with LODs, raised when all of the LODs are complete.
  223. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  224. */
  225. onComplete: () => void;
  226. /**
  227. * Observable raised when an error occurs.
  228. */
  229. readonly onErrorObservable: Observable<any>;
  230. private _onErrorObserver;
  231. /**
  232. * Callback raised when an error occurs.
  233. */
  234. onError: (reason: any) => void;
  235. /**
  236. * Observable raised after the loader is disposed.
  237. */
  238. readonly onDisposeObservable: Observable<void>;
  239. private _onDisposeObserver;
  240. /**
  241. * Callback raised after the loader is disposed.
  242. */
  243. onDispose: () => void;
  244. /**
  245. * Observable raised after a loader extension is created.
  246. * Set additional options for a loader extension in this event.
  247. */
  248. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  249. private _onExtensionLoadedObserver;
  250. /**
  251. * Callback raised after a loader extension is created.
  252. */
  253. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  254. /**
  255. * Defines if the loader logging is enabled.
  256. */
  257. loggingEnabled: boolean;
  258. /**
  259. * Defines if the loader should capture performance counters.
  260. */
  261. capturePerformanceCounters: boolean;
  262. /**
  263. * Defines if the loader should validate the asset.
  264. */
  265. validate: boolean;
  266. /**
  267. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  268. */
  269. readonly onValidatedObservable: Observable<GLTF2.IGLTFValidationResults>;
  270. private _onValidatedObserver;
  271. /**
  272. * Callback raised after a loader extension is created.
  273. */
  274. onValidated: (results: GLTF2.IGLTFValidationResults) => void;
  275. private _loader;
  276. /**
  277. * Name of the loader ("gltf")
  278. */
  279. name: string;
  280. /** @hidden */
  281. extensions: ISceneLoaderPluginExtensions;
  282. /**
  283. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  284. */
  285. dispose(): void;
  286. /** @hidden */
  287. _clear(): void;
  288. /** @hidden */
  289. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  290. /** @hidden */
  291. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  292. /** @hidden */
  293. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  294. meshes: AbstractMesh[];
  295. particleSystems: IParticleSystem[];
  296. skeletons: Skeleton[];
  297. animationGroups: AnimationGroup[];
  298. }>;
  299. /** @hidden */
  300. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  301. /** @hidden */
  302. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  303. /** @hidden */
  304. canDirectLoad(data: string): boolean;
  305. /** @hidden */
  306. directLoad(scene: Scene, data: string): any;
  307. /**
  308. * The callback that allows custom handling of the root url based on the response url.
  309. * @param rootUrl the original root url
  310. * @param responseURL the response url if available
  311. * @returns the new root url
  312. */
  313. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  314. /** @hidden */
  315. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  316. /**
  317. * The loader state or null if the loader is not active.
  318. */
  319. readonly loaderState: Nullable<GLTFLoaderState>;
  320. /**
  321. * Returns a promise that resolves when the asset is completely loaded.
  322. * @returns a promise that resolves when the asset is completely loaded.
  323. */
  324. whenCompleteAsync(): Promise<void>;
  325. private _validateAsync;
  326. private _getLoader;
  327. private _parseJson;
  328. private _unpackBinaryAsync;
  329. private _unpackBinaryV1Async;
  330. private _unpackBinaryV2Async;
  331. private static _parseVersion;
  332. private static _compareVersion;
  333. private static readonly _logSpaces;
  334. private _logIndentLevel;
  335. private _loggingEnabled;
  336. /** @hidden */
  337. _log: (message: string) => void;
  338. /** @hidden */
  339. _logOpen(message: string): void;
  340. /** @hidden */
  341. _logClose(): void;
  342. private _logEnabled;
  343. private _logDisabled;
  344. private _capturePerformanceCounters;
  345. /** @hidden */
  346. _startPerformanceCounter: (counterName: string) => void;
  347. /** @hidden */
  348. _endPerformanceCounter: (counterName: string) => void;
  349. private _startPerformanceCounterEnabled;
  350. private _startPerformanceCounterDisabled;
  351. private _endPerformanceCounterEnabled;
  352. private _endPerformanceCounterDisabled;
  353. }
  354. }
  355. declare module "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces" {
  356. import { Bone } from "babylonjs/Bones/bone";
  357. import { Skeleton } from "babylonjs/Bones/skeleton";
  358. import { Texture } from "babylonjs/Materials/Textures/texture";
  359. import { Node } from "babylonjs/node";
  360. import { Scene } from "babylonjs/scene";
  361. /**
  362. * Enums
  363. * @hidden
  364. */
  365. export enum EComponentType {
  366. BYTE = 5120,
  367. UNSIGNED_BYTE = 5121,
  368. SHORT = 5122,
  369. UNSIGNED_SHORT = 5123,
  370. FLOAT = 5126
  371. }
  372. /** @hidden */
  373. export enum EShaderType {
  374. FRAGMENT = 35632,
  375. VERTEX = 35633
  376. }
  377. /** @hidden */
  378. export enum EParameterType {
  379. BYTE = 5120,
  380. UNSIGNED_BYTE = 5121,
  381. SHORT = 5122,
  382. UNSIGNED_SHORT = 5123,
  383. INT = 5124,
  384. UNSIGNED_INT = 5125,
  385. FLOAT = 5126,
  386. FLOAT_VEC2 = 35664,
  387. FLOAT_VEC3 = 35665,
  388. FLOAT_VEC4 = 35666,
  389. INT_VEC2 = 35667,
  390. INT_VEC3 = 35668,
  391. INT_VEC4 = 35669,
  392. BOOL = 35670,
  393. BOOL_VEC2 = 35671,
  394. BOOL_VEC3 = 35672,
  395. BOOL_VEC4 = 35673,
  396. FLOAT_MAT2 = 35674,
  397. FLOAT_MAT3 = 35675,
  398. FLOAT_MAT4 = 35676,
  399. SAMPLER_2D = 35678
  400. }
  401. /** @hidden */
  402. export enum ETextureWrapMode {
  403. CLAMP_TO_EDGE = 33071,
  404. MIRRORED_REPEAT = 33648,
  405. REPEAT = 10497
  406. }
  407. /** @hidden */
  408. export enum ETextureFilterType {
  409. NEAREST = 9728,
  410. LINEAR = 9728,
  411. NEAREST_MIPMAP_NEAREST = 9984,
  412. LINEAR_MIPMAP_NEAREST = 9985,
  413. NEAREST_MIPMAP_LINEAR = 9986,
  414. LINEAR_MIPMAP_LINEAR = 9987
  415. }
  416. /** @hidden */
  417. export enum ETextureFormat {
  418. ALPHA = 6406,
  419. RGB = 6407,
  420. RGBA = 6408,
  421. LUMINANCE = 6409,
  422. LUMINANCE_ALPHA = 6410
  423. }
  424. /** @hidden */
  425. export enum ECullingType {
  426. FRONT = 1028,
  427. BACK = 1029,
  428. FRONT_AND_BACK = 1032
  429. }
  430. /** @hidden */
  431. export enum EBlendingFunction {
  432. ZERO = 0,
  433. ONE = 1,
  434. SRC_COLOR = 768,
  435. ONE_MINUS_SRC_COLOR = 769,
  436. DST_COLOR = 774,
  437. ONE_MINUS_DST_COLOR = 775,
  438. SRC_ALPHA = 770,
  439. ONE_MINUS_SRC_ALPHA = 771,
  440. DST_ALPHA = 772,
  441. ONE_MINUS_DST_ALPHA = 773,
  442. CONSTANT_COLOR = 32769,
  443. ONE_MINUS_CONSTANT_COLOR = 32770,
  444. CONSTANT_ALPHA = 32771,
  445. ONE_MINUS_CONSTANT_ALPHA = 32772,
  446. SRC_ALPHA_SATURATE = 776
  447. }
  448. /** @hidden */
  449. export interface IGLTFProperty {
  450. extensions?: {
  451. [key: string]: any;
  452. };
  453. extras?: Object;
  454. }
  455. /** @hidden */
  456. export interface IGLTFChildRootProperty extends IGLTFProperty {
  457. name?: string;
  458. }
  459. /** @hidden */
  460. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  461. bufferView: string;
  462. byteOffset: number;
  463. byteStride: number;
  464. count: number;
  465. type: string;
  466. componentType: EComponentType;
  467. max?: number[];
  468. min?: number[];
  469. name?: string;
  470. }
  471. /** @hidden */
  472. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  473. buffer: string;
  474. byteOffset: number;
  475. byteLength: number;
  476. byteStride: number;
  477. target?: number;
  478. }
  479. /** @hidden */
  480. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  481. uri: string;
  482. byteLength?: number;
  483. type?: string;
  484. }
  485. /** @hidden */
  486. export interface IGLTFShader extends IGLTFChildRootProperty {
  487. uri: string;
  488. type: EShaderType;
  489. }
  490. /** @hidden */
  491. export interface IGLTFProgram extends IGLTFChildRootProperty {
  492. attributes: string[];
  493. fragmentShader: string;
  494. vertexShader: string;
  495. }
  496. /** @hidden */
  497. export interface IGLTFTechniqueParameter {
  498. type: number;
  499. count?: number;
  500. semantic?: string;
  501. node?: string;
  502. value?: number | boolean | string | Array<any>;
  503. source?: string;
  504. babylonValue?: any;
  505. }
  506. /** @hidden */
  507. export interface IGLTFTechniqueCommonProfile {
  508. lightingModel: string;
  509. texcoordBindings: Object;
  510. parameters?: Array<any>;
  511. }
  512. /** @hidden */
  513. export interface IGLTFTechniqueStatesFunctions {
  514. blendColor?: number[];
  515. blendEquationSeparate?: number[];
  516. blendFuncSeparate?: number[];
  517. colorMask: boolean[];
  518. cullFace: number[];
  519. }
  520. /** @hidden */
  521. export interface IGLTFTechniqueStates {
  522. enable: number[];
  523. functions: IGLTFTechniqueStatesFunctions;
  524. }
  525. /** @hidden */
  526. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  527. parameters: {
  528. [key: string]: IGLTFTechniqueParameter;
  529. };
  530. program: string;
  531. attributes: {
  532. [key: string]: string;
  533. };
  534. uniforms: {
  535. [key: string]: string;
  536. };
  537. states: IGLTFTechniqueStates;
  538. }
  539. /** @hidden */
  540. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  541. technique?: string;
  542. values: string[];
  543. }
  544. /** @hidden */
  545. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  546. attributes: {
  547. [key: string]: string;
  548. };
  549. indices: string;
  550. material: string;
  551. mode?: number;
  552. }
  553. /** @hidden */
  554. export interface IGLTFMesh extends IGLTFChildRootProperty {
  555. primitives: IGLTFMeshPrimitive[];
  556. }
  557. /** @hidden */
  558. export interface IGLTFImage extends IGLTFChildRootProperty {
  559. uri: string;
  560. }
  561. /** @hidden */
  562. export interface IGLTFSampler extends IGLTFChildRootProperty {
  563. magFilter?: number;
  564. minFilter?: number;
  565. wrapS?: number;
  566. wrapT?: number;
  567. }
  568. /** @hidden */
  569. export interface IGLTFTexture extends IGLTFChildRootProperty {
  570. sampler: string;
  571. source: string;
  572. format?: ETextureFormat;
  573. internalFormat?: ETextureFormat;
  574. target?: number;
  575. type?: number;
  576. babylonTexture?: Texture;
  577. }
  578. /** @hidden */
  579. export interface IGLTFAmbienLight {
  580. color?: number[];
  581. }
  582. /** @hidden */
  583. export interface IGLTFDirectionalLight {
  584. color?: number[];
  585. }
  586. /** @hidden */
  587. export interface IGLTFPointLight {
  588. color?: number[];
  589. constantAttenuation?: number;
  590. linearAttenuation?: number;
  591. quadraticAttenuation?: number;
  592. }
  593. /** @hidden */
  594. export interface IGLTFSpotLight {
  595. color?: number[];
  596. constantAttenuation?: number;
  597. fallOfAngle?: number;
  598. fallOffExponent?: number;
  599. linearAttenuation?: number;
  600. quadraticAttenuation?: number;
  601. }
  602. /** @hidden */
  603. export interface IGLTFLight extends IGLTFChildRootProperty {
  604. type: string;
  605. }
  606. /** @hidden */
  607. export interface IGLTFCameraOrthographic {
  608. xmag: number;
  609. ymag: number;
  610. zfar: number;
  611. znear: number;
  612. }
  613. /** @hidden */
  614. export interface IGLTFCameraPerspective {
  615. aspectRatio: number;
  616. yfov: number;
  617. zfar: number;
  618. znear: number;
  619. }
  620. /** @hidden */
  621. export interface IGLTFCamera extends IGLTFChildRootProperty {
  622. type: string;
  623. }
  624. /** @hidden */
  625. export interface IGLTFAnimationChannelTarget {
  626. id: string;
  627. path: string;
  628. }
  629. /** @hidden */
  630. export interface IGLTFAnimationChannel {
  631. sampler: string;
  632. target: IGLTFAnimationChannelTarget;
  633. }
  634. /** @hidden */
  635. export interface IGLTFAnimationSampler {
  636. input: string;
  637. output: string;
  638. interpolation?: string;
  639. }
  640. /** @hidden */
  641. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  642. channels?: IGLTFAnimationChannel[];
  643. parameters?: {
  644. [key: string]: string;
  645. };
  646. samplers?: {
  647. [key: string]: IGLTFAnimationSampler;
  648. };
  649. }
  650. /** @hidden */
  651. export interface IGLTFNodeInstanceSkin {
  652. skeletons: string[];
  653. skin: string;
  654. meshes: string[];
  655. }
  656. /** @hidden */
  657. export interface IGLTFSkins extends IGLTFChildRootProperty {
  658. bindShapeMatrix: number[];
  659. inverseBindMatrices: string;
  660. jointNames: string[];
  661. babylonSkeleton?: Skeleton;
  662. }
  663. /** @hidden */
  664. export interface IGLTFNode extends IGLTFChildRootProperty {
  665. camera?: string;
  666. children: string[];
  667. skin?: string;
  668. jointName?: string;
  669. light?: string;
  670. matrix: number[];
  671. mesh?: string;
  672. meshes?: string[];
  673. rotation?: number[];
  674. scale?: number[];
  675. translation?: number[];
  676. babylonNode?: Node;
  677. }
  678. /** @hidden */
  679. export interface IGLTFScene extends IGLTFChildRootProperty {
  680. nodes: string[];
  681. }
  682. /** @hidden */
  683. export interface IGLTFRuntime {
  684. extensions: {
  685. [key: string]: any;
  686. };
  687. accessors: {
  688. [key: string]: IGLTFAccessor;
  689. };
  690. buffers: {
  691. [key: string]: IGLTFBuffer;
  692. };
  693. bufferViews: {
  694. [key: string]: IGLTFBufferView;
  695. };
  696. meshes: {
  697. [key: string]: IGLTFMesh;
  698. };
  699. lights: {
  700. [key: string]: IGLTFLight;
  701. };
  702. cameras: {
  703. [key: string]: IGLTFCamera;
  704. };
  705. nodes: {
  706. [key: string]: IGLTFNode;
  707. };
  708. images: {
  709. [key: string]: IGLTFImage;
  710. };
  711. textures: {
  712. [key: string]: IGLTFTexture;
  713. };
  714. shaders: {
  715. [key: string]: IGLTFShader;
  716. };
  717. programs: {
  718. [key: string]: IGLTFProgram;
  719. };
  720. samplers: {
  721. [key: string]: IGLTFSampler;
  722. };
  723. techniques: {
  724. [key: string]: IGLTFTechnique;
  725. };
  726. materials: {
  727. [key: string]: IGLTFMaterial;
  728. };
  729. animations: {
  730. [key: string]: IGLTFAnimation;
  731. };
  732. skins: {
  733. [key: string]: IGLTFSkins;
  734. };
  735. currentScene?: Object;
  736. scenes: {
  737. [key: string]: IGLTFScene;
  738. };
  739. extensionsUsed: string[];
  740. extensionsRequired?: string[];
  741. buffersCount: number;
  742. shaderscount: number;
  743. scene: Scene;
  744. rootUrl: string;
  745. loadedBufferCount: number;
  746. loadedBufferViews: {
  747. [name: string]: ArrayBufferView;
  748. };
  749. loadedShaderCount: number;
  750. importOnlyMeshes: boolean;
  751. importMeshesNames?: string[];
  752. dummyNodes: Node[];
  753. }
  754. /** @hidden */
  755. export interface INodeToRoot {
  756. bone: Bone;
  757. node: IGLTFNode;
  758. id: string;
  759. }
  760. /** @hidden */
  761. export interface IJointNode {
  762. node: IGLTFNode;
  763. id: string;
  764. }
  765. }
  766. declare module "babylonjs-loaders/glTF/1.0/glTFLoaderUtils" {
  767. import { IGLTFTechniqueParameter, IGLTFAccessor, ETextureFilterType, IGLTFRuntime, IGLTFBufferView, EComponentType } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  768. import { Effect } from "babylonjs/Materials/effect";
  769. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  770. import { Node } from "babylonjs/node";
  771. import { Scene } from "babylonjs/scene";
  772. /**
  773. * Utils functions for GLTF
  774. * @hidden
  775. */
  776. export class GLTFUtils {
  777. /**
  778. * Sets the given "parameter" matrix
  779. * @param scene: the Scene object
  780. * @param source: the source node where to pick the matrix
  781. * @param parameter: the GLTF technique parameter
  782. * @param uniformName: the name of the shader's uniform
  783. * @param shaderMaterial: the shader material
  784. */
  785. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  786. /**
  787. * Sets the given "parameter" matrix
  788. * @param shaderMaterial: the shader material
  789. * @param uniform: the name of the shader's uniform
  790. * @param value: the value of the uniform
  791. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  792. */
  793. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  794. /**
  795. * Returns the wrap mode of the texture
  796. * @param mode: the mode value
  797. */
  798. static GetWrapMode(mode: number): number;
  799. /**
  800. * Returns the byte stride giving an accessor
  801. * @param accessor: the GLTF accessor objet
  802. */
  803. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  804. /**
  805. * Returns the texture filter mode giving a mode value
  806. * @param mode: the filter mode value
  807. */
  808. static GetTextureFilterMode(mode: number): ETextureFilterType;
  809. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  810. /**
  811. * Returns a buffer from its accessor
  812. * @param gltfRuntime: the GLTF runtime
  813. * @param accessor: the GLTF accessor
  814. */
  815. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  816. /**
  817. * Decodes a buffer view into a string
  818. * @param view: the buffer view
  819. */
  820. static DecodeBufferToText(view: ArrayBufferView): string;
  821. /**
  822. * Returns the default material of gltf. Related to
  823. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  824. * @param scene: the Babylon.js scene
  825. */
  826. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  827. private static _DefaultMaterial;
  828. }
  829. }
  830. declare module "babylonjs-loaders/glTF/1.0/glTFLoader" {
  831. import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  832. import { Nullable } from "babylonjs/types";
  833. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  834. import { Skeleton } from "babylonjs/Bones/skeleton";
  835. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  836. import { Material } from "babylonjs/Materials/material";
  837. import { Texture } from "babylonjs/Materials/Textures/texture";
  838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  839. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  840. import { Scene } from "babylonjs/scene";
  841. import { IGLTFLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
  842. /**
  843. * Implementation of the base glTF spec
  844. * @hidden
  845. */
  846. export class GLTFLoaderBase {
  847. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  848. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  849. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  850. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  851. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  852. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  853. }
  854. /**
  855. * glTF V1 Loader
  856. * @hidden
  857. */
  858. export class GLTFLoader implements IGLTFLoader {
  859. static Extensions: {
  860. [name: string]: GLTFLoaderExtension;
  861. };
  862. static RegisterExtension(extension: GLTFLoaderExtension): void;
  863. state: Nullable<GLTFLoaderState>;
  864. dispose(): void;
  865. private _importMeshAsync;
  866. /**
  867. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  868. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  869. * @param scene the scene the meshes should be added to
  870. * @param data gltf data containing information of the meshes in a loaded file
  871. * @param rootUrl root url to load from
  872. * @param onProgress event that fires when loading progress has occured
  873. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  874. */
  875. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  876. meshes: AbstractMesh[];
  877. particleSystems: IParticleSystem[];
  878. skeletons: Skeleton[];
  879. animationGroups: AnimationGroup[];
  880. }>;
  881. private _loadAsync;
  882. /**
  883. * Imports all objects from a loaded gltf file and adds them to the scene
  884. * @param scene the scene the objects should be added to
  885. * @param data gltf data containing information of the meshes in a loaded file
  886. * @param rootUrl root url to load from
  887. * @param onProgress event that fires when loading progress has occured
  888. * @returns a promise which completes when objects have been loaded to the scene
  889. */
  890. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  891. private _loadShadersAsync;
  892. private _loadBuffersAsync;
  893. private _createNodes;
  894. }
  895. /** @hidden */
  896. export abstract class GLTFLoaderExtension {
  897. private _name;
  898. constructor(name: string);
  899. readonly name: string;
  900. /**
  901. * Defines an override for loading the runtime
  902. * Return true to stop further extensions from loading the runtime
  903. */
  904. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  905. /**
  906. * Defines an onverride for creating gltf runtime
  907. * Return true to stop further extensions from creating the runtime
  908. */
  909. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  910. /**
  911. * Defines an override for loading buffers
  912. * Return true to stop further extensions from loading this buffer
  913. */
  914. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  915. /**
  916. * Defines an override for loading texture buffers
  917. * Return true to stop further extensions from loading this texture data
  918. */
  919. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  920. /**
  921. * Defines an override for creating textures
  922. * Return true to stop further extensions from loading this texture
  923. */
  924. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  925. /**
  926. * Defines an override for loading shader strings
  927. * Return true to stop further extensions from loading this shader data
  928. */
  929. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  930. /**
  931. * Defines an override for loading materials
  932. * Return true to stop further extensions from loading this material
  933. */
  934. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  935. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  936. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  937. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  938. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  939. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  940. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  941. private static LoadTextureBufferAsync;
  942. private static CreateTextureAsync;
  943. private static ApplyExtensions;
  944. }
  945. }
  946. declare module "babylonjs-loaders/glTF/1.0/glTFBinaryExtension" {
  947. import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader";
  948. import { Scene } from "babylonjs/scene";
  949. import { IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
  950. import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  951. /** @hidden */
  952. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  953. private _bin;
  954. constructor();
  955. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  956. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  957. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  958. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  959. }
  960. }
  961. declare module "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension" {
  962. import { GLTFLoaderExtension } from "babylonjs-loaders/glTF/1.0/glTFLoader";
  963. import { IGLTFRuntime } from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  964. import { Material } from "babylonjs/Materials/material";
  965. /** @hidden */
  966. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  967. constructor();
  968. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  969. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  970. private _loadTexture;
  971. }
  972. }
  973. declare module "babylonjs-loaders/glTF/1.0/index" {
  974. export * from "babylonjs-loaders/glTF/1.0/glTFBinaryExtension";
  975. export * from "babylonjs-loaders/glTF/1.0/glTFLoader";
  976. export * from "babylonjs-loaders/glTF/1.0/glTFLoaderInterfaces";
  977. export * from "babylonjs-loaders/glTF/1.0/glTFLoaderUtils";
  978. export * from "babylonjs-loaders/glTF/1.0/glTFMaterialsCommonExtension";
  979. }
  980. declare module "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces" {
  981. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  982. import { Bone } from "babylonjs/Bones/bone";
  983. import { Skeleton } from "babylonjs/Bones/skeleton";
  984. import { Material } from "babylonjs/Materials/material";
  985. import { TransformNode } from "babylonjs/Meshes/transformNode";
  986. import { Buffer, VertexBuffer } from "babylonjs/Meshes/buffer";
  987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  988. import { Mesh } from "babylonjs/Meshes/mesh";
  989. import * as GLTF2 from "babylonjs-gltf2interface";
  990. /**
  991. * Loader interface with an index field.
  992. */
  993. export interface IArrayItem {
  994. /**
  995. * The index of this item in the array.
  996. */
  997. index: number;
  998. }
  999. /**
  1000. * Loader interface with additional members.
  1001. */
  1002. export interface IAccessor extends GLTF2.IAccessor, IArrayItem {
  1003. /** @hidden */
  1004. _data?: Promise<ArrayBufferView>;
  1005. /** @hidden */
  1006. _babylonVertexBuffer?: Promise<VertexBuffer>;
  1007. }
  1008. /**
  1009. * Loader interface with additional members.
  1010. */
  1011. export interface IAnimationChannel extends GLTF2.IAnimationChannel, IArrayItem {
  1012. }
  1013. /** @hidden */
  1014. export interface _IAnimationSamplerData {
  1015. input: Float32Array;
  1016. interpolation: GLTF2.AnimationSamplerInterpolation;
  1017. output: Float32Array;
  1018. }
  1019. /**
  1020. * Loader interface with additional members.
  1021. */
  1022. export interface IAnimationSampler extends GLTF2.IAnimationSampler, IArrayItem {
  1023. /** @hidden */
  1024. _data?: Promise<_IAnimationSamplerData>;
  1025. }
  1026. /**
  1027. * Loader interface with additional members.
  1028. */
  1029. export interface IAnimation extends GLTF2.IAnimation, IArrayItem {
  1030. channels: IAnimationChannel[];
  1031. samplers: IAnimationSampler[];
  1032. /** @hidden */
  1033. _babylonAnimationGroup?: AnimationGroup;
  1034. }
  1035. /**
  1036. * Loader interface with additional members.
  1037. */
  1038. export interface IBuffer extends GLTF2.IBuffer, IArrayItem {
  1039. /** @hidden */
  1040. _data?: Promise<ArrayBufferView>;
  1041. }
  1042. /**
  1043. * Loader interface with additional members.
  1044. */
  1045. export interface IBufferView extends GLTF2.IBufferView, IArrayItem {
  1046. /** @hidden */
  1047. _data?: Promise<ArrayBufferView>;
  1048. /** @hidden */
  1049. _babylonBuffer?: Promise<Buffer>;
  1050. }
  1051. /**
  1052. * Loader interface with additional members.
  1053. */
  1054. export interface ICamera extends GLTF2.ICamera, IArrayItem {
  1055. }
  1056. /**
  1057. * Loader interface with additional members.
  1058. */
  1059. export interface IImage extends GLTF2.IImage, IArrayItem {
  1060. /** @hidden */
  1061. _data?: Promise<ArrayBufferView>;
  1062. }
  1063. /**
  1064. * Loader interface with additional members.
  1065. */
  1066. export interface IMaterialNormalTextureInfo extends GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  1067. }
  1068. /**
  1069. * Loader interface with additional members.
  1070. */
  1071. export interface IMaterialOcclusionTextureInfo extends GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  1072. }
  1073. /**
  1074. * Loader interface with additional members.
  1075. */
  1076. export interface IMaterialPbrMetallicRoughness extends GLTF2.IMaterialPbrMetallicRoughness {
  1077. baseColorTexture?: ITextureInfo;
  1078. metallicRoughnessTexture?: ITextureInfo;
  1079. }
  1080. /**
  1081. * Loader interface with additional members.
  1082. */
  1083. export interface IMaterial extends GLTF2.IMaterial, IArrayItem {
  1084. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  1085. normalTexture?: IMaterialNormalTextureInfo;
  1086. occlusionTexture?: IMaterialOcclusionTextureInfo;
  1087. emissiveTexture?: ITextureInfo;
  1088. /** @hidden */
  1089. _data?: {
  1090. [babylonDrawMode: number]: {
  1091. babylonMaterial: Material;
  1092. babylonMeshes: AbstractMesh[];
  1093. promise: Promise<void>;
  1094. };
  1095. };
  1096. }
  1097. /**
  1098. * Loader interface with additional members.
  1099. */
  1100. export interface IMesh extends GLTF2.IMesh, IArrayItem {
  1101. primitives: IMeshPrimitive[];
  1102. }
  1103. /**
  1104. * Loader interface with additional members.
  1105. */
  1106. export interface IMeshPrimitive extends GLTF2.IMeshPrimitive, IArrayItem {
  1107. /** @hidden */
  1108. _instanceData?: {
  1109. babylonSourceMesh: Mesh;
  1110. promise: Promise<any>;
  1111. };
  1112. }
  1113. /**
  1114. * Loader interface with additional members.
  1115. */
  1116. export interface INode extends GLTF2.INode, IArrayItem {
  1117. /**
  1118. * The parent glTF node.
  1119. */
  1120. parent?: INode;
  1121. /** @hidden */
  1122. _babylonTransformNode?: TransformNode;
  1123. /** @hidden */
  1124. _primitiveBabylonMeshes?: AbstractMesh[];
  1125. /** @hidden */
  1126. _babylonBones?: Bone[];
  1127. /** @hidden */
  1128. _numMorphTargets?: number;
  1129. }
  1130. /** @hidden */
  1131. export interface _ISamplerData {
  1132. noMipMaps: boolean;
  1133. samplingMode: number;
  1134. wrapU: number;
  1135. wrapV: number;
  1136. }
  1137. /**
  1138. * Loader interface with additional members.
  1139. */
  1140. export interface ISampler extends GLTF2.ISampler, IArrayItem {
  1141. /** @hidden */
  1142. _data?: _ISamplerData;
  1143. }
  1144. /**
  1145. * Loader interface with additional members.
  1146. */
  1147. export interface IScene extends GLTF2.IScene, IArrayItem {
  1148. }
  1149. /**
  1150. * Loader interface with additional members.
  1151. */
  1152. export interface ISkin extends GLTF2.ISkin, IArrayItem {
  1153. /** @hidden */
  1154. _data?: {
  1155. babylonSkeleton: Skeleton;
  1156. promise: Promise<void>;
  1157. };
  1158. }
  1159. /**
  1160. * Loader interface with additional members.
  1161. */
  1162. export interface ITexture extends GLTF2.ITexture, IArrayItem {
  1163. }
  1164. /**
  1165. * Loader interface with additional members.
  1166. */
  1167. export interface ITextureInfo extends GLTF2.ITextureInfo {
  1168. }
  1169. /**
  1170. * Loader interface with additional members.
  1171. */
  1172. export interface IGLTF extends GLTF2.IGLTF {
  1173. accessors?: IAccessor[];
  1174. animations?: IAnimation[];
  1175. buffers?: IBuffer[];
  1176. bufferViews?: IBufferView[];
  1177. cameras?: ICamera[];
  1178. images?: IImage[];
  1179. materials?: IMaterial[];
  1180. meshes?: IMesh[];
  1181. nodes?: INode[];
  1182. samplers?: ISampler[];
  1183. scenes?: IScene[];
  1184. skins?: ISkin[];
  1185. textures?: ITexture[];
  1186. }
  1187. }
  1188. declare module "babylonjs-loaders/glTF/2.0/glTFLoaderExtension" {
  1189. import { Nullable } from "babylonjs/types";
  1190. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1191. import { Material } from "babylonjs/Materials/material";
  1192. import { Camera } from "babylonjs/Cameras/camera";
  1193. import { Geometry } from "babylonjs/Meshes/geometry";
  1194. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1196. import { Mesh } from "babylonjs/Meshes/mesh";
  1197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  1198. import { IDisposable } from "babylonjs/scene";
  1199. import { IScene, INode, IMesh, ISkin, ICamera, IMeshPrimitive, IMaterial, ITextureInfo, IAnimation, IBufferView, IBuffer } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1200. import { IGLTFLoaderExtension as IGLTFBaseLoaderExtension } from "babylonjs-loaders/glTF/glTFFileLoader";
  1201. import { IProperty } from 'babylonjs-gltf2interface';
  1202. /**
  1203. * Interface for a glTF loader extension.
  1204. */
  1205. export interface IGLTFLoaderExtension extends IGLTFBaseLoaderExtension, IDisposable {
  1206. /**
  1207. * Called after the loader state changes to LOADING.
  1208. */
  1209. onLoading?(): void;
  1210. /**
  1211. * Called after the loader state changes to READY.
  1212. */
  1213. onReady?(): void;
  1214. /**
  1215. * Define this method to modify the default behavior when loading scenes.
  1216. * @param context The context when loading the asset
  1217. * @param scene The glTF scene property
  1218. * @returns A promise that resolves when the load is complete or null if not handled
  1219. */
  1220. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  1221. /**
  1222. * Define this method to modify the default behavior when loading nodes.
  1223. * @param context The context when loading the asset
  1224. * @param node The glTF node property
  1225. * @param assign A function called synchronously after parsing the glTF properties
  1226. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  1227. */
  1228. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1229. /**
  1230. * Define this method to modify the default behavior when loading cameras.
  1231. * @param context The context when loading the asset
  1232. * @param camera The glTF camera property
  1233. * @param assign A function called synchronously after parsing the glTF properties
  1234. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1235. */
  1236. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1237. /**
  1238. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1239. * @param context The context when loading the asset
  1240. * @param primitive The glTF mesh primitive property
  1241. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1242. */
  1243. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1244. /**
  1245. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  1246. * @param context The context when loading the asset
  1247. * @param name The mesh name when loading the asset
  1248. * @param node The glTF node when loading the asset
  1249. * @param mesh The glTF mesh when loading the asset
  1250. * @param primitive The glTF mesh primitive property
  1251. * @param assign A function called synchronously after parsing the glTF properties
  1252. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  1253. */
  1254. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  1255. /**
  1256. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1257. * @param context The context when loading the asset
  1258. * @param material The glTF material property
  1259. * @param assign A function called synchronously after parsing the glTF properties
  1260. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1261. */
  1262. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1263. /**
  1264. * Define this method to modify the default behavior when creating materials.
  1265. * @param context The context when loading the asset
  1266. * @param material The glTF material property
  1267. * @param babylonDrawMode The draw mode for the Babylon material
  1268. * @returns The Babylon material or null if not handled
  1269. */
  1270. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1271. /**
  1272. * Define this method to modify the default behavior when loading material properties.
  1273. * @param context The context when loading the asset
  1274. * @param material The glTF material property
  1275. * @param babylonMaterial The Babylon material
  1276. * @returns A promise that resolves when the load is complete or null if not handled
  1277. */
  1278. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1279. /**
  1280. * Define this method to modify the default behavior when loading texture infos.
  1281. * @param context The context when loading the asset
  1282. * @param textureInfo The glTF texture info property
  1283. * @param assign A function called synchronously after parsing the glTF properties
  1284. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1285. */
  1286. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1287. /**
  1288. * Define this method to modify the default behavior when loading animations.
  1289. * @param context The context when loading the asset
  1290. * @param animation The glTF animation property
  1291. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1292. */
  1293. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1294. /**
  1295. * @hidden Define this method to modify the default behavior when loading skins.
  1296. * @param context The context when loading the asset
  1297. * @param node The glTF node property
  1298. * @param skin The glTF skin property
  1299. * @returns A promise that resolves when the load is complete or null if not handled
  1300. */
  1301. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  1302. /**
  1303. * @hidden Define this method to modify the default behavior when loading uris.
  1304. * @param context The context when loading the asset
  1305. * @param property The glTF property associated with the uri
  1306. * @param uri The uri to load
  1307. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1308. */
  1309. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1310. /**
  1311. * Define this method to modify the default behavior when loading buffer views.
  1312. * @param context The context when loading the asset
  1313. * @param bufferView The glTF buffer view property
  1314. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1315. */
  1316. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  1317. /**
  1318. * Define this method to modify the default behavior when loading buffers.
  1319. * @param context The context when loading the asset
  1320. * @param buffer The glTF buffer property
  1321. * @param byteOffset The byte offset to load
  1322. * @param byteLength The byte length to load
  1323. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1324. */
  1325. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  1326. }
  1327. }
  1328. declare module "babylonjs-loaders/glTF/2.0/glTFLoader" {
  1329. import { Nullable } from "babylonjs/types";
  1330. import { Camera } from "babylonjs/Cameras/camera";
  1331. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1332. import { Skeleton } from "babylonjs/Bones/skeleton";
  1333. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  1334. import { Material } from "babylonjs/Materials/material";
  1335. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  1338. import { Mesh } from "babylonjs/Meshes/mesh";
  1339. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  1340. import { Scene } from "babylonjs/scene";
  1341. import { IProperty } from "babylonjs-gltf2interface";
  1342. import { IGLTF, INode, IScene, IMesh, ICamera, IAnimation, IAnimationChannel, IBufferView, IMaterial, ITextureInfo, IImage, IMeshPrimitive, IArrayItem as IArrItem } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1343. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1344. import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData } from "babylonjs-loaders/glTF/glTFFileLoader";
  1345. import { IAnimatable } from 'babylonjs/Animations/animatable.interface';
  1346. import { IDataBuffer } from 'babylonjs/Misc/dataReader';
  1347. /**
  1348. * Helper class for working with arrays when loading the glTF asset
  1349. */
  1350. export class ArrayItem {
  1351. /**
  1352. * Gets an item from the given array.
  1353. * @param context The context when loading the asset
  1354. * @param array The array to get the item from
  1355. * @param index The index to the array
  1356. * @returns The array item
  1357. */
  1358. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1359. /**
  1360. * Assign an `index` field to each item of the given array.
  1361. * @param array The array of items
  1362. */
  1363. static Assign(array?: IArrItem[]): void;
  1364. }
  1365. /**
  1366. * The glTF 2.0 loader
  1367. */
  1368. export class GLTFLoader implements IGLTFLoader {
  1369. /** @hidden */
  1370. _completePromises: Promise<any>[];
  1371. private _disposed;
  1372. private _parent;
  1373. private _state;
  1374. private _extensions;
  1375. private _rootUrl;
  1376. private _fileName;
  1377. private _uniqueRootUrl;
  1378. private _gltf;
  1379. private _bin;
  1380. private _babylonScene;
  1381. private _rootBabylonMesh;
  1382. private _defaultBabylonMaterialData;
  1383. private _progressCallback?;
  1384. private _requests;
  1385. private static readonly _DefaultSampler;
  1386. private static _RegisteredExtensions;
  1387. /**
  1388. * Registers a loader extension.
  1389. * @param name The name of the loader extension.
  1390. * @param factory The factory function that creates the loader extension.
  1391. */
  1392. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1393. /**
  1394. * Unregisters a loader extension.
  1395. * @param name The name of the loader extension.
  1396. * @returns A boolean indicating whether the extension has been unregistered
  1397. */
  1398. static UnregisterExtension(name: string): boolean;
  1399. /**
  1400. * Gets the loader state.
  1401. */
  1402. readonly state: Nullable<GLTFLoaderState>;
  1403. /**
  1404. * The object that represents the glTF JSON.
  1405. */
  1406. readonly gltf: IGLTF;
  1407. /**
  1408. * The BIN chunk of a binary glTF.
  1409. */
  1410. readonly bin: Nullable<IDataBuffer>;
  1411. /**
  1412. * The parent file loader.
  1413. */
  1414. readonly parent: GLTFFileLoader;
  1415. /**
  1416. * The Babylon scene when loading the asset.
  1417. */
  1418. readonly babylonScene: Scene;
  1419. /**
  1420. * The root Babylon mesh when loading the asset.
  1421. */
  1422. readonly rootBabylonMesh: Mesh;
  1423. /** @hidden */
  1424. constructor(parent: GLTFFileLoader);
  1425. /** @hidden */
  1426. dispose(): void;
  1427. /** @hidden */
  1428. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1429. meshes: AbstractMesh[];
  1430. particleSystems: IParticleSystem[];
  1431. skeletons: Skeleton[];
  1432. animationGroups: AnimationGroup[];
  1433. }>;
  1434. /** @hidden */
  1435. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1436. private _loadAsync;
  1437. private _loadData;
  1438. private _setupData;
  1439. private _loadExtensions;
  1440. private _checkExtensions;
  1441. private _setState;
  1442. private _createRootNode;
  1443. /**
  1444. * Loads a glTF scene.
  1445. * @param context The context when loading the asset
  1446. * @param scene The glTF scene property
  1447. * @returns A promise that resolves when the load is complete
  1448. */
  1449. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  1450. private _forEachPrimitive;
  1451. private _getMeshes;
  1452. private _getSkeletons;
  1453. private _getAnimationGroups;
  1454. private _startAnimations;
  1455. /**
  1456. * Loads a glTF node.
  1457. * @param context The context when loading the asset
  1458. * @param node The glTF node property
  1459. * @param assign A function called synchronously after parsing the glTF properties
  1460. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1461. */
  1462. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  1463. private _loadMeshAsync;
  1464. /**
  1465. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  1466. * @param context The context when loading the asset
  1467. * @param name The mesh name when loading the asset
  1468. * @param node The glTF node when loading the asset
  1469. * @param mesh The glTF mesh when loading the asset
  1470. * @param primitive The glTF mesh primitive property
  1471. * @param assign A function called synchronously after parsing the glTF properties
  1472. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  1473. */
  1474. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  1475. private _loadVertexDataAsync;
  1476. private _createMorphTargets;
  1477. private _loadMorphTargetsAsync;
  1478. private _loadMorphTargetVertexDataAsync;
  1479. private static _LoadTransform;
  1480. private _loadSkinAsync;
  1481. private _loadBones;
  1482. private _loadBone;
  1483. private _loadSkinInverseBindMatricesDataAsync;
  1484. private _updateBoneMatrices;
  1485. private _getNodeMatrix;
  1486. /**
  1487. * Loads a glTF camera.
  1488. * @param context The context when loading the asset
  1489. * @param camera The glTF camera property
  1490. * @param assign A function called synchronously after parsing the glTF properties
  1491. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1492. */
  1493. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1494. private _loadAnimationsAsync;
  1495. /**
  1496. * Loads a glTF animation.
  1497. * @param context The context when loading the asset
  1498. * @param animation The glTF animation property
  1499. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1500. */
  1501. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  1502. /**
  1503. * @hidden Loads a glTF animation channel.
  1504. * @param context The context when loading the asset
  1505. * @param animationContext The context of the animation when loading the asset
  1506. * @param animation The glTF animation property
  1507. * @param channel The glTF animation channel property
  1508. * @param babylonAnimationGroup The babylon animation group property
  1509. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  1510. * @returns A void promise when the channel load is complete
  1511. */
  1512. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  1513. private _loadAnimationSamplerAsync;
  1514. private _loadBufferAsync;
  1515. /**
  1516. * Loads a glTF buffer view.
  1517. * @param context The context when loading the asset
  1518. * @param bufferView The glTF buffer view property
  1519. * @returns A promise that resolves with the loaded data when the load is complete
  1520. */
  1521. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1522. private _loadAccessorAsync;
  1523. private _loadFloatAccessorAsync;
  1524. private _loadIndicesAccessorAsync;
  1525. private _loadVertexBufferViewAsync;
  1526. private _loadVertexAccessorAsync;
  1527. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1528. /** @hidden */
  1529. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1530. private _createDefaultMaterial;
  1531. /**
  1532. * Creates a Babylon material from a glTF material.
  1533. * @param context The context when loading the asset
  1534. * @param material The glTF material property
  1535. * @param babylonDrawMode The draw mode for the Babylon material
  1536. * @returns The Babylon material
  1537. */
  1538. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1539. /**
  1540. * Loads properties from a glTF material into a Babylon material.
  1541. * @param context The context when loading the asset
  1542. * @param material The glTF material property
  1543. * @param babylonMaterial The Babylon material
  1544. * @returns A promise that resolves when the load is complete
  1545. */
  1546. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1547. /**
  1548. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1549. * @param context The context when loading the asset
  1550. * @param material The glTF material property
  1551. * @param babylonMaterial The Babylon material
  1552. * @returns A promise that resolves when the load is complete
  1553. */
  1554. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1555. /**
  1556. * Loads the alpha properties from a glTF material into a Babylon material.
  1557. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1558. * @param context The context when loading the asset
  1559. * @param material The glTF material property
  1560. * @param babylonMaterial The Babylon material
  1561. */
  1562. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1563. /**
  1564. * Loads a glTF texture info.
  1565. * @param context The context when loading the asset
  1566. * @param textureInfo The glTF texture info property
  1567. * @param assign A function called synchronously after parsing the glTF properties
  1568. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1569. */
  1570. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1571. private _loadTextureAsync;
  1572. private _loadSampler;
  1573. /**
  1574. * Loads a glTF image.
  1575. * @param context The context when loading the asset
  1576. * @param image The glTF image property
  1577. * @returns A promise that resolves with the loaded data when the load is complete
  1578. */
  1579. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1580. /**
  1581. * Loads a glTF uri.
  1582. * @param context The context when loading the asset
  1583. * @param property The glTF property associated with the uri
  1584. * @param uri The base64 or relative uri
  1585. * @returns A promise that resolves with the loaded data when the load is complete
  1586. */
  1587. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  1588. private _onProgress;
  1589. /**
  1590. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1591. * @param babylonObject the Babylon object with metadata
  1592. * @param pointer the JSON pointer
  1593. */
  1594. static AddPointerMetadata(babylonObject: {
  1595. metadata: any;
  1596. }, pointer: string): void;
  1597. private static _GetTextureWrapMode;
  1598. private static _GetTextureSamplingMode;
  1599. private static _GetTypedArrayConstructor;
  1600. private static _GetTypedArray;
  1601. private static _GetNumComponents;
  1602. private static _ValidateUri;
  1603. private static _GetDrawMode;
  1604. private _compileMaterialsAsync;
  1605. private _compileShadowGeneratorsAsync;
  1606. private _forEachExtensions;
  1607. private _applyExtensions;
  1608. private _extensionsOnLoading;
  1609. private _extensionsOnReady;
  1610. private _extensionsLoadSceneAsync;
  1611. private _extensionsLoadNodeAsync;
  1612. private _extensionsLoadCameraAsync;
  1613. private _extensionsLoadVertexDataAsync;
  1614. private _extensionsLoadMeshPrimitiveAsync;
  1615. private _extensionsLoadMaterialAsync;
  1616. private _extensionsCreateMaterial;
  1617. private _extensionsLoadMaterialPropertiesAsync;
  1618. private _extensionsLoadTextureInfoAsync;
  1619. private _extensionsLoadAnimationAsync;
  1620. private _extensionsLoadSkinAsync;
  1621. private _extensionsLoadUriAsync;
  1622. private _extensionsLoadBufferViewAsync;
  1623. private _extensionsLoadBufferAsync;
  1624. /**
  1625. * Helper method called by a loader extension to load an glTF extension.
  1626. * @param context The context when loading the asset
  1627. * @param property The glTF property to load the extension from
  1628. * @param extensionName The name of the extension to load
  1629. * @param actionAsync The action to run
  1630. * @returns The promise returned by actionAsync or null if the extension does not exist
  1631. */
  1632. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1633. /**
  1634. * Helper method called by a loader extension to load a glTF extra.
  1635. * @param context The context when loading the asset
  1636. * @param property The glTF property to load the extra from
  1637. * @param extensionName The name of the extension to load
  1638. * @param actionAsync The action to run
  1639. * @returns The promise returned by actionAsync or null if the extra does not exist
  1640. */
  1641. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1642. /**
  1643. * Checks for presence of an extension.
  1644. * @param name The name of the extension to check
  1645. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  1646. */
  1647. isExtensionUsed(name: string): boolean;
  1648. /**
  1649. * Increments the indentation level and logs a message.
  1650. * @param message The message to log
  1651. */
  1652. logOpen(message: string): void;
  1653. /**
  1654. * Decrements the indentation level.
  1655. */
  1656. logClose(): void;
  1657. /**
  1658. * Logs a message
  1659. * @param message The message to log
  1660. */
  1661. log(message: string): void;
  1662. /**
  1663. * Starts a performance counter.
  1664. * @param counterName The name of the performance counter
  1665. */
  1666. startPerformanceCounter(counterName: string): void;
  1667. /**
  1668. * Ends a performance counter.
  1669. * @param counterName The name of the performance counter
  1670. */
  1671. endPerformanceCounter(counterName: string): void;
  1672. }
  1673. }
  1674. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based" {
  1675. import { Nullable } from "babylonjs/types";
  1676. import { IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1677. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1678. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1679. /**
  1680. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  1681. */
  1682. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1683. /**
  1684. * The name of this extension.
  1685. */
  1686. readonly name: string;
  1687. /**
  1688. * Defines whether this extension is enabled.
  1689. */
  1690. enabled: boolean;
  1691. private _loader;
  1692. private _lights?;
  1693. /** @hidden */
  1694. constructor(loader: GLTFLoader);
  1695. /** @hidden */
  1696. dispose(): void;
  1697. /** @hidden */
  1698. onLoading(): void;
  1699. /** @hidden */
  1700. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1701. private _loadLightAsync;
  1702. }
  1703. }
  1704. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression" {
  1705. import { DracoCompression } from "babylonjs/Meshes/Compression/dracoCompression";
  1706. import { Nullable } from "babylonjs/types";
  1707. import { Geometry } from "babylonjs/Meshes/geometry";
  1708. import { Mesh } from "babylonjs/Meshes/mesh";
  1709. import { IMeshPrimitive } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1710. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1711. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1712. /**
  1713. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1714. */
  1715. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1716. /**
  1717. * The name of this extension.
  1718. */
  1719. readonly name: string;
  1720. /**
  1721. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  1722. */
  1723. dracoCompression?: DracoCompression;
  1724. /**
  1725. * Defines whether this extension is enabled.
  1726. */
  1727. enabled: boolean;
  1728. private _loader;
  1729. /** @hidden */
  1730. constructor(loader: GLTFLoader);
  1731. /** @hidden */
  1732. dispose(): void;
  1733. /** @hidden */
  1734. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1735. }
  1736. }
  1737. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual" {
  1738. import { Nullable } from "babylonjs/types";
  1739. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1740. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1741. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1742. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1743. /**
  1744. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  1745. */
  1746. export class KHR_lights implements IGLTFLoaderExtension {
  1747. /**
  1748. * The name of this extension.
  1749. */
  1750. readonly name: string;
  1751. /**
  1752. * Defines whether this extension is enabled.
  1753. */
  1754. enabled: boolean;
  1755. private _loader;
  1756. private _lights?;
  1757. /** @hidden */
  1758. constructor(loader: GLTFLoader);
  1759. /** @hidden */
  1760. dispose(): void;
  1761. /** @hidden */
  1762. onLoading(): void;
  1763. /** @hidden */
  1764. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1765. }
  1766. }
  1767. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness" {
  1768. import { Nullable } from "babylonjs/types";
  1769. import { Material } from "babylonjs/Materials/material";
  1770. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1771. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1772. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1773. /**
  1774. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1775. */
  1776. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1777. /**
  1778. * The name of this extension.
  1779. */
  1780. readonly name: string;
  1781. /**
  1782. * Defines whether this extension is enabled.
  1783. */
  1784. enabled: boolean;
  1785. /**
  1786. * Defines a number that determines the order the extensions are applied.
  1787. */
  1788. order: number;
  1789. private _loader;
  1790. /** @hidden */
  1791. constructor(loader: GLTFLoader);
  1792. /** @hidden */
  1793. dispose(): void;
  1794. /** @hidden */
  1795. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1796. private _loadSpecularGlossinessPropertiesAsync;
  1797. }
  1798. }
  1799. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit" {
  1800. import { Nullable } from "babylonjs/types";
  1801. import { Material } from "babylonjs/Materials/material";
  1802. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1803. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1804. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1805. /**
  1806. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1807. */
  1808. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1809. /**
  1810. * The name of this extension.
  1811. */
  1812. readonly name: string;
  1813. /**
  1814. * Defines whether this extension is enabled.
  1815. */
  1816. enabled: boolean;
  1817. /**
  1818. * Defines a number that determines the order the extensions are applied.
  1819. */
  1820. order: number;
  1821. private _loader;
  1822. /** @hidden */
  1823. constructor(loader: GLTFLoader);
  1824. /** @hidden */
  1825. dispose(): void;
  1826. /** @hidden */
  1827. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1828. private _loadUnlitPropertiesAsync;
  1829. }
  1830. }
  1831. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform" {
  1832. import { Nullable } from "babylonjs/types";
  1833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1834. import { ITextureInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1835. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1836. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1837. /**
  1838. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1839. */
  1840. export class KHR_texture_transform implements IGLTFLoaderExtension {
  1841. /**
  1842. * The name of this extension.
  1843. */
  1844. readonly name: string;
  1845. /**
  1846. * Defines whether this extension is enabled.
  1847. */
  1848. enabled: boolean;
  1849. private _loader;
  1850. /** @hidden */
  1851. constructor(loader: GLTFLoader);
  1852. /** @hidden */
  1853. dispose(): void;
  1854. /** @hidden */
  1855. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1856. }
  1857. }
  1858. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter" {
  1859. import { Nullable } from "babylonjs/types";
  1860. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1862. import { IScene, INode, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1863. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1864. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1865. /**
  1866. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1867. */
  1868. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1869. /**
  1870. * The name of this extension.
  1871. */
  1872. readonly name: string;
  1873. /**
  1874. * Defines whether this extension is enabled.
  1875. */
  1876. enabled: boolean;
  1877. private _loader;
  1878. private _clips;
  1879. private _emitters;
  1880. /** @hidden */
  1881. constructor(loader: GLTFLoader);
  1882. /** @hidden */
  1883. dispose(): void;
  1884. /** @hidden */
  1885. onLoading(): void;
  1886. /** @hidden */
  1887. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1888. /** @hidden */
  1889. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1890. /** @hidden */
  1891. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1892. private _loadClipAsync;
  1893. private _loadEmitterAsync;
  1894. private _getEventAction;
  1895. private _loadAnimationEventAsync;
  1896. }
  1897. }
  1898. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
  1899. import { Nullable } from "babylonjs/types";
  1900. import { Observable } from "babylonjs/Misc/observable";
  1901. import { Material } from "babylonjs/Materials/material";
  1902. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1903. import { Mesh } from "babylonjs/Meshes/mesh";
  1904. import { INode, IMaterial, IBuffer } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1905. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1906. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1907. import { IProperty } from 'babylonjs-gltf2interface';
  1908. /**
  1909. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1910. */
  1911. export class MSFT_lod implements IGLTFLoaderExtension {
  1912. /**
  1913. * The name of this extension.
  1914. */
  1915. readonly name: string;
  1916. /**
  1917. * Defines whether this extension is enabled.
  1918. */
  1919. enabled: boolean;
  1920. /**
  1921. * Defines a number that determines the order the extensions are applied.
  1922. */
  1923. order: number;
  1924. /**
  1925. * Maximum number of LODs to load, starting from the lowest LOD.
  1926. */
  1927. maxLODsToLoad: number;
  1928. /**
  1929. * Observable raised when all node LODs of one level are loaded.
  1930. * The event data is the index of the loaded LOD starting from zero.
  1931. * Dispose the loader to cancel the loading of the next level of LODs.
  1932. */
  1933. onNodeLODsLoadedObservable: Observable<number>;
  1934. /**
  1935. * Observable raised when all material LODs of one level are loaded.
  1936. * The event data is the index of the loaded LOD starting from zero.
  1937. * Dispose the loader to cancel the loading of the next level of LODs.
  1938. */
  1939. onMaterialLODsLoadedObservable: Observable<number>;
  1940. private _loader;
  1941. private _nodeIndexLOD;
  1942. private _nodeSignalLODs;
  1943. private _nodePromiseLODs;
  1944. private _materialIndexLOD;
  1945. private _materialSignalLODs;
  1946. private _materialPromiseLODs;
  1947. private _indexLOD;
  1948. private _bufferLODs;
  1949. /** @hidden */
  1950. constructor(loader: GLTFLoader);
  1951. /** @hidden */
  1952. dispose(): void;
  1953. /** @hidden */
  1954. onReady(): void;
  1955. /** @hidden */
  1956. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1957. /** @hidden */
  1958. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1959. /** @hidden */
  1960. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1961. /** @hidden */
  1962. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  1963. private _loadBufferLOD;
  1964. /**
  1965. * Gets an array of LOD properties from lowest to highest.
  1966. */
  1967. private _getLODs;
  1968. private _disposeUnusedMaterials;
  1969. }
  1970. }
  1971. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh" {
  1972. import { Nullable } from "babylonjs/types";
  1973. import { Material } from "babylonjs/Materials/material";
  1974. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1975. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1976. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1977. /** @hidden */
  1978. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1979. readonly name: string;
  1980. enabled: boolean;
  1981. private _loader;
  1982. constructor(loader: GLTFLoader);
  1983. dispose(): void;
  1984. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1985. }
  1986. }
  1987. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors" {
  1988. import { Nullable } from "babylonjs/types";
  1989. import { Material } from "babylonjs/Materials/material";
  1990. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1991. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1992. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1993. /** @hidden */
  1994. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1995. readonly name: string;
  1996. enabled: boolean;
  1997. private _loader;
  1998. constructor(loader: GLTFLoader);
  1999. dispose(): void;
  2000. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2001. }
  2002. }
  2003. declare module "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata" {
  2004. import { Nullable } from "babylonjs/types";
  2005. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2006. import { Camera } from "babylonjs/Cameras/camera";
  2007. import { INode, ICamera, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2008. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2009. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2010. import { Material } from "babylonjs/Materials/material";
  2011. /**
  2012. * Store glTF extras (if present) in BJS objects' metadata
  2013. */
  2014. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  2015. /**
  2016. * The name of this extension.
  2017. */
  2018. readonly name: string;
  2019. /**
  2020. * Defines whether this extension is enabled.
  2021. */
  2022. enabled: boolean;
  2023. private _loader;
  2024. private _assignExtras;
  2025. /** @hidden */
  2026. constructor(loader: GLTFLoader);
  2027. /** @hidden */
  2028. dispose(): void;
  2029. /** @hidden */
  2030. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2031. /** @hidden */
  2032. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  2033. /** @hidden */
  2034. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  2035. }
  2036. }
  2037. declare module "babylonjs-loaders/glTF/2.0/Extensions/index" {
  2038. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based";
  2039. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  2040. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual";
  2041. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  2042. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit";
  2043. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform";
  2044. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter";
  2045. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod";
  2046. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh";
  2047. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors";
  2048. export * from "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata";
  2049. }
  2050. declare module "babylonjs-loaders/glTF/2.0/index" {
  2051. export * from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2052. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2053. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2054. export * from "babylonjs-loaders/glTF/2.0/Extensions/index";
  2055. }
  2056. declare module "babylonjs-loaders/glTF/index" {
  2057. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2058. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2059. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2060. export { GLTF1, GLTF2 };
  2061. }
  2062. declare module "babylonjs-loaders/OBJ/objFileLoader" {
  2063. import { Vector2 } from "babylonjs/Maths/math";
  2064. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  2065. import { Skeleton } from "babylonjs/Bones/skeleton";
  2066. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2067. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  2068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2069. import { ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin } from "babylonjs/Loading/sceneLoader";
  2070. import { AssetContainer } from "babylonjs/assetContainer";
  2071. import { Scene } from "babylonjs/scene";
  2072. /**
  2073. * Class reading and parsing the MTL file bundled with the obj file.
  2074. */
  2075. export class MTLFileLoader {
  2076. /**
  2077. * All material loaded from the mtl will be set here
  2078. */
  2079. materials: StandardMaterial[];
  2080. /**
  2081. * This function will read the mtl file and create each material described inside
  2082. * This function could be improve by adding :
  2083. * -some component missing (Ni, Tf...)
  2084. * -including the specific options available
  2085. *
  2086. * @param scene defines the scene the material will be created in
  2087. * @param data defines the mtl data to parse
  2088. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  2089. */
  2090. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  2091. /**
  2092. * Gets the texture for the material.
  2093. *
  2094. * If the material is imported from input file,
  2095. * We sanitize the url to ensure it takes the textre from aside the material.
  2096. *
  2097. * @param rootUrl The root url to load from
  2098. * @param value The value stored in the mtl
  2099. * @return The Texture
  2100. */
  2101. private static _getTexture;
  2102. }
  2103. /**
  2104. * Options for loading OBJ/MTL files
  2105. */
  2106. type MeshLoadOptions = {
  2107. /**
  2108. * Defines if UVs are optimized by default during load.
  2109. */
  2110. OptimizeWithUV: boolean;
  2111. /**
  2112. * Defines custom scaling of UV coordinates of loaded meshes.
  2113. */
  2114. UVScaling: Vector2;
  2115. /**
  2116. * Invert model on y-axis (does a model scaling inversion)
  2117. */
  2118. InvertY: boolean;
  2119. /**
  2120. * Invert Y-Axis of referenced textures on load
  2121. */
  2122. InvertTextureY: boolean;
  2123. /**
  2124. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2125. */
  2126. ImportVertexColors: boolean;
  2127. /**
  2128. * Compute the normals for the model, even if normals are present in the file.
  2129. */
  2130. ComputeNormals: boolean;
  2131. /**
  2132. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2133. */
  2134. SkipMaterials: boolean;
  2135. /**
  2136. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2137. */
  2138. MaterialLoadingFailsSilently: boolean;
  2139. };
  2140. /**
  2141. * OBJ file type loader.
  2142. * This is a babylon scene loader plugin.
  2143. */
  2144. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2145. /**
  2146. * Defines if UVs are optimized by default during load.
  2147. */
  2148. static OPTIMIZE_WITH_UV: boolean;
  2149. /**
  2150. * Invert model on y-axis (does a model scaling inversion)
  2151. */
  2152. static INVERT_Y: boolean;
  2153. /**
  2154. * Invert Y-Axis of referenced textures on load
  2155. */
  2156. static INVERT_TEXTURE_Y: boolean;
  2157. /**
  2158. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2159. */
  2160. static IMPORT_VERTEX_COLORS: boolean;
  2161. /**
  2162. * Compute the normals for the model, even if normals are present in the file.
  2163. */
  2164. static COMPUTE_NORMALS: boolean;
  2165. /**
  2166. * Defines custom scaling of UV coordinates of loaded meshes.
  2167. */
  2168. static UV_SCALING: Vector2;
  2169. /**
  2170. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2171. */
  2172. static SKIP_MATERIALS: boolean;
  2173. /**
  2174. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2175. *
  2176. * Defaults to true for backwards compatibility.
  2177. */
  2178. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2179. /**
  2180. * Defines the name of the plugin.
  2181. */
  2182. name: string;
  2183. /**
  2184. * Defines the extension the plugin is able to load.
  2185. */
  2186. extensions: string;
  2187. /** @hidden */
  2188. obj: RegExp;
  2189. /** @hidden */
  2190. group: RegExp;
  2191. /** @hidden */
  2192. mtllib: RegExp;
  2193. /** @hidden */
  2194. usemtl: RegExp;
  2195. /** @hidden */
  2196. smooth: RegExp;
  2197. /** @hidden */
  2198. vertexPattern: RegExp;
  2199. /** @hidden */
  2200. normalPattern: RegExp;
  2201. /** @hidden */
  2202. uvPattern: RegExp;
  2203. /** @hidden */
  2204. facePattern1: RegExp;
  2205. /** @hidden */
  2206. facePattern2: RegExp;
  2207. /** @hidden */
  2208. facePattern3: RegExp;
  2209. /** @hidden */
  2210. facePattern4: RegExp;
  2211. /** @hidden */
  2212. facePattern5: RegExp;
  2213. private _meshLoadOptions;
  2214. /**
  2215. * Creates loader for .OBJ files
  2216. *
  2217. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2218. */
  2219. constructor(meshLoadOptions?: MeshLoadOptions);
  2220. private static readonly currentMeshLoadOptions;
  2221. /**
  2222. * Calls synchronously the MTL file attached to this obj.
  2223. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2224. * Without this function materials are not displayed in the first frame (but displayed after).
  2225. * In consequence it is impossible to get material information in your HTML file
  2226. *
  2227. * @param url The URL of the MTL file
  2228. * @param rootUrl
  2229. * @param onSuccess Callback function to be called when the MTL file is loaded
  2230. * @private
  2231. */
  2232. private _loadMTL;
  2233. /**
  2234. * Instantiates a OBJ file loader plugin.
  2235. * @returns the created plugin
  2236. */
  2237. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2238. /**
  2239. * If the data string can be loaded directly.
  2240. *
  2241. * @param data string containing the file data
  2242. * @returns if the data can be loaded directly
  2243. */
  2244. canDirectLoad(data: string): boolean;
  2245. /**
  2246. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2247. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2248. * @param scene the scene the meshes should be added to
  2249. * @param data the OBJ data to load
  2250. * @param rootUrl root url to load from
  2251. * @param onProgress event that fires when loading progress has occured
  2252. * @param fileName Defines the name of the file to load
  2253. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2254. */
  2255. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2256. meshes: AbstractMesh[];
  2257. particleSystems: IParticleSystem[];
  2258. skeletons: Skeleton[];
  2259. animationGroups: AnimationGroup[];
  2260. }>;
  2261. /**
  2262. * Imports all objects from the loaded OBJ data and adds them to the scene
  2263. * @param scene the scene the objects should be added to
  2264. * @param data the OBJ data to load
  2265. * @param rootUrl root url to load from
  2266. * @param onProgress event that fires when loading progress has occured
  2267. * @param fileName Defines the name of the file to load
  2268. * @returns a promise which completes when objects have been loaded to the scene
  2269. */
  2270. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2271. /**
  2272. * Load into an asset container.
  2273. * @param scene The scene to load into
  2274. * @param data The data to import
  2275. * @param rootUrl The root url for scene and resources
  2276. * @param onProgress The callback when the load progresses
  2277. * @param fileName Defines the name of the file to load
  2278. * @returns The loaded asset container
  2279. */
  2280. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2281. /**
  2282. * Read the OBJ file and create an Array of meshes.
  2283. * Each mesh contains all information given by the OBJ and the MTL file.
  2284. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2285. *
  2286. * @param meshesNames
  2287. * @param scene Scene The scene where are displayed the data
  2288. * @param data String The content of the obj file
  2289. * @param rootUrl String The path to the folder
  2290. * @returns Array<AbstractMesh>
  2291. * @private
  2292. */
  2293. private _parseSolid;
  2294. }
  2295. }
  2296. declare module "babylonjs-loaders/OBJ/index" {
  2297. export * from "babylonjs-loaders/OBJ/objFileLoader";
  2298. }
  2299. declare module "babylonjs-loaders/STL/stlFileLoader" {
  2300. import { Nullable } from "babylonjs/types";
  2301. import { Skeleton } from "babylonjs/Bones/skeleton";
  2302. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2304. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  2305. import { AssetContainer } from "babylonjs/assetContainer";
  2306. import { Scene } from "babylonjs/scene";
  2307. /**
  2308. * STL file type loader.
  2309. * This is a babylon scene loader plugin.
  2310. */
  2311. export class STLFileLoader implements ISceneLoaderPlugin {
  2312. /** @hidden */
  2313. solidPattern: RegExp;
  2314. /** @hidden */
  2315. facetsPattern: RegExp;
  2316. /** @hidden */
  2317. normalPattern: RegExp;
  2318. /** @hidden */
  2319. vertexPattern: RegExp;
  2320. /**
  2321. * Defines the name of the plugin.
  2322. */
  2323. name: string;
  2324. /**
  2325. * Defines the extensions the stl loader is able to load.
  2326. * force data to come in as an ArrayBuffer
  2327. * we'll convert to string if it looks like it's an ASCII .stl
  2328. */
  2329. extensions: ISceneLoaderPluginExtensions;
  2330. /**
  2331. * Import meshes into a scene.
  2332. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2333. * @param scene The scene to import into
  2334. * @param data The data to import
  2335. * @param rootUrl The root url for scene and resources
  2336. * @param meshes The meshes array to import into
  2337. * @param particleSystems The particle systems array to import into
  2338. * @param skeletons The skeletons array to import into
  2339. * @param onError The callback when import fails
  2340. * @returns True if successful or false otherwise
  2341. */
  2342. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2343. /**
  2344. * Load into a scene.
  2345. * @param scene The scene to load into
  2346. * @param data The data to import
  2347. * @param rootUrl The root url for scene and resources
  2348. * @param onError The callback when import fails
  2349. * @returns true if successful or false otherwise
  2350. */
  2351. load(scene: Scene, data: any, rootUrl: string): boolean;
  2352. /**
  2353. * Load into an asset container.
  2354. * @param scene The scene to load into
  2355. * @param data The data to import
  2356. * @param rootUrl The root url for scene and resources
  2357. * @param onError The callback when import fails
  2358. * @returns The loaded asset container
  2359. */
  2360. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2361. private _isBinary;
  2362. private _parseBinary;
  2363. private _parseASCII;
  2364. }
  2365. }
  2366. declare module "babylonjs-loaders/STL/index" {
  2367. export * from "babylonjs-loaders/STL/stlFileLoader";
  2368. }
  2369. declare module "babylonjs-loaders/index" {
  2370. export * from "babylonjs-loaders/glTF/index";
  2371. export * from "babylonjs-loaders/OBJ/index";
  2372. export * from "babylonjs-loaders/STL/index";
  2373. }
  2374. declare module "babylonjs-loaders/legacy/legacy-glTF" {
  2375. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2376. }
  2377. declare module "babylonjs-loaders/legacy/legacy-glTF1" {
  2378. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2379. export { GLTF1 };
  2380. }
  2381. declare module "babylonjs-loaders/legacy/legacy-glTF1FileLoader" {
  2382. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2383. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2384. }
  2385. declare module "babylonjs-loaders/legacy/legacy-glTF2" {
  2386. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2387. export { GLTF2 };
  2388. }
  2389. declare module "babylonjs-loaders/legacy/legacy-glTF2FileLoader" {
  2390. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2391. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2392. }
  2393. declare module "babylonjs-loaders/legacy/legacy-glTFFileLoader" {
  2394. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2395. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2396. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2397. }
  2398. declare module "babylonjs-loaders/legacy/legacy-objFileLoader" {
  2399. export * from "babylonjs-loaders/OBJ/index";
  2400. }
  2401. declare module "babylonjs-loaders/legacy/legacy-stlFileLoader" {
  2402. export * from "babylonjs-loaders/STL/index";
  2403. }
  2404. declare module "babylonjs-loaders/legacy/legacy" {
  2405. import "babylonjs-loaders/index";
  2406. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2407. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2408. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2409. export * from "babylonjs-loaders/legacy/legacy-objFileLoader";
  2410. export * from "babylonjs-loaders/legacy/legacy-stlFileLoader";
  2411. }
  2412. declare module "babylonjs-loaders" {
  2413. export * from "babylonjs-loaders/legacy/legacy";
  2414. }
  2415. declare module BABYLON {
  2416. /**
  2417. * Mode that determines the coordinate system to use.
  2418. */
  2419. export enum GLTFLoaderCoordinateSystemMode {
  2420. /**
  2421. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2422. */
  2423. AUTO = 0,
  2424. /**
  2425. * Sets the useRightHandedSystem flag on the scene.
  2426. */
  2427. FORCE_RIGHT_HANDED = 1
  2428. }
  2429. /**
  2430. * Mode that determines what animations will start.
  2431. */
  2432. export enum GLTFLoaderAnimationStartMode {
  2433. /**
  2434. * No animation will start.
  2435. */
  2436. NONE = 0,
  2437. /**
  2438. * The first animation will start.
  2439. */
  2440. FIRST = 1,
  2441. /**
  2442. * All animations will start.
  2443. */
  2444. ALL = 2
  2445. }
  2446. /**
  2447. * Interface that contains the data for the glTF asset.
  2448. */
  2449. export interface IGLTFLoaderData {
  2450. /**
  2451. * The object that represents the glTF JSON.
  2452. */
  2453. json: Object;
  2454. /**
  2455. * The BIN chunk of a binary glTF.
  2456. */
  2457. bin: Nullable<IDataBuffer>;
  2458. }
  2459. /**
  2460. * Interface for extending the loader.
  2461. */
  2462. export interface IGLTFLoaderExtension {
  2463. /**
  2464. * The name of this extension.
  2465. */
  2466. readonly name: string;
  2467. /**
  2468. * Defines whether this extension is enabled.
  2469. */
  2470. enabled: boolean;
  2471. /**
  2472. * Defines the order of this extension.
  2473. * The loader sorts the extensions using these values when loading.
  2474. */
  2475. order?: number;
  2476. }
  2477. /**
  2478. * Loader state.
  2479. */
  2480. export enum GLTFLoaderState {
  2481. /**
  2482. * The asset is loading.
  2483. */
  2484. LOADING = 0,
  2485. /**
  2486. * The asset is ready for rendering.
  2487. */
  2488. READY = 1,
  2489. /**
  2490. * The asset is completely loaded.
  2491. */
  2492. COMPLETE = 2
  2493. }
  2494. /** @hidden */
  2495. export interface IGLTFLoader extends IDisposable {
  2496. readonly state: Nullable<GLTFLoaderState>;
  2497. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  2498. meshes: AbstractMesh[];
  2499. particleSystems: IParticleSystem[];
  2500. skeletons: Skeleton[];
  2501. animationGroups: AnimationGroup[];
  2502. }>;
  2503. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  2504. }
  2505. /**
  2506. * File loader for loading glTF files into a scene.
  2507. */
  2508. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2509. /** @hidden */
  2510. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2511. /** @hidden */
  2512. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2513. /**
  2514. * Raised when the asset has been parsed
  2515. */
  2516. onParsedObservable: Observable<IGLTFLoaderData>;
  2517. private _onParsedObserver;
  2518. /**
  2519. * Raised when the asset has been parsed
  2520. */
  2521. onParsed: (loaderData: IGLTFLoaderData) => void;
  2522. /**
  2523. * 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.
  2524. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  2525. * Defaults to true.
  2526. * @hidden
  2527. */
  2528. static IncrementalLoading: boolean;
  2529. /**
  2530. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  2531. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  2532. * @hidden
  2533. */
  2534. static HomogeneousCoordinates: boolean;
  2535. /**
  2536. * The coordinate system mode. Defaults to AUTO.
  2537. */
  2538. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  2539. /**
  2540. * The animation start mode. Defaults to FIRST.
  2541. */
  2542. animationStartMode: GLTFLoaderAnimationStartMode;
  2543. /**
  2544. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  2545. */
  2546. compileMaterials: boolean;
  2547. /**
  2548. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  2549. */
  2550. useClipPlane: boolean;
  2551. /**
  2552. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  2553. */
  2554. compileShadowGenerators: boolean;
  2555. /**
  2556. * Defines if the Alpha blended materials are only applied as coverage.
  2557. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  2558. * If true, no extra effects are applied to transparent pixels.
  2559. */
  2560. transparencyAsCoverage: boolean;
  2561. /**
  2562. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  2563. * Enabling will disable offline support and glTF validator.
  2564. * Defaults to false.
  2565. */
  2566. useRangeRequests: boolean;
  2567. /**
  2568. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  2569. */
  2570. createInstances: boolean;
  2571. /**
  2572. * Function called before loading a url referenced by the asset.
  2573. */
  2574. preprocessUrlAsync: (url: string) => Promise<string>;
  2575. /**
  2576. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2577. */
  2578. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  2579. private _onMeshLoadedObserver;
  2580. /**
  2581. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2582. */
  2583. onMeshLoaded: (mesh: AbstractMesh) => void;
  2584. /**
  2585. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  2586. */
  2587. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  2588. private _onTextureLoadedObserver;
  2589. /**
  2590. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  2591. */
  2592. onTextureLoaded: (texture: BaseTexture) => void;
  2593. /**
  2594. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  2595. */
  2596. readonly onMaterialLoadedObservable: Observable<Material>;
  2597. private _onMaterialLoadedObserver;
  2598. /**
  2599. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  2600. */
  2601. onMaterialLoaded: (material: Material) => void;
  2602. /**
  2603. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  2604. */
  2605. readonly onCameraLoadedObservable: Observable<Camera>;
  2606. private _onCameraLoadedObserver;
  2607. /**
  2608. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  2609. */
  2610. onCameraLoaded: (camera: Camera) => void;
  2611. /**
  2612. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  2613. * For assets with LODs, raised when all of the LODs are complete.
  2614. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2615. */
  2616. readonly onCompleteObservable: Observable<void>;
  2617. private _onCompleteObserver;
  2618. /**
  2619. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  2620. * For assets with LODs, raised when all of the LODs are complete.
  2621. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2622. */
  2623. onComplete: () => void;
  2624. /**
  2625. * Observable raised when an error occurs.
  2626. */
  2627. readonly onErrorObservable: Observable<any>;
  2628. private _onErrorObserver;
  2629. /**
  2630. * Callback raised when an error occurs.
  2631. */
  2632. onError: (reason: any) => void;
  2633. /**
  2634. * Observable raised after the loader is disposed.
  2635. */
  2636. readonly onDisposeObservable: Observable<void>;
  2637. private _onDisposeObserver;
  2638. /**
  2639. * Callback raised after the loader is disposed.
  2640. */
  2641. onDispose: () => void;
  2642. /**
  2643. * Observable raised after a loader extension is created.
  2644. * Set additional options for a loader extension in this event.
  2645. */
  2646. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  2647. private _onExtensionLoadedObserver;
  2648. /**
  2649. * Callback raised after a loader extension is created.
  2650. */
  2651. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  2652. /**
  2653. * Defines if the loader logging is enabled.
  2654. */
  2655. loggingEnabled: boolean;
  2656. /**
  2657. * Defines if the loader should capture performance counters.
  2658. */
  2659. capturePerformanceCounters: boolean;
  2660. /**
  2661. * Defines if the loader should validate the asset.
  2662. */
  2663. validate: boolean;
  2664. /**
  2665. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  2666. */
  2667. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  2668. private _onValidatedObserver;
  2669. /**
  2670. * Callback raised after a loader extension is created.
  2671. */
  2672. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  2673. private _loader;
  2674. /**
  2675. * Name of the loader ("gltf")
  2676. */
  2677. name: string;
  2678. /** @hidden */
  2679. extensions: ISceneLoaderPluginExtensions;
  2680. /**
  2681. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  2682. */
  2683. dispose(): void;
  2684. /** @hidden */
  2685. _clear(): void;
  2686. /** @hidden */
  2687. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  2688. /** @hidden */
  2689. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  2690. /** @hidden */
  2691. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2692. meshes: AbstractMesh[];
  2693. particleSystems: IParticleSystem[];
  2694. skeletons: Skeleton[];
  2695. animationGroups: AnimationGroup[];
  2696. }>;
  2697. /** @hidden */
  2698. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2699. /** @hidden */
  2700. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2701. /** @hidden */
  2702. canDirectLoad(data: string): boolean;
  2703. /** @hidden */
  2704. directLoad(scene: Scene, data: string): any;
  2705. /**
  2706. * The callback that allows custom handling of the root url based on the response url.
  2707. * @param rootUrl the original root url
  2708. * @param responseURL the response url if available
  2709. * @returns the new root url
  2710. */
  2711. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  2712. /** @hidden */
  2713. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  2714. /**
  2715. * The loader state or null if the loader is not active.
  2716. */
  2717. readonly loaderState: Nullable<GLTFLoaderState>;
  2718. /**
  2719. * Returns a promise that resolves when the asset is completely loaded.
  2720. * @returns a promise that resolves when the asset is completely loaded.
  2721. */
  2722. whenCompleteAsync(): Promise<void>;
  2723. private _validateAsync;
  2724. private _getLoader;
  2725. private _parseJson;
  2726. private _unpackBinaryAsync;
  2727. private _unpackBinaryV1Async;
  2728. private _unpackBinaryV2Async;
  2729. private static _parseVersion;
  2730. private static _compareVersion;
  2731. private static readonly _logSpaces;
  2732. private _logIndentLevel;
  2733. private _loggingEnabled;
  2734. /** @hidden */
  2735. _log: (message: string) => void;
  2736. /** @hidden */
  2737. _logOpen(message: string): void;
  2738. /** @hidden */
  2739. _logClose(): void;
  2740. private _logEnabled;
  2741. private _logDisabled;
  2742. private _capturePerformanceCounters;
  2743. /** @hidden */
  2744. _startPerformanceCounter: (counterName: string) => void;
  2745. /** @hidden */
  2746. _endPerformanceCounter: (counterName: string) => void;
  2747. private _startPerformanceCounterEnabled;
  2748. private _startPerformanceCounterDisabled;
  2749. private _endPerformanceCounterEnabled;
  2750. private _endPerformanceCounterDisabled;
  2751. }
  2752. }
  2753. declare module BABYLON.GLTF1 {
  2754. /**
  2755. * Enums
  2756. * @hidden
  2757. */
  2758. export enum EComponentType {
  2759. BYTE = 5120,
  2760. UNSIGNED_BYTE = 5121,
  2761. SHORT = 5122,
  2762. UNSIGNED_SHORT = 5123,
  2763. FLOAT = 5126
  2764. }
  2765. /** @hidden */
  2766. export enum EShaderType {
  2767. FRAGMENT = 35632,
  2768. VERTEX = 35633
  2769. }
  2770. /** @hidden */
  2771. export enum EParameterType {
  2772. BYTE = 5120,
  2773. UNSIGNED_BYTE = 5121,
  2774. SHORT = 5122,
  2775. UNSIGNED_SHORT = 5123,
  2776. INT = 5124,
  2777. UNSIGNED_INT = 5125,
  2778. FLOAT = 5126,
  2779. FLOAT_VEC2 = 35664,
  2780. FLOAT_VEC3 = 35665,
  2781. FLOAT_VEC4 = 35666,
  2782. INT_VEC2 = 35667,
  2783. INT_VEC3 = 35668,
  2784. INT_VEC4 = 35669,
  2785. BOOL = 35670,
  2786. BOOL_VEC2 = 35671,
  2787. BOOL_VEC3 = 35672,
  2788. BOOL_VEC4 = 35673,
  2789. FLOAT_MAT2 = 35674,
  2790. FLOAT_MAT3 = 35675,
  2791. FLOAT_MAT4 = 35676,
  2792. SAMPLER_2D = 35678
  2793. }
  2794. /** @hidden */
  2795. export enum ETextureWrapMode {
  2796. CLAMP_TO_EDGE = 33071,
  2797. MIRRORED_REPEAT = 33648,
  2798. REPEAT = 10497
  2799. }
  2800. /** @hidden */
  2801. export enum ETextureFilterType {
  2802. NEAREST = 9728,
  2803. LINEAR = 9728,
  2804. NEAREST_MIPMAP_NEAREST = 9984,
  2805. LINEAR_MIPMAP_NEAREST = 9985,
  2806. NEAREST_MIPMAP_LINEAR = 9986,
  2807. LINEAR_MIPMAP_LINEAR = 9987
  2808. }
  2809. /** @hidden */
  2810. export enum ETextureFormat {
  2811. ALPHA = 6406,
  2812. RGB = 6407,
  2813. RGBA = 6408,
  2814. LUMINANCE = 6409,
  2815. LUMINANCE_ALPHA = 6410
  2816. }
  2817. /** @hidden */
  2818. export enum ECullingType {
  2819. FRONT = 1028,
  2820. BACK = 1029,
  2821. FRONT_AND_BACK = 1032
  2822. }
  2823. /** @hidden */
  2824. export enum EBlendingFunction {
  2825. ZERO = 0,
  2826. ONE = 1,
  2827. SRC_COLOR = 768,
  2828. ONE_MINUS_SRC_COLOR = 769,
  2829. DST_COLOR = 774,
  2830. ONE_MINUS_DST_COLOR = 775,
  2831. SRC_ALPHA = 770,
  2832. ONE_MINUS_SRC_ALPHA = 771,
  2833. DST_ALPHA = 772,
  2834. ONE_MINUS_DST_ALPHA = 773,
  2835. CONSTANT_COLOR = 32769,
  2836. ONE_MINUS_CONSTANT_COLOR = 32770,
  2837. CONSTANT_ALPHA = 32771,
  2838. ONE_MINUS_CONSTANT_ALPHA = 32772,
  2839. SRC_ALPHA_SATURATE = 776
  2840. }
  2841. /** @hidden */
  2842. export interface IGLTFProperty {
  2843. extensions?: {
  2844. [key: string]: any;
  2845. };
  2846. extras?: Object;
  2847. }
  2848. /** @hidden */
  2849. export interface IGLTFChildRootProperty extends IGLTFProperty {
  2850. name?: string;
  2851. }
  2852. /** @hidden */
  2853. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  2854. bufferView: string;
  2855. byteOffset: number;
  2856. byteStride: number;
  2857. count: number;
  2858. type: string;
  2859. componentType: EComponentType;
  2860. max?: number[];
  2861. min?: number[];
  2862. name?: string;
  2863. }
  2864. /** @hidden */
  2865. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  2866. buffer: string;
  2867. byteOffset: number;
  2868. byteLength: number;
  2869. byteStride: number;
  2870. target?: number;
  2871. }
  2872. /** @hidden */
  2873. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  2874. uri: string;
  2875. byteLength?: number;
  2876. type?: string;
  2877. }
  2878. /** @hidden */
  2879. export interface IGLTFShader extends IGLTFChildRootProperty {
  2880. uri: string;
  2881. type: EShaderType;
  2882. }
  2883. /** @hidden */
  2884. export interface IGLTFProgram extends IGLTFChildRootProperty {
  2885. attributes: string[];
  2886. fragmentShader: string;
  2887. vertexShader: string;
  2888. }
  2889. /** @hidden */
  2890. export interface IGLTFTechniqueParameter {
  2891. type: number;
  2892. count?: number;
  2893. semantic?: string;
  2894. node?: string;
  2895. value?: number | boolean | string | Array<any>;
  2896. source?: string;
  2897. babylonValue?: any;
  2898. }
  2899. /** @hidden */
  2900. export interface IGLTFTechniqueCommonProfile {
  2901. lightingModel: string;
  2902. texcoordBindings: Object;
  2903. parameters?: Array<any>;
  2904. }
  2905. /** @hidden */
  2906. export interface IGLTFTechniqueStatesFunctions {
  2907. blendColor?: number[];
  2908. blendEquationSeparate?: number[];
  2909. blendFuncSeparate?: number[];
  2910. colorMask: boolean[];
  2911. cullFace: number[];
  2912. }
  2913. /** @hidden */
  2914. export interface IGLTFTechniqueStates {
  2915. enable: number[];
  2916. functions: IGLTFTechniqueStatesFunctions;
  2917. }
  2918. /** @hidden */
  2919. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  2920. parameters: {
  2921. [key: string]: IGLTFTechniqueParameter;
  2922. };
  2923. program: string;
  2924. attributes: {
  2925. [key: string]: string;
  2926. };
  2927. uniforms: {
  2928. [key: string]: string;
  2929. };
  2930. states: IGLTFTechniqueStates;
  2931. }
  2932. /** @hidden */
  2933. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  2934. technique?: string;
  2935. values: string[];
  2936. }
  2937. /** @hidden */
  2938. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  2939. attributes: {
  2940. [key: string]: string;
  2941. };
  2942. indices: string;
  2943. material: string;
  2944. mode?: number;
  2945. }
  2946. /** @hidden */
  2947. export interface IGLTFMesh extends IGLTFChildRootProperty {
  2948. primitives: IGLTFMeshPrimitive[];
  2949. }
  2950. /** @hidden */
  2951. export interface IGLTFImage extends IGLTFChildRootProperty {
  2952. uri: string;
  2953. }
  2954. /** @hidden */
  2955. export interface IGLTFSampler extends IGLTFChildRootProperty {
  2956. magFilter?: number;
  2957. minFilter?: number;
  2958. wrapS?: number;
  2959. wrapT?: number;
  2960. }
  2961. /** @hidden */
  2962. export interface IGLTFTexture extends IGLTFChildRootProperty {
  2963. sampler: string;
  2964. source: string;
  2965. format?: ETextureFormat;
  2966. internalFormat?: ETextureFormat;
  2967. target?: number;
  2968. type?: number;
  2969. babylonTexture?: Texture;
  2970. }
  2971. /** @hidden */
  2972. export interface IGLTFAmbienLight {
  2973. color?: number[];
  2974. }
  2975. /** @hidden */
  2976. export interface IGLTFDirectionalLight {
  2977. color?: number[];
  2978. }
  2979. /** @hidden */
  2980. export interface IGLTFPointLight {
  2981. color?: number[];
  2982. constantAttenuation?: number;
  2983. linearAttenuation?: number;
  2984. quadraticAttenuation?: number;
  2985. }
  2986. /** @hidden */
  2987. export interface IGLTFSpotLight {
  2988. color?: number[];
  2989. constantAttenuation?: number;
  2990. fallOfAngle?: number;
  2991. fallOffExponent?: number;
  2992. linearAttenuation?: number;
  2993. quadraticAttenuation?: number;
  2994. }
  2995. /** @hidden */
  2996. export interface IGLTFLight extends IGLTFChildRootProperty {
  2997. type: string;
  2998. }
  2999. /** @hidden */
  3000. export interface IGLTFCameraOrthographic {
  3001. xmag: number;
  3002. ymag: number;
  3003. zfar: number;
  3004. znear: number;
  3005. }
  3006. /** @hidden */
  3007. export interface IGLTFCameraPerspective {
  3008. aspectRatio: number;
  3009. yfov: number;
  3010. zfar: number;
  3011. znear: number;
  3012. }
  3013. /** @hidden */
  3014. export interface IGLTFCamera extends IGLTFChildRootProperty {
  3015. type: string;
  3016. }
  3017. /** @hidden */
  3018. export interface IGLTFAnimationChannelTarget {
  3019. id: string;
  3020. path: string;
  3021. }
  3022. /** @hidden */
  3023. export interface IGLTFAnimationChannel {
  3024. sampler: string;
  3025. target: IGLTFAnimationChannelTarget;
  3026. }
  3027. /** @hidden */
  3028. export interface IGLTFAnimationSampler {
  3029. input: string;
  3030. output: string;
  3031. interpolation?: string;
  3032. }
  3033. /** @hidden */
  3034. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  3035. channels?: IGLTFAnimationChannel[];
  3036. parameters?: {
  3037. [key: string]: string;
  3038. };
  3039. samplers?: {
  3040. [key: string]: IGLTFAnimationSampler;
  3041. };
  3042. }
  3043. /** @hidden */
  3044. export interface IGLTFNodeInstanceSkin {
  3045. skeletons: string[];
  3046. skin: string;
  3047. meshes: string[];
  3048. }
  3049. /** @hidden */
  3050. export interface IGLTFSkins extends IGLTFChildRootProperty {
  3051. bindShapeMatrix: number[];
  3052. inverseBindMatrices: string;
  3053. jointNames: string[];
  3054. babylonSkeleton?: Skeleton;
  3055. }
  3056. /** @hidden */
  3057. export interface IGLTFNode extends IGLTFChildRootProperty {
  3058. camera?: string;
  3059. children: string[];
  3060. skin?: string;
  3061. jointName?: string;
  3062. light?: string;
  3063. matrix: number[];
  3064. mesh?: string;
  3065. meshes?: string[];
  3066. rotation?: number[];
  3067. scale?: number[];
  3068. translation?: number[];
  3069. babylonNode?: Node;
  3070. }
  3071. /** @hidden */
  3072. export interface IGLTFScene extends IGLTFChildRootProperty {
  3073. nodes: string[];
  3074. }
  3075. /** @hidden */
  3076. export interface IGLTFRuntime {
  3077. extensions: {
  3078. [key: string]: any;
  3079. };
  3080. accessors: {
  3081. [key: string]: IGLTFAccessor;
  3082. };
  3083. buffers: {
  3084. [key: string]: IGLTFBuffer;
  3085. };
  3086. bufferViews: {
  3087. [key: string]: IGLTFBufferView;
  3088. };
  3089. meshes: {
  3090. [key: string]: IGLTFMesh;
  3091. };
  3092. lights: {
  3093. [key: string]: IGLTFLight;
  3094. };
  3095. cameras: {
  3096. [key: string]: IGLTFCamera;
  3097. };
  3098. nodes: {
  3099. [key: string]: IGLTFNode;
  3100. };
  3101. images: {
  3102. [key: string]: IGLTFImage;
  3103. };
  3104. textures: {
  3105. [key: string]: IGLTFTexture;
  3106. };
  3107. shaders: {
  3108. [key: string]: IGLTFShader;
  3109. };
  3110. programs: {
  3111. [key: string]: IGLTFProgram;
  3112. };
  3113. samplers: {
  3114. [key: string]: IGLTFSampler;
  3115. };
  3116. techniques: {
  3117. [key: string]: IGLTFTechnique;
  3118. };
  3119. materials: {
  3120. [key: string]: IGLTFMaterial;
  3121. };
  3122. animations: {
  3123. [key: string]: IGLTFAnimation;
  3124. };
  3125. skins: {
  3126. [key: string]: IGLTFSkins;
  3127. };
  3128. currentScene?: Object;
  3129. scenes: {
  3130. [key: string]: IGLTFScene;
  3131. };
  3132. extensionsUsed: string[];
  3133. extensionsRequired?: string[];
  3134. buffersCount: number;
  3135. shaderscount: number;
  3136. scene: Scene;
  3137. rootUrl: string;
  3138. loadedBufferCount: number;
  3139. loadedBufferViews: {
  3140. [name: string]: ArrayBufferView;
  3141. };
  3142. loadedShaderCount: number;
  3143. importOnlyMeshes: boolean;
  3144. importMeshesNames?: string[];
  3145. dummyNodes: Node[];
  3146. }
  3147. /** @hidden */
  3148. export interface INodeToRoot {
  3149. bone: Bone;
  3150. node: IGLTFNode;
  3151. id: string;
  3152. }
  3153. /** @hidden */
  3154. export interface IJointNode {
  3155. node: IGLTFNode;
  3156. id: string;
  3157. }
  3158. }
  3159. declare module BABYLON.GLTF1 {
  3160. /**
  3161. * Utils functions for GLTF
  3162. * @hidden
  3163. */
  3164. export class GLTFUtils {
  3165. /**
  3166. * Sets the given "parameter" matrix
  3167. * @param scene: the Scene object
  3168. * @param source: the source node where to pick the matrix
  3169. * @param parameter: the GLTF technique parameter
  3170. * @param uniformName: the name of the shader's uniform
  3171. * @param shaderMaterial: the shader material
  3172. */
  3173. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  3174. /**
  3175. * Sets the given "parameter" matrix
  3176. * @param shaderMaterial: the shader material
  3177. * @param uniform: the name of the shader's uniform
  3178. * @param value: the value of the uniform
  3179. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3180. */
  3181. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  3182. /**
  3183. * Returns the wrap mode of the texture
  3184. * @param mode: the mode value
  3185. */
  3186. static GetWrapMode(mode: number): number;
  3187. /**
  3188. * Returns the byte stride giving an accessor
  3189. * @param accessor: the GLTF accessor objet
  3190. */
  3191. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  3192. /**
  3193. * Returns the texture filter mode giving a mode value
  3194. * @param mode: the filter mode value
  3195. */
  3196. static GetTextureFilterMode(mode: number): ETextureFilterType;
  3197. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  3198. /**
  3199. * Returns a buffer from its accessor
  3200. * @param gltfRuntime: the GLTF runtime
  3201. * @param accessor: the GLTF accessor
  3202. */
  3203. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  3204. /**
  3205. * Decodes a buffer view into a string
  3206. * @param view: the buffer view
  3207. */
  3208. static DecodeBufferToText(view: ArrayBufferView): string;
  3209. /**
  3210. * Returns the default material of gltf. Related to
  3211. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3212. * @param scene: the Babylon.js scene
  3213. */
  3214. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  3215. private static _DefaultMaterial;
  3216. }
  3217. }
  3218. declare module BABYLON.GLTF1 {
  3219. /**
  3220. * Implementation of the base glTF spec
  3221. * @hidden
  3222. */
  3223. export class GLTFLoaderBase {
  3224. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  3225. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3226. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  3227. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3228. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  3229. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3230. }
  3231. /**
  3232. * glTF V1 Loader
  3233. * @hidden
  3234. */
  3235. export class GLTFLoader implements IGLTFLoader {
  3236. static Extensions: {
  3237. [name: string]: GLTFLoaderExtension;
  3238. };
  3239. static RegisterExtension(extension: GLTFLoaderExtension): void;
  3240. state: Nullable<GLTFLoaderState>;
  3241. dispose(): void;
  3242. private _importMeshAsync;
  3243. /**
  3244. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3245. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3246. * @param scene the scene the meshes should be added to
  3247. * @param data gltf data containing information of the meshes in a loaded file
  3248. * @param rootUrl root url to load from
  3249. * @param onProgress event that fires when loading progress has occured
  3250. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3251. */
  3252. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  3253. meshes: AbstractMesh[];
  3254. particleSystems: IParticleSystem[];
  3255. skeletons: Skeleton[];
  3256. animationGroups: AnimationGroup[];
  3257. }>;
  3258. private _loadAsync;
  3259. /**
  3260. * Imports all objects from a loaded gltf file and adds them to the scene
  3261. * @param scene the scene the objects should be added to
  3262. * @param data gltf data containing information of the meshes in a loaded file
  3263. * @param rootUrl root url to load from
  3264. * @param onProgress event that fires when loading progress has occured
  3265. * @returns a promise which completes when objects have been loaded to the scene
  3266. */
  3267. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  3268. private _loadShadersAsync;
  3269. private _loadBuffersAsync;
  3270. private _createNodes;
  3271. }
  3272. /** @hidden */
  3273. export abstract class GLTFLoaderExtension {
  3274. private _name;
  3275. constructor(name: string);
  3276. readonly name: string;
  3277. /**
  3278. * Defines an override for loading the runtime
  3279. * Return true to stop further extensions from loading the runtime
  3280. */
  3281. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  3282. /**
  3283. * Defines an onverride for creating gltf runtime
  3284. * Return true to stop further extensions from creating the runtime
  3285. */
  3286. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  3287. /**
  3288. * Defines an override for loading buffers
  3289. * Return true to stop further extensions from loading this buffer
  3290. */
  3291. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  3292. /**
  3293. * Defines an override for loading texture buffers
  3294. * Return true to stop further extensions from loading this texture data
  3295. */
  3296. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3297. /**
  3298. * Defines an override for creating textures
  3299. * Return true to stop further extensions from loading this texture
  3300. */
  3301. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  3302. /**
  3303. * Defines an override for loading shader strings
  3304. * Return true to stop further extensions from loading this shader data
  3305. */
  3306. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3307. /**
  3308. * Defines an override for loading materials
  3309. * Return true to stop further extensions from loading this material
  3310. */
  3311. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3312. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  3313. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  3314. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3315. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3316. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  3317. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3318. private static LoadTextureBufferAsync;
  3319. private static CreateTextureAsync;
  3320. private static ApplyExtensions;
  3321. }
  3322. }
  3323. declare module BABYLON.GLTF1 {
  3324. /** @hidden */
  3325. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  3326. private _bin;
  3327. constructor();
  3328. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  3329. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3330. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3331. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3332. }
  3333. }
  3334. declare module BABYLON.GLTF1 {
  3335. /** @hidden */
  3336. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  3337. constructor();
  3338. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  3339. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3340. private _loadTexture;
  3341. }
  3342. }
  3343. declare module BABYLON.GLTF2.Loader {
  3344. /**
  3345. * Loader interface with an index field.
  3346. */
  3347. export interface IArrayItem {
  3348. /**
  3349. * The index of this item in the array.
  3350. */
  3351. index: number;
  3352. }
  3353. /**
  3354. * Loader interface with additional members.
  3355. */
  3356. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3357. /** @hidden */
  3358. _data?: Promise<ArrayBufferView>;
  3359. /** @hidden */
  3360. _babylonVertexBuffer?: Promise<VertexBuffer>;
  3361. }
  3362. /**
  3363. * Loader interface with additional members.
  3364. */
  3365. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3366. }
  3367. /** @hidden */
  3368. export interface _IAnimationSamplerData {
  3369. input: Float32Array;
  3370. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3371. output: Float32Array;
  3372. }
  3373. /**
  3374. * Loader interface with additional members.
  3375. */
  3376. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3377. /** @hidden */
  3378. _data?: Promise<_IAnimationSamplerData>;
  3379. }
  3380. /**
  3381. * Loader interface with additional members.
  3382. */
  3383. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3384. channels: IAnimationChannel[];
  3385. samplers: IAnimationSampler[];
  3386. /** @hidden */
  3387. _babylonAnimationGroup?: AnimationGroup;
  3388. }
  3389. /**
  3390. * Loader interface with additional members.
  3391. */
  3392. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3393. /** @hidden */
  3394. _data?: Promise<ArrayBufferView>;
  3395. }
  3396. /**
  3397. * Loader interface with additional members.
  3398. */
  3399. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3400. /** @hidden */
  3401. _data?: Promise<ArrayBufferView>;
  3402. /** @hidden */
  3403. _babylonBuffer?: Promise<Buffer>;
  3404. }
  3405. /**
  3406. * Loader interface with additional members.
  3407. */
  3408. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3409. }
  3410. /**
  3411. * Loader interface with additional members.
  3412. */
  3413. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3414. /** @hidden */
  3415. _data?: Promise<ArrayBufferView>;
  3416. }
  3417. /**
  3418. * Loader interface with additional members.
  3419. */
  3420. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  3421. }
  3422. /**
  3423. * Loader interface with additional members.
  3424. */
  3425. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  3426. }
  3427. /**
  3428. * Loader interface with additional members.
  3429. */
  3430. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3431. baseColorTexture?: ITextureInfo;
  3432. metallicRoughnessTexture?: ITextureInfo;
  3433. }
  3434. /**
  3435. * Loader interface with additional members.
  3436. */
  3437. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3438. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3439. normalTexture?: IMaterialNormalTextureInfo;
  3440. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3441. emissiveTexture?: ITextureInfo;
  3442. /** @hidden */
  3443. _data?: {
  3444. [babylonDrawMode: number]: {
  3445. babylonMaterial: Material;
  3446. babylonMeshes: AbstractMesh[];
  3447. promise: Promise<void>;
  3448. };
  3449. };
  3450. }
  3451. /**
  3452. * Loader interface with additional members.
  3453. */
  3454. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3455. primitives: IMeshPrimitive[];
  3456. }
  3457. /**
  3458. * Loader interface with additional members.
  3459. */
  3460. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3461. /** @hidden */
  3462. _instanceData?: {
  3463. babylonSourceMesh: Mesh;
  3464. promise: Promise<any>;
  3465. };
  3466. }
  3467. /**
  3468. * Loader interface with additional members.
  3469. */
  3470. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  3471. /**
  3472. * The parent glTF node.
  3473. */
  3474. parent?: INode;
  3475. /** @hidden */
  3476. _babylonTransformNode?: TransformNode;
  3477. /** @hidden */
  3478. _primitiveBabylonMeshes?: AbstractMesh[];
  3479. /** @hidden */
  3480. _babylonBones?: Bone[];
  3481. /** @hidden */
  3482. _numMorphTargets?: number;
  3483. }
  3484. /** @hidden */
  3485. export interface _ISamplerData {
  3486. noMipMaps: boolean;
  3487. samplingMode: number;
  3488. wrapU: number;
  3489. wrapV: number;
  3490. }
  3491. /**
  3492. * Loader interface with additional members.
  3493. */
  3494. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  3495. /** @hidden */
  3496. _data?: _ISamplerData;
  3497. }
  3498. /**
  3499. * Loader interface with additional members.
  3500. */
  3501. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  3502. }
  3503. /**
  3504. * Loader interface with additional members.
  3505. */
  3506. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  3507. /** @hidden */
  3508. _data?: {
  3509. babylonSkeleton: Skeleton;
  3510. promise: Promise<void>;
  3511. };
  3512. }
  3513. /**
  3514. * Loader interface with additional members.
  3515. */
  3516. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  3517. }
  3518. /**
  3519. * Loader interface with additional members.
  3520. */
  3521. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  3522. }
  3523. /**
  3524. * Loader interface with additional members.
  3525. */
  3526. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  3527. accessors?: IAccessor[];
  3528. animations?: IAnimation[];
  3529. buffers?: IBuffer[];
  3530. bufferViews?: IBufferView[];
  3531. cameras?: ICamera[];
  3532. images?: IImage[];
  3533. materials?: IMaterial[];
  3534. meshes?: IMesh[];
  3535. nodes?: INode[];
  3536. samplers?: ISampler[];
  3537. scenes?: IScene[];
  3538. skins?: ISkin[];
  3539. textures?: ITexture[];
  3540. }
  3541. }
  3542. declare module BABYLON.GLTF2 {
  3543. /**
  3544. * Interface for a glTF loader extension.
  3545. */
  3546. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  3547. /**
  3548. * Called after the loader state changes to LOADING.
  3549. */
  3550. onLoading?(): void;
  3551. /**
  3552. * Called after the loader state changes to READY.
  3553. */
  3554. onReady?(): void;
  3555. /**
  3556. * Define this method to modify the default behavior when loading scenes.
  3557. * @param context The context when loading the asset
  3558. * @param scene The glTF scene property
  3559. * @returns A promise that resolves when the load is complete or null if not handled
  3560. */
  3561. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  3562. /**
  3563. * Define this method to modify the default behavior when loading nodes.
  3564. * @param context The context when loading the asset
  3565. * @param node The glTF node property
  3566. * @param assign A function called synchronously after parsing the glTF properties
  3567. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  3568. */
  3569. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3570. /**
  3571. * Define this method to modify the default behavior when loading cameras.
  3572. * @param context The context when loading the asset
  3573. * @param camera The glTF camera property
  3574. * @param assign A function called synchronously after parsing the glTF properties
  3575. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  3576. */
  3577. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  3578. /**
  3579. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  3580. * @param context The context when loading the asset
  3581. * @param primitive The glTF mesh primitive property
  3582. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  3583. */
  3584. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  3585. /**
  3586. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  3587. * @param context The context when loading the asset
  3588. * @param name The mesh name when loading the asset
  3589. * @param node The glTF node when loading the asset
  3590. * @param mesh The glTF mesh when loading the asset
  3591. * @param primitive The glTF mesh primitive property
  3592. * @param assign A function called synchronously after parsing the glTF properties
  3593. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  3594. */
  3595. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  3596. /**
  3597. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  3598. * @param context The context when loading the asset
  3599. * @param material The glTF material property
  3600. * @param assign A function called synchronously after parsing the glTF properties
  3601. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  3602. */
  3603. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  3604. /**
  3605. * Define this method to modify the default behavior when creating materials.
  3606. * @param context The context when loading the asset
  3607. * @param material The glTF material property
  3608. * @param babylonDrawMode The draw mode for the Babylon material
  3609. * @returns The Babylon material or null if not handled
  3610. */
  3611. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  3612. /**
  3613. * Define this method to modify the default behavior when loading material properties.
  3614. * @param context The context when loading the asset
  3615. * @param material The glTF material property
  3616. * @param babylonMaterial The Babylon material
  3617. * @returns A promise that resolves when the load is complete or null if not handled
  3618. */
  3619. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3620. /**
  3621. * Define this method to modify the default behavior when loading texture infos.
  3622. * @param context The context when loading the asset
  3623. * @param textureInfo The glTF texture info property
  3624. * @param assign A function called synchronously after parsing the glTF properties
  3625. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  3626. */
  3627. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3628. /**
  3629. * Define this method to modify the default behavior when loading animations.
  3630. * @param context The context when loading the asset
  3631. * @param animation The glTF animation property
  3632. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  3633. */
  3634. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  3635. /**
  3636. * @hidden Define this method to modify the default behavior when loading skins.
  3637. * @param context The context when loading the asset
  3638. * @param node The glTF node property
  3639. * @param skin The glTF skin property
  3640. * @returns A promise that resolves when the load is complete or null if not handled
  3641. */
  3642. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  3643. /**
  3644. * @hidden Define this method to modify the default behavior when loading uris.
  3645. * @param context The context when loading the asset
  3646. * @param property The glTF property associated with the uri
  3647. * @param uri The uri to load
  3648. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3649. */
  3650. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  3651. /**
  3652. * Define this method to modify the default behavior when loading buffer views.
  3653. * @param context The context when loading the asset
  3654. * @param bufferView The glTF buffer view property
  3655. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3656. */
  3657. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  3658. /**
  3659. * Define this method to modify the default behavior when loading buffers.
  3660. * @param context The context when loading the asset
  3661. * @param buffer The glTF buffer property
  3662. * @param byteOffset The byte offset to load
  3663. * @param byteLength The byte length to load
  3664. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3665. */
  3666. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  3667. }
  3668. }
  3669. declare module BABYLON.GLTF2 {
  3670. /**
  3671. * Helper class for working with arrays when loading the glTF asset
  3672. */
  3673. export class ArrayItem {
  3674. /**
  3675. * Gets an item from the given array.
  3676. * @param context The context when loading the asset
  3677. * @param array The array to get the item from
  3678. * @param index The index to the array
  3679. * @returns The array item
  3680. */
  3681. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  3682. /**
  3683. * Assign an `index` field to each item of the given array.
  3684. * @param array The array of items
  3685. */
  3686. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  3687. }
  3688. /**
  3689. * The glTF 2.0 loader
  3690. */
  3691. export class GLTFLoader implements IGLTFLoader {
  3692. /** @hidden */
  3693. _completePromises: Promise<any>[];
  3694. private _disposed;
  3695. private _parent;
  3696. private _state;
  3697. private _extensions;
  3698. private _rootUrl;
  3699. private _fileName;
  3700. private _uniqueRootUrl;
  3701. private _gltf;
  3702. private _bin;
  3703. private _babylonScene;
  3704. private _rootBabylonMesh;
  3705. private _defaultBabylonMaterialData;
  3706. private _progressCallback?;
  3707. private _requests;
  3708. private static readonly _DefaultSampler;
  3709. private static _RegisteredExtensions;
  3710. /**
  3711. * Registers a loader extension.
  3712. * @param name The name of the loader extension.
  3713. * @param factory The factory function that creates the loader extension.
  3714. */
  3715. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  3716. /**
  3717. * Unregisters a loader extension.
  3718. * @param name The name of the loader extension.
  3719. * @returns A boolean indicating whether the extension has been unregistered
  3720. */
  3721. static UnregisterExtension(name: string): boolean;
  3722. /**
  3723. * Gets the loader state.
  3724. */
  3725. readonly state: Nullable<GLTFLoaderState>;
  3726. /**
  3727. * The object that represents the glTF JSON.
  3728. */
  3729. readonly gltf: IGLTF;
  3730. /**
  3731. * The BIN chunk of a binary glTF.
  3732. */
  3733. readonly bin: Nullable<IDataBuffer>;
  3734. /**
  3735. * The parent file loader.
  3736. */
  3737. readonly parent: GLTFFileLoader;
  3738. /**
  3739. * The Babylon scene when loading the asset.
  3740. */
  3741. readonly babylonScene: Scene;
  3742. /**
  3743. * The root Babylon mesh when loading the asset.
  3744. */
  3745. readonly rootBabylonMesh: Mesh;
  3746. /** @hidden */
  3747. constructor(parent: GLTFFileLoader);
  3748. /** @hidden */
  3749. dispose(): void;
  3750. /** @hidden */
  3751. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  3752. meshes: AbstractMesh[];
  3753. particleSystems: IParticleSystem[];
  3754. skeletons: Skeleton[];
  3755. animationGroups: AnimationGroup[];
  3756. }>;
  3757. /** @hidden */
  3758. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  3759. private _loadAsync;
  3760. private _loadData;
  3761. private _setupData;
  3762. private _loadExtensions;
  3763. private _checkExtensions;
  3764. private _setState;
  3765. private _createRootNode;
  3766. /**
  3767. * Loads a glTF scene.
  3768. * @param context The context when loading the asset
  3769. * @param scene The glTF scene property
  3770. * @returns A promise that resolves when the load is complete
  3771. */
  3772. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  3773. private _forEachPrimitive;
  3774. private _getMeshes;
  3775. private _getSkeletons;
  3776. private _getAnimationGroups;
  3777. private _startAnimations;
  3778. /**
  3779. * Loads a glTF node.
  3780. * @param context The context when loading the asset
  3781. * @param node The glTF node property
  3782. * @param assign A function called synchronously after parsing the glTF properties
  3783. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  3784. */
  3785. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  3786. private _loadMeshAsync;
  3787. /**
  3788. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  3789. * @param context The context when loading the asset
  3790. * @param name The mesh name when loading the asset
  3791. * @param node The glTF node when loading the asset
  3792. * @param mesh The glTF mesh when loading the asset
  3793. * @param primitive The glTF mesh primitive property
  3794. * @param assign A function called synchronously after parsing the glTF properties
  3795. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  3796. */
  3797. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  3798. private _loadVertexDataAsync;
  3799. private _createMorphTargets;
  3800. private _loadMorphTargetsAsync;
  3801. private _loadMorphTargetVertexDataAsync;
  3802. private static _LoadTransform;
  3803. private _loadSkinAsync;
  3804. private _loadBones;
  3805. private _loadBone;
  3806. private _loadSkinInverseBindMatricesDataAsync;
  3807. private _updateBoneMatrices;
  3808. private _getNodeMatrix;
  3809. /**
  3810. * Loads a glTF camera.
  3811. * @param context The context when loading the asset
  3812. * @param camera The glTF camera property
  3813. * @param assign A function called synchronously after parsing the glTF properties
  3814. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  3815. */
  3816. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  3817. private _loadAnimationsAsync;
  3818. /**
  3819. * Loads a glTF animation.
  3820. * @param context The context when loading the asset
  3821. * @param animation The glTF animation property
  3822. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  3823. */
  3824. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  3825. /**
  3826. * @hidden Loads a glTF animation channel.
  3827. * @param context The context when loading the asset
  3828. * @param animationContext The context of the animation when loading the asset
  3829. * @param animation The glTF animation property
  3830. * @param channel The glTF animation channel property
  3831. * @param babylonAnimationGroup The babylon animation group property
  3832. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  3833. * @returns A void promise when the channel load is complete
  3834. */
  3835. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  3836. private _loadAnimationSamplerAsync;
  3837. private _loadBufferAsync;
  3838. /**
  3839. * Loads a glTF buffer view.
  3840. * @param context The context when loading the asset
  3841. * @param bufferView The glTF buffer view property
  3842. * @returns A promise that resolves with the loaded data when the load is complete
  3843. */
  3844. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  3845. private _loadAccessorAsync;
  3846. private _loadFloatAccessorAsync;
  3847. private _loadIndicesAccessorAsync;
  3848. private _loadVertexBufferViewAsync;
  3849. private _loadVertexAccessorAsync;
  3850. private _loadMaterialMetallicRoughnessPropertiesAsync;
  3851. /** @hidden */
  3852. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  3853. private _createDefaultMaterial;
  3854. /**
  3855. * Creates a Babylon material from a glTF material.
  3856. * @param context The context when loading the asset
  3857. * @param material The glTF material property
  3858. * @param babylonDrawMode The draw mode for the Babylon material
  3859. * @returns The Babylon material
  3860. */
  3861. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  3862. /**
  3863. * Loads properties from a glTF material into a Babylon material.
  3864. * @param context The context when loading the asset
  3865. * @param material The glTF material property
  3866. * @param babylonMaterial The Babylon material
  3867. * @returns A promise that resolves when the load is complete
  3868. */
  3869. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3870. /**
  3871. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  3872. * @param context The context when loading the asset
  3873. * @param material The glTF material property
  3874. * @param babylonMaterial The Babylon material
  3875. * @returns A promise that resolves when the load is complete
  3876. */
  3877. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3878. /**
  3879. * Loads the alpha properties from a glTF material into a Babylon material.
  3880. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  3881. * @param context The context when loading the asset
  3882. * @param material The glTF material property
  3883. * @param babylonMaterial The Babylon material
  3884. */
  3885. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  3886. /**
  3887. * Loads a glTF texture info.
  3888. * @param context The context when loading the asset
  3889. * @param textureInfo The glTF texture info property
  3890. * @param assign A function called synchronously after parsing the glTF properties
  3891. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  3892. */
  3893. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  3894. private _loadTextureAsync;
  3895. private _loadSampler;
  3896. /**
  3897. * Loads a glTF image.
  3898. * @param context The context when loading the asset
  3899. * @param image The glTF image property
  3900. * @returns A promise that resolves with the loaded data when the load is complete
  3901. */
  3902. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  3903. /**
  3904. * Loads a glTF uri.
  3905. * @param context The context when loading the asset
  3906. * @param property The glTF property associated with the uri
  3907. * @param uri The base64 or relative uri
  3908. * @returns A promise that resolves with the loaded data when the load is complete
  3909. */
  3910. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  3911. private _onProgress;
  3912. /**
  3913. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  3914. * @param babylonObject the Babylon object with metadata
  3915. * @param pointer the JSON pointer
  3916. */
  3917. static AddPointerMetadata(babylonObject: {
  3918. metadata: any;
  3919. }, pointer: string): void;
  3920. private static _GetTextureWrapMode;
  3921. private static _GetTextureSamplingMode;
  3922. private static _GetTypedArrayConstructor;
  3923. private static _GetTypedArray;
  3924. private static _GetNumComponents;
  3925. private static _ValidateUri;
  3926. private static _GetDrawMode;
  3927. private _compileMaterialsAsync;
  3928. private _compileShadowGeneratorsAsync;
  3929. private _forEachExtensions;
  3930. private _applyExtensions;
  3931. private _extensionsOnLoading;
  3932. private _extensionsOnReady;
  3933. private _extensionsLoadSceneAsync;
  3934. private _extensionsLoadNodeAsync;
  3935. private _extensionsLoadCameraAsync;
  3936. private _extensionsLoadVertexDataAsync;
  3937. private _extensionsLoadMeshPrimitiveAsync;
  3938. private _extensionsLoadMaterialAsync;
  3939. private _extensionsCreateMaterial;
  3940. private _extensionsLoadMaterialPropertiesAsync;
  3941. private _extensionsLoadTextureInfoAsync;
  3942. private _extensionsLoadAnimationAsync;
  3943. private _extensionsLoadSkinAsync;
  3944. private _extensionsLoadUriAsync;
  3945. private _extensionsLoadBufferViewAsync;
  3946. private _extensionsLoadBufferAsync;
  3947. /**
  3948. * Helper method called by a loader extension to load an glTF extension.
  3949. * @param context The context when loading the asset
  3950. * @param property The glTF property to load the extension from
  3951. * @param extensionName The name of the extension to load
  3952. * @param actionAsync The action to run
  3953. * @returns The promise returned by actionAsync or null if the extension does not exist
  3954. */
  3955. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  3956. /**
  3957. * Helper method called by a loader extension to load a glTF extra.
  3958. * @param context The context when loading the asset
  3959. * @param property The glTF property to load the extra from
  3960. * @param extensionName The name of the extension to load
  3961. * @param actionAsync The action to run
  3962. * @returns The promise returned by actionAsync or null if the extra does not exist
  3963. */
  3964. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  3965. /**
  3966. * Checks for presence of an extension.
  3967. * @param name The name of the extension to check
  3968. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  3969. */
  3970. isExtensionUsed(name: string): boolean;
  3971. /**
  3972. * Increments the indentation level and logs a message.
  3973. * @param message The message to log
  3974. */
  3975. logOpen(message: string): void;
  3976. /**
  3977. * Decrements the indentation level.
  3978. */
  3979. logClose(): void;
  3980. /**
  3981. * Logs a message
  3982. * @param message The message to log
  3983. */
  3984. log(message: string): void;
  3985. /**
  3986. * Starts a performance counter.
  3987. * @param counterName The name of the performance counter
  3988. */
  3989. startPerformanceCounter(counterName: string): void;
  3990. /**
  3991. * Ends a performance counter.
  3992. * @param counterName The name of the performance counter
  3993. */
  3994. endPerformanceCounter(counterName: string): void;
  3995. }
  3996. }
  3997. declare module BABYLON.GLTF2.Loader.Extensions {
  3998. /**
  3999. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  4000. */
  4001. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  4002. /**
  4003. * The name of this extension.
  4004. */
  4005. readonly name: string;
  4006. /**
  4007. * Defines whether this extension is enabled.
  4008. */
  4009. enabled: boolean;
  4010. private _loader;
  4011. private _lights?;
  4012. /** @hidden */
  4013. constructor(loader: GLTFLoader);
  4014. /** @hidden */
  4015. dispose(): void;
  4016. /** @hidden */
  4017. onLoading(): void;
  4018. /** @hidden */
  4019. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4020. private _loadLightAsync;
  4021. }
  4022. }
  4023. declare module BABYLON.GLTF2.Loader.Extensions {
  4024. /**
  4025. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  4026. */
  4027. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  4028. /**
  4029. * The name of this extension.
  4030. */
  4031. readonly name: string;
  4032. /**
  4033. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  4034. */
  4035. dracoCompression?: DracoCompression;
  4036. /**
  4037. * Defines whether this extension is enabled.
  4038. */
  4039. enabled: boolean;
  4040. private _loader;
  4041. /** @hidden */
  4042. constructor(loader: GLTFLoader);
  4043. /** @hidden */
  4044. dispose(): void;
  4045. /** @hidden */
  4046. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  4047. }
  4048. }
  4049. declare module BABYLON.GLTF2.Loader.Extensions {
  4050. /**
  4051. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  4052. */
  4053. export class KHR_lights implements IGLTFLoaderExtension {
  4054. /**
  4055. * The name of this extension.
  4056. */
  4057. readonly name: string;
  4058. /**
  4059. * Defines whether this extension is enabled.
  4060. */
  4061. enabled: boolean;
  4062. private _loader;
  4063. private _lights?;
  4064. /** @hidden */
  4065. constructor(loader: GLTFLoader);
  4066. /** @hidden */
  4067. dispose(): void;
  4068. /** @hidden */
  4069. onLoading(): void;
  4070. /** @hidden */
  4071. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4072. }
  4073. }
  4074. declare module BABYLON.GLTF2.Loader.Extensions {
  4075. /**
  4076. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  4077. */
  4078. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  4079. /**
  4080. * The name of this extension.
  4081. */
  4082. readonly name: string;
  4083. /**
  4084. * Defines whether this extension is enabled.
  4085. */
  4086. enabled: boolean;
  4087. /**
  4088. * Defines a number that determines the order the extensions are applied.
  4089. */
  4090. order: number;
  4091. private _loader;
  4092. /** @hidden */
  4093. constructor(loader: GLTFLoader);
  4094. /** @hidden */
  4095. dispose(): void;
  4096. /** @hidden */
  4097. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4098. private _loadSpecularGlossinessPropertiesAsync;
  4099. }
  4100. }
  4101. declare module BABYLON.GLTF2.Loader.Extensions {
  4102. /**
  4103. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  4104. */
  4105. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  4106. /**
  4107. * The name of this extension.
  4108. */
  4109. readonly name: string;
  4110. /**
  4111. * Defines whether this extension is enabled.
  4112. */
  4113. enabled: boolean;
  4114. /**
  4115. * Defines a number that determines the order the extensions are applied.
  4116. */
  4117. order: number;
  4118. private _loader;
  4119. /** @hidden */
  4120. constructor(loader: GLTFLoader);
  4121. /** @hidden */
  4122. dispose(): void;
  4123. /** @hidden */
  4124. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4125. private _loadUnlitPropertiesAsync;
  4126. }
  4127. }
  4128. declare module BABYLON.GLTF2.Loader.Extensions {
  4129. /**
  4130. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  4131. */
  4132. export class KHR_texture_transform implements IGLTFLoaderExtension {
  4133. /**
  4134. * The name of this extension.
  4135. */
  4136. readonly name: string;
  4137. /**
  4138. * Defines whether this extension is enabled.
  4139. */
  4140. enabled: boolean;
  4141. private _loader;
  4142. /** @hidden */
  4143. constructor(loader: GLTFLoader);
  4144. /** @hidden */
  4145. dispose(): void;
  4146. /** @hidden */
  4147. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4148. }
  4149. }
  4150. declare module BABYLON.GLTF2.Loader.Extensions {
  4151. /**
  4152. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  4153. */
  4154. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  4155. /**
  4156. * The name of this extension.
  4157. */
  4158. readonly name: string;
  4159. /**
  4160. * Defines whether this extension is enabled.
  4161. */
  4162. enabled: boolean;
  4163. private _loader;
  4164. private _clips;
  4165. private _emitters;
  4166. /** @hidden */
  4167. constructor(loader: GLTFLoader);
  4168. /** @hidden */
  4169. dispose(): void;
  4170. /** @hidden */
  4171. onLoading(): void;
  4172. /** @hidden */
  4173. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4174. /** @hidden */
  4175. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4176. /** @hidden */
  4177. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  4178. private _loadClipAsync;
  4179. private _loadEmitterAsync;
  4180. private _getEventAction;
  4181. private _loadAnimationEventAsync;
  4182. }
  4183. }
  4184. declare module BABYLON.GLTF2.Loader.Extensions {
  4185. /**
  4186. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  4187. */
  4188. export class MSFT_lod implements IGLTFLoaderExtension {
  4189. /**
  4190. * The name of this extension.
  4191. */
  4192. readonly name: string;
  4193. /**
  4194. * Defines whether this extension is enabled.
  4195. */
  4196. enabled: boolean;
  4197. /**
  4198. * Defines a number that determines the order the extensions are applied.
  4199. */
  4200. order: number;
  4201. /**
  4202. * Maximum number of LODs to load, starting from the lowest LOD.
  4203. */
  4204. maxLODsToLoad: number;
  4205. /**
  4206. * Observable raised when all node LODs of one level are loaded.
  4207. * The event data is the index of the loaded LOD starting from zero.
  4208. * Dispose the loader to cancel the loading of the next level of LODs.
  4209. */
  4210. onNodeLODsLoadedObservable: Observable<number>;
  4211. /**
  4212. * Observable raised when all material LODs of one level are loaded.
  4213. * The event data is the index of the loaded LOD starting from zero.
  4214. * Dispose the loader to cancel the loading of the next level of LODs.
  4215. */
  4216. onMaterialLODsLoadedObservable: Observable<number>;
  4217. private _loader;
  4218. private _nodeIndexLOD;
  4219. private _nodeSignalLODs;
  4220. private _nodePromiseLODs;
  4221. private _materialIndexLOD;
  4222. private _materialSignalLODs;
  4223. private _materialPromiseLODs;
  4224. private _indexLOD;
  4225. private _bufferLODs;
  4226. /** @hidden */
  4227. constructor(loader: GLTFLoader);
  4228. /** @hidden */
  4229. dispose(): void;
  4230. /** @hidden */
  4231. onReady(): void;
  4232. /** @hidden */
  4233. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4234. /** @hidden */
  4235. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  4236. /** @hidden */
  4237. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  4238. /** @hidden */
  4239. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  4240. private _loadBufferLOD;
  4241. /**
  4242. * Gets an array of LOD properties from lowest to highest.
  4243. */
  4244. private _getLODs;
  4245. private _disposeUnusedMaterials;
  4246. }
  4247. }
  4248. declare module BABYLON.GLTF2.Loader.Extensions {
  4249. /** @hidden */
  4250. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  4251. readonly name: string;
  4252. enabled: boolean;
  4253. private _loader;
  4254. constructor(loader: GLTFLoader);
  4255. dispose(): void;
  4256. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4257. }
  4258. }
  4259. declare module BABYLON.GLTF2.Loader.Extensions {
  4260. /** @hidden */
  4261. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  4262. readonly name: string;
  4263. enabled: boolean;
  4264. private _loader;
  4265. constructor(loader: GLTFLoader);
  4266. dispose(): void;
  4267. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4268. }
  4269. }
  4270. declare module BABYLON.GLTF2.Loader.Extensions {
  4271. /**
  4272. * Store glTF extras (if present) in BJS objects' metadata
  4273. */
  4274. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  4275. /**
  4276. * The name of this extension.
  4277. */
  4278. readonly name: string;
  4279. /**
  4280. * Defines whether this extension is enabled.
  4281. */
  4282. enabled: boolean;
  4283. private _loader;
  4284. private _assignExtras;
  4285. /** @hidden */
  4286. constructor(loader: GLTFLoader);
  4287. /** @hidden */
  4288. dispose(): void;
  4289. /** @hidden */
  4290. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4291. /** @hidden */
  4292. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  4293. /** @hidden */
  4294. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  4295. }
  4296. }
  4297. declare module BABYLON {
  4298. /**
  4299. * Class reading and parsing the MTL file bundled with the obj file.
  4300. */
  4301. export class MTLFileLoader {
  4302. /**
  4303. * All material loaded from the mtl will be set here
  4304. */
  4305. materials: StandardMaterial[];
  4306. /**
  4307. * This function will read the mtl file and create each material described inside
  4308. * This function could be improve by adding :
  4309. * -some component missing (Ni, Tf...)
  4310. * -including the specific options available
  4311. *
  4312. * @param scene defines the scene the material will be created in
  4313. * @param data defines the mtl data to parse
  4314. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  4315. */
  4316. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  4317. /**
  4318. * Gets the texture for the material.
  4319. *
  4320. * If the material is imported from input file,
  4321. * We sanitize the url to ensure it takes the textre from aside the material.
  4322. *
  4323. * @param rootUrl The root url to load from
  4324. * @param value The value stored in the mtl
  4325. * @return The Texture
  4326. */
  4327. private static _getTexture;
  4328. }
  4329. /**
  4330. * Options for loading OBJ/MTL files
  4331. */
  4332. type MeshLoadOptions = {
  4333. /**
  4334. * Defines if UVs are optimized by default during load.
  4335. */
  4336. OptimizeWithUV: boolean;
  4337. /**
  4338. * Defines custom scaling of UV coordinates of loaded meshes.
  4339. */
  4340. UVScaling: Vector2;
  4341. /**
  4342. * Invert model on y-axis (does a model scaling inversion)
  4343. */
  4344. InvertY: boolean;
  4345. /**
  4346. * Invert Y-Axis of referenced textures on load
  4347. */
  4348. InvertTextureY: boolean;
  4349. /**
  4350. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4351. */
  4352. ImportVertexColors: boolean;
  4353. /**
  4354. * Compute the normals for the model, even if normals are present in the file.
  4355. */
  4356. ComputeNormals: boolean;
  4357. /**
  4358. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4359. */
  4360. SkipMaterials: boolean;
  4361. /**
  4362. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4363. */
  4364. MaterialLoadingFailsSilently: boolean;
  4365. };
  4366. /**
  4367. * OBJ file type loader.
  4368. * This is a babylon scene loader plugin.
  4369. */
  4370. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  4371. /**
  4372. * Defines if UVs are optimized by default during load.
  4373. */
  4374. static OPTIMIZE_WITH_UV: boolean;
  4375. /**
  4376. * Invert model on y-axis (does a model scaling inversion)
  4377. */
  4378. static INVERT_Y: boolean;
  4379. /**
  4380. * Invert Y-Axis of referenced textures on load
  4381. */
  4382. static INVERT_TEXTURE_Y: boolean;
  4383. /**
  4384. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4385. */
  4386. static IMPORT_VERTEX_COLORS: boolean;
  4387. /**
  4388. * Compute the normals for the model, even if normals are present in the file.
  4389. */
  4390. static COMPUTE_NORMALS: boolean;
  4391. /**
  4392. * Defines custom scaling of UV coordinates of loaded meshes.
  4393. */
  4394. static UV_SCALING: Vector2;
  4395. /**
  4396. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4397. */
  4398. static SKIP_MATERIALS: boolean;
  4399. /**
  4400. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4401. *
  4402. * Defaults to true for backwards compatibility.
  4403. */
  4404. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  4405. /**
  4406. * Defines the name of the plugin.
  4407. */
  4408. name: string;
  4409. /**
  4410. * Defines the extension the plugin is able to load.
  4411. */
  4412. extensions: string;
  4413. /** @hidden */
  4414. obj: RegExp;
  4415. /** @hidden */
  4416. group: RegExp;
  4417. /** @hidden */
  4418. mtllib: RegExp;
  4419. /** @hidden */
  4420. usemtl: RegExp;
  4421. /** @hidden */
  4422. smooth: RegExp;
  4423. /** @hidden */
  4424. vertexPattern: RegExp;
  4425. /** @hidden */
  4426. normalPattern: RegExp;
  4427. /** @hidden */
  4428. uvPattern: RegExp;
  4429. /** @hidden */
  4430. facePattern1: RegExp;
  4431. /** @hidden */
  4432. facePattern2: RegExp;
  4433. /** @hidden */
  4434. facePattern3: RegExp;
  4435. /** @hidden */
  4436. facePattern4: RegExp;
  4437. /** @hidden */
  4438. facePattern5: RegExp;
  4439. private _meshLoadOptions;
  4440. /**
  4441. * Creates loader for .OBJ files
  4442. *
  4443. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  4444. */
  4445. constructor(meshLoadOptions?: MeshLoadOptions);
  4446. private static readonly currentMeshLoadOptions;
  4447. /**
  4448. * Calls synchronously the MTL file attached to this obj.
  4449. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  4450. * Without this function materials are not displayed in the first frame (but displayed after).
  4451. * In consequence it is impossible to get material information in your HTML file
  4452. *
  4453. * @param url The URL of the MTL file
  4454. * @param rootUrl
  4455. * @param onSuccess Callback function to be called when the MTL file is loaded
  4456. * @private
  4457. */
  4458. private _loadMTL;
  4459. /**
  4460. * Instantiates a OBJ file loader plugin.
  4461. * @returns the created plugin
  4462. */
  4463. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  4464. /**
  4465. * If the data string can be loaded directly.
  4466. *
  4467. * @param data string containing the file data
  4468. * @returns if the data can be loaded directly
  4469. */
  4470. canDirectLoad(data: string): boolean;
  4471. /**
  4472. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  4473. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  4474. * @param scene the scene the meshes should be added to
  4475. * @param data the OBJ data to load
  4476. * @param rootUrl root url to load from
  4477. * @param onProgress event that fires when loading progress has occured
  4478. * @param fileName Defines the name of the file to load
  4479. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  4480. */
  4481. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  4482. meshes: AbstractMesh[];
  4483. particleSystems: IParticleSystem[];
  4484. skeletons: Skeleton[];
  4485. animationGroups: AnimationGroup[];
  4486. }>;
  4487. /**
  4488. * Imports all objects from the loaded OBJ data and adds them to the scene
  4489. * @param scene the scene the objects should be added to
  4490. * @param data the OBJ data to load
  4491. * @param rootUrl root url to load from
  4492. * @param onProgress event that fires when loading progress has occured
  4493. * @param fileName Defines the name of the file to load
  4494. * @returns a promise which completes when objects have been loaded to the scene
  4495. */
  4496. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4497. /**
  4498. * Load into an asset container.
  4499. * @param scene The scene to load into
  4500. * @param data The data to import
  4501. * @param rootUrl The root url for scene and resources
  4502. * @param onProgress The callback when the load progresses
  4503. * @param fileName Defines the name of the file to load
  4504. * @returns The loaded asset container
  4505. */
  4506. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  4507. /**
  4508. * Read the OBJ file and create an Array of meshes.
  4509. * Each mesh contains all information given by the OBJ and the MTL file.
  4510. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  4511. *
  4512. * @param meshesNames
  4513. * @param scene Scene The scene where are displayed the data
  4514. * @param data String The content of the obj file
  4515. * @param rootUrl String The path to the folder
  4516. * @returns Array<AbstractMesh>
  4517. * @private
  4518. */
  4519. private _parseSolid;
  4520. }
  4521. }
  4522. declare module BABYLON {
  4523. /**
  4524. * STL file type loader.
  4525. * This is a babylon scene loader plugin.
  4526. */
  4527. export class STLFileLoader implements ISceneLoaderPlugin {
  4528. /** @hidden */
  4529. solidPattern: RegExp;
  4530. /** @hidden */
  4531. facetsPattern: RegExp;
  4532. /** @hidden */
  4533. normalPattern: RegExp;
  4534. /** @hidden */
  4535. vertexPattern: RegExp;
  4536. /**
  4537. * Defines the name of the plugin.
  4538. */
  4539. name: string;
  4540. /**
  4541. * Defines the extensions the stl loader is able to load.
  4542. * force data to come in as an ArrayBuffer
  4543. * we'll convert to string if it looks like it's an ASCII .stl
  4544. */
  4545. extensions: ISceneLoaderPluginExtensions;
  4546. /**
  4547. * Import meshes into a scene.
  4548. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  4549. * @param scene The scene to import into
  4550. * @param data The data to import
  4551. * @param rootUrl The root url for scene and resources
  4552. * @param meshes The meshes array to import into
  4553. * @param particleSystems The particle systems array to import into
  4554. * @param skeletons The skeletons array to import into
  4555. * @param onError The callback when import fails
  4556. * @returns True if successful or false otherwise
  4557. */
  4558. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  4559. /**
  4560. * Load into a scene.
  4561. * @param scene The scene to load into
  4562. * @param data The data to import
  4563. * @param rootUrl The root url for scene and resources
  4564. * @param onError The callback when import fails
  4565. * @returns true if successful or false otherwise
  4566. */
  4567. load(scene: Scene, data: any, rootUrl: string): boolean;
  4568. /**
  4569. * Load into an asset container.
  4570. * @param scene The scene to load into
  4571. * @param data The data to import
  4572. * @param rootUrl The root url for scene and resources
  4573. * @param onError The callback when import fails
  4574. * @returns The loaded asset container
  4575. */
  4576. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  4577. private _isBinary;
  4578. private _parseBinary;
  4579. private _parseASCII;
  4580. }
  4581. }