babylonjs.loaders.module.d.ts 214 KB

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