babylonjs.loaders.module.d.ts 227 KB

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