babylonjs.loaders.module.d.ts 229 KB

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