babylonjs.loaders.module.d.ts 228 KB

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