babylonjs.loaders.module.d.ts 220 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343
  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): Nullable<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, IAccessor, 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. /** @hidden */
  1421. _disableInstancedMesh: number;
  1422. private _disposed;
  1423. private _parent;
  1424. private _state;
  1425. private _extensions;
  1426. private _rootUrl;
  1427. private _fileName;
  1428. private _uniqueRootUrl;
  1429. private _gltf;
  1430. private _bin;
  1431. private _babylonScene;
  1432. private _rootBabylonMesh;
  1433. private _defaultBabylonMaterialData;
  1434. private _progressCallback?;
  1435. private _requests;
  1436. private static _RegisteredExtensions;
  1437. /**
  1438. * The default glTF sampler.
  1439. */
  1440. static readonly DefaultSampler: ISampler;
  1441. /**
  1442. * Registers a loader extension.
  1443. * @param name The name of the loader extension.
  1444. * @param factory The factory function that creates the loader extension.
  1445. */
  1446. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1447. /**
  1448. * Unregisters a loader extension.
  1449. * @param name The name of the loader extension.
  1450. * @returns A boolean indicating whether the extension has been unregistered
  1451. */
  1452. static UnregisterExtension(name: string): boolean;
  1453. /**
  1454. * The loader state.
  1455. */
  1456. get state(): Nullable<GLTFLoaderState>;
  1457. /**
  1458. * The object that represents the glTF JSON.
  1459. */
  1460. get gltf(): IGLTF;
  1461. /**
  1462. * The BIN chunk of a binary glTF.
  1463. */
  1464. get bin(): Nullable<IDataBuffer>;
  1465. /**
  1466. * The parent file loader.
  1467. */
  1468. get parent(): GLTFFileLoader;
  1469. /**
  1470. * The Babylon scene when loading the asset.
  1471. */
  1472. get babylonScene(): Scene;
  1473. /**
  1474. * The root Babylon mesh when loading the asset.
  1475. */
  1476. get rootBabylonMesh(): Mesh;
  1477. /** @hidden */
  1478. constructor(parent: GLTFFileLoader);
  1479. /** @hidden */
  1480. dispose(): void;
  1481. /** @hidden */
  1482. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  1483. /** @hidden */
  1484. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1485. private _loadAsync;
  1486. private _loadData;
  1487. private _setupData;
  1488. private _loadExtensions;
  1489. private _checkExtensions;
  1490. private _setState;
  1491. private _createRootNode;
  1492. /**
  1493. * Loads a glTF scene.
  1494. * @param context The context when loading the asset
  1495. * @param scene The glTF scene property
  1496. * @returns A promise that resolves when the load is complete
  1497. */
  1498. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  1499. private _forEachPrimitive;
  1500. private _getMeshes;
  1501. private _getTransformNodes;
  1502. private _getSkeletons;
  1503. private _getAnimationGroups;
  1504. private _startAnimations;
  1505. /**
  1506. * Loads a glTF node.
  1507. * @param context The context when loading the asset
  1508. * @param node The glTF node property
  1509. * @param assign A function called synchronously after parsing the glTF properties
  1510. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1511. */
  1512. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  1513. private _loadMeshAsync;
  1514. /**
  1515. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  1516. * @param context The context when loading the asset
  1517. * @param name The mesh name when loading the asset
  1518. * @param node The glTF node when loading the asset
  1519. * @param mesh The glTF mesh when loading the asset
  1520. * @param primitive The glTF mesh primitive property
  1521. * @param assign A function called synchronously after parsing the glTF properties
  1522. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  1523. */
  1524. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  1525. private _loadVertexDataAsync;
  1526. private _createMorphTargets;
  1527. private _loadMorphTargetsAsync;
  1528. private _loadMorphTargetVertexDataAsync;
  1529. private static _LoadTransform;
  1530. private _loadSkinAsync;
  1531. private _loadBones;
  1532. private _loadBone;
  1533. private _loadSkinInverseBindMatricesDataAsync;
  1534. private _updateBoneMatrices;
  1535. private _getNodeMatrix;
  1536. /**
  1537. * Loads a glTF camera.
  1538. * @param context The context when loading the asset
  1539. * @param camera The glTF camera property
  1540. * @param assign A function called synchronously after parsing the glTF properties
  1541. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1542. */
  1543. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1544. private _loadAnimationsAsync;
  1545. /**
  1546. * Loads a glTF animation.
  1547. * @param context The context when loading the asset
  1548. * @param animation The glTF animation property
  1549. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1550. */
  1551. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  1552. /**
  1553. * @hidden Loads a glTF animation channel.
  1554. * @param context The context when loading the asset
  1555. * @param animationContext The context of the animation when loading the asset
  1556. * @param animation The glTF animation property
  1557. * @param channel The glTF animation channel property
  1558. * @param babylonAnimationGroup The babylon animation group property
  1559. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  1560. * @returns A void promise when the channel load is complete
  1561. */
  1562. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  1563. private _loadAnimationSamplerAsync;
  1564. private _loadBufferAsync;
  1565. /**
  1566. * Loads a glTF buffer view.
  1567. * @param context The context when loading the asset
  1568. * @param bufferView The glTF buffer view property
  1569. * @returns A promise that resolves with the loaded data when the load is complete
  1570. */
  1571. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1572. private _loadAccessorAsync;
  1573. /** @hidden */
  1574. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  1575. private _loadIndicesAccessorAsync;
  1576. private _loadVertexBufferViewAsync;
  1577. private _loadVertexAccessorAsync;
  1578. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1579. /** @hidden */
  1580. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1581. private _createDefaultMaterial;
  1582. /**
  1583. * Creates a Babylon material from a glTF material.
  1584. * @param context The context when loading the asset
  1585. * @param material The glTF material property
  1586. * @param babylonDrawMode The draw mode for the Babylon material
  1587. * @returns The Babylon material
  1588. */
  1589. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1590. /**
  1591. * Loads properties from a glTF material into a Babylon material.
  1592. * @param context The context when loading the asset
  1593. * @param material The glTF material property
  1594. * @param babylonMaterial The Babylon material
  1595. * @returns A promise that resolves when the load is complete
  1596. */
  1597. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1598. /**
  1599. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1600. * @param context The context when loading the asset
  1601. * @param material The glTF material property
  1602. * @param babylonMaterial The Babylon material
  1603. * @returns A promise that resolves when the load is complete
  1604. */
  1605. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1606. /**
  1607. * Loads the alpha properties from a glTF material into a Babylon material.
  1608. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1609. * @param context The context when loading the asset
  1610. * @param material The glTF material property
  1611. * @param babylonMaterial The Babylon material
  1612. */
  1613. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1614. /**
  1615. * Loads a glTF texture info.
  1616. * @param context The context when loading the asset
  1617. * @param textureInfo The glTF texture info property
  1618. * @param assign A function called synchronously after parsing the glTF properties
  1619. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1620. */
  1621. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1622. /** @hidden */
  1623. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1624. /** @hidden */
  1625. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1626. private _loadSampler;
  1627. /**
  1628. * Loads a glTF image.
  1629. * @param context The context when loading the asset
  1630. * @param image The glTF image property
  1631. * @returns A promise that resolves with the loaded data when the load is complete
  1632. */
  1633. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1634. /**
  1635. * Loads a glTF uri.
  1636. * @param context The context when loading the asset
  1637. * @param property The glTF property associated with the uri
  1638. * @param uri The base64 or relative uri
  1639. * @returns A promise that resolves with the loaded data when the load is complete
  1640. */
  1641. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  1642. private _onProgress;
  1643. /**
  1644. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1645. * @param babylonObject the Babylon object with metadata
  1646. * @param pointer the JSON pointer
  1647. */
  1648. static AddPointerMetadata(babylonObject: {
  1649. metadata: any;
  1650. }, pointer: string): void;
  1651. private static _GetTextureWrapMode;
  1652. private static _GetTextureSamplingMode;
  1653. private static _GetTypedArrayConstructor;
  1654. private static _GetTypedArray;
  1655. private static _GetNumComponents;
  1656. private static _ValidateUri;
  1657. private static _GetDrawMode;
  1658. private _compileMaterialsAsync;
  1659. private _compileShadowGeneratorsAsync;
  1660. private _forEachExtensions;
  1661. private _applyExtensions;
  1662. private _extensionsOnLoading;
  1663. private _extensionsOnReady;
  1664. private _extensionsLoadSceneAsync;
  1665. private _extensionsLoadNodeAsync;
  1666. private _extensionsLoadCameraAsync;
  1667. private _extensionsLoadVertexDataAsync;
  1668. private _extensionsLoadMeshPrimitiveAsync;
  1669. private _extensionsLoadMaterialAsync;
  1670. private _extensionsCreateMaterial;
  1671. private _extensionsLoadMaterialPropertiesAsync;
  1672. private _extensionsLoadTextureInfoAsync;
  1673. private _extensionsLoadTextureAsync;
  1674. private _extensionsLoadAnimationAsync;
  1675. private _extensionsLoadSkinAsync;
  1676. private _extensionsLoadUriAsync;
  1677. private _extensionsLoadBufferViewAsync;
  1678. private _extensionsLoadBufferAsync;
  1679. /**
  1680. * Helper method called by a loader extension to load an glTF extension.
  1681. * @param context The context when loading the asset
  1682. * @param property The glTF property to load the extension from
  1683. * @param extensionName The name of the extension to load
  1684. * @param actionAsync The action to run
  1685. * @returns The promise returned by actionAsync or null if the extension does not exist
  1686. */
  1687. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1688. /**
  1689. * Helper method called by a loader extension to load a glTF extra.
  1690. * @param context The context when loading the asset
  1691. * @param property The glTF property to load the extra from
  1692. * @param extensionName The name of the extension to load
  1693. * @param actionAsync The action to run
  1694. * @returns The promise returned by actionAsync or null if the extra does not exist
  1695. */
  1696. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1697. /**
  1698. * Checks for presence of an extension.
  1699. * @param name The name of the extension to check
  1700. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  1701. */
  1702. isExtensionUsed(name: string): boolean;
  1703. /**
  1704. * Increments the indentation level and logs a message.
  1705. * @param message The message to log
  1706. */
  1707. logOpen(message: string): void;
  1708. /**
  1709. * Decrements the indentation level.
  1710. */
  1711. logClose(): void;
  1712. /**
  1713. * Logs a message
  1714. * @param message The message to log
  1715. */
  1716. log(message: string): void;
  1717. /**
  1718. * Starts a performance counter.
  1719. * @param counterName The name of the performance counter
  1720. */
  1721. startPerformanceCounter(counterName: string): void;
  1722. /**
  1723. * Ends a performance counter.
  1724. * @param counterName The name of the performance counter
  1725. */
  1726. endPerformanceCounter(counterName: string): void;
  1727. }
  1728. }
  1729. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based" {
  1730. import { Nullable } from "babylonjs/types";
  1731. import { IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1732. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1733. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1734. /**
  1735. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  1736. */
  1737. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1738. /**
  1739. * The name of this extension.
  1740. */
  1741. readonly name: string;
  1742. /**
  1743. * Defines whether this extension is enabled.
  1744. */
  1745. enabled: boolean;
  1746. private _loader;
  1747. private _lights?;
  1748. /** @hidden */
  1749. constructor(loader: GLTFLoader);
  1750. /** @hidden */
  1751. dispose(): void;
  1752. /** @hidden */
  1753. onLoading(): void;
  1754. /** @hidden */
  1755. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1756. private _loadLightAsync;
  1757. }
  1758. }
  1759. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_mesh_gpu_instancing" {
  1760. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1761. import { Nullable } from "babylonjs/types";
  1762. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1763. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1764. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1765. /**
  1766. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  1767. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  1768. * !!! Experimental Extension Subject to Changes !!!
  1769. */
  1770. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  1771. /**
  1772. * The name of this extension.
  1773. */
  1774. readonly name: string;
  1775. /**
  1776. * Defines whether this extension is enabled.
  1777. */
  1778. enabled: boolean;
  1779. private _loader;
  1780. /** @hidden */
  1781. constructor(loader: GLTFLoader);
  1782. /** @hidden */
  1783. dispose(): void;
  1784. /** @hidden */
  1785. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1786. }
  1787. }
  1788. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression" {
  1789. import { DracoCompression } from "babylonjs/Meshes/Compression/dracoCompression";
  1790. import { Nullable } from "babylonjs/types";
  1791. import { Geometry } from "babylonjs/Meshes/geometry";
  1792. import { Mesh } from "babylonjs/Meshes/mesh";
  1793. import { IMeshPrimitive } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1794. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1795. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1796. /**
  1797. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1798. */
  1799. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1800. /**
  1801. * The name of this extension.
  1802. */
  1803. readonly name: string;
  1804. /**
  1805. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  1806. */
  1807. dracoCompression?: DracoCompression;
  1808. /**
  1809. * Defines whether this extension is enabled.
  1810. */
  1811. enabled: boolean;
  1812. private _loader;
  1813. /** @hidden */
  1814. constructor(loader: GLTFLoader);
  1815. /** @hidden */
  1816. dispose(): void;
  1817. /** @hidden */
  1818. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1819. }
  1820. }
  1821. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual" {
  1822. import { Nullable } from "babylonjs/types";
  1823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1824. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1825. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1826. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1827. /**
  1828. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  1829. */
  1830. export class KHR_lights implements IGLTFLoaderExtension {
  1831. /**
  1832. * The name of this extension.
  1833. */
  1834. readonly name: string;
  1835. /**
  1836. * Defines whether this extension is enabled.
  1837. */
  1838. enabled: boolean;
  1839. private _loader;
  1840. private _lights?;
  1841. /** @hidden */
  1842. constructor(loader: GLTFLoader);
  1843. /** @hidden */
  1844. dispose(): void;
  1845. /** @hidden */
  1846. onLoading(): void;
  1847. /** @hidden */
  1848. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1849. }
  1850. }
  1851. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness" {
  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_pbrSpecularGlossiness)
  1859. */
  1860. export class KHR_materials_pbrSpecularGlossiness 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 _loadSpecularGlossinessPropertiesAsync;
  1881. }
  1882. }
  1883. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit" {
  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. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1891. */
  1892. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1893. /**
  1894. * The name of this extension.
  1895. */
  1896. readonly name: string;
  1897. /**
  1898. * Defines whether this extension is enabled.
  1899. */
  1900. enabled: boolean;
  1901. /**
  1902. * Defines a number that determines the order the extensions are applied.
  1903. */
  1904. order: number;
  1905. private _loader;
  1906. /** @hidden */
  1907. constructor(loader: GLTFLoader);
  1908. /** @hidden */
  1909. dispose(): void;
  1910. /** @hidden */
  1911. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1912. private _loadUnlitPropertiesAsync;
  1913. }
  1914. }
  1915. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_clearcoat" {
  1916. import { Nullable } from "babylonjs/types";
  1917. import { Material } from "babylonjs/Materials/material";
  1918. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1919. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1920. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1921. /**
  1922. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1923. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  1924. * !!! Experimental Extension Subject to Changes !!!
  1925. */
  1926. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  1927. /**
  1928. * The name of this extension.
  1929. */
  1930. readonly name: string;
  1931. /**
  1932. * Defines whether this extension is enabled.
  1933. */
  1934. enabled: boolean;
  1935. /**
  1936. * Defines a number that determines the order the extensions are applied.
  1937. */
  1938. order: number;
  1939. private _loader;
  1940. /** @hidden */
  1941. constructor(loader: GLTFLoader);
  1942. /** @hidden */
  1943. dispose(): void;
  1944. /** @hidden */
  1945. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1946. private _loadClearCoatPropertiesAsync;
  1947. }
  1948. }
  1949. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_sheen" {
  1950. import { Nullable } from "babylonjs/types";
  1951. import { Material } from "babylonjs/Materials/material";
  1952. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1953. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1954. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1955. /**
  1956. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  1957. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  1958. * !!! Experimental Extension Subject to Changes !!!
  1959. */
  1960. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  1961. /**
  1962. * The name of this extension.
  1963. */
  1964. readonly name: string;
  1965. /**
  1966. * Defines whether this extension is enabled.
  1967. */
  1968. enabled: boolean;
  1969. /**
  1970. * Defines a number that determines the order the extensions are applied.
  1971. */
  1972. order: number;
  1973. private _loader;
  1974. /** @hidden */
  1975. constructor(loader: GLTFLoader);
  1976. /** @hidden */
  1977. dispose(): void;
  1978. /** @hidden */
  1979. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1980. private _loadSheenPropertiesAsync;
  1981. }
  1982. }
  1983. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular" {
  1984. import { Nullable } from "babylonjs/types";
  1985. import { Material } from "babylonjs/Materials/material";
  1986. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1987. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1988. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1989. /**
  1990. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  1991. * !!! Experimental Extension Subject to Changes !!!
  1992. */
  1993. export class KHR_materials_specular implements IGLTFLoaderExtension {
  1994. /**
  1995. * The name of this extension.
  1996. */
  1997. readonly name: string;
  1998. /**
  1999. * Defines whether this extension is enabled.
  2000. */
  2001. enabled: boolean;
  2002. /**
  2003. * Defines a number that determines the order the extensions are applied.
  2004. */
  2005. order: number;
  2006. private _loader;
  2007. /** @hidden */
  2008. constructor(loader: GLTFLoader);
  2009. /** @hidden */
  2010. dispose(): void;
  2011. /** @hidden */
  2012. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2013. private _loadSpecularPropertiesAsync;
  2014. }
  2015. }
  2016. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_ior" {
  2017. import { Nullable } from "babylonjs/types";
  2018. import { Material } from "babylonjs/Materials/material";
  2019. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2020. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2021. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2022. /**
  2023. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  2024. * !!! Experimental Extension Subject to Changes !!!
  2025. */
  2026. export class KHR_materials_ior implements IGLTFLoaderExtension {
  2027. /**
  2028. * Default ior Value from the spec.
  2029. */
  2030. private static readonly _DEFAULT_IOR;
  2031. /**
  2032. * The name of this extension.
  2033. */
  2034. readonly name: string;
  2035. /**
  2036. * Defines whether this extension is enabled.
  2037. */
  2038. enabled: boolean;
  2039. /**
  2040. * Defines a number that determines the order the extensions are applied.
  2041. */
  2042. order: number;
  2043. private _loader;
  2044. /** @hidden */
  2045. constructor(loader: GLTFLoader);
  2046. /** @hidden */
  2047. dispose(): void;
  2048. /** @hidden */
  2049. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2050. private _loadIorPropertiesAsync;
  2051. }
  2052. }
  2053. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_variants" {
  2054. import { Nullable } from "babylonjs/types";
  2055. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2056. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2057. import { AbstractMesh } from 'babylonjs/Meshes/abstractMesh';
  2058. import { INode, IMeshPrimitive, IMesh } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2059. /**
  2060. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  2061. * !!! Experimental Extension Subject to Changes !!!
  2062. */
  2063. export class KHR_materials_variants implements IGLTFLoaderExtension {
  2064. /**
  2065. * The name of this extension.
  2066. */
  2067. readonly name: string;
  2068. /**
  2069. * Defines whether this extension is enabled.
  2070. */
  2071. enabled: boolean;
  2072. private _loader;
  2073. /**
  2074. * The default variant name.
  2075. */
  2076. defaultVariant: string | undefined;
  2077. private _tagsToMap;
  2078. /** @hidden */
  2079. constructor(loader: GLTFLoader);
  2080. /** @hidden */
  2081. dispose(): void;
  2082. /**
  2083. * Return a list of available variants for this asset.
  2084. * @returns {string[]}
  2085. */
  2086. getVariants(): string[];
  2087. /**
  2088. * Select a variant by providing a list of variant tag names.
  2089. *
  2090. * @param {(string | string[])} variantName
  2091. */
  2092. selectVariant(variantName: string | string[]): void;
  2093. /**
  2094. * Select a variant by providing a single variant tag.
  2095. *
  2096. * @param {string} variantName
  2097. */
  2098. selectVariantTag(variantName: string): void;
  2099. /** @hidden */
  2100. onLoading(): void;
  2101. /** @hidden */
  2102. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  2103. }
  2104. }
  2105. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_transmission" {
  2106. import { Nullable } from "babylonjs/types";
  2107. import { Material } from "babylonjs/Materials/material";
  2108. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2109. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2110. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2111. /**
  2112. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  2113. * !!! Experimental Extension Subject to Changes !!!
  2114. */
  2115. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  2116. /**
  2117. * The name of this extension.
  2118. */
  2119. readonly name: string;
  2120. /**
  2121. * Defines whether this extension is enabled.
  2122. */
  2123. enabled: boolean;
  2124. /**
  2125. * Defines a number that determines the order the extensions are applied.
  2126. */
  2127. order: number;
  2128. private _loader;
  2129. /** @hidden */
  2130. constructor(loader: GLTFLoader);
  2131. /** @hidden */
  2132. dispose(): void;
  2133. /** @hidden */
  2134. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2135. private _loadTransparentPropertiesAsync;
  2136. }
  2137. }
  2138. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_quantization" {
  2139. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2140. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2141. /**
  2142. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  2143. */
  2144. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  2145. /**
  2146. * The name of this extension.
  2147. */
  2148. readonly name: string;
  2149. /**
  2150. * Defines whether this extension is enabled.
  2151. */
  2152. enabled: boolean;
  2153. /** @hidden */
  2154. constructor(loader: GLTFLoader);
  2155. /** @hidden */
  2156. dispose(): void;
  2157. }
  2158. }
  2159. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_basisu" {
  2160. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2161. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2162. import { ITexture } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  2164. import { Nullable } from "babylonjs/types";
  2165. /**
  2166. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  2167. * !!! Experimental Extension Subject to Changes !!!
  2168. */
  2169. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  2170. /** The name of this extension. */
  2171. readonly name: string;
  2172. /** Defines whether this extension is enabled. */
  2173. enabled: boolean;
  2174. private _loader;
  2175. /** @hidden */
  2176. constructor(loader: GLTFLoader);
  2177. /** @hidden */
  2178. dispose(): void;
  2179. /** @hidden */
  2180. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  2181. }
  2182. }
  2183. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform" {
  2184. import { Nullable } from "babylonjs/types";
  2185. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  2186. import { ITextureInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2187. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2188. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2189. /**
  2190. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  2191. */
  2192. export class KHR_texture_transform implements IGLTFLoaderExtension {
  2193. /**
  2194. * The name of this extension.
  2195. */
  2196. readonly name: string;
  2197. /**
  2198. * Defines whether this extension is enabled.
  2199. */
  2200. enabled: boolean;
  2201. private _loader;
  2202. /** @hidden */
  2203. constructor(loader: GLTFLoader);
  2204. /** @hidden */
  2205. dispose(): void;
  2206. /** @hidden */
  2207. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  2208. }
  2209. }
  2210. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_xmp" {
  2211. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2212. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2213. /**
  2214. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  2215. * !!! Experimental Extension Subject to Changes !!!
  2216. */
  2217. export class KHR_xmp implements IGLTFLoaderExtension {
  2218. /**
  2219. * The name of this extension.
  2220. */
  2221. readonly name: string;
  2222. /**
  2223. * Defines whether this extension is enabled.
  2224. */
  2225. enabled: boolean;
  2226. /**
  2227. * Defines a number that determines the order the extensions are applied.
  2228. */
  2229. order: number;
  2230. private _loader;
  2231. /** @hidden */
  2232. constructor(loader: GLTFLoader);
  2233. /** @hidden */
  2234. dispose(): void;
  2235. /**
  2236. * Called after the loader state changes to LOADING.
  2237. */
  2238. onLoading(): void;
  2239. }
  2240. }
  2241. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter" {
  2242. import { Nullable } from "babylonjs/types";
  2243. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  2244. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2245. import { IScene, INode, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2246. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2247. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2248. /**
  2249. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  2250. */
  2251. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  2252. /**
  2253. * The name of this extension.
  2254. */
  2255. readonly name: string;
  2256. /**
  2257. * Defines whether this extension is enabled.
  2258. */
  2259. enabled: boolean;
  2260. private _loader;
  2261. private _clips;
  2262. private _emitters;
  2263. /** @hidden */
  2264. constructor(loader: GLTFLoader);
  2265. /** @hidden */
  2266. dispose(): void;
  2267. /** @hidden */
  2268. onLoading(): void;
  2269. /** @hidden */
  2270. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  2271. /** @hidden */
  2272. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2273. /** @hidden */
  2274. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  2275. private _loadClipAsync;
  2276. private _loadEmitterAsync;
  2277. private _getEventAction;
  2278. private _loadAnimationEventAsync;
  2279. }
  2280. }
  2281. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
  2282. import { Nullable } from "babylonjs/types";
  2283. import { Observable } from "babylonjs/Misc/observable";
  2284. import { Material } from "babylonjs/Materials/material";
  2285. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2286. import { Mesh } from "babylonjs/Meshes/mesh";
  2287. import { INode, IMaterial, IBuffer, IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2288. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2289. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2290. import { IProperty } from 'babylonjs-gltf2interface';
  2291. /**
  2292. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  2293. */
  2294. export class MSFT_lod implements IGLTFLoaderExtension {
  2295. /**
  2296. * The name of this extension.
  2297. */
  2298. readonly name: string;
  2299. /**
  2300. * Defines whether this extension is enabled.
  2301. */
  2302. enabled: boolean;
  2303. /**
  2304. * Defines a number that determines the order the extensions are applied.
  2305. */
  2306. order: number;
  2307. /**
  2308. * Maximum number of LODs to load, starting from the lowest LOD.
  2309. */
  2310. maxLODsToLoad: number;
  2311. /**
  2312. * Observable raised when all node LODs of one level are loaded.
  2313. * The event data is the index of the loaded LOD starting from zero.
  2314. * Dispose the loader to cancel the loading of the next level of LODs.
  2315. */
  2316. onNodeLODsLoadedObservable: Observable<number>;
  2317. /**
  2318. * Observable raised when all material LODs of one level are loaded.
  2319. * The event data is the index of the loaded LOD starting from zero.
  2320. * Dispose the loader to cancel the loading of the next level of LODs.
  2321. */
  2322. onMaterialLODsLoadedObservable: Observable<number>;
  2323. private _loader;
  2324. private _nodeIndexLOD;
  2325. private _nodeSignalLODs;
  2326. private _nodePromiseLODs;
  2327. private _materialIndexLOD;
  2328. private _materialSignalLODs;
  2329. private _materialPromiseLODs;
  2330. private _indexLOD;
  2331. private _bufferLODs;
  2332. /** @hidden */
  2333. constructor(loader: GLTFLoader);
  2334. /** @hidden */
  2335. dispose(): void;
  2336. /** @hidden */
  2337. onReady(): void;
  2338. /** @hidden */
  2339. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  2340. /** @hidden */
  2341. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2342. /** @hidden */
  2343. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  2344. /** @hidden */
  2345. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  2346. /** @hidden */
  2347. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  2348. private _loadBufferLOD;
  2349. /**
  2350. * Gets an array of LOD properties from lowest to highest.
  2351. */
  2352. private _getLODs;
  2353. private _disposeTransformNode;
  2354. private _disposeMaterials;
  2355. }
  2356. }
  2357. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh" {
  2358. import { Nullable } from "babylonjs/types";
  2359. import { Material } from "babylonjs/Materials/material";
  2360. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2361. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2362. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2363. /** @hidden */
  2364. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  2365. readonly name: string;
  2366. enabled: boolean;
  2367. private _loader;
  2368. constructor(loader: GLTFLoader);
  2369. dispose(): void;
  2370. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2371. }
  2372. }
  2373. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors" {
  2374. import { Nullable } from "babylonjs/types";
  2375. import { Material } from "babylonjs/Materials/material";
  2376. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2377. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2378. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2379. /** @hidden */
  2380. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  2381. readonly name: string;
  2382. enabled: boolean;
  2383. private _loader;
  2384. constructor(loader: GLTFLoader);
  2385. dispose(): void;
  2386. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2387. }
  2388. }
  2389. declare module "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata" {
  2390. import { Nullable } from "babylonjs/types";
  2391. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2392. import { Camera } from "babylonjs/Cameras/camera";
  2393. import { INode, ICamera, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2394. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2395. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2396. import { Material } from "babylonjs/Materials/material";
  2397. /**
  2398. * Store glTF extras (if present) in BJS objects' metadata
  2399. */
  2400. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  2401. /**
  2402. * The name of this extension.
  2403. */
  2404. readonly name: string;
  2405. /**
  2406. * Defines whether this extension is enabled.
  2407. */
  2408. enabled: boolean;
  2409. private _loader;
  2410. private _assignExtras;
  2411. /** @hidden */
  2412. constructor(loader: GLTFLoader);
  2413. /** @hidden */
  2414. dispose(): void;
  2415. /** @hidden */
  2416. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2417. /** @hidden */
  2418. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  2419. /** @hidden */
  2420. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  2421. }
  2422. }
  2423. declare module "babylonjs-loaders/glTF/2.0/Extensions/index" {
  2424. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based";
  2425. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_mesh_gpu_instancing";
  2426. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  2427. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual";
  2428. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  2429. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit";
  2430. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_clearcoat";
  2431. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_sheen";
  2432. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular";
  2433. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_ior";
  2434. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_variants";
  2435. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_transmission";
  2436. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_quantization";
  2437. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_basisu";
  2438. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform";
  2439. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_xmp";
  2440. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter";
  2441. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod";
  2442. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh";
  2443. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors";
  2444. export * from "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata";
  2445. }
  2446. declare module "babylonjs-loaders/glTF/2.0/index" {
  2447. export * from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2448. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2449. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2450. export * from "babylonjs-loaders/glTF/2.0/Extensions/index";
  2451. }
  2452. declare module "babylonjs-loaders/glTF/index" {
  2453. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2454. export * from "babylonjs-loaders/glTF/glTFValidation";
  2455. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2456. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2457. export { GLTF1, GLTF2 };
  2458. }
  2459. declare module "babylonjs-loaders/OBJ/mtlFileLoader" {
  2460. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  2461. import { Scene } from "babylonjs/scene";
  2462. /**
  2463. * Class reading and parsing the MTL file bundled with the obj file.
  2464. */
  2465. export class MTLFileLoader {
  2466. /**
  2467. * Invert Y-Axis of referenced textures on load
  2468. */
  2469. static INVERT_TEXTURE_Y: boolean;
  2470. /**
  2471. * All material loaded from the mtl will be set here
  2472. */
  2473. materials: StandardMaterial[];
  2474. /**
  2475. * This function will read the mtl file and create each material described inside
  2476. * This function could be improve by adding :
  2477. * -some component missing (Ni, Tf...)
  2478. * -including the specific options available
  2479. *
  2480. * @param scene defines the scene the material will be created in
  2481. * @param data defines the mtl data to parse
  2482. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  2483. * @param forAssetContainer defines if the material should be registered in the scene
  2484. */
  2485. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  2486. /**
  2487. * Gets the texture for the material.
  2488. *
  2489. * If the material is imported from input file,
  2490. * We sanitize the url to ensure it takes the textre from aside the material.
  2491. *
  2492. * @param rootUrl The root url to load from
  2493. * @param value The value stored in the mtl
  2494. * @return The Texture
  2495. */
  2496. private static _getTexture;
  2497. }
  2498. }
  2499. declare module "babylonjs-loaders/OBJ/objFileLoader" {
  2500. import { Vector2 } from "babylonjs/Maths/math.vector";
  2501. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  2502. import { Skeleton } from "babylonjs/Bones/skeleton";
  2503. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2505. import { ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin } from "babylonjs/Loading/sceneLoader";
  2506. import { AssetContainer } from "babylonjs/assetContainer";
  2507. import { Scene } from "babylonjs/scene";
  2508. /**
  2509. * Options for loading OBJ/MTL files
  2510. */
  2511. type MeshLoadOptions = {
  2512. /**
  2513. * Defines if UVs are optimized by default during load.
  2514. */
  2515. OptimizeWithUV: boolean;
  2516. /**
  2517. * Defines custom scaling of UV coordinates of loaded meshes.
  2518. */
  2519. UVScaling: Vector2;
  2520. /**
  2521. * Invert model on y-axis (does a model scaling inversion)
  2522. */
  2523. InvertY: boolean;
  2524. /**
  2525. * Invert Y-Axis of referenced textures on load
  2526. */
  2527. InvertTextureY: boolean;
  2528. /**
  2529. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2530. */
  2531. ImportVertexColors: boolean;
  2532. /**
  2533. * Compute the normals for the model, even if normals are present in the file.
  2534. */
  2535. ComputeNormals: boolean;
  2536. /**
  2537. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2538. */
  2539. SkipMaterials: boolean;
  2540. /**
  2541. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2542. */
  2543. MaterialLoadingFailsSilently: boolean;
  2544. };
  2545. /**
  2546. * OBJ file type loader.
  2547. * This is a babylon scene loader plugin.
  2548. */
  2549. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2550. /**
  2551. * Defines if UVs are optimized by default during load.
  2552. */
  2553. static OPTIMIZE_WITH_UV: boolean;
  2554. /**
  2555. * Invert model on y-axis (does a model scaling inversion)
  2556. */
  2557. static INVERT_Y: boolean;
  2558. /**
  2559. * Invert Y-Axis of referenced textures on load
  2560. */
  2561. static get INVERT_TEXTURE_Y(): boolean;
  2562. static set INVERT_TEXTURE_Y(value: boolean);
  2563. /**
  2564. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2565. */
  2566. static IMPORT_VERTEX_COLORS: boolean;
  2567. /**
  2568. * Compute the normals for the model, even if normals are present in the file.
  2569. */
  2570. static COMPUTE_NORMALS: boolean;
  2571. /**
  2572. * Defines custom scaling of UV coordinates of loaded meshes.
  2573. */
  2574. static UV_SCALING: Vector2;
  2575. /**
  2576. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2577. */
  2578. static SKIP_MATERIALS: boolean;
  2579. /**
  2580. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2581. *
  2582. * Defaults to true for backwards compatibility.
  2583. */
  2584. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2585. /**
  2586. * Defines the name of the plugin.
  2587. */
  2588. name: string;
  2589. /**
  2590. * Defines the extension the plugin is able to load.
  2591. */
  2592. extensions: string;
  2593. /** @hidden */
  2594. obj: RegExp;
  2595. /** @hidden */
  2596. group: RegExp;
  2597. /** @hidden */
  2598. mtllib: RegExp;
  2599. /** @hidden */
  2600. usemtl: RegExp;
  2601. /** @hidden */
  2602. smooth: RegExp;
  2603. /** @hidden */
  2604. vertexPattern: RegExp;
  2605. /** @hidden */
  2606. normalPattern: RegExp;
  2607. /** @hidden */
  2608. uvPattern: RegExp;
  2609. /** @hidden */
  2610. facePattern1: RegExp;
  2611. /** @hidden */
  2612. facePattern2: RegExp;
  2613. /** @hidden */
  2614. facePattern3: RegExp;
  2615. /** @hidden */
  2616. facePattern4: RegExp;
  2617. /** @hidden */
  2618. facePattern5: RegExp;
  2619. private _forAssetContainer;
  2620. private _meshLoadOptions;
  2621. /**
  2622. * Creates loader for .OBJ files
  2623. *
  2624. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2625. */
  2626. constructor(meshLoadOptions?: MeshLoadOptions);
  2627. private static get currentMeshLoadOptions();
  2628. /**
  2629. * Calls synchronously the MTL file attached to this obj.
  2630. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2631. * Without this function materials are not displayed in the first frame (but displayed after).
  2632. * In consequence it is impossible to get material information in your HTML file
  2633. *
  2634. * @param url The URL of the MTL file
  2635. * @param rootUrl
  2636. * @param onSuccess Callback function to be called when the MTL file is loaded
  2637. * @private
  2638. */
  2639. private _loadMTL;
  2640. /**
  2641. * Instantiates a OBJ file loader plugin.
  2642. * @returns the created plugin
  2643. */
  2644. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2645. /**
  2646. * If the data string can be loaded directly.
  2647. *
  2648. * @param data string containing the file data
  2649. * @returns if the data can be loaded directly
  2650. */
  2651. canDirectLoad(data: string): boolean;
  2652. /**
  2653. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2654. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2655. * @param scene the scene the meshes should be added to
  2656. * @param data the OBJ data to load
  2657. * @param rootUrl root url to load from
  2658. * @param onProgress event that fires when loading progress has occured
  2659. * @param fileName Defines the name of the file to load
  2660. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2661. */
  2662. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2663. meshes: AbstractMesh[];
  2664. particleSystems: IParticleSystem[];
  2665. skeletons: Skeleton[];
  2666. animationGroups: AnimationGroup[];
  2667. }>;
  2668. /**
  2669. * Imports all objects from the loaded OBJ data and adds them to the scene
  2670. * @param scene the scene the objects should be added to
  2671. * @param data the OBJ data to load
  2672. * @param rootUrl root url to load from
  2673. * @param onProgress event that fires when loading progress has occured
  2674. * @param fileName Defines the name of the file to load
  2675. * @returns a promise which completes when objects have been loaded to the scene
  2676. */
  2677. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2678. /**
  2679. * Load into an asset container.
  2680. * @param scene The scene to load into
  2681. * @param data The data to import
  2682. * @param rootUrl The root url for scene and resources
  2683. * @param onProgress The callback when the load progresses
  2684. * @param fileName Defines the name of the file to load
  2685. * @returns The loaded asset container
  2686. */
  2687. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2688. /**
  2689. * Read the OBJ file and create an Array of meshes.
  2690. * Each mesh contains all information given by the OBJ and the MTL file.
  2691. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2692. *
  2693. * @param meshesNames
  2694. * @param scene Scene The scene where are displayed the data
  2695. * @param data String The content of the obj file
  2696. * @param rootUrl String The path to the folder
  2697. * @returns Array<AbstractMesh>
  2698. * @private
  2699. */
  2700. private _parseSolid;
  2701. }
  2702. }
  2703. declare module "babylonjs-loaders/OBJ/index" {
  2704. export * from "babylonjs-loaders/OBJ/mtlFileLoader";
  2705. export * from "babylonjs-loaders/OBJ/objFileLoader";
  2706. }
  2707. declare module "babylonjs-loaders/STL/stlFileLoader" {
  2708. import { Nullable } from "babylonjs/types";
  2709. import { Skeleton } from "babylonjs/Bones/skeleton";
  2710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2712. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  2713. import { AssetContainer } from "babylonjs/assetContainer";
  2714. import { Scene } from "babylonjs/scene";
  2715. /**
  2716. * STL file type loader.
  2717. * This is a babylon scene loader plugin.
  2718. */
  2719. export class STLFileLoader implements ISceneLoaderPlugin {
  2720. /** @hidden */
  2721. solidPattern: RegExp;
  2722. /** @hidden */
  2723. facetsPattern: RegExp;
  2724. /** @hidden */
  2725. normalPattern: RegExp;
  2726. /** @hidden */
  2727. vertexPattern: RegExp;
  2728. /**
  2729. * Defines the name of the plugin.
  2730. */
  2731. name: string;
  2732. /**
  2733. * Defines the extensions the stl loader is able to load.
  2734. * force data to come in as an ArrayBuffer
  2735. * we'll convert to string if it looks like it's an ASCII .stl
  2736. */
  2737. extensions: ISceneLoaderPluginExtensions;
  2738. /**
  2739. * Import meshes into a scene.
  2740. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2741. * @param scene The scene to import into
  2742. * @param data The data to import
  2743. * @param rootUrl The root url for scene and resources
  2744. * @param meshes The meshes array to import into
  2745. * @param particleSystems The particle systems array to import into
  2746. * @param skeletons The skeletons array to import into
  2747. * @param onError The callback when import fails
  2748. * @returns True if successful or false otherwise
  2749. */
  2750. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2751. /**
  2752. * Load into a scene.
  2753. * @param scene The scene to load into
  2754. * @param data The data to import
  2755. * @param rootUrl The root url for scene and resources
  2756. * @param onError The callback when import fails
  2757. * @returns true if successful or false otherwise
  2758. */
  2759. load(scene: Scene, data: any, rootUrl: string): boolean;
  2760. /**
  2761. * Load into an asset container.
  2762. * @param scene The scene to load into
  2763. * @param data The data to import
  2764. * @param rootUrl The root url for scene and resources
  2765. * @param onError The callback when import fails
  2766. * @returns The loaded asset container
  2767. */
  2768. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2769. private _isBinary;
  2770. private _parseBinary;
  2771. private _parseASCII;
  2772. }
  2773. }
  2774. declare module "babylonjs-loaders/STL/index" {
  2775. export * from "babylonjs-loaders/STL/stlFileLoader";
  2776. }
  2777. declare module "babylonjs-loaders/index" {
  2778. export * from "babylonjs-loaders/glTF/index";
  2779. export * from "babylonjs-loaders/OBJ/index";
  2780. export * from "babylonjs-loaders/STL/index";
  2781. }
  2782. declare module "babylonjs-loaders/legacy/legacy-glTF" {
  2783. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2784. export * from "babylonjs-loaders/glTF/glTFValidation";
  2785. }
  2786. declare module "babylonjs-loaders/legacy/legacy-glTF1" {
  2787. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2788. export { GLTF1 };
  2789. }
  2790. declare module "babylonjs-loaders/legacy/legacy-glTF1FileLoader" {
  2791. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2792. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2793. }
  2794. declare module "babylonjs-loaders/legacy/legacy-glTF2" {
  2795. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2796. export { GLTF2 };
  2797. }
  2798. declare module "babylonjs-loaders/legacy/legacy-glTF2FileLoader" {
  2799. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2800. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2801. }
  2802. declare module "babylonjs-loaders/legacy/legacy-glTFFileLoader" {
  2803. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2804. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2805. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2806. }
  2807. declare module "babylonjs-loaders/legacy/legacy-objFileLoader" {
  2808. export * from "babylonjs-loaders/OBJ/index";
  2809. }
  2810. declare module "babylonjs-loaders/legacy/legacy-stlFileLoader" {
  2811. export * from "babylonjs-loaders/STL/index";
  2812. }
  2813. declare module "babylonjs-loaders/legacy/legacy" {
  2814. import "babylonjs-loaders/index";
  2815. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2816. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2817. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2818. export * from "babylonjs-loaders/legacy/legacy-objFileLoader";
  2819. export * from "babylonjs-loaders/legacy/legacy-stlFileLoader";
  2820. }
  2821. declare module "babylonjs-loaders" {
  2822. export * from "babylonjs-loaders/legacy/legacy";
  2823. }
  2824. declare module BABYLON {
  2825. /**
  2826. * Configuration for glTF validation
  2827. */
  2828. export interface IGLTFValidationConfiguration {
  2829. /**
  2830. * The url of the glTF validator.
  2831. */
  2832. url: string;
  2833. }
  2834. /**
  2835. * glTF validation
  2836. */
  2837. export class GLTFValidation {
  2838. /**
  2839. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  2840. */
  2841. static Configuration: IGLTFValidationConfiguration;
  2842. private static _LoadScriptPromise;
  2843. /**
  2844. * Validate a glTF asset using the glTF-Validator.
  2845. * @param data The JSON of a glTF or the array buffer of a binary glTF
  2846. * @param rootUrl The root url for the glTF
  2847. * @param fileName The file name for the glTF
  2848. * @param getExternalResource The callback to get external resources for the glTF validator
  2849. * @returns A promise that resolves with the glTF validation results once complete
  2850. */
  2851. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  2852. }
  2853. }
  2854. declare module BABYLON {
  2855. /**
  2856. * Mode that determines the coordinate system to use.
  2857. */
  2858. export enum GLTFLoaderCoordinateSystemMode {
  2859. /**
  2860. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2861. */
  2862. AUTO = 0,
  2863. /**
  2864. * Sets the useRightHandedSystem flag on the scene.
  2865. */
  2866. FORCE_RIGHT_HANDED = 1
  2867. }
  2868. /**
  2869. * Mode that determines what animations will start.
  2870. */
  2871. export enum GLTFLoaderAnimationStartMode {
  2872. /**
  2873. * No animation will start.
  2874. */
  2875. NONE = 0,
  2876. /**
  2877. * The first animation will start.
  2878. */
  2879. FIRST = 1,
  2880. /**
  2881. * All animations will start.
  2882. */
  2883. ALL = 2
  2884. }
  2885. /**
  2886. * Interface that contains the data for the glTF asset.
  2887. */
  2888. export interface IGLTFLoaderData {
  2889. /**
  2890. * The object that represents the glTF JSON.
  2891. */
  2892. json: Object;
  2893. /**
  2894. * The BIN chunk of a binary glTF.
  2895. */
  2896. bin: Nullable<IDataBuffer>;
  2897. }
  2898. /**
  2899. * Interface for extending the loader.
  2900. */
  2901. export interface IGLTFLoaderExtension {
  2902. /**
  2903. * The name of this extension.
  2904. */
  2905. readonly name: string;
  2906. /**
  2907. * Defines whether this extension is enabled.
  2908. */
  2909. enabled: boolean;
  2910. /**
  2911. * Defines the order of this extension.
  2912. * The loader sorts the extensions using these values when loading.
  2913. */
  2914. order?: number;
  2915. }
  2916. /**
  2917. * Loader state.
  2918. */
  2919. export enum GLTFLoaderState {
  2920. /**
  2921. * The asset is loading.
  2922. */
  2923. LOADING = 0,
  2924. /**
  2925. * The asset is ready for rendering.
  2926. */
  2927. READY = 1,
  2928. /**
  2929. * The asset is completely loaded.
  2930. */
  2931. COMPLETE = 2
  2932. }
  2933. /** @hidden */
  2934. export interface IImportMeshAsyncOutput {
  2935. meshes: AbstractMesh[];
  2936. particleSystems: IParticleSystem[];
  2937. skeletons: Skeleton[];
  2938. animationGroups: AnimationGroup[];
  2939. lights: Light[];
  2940. transformNodes: TransformNode[];
  2941. }
  2942. /** @hidden */
  2943. export interface IGLTFLoader extends IDisposable {
  2944. readonly state: Nullable<GLTFLoaderState>;
  2945. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  2946. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  2947. }
  2948. /**
  2949. * File loader for loading glTF files into a scene.
  2950. */
  2951. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2952. /** @hidden */
  2953. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2954. /** @hidden */
  2955. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2956. /**
  2957. * Raised when the asset has been parsed
  2958. */
  2959. onParsedObservable: Observable<IGLTFLoaderData>;
  2960. private _onParsedObserver;
  2961. /**
  2962. * Raised when the asset has been parsed
  2963. */
  2964. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  2965. /**
  2966. * 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.
  2967. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  2968. * Defaults to true.
  2969. * @hidden
  2970. */
  2971. static IncrementalLoading: boolean;
  2972. /**
  2973. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  2974. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  2975. * @hidden
  2976. */
  2977. static HomogeneousCoordinates: boolean;
  2978. /**
  2979. * The coordinate system mode. Defaults to AUTO.
  2980. */
  2981. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  2982. /**
  2983. * The animation start mode. Defaults to FIRST.
  2984. */
  2985. animationStartMode: GLTFLoaderAnimationStartMode;
  2986. /**
  2987. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  2988. */
  2989. compileMaterials: boolean;
  2990. /**
  2991. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  2992. */
  2993. useClipPlane: boolean;
  2994. /**
  2995. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  2996. */
  2997. compileShadowGenerators: boolean;
  2998. /**
  2999. * Defines if the Alpha blended materials are only applied as coverage.
  3000. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  3001. * If true, no extra effects are applied to transparent pixels.
  3002. */
  3003. transparencyAsCoverage: boolean;
  3004. /**
  3005. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  3006. * Enabling will disable offline support and glTF validator.
  3007. * Defaults to false.
  3008. */
  3009. useRangeRequests: boolean;
  3010. /**
  3011. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  3012. */
  3013. createInstances: boolean;
  3014. /**
  3015. * Function called before loading a url referenced by the asset.
  3016. */
  3017. preprocessUrlAsync: (url: string) => Promise<string>;
  3018. /**
  3019. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  3020. */
  3021. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  3022. private _onMeshLoadedObserver;
  3023. /**
  3024. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  3025. */
  3026. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  3027. /**
  3028. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  3029. */
  3030. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  3031. private _onTextureLoadedObserver;
  3032. /**
  3033. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  3034. */
  3035. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  3036. /**
  3037. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  3038. */
  3039. readonly onMaterialLoadedObservable: Observable<Material>;
  3040. private _onMaterialLoadedObserver;
  3041. /**
  3042. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  3043. */
  3044. set onMaterialLoaded(callback: (material: Material) => void);
  3045. /**
  3046. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  3047. */
  3048. readonly onCameraLoadedObservable: Observable<Camera>;
  3049. private _onCameraLoadedObserver;
  3050. /**
  3051. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  3052. */
  3053. set onCameraLoaded(callback: (camera: Camera) => void);
  3054. /**
  3055. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  3056. * For assets with LODs, raised when all of the LODs are complete.
  3057. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  3058. */
  3059. readonly onCompleteObservable: Observable<void>;
  3060. private _onCompleteObserver;
  3061. /**
  3062. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  3063. * For assets with LODs, raised when all of the LODs are complete.
  3064. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  3065. */
  3066. set onComplete(callback: () => void);
  3067. /**
  3068. * Observable raised when an error occurs.
  3069. */
  3070. readonly onErrorObservable: Observable<any>;
  3071. private _onErrorObserver;
  3072. /**
  3073. * Callback raised when an error occurs.
  3074. */
  3075. set onError(callback: (reason: any) => void);
  3076. /**
  3077. * Observable raised after the loader is disposed.
  3078. */
  3079. readonly onDisposeObservable: Observable<void>;
  3080. private _onDisposeObserver;
  3081. /**
  3082. * Callback raised after the loader is disposed.
  3083. */
  3084. set onDispose(callback: () => void);
  3085. /**
  3086. * Observable raised after a loader extension is created.
  3087. * Set additional options for a loader extension in this event.
  3088. */
  3089. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  3090. private _onExtensionLoadedObserver;
  3091. /**
  3092. * Callback raised after a loader extension is created.
  3093. */
  3094. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  3095. /**
  3096. * Defines if the loader logging is enabled.
  3097. */
  3098. get loggingEnabled(): boolean;
  3099. set loggingEnabled(value: boolean);
  3100. /**
  3101. * Defines if the loader should capture performance counters.
  3102. */
  3103. get capturePerformanceCounters(): boolean;
  3104. set capturePerformanceCounters(value: boolean);
  3105. /**
  3106. * Defines if the loader should validate the asset.
  3107. */
  3108. validate: boolean;
  3109. /**
  3110. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  3111. */
  3112. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  3113. private _onValidatedObserver;
  3114. /**
  3115. * Callback raised after a loader extension is created.
  3116. */
  3117. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  3118. private _loader;
  3119. /**
  3120. * Name of the loader ("gltf")
  3121. */
  3122. name: string;
  3123. /** @hidden */
  3124. extensions: ISceneLoaderPluginExtensions;
  3125. /**
  3126. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  3127. */
  3128. dispose(): void;
  3129. /** @hidden */
  3130. _clear(): void;
  3131. /** @hidden */
  3132. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  3133. /** @hidden */
  3134. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  3135. /** @hidden */
  3136. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  3137. meshes: AbstractMesh[];
  3138. particleSystems: IParticleSystem[];
  3139. skeletons: Skeleton[];
  3140. animationGroups: AnimationGroup[];
  3141. }>;
  3142. /** @hidden */
  3143. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  3144. /** @hidden */
  3145. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  3146. /** @hidden */
  3147. canDirectLoad(data: string): boolean;
  3148. /** @hidden */
  3149. directLoad(scene: Scene, data: string): any;
  3150. /**
  3151. * The callback that allows custom handling of the root url based on the response url.
  3152. * @param rootUrl the original root url
  3153. * @param responseURL the response url if available
  3154. * @returns the new root url
  3155. */
  3156. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  3157. /** @hidden */
  3158. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  3159. /**
  3160. * The loader state or null if the loader is not active.
  3161. */
  3162. get loaderState(): Nullable<GLTFLoaderState>;
  3163. /**
  3164. * Returns a promise that resolves when the asset is completely loaded.
  3165. * @returns a promise that resolves when the asset is completely loaded.
  3166. */
  3167. whenCompleteAsync(): Promise<void>;
  3168. private _validate;
  3169. private _getLoader;
  3170. private _parseJson;
  3171. private _unpackBinaryAsync;
  3172. private _unpackBinaryV1Async;
  3173. private _unpackBinaryV2Async;
  3174. private static _parseVersion;
  3175. private static _compareVersion;
  3176. private static readonly _logSpaces;
  3177. private _logIndentLevel;
  3178. private _loggingEnabled;
  3179. /** @hidden */
  3180. _log: (message: string) => void;
  3181. /** @hidden */
  3182. _logOpen(message: string): void;
  3183. /** @hidden */
  3184. _logClose(): void;
  3185. private _logEnabled;
  3186. private _logDisabled;
  3187. private _capturePerformanceCounters;
  3188. /** @hidden */
  3189. _startPerformanceCounter: (counterName: string) => void;
  3190. /** @hidden */
  3191. _endPerformanceCounter: (counterName: string) => void;
  3192. private _startPerformanceCounterEnabled;
  3193. private _startPerformanceCounterDisabled;
  3194. private _endPerformanceCounterEnabled;
  3195. private _endPerformanceCounterDisabled;
  3196. }
  3197. }
  3198. declare module BABYLON.GLTF1 {
  3199. /**
  3200. * Enums
  3201. * @hidden
  3202. */
  3203. export enum EComponentType {
  3204. BYTE = 5120,
  3205. UNSIGNED_BYTE = 5121,
  3206. SHORT = 5122,
  3207. UNSIGNED_SHORT = 5123,
  3208. FLOAT = 5126
  3209. }
  3210. /** @hidden */
  3211. export enum EShaderType {
  3212. FRAGMENT = 35632,
  3213. VERTEX = 35633
  3214. }
  3215. /** @hidden */
  3216. export enum EParameterType {
  3217. BYTE = 5120,
  3218. UNSIGNED_BYTE = 5121,
  3219. SHORT = 5122,
  3220. UNSIGNED_SHORT = 5123,
  3221. INT = 5124,
  3222. UNSIGNED_INT = 5125,
  3223. FLOAT = 5126,
  3224. FLOAT_VEC2 = 35664,
  3225. FLOAT_VEC3 = 35665,
  3226. FLOAT_VEC4 = 35666,
  3227. INT_VEC2 = 35667,
  3228. INT_VEC3 = 35668,
  3229. INT_VEC4 = 35669,
  3230. BOOL = 35670,
  3231. BOOL_VEC2 = 35671,
  3232. BOOL_VEC3 = 35672,
  3233. BOOL_VEC4 = 35673,
  3234. FLOAT_MAT2 = 35674,
  3235. FLOAT_MAT3 = 35675,
  3236. FLOAT_MAT4 = 35676,
  3237. SAMPLER_2D = 35678
  3238. }
  3239. /** @hidden */
  3240. export enum ETextureWrapMode {
  3241. CLAMP_TO_EDGE = 33071,
  3242. MIRRORED_REPEAT = 33648,
  3243. REPEAT = 10497
  3244. }
  3245. /** @hidden */
  3246. export enum ETextureFilterType {
  3247. NEAREST = 9728,
  3248. LINEAR = 9728,
  3249. NEAREST_MIPMAP_NEAREST = 9984,
  3250. LINEAR_MIPMAP_NEAREST = 9985,
  3251. NEAREST_MIPMAP_LINEAR = 9986,
  3252. LINEAR_MIPMAP_LINEAR = 9987
  3253. }
  3254. /** @hidden */
  3255. export enum ETextureFormat {
  3256. ALPHA = 6406,
  3257. RGB = 6407,
  3258. RGBA = 6408,
  3259. LUMINANCE = 6409,
  3260. LUMINANCE_ALPHA = 6410
  3261. }
  3262. /** @hidden */
  3263. export enum ECullingType {
  3264. FRONT = 1028,
  3265. BACK = 1029,
  3266. FRONT_AND_BACK = 1032
  3267. }
  3268. /** @hidden */
  3269. export enum EBlendingFunction {
  3270. ZERO = 0,
  3271. ONE = 1,
  3272. SRC_COLOR = 768,
  3273. ONE_MINUS_SRC_COLOR = 769,
  3274. DST_COLOR = 774,
  3275. ONE_MINUS_DST_COLOR = 775,
  3276. SRC_ALPHA = 770,
  3277. ONE_MINUS_SRC_ALPHA = 771,
  3278. DST_ALPHA = 772,
  3279. ONE_MINUS_DST_ALPHA = 773,
  3280. CONSTANT_COLOR = 32769,
  3281. ONE_MINUS_CONSTANT_COLOR = 32770,
  3282. CONSTANT_ALPHA = 32771,
  3283. ONE_MINUS_CONSTANT_ALPHA = 32772,
  3284. SRC_ALPHA_SATURATE = 776
  3285. }
  3286. /** @hidden */
  3287. export interface IGLTFProperty {
  3288. extensions?: {
  3289. [key: string]: any;
  3290. };
  3291. extras?: Object;
  3292. }
  3293. /** @hidden */
  3294. export interface IGLTFChildRootProperty extends IGLTFProperty {
  3295. name?: string;
  3296. }
  3297. /** @hidden */
  3298. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  3299. bufferView: string;
  3300. byteOffset: number;
  3301. byteStride: number;
  3302. count: number;
  3303. type: string;
  3304. componentType: EComponentType;
  3305. max?: number[];
  3306. min?: number[];
  3307. name?: string;
  3308. }
  3309. /** @hidden */
  3310. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  3311. buffer: string;
  3312. byteOffset: number;
  3313. byteLength: number;
  3314. byteStride: number;
  3315. target?: number;
  3316. }
  3317. /** @hidden */
  3318. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  3319. uri: string;
  3320. byteLength?: number;
  3321. type?: string;
  3322. }
  3323. /** @hidden */
  3324. export interface IGLTFShader extends IGLTFChildRootProperty {
  3325. uri: string;
  3326. type: EShaderType;
  3327. }
  3328. /** @hidden */
  3329. export interface IGLTFProgram extends IGLTFChildRootProperty {
  3330. attributes: string[];
  3331. fragmentShader: string;
  3332. vertexShader: string;
  3333. }
  3334. /** @hidden */
  3335. export interface IGLTFTechniqueParameter {
  3336. type: number;
  3337. count?: number;
  3338. semantic?: string;
  3339. node?: string;
  3340. value?: number | boolean | string | Array<any>;
  3341. source?: string;
  3342. babylonValue?: any;
  3343. }
  3344. /** @hidden */
  3345. export interface IGLTFTechniqueCommonProfile {
  3346. lightingModel: string;
  3347. texcoordBindings: Object;
  3348. parameters?: Array<any>;
  3349. }
  3350. /** @hidden */
  3351. export interface IGLTFTechniqueStatesFunctions {
  3352. blendColor?: number[];
  3353. blendEquationSeparate?: number[];
  3354. blendFuncSeparate?: number[];
  3355. colorMask: boolean[];
  3356. cullFace: number[];
  3357. }
  3358. /** @hidden */
  3359. export interface IGLTFTechniqueStates {
  3360. enable: number[];
  3361. functions: IGLTFTechniqueStatesFunctions;
  3362. }
  3363. /** @hidden */
  3364. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  3365. parameters: {
  3366. [key: string]: IGLTFTechniqueParameter;
  3367. };
  3368. program: string;
  3369. attributes: {
  3370. [key: string]: string;
  3371. };
  3372. uniforms: {
  3373. [key: string]: string;
  3374. };
  3375. states: IGLTFTechniqueStates;
  3376. }
  3377. /** @hidden */
  3378. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  3379. technique?: string;
  3380. values: string[];
  3381. }
  3382. /** @hidden */
  3383. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  3384. attributes: {
  3385. [key: string]: string;
  3386. };
  3387. indices: string;
  3388. material: string;
  3389. mode?: number;
  3390. }
  3391. /** @hidden */
  3392. export interface IGLTFMesh extends IGLTFChildRootProperty {
  3393. primitives: IGLTFMeshPrimitive[];
  3394. }
  3395. /** @hidden */
  3396. export interface IGLTFImage extends IGLTFChildRootProperty {
  3397. uri: string;
  3398. }
  3399. /** @hidden */
  3400. export interface IGLTFSampler extends IGLTFChildRootProperty {
  3401. magFilter?: number;
  3402. minFilter?: number;
  3403. wrapS?: number;
  3404. wrapT?: number;
  3405. }
  3406. /** @hidden */
  3407. export interface IGLTFTexture extends IGLTFChildRootProperty {
  3408. sampler: string;
  3409. source: string;
  3410. format?: ETextureFormat;
  3411. internalFormat?: ETextureFormat;
  3412. target?: number;
  3413. type?: number;
  3414. babylonTexture?: Texture;
  3415. }
  3416. /** @hidden */
  3417. export interface IGLTFAmbienLight {
  3418. color?: number[];
  3419. }
  3420. /** @hidden */
  3421. export interface IGLTFDirectionalLight {
  3422. color?: number[];
  3423. }
  3424. /** @hidden */
  3425. export interface IGLTFPointLight {
  3426. color?: number[];
  3427. constantAttenuation?: number;
  3428. linearAttenuation?: number;
  3429. quadraticAttenuation?: number;
  3430. }
  3431. /** @hidden */
  3432. export interface IGLTFSpotLight {
  3433. color?: number[];
  3434. constantAttenuation?: number;
  3435. fallOfAngle?: number;
  3436. fallOffExponent?: number;
  3437. linearAttenuation?: number;
  3438. quadraticAttenuation?: number;
  3439. }
  3440. /** @hidden */
  3441. export interface IGLTFLight extends IGLTFChildRootProperty {
  3442. type: string;
  3443. }
  3444. /** @hidden */
  3445. export interface IGLTFCameraOrthographic {
  3446. xmag: number;
  3447. ymag: number;
  3448. zfar: number;
  3449. znear: number;
  3450. }
  3451. /** @hidden */
  3452. export interface IGLTFCameraPerspective {
  3453. aspectRatio: number;
  3454. yfov: number;
  3455. zfar: number;
  3456. znear: number;
  3457. }
  3458. /** @hidden */
  3459. export interface IGLTFCamera extends IGLTFChildRootProperty {
  3460. type: string;
  3461. }
  3462. /** @hidden */
  3463. export interface IGLTFAnimationChannelTarget {
  3464. id: string;
  3465. path: string;
  3466. }
  3467. /** @hidden */
  3468. export interface IGLTFAnimationChannel {
  3469. sampler: string;
  3470. target: IGLTFAnimationChannelTarget;
  3471. }
  3472. /** @hidden */
  3473. export interface IGLTFAnimationSampler {
  3474. input: string;
  3475. output: string;
  3476. interpolation?: string;
  3477. }
  3478. /** @hidden */
  3479. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  3480. channels?: IGLTFAnimationChannel[];
  3481. parameters?: {
  3482. [key: string]: string;
  3483. };
  3484. samplers?: {
  3485. [key: string]: IGLTFAnimationSampler;
  3486. };
  3487. }
  3488. /** @hidden */
  3489. export interface IGLTFNodeInstanceSkin {
  3490. skeletons: string[];
  3491. skin: string;
  3492. meshes: string[];
  3493. }
  3494. /** @hidden */
  3495. export interface IGLTFSkins extends IGLTFChildRootProperty {
  3496. bindShapeMatrix: number[];
  3497. inverseBindMatrices: string;
  3498. jointNames: string[];
  3499. babylonSkeleton?: Skeleton;
  3500. }
  3501. /** @hidden */
  3502. export interface IGLTFNode extends IGLTFChildRootProperty {
  3503. camera?: string;
  3504. children: string[];
  3505. skin?: string;
  3506. jointName?: string;
  3507. light?: string;
  3508. matrix: number[];
  3509. mesh?: string;
  3510. meshes?: string[];
  3511. rotation?: number[];
  3512. scale?: number[];
  3513. translation?: number[];
  3514. babylonNode?: Node;
  3515. }
  3516. /** @hidden */
  3517. export interface IGLTFScene extends IGLTFChildRootProperty {
  3518. nodes: string[];
  3519. }
  3520. /** @hidden */
  3521. export interface IGLTFRuntime {
  3522. extensions: {
  3523. [key: string]: any;
  3524. };
  3525. accessors: {
  3526. [key: string]: IGLTFAccessor;
  3527. };
  3528. buffers: {
  3529. [key: string]: IGLTFBuffer;
  3530. };
  3531. bufferViews: {
  3532. [key: string]: IGLTFBufferView;
  3533. };
  3534. meshes: {
  3535. [key: string]: IGLTFMesh;
  3536. };
  3537. lights: {
  3538. [key: string]: IGLTFLight;
  3539. };
  3540. cameras: {
  3541. [key: string]: IGLTFCamera;
  3542. };
  3543. nodes: {
  3544. [key: string]: IGLTFNode;
  3545. };
  3546. images: {
  3547. [key: string]: IGLTFImage;
  3548. };
  3549. textures: {
  3550. [key: string]: IGLTFTexture;
  3551. };
  3552. shaders: {
  3553. [key: string]: IGLTFShader;
  3554. };
  3555. programs: {
  3556. [key: string]: IGLTFProgram;
  3557. };
  3558. samplers: {
  3559. [key: string]: IGLTFSampler;
  3560. };
  3561. techniques: {
  3562. [key: string]: IGLTFTechnique;
  3563. };
  3564. materials: {
  3565. [key: string]: IGLTFMaterial;
  3566. };
  3567. animations: {
  3568. [key: string]: IGLTFAnimation;
  3569. };
  3570. skins: {
  3571. [key: string]: IGLTFSkins;
  3572. };
  3573. currentScene?: Object;
  3574. scenes: {
  3575. [key: string]: IGLTFScene;
  3576. };
  3577. extensionsUsed: string[];
  3578. extensionsRequired?: string[];
  3579. buffersCount: number;
  3580. shaderscount: number;
  3581. scene: Scene;
  3582. rootUrl: string;
  3583. loadedBufferCount: number;
  3584. loadedBufferViews: {
  3585. [name: string]: ArrayBufferView;
  3586. };
  3587. loadedShaderCount: number;
  3588. importOnlyMeshes: boolean;
  3589. importMeshesNames?: string[];
  3590. dummyNodes: Node[];
  3591. forAssetContainer: boolean;
  3592. }
  3593. /** @hidden */
  3594. export interface INodeToRoot {
  3595. bone: Bone;
  3596. node: IGLTFNode;
  3597. id: string;
  3598. }
  3599. /** @hidden */
  3600. export interface IJointNode {
  3601. node: IGLTFNode;
  3602. id: string;
  3603. }
  3604. }
  3605. declare module BABYLON.GLTF1 {
  3606. /**
  3607. * Utils functions for GLTF
  3608. * @hidden
  3609. */
  3610. export class GLTFUtils {
  3611. /**
  3612. * Sets the given "parameter" matrix
  3613. * @param scene: the Scene object
  3614. * @param source: the source node where to pick the matrix
  3615. * @param parameter: the GLTF technique parameter
  3616. * @param uniformName: the name of the shader's uniform
  3617. * @param shaderMaterial: the shader material
  3618. */
  3619. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  3620. /**
  3621. * Sets the given "parameter" matrix
  3622. * @param shaderMaterial: the shader material
  3623. * @param uniform: the name of the shader's uniform
  3624. * @param value: the value of the uniform
  3625. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3626. */
  3627. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  3628. /**
  3629. * Returns the wrap mode of the texture
  3630. * @param mode: the mode value
  3631. */
  3632. static GetWrapMode(mode: number): number;
  3633. /**
  3634. * Returns the byte stride giving an accessor
  3635. * @param accessor: the GLTF accessor objet
  3636. */
  3637. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  3638. /**
  3639. * Returns the texture filter mode giving a mode value
  3640. * @param mode: the filter mode value
  3641. */
  3642. static GetTextureFilterMode(mode: number): ETextureFilterType;
  3643. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  3644. /**
  3645. * Returns a buffer from its accessor
  3646. * @param gltfRuntime: the GLTF runtime
  3647. * @param accessor: the GLTF accessor
  3648. */
  3649. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  3650. /**
  3651. * Decodes a buffer view into a string
  3652. * @param view: the buffer view
  3653. */
  3654. static DecodeBufferToText(view: ArrayBufferView): string;
  3655. /**
  3656. * Returns the default material of gltf. Related to
  3657. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3658. * @param scene: the Babylon.js scene
  3659. */
  3660. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  3661. private static _DefaultMaterial;
  3662. }
  3663. }
  3664. declare module BABYLON.GLTF1 {
  3665. /**
  3666. * Implementation of the base glTF spec
  3667. * @hidden
  3668. */
  3669. export class GLTFLoaderBase {
  3670. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  3671. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3672. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  3673. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3674. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  3675. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3676. }
  3677. /**
  3678. * glTF V1 Loader
  3679. * @hidden
  3680. */
  3681. export class GLTFLoader implements IGLTFLoader {
  3682. static Extensions: {
  3683. [name: string]: GLTFLoaderExtension;
  3684. };
  3685. static RegisterExtension(extension: GLTFLoaderExtension): void;
  3686. state: Nullable<GLTFLoaderState>;
  3687. dispose(): void;
  3688. private _importMeshAsync;
  3689. /**
  3690. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3691. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3692. * @param scene the scene the meshes should be added to
  3693. * @param forAssetContainer defines if the entities must be stored in the scene
  3694. * @param data gltf data containing information of the meshes in a loaded file
  3695. * @param rootUrl root url to load from
  3696. * @param onProgress event that fires when loading progress has occured
  3697. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3698. */
  3699. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  3700. private _loadAsync;
  3701. /**
  3702. * Imports all objects from a loaded gltf file and adds them to the scene
  3703. * @param scene the scene the objects should be added to
  3704. * @param data gltf data containing information of the meshes in a loaded file
  3705. * @param rootUrl root url to load from
  3706. * @param onProgress event that fires when loading progress has occured
  3707. * @returns a promise which completes when objects have been loaded to the scene
  3708. */
  3709. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  3710. private _loadShadersAsync;
  3711. private _loadBuffersAsync;
  3712. private _createNodes;
  3713. }
  3714. /** @hidden */
  3715. export abstract class GLTFLoaderExtension {
  3716. private _name;
  3717. constructor(name: string);
  3718. get name(): string;
  3719. /**
  3720. * Defines an override for loading the runtime
  3721. * Return true to stop further extensions from loading the runtime
  3722. */
  3723. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  3724. /**
  3725. * Defines an onverride for creating gltf runtime
  3726. * Return true to stop further extensions from creating the runtime
  3727. */
  3728. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  3729. /**
  3730. * Defines an override for loading buffers
  3731. * Return true to stop further extensions from loading this buffer
  3732. */
  3733. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  3734. /**
  3735. * Defines an override for loading texture buffers
  3736. * Return true to stop further extensions from loading this texture data
  3737. */
  3738. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3739. /**
  3740. * Defines an override for creating textures
  3741. * Return true to stop further extensions from loading this texture
  3742. */
  3743. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  3744. /**
  3745. * Defines an override for loading shader strings
  3746. * Return true to stop further extensions from loading this shader data
  3747. */
  3748. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3749. /**
  3750. * Defines an override for loading materials
  3751. * Return true to stop further extensions from loading this material
  3752. */
  3753. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3754. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  3755. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  3756. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3757. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3758. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  3759. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3760. private static LoadTextureBufferAsync;
  3761. private static CreateTextureAsync;
  3762. private static ApplyExtensions;
  3763. }
  3764. }
  3765. declare module BABYLON.GLTF1 {
  3766. /** @hidden */
  3767. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  3768. private _bin;
  3769. constructor();
  3770. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  3771. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3772. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3773. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3774. }
  3775. }
  3776. declare module BABYLON.GLTF1 {
  3777. /** @hidden */
  3778. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  3779. constructor();
  3780. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  3781. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3782. private _loadTexture;
  3783. }
  3784. }
  3785. declare module BABYLON.GLTF2.Loader {
  3786. /**
  3787. * Loader interface with an index field.
  3788. */
  3789. export interface IArrayItem {
  3790. /**
  3791. * The index of this item in the array.
  3792. */
  3793. index: number;
  3794. }
  3795. /**
  3796. * Loader interface with additional members.
  3797. */
  3798. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3799. /** @hidden */
  3800. _data?: Promise<ArrayBufferView>;
  3801. /** @hidden */
  3802. _babylonVertexBuffer?: Promise<VertexBuffer>;
  3803. }
  3804. /**
  3805. * Loader interface with additional members.
  3806. */
  3807. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3808. }
  3809. /** @hidden */
  3810. export interface _IAnimationSamplerData {
  3811. input: Float32Array;
  3812. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3813. output: Float32Array;
  3814. }
  3815. /**
  3816. * Loader interface with additional members.
  3817. */
  3818. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3819. /** @hidden */
  3820. _data?: Promise<_IAnimationSamplerData>;
  3821. }
  3822. /**
  3823. * Loader interface with additional members.
  3824. */
  3825. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3826. channels: IAnimationChannel[];
  3827. samplers: IAnimationSampler[];
  3828. /** @hidden */
  3829. _babylonAnimationGroup?: AnimationGroup;
  3830. }
  3831. /**
  3832. * Loader interface with additional members.
  3833. */
  3834. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3835. /** @hidden */
  3836. _data?: Promise<ArrayBufferView>;
  3837. }
  3838. /**
  3839. * Loader interface with additional members.
  3840. */
  3841. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3842. /** @hidden */
  3843. _data?: Promise<ArrayBufferView>;
  3844. /** @hidden */
  3845. _babylonBuffer?: Promise<Buffer>;
  3846. }
  3847. /**
  3848. * Loader interface with additional members.
  3849. */
  3850. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3851. }
  3852. /**
  3853. * Loader interface with additional members.
  3854. */
  3855. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3856. /** @hidden */
  3857. _data?: Promise<ArrayBufferView>;
  3858. }
  3859. /**
  3860. * Loader interface with additional members.
  3861. */
  3862. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  3863. }
  3864. /**
  3865. * Loader interface with additional members.
  3866. */
  3867. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  3868. }
  3869. /**
  3870. * Loader interface with additional members.
  3871. */
  3872. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3873. baseColorTexture?: ITextureInfo;
  3874. metallicRoughnessTexture?: ITextureInfo;
  3875. }
  3876. /**
  3877. * Loader interface with additional members.
  3878. */
  3879. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3880. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3881. normalTexture?: IMaterialNormalTextureInfo;
  3882. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3883. emissiveTexture?: ITextureInfo;
  3884. /** @hidden */
  3885. _data?: {
  3886. [babylonDrawMode: number]: {
  3887. babylonMaterial: Material;
  3888. babylonMeshes: AbstractMesh[];
  3889. promise: Promise<void>;
  3890. };
  3891. };
  3892. }
  3893. /**
  3894. * Loader interface with additional members.
  3895. */
  3896. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3897. primitives: IMeshPrimitive[];
  3898. }
  3899. /**
  3900. * Loader interface with additional members.
  3901. */
  3902. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3903. /** @hidden */
  3904. _instanceData?: {
  3905. babylonSourceMesh: Mesh;
  3906. promise: Promise<any>;
  3907. };
  3908. }
  3909. /**
  3910. * Loader interface with additional members.
  3911. */
  3912. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  3913. /**
  3914. * The parent glTF node.
  3915. */
  3916. parent?: INode;
  3917. /** @hidden */
  3918. _babylonTransformNode?: TransformNode;
  3919. /** @hidden */
  3920. _primitiveBabylonMeshes?: AbstractMesh[];
  3921. /** @hidden */
  3922. _babylonBones?: Bone[];
  3923. /** @hidden */
  3924. _numMorphTargets?: number;
  3925. }
  3926. /** @hidden */
  3927. export interface _ISamplerData {
  3928. noMipMaps: boolean;
  3929. samplingMode: number;
  3930. wrapU: number;
  3931. wrapV: number;
  3932. }
  3933. /**
  3934. * Loader interface with additional members.
  3935. */
  3936. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  3937. /** @hidden */
  3938. _data?: _ISamplerData;
  3939. }
  3940. /**
  3941. * Loader interface with additional members.
  3942. */
  3943. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  3944. }
  3945. /**
  3946. * Loader interface with additional members.
  3947. */
  3948. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  3949. /** @hidden */
  3950. _data?: {
  3951. babylonSkeleton: Skeleton;
  3952. promise: Promise<void>;
  3953. };
  3954. }
  3955. /**
  3956. * Loader interface with additional members.
  3957. */
  3958. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  3959. }
  3960. /**
  3961. * Loader interface with additional members.
  3962. */
  3963. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  3964. }
  3965. /**
  3966. * Loader interface with additional members.
  3967. */
  3968. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  3969. accessors?: IAccessor[];
  3970. animations?: IAnimation[];
  3971. buffers?: IBuffer[];
  3972. bufferViews?: IBufferView[];
  3973. cameras?: ICamera[];
  3974. images?: IImage[];
  3975. materials?: IMaterial[];
  3976. meshes?: IMesh[];
  3977. nodes?: INode[];
  3978. samplers?: ISampler[];
  3979. scenes?: IScene[];
  3980. skins?: ISkin[];
  3981. textures?: ITexture[];
  3982. }
  3983. }
  3984. declare module BABYLON.GLTF2 {
  3985. /**
  3986. * Interface for a glTF loader extension.
  3987. */
  3988. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  3989. /**
  3990. * Called after the loader state changes to LOADING.
  3991. */
  3992. onLoading?(): void;
  3993. /**
  3994. * Called after the loader state changes to READY.
  3995. */
  3996. onReady?(): void;
  3997. /**
  3998. * Define this method to modify the default behavior when loading scenes.
  3999. * @param context The context when loading the asset
  4000. * @param scene The glTF scene property
  4001. * @returns A promise that resolves when the load is complete or null if not handled
  4002. */
  4003. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  4004. /**
  4005. * Define this method to modify the default behavior when loading nodes.
  4006. * @param context The context when loading the asset
  4007. * @param node The glTF node property
  4008. * @param assign A function called synchronously after parsing the glTF properties
  4009. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  4010. */
  4011. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4012. /**
  4013. * Define this method to modify the default behavior when loading cameras.
  4014. * @param context The context when loading the asset
  4015. * @param camera The glTF camera property
  4016. * @param assign A function called synchronously after parsing the glTF properties
  4017. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  4018. */
  4019. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  4020. /**
  4021. * @hidden
  4022. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  4023. * @param context The context when loading the asset
  4024. * @param primitive The glTF mesh primitive property
  4025. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  4026. */
  4027. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  4028. /**
  4029. * @hidden
  4030. * Define this method to modify the default behavior when loading data for mesh primitives.
  4031. * @param context The context when loading the asset
  4032. * @param name The mesh name when loading the asset
  4033. * @param node The glTF node when loading the asset
  4034. * @param mesh The glTF mesh when loading the asset
  4035. * @param primitive The glTF mesh primitive property
  4036. * @param assign A function called synchronously after parsing the glTF properties
  4037. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  4038. */
  4039. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  4040. /**
  4041. * @hidden
  4042. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  4043. * @param context The context when loading the asset
  4044. * @param material The glTF material property
  4045. * @param assign A function called synchronously after parsing the glTF properties
  4046. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  4047. */
  4048. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  4049. /**
  4050. * Define this method to modify the default behavior when creating materials.
  4051. * @param context The context when loading the asset
  4052. * @param material The glTF material property
  4053. * @param babylonDrawMode The draw mode for the Babylon material
  4054. * @returns The Babylon material or null if not handled
  4055. */
  4056. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  4057. /**
  4058. * Define this method to modify the default behavior when loading material properties.
  4059. * @param context The context when loading the asset
  4060. * @param material The glTF material property
  4061. * @param babylonMaterial The Babylon material
  4062. * @returns A promise that resolves when the load is complete or null if not handled
  4063. */
  4064. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4065. /**
  4066. * Define this method to modify the default behavior when loading texture infos.
  4067. * @param context The context when loading the asset
  4068. * @param textureInfo The glTF texture info property
  4069. * @param assign A function called synchronously after parsing the glTF properties
  4070. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  4071. */
  4072. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4073. /**
  4074. * @hidden
  4075. * Define this method to modify the default behavior when loading textures.
  4076. * @param context The context when loading the asset
  4077. * @param texture The glTF texture property
  4078. * @param assign A function called synchronously after parsing the glTF properties
  4079. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  4080. */
  4081. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4082. /**
  4083. * Define this method to modify the default behavior when loading animations.
  4084. * @param context The context when loading the asset
  4085. * @param animation The glTF animation property
  4086. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  4087. */
  4088. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  4089. /**
  4090. * @hidden
  4091. * Define this method to modify the default behavior when loading skins.
  4092. * @param context The context when loading the asset
  4093. * @param node The glTF node property
  4094. * @param skin The glTF skin property
  4095. * @returns A promise that resolves when the load is complete or null if not handled
  4096. */
  4097. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  4098. /**
  4099. * @hidden
  4100. * Define this method to modify the default behavior when loading uris.
  4101. * @param context The context when loading the asset
  4102. * @param property The glTF property associated with the uri
  4103. * @param uri The uri to load
  4104. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  4105. */
  4106. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  4107. /**
  4108. * Define this method to modify the default behavior when loading buffer views.
  4109. * @param context The context when loading the asset
  4110. * @param bufferView The glTF buffer view property
  4111. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  4112. */
  4113. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  4114. /**
  4115. * Define this method to modify the default behavior when loading buffers.
  4116. * @param context The context when loading the asset
  4117. * @param buffer The glTF buffer property
  4118. * @param byteOffset The byte offset to load
  4119. * @param byteLength The byte length to load
  4120. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  4121. */
  4122. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  4123. }
  4124. }
  4125. declare module BABYLON.GLTF2 {
  4126. /**
  4127. * Helper class for working with arrays when loading the glTF asset
  4128. */
  4129. export class ArrayItem {
  4130. /**
  4131. * Gets an item from the given array.
  4132. * @param context The context when loading the asset
  4133. * @param array The array to get the item from
  4134. * @param index The index to the array
  4135. * @returns The array item
  4136. */
  4137. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  4138. /**
  4139. * Assign an `index` field to each item of the given array.
  4140. * @param array The array of items
  4141. */
  4142. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  4143. }
  4144. /**
  4145. * The glTF 2.0 loader
  4146. */
  4147. export class GLTFLoader implements IGLTFLoader {
  4148. /** @hidden */
  4149. _completePromises: Promise<any>[];
  4150. /** @hidden */
  4151. _forAssetContainer: boolean;
  4152. /** Storage */
  4153. _babylonLights: Light[];
  4154. /** @hidden */
  4155. _disableInstancedMesh: number;
  4156. private _disposed;
  4157. private _parent;
  4158. private _state;
  4159. private _extensions;
  4160. private _rootUrl;
  4161. private _fileName;
  4162. private _uniqueRootUrl;
  4163. private _gltf;
  4164. private _bin;
  4165. private _babylonScene;
  4166. private _rootBabylonMesh;
  4167. private _defaultBabylonMaterialData;
  4168. private _progressCallback?;
  4169. private _requests;
  4170. private static _RegisteredExtensions;
  4171. /**
  4172. * The default glTF sampler.
  4173. */
  4174. static readonly DefaultSampler: ISampler;
  4175. /**
  4176. * Registers a loader extension.
  4177. * @param name The name of the loader extension.
  4178. * @param factory The factory function that creates the loader extension.
  4179. */
  4180. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  4181. /**
  4182. * Unregisters a loader extension.
  4183. * @param name The name of the loader extension.
  4184. * @returns A boolean indicating whether the extension has been unregistered
  4185. */
  4186. static UnregisterExtension(name: string): boolean;
  4187. /**
  4188. * The loader state.
  4189. */
  4190. get state(): Nullable<GLTFLoaderState>;
  4191. /**
  4192. * The object that represents the glTF JSON.
  4193. */
  4194. get gltf(): IGLTF;
  4195. /**
  4196. * The BIN chunk of a binary glTF.
  4197. */
  4198. get bin(): Nullable<IDataBuffer>;
  4199. /**
  4200. * The parent file loader.
  4201. */
  4202. get parent(): GLTFFileLoader;
  4203. /**
  4204. * The Babylon scene when loading the asset.
  4205. */
  4206. get babylonScene(): Scene;
  4207. /**
  4208. * The root Babylon mesh when loading the asset.
  4209. */
  4210. get rootBabylonMesh(): Mesh;
  4211. /** @hidden */
  4212. constructor(parent: GLTFFileLoader);
  4213. /** @hidden */
  4214. dispose(): void;
  4215. /** @hidden */
  4216. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  4217. /** @hidden */
  4218. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4219. private _loadAsync;
  4220. private _loadData;
  4221. private _setupData;
  4222. private _loadExtensions;
  4223. private _checkExtensions;
  4224. private _setState;
  4225. private _createRootNode;
  4226. /**
  4227. * Loads a glTF scene.
  4228. * @param context The context when loading the asset
  4229. * @param scene The glTF scene property
  4230. * @returns A promise that resolves when the load is complete
  4231. */
  4232. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  4233. private _forEachPrimitive;
  4234. private _getMeshes;
  4235. private _getTransformNodes;
  4236. private _getSkeletons;
  4237. private _getAnimationGroups;
  4238. private _startAnimations;
  4239. /**
  4240. * Loads a glTF node.
  4241. * @param context The context when loading the asset
  4242. * @param node The glTF node property
  4243. * @param assign A function called synchronously after parsing the glTF properties
  4244. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  4245. */
  4246. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  4247. private _loadMeshAsync;
  4248. /**
  4249. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  4250. * @param context The context when loading the asset
  4251. * @param name The mesh name when loading the asset
  4252. * @param node The glTF node when loading the asset
  4253. * @param mesh The glTF mesh when loading the asset
  4254. * @param primitive The glTF mesh primitive property
  4255. * @param assign A function called synchronously after parsing the glTF properties
  4256. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  4257. */
  4258. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  4259. private _loadVertexDataAsync;
  4260. private _createMorphTargets;
  4261. private _loadMorphTargetsAsync;
  4262. private _loadMorphTargetVertexDataAsync;
  4263. private static _LoadTransform;
  4264. private _loadSkinAsync;
  4265. private _loadBones;
  4266. private _loadBone;
  4267. private _loadSkinInverseBindMatricesDataAsync;
  4268. private _updateBoneMatrices;
  4269. private _getNodeMatrix;
  4270. /**
  4271. * Loads a glTF camera.
  4272. * @param context The context when loading the asset
  4273. * @param camera The glTF camera property
  4274. * @param assign A function called synchronously after parsing the glTF properties
  4275. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  4276. */
  4277. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  4278. private _loadAnimationsAsync;
  4279. /**
  4280. * Loads a glTF animation.
  4281. * @param context The context when loading the asset
  4282. * @param animation The glTF animation property
  4283. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  4284. */
  4285. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  4286. /**
  4287. * @hidden Loads a glTF animation channel.
  4288. * @param context The context when loading the asset
  4289. * @param animationContext The context of the animation when loading the asset
  4290. * @param animation The glTF animation property
  4291. * @param channel The glTF animation channel property
  4292. * @param babylonAnimationGroup The babylon animation group property
  4293. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  4294. * @returns A void promise when the channel load is complete
  4295. */
  4296. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  4297. private _loadAnimationSamplerAsync;
  4298. private _loadBufferAsync;
  4299. /**
  4300. * Loads a glTF buffer view.
  4301. * @param context The context when loading the asset
  4302. * @param bufferView The glTF buffer view property
  4303. * @returns A promise that resolves with the loaded data when the load is complete
  4304. */
  4305. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  4306. private _loadAccessorAsync;
  4307. /** @hidden */
  4308. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  4309. private _loadIndicesAccessorAsync;
  4310. private _loadVertexBufferViewAsync;
  4311. private _loadVertexAccessorAsync;
  4312. private _loadMaterialMetallicRoughnessPropertiesAsync;
  4313. /** @hidden */
  4314. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  4315. private _createDefaultMaterial;
  4316. /**
  4317. * Creates a Babylon material from a glTF material.
  4318. * @param context The context when loading the asset
  4319. * @param material The glTF material property
  4320. * @param babylonDrawMode The draw mode for the Babylon material
  4321. * @returns The Babylon material
  4322. */
  4323. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  4324. /**
  4325. * Loads properties from a glTF material into a Babylon material.
  4326. * @param context The context when loading the asset
  4327. * @param material The glTF material property
  4328. * @param babylonMaterial The Babylon material
  4329. * @returns A promise that resolves when the load is complete
  4330. */
  4331. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  4332. /**
  4333. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  4334. * @param context The context when loading the asset
  4335. * @param material The glTF material property
  4336. * @param babylonMaterial The Babylon material
  4337. * @returns A promise that resolves when the load is complete
  4338. */
  4339. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  4340. /**
  4341. * Loads the alpha properties from a glTF material into a Babylon material.
  4342. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  4343. * @param context The context when loading the asset
  4344. * @param material The glTF material property
  4345. * @param babylonMaterial The Babylon material
  4346. */
  4347. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  4348. /**
  4349. * Loads a glTF texture info.
  4350. * @param context The context when loading the asset
  4351. * @param textureInfo The glTF texture info property
  4352. * @param assign A function called synchronously after parsing the glTF properties
  4353. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  4354. */
  4355. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4356. /** @hidden */
  4357. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4358. /** @hidden */
  4359. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4360. private _loadSampler;
  4361. /**
  4362. * Loads a glTF image.
  4363. * @param context The context when loading the asset
  4364. * @param image The glTF image property
  4365. * @returns A promise that resolves with the loaded data when the load is complete
  4366. */
  4367. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  4368. /**
  4369. * Loads a glTF uri.
  4370. * @param context The context when loading the asset
  4371. * @param property The glTF property associated with the uri
  4372. * @param uri The base64 or relative uri
  4373. * @returns A promise that resolves with the loaded data when the load is complete
  4374. */
  4375. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  4376. private _onProgress;
  4377. /**
  4378. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  4379. * @param babylonObject the Babylon object with metadata
  4380. * @param pointer the JSON pointer
  4381. */
  4382. static AddPointerMetadata(babylonObject: {
  4383. metadata: any;
  4384. }, pointer: string): void;
  4385. private static _GetTextureWrapMode;
  4386. private static _GetTextureSamplingMode;
  4387. private static _GetTypedArrayConstructor;
  4388. private static _GetTypedArray;
  4389. private static _GetNumComponents;
  4390. private static _ValidateUri;
  4391. private static _GetDrawMode;
  4392. private _compileMaterialsAsync;
  4393. private _compileShadowGeneratorsAsync;
  4394. private _forEachExtensions;
  4395. private _applyExtensions;
  4396. private _extensionsOnLoading;
  4397. private _extensionsOnReady;
  4398. private _extensionsLoadSceneAsync;
  4399. private _extensionsLoadNodeAsync;
  4400. private _extensionsLoadCameraAsync;
  4401. private _extensionsLoadVertexDataAsync;
  4402. private _extensionsLoadMeshPrimitiveAsync;
  4403. private _extensionsLoadMaterialAsync;
  4404. private _extensionsCreateMaterial;
  4405. private _extensionsLoadMaterialPropertiesAsync;
  4406. private _extensionsLoadTextureInfoAsync;
  4407. private _extensionsLoadTextureAsync;
  4408. private _extensionsLoadAnimationAsync;
  4409. private _extensionsLoadSkinAsync;
  4410. private _extensionsLoadUriAsync;
  4411. private _extensionsLoadBufferViewAsync;
  4412. private _extensionsLoadBufferAsync;
  4413. /**
  4414. * Helper method called by a loader extension to load an glTF extension.
  4415. * @param context The context when loading the asset
  4416. * @param property The glTF property to load the extension from
  4417. * @param extensionName The name of the extension to load
  4418. * @param actionAsync The action to run
  4419. * @returns The promise returned by actionAsync or null if the extension does not exist
  4420. */
  4421. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4422. /**
  4423. * Helper method called by a loader extension to load a glTF extra.
  4424. * @param context The context when loading the asset
  4425. * @param property The glTF property to load the extra from
  4426. * @param extensionName The name of the extension to load
  4427. * @param actionAsync The action to run
  4428. * @returns The promise returned by actionAsync or null if the extra does not exist
  4429. */
  4430. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4431. /**
  4432. * Checks for presence of an extension.
  4433. * @param name The name of the extension to check
  4434. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  4435. */
  4436. isExtensionUsed(name: string): boolean;
  4437. /**
  4438. * Increments the indentation level and logs a message.
  4439. * @param message The message to log
  4440. */
  4441. logOpen(message: string): void;
  4442. /**
  4443. * Decrements the indentation level.
  4444. */
  4445. logClose(): void;
  4446. /**
  4447. * Logs a message
  4448. * @param message The message to log
  4449. */
  4450. log(message: string): void;
  4451. /**
  4452. * Starts a performance counter.
  4453. * @param counterName The name of the performance counter
  4454. */
  4455. startPerformanceCounter(counterName: string): void;
  4456. /**
  4457. * Ends a performance counter.
  4458. * @param counterName The name of the performance counter
  4459. */
  4460. endPerformanceCounter(counterName: string): void;
  4461. }
  4462. }
  4463. declare module BABYLON.GLTF2.Loader.Extensions {
  4464. /**
  4465. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  4466. */
  4467. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  4468. /**
  4469. * The name of this extension.
  4470. */
  4471. readonly name: string;
  4472. /**
  4473. * Defines whether this extension is enabled.
  4474. */
  4475. enabled: boolean;
  4476. private _loader;
  4477. private _lights?;
  4478. /** @hidden */
  4479. constructor(loader: GLTFLoader);
  4480. /** @hidden */
  4481. dispose(): void;
  4482. /** @hidden */
  4483. onLoading(): void;
  4484. /** @hidden */
  4485. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4486. private _loadLightAsync;
  4487. }
  4488. }
  4489. declare module BABYLON.GLTF2.Loader.Extensions {
  4490. /**
  4491. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  4492. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  4493. * !!! Experimental Extension Subject to Changes !!!
  4494. */
  4495. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  4496. /**
  4497. * The name of this extension.
  4498. */
  4499. readonly name: string;
  4500. /**
  4501. * Defines whether this extension is enabled.
  4502. */
  4503. enabled: boolean;
  4504. private _loader;
  4505. /** @hidden */
  4506. constructor(loader: GLTFLoader);
  4507. /** @hidden */
  4508. dispose(): void;
  4509. /** @hidden */
  4510. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4511. }
  4512. }
  4513. declare module BABYLON.GLTF2.Loader.Extensions {
  4514. /**
  4515. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  4516. */
  4517. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  4518. /**
  4519. * The name of this extension.
  4520. */
  4521. readonly name: string;
  4522. /**
  4523. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  4524. */
  4525. dracoCompression?: DracoCompression;
  4526. /**
  4527. * Defines whether this extension is enabled.
  4528. */
  4529. enabled: boolean;
  4530. private _loader;
  4531. /** @hidden */
  4532. constructor(loader: GLTFLoader);
  4533. /** @hidden */
  4534. dispose(): void;
  4535. /** @hidden */
  4536. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  4537. }
  4538. }
  4539. declare module BABYLON.GLTF2.Loader.Extensions {
  4540. /**
  4541. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  4542. */
  4543. export class KHR_lights implements IGLTFLoaderExtension {
  4544. /**
  4545. * The name of this extension.
  4546. */
  4547. readonly name: string;
  4548. /**
  4549. * Defines whether this extension is enabled.
  4550. */
  4551. enabled: boolean;
  4552. private _loader;
  4553. private _lights?;
  4554. /** @hidden */
  4555. constructor(loader: GLTFLoader);
  4556. /** @hidden */
  4557. dispose(): void;
  4558. /** @hidden */
  4559. onLoading(): void;
  4560. /** @hidden */
  4561. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4562. }
  4563. }
  4564. declare module BABYLON.GLTF2.Loader.Extensions {
  4565. /**
  4566. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  4567. */
  4568. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  4569. /**
  4570. * The name of this extension.
  4571. */
  4572. readonly name: string;
  4573. /**
  4574. * Defines whether this extension is enabled.
  4575. */
  4576. enabled: boolean;
  4577. /**
  4578. * Defines a number that determines the order the extensions are applied.
  4579. */
  4580. order: number;
  4581. private _loader;
  4582. /** @hidden */
  4583. constructor(loader: GLTFLoader);
  4584. /** @hidden */
  4585. dispose(): void;
  4586. /** @hidden */
  4587. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4588. private _loadSpecularGlossinessPropertiesAsync;
  4589. }
  4590. }
  4591. declare module BABYLON.GLTF2.Loader.Extensions {
  4592. /**
  4593. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  4594. */
  4595. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  4596. /**
  4597. * The name of this extension.
  4598. */
  4599. readonly name: string;
  4600. /**
  4601. * Defines whether this extension is enabled.
  4602. */
  4603. enabled: boolean;
  4604. /**
  4605. * Defines a number that determines the order the extensions are applied.
  4606. */
  4607. order: number;
  4608. private _loader;
  4609. /** @hidden */
  4610. constructor(loader: GLTFLoader);
  4611. /** @hidden */
  4612. dispose(): void;
  4613. /** @hidden */
  4614. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4615. private _loadUnlitPropertiesAsync;
  4616. }
  4617. }
  4618. declare module BABYLON.GLTF2.Loader.Extensions {
  4619. /**
  4620. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  4621. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  4622. * !!! Experimental Extension Subject to Changes !!!
  4623. */
  4624. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  4625. /**
  4626. * The name of this extension.
  4627. */
  4628. readonly name: string;
  4629. /**
  4630. * Defines whether this extension is enabled.
  4631. */
  4632. enabled: boolean;
  4633. /**
  4634. * Defines a number that determines the order the extensions are applied.
  4635. */
  4636. order: number;
  4637. private _loader;
  4638. /** @hidden */
  4639. constructor(loader: GLTFLoader);
  4640. /** @hidden */
  4641. dispose(): void;
  4642. /** @hidden */
  4643. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4644. private _loadClearCoatPropertiesAsync;
  4645. }
  4646. }
  4647. declare module BABYLON.GLTF2.Loader.Extensions {
  4648. /**
  4649. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  4650. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  4651. * !!! Experimental Extension Subject to Changes !!!
  4652. */
  4653. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  4654. /**
  4655. * The name of this extension.
  4656. */
  4657. readonly name: string;
  4658. /**
  4659. * Defines whether this extension is enabled.
  4660. */
  4661. enabled: boolean;
  4662. /**
  4663. * Defines a number that determines the order the extensions are applied.
  4664. */
  4665. order: number;
  4666. private _loader;
  4667. /** @hidden */
  4668. constructor(loader: GLTFLoader);
  4669. /** @hidden */
  4670. dispose(): void;
  4671. /** @hidden */
  4672. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4673. private _loadSheenPropertiesAsync;
  4674. }
  4675. }
  4676. declare module BABYLON.GLTF2.Loader.Extensions {
  4677. /**
  4678. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  4679. * !!! Experimental Extension Subject to Changes !!!
  4680. */
  4681. export class KHR_materials_specular implements IGLTFLoaderExtension {
  4682. /**
  4683. * The name of this extension.
  4684. */
  4685. readonly name: string;
  4686. /**
  4687. * Defines whether this extension is enabled.
  4688. */
  4689. enabled: boolean;
  4690. /**
  4691. * Defines a number that determines the order the extensions are applied.
  4692. */
  4693. order: number;
  4694. private _loader;
  4695. /** @hidden */
  4696. constructor(loader: GLTFLoader);
  4697. /** @hidden */
  4698. dispose(): void;
  4699. /** @hidden */
  4700. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4701. private _loadSpecularPropertiesAsync;
  4702. }
  4703. }
  4704. declare module BABYLON.GLTF2.Loader.Extensions {
  4705. /**
  4706. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  4707. * !!! Experimental Extension Subject to Changes !!!
  4708. */
  4709. export class KHR_materials_ior implements IGLTFLoaderExtension {
  4710. /**
  4711. * Default ior Value from the spec.
  4712. */
  4713. private static readonly _DEFAULT_IOR;
  4714. /**
  4715. * The name of this extension.
  4716. */
  4717. readonly name: string;
  4718. /**
  4719. * Defines whether this extension is enabled.
  4720. */
  4721. enabled: boolean;
  4722. /**
  4723. * Defines a number that determines the order the extensions are applied.
  4724. */
  4725. order: number;
  4726. private _loader;
  4727. /** @hidden */
  4728. constructor(loader: GLTFLoader);
  4729. /** @hidden */
  4730. dispose(): void;
  4731. /** @hidden */
  4732. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4733. private _loadIorPropertiesAsync;
  4734. }
  4735. }
  4736. declare module BABYLON.GLTF2.Loader.Extensions {
  4737. /**
  4738. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  4739. * !!! Experimental Extension Subject to Changes !!!
  4740. */
  4741. export class KHR_materials_variants implements IGLTFLoaderExtension {
  4742. /**
  4743. * The name of this extension.
  4744. */
  4745. readonly name: string;
  4746. /**
  4747. * Defines whether this extension is enabled.
  4748. */
  4749. enabled: boolean;
  4750. private _loader;
  4751. /**
  4752. * The default variant name.
  4753. */
  4754. defaultVariant: string | undefined;
  4755. private _tagsToMap;
  4756. /** @hidden */
  4757. constructor(loader: GLTFLoader);
  4758. /** @hidden */
  4759. dispose(): void;
  4760. /**
  4761. * Return a list of available variants for this asset.
  4762. * @returns {string[]}
  4763. */
  4764. getVariants(): string[];
  4765. /**
  4766. * Select a variant by providing a list of variant tag names.
  4767. *
  4768. * @param {(string | string[])} variantName
  4769. */
  4770. selectVariant(variantName: string | string[]): void;
  4771. /**
  4772. * Select a variant by providing a single variant tag.
  4773. *
  4774. * @param {string} variantName
  4775. */
  4776. selectVariantTag(variantName: string): void;
  4777. /** @hidden */
  4778. onLoading(): void;
  4779. /** @hidden */
  4780. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  4781. }
  4782. }
  4783. declare module BABYLON.GLTF2.Loader.Extensions {
  4784. /**
  4785. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  4786. * !!! Experimental Extension Subject to Changes !!!
  4787. */
  4788. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  4789. /**
  4790. * The name of this extension.
  4791. */
  4792. readonly name: string;
  4793. /**
  4794. * Defines whether this extension is enabled.
  4795. */
  4796. enabled: boolean;
  4797. /**
  4798. * Defines a number that determines the order the extensions are applied.
  4799. */
  4800. order: number;
  4801. private _loader;
  4802. /** @hidden */
  4803. constructor(loader: GLTFLoader);
  4804. /** @hidden */
  4805. dispose(): void;
  4806. /** @hidden */
  4807. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4808. private _loadTransparentPropertiesAsync;
  4809. }
  4810. }
  4811. declare module BABYLON.GLTF2.Loader.Extensions {
  4812. /**
  4813. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  4814. */
  4815. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  4816. /**
  4817. * The name of this extension.
  4818. */
  4819. readonly name: string;
  4820. /**
  4821. * Defines whether this extension is enabled.
  4822. */
  4823. enabled: boolean;
  4824. /** @hidden */
  4825. constructor(loader: GLTFLoader);
  4826. /** @hidden */
  4827. dispose(): void;
  4828. }
  4829. }
  4830. declare module BABYLON.GLTF2.Loader.Extensions {
  4831. /**
  4832. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  4833. * !!! Experimental Extension Subject to Changes !!!
  4834. */
  4835. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  4836. /** The name of this extension. */
  4837. readonly name: string;
  4838. /** Defines whether this extension is enabled. */
  4839. enabled: boolean;
  4840. private _loader;
  4841. /** @hidden */
  4842. constructor(loader: GLTFLoader);
  4843. /** @hidden */
  4844. dispose(): void;
  4845. /** @hidden */
  4846. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4847. }
  4848. }
  4849. declare module BABYLON.GLTF2.Loader.Extensions {
  4850. /**
  4851. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  4852. */
  4853. export class KHR_texture_transform implements IGLTFLoaderExtension {
  4854. /**
  4855. * The name of this extension.
  4856. */
  4857. readonly name: string;
  4858. /**
  4859. * Defines whether this extension is enabled.
  4860. */
  4861. enabled: boolean;
  4862. private _loader;
  4863. /** @hidden */
  4864. constructor(loader: GLTFLoader);
  4865. /** @hidden */
  4866. dispose(): void;
  4867. /** @hidden */
  4868. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4869. }
  4870. }
  4871. declare module BABYLON.GLTF2.Loader.Extensions {
  4872. /**
  4873. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  4874. * !!! Experimental Extension Subject to Changes !!!
  4875. */
  4876. export class KHR_xmp implements IGLTFLoaderExtension {
  4877. /**
  4878. * The name of this extension.
  4879. */
  4880. readonly name: string;
  4881. /**
  4882. * Defines whether this extension is enabled.
  4883. */
  4884. enabled: boolean;
  4885. /**
  4886. * Defines a number that determines the order the extensions are applied.
  4887. */
  4888. order: number;
  4889. private _loader;
  4890. /** @hidden */
  4891. constructor(loader: GLTFLoader);
  4892. /** @hidden */
  4893. dispose(): void;
  4894. /**
  4895. * Called after the loader state changes to LOADING.
  4896. */
  4897. onLoading(): void;
  4898. }
  4899. }
  4900. declare module BABYLON.GLTF2.Loader.Extensions {
  4901. /**
  4902. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  4903. */
  4904. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  4905. /**
  4906. * The name of this extension.
  4907. */
  4908. readonly name: string;
  4909. /**
  4910. * Defines whether this extension is enabled.
  4911. */
  4912. enabled: boolean;
  4913. private _loader;
  4914. private _clips;
  4915. private _emitters;
  4916. /** @hidden */
  4917. constructor(loader: GLTFLoader);
  4918. /** @hidden */
  4919. dispose(): void;
  4920. /** @hidden */
  4921. onLoading(): void;
  4922. /** @hidden */
  4923. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4924. /** @hidden */
  4925. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4926. /** @hidden */
  4927. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  4928. private _loadClipAsync;
  4929. private _loadEmitterAsync;
  4930. private _getEventAction;
  4931. private _loadAnimationEventAsync;
  4932. }
  4933. }
  4934. declare module BABYLON.GLTF2.Loader.Extensions {
  4935. /**
  4936. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  4937. */
  4938. export class MSFT_lod implements IGLTFLoaderExtension {
  4939. /**
  4940. * The name of this extension.
  4941. */
  4942. readonly name: string;
  4943. /**
  4944. * Defines whether this extension is enabled.
  4945. */
  4946. enabled: boolean;
  4947. /**
  4948. * Defines a number that determines the order the extensions are applied.
  4949. */
  4950. order: number;
  4951. /**
  4952. * Maximum number of LODs to load, starting from the lowest LOD.
  4953. */
  4954. maxLODsToLoad: number;
  4955. /**
  4956. * Observable raised when all node LODs of one level are loaded.
  4957. * The event data is the index of the loaded LOD starting from zero.
  4958. * Dispose the loader to cancel the loading of the next level of LODs.
  4959. */
  4960. onNodeLODsLoadedObservable: Observable<number>;
  4961. /**
  4962. * Observable raised when all material LODs of one level are loaded.
  4963. * The event data is the index of the loaded LOD starting from zero.
  4964. * Dispose the loader to cancel the loading of the next level of LODs.
  4965. */
  4966. onMaterialLODsLoadedObservable: Observable<number>;
  4967. private _loader;
  4968. private _nodeIndexLOD;
  4969. private _nodeSignalLODs;
  4970. private _nodePromiseLODs;
  4971. private _materialIndexLOD;
  4972. private _materialSignalLODs;
  4973. private _materialPromiseLODs;
  4974. private _indexLOD;
  4975. private _bufferLODs;
  4976. /** @hidden */
  4977. constructor(loader: GLTFLoader);
  4978. /** @hidden */
  4979. dispose(): void;
  4980. /** @hidden */
  4981. onReady(): void;
  4982. /** @hidden */
  4983. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4984. /** @hidden */
  4985. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4986. /** @hidden */
  4987. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  4988. /** @hidden */
  4989. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  4990. /** @hidden */
  4991. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  4992. private _loadBufferLOD;
  4993. /**
  4994. * Gets an array of LOD properties from lowest to highest.
  4995. */
  4996. private _getLODs;
  4997. private _disposeTransformNode;
  4998. private _disposeMaterials;
  4999. }
  5000. }
  5001. declare module BABYLON.GLTF2.Loader.Extensions {
  5002. /** @hidden */
  5003. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  5004. readonly name: string;
  5005. enabled: boolean;
  5006. private _loader;
  5007. constructor(loader: GLTFLoader);
  5008. dispose(): void;
  5009. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  5010. }
  5011. }
  5012. declare module BABYLON.GLTF2.Loader.Extensions {
  5013. /** @hidden */
  5014. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  5015. readonly name: string;
  5016. enabled: boolean;
  5017. private _loader;
  5018. constructor(loader: GLTFLoader);
  5019. dispose(): void;
  5020. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  5021. }
  5022. }
  5023. declare module BABYLON.GLTF2.Loader.Extensions {
  5024. /**
  5025. * Store glTF extras (if present) in BJS objects' metadata
  5026. */
  5027. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  5028. /**
  5029. * The name of this extension.
  5030. */
  5031. readonly name: string;
  5032. /**
  5033. * Defines whether this extension is enabled.
  5034. */
  5035. enabled: boolean;
  5036. private _loader;
  5037. private _assignExtras;
  5038. /** @hidden */
  5039. constructor(loader: GLTFLoader);
  5040. /** @hidden */
  5041. dispose(): void;
  5042. /** @hidden */
  5043. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  5044. /** @hidden */
  5045. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  5046. /** @hidden */
  5047. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  5048. }
  5049. }
  5050. declare module BABYLON {
  5051. /**
  5052. * Class reading and parsing the MTL file bundled with the obj file.
  5053. */
  5054. export class MTLFileLoader {
  5055. /**
  5056. * Invert Y-Axis of referenced textures on load
  5057. */
  5058. static INVERT_TEXTURE_Y: boolean;
  5059. /**
  5060. * All material loaded from the mtl will be set here
  5061. */
  5062. materials: StandardMaterial[];
  5063. /**
  5064. * This function will read the mtl file and create each material described inside
  5065. * This function could be improve by adding :
  5066. * -some component missing (Ni, Tf...)
  5067. * -including the specific options available
  5068. *
  5069. * @param scene defines the scene the material will be created in
  5070. * @param data defines the mtl data to parse
  5071. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  5072. * @param forAssetContainer defines if the material should be registered in the scene
  5073. */
  5074. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  5075. /**
  5076. * Gets the texture for the material.
  5077. *
  5078. * If the material is imported from input file,
  5079. * We sanitize the url to ensure it takes the textre from aside the material.
  5080. *
  5081. * @param rootUrl The root url to load from
  5082. * @param value The value stored in the mtl
  5083. * @return The Texture
  5084. */
  5085. private static _getTexture;
  5086. }
  5087. }
  5088. declare module BABYLON {
  5089. /**
  5090. * Options for loading OBJ/MTL files
  5091. */
  5092. type MeshLoadOptions = {
  5093. /**
  5094. * Defines if UVs are optimized by default during load.
  5095. */
  5096. OptimizeWithUV: boolean;
  5097. /**
  5098. * Defines custom scaling of UV coordinates of loaded meshes.
  5099. */
  5100. UVScaling: Vector2;
  5101. /**
  5102. * Invert model on y-axis (does a model scaling inversion)
  5103. */
  5104. InvertY: boolean;
  5105. /**
  5106. * Invert Y-Axis of referenced textures on load
  5107. */
  5108. InvertTextureY: boolean;
  5109. /**
  5110. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  5111. */
  5112. ImportVertexColors: boolean;
  5113. /**
  5114. * Compute the normals for the model, even if normals are present in the file.
  5115. */
  5116. ComputeNormals: boolean;
  5117. /**
  5118. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  5119. */
  5120. SkipMaterials: boolean;
  5121. /**
  5122. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  5123. */
  5124. MaterialLoadingFailsSilently: boolean;
  5125. };
  5126. /**
  5127. * OBJ file type loader.
  5128. * This is a babylon scene loader plugin.
  5129. */
  5130. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  5131. /**
  5132. * Defines if UVs are optimized by default during load.
  5133. */
  5134. static OPTIMIZE_WITH_UV: boolean;
  5135. /**
  5136. * Invert model on y-axis (does a model scaling inversion)
  5137. */
  5138. static INVERT_Y: boolean;
  5139. /**
  5140. * Invert Y-Axis of referenced textures on load
  5141. */
  5142. static get INVERT_TEXTURE_Y(): boolean;
  5143. static set INVERT_TEXTURE_Y(value: boolean);
  5144. /**
  5145. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  5146. */
  5147. static IMPORT_VERTEX_COLORS: boolean;
  5148. /**
  5149. * Compute the normals for the model, even if normals are present in the file.
  5150. */
  5151. static COMPUTE_NORMALS: boolean;
  5152. /**
  5153. * Defines custom scaling of UV coordinates of loaded meshes.
  5154. */
  5155. static UV_SCALING: Vector2;
  5156. /**
  5157. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  5158. */
  5159. static SKIP_MATERIALS: boolean;
  5160. /**
  5161. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  5162. *
  5163. * Defaults to true for backwards compatibility.
  5164. */
  5165. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  5166. /**
  5167. * Defines the name of the plugin.
  5168. */
  5169. name: string;
  5170. /**
  5171. * Defines the extension the plugin is able to load.
  5172. */
  5173. extensions: string;
  5174. /** @hidden */
  5175. obj: RegExp;
  5176. /** @hidden */
  5177. group: RegExp;
  5178. /** @hidden */
  5179. mtllib: RegExp;
  5180. /** @hidden */
  5181. usemtl: RegExp;
  5182. /** @hidden */
  5183. smooth: RegExp;
  5184. /** @hidden */
  5185. vertexPattern: RegExp;
  5186. /** @hidden */
  5187. normalPattern: RegExp;
  5188. /** @hidden */
  5189. uvPattern: RegExp;
  5190. /** @hidden */
  5191. facePattern1: RegExp;
  5192. /** @hidden */
  5193. facePattern2: RegExp;
  5194. /** @hidden */
  5195. facePattern3: RegExp;
  5196. /** @hidden */
  5197. facePattern4: RegExp;
  5198. /** @hidden */
  5199. facePattern5: RegExp;
  5200. private _forAssetContainer;
  5201. private _meshLoadOptions;
  5202. /**
  5203. * Creates loader for .OBJ files
  5204. *
  5205. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  5206. */
  5207. constructor(meshLoadOptions?: MeshLoadOptions);
  5208. private static get currentMeshLoadOptions();
  5209. /**
  5210. * Calls synchronously the MTL file attached to this obj.
  5211. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  5212. * Without this function materials are not displayed in the first frame (but displayed after).
  5213. * In consequence it is impossible to get material information in your HTML file
  5214. *
  5215. * @param url The URL of the MTL file
  5216. * @param rootUrl
  5217. * @param onSuccess Callback function to be called when the MTL file is loaded
  5218. * @private
  5219. */
  5220. private _loadMTL;
  5221. /**
  5222. * Instantiates a OBJ file loader plugin.
  5223. * @returns the created plugin
  5224. */
  5225. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  5226. /**
  5227. * If the data string can be loaded directly.
  5228. *
  5229. * @param data string containing the file data
  5230. * @returns if the data can be loaded directly
  5231. */
  5232. canDirectLoad(data: string): boolean;
  5233. /**
  5234. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  5235. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  5236. * @param scene the scene the meshes should be added to
  5237. * @param data the OBJ data to load
  5238. * @param rootUrl root url to load from
  5239. * @param onProgress event that fires when loading progress has occured
  5240. * @param fileName Defines the name of the file to load
  5241. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  5242. */
  5243. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  5244. meshes: AbstractMesh[];
  5245. particleSystems: IParticleSystem[];
  5246. skeletons: Skeleton[];
  5247. animationGroups: AnimationGroup[];
  5248. }>;
  5249. /**
  5250. * Imports all objects from the loaded OBJ data and adds them to the scene
  5251. * @param scene the scene the objects should be added to
  5252. * @param data the OBJ data to load
  5253. * @param rootUrl root url to load from
  5254. * @param onProgress event that fires when loading progress has occured
  5255. * @param fileName Defines the name of the file to load
  5256. * @returns a promise which completes when objects have been loaded to the scene
  5257. */
  5258. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  5259. /**
  5260. * Load into an asset container.
  5261. * @param scene The scene to load into
  5262. * @param data The data to import
  5263. * @param rootUrl The root url for scene and resources
  5264. * @param onProgress The callback when the load progresses
  5265. * @param fileName Defines the name of the file to load
  5266. * @returns The loaded asset container
  5267. */
  5268. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  5269. /**
  5270. * Read the OBJ file and create an Array of meshes.
  5271. * Each mesh contains all information given by the OBJ and the MTL file.
  5272. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  5273. *
  5274. * @param meshesNames
  5275. * @param scene Scene The scene where are displayed the data
  5276. * @param data String The content of the obj file
  5277. * @param rootUrl String The path to the folder
  5278. * @returns Array<AbstractMesh>
  5279. * @private
  5280. */
  5281. private _parseSolid;
  5282. }
  5283. }
  5284. declare module BABYLON {
  5285. /**
  5286. * STL file type loader.
  5287. * This is a babylon scene loader plugin.
  5288. */
  5289. export class STLFileLoader implements ISceneLoaderPlugin {
  5290. /** @hidden */
  5291. solidPattern: RegExp;
  5292. /** @hidden */
  5293. facetsPattern: RegExp;
  5294. /** @hidden */
  5295. normalPattern: RegExp;
  5296. /** @hidden */
  5297. vertexPattern: RegExp;
  5298. /**
  5299. * Defines the name of the plugin.
  5300. */
  5301. name: string;
  5302. /**
  5303. * Defines the extensions the stl loader is able to load.
  5304. * force data to come in as an ArrayBuffer
  5305. * we'll convert to string if it looks like it's an ASCII .stl
  5306. */
  5307. extensions: ISceneLoaderPluginExtensions;
  5308. /**
  5309. * Import meshes into a scene.
  5310. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  5311. * @param scene The scene to import into
  5312. * @param data The data to import
  5313. * @param rootUrl The root url for scene and resources
  5314. * @param meshes The meshes array to import into
  5315. * @param particleSystems The particle systems array to import into
  5316. * @param skeletons The skeletons array to import into
  5317. * @param onError The callback when import fails
  5318. * @returns True if successful or false otherwise
  5319. */
  5320. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  5321. /**
  5322. * Load into a scene.
  5323. * @param scene The scene to load into
  5324. * @param data The data to import
  5325. * @param rootUrl The root url for scene and resources
  5326. * @param onError The callback when import fails
  5327. * @returns true if successful or false otherwise
  5328. */
  5329. load(scene: Scene, data: any, rootUrl: string): boolean;
  5330. /**
  5331. * Load into an asset container.
  5332. * @param scene The scene to load into
  5333. * @param data The data to import
  5334. * @param rootUrl The root url for scene and resources
  5335. * @param onError The callback when import fails
  5336. * @returns The loaded asset container
  5337. */
  5338. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  5339. private _isBinary;
  5340. private _parseBinary;
  5341. private _parseASCII;
  5342. }
  5343. }