babylonjs.loaders.module.d.ts 195 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707
  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_materials_clearcoat" {
  1832. import { Nullable } from "babylonjs/types";
  1833. import { Material } from "babylonjs/Materials/material";
  1834. import { IMaterial } 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. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1839. * [Playground Sample](https://www.babylonjs-playground.com/#7F7PN6)
  1840. * !!! Experimental Extension Subject to Changes !!!
  1841. */
  1842. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  1843. /**
  1844. * The name of this extension.
  1845. */
  1846. readonly name: string;
  1847. /**
  1848. * Defines whether this extension is enabled.
  1849. */
  1850. enabled: boolean;
  1851. /**
  1852. * Defines a number that determines the order the extensions are applied.
  1853. */
  1854. order: number;
  1855. private _loader;
  1856. /** @hidden */
  1857. constructor(loader: GLTFLoader);
  1858. /** @hidden */
  1859. dispose(): void;
  1860. /** @hidden */
  1861. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1862. private _loadClearCoatPropertiesAsync;
  1863. }
  1864. }
  1865. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular" {
  1866. import { Nullable } from "babylonjs/types";
  1867. import { Material } from "babylonjs/Materials/material";
  1868. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1869. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1870. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1871. /**
  1872. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1873. * !!! Experimental Extension Subject to Changes !!!
  1874. */
  1875. export class KHR_materials_specular implements IGLTFLoaderExtension {
  1876. /**
  1877. * The name of this extension.
  1878. */
  1879. readonly name: string;
  1880. /**
  1881. * Defines whether this extension is enabled.
  1882. */
  1883. enabled: boolean;
  1884. /**
  1885. * Defines a number that determines the order the extensions are applied.
  1886. */
  1887. order: number;
  1888. private _loader;
  1889. /** @hidden */
  1890. constructor(loader: GLTFLoader);
  1891. /** @hidden */
  1892. dispose(): void;
  1893. /** @hidden */
  1894. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1895. private _loadSpecularPropertiesAsync;
  1896. }
  1897. }
  1898. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform" {
  1899. import { Nullable } from "babylonjs/types";
  1900. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1901. import { ITextureInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1902. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1903. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1904. /**
  1905. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1906. */
  1907. export class KHR_texture_transform implements IGLTFLoaderExtension {
  1908. /**
  1909. * The name of this extension.
  1910. */
  1911. readonly name: string;
  1912. /**
  1913. * Defines whether this extension is enabled.
  1914. */
  1915. enabled: boolean;
  1916. private _loader;
  1917. /** @hidden */
  1918. constructor(loader: GLTFLoader);
  1919. /** @hidden */
  1920. dispose(): void;
  1921. /** @hidden */
  1922. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1923. }
  1924. }
  1925. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter" {
  1926. import { Nullable } from "babylonjs/types";
  1927. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  1928. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1929. import { IScene, INode, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1930. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1931. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1932. /**
  1933. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1934. */
  1935. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1936. /**
  1937. * The name of this extension.
  1938. */
  1939. readonly name: string;
  1940. /**
  1941. * Defines whether this extension is enabled.
  1942. */
  1943. enabled: boolean;
  1944. private _loader;
  1945. private _clips;
  1946. private _emitters;
  1947. /** @hidden */
  1948. constructor(loader: GLTFLoader);
  1949. /** @hidden */
  1950. dispose(): void;
  1951. /** @hidden */
  1952. onLoading(): void;
  1953. /** @hidden */
  1954. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1955. /** @hidden */
  1956. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1957. /** @hidden */
  1958. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1959. private _loadClipAsync;
  1960. private _loadEmitterAsync;
  1961. private _getEventAction;
  1962. private _loadAnimationEventAsync;
  1963. }
  1964. }
  1965. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
  1966. import { Nullable } from "babylonjs/types";
  1967. import { Observable } from "babylonjs/Misc/observable";
  1968. import { Material } from "babylonjs/Materials/material";
  1969. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1970. import { Mesh } from "babylonjs/Meshes/mesh";
  1971. import { INode, IMaterial, IBuffer } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1972. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1973. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1974. import { IProperty } from 'babylonjs-gltf2interface';
  1975. /**
  1976. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1977. */
  1978. export class MSFT_lod implements IGLTFLoaderExtension {
  1979. /**
  1980. * The name of this extension.
  1981. */
  1982. readonly name: string;
  1983. /**
  1984. * Defines whether this extension is enabled.
  1985. */
  1986. enabled: boolean;
  1987. /**
  1988. * Defines a number that determines the order the extensions are applied.
  1989. */
  1990. order: number;
  1991. /**
  1992. * Maximum number of LODs to load, starting from the lowest LOD.
  1993. */
  1994. maxLODsToLoad: number;
  1995. /**
  1996. * Observable raised when all node LODs of one level are loaded.
  1997. * The event data is the index of the loaded LOD starting from zero.
  1998. * Dispose the loader to cancel the loading of the next level of LODs.
  1999. */
  2000. onNodeLODsLoadedObservable: Observable<number>;
  2001. /**
  2002. * Observable raised when all material LODs of one level are loaded.
  2003. * The event data is the index of the loaded LOD starting from zero.
  2004. * Dispose the loader to cancel the loading of the next level of LODs.
  2005. */
  2006. onMaterialLODsLoadedObservable: Observable<number>;
  2007. private _loader;
  2008. private _nodeIndexLOD;
  2009. private _nodeSignalLODs;
  2010. private _nodePromiseLODs;
  2011. private _materialIndexLOD;
  2012. private _materialSignalLODs;
  2013. private _materialPromiseLODs;
  2014. private _indexLOD;
  2015. private _bufferLODs;
  2016. /** @hidden */
  2017. constructor(loader: GLTFLoader);
  2018. /** @hidden */
  2019. dispose(): void;
  2020. /** @hidden */
  2021. onReady(): void;
  2022. /** @hidden */
  2023. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2024. /** @hidden */
  2025. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  2026. /** @hidden */
  2027. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  2028. /** @hidden */
  2029. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  2030. private _loadBufferLOD;
  2031. /**
  2032. * Gets an array of LOD properties from lowest to highest.
  2033. */
  2034. private _getLODs;
  2035. private _disposeUnusedMaterials;
  2036. }
  2037. }
  2038. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh" {
  2039. import { Nullable } from "babylonjs/types";
  2040. import { Material } from "babylonjs/Materials/material";
  2041. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2042. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2043. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2044. /** @hidden */
  2045. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  2046. readonly name: string;
  2047. enabled: boolean;
  2048. private _loader;
  2049. constructor(loader: GLTFLoader);
  2050. dispose(): void;
  2051. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2052. }
  2053. }
  2054. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors" {
  2055. import { Nullable } from "babylonjs/types";
  2056. import { Material } from "babylonjs/Materials/material";
  2057. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2058. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2059. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2060. /** @hidden */
  2061. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  2062. readonly name: string;
  2063. enabled: boolean;
  2064. private _loader;
  2065. constructor(loader: GLTFLoader);
  2066. dispose(): void;
  2067. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2068. }
  2069. }
  2070. declare module "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata" {
  2071. import { Nullable } from "babylonjs/types";
  2072. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2073. import { Camera } from "babylonjs/Cameras/camera";
  2074. import { INode, ICamera, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2075. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2076. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2077. import { Material } from "babylonjs/Materials/material";
  2078. /**
  2079. * Store glTF extras (if present) in BJS objects' metadata
  2080. */
  2081. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  2082. /**
  2083. * The name of this extension.
  2084. */
  2085. readonly name: string;
  2086. /**
  2087. * Defines whether this extension is enabled.
  2088. */
  2089. enabled: boolean;
  2090. private _loader;
  2091. private _assignExtras;
  2092. /** @hidden */
  2093. constructor(loader: GLTFLoader);
  2094. /** @hidden */
  2095. dispose(): void;
  2096. /** @hidden */
  2097. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2098. /** @hidden */
  2099. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  2100. /** @hidden */
  2101. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  2102. }
  2103. }
  2104. declare module "babylonjs-loaders/glTF/2.0/Extensions/index" {
  2105. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based";
  2106. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  2107. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual";
  2108. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  2109. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit";
  2110. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_clearcoat";
  2111. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular";
  2112. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform";
  2113. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter";
  2114. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod";
  2115. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh";
  2116. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors";
  2117. export * from "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata";
  2118. }
  2119. declare module "babylonjs-loaders/glTF/2.0/index" {
  2120. export * from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2121. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2122. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2123. export * from "babylonjs-loaders/glTF/2.0/Extensions/index";
  2124. }
  2125. declare module "babylonjs-loaders/glTF/index" {
  2126. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2127. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2128. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2129. export { GLTF1, GLTF2 };
  2130. }
  2131. declare module "babylonjs-loaders/OBJ/objFileLoader" {
  2132. import { Vector2 } from "babylonjs/Maths/math";
  2133. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  2134. import { Skeleton } from "babylonjs/Bones/skeleton";
  2135. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2136. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  2137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2138. import { ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin } from "babylonjs/Loading/sceneLoader";
  2139. import { AssetContainer } from "babylonjs/assetContainer";
  2140. import { Scene } from "babylonjs/scene";
  2141. /**
  2142. * Class reading and parsing the MTL file bundled with the obj file.
  2143. */
  2144. export class MTLFileLoader {
  2145. /**
  2146. * All material loaded from the mtl will be set here
  2147. */
  2148. materials: StandardMaterial[];
  2149. /**
  2150. * This function will read the mtl file and create each material described inside
  2151. * This function could be improve by adding :
  2152. * -some component missing (Ni, Tf...)
  2153. * -including the specific options available
  2154. *
  2155. * @param scene defines the scene the material will be created in
  2156. * @param data defines the mtl data to parse
  2157. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  2158. */
  2159. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  2160. /**
  2161. * Gets the texture for the material.
  2162. *
  2163. * If the material is imported from input file,
  2164. * We sanitize the url to ensure it takes the textre from aside the material.
  2165. *
  2166. * @param rootUrl The root url to load from
  2167. * @param value The value stored in the mtl
  2168. * @return The Texture
  2169. */
  2170. private static _getTexture;
  2171. }
  2172. /**
  2173. * Options for loading OBJ/MTL files
  2174. */
  2175. type MeshLoadOptions = {
  2176. /**
  2177. * Defines if UVs are optimized by default during load.
  2178. */
  2179. OptimizeWithUV: boolean;
  2180. /**
  2181. * Defines custom scaling of UV coordinates of loaded meshes.
  2182. */
  2183. UVScaling: Vector2;
  2184. /**
  2185. * Invert model on y-axis (does a model scaling inversion)
  2186. */
  2187. InvertY: boolean;
  2188. /**
  2189. * Invert Y-Axis of referenced textures on load
  2190. */
  2191. InvertTextureY: boolean;
  2192. /**
  2193. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2194. */
  2195. ImportVertexColors: boolean;
  2196. /**
  2197. * Compute the normals for the model, even if normals are present in the file.
  2198. */
  2199. ComputeNormals: boolean;
  2200. /**
  2201. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2202. */
  2203. SkipMaterials: boolean;
  2204. /**
  2205. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2206. */
  2207. MaterialLoadingFailsSilently: boolean;
  2208. };
  2209. /**
  2210. * OBJ file type loader.
  2211. * This is a babylon scene loader plugin.
  2212. */
  2213. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2214. /**
  2215. * Defines if UVs are optimized by default during load.
  2216. */
  2217. static OPTIMIZE_WITH_UV: boolean;
  2218. /**
  2219. * Invert model on y-axis (does a model scaling inversion)
  2220. */
  2221. static INVERT_Y: boolean;
  2222. /**
  2223. * Invert Y-Axis of referenced textures on load
  2224. */
  2225. static INVERT_TEXTURE_Y: boolean;
  2226. /**
  2227. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2228. */
  2229. static IMPORT_VERTEX_COLORS: boolean;
  2230. /**
  2231. * Compute the normals for the model, even if normals are present in the file.
  2232. */
  2233. static COMPUTE_NORMALS: boolean;
  2234. /**
  2235. * Defines custom scaling of UV coordinates of loaded meshes.
  2236. */
  2237. static UV_SCALING: Vector2;
  2238. /**
  2239. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2240. */
  2241. static SKIP_MATERIALS: boolean;
  2242. /**
  2243. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2244. *
  2245. * Defaults to true for backwards compatibility.
  2246. */
  2247. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2248. /**
  2249. * Defines the name of the plugin.
  2250. */
  2251. name: string;
  2252. /**
  2253. * Defines the extension the plugin is able to load.
  2254. */
  2255. extensions: string;
  2256. /** @hidden */
  2257. obj: RegExp;
  2258. /** @hidden */
  2259. group: RegExp;
  2260. /** @hidden */
  2261. mtllib: RegExp;
  2262. /** @hidden */
  2263. usemtl: RegExp;
  2264. /** @hidden */
  2265. smooth: RegExp;
  2266. /** @hidden */
  2267. vertexPattern: RegExp;
  2268. /** @hidden */
  2269. normalPattern: RegExp;
  2270. /** @hidden */
  2271. uvPattern: RegExp;
  2272. /** @hidden */
  2273. facePattern1: RegExp;
  2274. /** @hidden */
  2275. facePattern2: RegExp;
  2276. /** @hidden */
  2277. facePattern3: RegExp;
  2278. /** @hidden */
  2279. facePattern4: RegExp;
  2280. /** @hidden */
  2281. facePattern5: RegExp;
  2282. private _meshLoadOptions;
  2283. /**
  2284. * Creates loader for .OBJ files
  2285. *
  2286. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2287. */
  2288. constructor(meshLoadOptions?: MeshLoadOptions);
  2289. private static readonly currentMeshLoadOptions;
  2290. /**
  2291. * Calls synchronously the MTL file attached to this obj.
  2292. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2293. * Without this function materials are not displayed in the first frame (but displayed after).
  2294. * In consequence it is impossible to get material information in your HTML file
  2295. *
  2296. * @param url The URL of the MTL file
  2297. * @param rootUrl
  2298. * @param onSuccess Callback function to be called when the MTL file is loaded
  2299. * @private
  2300. */
  2301. private _loadMTL;
  2302. /**
  2303. * Instantiates a OBJ file loader plugin.
  2304. * @returns the created plugin
  2305. */
  2306. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2307. /**
  2308. * If the data string can be loaded directly.
  2309. *
  2310. * @param data string containing the file data
  2311. * @returns if the data can be loaded directly
  2312. */
  2313. canDirectLoad(data: string): boolean;
  2314. /**
  2315. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2316. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2317. * @param scene the scene the meshes should be added to
  2318. * @param data the OBJ data to load
  2319. * @param rootUrl root url to load from
  2320. * @param onProgress event that fires when loading progress has occured
  2321. * @param fileName Defines the name of the file to load
  2322. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2323. */
  2324. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2325. meshes: AbstractMesh[];
  2326. particleSystems: IParticleSystem[];
  2327. skeletons: Skeleton[];
  2328. animationGroups: AnimationGroup[];
  2329. }>;
  2330. /**
  2331. * Imports all objects from the loaded OBJ data and adds them to the scene
  2332. * @param scene the scene the objects should be added to
  2333. * @param data the OBJ data to load
  2334. * @param rootUrl root url to load from
  2335. * @param onProgress event that fires when loading progress has occured
  2336. * @param fileName Defines the name of the file to load
  2337. * @returns a promise which completes when objects have been loaded to the scene
  2338. */
  2339. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2340. /**
  2341. * Load into an asset container.
  2342. * @param scene The scene to load into
  2343. * @param data The data to import
  2344. * @param rootUrl The root url for scene and resources
  2345. * @param onProgress The callback when the load progresses
  2346. * @param fileName Defines the name of the file to load
  2347. * @returns The loaded asset container
  2348. */
  2349. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2350. /**
  2351. * Read the OBJ file and create an Array of meshes.
  2352. * Each mesh contains all information given by the OBJ and the MTL file.
  2353. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2354. *
  2355. * @param meshesNames
  2356. * @param scene Scene The scene where are displayed the data
  2357. * @param data String The content of the obj file
  2358. * @param rootUrl String The path to the folder
  2359. * @returns Array<AbstractMesh>
  2360. * @private
  2361. */
  2362. private _parseSolid;
  2363. }
  2364. }
  2365. declare module "babylonjs-loaders/OBJ/index" {
  2366. export * from "babylonjs-loaders/OBJ/objFileLoader";
  2367. }
  2368. declare module "babylonjs-loaders/STL/stlFileLoader" {
  2369. import { Nullable } from "babylonjs/types";
  2370. import { Skeleton } from "babylonjs/Bones/skeleton";
  2371. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2373. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  2374. import { AssetContainer } from "babylonjs/assetContainer";
  2375. import { Scene } from "babylonjs/scene";
  2376. /**
  2377. * STL file type loader.
  2378. * This is a babylon scene loader plugin.
  2379. */
  2380. export class STLFileLoader implements ISceneLoaderPlugin {
  2381. /** @hidden */
  2382. solidPattern: RegExp;
  2383. /** @hidden */
  2384. facetsPattern: RegExp;
  2385. /** @hidden */
  2386. normalPattern: RegExp;
  2387. /** @hidden */
  2388. vertexPattern: RegExp;
  2389. /**
  2390. * Defines the name of the plugin.
  2391. */
  2392. name: string;
  2393. /**
  2394. * Defines the extensions the stl loader is able to load.
  2395. * force data to come in as an ArrayBuffer
  2396. * we'll convert to string if it looks like it's an ASCII .stl
  2397. */
  2398. extensions: ISceneLoaderPluginExtensions;
  2399. /**
  2400. * Import meshes into a scene.
  2401. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2402. * @param scene The scene to import into
  2403. * @param data The data to import
  2404. * @param rootUrl The root url for scene and resources
  2405. * @param meshes The meshes array to import into
  2406. * @param particleSystems The particle systems array to import into
  2407. * @param skeletons The skeletons array to import into
  2408. * @param onError The callback when import fails
  2409. * @returns True if successful or false otherwise
  2410. */
  2411. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2412. /**
  2413. * Load into a scene.
  2414. * @param scene The scene to load into
  2415. * @param data The data to import
  2416. * @param rootUrl The root url for scene and resources
  2417. * @param onError The callback when import fails
  2418. * @returns true if successful or false otherwise
  2419. */
  2420. load(scene: Scene, data: any, rootUrl: string): boolean;
  2421. /**
  2422. * Load into an asset container.
  2423. * @param scene The scene to load into
  2424. * @param data The data to import
  2425. * @param rootUrl The root url for scene and resources
  2426. * @param onError The callback when import fails
  2427. * @returns The loaded asset container
  2428. */
  2429. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2430. private _isBinary;
  2431. private _parseBinary;
  2432. private _parseASCII;
  2433. }
  2434. }
  2435. declare module "babylonjs-loaders/STL/index" {
  2436. export * from "babylonjs-loaders/STL/stlFileLoader";
  2437. }
  2438. declare module "babylonjs-loaders/index" {
  2439. export * from "babylonjs-loaders/glTF/index";
  2440. export * from "babylonjs-loaders/OBJ/index";
  2441. export * from "babylonjs-loaders/STL/index";
  2442. }
  2443. declare module "babylonjs-loaders/legacy/legacy-glTF" {
  2444. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2445. }
  2446. declare module "babylonjs-loaders/legacy/legacy-glTF1" {
  2447. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2448. export { GLTF1 };
  2449. }
  2450. declare module "babylonjs-loaders/legacy/legacy-glTF1FileLoader" {
  2451. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2452. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2453. }
  2454. declare module "babylonjs-loaders/legacy/legacy-glTF2" {
  2455. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2456. export { GLTF2 };
  2457. }
  2458. declare module "babylonjs-loaders/legacy/legacy-glTF2FileLoader" {
  2459. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2460. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2461. }
  2462. declare module "babylonjs-loaders/legacy/legacy-glTFFileLoader" {
  2463. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2464. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2465. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2466. }
  2467. declare module "babylonjs-loaders/legacy/legacy-objFileLoader" {
  2468. export * from "babylonjs-loaders/OBJ/index";
  2469. }
  2470. declare module "babylonjs-loaders/legacy/legacy-stlFileLoader" {
  2471. export * from "babylonjs-loaders/STL/index";
  2472. }
  2473. declare module "babylonjs-loaders/legacy/legacy" {
  2474. import "babylonjs-loaders/index";
  2475. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2476. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2477. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2478. export * from "babylonjs-loaders/legacy/legacy-objFileLoader";
  2479. export * from "babylonjs-loaders/legacy/legacy-stlFileLoader";
  2480. }
  2481. declare module "babylonjs-loaders" {
  2482. export * from "babylonjs-loaders/legacy/legacy";
  2483. }
  2484. declare module BABYLON {
  2485. /**
  2486. * Mode that determines the coordinate system to use.
  2487. */
  2488. export enum GLTFLoaderCoordinateSystemMode {
  2489. /**
  2490. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2491. */
  2492. AUTO = 0,
  2493. /**
  2494. * Sets the useRightHandedSystem flag on the scene.
  2495. */
  2496. FORCE_RIGHT_HANDED = 1
  2497. }
  2498. /**
  2499. * Mode that determines what animations will start.
  2500. */
  2501. export enum GLTFLoaderAnimationStartMode {
  2502. /**
  2503. * No animation will start.
  2504. */
  2505. NONE = 0,
  2506. /**
  2507. * The first animation will start.
  2508. */
  2509. FIRST = 1,
  2510. /**
  2511. * All animations will start.
  2512. */
  2513. ALL = 2
  2514. }
  2515. /**
  2516. * Interface that contains the data for the glTF asset.
  2517. */
  2518. export interface IGLTFLoaderData {
  2519. /**
  2520. * The object that represents the glTF JSON.
  2521. */
  2522. json: Object;
  2523. /**
  2524. * The BIN chunk of a binary glTF.
  2525. */
  2526. bin: Nullable<IDataBuffer>;
  2527. }
  2528. /**
  2529. * Interface for extending the loader.
  2530. */
  2531. export interface IGLTFLoaderExtension {
  2532. /**
  2533. * The name of this extension.
  2534. */
  2535. readonly name: string;
  2536. /**
  2537. * Defines whether this extension is enabled.
  2538. */
  2539. enabled: boolean;
  2540. /**
  2541. * Defines the order of this extension.
  2542. * The loader sorts the extensions using these values when loading.
  2543. */
  2544. order?: number;
  2545. }
  2546. /**
  2547. * Loader state.
  2548. */
  2549. export enum GLTFLoaderState {
  2550. /**
  2551. * The asset is loading.
  2552. */
  2553. LOADING = 0,
  2554. /**
  2555. * The asset is ready for rendering.
  2556. */
  2557. READY = 1,
  2558. /**
  2559. * The asset is completely loaded.
  2560. */
  2561. COMPLETE = 2
  2562. }
  2563. /** @hidden */
  2564. export interface IGLTFLoader extends IDisposable {
  2565. readonly state: Nullable<GLTFLoaderState>;
  2566. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  2567. meshes: AbstractMesh[];
  2568. particleSystems: IParticleSystem[];
  2569. skeletons: Skeleton[];
  2570. animationGroups: AnimationGroup[];
  2571. }>;
  2572. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  2573. }
  2574. /**
  2575. * File loader for loading glTF files into a scene.
  2576. */
  2577. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2578. /** @hidden */
  2579. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2580. /** @hidden */
  2581. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2582. /**
  2583. * Raised when the asset has been parsed
  2584. */
  2585. onParsedObservable: Observable<IGLTFLoaderData>;
  2586. private _onParsedObserver;
  2587. /**
  2588. * Raised when the asset has been parsed
  2589. */
  2590. onParsed: (loaderData: IGLTFLoaderData) => void;
  2591. /**
  2592. * 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.
  2593. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  2594. * Defaults to true.
  2595. * @hidden
  2596. */
  2597. static IncrementalLoading: boolean;
  2598. /**
  2599. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  2600. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  2601. * @hidden
  2602. */
  2603. static HomogeneousCoordinates: boolean;
  2604. /**
  2605. * The coordinate system mode. Defaults to AUTO.
  2606. */
  2607. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  2608. /**
  2609. * The animation start mode. Defaults to FIRST.
  2610. */
  2611. animationStartMode: GLTFLoaderAnimationStartMode;
  2612. /**
  2613. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  2614. */
  2615. compileMaterials: boolean;
  2616. /**
  2617. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  2618. */
  2619. useClipPlane: boolean;
  2620. /**
  2621. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  2622. */
  2623. compileShadowGenerators: boolean;
  2624. /**
  2625. * Defines if the Alpha blended materials are only applied as coverage.
  2626. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  2627. * If true, no extra effects are applied to transparent pixels.
  2628. */
  2629. transparencyAsCoverage: boolean;
  2630. /**
  2631. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  2632. * Enabling will disable offline support and glTF validator.
  2633. * Defaults to false.
  2634. */
  2635. useRangeRequests: boolean;
  2636. /**
  2637. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  2638. */
  2639. createInstances: boolean;
  2640. /**
  2641. * Function called before loading a url referenced by the asset.
  2642. */
  2643. preprocessUrlAsync: (url: string) => Promise<string>;
  2644. /**
  2645. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2646. */
  2647. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  2648. private _onMeshLoadedObserver;
  2649. /**
  2650. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2651. */
  2652. onMeshLoaded: (mesh: AbstractMesh) => void;
  2653. /**
  2654. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  2655. */
  2656. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  2657. private _onTextureLoadedObserver;
  2658. /**
  2659. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  2660. */
  2661. onTextureLoaded: (texture: BaseTexture) => void;
  2662. /**
  2663. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  2664. */
  2665. readonly onMaterialLoadedObservable: Observable<Material>;
  2666. private _onMaterialLoadedObserver;
  2667. /**
  2668. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  2669. */
  2670. onMaterialLoaded: (material: Material) => void;
  2671. /**
  2672. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  2673. */
  2674. readonly onCameraLoadedObservable: Observable<Camera>;
  2675. private _onCameraLoadedObserver;
  2676. /**
  2677. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  2678. */
  2679. onCameraLoaded: (camera: Camera) => void;
  2680. /**
  2681. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  2682. * For assets with LODs, raised when all of the LODs are complete.
  2683. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2684. */
  2685. readonly onCompleteObservable: Observable<void>;
  2686. private _onCompleteObserver;
  2687. /**
  2688. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  2689. * For assets with LODs, raised when all of the LODs are complete.
  2690. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2691. */
  2692. onComplete: () => void;
  2693. /**
  2694. * Observable raised when an error occurs.
  2695. */
  2696. readonly onErrorObservable: Observable<any>;
  2697. private _onErrorObserver;
  2698. /**
  2699. * Callback raised when an error occurs.
  2700. */
  2701. onError: (reason: any) => void;
  2702. /**
  2703. * Observable raised after the loader is disposed.
  2704. */
  2705. readonly onDisposeObservable: Observable<void>;
  2706. private _onDisposeObserver;
  2707. /**
  2708. * Callback raised after the loader is disposed.
  2709. */
  2710. onDispose: () => void;
  2711. /**
  2712. * Observable raised after a loader extension is created.
  2713. * Set additional options for a loader extension in this event.
  2714. */
  2715. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  2716. private _onExtensionLoadedObserver;
  2717. /**
  2718. * Callback raised after a loader extension is created.
  2719. */
  2720. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  2721. /**
  2722. * Defines if the loader logging is enabled.
  2723. */
  2724. loggingEnabled: boolean;
  2725. /**
  2726. * Defines if the loader should capture performance counters.
  2727. */
  2728. capturePerformanceCounters: boolean;
  2729. /**
  2730. * Defines if the loader should validate the asset.
  2731. */
  2732. validate: boolean;
  2733. /**
  2734. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  2735. */
  2736. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  2737. private _onValidatedObserver;
  2738. /**
  2739. * Callback raised after a loader extension is created.
  2740. */
  2741. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  2742. private _loader;
  2743. /**
  2744. * Name of the loader ("gltf")
  2745. */
  2746. name: string;
  2747. /** @hidden */
  2748. extensions: ISceneLoaderPluginExtensions;
  2749. /**
  2750. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  2751. */
  2752. dispose(): void;
  2753. /** @hidden */
  2754. _clear(): void;
  2755. /** @hidden */
  2756. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  2757. /** @hidden */
  2758. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  2759. /** @hidden */
  2760. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2761. meshes: AbstractMesh[];
  2762. particleSystems: IParticleSystem[];
  2763. skeletons: Skeleton[];
  2764. animationGroups: AnimationGroup[];
  2765. }>;
  2766. /** @hidden */
  2767. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2768. /** @hidden */
  2769. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2770. /** @hidden */
  2771. canDirectLoad(data: string): boolean;
  2772. /** @hidden */
  2773. directLoad(scene: Scene, data: string): any;
  2774. /**
  2775. * The callback that allows custom handling of the root url based on the response url.
  2776. * @param rootUrl the original root url
  2777. * @param responseURL the response url if available
  2778. * @returns the new root url
  2779. */
  2780. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  2781. /** @hidden */
  2782. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  2783. /**
  2784. * The loader state or null if the loader is not active.
  2785. */
  2786. readonly loaderState: Nullable<GLTFLoaderState>;
  2787. /**
  2788. * Returns a promise that resolves when the asset is completely loaded.
  2789. * @returns a promise that resolves when the asset is completely loaded.
  2790. */
  2791. whenCompleteAsync(): Promise<void>;
  2792. private _validateAsync;
  2793. private _getLoader;
  2794. private _parseJson;
  2795. private _unpackBinaryAsync;
  2796. private _unpackBinaryV1Async;
  2797. private _unpackBinaryV2Async;
  2798. private static _parseVersion;
  2799. private static _compareVersion;
  2800. private static readonly _logSpaces;
  2801. private _logIndentLevel;
  2802. private _loggingEnabled;
  2803. /** @hidden */
  2804. _log: (message: string) => void;
  2805. /** @hidden */
  2806. _logOpen(message: string): void;
  2807. /** @hidden */
  2808. _logClose(): void;
  2809. private _logEnabled;
  2810. private _logDisabled;
  2811. private _capturePerformanceCounters;
  2812. /** @hidden */
  2813. _startPerformanceCounter: (counterName: string) => void;
  2814. /** @hidden */
  2815. _endPerformanceCounter: (counterName: string) => void;
  2816. private _startPerformanceCounterEnabled;
  2817. private _startPerformanceCounterDisabled;
  2818. private _endPerformanceCounterEnabled;
  2819. private _endPerformanceCounterDisabled;
  2820. }
  2821. }
  2822. declare module BABYLON.GLTF1 {
  2823. /**
  2824. * Enums
  2825. * @hidden
  2826. */
  2827. export enum EComponentType {
  2828. BYTE = 5120,
  2829. UNSIGNED_BYTE = 5121,
  2830. SHORT = 5122,
  2831. UNSIGNED_SHORT = 5123,
  2832. FLOAT = 5126
  2833. }
  2834. /** @hidden */
  2835. export enum EShaderType {
  2836. FRAGMENT = 35632,
  2837. VERTEX = 35633
  2838. }
  2839. /** @hidden */
  2840. export enum EParameterType {
  2841. BYTE = 5120,
  2842. UNSIGNED_BYTE = 5121,
  2843. SHORT = 5122,
  2844. UNSIGNED_SHORT = 5123,
  2845. INT = 5124,
  2846. UNSIGNED_INT = 5125,
  2847. FLOAT = 5126,
  2848. FLOAT_VEC2 = 35664,
  2849. FLOAT_VEC3 = 35665,
  2850. FLOAT_VEC4 = 35666,
  2851. INT_VEC2 = 35667,
  2852. INT_VEC3 = 35668,
  2853. INT_VEC4 = 35669,
  2854. BOOL = 35670,
  2855. BOOL_VEC2 = 35671,
  2856. BOOL_VEC3 = 35672,
  2857. BOOL_VEC4 = 35673,
  2858. FLOAT_MAT2 = 35674,
  2859. FLOAT_MAT3 = 35675,
  2860. FLOAT_MAT4 = 35676,
  2861. SAMPLER_2D = 35678
  2862. }
  2863. /** @hidden */
  2864. export enum ETextureWrapMode {
  2865. CLAMP_TO_EDGE = 33071,
  2866. MIRRORED_REPEAT = 33648,
  2867. REPEAT = 10497
  2868. }
  2869. /** @hidden */
  2870. export enum ETextureFilterType {
  2871. NEAREST = 9728,
  2872. LINEAR = 9728,
  2873. NEAREST_MIPMAP_NEAREST = 9984,
  2874. LINEAR_MIPMAP_NEAREST = 9985,
  2875. NEAREST_MIPMAP_LINEAR = 9986,
  2876. LINEAR_MIPMAP_LINEAR = 9987
  2877. }
  2878. /** @hidden */
  2879. export enum ETextureFormat {
  2880. ALPHA = 6406,
  2881. RGB = 6407,
  2882. RGBA = 6408,
  2883. LUMINANCE = 6409,
  2884. LUMINANCE_ALPHA = 6410
  2885. }
  2886. /** @hidden */
  2887. export enum ECullingType {
  2888. FRONT = 1028,
  2889. BACK = 1029,
  2890. FRONT_AND_BACK = 1032
  2891. }
  2892. /** @hidden */
  2893. export enum EBlendingFunction {
  2894. ZERO = 0,
  2895. ONE = 1,
  2896. SRC_COLOR = 768,
  2897. ONE_MINUS_SRC_COLOR = 769,
  2898. DST_COLOR = 774,
  2899. ONE_MINUS_DST_COLOR = 775,
  2900. SRC_ALPHA = 770,
  2901. ONE_MINUS_SRC_ALPHA = 771,
  2902. DST_ALPHA = 772,
  2903. ONE_MINUS_DST_ALPHA = 773,
  2904. CONSTANT_COLOR = 32769,
  2905. ONE_MINUS_CONSTANT_COLOR = 32770,
  2906. CONSTANT_ALPHA = 32771,
  2907. ONE_MINUS_CONSTANT_ALPHA = 32772,
  2908. SRC_ALPHA_SATURATE = 776
  2909. }
  2910. /** @hidden */
  2911. export interface IGLTFProperty {
  2912. extensions?: {
  2913. [key: string]: any;
  2914. };
  2915. extras?: Object;
  2916. }
  2917. /** @hidden */
  2918. export interface IGLTFChildRootProperty extends IGLTFProperty {
  2919. name?: string;
  2920. }
  2921. /** @hidden */
  2922. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  2923. bufferView: string;
  2924. byteOffset: number;
  2925. byteStride: number;
  2926. count: number;
  2927. type: string;
  2928. componentType: EComponentType;
  2929. max?: number[];
  2930. min?: number[];
  2931. name?: string;
  2932. }
  2933. /** @hidden */
  2934. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  2935. buffer: string;
  2936. byteOffset: number;
  2937. byteLength: number;
  2938. byteStride: number;
  2939. target?: number;
  2940. }
  2941. /** @hidden */
  2942. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  2943. uri: string;
  2944. byteLength?: number;
  2945. type?: string;
  2946. }
  2947. /** @hidden */
  2948. export interface IGLTFShader extends IGLTFChildRootProperty {
  2949. uri: string;
  2950. type: EShaderType;
  2951. }
  2952. /** @hidden */
  2953. export interface IGLTFProgram extends IGLTFChildRootProperty {
  2954. attributes: string[];
  2955. fragmentShader: string;
  2956. vertexShader: string;
  2957. }
  2958. /** @hidden */
  2959. export interface IGLTFTechniqueParameter {
  2960. type: number;
  2961. count?: number;
  2962. semantic?: string;
  2963. node?: string;
  2964. value?: number | boolean | string | Array<any>;
  2965. source?: string;
  2966. babylonValue?: any;
  2967. }
  2968. /** @hidden */
  2969. export interface IGLTFTechniqueCommonProfile {
  2970. lightingModel: string;
  2971. texcoordBindings: Object;
  2972. parameters?: Array<any>;
  2973. }
  2974. /** @hidden */
  2975. export interface IGLTFTechniqueStatesFunctions {
  2976. blendColor?: number[];
  2977. blendEquationSeparate?: number[];
  2978. blendFuncSeparate?: number[];
  2979. colorMask: boolean[];
  2980. cullFace: number[];
  2981. }
  2982. /** @hidden */
  2983. export interface IGLTFTechniqueStates {
  2984. enable: number[];
  2985. functions: IGLTFTechniqueStatesFunctions;
  2986. }
  2987. /** @hidden */
  2988. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  2989. parameters: {
  2990. [key: string]: IGLTFTechniqueParameter;
  2991. };
  2992. program: string;
  2993. attributes: {
  2994. [key: string]: string;
  2995. };
  2996. uniforms: {
  2997. [key: string]: string;
  2998. };
  2999. states: IGLTFTechniqueStates;
  3000. }
  3001. /** @hidden */
  3002. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  3003. technique?: string;
  3004. values: string[];
  3005. }
  3006. /** @hidden */
  3007. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  3008. attributes: {
  3009. [key: string]: string;
  3010. };
  3011. indices: string;
  3012. material: string;
  3013. mode?: number;
  3014. }
  3015. /** @hidden */
  3016. export interface IGLTFMesh extends IGLTFChildRootProperty {
  3017. primitives: IGLTFMeshPrimitive[];
  3018. }
  3019. /** @hidden */
  3020. export interface IGLTFImage extends IGLTFChildRootProperty {
  3021. uri: string;
  3022. }
  3023. /** @hidden */
  3024. export interface IGLTFSampler extends IGLTFChildRootProperty {
  3025. magFilter?: number;
  3026. minFilter?: number;
  3027. wrapS?: number;
  3028. wrapT?: number;
  3029. }
  3030. /** @hidden */
  3031. export interface IGLTFTexture extends IGLTFChildRootProperty {
  3032. sampler: string;
  3033. source: string;
  3034. format?: ETextureFormat;
  3035. internalFormat?: ETextureFormat;
  3036. target?: number;
  3037. type?: number;
  3038. babylonTexture?: Texture;
  3039. }
  3040. /** @hidden */
  3041. export interface IGLTFAmbienLight {
  3042. color?: number[];
  3043. }
  3044. /** @hidden */
  3045. export interface IGLTFDirectionalLight {
  3046. color?: number[];
  3047. }
  3048. /** @hidden */
  3049. export interface IGLTFPointLight {
  3050. color?: number[];
  3051. constantAttenuation?: number;
  3052. linearAttenuation?: number;
  3053. quadraticAttenuation?: number;
  3054. }
  3055. /** @hidden */
  3056. export interface IGLTFSpotLight {
  3057. color?: number[];
  3058. constantAttenuation?: number;
  3059. fallOfAngle?: number;
  3060. fallOffExponent?: number;
  3061. linearAttenuation?: number;
  3062. quadraticAttenuation?: number;
  3063. }
  3064. /** @hidden */
  3065. export interface IGLTFLight extends IGLTFChildRootProperty {
  3066. type: string;
  3067. }
  3068. /** @hidden */
  3069. export interface IGLTFCameraOrthographic {
  3070. xmag: number;
  3071. ymag: number;
  3072. zfar: number;
  3073. znear: number;
  3074. }
  3075. /** @hidden */
  3076. export interface IGLTFCameraPerspective {
  3077. aspectRatio: number;
  3078. yfov: number;
  3079. zfar: number;
  3080. znear: number;
  3081. }
  3082. /** @hidden */
  3083. export interface IGLTFCamera extends IGLTFChildRootProperty {
  3084. type: string;
  3085. }
  3086. /** @hidden */
  3087. export interface IGLTFAnimationChannelTarget {
  3088. id: string;
  3089. path: string;
  3090. }
  3091. /** @hidden */
  3092. export interface IGLTFAnimationChannel {
  3093. sampler: string;
  3094. target: IGLTFAnimationChannelTarget;
  3095. }
  3096. /** @hidden */
  3097. export interface IGLTFAnimationSampler {
  3098. input: string;
  3099. output: string;
  3100. interpolation?: string;
  3101. }
  3102. /** @hidden */
  3103. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  3104. channels?: IGLTFAnimationChannel[];
  3105. parameters?: {
  3106. [key: string]: string;
  3107. };
  3108. samplers?: {
  3109. [key: string]: IGLTFAnimationSampler;
  3110. };
  3111. }
  3112. /** @hidden */
  3113. export interface IGLTFNodeInstanceSkin {
  3114. skeletons: string[];
  3115. skin: string;
  3116. meshes: string[];
  3117. }
  3118. /** @hidden */
  3119. export interface IGLTFSkins extends IGLTFChildRootProperty {
  3120. bindShapeMatrix: number[];
  3121. inverseBindMatrices: string;
  3122. jointNames: string[];
  3123. babylonSkeleton?: Skeleton;
  3124. }
  3125. /** @hidden */
  3126. export interface IGLTFNode extends IGLTFChildRootProperty {
  3127. camera?: string;
  3128. children: string[];
  3129. skin?: string;
  3130. jointName?: string;
  3131. light?: string;
  3132. matrix: number[];
  3133. mesh?: string;
  3134. meshes?: string[];
  3135. rotation?: number[];
  3136. scale?: number[];
  3137. translation?: number[];
  3138. babylonNode?: Node;
  3139. }
  3140. /** @hidden */
  3141. export interface IGLTFScene extends IGLTFChildRootProperty {
  3142. nodes: string[];
  3143. }
  3144. /** @hidden */
  3145. export interface IGLTFRuntime {
  3146. extensions: {
  3147. [key: string]: any;
  3148. };
  3149. accessors: {
  3150. [key: string]: IGLTFAccessor;
  3151. };
  3152. buffers: {
  3153. [key: string]: IGLTFBuffer;
  3154. };
  3155. bufferViews: {
  3156. [key: string]: IGLTFBufferView;
  3157. };
  3158. meshes: {
  3159. [key: string]: IGLTFMesh;
  3160. };
  3161. lights: {
  3162. [key: string]: IGLTFLight;
  3163. };
  3164. cameras: {
  3165. [key: string]: IGLTFCamera;
  3166. };
  3167. nodes: {
  3168. [key: string]: IGLTFNode;
  3169. };
  3170. images: {
  3171. [key: string]: IGLTFImage;
  3172. };
  3173. textures: {
  3174. [key: string]: IGLTFTexture;
  3175. };
  3176. shaders: {
  3177. [key: string]: IGLTFShader;
  3178. };
  3179. programs: {
  3180. [key: string]: IGLTFProgram;
  3181. };
  3182. samplers: {
  3183. [key: string]: IGLTFSampler;
  3184. };
  3185. techniques: {
  3186. [key: string]: IGLTFTechnique;
  3187. };
  3188. materials: {
  3189. [key: string]: IGLTFMaterial;
  3190. };
  3191. animations: {
  3192. [key: string]: IGLTFAnimation;
  3193. };
  3194. skins: {
  3195. [key: string]: IGLTFSkins;
  3196. };
  3197. currentScene?: Object;
  3198. scenes: {
  3199. [key: string]: IGLTFScene;
  3200. };
  3201. extensionsUsed: string[];
  3202. extensionsRequired?: string[];
  3203. buffersCount: number;
  3204. shaderscount: number;
  3205. scene: Scene;
  3206. rootUrl: string;
  3207. loadedBufferCount: number;
  3208. loadedBufferViews: {
  3209. [name: string]: ArrayBufferView;
  3210. };
  3211. loadedShaderCount: number;
  3212. importOnlyMeshes: boolean;
  3213. importMeshesNames?: string[];
  3214. dummyNodes: Node[];
  3215. }
  3216. /** @hidden */
  3217. export interface INodeToRoot {
  3218. bone: Bone;
  3219. node: IGLTFNode;
  3220. id: string;
  3221. }
  3222. /** @hidden */
  3223. export interface IJointNode {
  3224. node: IGLTFNode;
  3225. id: string;
  3226. }
  3227. }
  3228. declare module BABYLON.GLTF1 {
  3229. /**
  3230. * Utils functions for GLTF
  3231. * @hidden
  3232. */
  3233. export class GLTFUtils {
  3234. /**
  3235. * Sets the given "parameter" matrix
  3236. * @param scene: the Scene object
  3237. * @param source: the source node where to pick the matrix
  3238. * @param parameter: the GLTF technique parameter
  3239. * @param uniformName: the name of the shader's uniform
  3240. * @param shaderMaterial: the shader material
  3241. */
  3242. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  3243. /**
  3244. * Sets the given "parameter" matrix
  3245. * @param shaderMaterial: the shader material
  3246. * @param uniform: the name of the shader's uniform
  3247. * @param value: the value of the uniform
  3248. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3249. */
  3250. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  3251. /**
  3252. * Returns the wrap mode of the texture
  3253. * @param mode: the mode value
  3254. */
  3255. static GetWrapMode(mode: number): number;
  3256. /**
  3257. * Returns the byte stride giving an accessor
  3258. * @param accessor: the GLTF accessor objet
  3259. */
  3260. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  3261. /**
  3262. * Returns the texture filter mode giving a mode value
  3263. * @param mode: the filter mode value
  3264. */
  3265. static GetTextureFilterMode(mode: number): ETextureFilterType;
  3266. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  3267. /**
  3268. * Returns a buffer from its accessor
  3269. * @param gltfRuntime: the GLTF runtime
  3270. * @param accessor: the GLTF accessor
  3271. */
  3272. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  3273. /**
  3274. * Decodes a buffer view into a string
  3275. * @param view: the buffer view
  3276. */
  3277. static DecodeBufferToText(view: ArrayBufferView): string;
  3278. /**
  3279. * Returns the default material of gltf. Related to
  3280. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3281. * @param scene: the Babylon.js scene
  3282. */
  3283. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  3284. private static _DefaultMaterial;
  3285. }
  3286. }
  3287. declare module BABYLON.GLTF1 {
  3288. /**
  3289. * Implementation of the base glTF spec
  3290. * @hidden
  3291. */
  3292. export class GLTFLoaderBase {
  3293. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  3294. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3295. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  3296. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3297. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  3298. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3299. }
  3300. /**
  3301. * glTF V1 Loader
  3302. * @hidden
  3303. */
  3304. export class GLTFLoader implements IGLTFLoader {
  3305. static Extensions: {
  3306. [name: string]: GLTFLoaderExtension;
  3307. };
  3308. static RegisterExtension(extension: GLTFLoaderExtension): void;
  3309. state: Nullable<GLTFLoaderState>;
  3310. dispose(): void;
  3311. private _importMeshAsync;
  3312. /**
  3313. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3314. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3315. * @param scene the scene the meshes should be added to
  3316. * @param data gltf data containing information of the meshes in a loaded file
  3317. * @param rootUrl root url to load from
  3318. * @param onProgress event that fires when loading progress has occured
  3319. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3320. */
  3321. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  3322. meshes: AbstractMesh[];
  3323. particleSystems: IParticleSystem[];
  3324. skeletons: Skeleton[];
  3325. animationGroups: AnimationGroup[];
  3326. }>;
  3327. private _loadAsync;
  3328. /**
  3329. * Imports all objects from a loaded gltf file and adds them to the scene
  3330. * @param scene the scene the objects should be added to
  3331. * @param data gltf data containing information of the meshes in a loaded file
  3332. * @param rootUrl root url to load from
  3333. * @param onProgress event that fires when loading progress has occured
  3334. * @returns a promise which completes when objects have been loaded to the scene
  3335. */
  3336. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  3337. private _loadShadersAsync;
  3338. private _loadBuffersAsync;
  3339. private _createNodes;
  3340. }
  3341. /** @hidden */
  3342. export abstract class GLTFLoaderExtension {
  3343. private _name;
  3344. constructor(name: string);
  3345. readonly name: string;
  3346. /**
  3347. * Defines an override for loading the runtime
  3348. * Return true to stop further extensions from loading the runtime
  3349. */
  3350. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  3351. /**
  3352. * Defines an onverride for creating gltf runtime
  3353. * Return true to stop further extensions from creating the runtime
  3354. */
  3355. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  3356. /**
  3357. * Defines an override for loading buffers
  3358. * Return true to stop further extensions from loading this buffer
  3359. */
  3360. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  3361. /**
  3362. * Defines an override for loading texture buffers
  3363. * Return true to stop further extensions from loading this texture data
  3364. */
  3365. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3366. /**
  3367. * Defines an override for creating textures
  3368. * Return true to stop further extensions from loading this texture
  3369. */
  3370. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  3371. /**
  3372. * Defines an override for loading shader strings
  3373. * Return true to stop further extensions from loading this shader data
  3374. */
  3375. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3376. /**
  3377. * Defines an override for loading materials
  3378. * Return true to stop further extensions from loading this material
  3379. */
  3380. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3381. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  3382. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  3383. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3384. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3385. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  3386. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3387. private static LoadTextureBufferAsync;
  3388. private static CreateTextureAsync;
  3389. private static ApplyExtensions;
  3390. }
  3391. }
  3392. declare module BABYLON.GLTF1 {
  3393. /** @hidden */
  3394. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  3395. private _bin;
  3396. constructor();
  3397. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  3398. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3399. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3400. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3401. }
  3402. }
  3403. declare module BABYLON.GLTF1 {
  3404. /** @hidden */
  3405. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  3406. constructor();
  3407. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  3408. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3409. private _loadTexture;
  3410. }
  3411. }
  3412. declare module BABYLON.GLTF2.Loader {
  3413. /**
  3414. * Loader interface with an index field.
  3415. */
  3416. export interface IArrayItem {
  3417. /**
  3418. * The index of this item in the array.
  3419. */
  3420. index: number;
  3421. }
  3422. /**
  3423. * Loader interface with additional members.
  3424. */
  3425. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3426. /** @hidden */
  3427. _data?: Promise<ArrayBufferView>;
  3428. /** @hidden */
  3429. _babylonVertexBuffer?: Promise<VertexBuffer>;
  3430. }
  3431. /**
  3432. * Loader interface with additional members.
  3433. */
  3434. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3435. }
  3436. /** @hidden */
  3437. export interface _IAnimationSamplerData {
  3438. input: Float32Array;
  3439. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3440. output: Float32Array;
  3441. }
  3442. /**
  3443. * Loader interface with additional members.
  3444. */
  3445. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3446. /** @hidden */
  3447. _data?: Promise<_IAnimationSamplerData>;
  3448. }
  3449. /**
  3450. * Loader interface with additional members.
  3451. */
  3452. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3453. channels: IAnimationChannel[];
  3454. samplers: IAnimationSampler[];
  3455. /** @hidden */
  3456. _babylonAnimationGroup?: AnimationGroup;
  3457. }
  3458. /**
  3459. * Loader interface with additional members.
  3460. */
  3461. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3462. /** @hidden */
  3463. _data?: Promise<ArrayBufferView>;
  3464. }
  3465. /**
  3466. * Loader interface with additional members.
  3467. */
  3468. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3469. /** @hidden */
  3470. _data?: Promise<ArrayBufferView>;
  3471. /** @hidden */
  3472. _babylonBuffer?: Promise<Buffer>;
  3473. }
  3474. /**
  3475. * Loader interface with additional members.
  3476. */
  3477. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3478. }
  3479. /**
  3480. * Loader interface with additional members.
  3481. */
  3482. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3483. /** @hidden */
  3484. _data?: Promise<ArrayBufferView>;
  3485. }
  3486. /**
  3487. * Loader interface with additional members.
  3488. */
  3489. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  3490. }
  3491. /**
  3492. * Loader interface with additional members.
  3493. */
  3494. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  3495. }
  3496. /**
  3497. * Loader interface with additional members.
  3498. */
  3499. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3500. baseColorTexture?: ITextureInfo;
  3501. metallicRoughnessTexture?: ITextureInfo;
  3502. }
  3503. /**
  3504. * Loader interface with additional members.
  3505. */
  3506. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3507. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3508. normalTexture?: IMaterialNormalTextureInfo;
  3509. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3510. emissiveTexture?: ITextureInfo;
  3511. /** @hidden */
  3512. _data?: {
  3513. [babylonDrawMode: number]: {
  3514. babylonMaterial: Material;
  3515. babylonMeshes: AbstractMesh[];
  3516. promise: Promise<void>;
  3517. };
  3518. };
  3519. }
  3520. /**
  3521. * Loader interface with additional members.
  3522. */
  3523. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3524. primitives: IMeshPrimitive[];
  3525. }
  3526. /**
  3527. * Loader interface with additional members.
  3528. */
  3529. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3530. /** @hidden */
  3531. _instanceData?: {
  3532. babylonSourceMesh: Mesh;
  3533. promise: Promise<any>;
  3534. };
  3535. }
  3536. /**
  3537. * Loader interface with additional members.
  3538. */
  3539. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  3540. /**
  3541. * The parent glTF node.
  3542. */
  3543. parent?: INode;
  3544. /** @hidden */
  3545. _babylonTransformNode?: TransformNode;
  3546. /** @hidden */
  3547. _primitiveBabylonMeshes?: AbstractMesh[];
  3548. /** @hidden */
  3549. _babylonBones?: Bone[];
  3550. /** @hidden */
  3551. _numMorphTargets?: number;
  3552. }
  3553. /** @hidden */
  3554. export interface _ISamplerData {
  3555. noMipMaps: boolean;
  3556. samplingMode: number;
  3557. wrapU: number;
  3558. wrapV: number;
  3559. }
  3560. /**
  3561. * Loader interface with additional members.
  3562. */
  3563. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  3564. /** @hidden */
  3565. _data?: _ISamplerData;
  3566. }
  3567. /**
  3568. * Loader interface with additional members.
  3569. */
  3570. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  3571. }
  3572. /**
  3573. * Loader interface with additional members.
  3574. */
  3575. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  3576. /** @hidden */
  3577. _data?: {
  3578. babylonSkeleton: Skeleton;
  3579. promise: Promise<void>;
  3580. };
  3581. }
  3582. /**
  3583. * Loader interface with additional members.
  3584. */
  3585. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  3586. }
  3587. /**
  3588. * Loader interface with additional members.
  3589. */
  3590. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  3591. }
  3592. /**
  3593. * Loader interface with additional members.
  3594. */
  3595. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  3596. accessors?: IAccessor[];
  3597. animations?: IAnimation[];
  3598. buffers?: IBuffer[];
  3599. bufferViews?: IBufferView[];
  3600. cameras?: ICamera[];
  3601. images?: IImage[];
  3602. materials?: IMaterial[];
  3603. meshes?: IMesh[];
  3604. nodes?: INode[];
  3605. samplers?: ISampler[];
  3606. scenes?: IScene[];
  3607. skins?: ISkin[];
  3608. textures?: ITexture[];
  3609. }
  3610. }
  3611. declare module BABYLON.GLTF2 {
  3612. /**
  3613. * Interface for a glTF loader extension.
  3614. */
  3615. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  3616. /**
  3617. * Called after the loader state changes to LOADING.
  3618. */
  3619. onLoading?(): void;
  3620. /**
  3621. * Called after the loader state changes to READY.
  3622. */
  3623. onReady?(): void;
  3624. /**
  3625. * Define this method to modify the default behavior when loading scenes.
  3626. * @param context The context when loading the asset
  3627. * @param scene The glTF scene property
  3628. * @returns A promise that resolves when the load is complete or null if not handled
  3629. */
  3630. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  3631. /**
  3632. * Define this method to modify the default behavior when loading nodes.
  3633. * @param context The context when loading the asset
  3634. * @param node The glTF node property
  3635. * @param assign A function called synchronously after parsing the glTF properties
  3636. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  3637. */
  3638. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3639. /**
  3640. * Define this method to modify the default behavior when loading cameras.
  3641. * @param context The context when loading the asset
  3642. * @param camera The glTF camera property
  3643. * @param assign A function called synchronously after parsing the glTF properties
  3644. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  3645. */
  3646. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  3647. /**
  3648. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  3649. * @param context The context when loading the asset
  3650. * @param primitive The glTF mesh primitive property
  3651. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  3652. */
  3653. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  3654. /**
  3655. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  3656. * @param context The context when loading the asset
  3657. * @param name The mesh name when loading the asset
  3658. * @param node The glTF node when loading the asset
  3659. * @param mesh The glTF mesh when loading the asset
  3660. * @param primitive The glTF mesh primitive property
  3661. * @param assign A function called synchronously after parsing the glTF properties
  3662. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  3663. */
  3664. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  3665. /**
  3666. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  3667. * @param context The context when loading the asset
  3668. * @param material The glTF material property
  3669. * @param assign A function called synchronously after parsing the glTF properties
  3670. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  3671. */
  3672. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  3673. /**
  3674. * Define this method to modify the default behavior when creating materials.
  3675. * @param context The context when loading the asset
  3676. * @param material The glTF material property
  3677. * @param babylonDrawMode The draw mode for the Babylon material
  3678. * @returns The Babylon material or null if not handled
  3679. */
  3680. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  3681. /**
  3682. * Define this method to modify the default behavior when loading material properties.
  3683. * @param context The context when loading the asset
  3684. * @param material The glTF material property
  3685. * @param babylonMaterial The Babylon material
  3686. * @returns A promise that resolves when the load is complete or null if not handled
  3687. */
  3688. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3689. /**
  3690. * Define this method to modify the default behavior when loading texture infos.
  3691. * @param context The context when loading the asset
  3692. * @param textureInfo The glTF texture info property
  3693. * @param assign A function called synchronously after parsing the glTF properties
  3694. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  3695. */
  3696. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3697. /**
  3698. * Define this method to modify the default behavior when loading animations.
  3699. * @param context The context when loading the asset
  3700. * @param animation The glTF animation property
  3701. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  3702. */
  3703. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  3704. /**
  3705. * @hidden Define this method to modify the default behavior when loading skins.
  3706. * @param context The context when loading the asset
  3707. * @param node The glTF node property
  3708. * @param skin The glTF skin property
  3709. * @returns A promise that resolves when the load is complete or null if not handled
  3710. */
  3711. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  3712. /**
  3713. * @hidden Define this method to modify the default behavior when loading uris.
  3714. * @param context The context when loading the asset
  3715. * @param property The glTF property associated with the uri
  3716. * @param uri The uri to load
  3717. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3718. */
  3719. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  3720. /**
  3721. * Define this method to modify the default behavior when loading buffer views.
  3722. * @param context The context when loading the asset
  3723. * @param bufferView The glTF buffer view property
  3724. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3725. */
  3726. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  3727. /**
  3728. * Define this method to modify the default behavior when loading buffers.
  3729. * @param context The context when loading the asset
  3730. * @param buffer The glTF buffer property
  3731. * @param byteOffset The byte offset to load
  3732. * @param byteLength The byte length to load
  3733. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3734. */
  3735. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  3736. }
  3737. }
  3738. declare module BABYLON.GLTF2 {
  3739. /**
  3740. * Helper class for working with arrays when loading the glTF asset
  3741. */
  3742. export class ArrayItem {
  3743. /**
  3744. * Gets an item from the given array.
  3745. * @param context The context when loading the asset
  3746. * @param array The array to get the item from
  3747. * @param index The index to the array
  3748. * @returns The array item
  3749. */
  3750. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  3751. /**
  3752. * Assign an `index` field to each item of the given array.
  3753. * @param array The array of items
  3754. */
  3755. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  3756. }
  3757. /**
  3758. * The glTF 2.0 loader
  3759. */
  3760. export class GLTFLoader implements IGLTFLoader {
  3761. /** @hidden */
  3762. _completePromises: Promise<any>[];
  3763. private _disposed;
  3764. private _parent;
  3765. private _state;
  3766. private _extensions;
  3767. private _rootUrl;
  3768. private _fileName;
  3769. private _uniqueRootUrl;
  3770. private _gltf;
  3771. private _bin;
  3772. private _babylonScene;
  3773. private _rootBabylonMesh;
  3774. private _defaultBabylonMaterialData;
  3775. private _progressCallback?;
  3776. private _requests;
  3777. private static readonly _DefaultSampler;
  3778. private static _RegisteredExtensions;
  3779. /**
  3780. * Registers a loader extension.
  3781. * @param name The name of the loader extension.
  3782. * @param factory The factory function that creates the loader extension.
  3783. */
  3784. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  3785. /**
  3786. * Unregisters a loader extension.
  3787. * @param name The name of the loader extension.
  3788. * @returns A boolean indicating whether the extension has been unregistered
  3789. */
  3790. static UnregisterExtension(name: string): boolean;
  3791. /**
  3792. * Gets the loader state.
  3793. */
  3794. readonly state: Nullable<GLTFLoaderState>;
  3795. /**
  3796. * The object that represents the glTF JSON.
  3797. */
  3798. readonly gltf: IGLTF;
  3799. /**
  3800. * The BIN chunk of a binary glTF.
  3801. */
  3802. readonly bin: Nullable<IDataBuffer>;
  3803. /**
  3804. * The parent file loader.
  3805. */
  3806. readonly parent: GLTFFileLoader;
  3807. /**
  3808. * The Babylon scene when loading the asset.
  3809. */
  3810. readonly babylonScene: Scene;
  3811. /**
  3812. * The root Babylon mesh when loading the asset.
  3813. */
  3814. readonly rootBabylonMesh: Mesh;
  3815. /** @hidden */
  3816. constructor(parent: GLTFFileLoader);
  3817. /** @hidden */
  3818. dispose(): void;
  3819. /** @hidden */
  3820. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  3821. meshes: AbstractMesh[];
  3822. particleSystems: IParticleSystem[];
  3823. skeletons: Skeleton[];
  3824. animationGroups: AnimationGroup[];
  3825. }>;
  3826. /** @hidden */
  3827. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  3828. private _loadAsync;
  3829. private _loadData;
  3830. private _setupData;
  3831. private _loadExtensions;
  3832. private _checkExtensions;
  3833. private _setState;
  3834. private _createRootNode;
  3835. /**
  3836. * Loads a glTF scene.
  3837. * @param context The context when loading the asset
  3838. * @param scene The glTF scene property
  3839. * @returns A promise that resolves when the load is complete
  3840. */
  3841. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  3842. private _forEachPrimitive;
  3843. private _getMeshes;
  3844. private _getSkeletons;
  3845. private _getAnimationGroups;
  3846. private _startAnimations;
  3847. /**
  3848. * Loads a glTF node.
  3849. * @param context The context when loading the asset
  3850. * @param node The glTF node property
  3851. * @param assign A function called synchronously after parsing the glTF properties
  3852. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  3853. */
  3854. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  3855. private _loadMeshAsync;
  3856. /**
  3857. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  3858. * @param context The context when loading the asset
  3859. * @param name The mesh name when loading the asset
  3860. * @param node The glTF node when loading the asset
  3861. * @param mesh The glTF mesh when loading the asset
  3862. * @param primitive The glTF mesh primitive property
  3863. * @param assign A function called synchronously after parsing the glTF properties
  3864. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  3865. */
  3866. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  3867. private _loadVertexDataAsync;
  3868. private _createMorphTargets;
  3869. private _loadMorphTargetsAsync;
  3870. private _loadMorphTargetVertexDataAsync;
  3871. private static _LoadTransform;
  3872. private _loadSkinAsync;
  3873. private _loadBones;
  3874. private _loadBone;
  3875. private _loadSkinInverseBindMatricesDataAsync;
  3876. private _updateBoneMatrices;
  3877. private _getNodeMatrix;
  3878. /**
  3879. * Loads a glTF camera.
  3880. * @param context The context when loading the asset
  3881. * @param camera The glTF camera property
  3882. * @param assign A function called synchronously after parsing the glTF properties
  3883. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  3884. */
  3885. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  3886. private _loadAnimationsAsync;
  3887. /**
  3888. * Loads a glTF animation.
  3889. * @param context The context when loading the asset
  3890. * @param animation The glTF animation property
  3891. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  3892. */
  3893. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  3894. /**
  3895. * @hidden Loads a glTF animation channel.
  3896. * @param context The context when loading the asset
  3897. * @param animationContext The context of the animation when loading the asset
  3898. * @param animation The glTF animation property
  3899. * @param channel The glTF animation channel property
  3900. * @param babylonAnimationGroup The babylon animation group property
  3901. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  3902. * @returns A void promise when the channel load is complete
  3903. */
  3904. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  3905. private _loadAnimationSamplerAsync;
  3906. private _loadBufferAsync;
  3907. /**
  3908. * Loads a glTF buffer view.
  3909. * @param context The context when loading the asset
  3910. * @param bufferView The glTF buffer view property
  3911. * @returns A promise that resolves with the loaded data when the load is complete
  3912. */
  3913. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  3914. private _loadAccessorAsync;
  3915. private _loadFloatAccessorAsync;
  3916. private _loadIndicesAccessorAsync;
  3917. private _loadVertexBufferViewAsync;
  3918. private _loadVertexAccessorAsync;
  3919. private _loadMaterialMetallicRoughnessPropertiesAsync;
  3920. /** @hidden */
  3921. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  3922. private _createDefaultMaterial;
  3923. /**
  3924. * Creates a Babylon material from a glTF material.
  3925. * @param context The context when loading the asset
  3926. * @param material The glTF material property
  3927. * @param babylonDrawMode The draw mode for the Babylon material
  3928. * @returns The Babylon material
  3929. */
  3930. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  3931. /**
  3932. * Loads properties from a glTF material into a Babylon material.
  3933. * @param context The context when loading the asset
  3934. * @param material The glTF material property
  3935. * @param babylonMaterial The Babylon material
  3936. * @returns A promise that resolves when the load is complete
  3937. */
  3938. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3939. /**
  3940. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  3941. * @param context The context when loading the asset
  3942. * @param material The glTF material property
  3943. * @param babylonMaterial The Babylon material
  3944. * @returns A promise that resolves when the load is complete
  3945. */
  3946. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  3947. /**
  3948. * Loads the alpha properties from a glTF material into a Babylon material.
  3949. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  3950. * @param context The context when loading the asset
  3951. * @param material The glTF material property
  3952. * @param babylonMaterial The Babylon material
  3953. */
  3954. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  3955. /**
  3956. * Loads a glTF texture info.
  3957. * @param context The context when loading the asset
  3958. * @param textureInfo The glTF texture info property
  3959. * @param assign A function called synchronously after parsing the glTF properties
  3960. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  3961. */
  3962. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  3963. private _loadTextureAsync;
  3964. private _loadSampler;
  3965. /**
  3966. * Loads a glTF image.
  3967. * @param context The context when loading the asset
  3968. * @param image The glTF image property
  3969. * @returns A promise that resolves with the loaded data when the load is complete
  3970. */
  3971. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  3972. /**
  3973. * Loads a glTF uri.
  3974. * @param context The context when loading the asset
  3975. * @param property The glTF property associated with the uri
  3976. * @param uri The base64 or relative uri
  3977. * @returns A promise that resolves with the loaded data when the load is complete
  3978. */
  3979. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  3980. private _onProgress;
  3981. /**
  3982. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  3983. * @param babylonObject the Babylon object with metadata
  3984. * @param pointer the JSON pointer
  3985. */
  3986. static AddPointerMetadata(babylonObject: {
  3987. metadata: any;
  3988. }, pointer: string): void;
  3989. private static _GetTextureWrapMode;
  3990. private static _GetTextureSamplingMode;
  3991. private static _GetTypedArrayConstructor;
  3992. private static _GetTypedArray;
  3993. private static _GetNumComponents;
  3994. private static _ValidateUri;
  3995. private static _GetDrawMode;
  3996. private _compileMaterialsAsync;
  3997. private _compileShadowGeneratorsAsync;
  3998. private _forEachExtensions;
  3999. private _applyExtensions;
  4000. private _extensionsOnLoading;
  4001. private _extensionsOnReady;
  4002. private _extensionsLoadSceneAsync;
  4003. private _extensionsLoadNodeAsync;
  4004. private _extensionsLoadCameraAsync;
  4005. private _extensionsLoadVertexDataAsync;
  4006. private _extensionsLoadMeshPrimitiveAsync;
  4007. private _extensionsLoadMaterialAsync;
  4008. private _extensionsCreateMaterial;
  4009. private _extensionsLoadMaterialPropertiesAsync;
  4010. private _extensionsLoadTextureInfoAsync;
  4011. private _extensionsLoadAnimationAsync;
  4012. private _extensionsLoadSkinAsync;
  4013. private _extensionsLoadUriAsync;
  4014. private _extensionsLoadBufferViewAsync;
  4015. private _extensionsLoadBufferAsync;
  4016. /**
  4017. * Helper method called by a loader extension to load an glTF extension.
  4018. * @param context The context when loading the asset
  4019. * @param property The glTF property to load the extension from
  4020. * @param extensionName The name of the extension to load
  4021. * @param actionAsync The action to run
  4022. * @returns The promise returned by actionAsync or null if the extension does not exist
  4023. */
  4024. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4025. /**
  4026. * Helper method called by a loader extension to load a glTF extra.
  4027. * @param context The context when loading the asset
  4028. * @param property The glTF property to load the extra from
  4029. * @param extensionName The name of the extension to load
  4030. * @param actionAsync The action to run
  4031. * @returns The promise returned by actionAsync or null if the extra does not exist
  4032. */
  4033. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4034. /**
  4035. * Checks for presence of an extension.
  4036. * @param name The name of the extension to check
  4037. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  4038. */
  4039. isExtensionUsed(name: string): boolean;
  4040. /**
  4041. * Increments the indentation level and logs a message.
  4042. * @param message The message to log
  4043. */
  4044. logOpen(message: string): void;
  4045. /**
  4046. * Decrements the indentation level.
  4047. */
  4048. logClose(): void;
  4049. /**
  4050. * Logs a message
  4051. * @param message The message to log
  4052. */
  4053. log(message: string): void;
  4054. /**
  4055. * Starts a performance counter.
  4056. * @param counterName The name of the performance counter
  4057. */
  4058. startPerformanceCounter(counterName: string): void;
  4059. /**
  4060. * Ends a performance counter.
  4061. * @param counterName The name of the performance counter
  4062. */
  4063. endPerformanceCounter(counterName: string): void;
  4064. }
  4065. }
  4066. declare module BABYLON.GLTF2.Loader.Extensions {
  4067. /**
  4068. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  4069. */
  4070. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  4071. /**
  4072. * The name of this extension.
  4073. */
  4074. readonly name: string;
  4075. /**
  4076. * Defines whether this extension is enabled.
  4077. */
  4078. enabled: boolean;
  4079. private _loader;
  4080. private _lights?;
  4081. /** @hidden */
  4082. constructor(loader: GLTFLoader);
  4083. /** @hidden */
  4084. dispose(): void;
  4085. /** @hidden */
  4086. onLoading(): void;
  4087. /** @hidden */
  4088. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4089. private _loadLightAsync;
  4090. }
  4091. }
  4092. declare module BABYLON.GLTF2.Loader.Extensions {
  4093. /**
  4094. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  4095. */
  4096. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  4097. /**
  4098. * The name of this extension.
  4099. */
  4100. readonly name: string;
  4101. /**
  4102. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  4103. */
  4104. dracoCompression?: DracoCompression;
  4105. /**
  4106. * Defines whether this extension is enabled.
  4107. */
  4108. enabled: boolean;
  4109. private _loader;
  4110. /** @hidden */
  4111. constructor(loader: GLTFLoader);
  4112. /** @hidden */
  4113. dispose(): void;
  4114. /** @hidden */
  4115. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  4116. }
  4117. }
  4118. declare module BABYLON.GLTF2.Loader.Extensions {
  4119. /**
  4120. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  4121. */
  4122. export class KHR_lights implements IGLTFLoaderExtension {
  4123. /**
  4124. * The name of this extension.
  4125. */
  4126. readonly name: string;
  4127. /**
  4128. * Defines whether this extension is enabled.
  4129. */
  4130. enabled: boolean;
  4131. private _loader;
  4132. private _lights?;
  4133. /** @hidden */
  4134. constructor(loader: GLTFLoader);
  4135. /** @hidden */
  4136. dispose(): void;
  4137. /** @hidden */
  4138. onLoading(): void;
  4139. /** @hidden */
  4140. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4141. }
  4142. }
  4143. declare module BABYLON.GLTF2.Loader.Extensions {
  4144. /**
  4145. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  4146. */
  4147. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  4148. /**
  4149. * The name of this extension.
  4150. */
  4151. readonly name: string;
  4152. /**
  4153. * Defines whether this extension is enabled.
  4154. */
  4155. enabled: boolean;
  4156. /**
  4157. * Defines a number that determines the order the extensions are applied.
  4158. */
  4159. order: number;
  4160. private _loader;
  4161. /** @hidden */
  4162. constructor(loader: GLTFLoader);
  4163. /** @hidden */
  4164. dispose(): void;
  4165. /** @hidden */
  4166. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4167. private _loadSpecularGlossinessPropertiesAsync;
  4168. }
  4169. }
  4170. declare module BABYLON.GLTF2.Loader.Extensions {
  4171. /**
  4172. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  4173. */
  4174. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  4175. /**
  4176. * The name of this extension.
  4177. */
  4178. readonly name: string;
  4179. /**
  4180. * Defines whether this extension is enabled.
  4181. */
  4182. enabled: boolean;
  4183. /**
  4184. * Defines a number that determines the order the extensions are applied.
  4185. */
  4186. order: number;
  4187. private _loader;
  4188. /** @hidden */
  4189. constructor(loader: GLTFLoader);
  4190. /** @hidden */
  4191. dispose(): void;
  4192. /** @hidden */
  4193. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4194. private _loadUnlitPropertiesAsync;
  4195. }
  4196. }
  4197. declare module BABYLON.GLTF2.Loader.Extensions {
  4198. /**
  4199. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  4200. * [Playground Sample](https://www.babylonjs-playground.com/#7F7PN6)
  4201. * !!! Experimental Extension Subject to Changes !!!
  4202. */
  4203. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  4204. /**
  4205. * The name of this extension.
  4206. */
  4207. readonly name: string;
  4208. /**
  4209. * Defines whether this extension is enabled.
  4210. */
  4211. enabled: boolean;
  4212. /**
  4213. * Defines a number that determines the order the extensions are applied.
  4214. */
  4215. order: number;
  4216. private _loader;
  4217. /** @hidden */
  4218. constructor(loader: GLTFLoader);
  4219. /** @hidden */
  4220. dispose(): void;
  4221. /** @hidden */
  4222. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4223. private _loadClearCoatPropertiesAsync;
  4224. }
  4225. }
  4226. declare module BABYLON.GLTF2.Loader.Extensions {
  4227. /**
  4228. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  4229. * !!! Experimental Extension Subject to Changes !!!
  4230. */
  4231. export class KHR_materials_specular implements IGLTFLoaderExtension {
  4232. /**
  4233. * The name of this extension.
  4234. */
  4235. readonly name: string;
  4236. /**
  4237. * Defines whether this extension is enabled.
  4238. */
  4239. enabled: boolean;
  4240. /**
  4241. * Defines a number that determines the order the extensions are applied.
  4242. */
  4243. order: number;
  4244. private _loader;
  4245. /** @hidden */
  4246. constructor(loader: GLTFLoader);
  4247. /** @hidden */
  4248. dispose(): void;
  4249. /** @hidden */
  4250. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4251. private _loadSpecularPropertiesAsync;
  4252. }
  4253. }
  4254. declare module BABYLON.GLTF2.Loader.Extensions {
  4255. /**
  4256. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  4257. */
  4258. export class KHR_texture_transform implements IGLTFLoaderExtension {
  4259. /**
  4260. * The name of this extension.
  4261. */
  4262. readonly name: string;
  4263. /**
  4264. * Defines whether this extension is enabled.
  4265. */
  4266. enabled: boolean;
  4267. private _loader;
  4268. /** @hidden */
  4269. constructor(loader: GLTFLoader);
  4270. /** @hidden */
  4271. dispose(): void;
  4272. /** @hidden */
  4273. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4274. }
  4275. }
  4276. declare module BABYLON.GLTF2.Loader.Extensions {
  4277. /**
  4278. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  4279. */
  4280. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  4281. /**
  4282. * The name of this extension.
  4283. */
  4284. readonly name: string;
  4285. /**
  4286. * Defines whether this extension is enabled.
  4287. */
  4288. enabled: boolean;
  4289. private _loader;
  4290. private _clips;
  4291. private _emitters;
  4292. /** @hidden */
  4293. constructor(loader: GLTFLoader);
  4294. /** @hidden */
  4295. dispose(): void;
  4296. /** @hidden */
  4297. onLoading(): void;
  4298. /** @hidden */
  4299. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4300. /** @hidden */
  4301. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4302. /** @hidden */
  4303. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  4304. private _loadClipAsync;
  4305. private _loadEmitterAsync;
  4306. private _getEventAction;
  4307. private _loadAnimationEventAsync;
  4308. }
  4309. }
  4310. declare module BABYLON.GLTF2.Loader.Extensions {
  4311. /**
  4312. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  4313. */
  4314. export class MSFT_lod implements IGLTFLoaderExtension {
  4315. /**
  4316. * The name of this extension.
  4317. */
  4318. readonly name: string;
  4319. /**
  4320. * Defines whether this extension is enabled.
  4321. */
  4322. enabled: boolean;
  4323. /**
  4324. * Defines a number that determines the order the extensions are applied.
  4325. */
  4326. order: number;
  4327. /**
  4328. * Maximum number of LODs to load, starting from the lowest LOD.
  4329. */
  4330. maxLODsToLoad: number;
  4331. /**
  4332. * Observable raised when all node LODs of one level are loaded.
  4333. * The event data is the index of the loaded LOD starting from zero.
  4334. * Dispose the loader to cancel the loading of the next level of LODs.
  4335. */
  4336. onNodeLODsLoadedObservable: Observable<number>;
  4337. /**
  4338. * Observable raised when all material LODs of one level are loaded.
  4339. * The event data is the index of the loaded LOD starting from zero.
  4340. * Dispose the loader to cancel the loading of the next level of LODs.
  4341. */
  4342. onMaterialLODsLoadedObservable: Observable<number>;
  4343. private _loader;
  4344. private _nodeIndexLOD;
  4345. private _nodeSignalLODs;
  4346. private _nodePromiseLODs;
  4347. private _materialIndexLOD;
  4348. private _materialSignalLODs;
  4349. private _materialPromiseLODs;
  4350. private _indexLOD;
  4351. private _bufferLODs;
  4352. /** @hidden */
  4353. constructor(loader: GLTFLoader);
  4354. /** @hidden */
  4355. dispose(): void;
  4356. /** @hidden */
  4357. onReady(): void;
  4358. /** @hidden */
  4359. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4360. /** @hidden */
  4361. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  4362. /** @hidden */
  4363. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  4364. /** @hidden */
  4365. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  4366. private _loadBufferLOD;
  4367. /**
  4368. * Gets an array of LOD properties from lowest to highest.
  4369. */
  4370. private _getLODs;
  4371. private _disposeUnusedMaterials;
  4372. }
  4373. }
  4374. declare module BABYLON.GLTF2.Loader.Extensions {
  4375. /** @hidden */
  4376. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  4377. readonly name: string;
  4378. enabled: boolean;
  4379. private _loader;
  4380. constructor(loader: GLTFLoader);
  4381. dispose(): void;
  4382. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4383. }
  4384. }
  4385. declare module BABYLON.GLTF2.Loader.Extensions {
  4386. /** @hidden */
  4387. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  4388. readonly name: string;
  4389. enabled: boolean;
  4390. private _loader;
  4391. constructor(loader: GLTFLoader);
  4392. dispose(): void;
  4393. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4394. }
  4395. }
  4396. declare module BABYLON.GLTF2.Loader.Extensions {
  4397. /**
  4398. * Store glTF extras (if present) in BJS objects' metadata
  4399. */
  4400. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  4401. /**
  4402. * The name of this extension.
  4403. */
  4404. readonly name: string;
  4405. /**
  4406. * Defines whether this extension is enabled.
  4407. */
  4408. enabled: boolean;
  4409. private _loader;
  4410. private _assignExtras;
  4411. /** @hidden */
  4412. constructor(loader: GLTFLoader);
  4413. /** @hidden */
  4414. dispose(): void;
  4415. /** @hidden */
  4416. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4417. /** @hidden */
  4418. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  4419. /** @hidden */
  4420. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  4421. }
  4422. }
  4423. declare module BABYLON {
  4424. /**
  4425. * Class reading and parsing the MTL file bundled with the obj file.
  4426. */
  4427. export class MTLFileLoader {
  4428. /**
  4429. * All material loaded from the mtl will be set here
  4430. */
  4431. materials: StandardMaterial[];
  4432. /**
  4433. * This function will read the mtl file and create each material described inside
  4434. * This function could be improve by adding :
  4435. * -some component missing (Ni, Tf...)
  4436. * -including the specific options available
  4437. *
  4438. * @param scene defines the scene the material will be created in
  4439. * @param data defines the mtl data to parse
  4440. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  4441. */
  4442. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  4443. /**
  4444. * Gets the texture for the material.
  4445. *
  4446. * If the material is imported from input file,
  4447. * We sanitize the url to ensure it takes the textre from aside the material.
  4448. *
  4449. * @param rootUrl The root url to load from
  4450. * @param value The value stored in the mtl
  4451. * @return The Texture
  4452. */
  4453. private static _getTexture;
  4454. }
  4455. /**
  4456. * Options for loading OBJ/MTL files
  4457. */
  4458. type MeshLoadOptions = {
  4459. /**
  4460. * Defines if UVs are optimized by default during load.
  4461. */
  4462. OptimizeWithUV: boolean;
  4463. /**
  4464. * Defines custom scaling of UV coordinates of loaded meshes.
  4465. */
  4466. UVScaling: Vector2;
  4467. /**
  4468. * Invert model on y-axis (does a model scaling inversion)
  4469. */
  4470. InvertY: boolean;
  4471. /**
  4472. * Invert Y-Axis of referenced textures on load
  4473. */
  4474. InvertTextureY: boolean;
  4475. /**
  4476. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4477. */
  4478. ImportVertexColors: boolean;
  4479. /**
  4480. * Compute the normals for the model, even if normals are present in the file.
  4481. */
  4482. ComputeNormals: boolean;
  4483. /**
  4484. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4485. */
  4486. SkipMaterials: boolean;
  4487. /**
  4488. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4489. */
  4490. MaterialLoadingFailsSilently: boolean;
  4491. };
  4492. /**
  4493. * OBJ file type loader.
  4494. * This is a babylon scene loader plugin.
  4495. */
  4496. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  4497. /**
  4498. * Defines if UVs are optimized by default during load.
  4499. */
  4500. static OPTIMIZE_WITH_UV: boolean;
  4501. /**
  4502. * Invert model on y-axis (does a model scaling inversion)
  4503. */
  4504. static INVERT_Y: boolean;
  4505. /**
  4506. * Invert Y-Axis of referenced textures on load
  4507. */
  4508. static INVERT_TEXTURE_Y: boolean;
  4509. /**
  4510. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4511. */
  4512. static IMPORT_VERTEX_COLORS: boolean;
  4513. /**
  4514. * Compute the normals for the model, even if normals are present in the file.
  4515. */
  4516. static COMPUTE_NORMALS: boolean;
  4517. /**
  4518. * Defines custom scaling of UV coordinates of loaded meshes.
  4519. */
  4520. static UV_SCALING: Vector2;
  4521. /**
  4522. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4523. */
  4524. static SKIP_MATERIALS: boolean;
  4525. /**
  4526. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4527. *
  4528. * Defaults to true for backwards compatibility.
  4529. */
  4530. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  4531. /**
  4532. * Defines the name of the plugin.
  4533. */
  4534. name: string;
  4535. /**
  4536. * Defines the extension the plugin is able to load.
  4537. */
  4538. extensions: string;
  4539. /** @hidden */
  4540. obj: RegExp;
  4541. /** @hidden */
  4542. group: RegExp;
  4543. /** @hidden */
  4544. mtllib: RegExp;
  4545. /** @hidden */
  4546. usemtl: RegExp;
  4547. /** @hidden */
  4548. smooth: RegExp;
  4549. /** @hidden */
  4550. vertexPattern: RegExp;
  4551. /** @hidden */
  4552. normalPattern: RegExp;
  4553. /** @hidden */
  4554. uvPattern: RegExp;
  4555. /** @hidden */
  4556. facePattern1: RegExp;
  4557. /** @hidden */
  4558. facePattern2: RegExp;
  4559. /** @hidden */
  4560. facePattern3: RegExp;
  4561. /** @hidden */
  4562. facePattern4: RegExp;
  4563. /** @hidden */
  4564. facePattern5: RegExp;
  4565. private _meshLoadOptions;
  4566. /**
  4567. * Creates loader for .OBJ files
  4568. *
  4569. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  4570. */
  4571. constructor(meshLoadOptions?: MeshLoadOptions);
  4572. private static readonly currentMeshLoadOptions;
  4573. /**
  4574. * Calls synchronously the MTL file attached to this obj.
  4575. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  4576. * Without this function materials are not displayed in the first frame (but displayed after).
  4577. * In consequence it is impossible to get material information in your HTML file
  4578. *
  4579. * @param url The URL of the MTL file
  4580. * @param rootUrl
  4581. * @param onSuccess Callback function to be called when the MTL file is loaded
  4582. * @private
  4583. */
  4584. private _loadMTL;
  4585. /**
  4586. * Instantiates a OBJ file loader plugin.
  4587. * @returns the created plugin
  4588. */
  4589. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  4590. /**
  4591. * If the data string can be loaded directly.
  4592. *
  4593. * @param data string containing the file data
  4594. * @returns if the data can be loaded directly
  4595. */
  4596. canDirectLoad(data: string): boolean;
  4597. /**
  4598. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  4599. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  4600. * @param scene the scene the meshes should be added to
  4601. * @param data the OBJ data to load
  4602. * @param rootUrl root url to load from
  4603. * @param onProgress event that fires when loading progress has occured
  4604. * @param fileName Defines the name of the file to load
  4605. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  4606. */
  4607. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  4608. meshes: AbstractMesh[];
  4609. particleSystems: IParticleSystem[];
  4610. skeletons: Skeleton[];
  4611. animationGroups: AnimationGroup[];
  4612. }>;
  4613. /**
  4614. * Imports all objects from the loaded OBJ data and adds them to the scene
  4615. * @param scene the scene the objects should be added to
  4616. * @param data the OBJ data to load
  4617. * @param rootUrl root url to load from
  4618. * @param onProgress event that fires when loading progress has occured
  4619. * @param fileName Defines the name of the file to load
  4620. * @returns a promise which completes when objects have been loaded to the scene
  4621. */
  4622. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4623. /**
  4624. * Load into an asset container.
  4625. * @param scene The scene to load into
  4626. * @param data The data to import
  4627. * @param rootUrl The root url for scene and resources
  4628. * @param onProgress The callback when the load progresses
  4629. * @param fileName Defines the name of the file to load
  4630. * @returns The loaded asset container
  4631. */
  4632. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  4633. /**
  4634. * Read the OBJ file and create an Array of meshes.
  4635. * Each mesh contains all information given by the OBJ and the MTL file.
  4636. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  4637. *
  4638. * @param meshesNames
  4639. * @param scene Scene The scene where are displayed the data
  4640. * @param data String The content of the obj file
  4641. * @param rootUrl String The path to the folder
  4642. * @returns Array<AbstractMesh>
  4643. * @private
  4644. */
  4645. private _parseSolid;
  4646. }
  4647. }
  4648. declare module BABYLON {
  4649. /**
  4650. * STL file type loader.
  4651. * This is a babylon scene loader plugin.
  4652. */
  4653. export class STLFileLoader implements ISceneLoaderPlugin {
  4654. /** @hidden */
  4655. solidPattern: RegExp;
  4656. /** @hidden */
  4657. facetsPattern: RegExp;
  4658. /** @hidden */
  4659. normalPattern: RegExp;
  4660. /** @hidden */
  4661. vertexPattern: RegExp;
  4662. /**
  4663. * Defines the name of the plugin.
  4664. */
  4665. name: string;
  4666. /**
  4667. * Defines the extensions the stl loader is able to load.
  4668. * force data to come in as an ArrayBuffer
  4669. * we'll convert to string if it looks like it's an ASCII .stl
  4670. */
  4671. extensions: ISceneLoaderPluginExtensions;
  4672. /**
  4673. * Import meshes into a scene.
  4674. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  4675. * @param scene The scene to import into
  4676. * @param data The data to import
  4677. * @param rootUrl The root url for scene and resources
  4678. * @param meshes The meshes array to import into
  4679. * @param particleSystems The particle systems array to import into
  4680. * @param skeletons The skeletons array to import into
  4681. * @param onError The callback when import fails
  4682. * @returns True if successful or false otherwise
  4683. */
  4684. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  4685. /**
  4686. * Load into a scene.
  4687. * @param scene The scene to load into
  4688. * @param data The data to import
  4689. * @param rootUrl The root url for scene and resources
  4690. * @param onError The callback when import fails
  4691. * @returns true if successful or false otherwise
  4692. */
  4693. load(scene: Scene, data: any, rootUrl: string): boolean;
  4694. /**
  4695. * Load into an asset container.
  4696. * @param scene The scene to load into
  4697. * @param data The data to import
  4698. * @param rootUrl The root url for scene and resources
  4699. * @param onError The callback when import fails
  4700. * @returns The loaded asset container
  4701. */
  4702. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  4703. private _isBinary;
  4704. private _parseBinary;
  4705. private _parseASCII;
  4706. }
  4707. }