babylonjs.loaders.module.d.ts 223 KB

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