babylonjs.loaders.module.d.ts 223 KB

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