babylonjs.loaders.module.d.ts 223 KB

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