babylonjs.loaders.module.d.ts 207 KB

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