babylonjs.loaders.module.d.ts 198 KB

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