babylonjs.loaders.module.d.ts 210 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048
  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/KHR_draco_mesh_compression" {
  1758. import { DracoCompression } from "babylonjs/Meshes/Compression/dracoCompression";
  1759. import { Nullable } from "babylonjs/types";
  1760. import { Geometry } from "babylonjs/Meshes/geometry";
  1761. import { Mesh } from "babylonjs/Meshes/mesh";
  1762. import { IMeshPrimitive } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1763. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1764. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1765. /**
  1766. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1767. */
  1768. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1769. /**
  1770. * The name of this extension.
  1771. */
  1772. readonly name: string;
  1773. /**
  1774. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  1775. */
  1776. dracoCompression?: DracoCompression;
  1777. /**
  1778. * Defines whether this extension is enabled.
  1779. */
  1780. enabled: boolean;
  1781. private _loader;
  1782. /** @hidden */
  1783. constructor(loader: GLTFLoader);
  1784. /** @hidden */
  1785. dispose(): void;
  1786. /** @hidden */
  1787. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1788. }
  1789. }
  1790. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual" {
  1791. import { Nullable } from "babylonjs/types";
  1792. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1793. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1794. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1795. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1796. /**
  1797. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  1798. */
  1799. export class KHR_lights implements IGLTFLoaderExtension {
  1800. /**
  1801. * The name of this extension.
  1802. */
  1803. readonly name: string;
  1804. /**
  1805. * Defines whether this extension is enabled.
  1806. */
  1807. enabled: boolean;
  1808. private _loader;
  1809. private _lights?;
  1810. /** @hidden */
  1811. constructor(loader: GLTFLoader);
  1812. /** @hidden */
  1813. dispose(): void;
  1814. /** @hidden */
  1815. onLoading(): void;
  1816. /** @hidden */
  1817. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1818. }
  1819. }
  1820. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness" {
  1821. import { Nullable } from "babylonjs/types";
  1822. import { Material } from "babylonjs/Materials/material";
  1823. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1824. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1825. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1826. /**
  1827. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1828. */
  1829. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1830. /**
  1831. * The name of this extension.
  1832. */
  1833. readonly name: string;
  1834. /**
  1835. * Defines whether this extension is enabled.
  1836. */
  1837. enabled: boolean;
  1838. /**
  1839. * Defines a number that determines the order the extensions are applied.
  1840. */
  1841. order: number;
  1842. private _loader;
  1843. /** @hidden */
  1844. constructor(loader: GLTFLoader);
  1845. /** @hidden */
  1846. dispose(): void;
  1847. /** @hidden */
  1848. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1849. private _loadSpecularGlossinessPropertiesAsync;
  1850. }
  1851. }
  1852. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit" {
  1853. import { Nullable } from "babylonjs/types";
  1854. import { Material } from "babylonjs/Materials/material";
  1855. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1856. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1857. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1858. /**
  1859. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1860. */
  1861. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1862. /**
  1863. * The name of this extension.
  1864. */
  1865. readonly name: string;
  1866. /**
  1867. * Defines whether this extension is enabled.
  1868. */
  1869. enabled: boolean;
  1870. /**
  1871. * Defines a number that determines the order the extensions are applied.
  1872. */
  1873. order: number;
  1874. private _loader;
  1875. /** @hidden */
  1876. constructor(loader: GLTFLoader);
  1877. /** @hidden */
  1878. dispose(): void;
  1879. /** @hidden */
  1880. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1881. private _loadUnlitPropertiesAsync;
  1882. }
  1883. }
  1884. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_clearcoat" {
  1885. import { Nullable } from "babylonjs/types";
  1886. import { Material } from "babylonjs/Materials/material";
  1887. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1888. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1889. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1890. /**
  1891. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1892. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  1893. * !!! Experimental Extension Subject to Changes !!!
  1894. */
  1895. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  1896. /**
  1897. * The name of this extension.
  1898. */
  1899. readonly name: string;
  1900. /**
  1901. * Defines whether this extension is enabled.
  1902. */
  1903. enabled: boolean;
  1904. /**
  1905. * Defines a number that determines the order the extensions are applied.
  1906. */
  1907. order: number;
  1908. private _loader;
  1909. /** @hidden */
  1910. constructor(loader: GLTFLoader);
  1911. /** @hidden */
  1912. dispose(): void;
  1913. /** @hidden */
  1914. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1915. private _loadClearCoatPropertiesAsync;
  1916. }
  1917. }
  1918. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_sheen" {
  1919. import { Nullable } from "babylonjs/types";
  1920. import { Material } from "babylonjs/Materials/material";
  1921. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1922. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1923. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1924. /**
  1925. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  1926. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  1927. * !!! Experimental Extension Subject to Changes !!!
  1928. */
  1929. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  1930. /**
  1931. * The name of this extension.
  1932. */
  1933. readonly name: string;
  1934. /**
  1935. * Defines whether this extension is enabled.
  1936. */
  1937. enabled: boolean;
  1938. /**
  1939. * Defines a number that determines the order the extensions are applied.
  1940. */
  1941. order: number;
  1942. private _loader;
  1943. /** @hidden */
  1944. constructor(loader: GLTFLoader);
  1945. /** @hidden */
  1946. dispose(): void;
  1947. /** @hidden */
  1948. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1949. private _loadSheenPropertiesAsync;
  1950. }
  1951. }
  1952. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular" {
  1953. import { Nullable } from "babylonjs/types";
  1954. import { Material } from "babylonjs/Materials/material";
  1955. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1956. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1957. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1958. /**
  1959. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1960. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  1961. * !!! Experimental Extension Subject to Changes !!!
  1962. */
  1963. export class KHR_materials_specular implements IGLTFLoaderExtension {
  1964. /**
  1965. * The name of this extension.
  1966. */
  1967. readonly name: string;
  1968. /**
  1969. * Defines whether this extension is enabled.
  1970. */
  1971. enabled: boolean;
  1972. /**
  1973. * Defines a number that determines the order the extensions are applied.
  1974. */
  1975. order: number;
  1976. private _loader;
  1977. /** @hidden */
  1978. constructor(loader: GLTFLoader);
  1979. /** @hidden */
  1980. dispose(): void;
  1981. /** @hidden */
  1982. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1983. private _loadSpecularPropertiesAsync;
  1984. }
  1985. }
  1986. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_instancing" {
  1987. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1988. import { Nullable } from "babylonjs/types";
  1989. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1990. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1991. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1992. /**
  1993. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  1994. * [Playground Sample](//TODO)
  1995. * !!! Experimental Extension Subject to Changes !!!
  1996. */
  1997. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  1998. /**
  1999. * The name of this extension.
  2000. */
  2001. readonly name: string;
  2002. /**
  2003. * Defines whether this extension is enabled.
  2004. */
  2005. enabled: boolean;
  2006. private _loader;
  2007. /** @hidden */
  2008. constructor(loader: GLTFLoader);
  2009. /** @hidden */
  2010. dispose(): void;
  2011. /** @hidden */
  2012. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2013. }
  2014. }
  2015. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_quantization" {
  2016. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2017. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2018. /**
  2019. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  2020. */
  2021. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  2022. /**
  2023. * The name of this extension.
  2024. */
  2025. readonly name: string;
  2026. /**
  2027. * Defines whether this extension is enabled.
  2028. */
  2029. enabled: boolean;
  2030. /** @hidden */
  2031. constructor(loader: GLTFLoader);
  2032. /** @hidden */
  2033. dispose(): void;
  2034. }
  2035. }
  2036. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_basisu" {
  2037. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2038. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2039. import { ITexture } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2040. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  2041. import { Nullable } from "babylonjs/types";
  2042. /**
  2043. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  2044. * !!! Experimental Extension Subject to Changes !!!
  2045. */
  2046. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  2047. /** The name of this extension. */
  2048. readonly name: string;
  2049. /** Defines whether this extension is enabled. */
  2050. enabled: boolean;
  2051. private _loader;
  2052. /** @hidden */
  2053. constructor(loader: GLTFLoader);
  2054. /** @hidden */
  2055. dispose(): void;
  2056. /** @hidden */
  2057. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  2058. }
  2059. }
  2060. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform" {
  2061. import { Nullable } from "babylonjs/types";
  2062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  2063. import { ITextureInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2064. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2065. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2066. /**
  2067. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  2068. */
  2069. export class KHR_texture_transform implements IGLTFLoaderExtension {
  2070. /**
  2071. * The name of this extension.
  2072. */
  2073. readonly name: string;
  2074. /**
  2075. * Defines whether this extension is enabled.
  2076. */
  2077. enabled: boolean;
  2078. private _loader;
  2079. /** @hidden */
  2080. constructor(loader: GLTFLoader);
  2081. /** @hidden */
  2082. dispose(): void;
  2083. /** @hidden */
  2084. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  2085. }
  2086. }
  2087. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter" {
  2088. import { Nullable } from "babylonjs/types";
  2089. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  2090. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2091. import { IScene, INode, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2092. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2093. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2094. /**
  2095. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  2096. */
  2097. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  2098. /**
  2099. * The name of this extension.
  2100. */
  2101. readonly name: string;
  2102. /**
  2103. * Defines whether this extension is enabled.
  2104. */
  2105. enabled: boolean;
  2106. private _loader;
  2107. private _clips;
  2108. private _emitters;
  2109. /** @hidden */
  2110. constructor(loader: GLTFLoader);
  2111. /** @hidden */
  2112. dispose(): void;
  2113. /** @hidden */
  2114. onLoading(): void;
  2115. /** @hidden */
  2116. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  2117. /** @hidden */
  2118. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2119. /** @hidden */
  2120. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  2121. private _loadClipAsync;
  2122. private _loadEmitterAsync;
  2123. private _getEventAction;
  2124. private _loadAnimationEventAsync;
  2125. }
  2126. }
  2127. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
  2128. import { Nullable } from "babylonjs/types";
  2129. import { Observable } from "babylonjs/Misc/observable";
  2130. import { Material } from "babylonjs/Materials/material";
  2131. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2132. import { Mesh } from "babylonjs/Meshes/mesh";
  2133. import { INode, IMaterial, IBuffer, IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2134. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2135. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2136. import { IProperty } from 'babylonjs-gltf2interface';
  2137. /**
  2138. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  2139. */
  2140. export class MSFT_lod implements IGLTFLoaderExtension {
  2141. /**
  2142. * The name of this extension.
  2143. */
  2144. readonly name: string;
  2145. /**
  2146. * Defines whether this extension is enabled.
  2147. */
  2148. enabled: boolean;
  2149. /**
  2150. * Defines a number that determines the order the extensions are applied.
  2151. */
  2152. order: number;
  2153. /**
  2154. * Maximum number of LODs to load, starting from the lowest LOD.
  2155. */
  2156. maxLODsToLoad: number;
  2157. /**
  2158. * Observable raised when all node LODs of one level are loaded.
  2159. * The event data is the index of the loaded LOD starting from zero.
  2160. * Dispose the loader to cancel the loading of the next level of LODs.
  2161. */
  2162. onNodeLODsLoadedObservable: Observable<number>;
  2163. /**
  2164. * Observable raised when all material LODs of one level are loaded.
  2165. * The event data is the index of the loaded LOD starting from zero.
  2166. * Dispose the loader to cancel the loading of the next level of LODs.
  2167. */
  2168. onMaterialLODsLoadedObservable: Observable<number>;
  2169. private _loader;
  2170. private _nodeIndexLOD;
  2171. private _nodeSignalLODs;
  2172. private _nodePromiseLODs;
  2173. private _materialIndexLOD;
  2174. private _materialSignalLODs;
  2175. private _materialPromiseLODs;
  2176. private _indexLOD;
  2177. private _bufferLODs;
  2178. /** @hidden */
  2179. constructor(loader: GLTFLoader);
  2180. /** @hidden */
  2181. dispose(): void;
  2182. /** @hidden */
  2183. onReady(): void;
  2184. /** @hidden */
  2185. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  2186. /** @hidden */
  2187. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2188. /** @hidden */
  2189. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  2190. /** @hidden */
  2191. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  2192. /** @hidden */
  2193. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  2194. private _loadBufferLOD;
  2195. /**
  2196. * Gets an array of LOD properties from lowest to highest.
  2197. */
  2198. private _getLODs;
  2199. private _disposeTransformNode;
  2200. private _disposeMaterials;
  2201. }
  2202. }
  2203. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh" {
  2204. import { Nullable } from "babylonjs/types";
  2205. import { Material } from "babylonjs/Materials/material";
  2206. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2207. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2208. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2209. /** @hidden */
  2210. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  2211. readonly name: string;
  2212. enabled: boolean;
  2213. private _loader;
  2214. constructor(loader: GLTFLoader);
  2215. dispose(): void;
  2216. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2217. }
  2218. }
  2219. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors" {
  2220. import { Nullable } from "babylonjs/types";
  2221. import { Material } from "babylonjs/Materials/material";
  2222. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2223. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2224. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2225. /** @hidden */
  2226. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  2227. readonly name: string;
  2228. enabled: boolean;
  2229. private _loader;
  2230. constructor(loader: GLTFLoader);
  2231. dispose(): void;
  2232. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2233. }
  2234. }
  2235. declare module "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata" {
  2236. import { Nullable } from "babylonjs/types";
  2237. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2238. import { Camera } from "babylonjs/Cameras/camera";
  2239. import { INode, ICamera, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2240. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2241. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2242. import { Material } from "babylonjs/Materials/material";
  2243. /**
  2244. * Store glTF extras (if present) in BJS objects' metadata
  2245. */
  2246. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  2247. /**
  2248. * The name of this extension.
  2249. */
  2250. readonly name: string;
  2251. /**
  2252. * Defines whether this extension is enabled.
  2253. */
  2254. enabled: boolean;
  2255. private _loader;
  2256. private _assignExtras;
  2257. /** @hidden */
  2258. constructor(loader: GLTFLoader);
  2259. /** @hidden */
  2260. dispose(): void;
  2261. /** @hidden */
  2262. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2263. /** @hidden */
  2264. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  2265. /** @hidden */
  2266. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  2267. }
  2268. }
  2269. declare module "babylonjs-loaders/glTF/2.0/Extensions/index" {
  2270. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based";
  2271. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  2272. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual";
  2273. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  2274. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit";
  2275. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_clearcoat";
  2276. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_sheen";
  2277. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular";
  2278. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_instancing";
  2279. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_quantization";
  2280. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_basisu";
  2281. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform";
  2282. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter";
  2283. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod";
  2284. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh";
  2285. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors";
  2286. export * from "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata";
  2287. }
  2288. declare module "babylonjs-loaders/glTF/2.0/index" {
  2289. export * from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2290. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2291. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2292. export * from "babylonjs-loaders/glTF/2.0/Extensions/index";
  2293. }
  2294. declare module "babylonjs-loaders/glTF/index" {
  2295. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2296. export * from "babylonjs-loaders/glTF/glTFValidation";
  2297. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2298. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2299. export { GLTF1, GLTF2 };
  2300. }
  2301. declare module "babylonjs-loaders/OBJ/mtlFileLoader" {
  2302. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  2303. import { Scene } from "babylonjs/scene";
  2304. /**
  2305. * Class reading and parsing the MTL file bundled with the obj file.
  2306. */
  2307. export class MTLFileLoader {
  2308. /**
  2309. * Invert Y-Axis of referenced textures on load
  2310. */
  2311. static INVERT_TEXTURE_Y: boolean;
  2312. /**
  2313. * All material loaded from the mtl will be set here
  2314. */
  2315. materials: StandardMaterial[];
  2316. /**
  2317. * This function will read the mtl file and create each material described inside
  2318. * This function could be improve by adding :
  2319. * -some component missing (Ni, Tf...)
  2320. * -including the specific options available
  2321. *
  2322. * @param scene defines the scene the material will be created in
  2323. * @param data defines the mtl data to parse
  2324. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  2325. * @param forAssetContainer defines if the material should be registered in the scene
  2326. */
  2327. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  2328. /**
  2329. * Gets the texture for the material.
  2330. *
  2331. * If the material is imported from input file,
  2332. * We sanitize the url to ensure it takes the textre from aside the material.
  2333. *
  2334. * @param rootUrl The root url to load from
  2335. * @param value The value stored in the mtl
  2336. * @return The Texture
  2337. */
  2338. private static _getTexture;
  2339. }
  2340. }
  2341. declare module "babylonjs-loaders/OBJ/objFileLoader" {
  2342. import { Vector2 } from "babylonjs/Maths/math.vector";
  2343. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  2344. import { Skeleton } from "babylonjs/Bones/skeleton";
  2345. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2346. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2347. import { ISceneLoaderPluginAsync, SceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin } from "babylonjs/Loading/sceneLoader";
  2348. import { AssetContainer } from "babylonjs/assetContainer";
  2349. import { Scene } from "babylonjs/scene";
  2350. /**
  2351. * Options for loading OBJ/MTL files
  2352. */
  2353. type MeshLoadOptions = {
  2354. /**
  2355. * Defines if UVs are optimized by default during load.
  2356. */
  2357. OptimizeWithUV: boolean;
  2358. /**
  2359. * Defines custom scaling of UV coordinates of loaded meshes.
  2360. */
  2361. UVScaling: Vector2;
  2362. /**
  2363. * Invert model on y-axis (does a model scaling inversion)
  2364. */
  2365. InvertY: boolean;
  2366. /**
  2367. * Invert Y-Axis of referenced textures on load
  2368. */
  2369. InvertTextureY: boolean;
  2370. /**
  2371. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2372. */
  2373. ImportVertexColors: boolean;
  2374. /**
  2375. * Compute the normals for the model, even if normals are present in the file.
  2376. */
  2377. ComputeNormals: boolean;
  2378. /**
  2379. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2380. */
  2381. SkipMaterials: boolean;
  2382. /**
  2383. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2384. */
  2385. MaterialLoadingFailsSilently: boolean;
  2386. };
  2387. /**
  2388. * OBJ file type loader.
  2389. * This is a babylon scene loader plugin.
  2390. */
  2391. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2392. /**
  2393. * Defines if UVs are optimized by default during load.
  2394. */
  2395. static OPTIMIZE_WITH_UV: boolean;
  2396. /**
  2397. * Invert model on y-axis (does a model scaling inversion)
  2398. */
  2399. static INVERT_Y: boolean;
  2400. /**
  2401. * Invert Y-Axis of referenced textures on load
  2402. */
  2403. static get INVERT_TEXTURE_Y(): boolean;
  2404. static set INVERT_TEXTURE_Y(value: boolean);
  2405. /**
  2406. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2407. */
  2408. static IMPORT_VERTEX_COLORS: boolean;
  2409. /**
  2410. * Compute the normals for the model, even if normals are present in the file.
  2411. */
  2412. static COMPUTE_NORMALS: boolean;
  2413. /**
  2414. * Defines custom scaling of UV coordinates of loaded meshes.
  2415. */
  2416. static UV_SCALING: Vector2;
  2417. /**
  2418. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2419. */
  2420. static SKIP_MATERIALS: boolean;
  2421. /**
  2422. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2423. *
  2424. * Defaults to true for backwards compatibility.
  2425. */
  2426. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2427. /**
  2428. * Defines the name of the plugin.
  2429. */
  2430. name: string;
  2431. /**
  2432. * Defines the extension the plugin is able to load.
  2433. */
  2434. extensions: string;
  2435. /** @hidden */
  2436. obj: RegExp;
  2437. /** @hidden */
  2438. group: RegExp;
  2439. /** @hidden */
  2440. mtllib: RegExp;
  2441. /** @hidden */
  2442. usemtl: RegExp;
  2443. /** @hidden */
  2444. smooth: RegExp;
  2445. /** @hidden */
  2446. vertexPattern: RegExp;
  2447. /** @hidden */
  2448. normalPattern: RegExp;
  2449. /** @hidden */
  2450. uvPattern: RegExp;
  2451. /** @hidden */
  2452. facePattern1: RegExp;
  2453. /** @hidden */
  2454. facePattern2: RegExp;
  2455. /** @hidden */
  2456. facePattern3: RegExp;
  2457. /** @hidden */
  2458. facePattern4: RegExp;
  2459. /** @hidden */
  2460. facePattern5: RegExp;
  2461. private _forAssetContainer;
  2462. private _meshLoadOptions;
  2463. /**
  2464. * Creates loader for .OBJ files
  2465. *
  2466. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2467. */
  2468. constructor(meshLoadOptions?: MeshLoadOptions);
  2469. private static get currentMeshLoadOptions();
  2470. /**
  2471. * Calls synchronously the MTL file attached to this obj.
  2472. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2473. * Without this function materials are not displayed in the first frame (but displayed after).
  2474. * In consequence it is impossible to get material information in your HTML file
  2475. *
  2476. * @param url The URL of the MTL file
  2477. * @param rootUrl
  2478. * @param onSuccess Callback function to be called when the MTL file is loaded
  2479. * @private
  2480. */
  2481. private _loadMTL;
  2482. /**
  2483. * Instantiates a OBJ file loader plugin.
  2484. * @returns the created plugin
  2485. */
  2486. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2487. /**
  2488. * If the data string can be loaded directly.
  2489. *
  2490. * @param data string containing the file data
  2491. * @returns if the data can be loaded directly
  2492. */
  2493. canDirectLoad(data: string): boolean;
  2494. /**
  2495. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2496. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2497. * @param scene the scene the meshes should be added to
  2498. * @param data the OBJ data to load
  2499. * @param rootUrl root url to load from
  2500. * @param onProgress event that fires when loading progress has occured
  2501. * @param fileName Defines the name of the file to load
  2502. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2503. */
  2504. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2505. meshes: AbstractMesh[];
  2506. particleSystems: IParticleSystem[];
  2507. skeletons: Skeleton[];
  2508. animationGroups: AnimationGroup[];
  2509. }>;
  2510. /**
  2511. * Imports all objects from the loaded OBJ data and adds them to the scene
  2512. * @param scene the scene the objects should be added to
  2513. * @param data the OBJ data to load
  2514. * @param rootUrl root url to load from
  2515. * @param onProgress event that fires when loading progress has occured
  2516. * @param fileName Defines the name of the file to load
  2517. * @returns a promise which completes when objects have been loaded to the scene
  2518. */
  2519. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2520. /**
  2521. * Load into an asset container.
  2522. * @param scene The scene to load into
  2523. * @param data The data to import
  2524. * @param rootUrl The root url for scene and resources
  2525. * @param onProgress The callback when the load progresses
  2526. * @param fileName Defines the name of the file to load
  2527. * @returns The loaded asset container
  2528. */
  2529. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2530. /**
  2531. * Read the OBJ file and create an Array of meshes.
  2532. * Each mesh contains all information given by the OBJ and the MTL file.
  2533. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2534. *
  2535. * @param meshesNames
  2536. * @param scene Scene The scene where are displayed the data
  2537. * @param data String The content of the obj file
  2538. * @param rootUrl String The path to the folder
  2539. * @returns Array<AbstractMesh>
  2540. * @private
  2541. */
  2542. private _parseSolid;
  2543. }
  2544. }
  2545. declare module "babylonjs-loaders/OBJ/index" {
  2546. export * from "babylonjs-loaders/OBJ/mtlFileLoader";
  2547. export * from "babylonjs-loaders/OBJ/objFileLoader";
  2548. }
  2549. declare module "babylonjs-loaders/STL/stlFileLoader" {
  2550. import { Nullable } from "babylonjs/types";
  2551. import { Skeleton } from "babylonjs/Bones/skeleton";
  2552. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2554. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  2555. import { AssetContainer } from "babylonjs/assetContainer";
  2556. import { Scene } from "babylonjs/scene";
  2557. /**
  2558. * STL file type loader.
  2559. * This is a babylon scene loader plugin.
  2560. */
  2561. export class STLFileLoader implements ISceneLoaderPlugin {
  2562. /** @hidden */
  2563. solidPattern: RegExp;
  2564. /** @hidden */
  2565. facetsPattern: RegExp;
  2566. /** @hidden */
  2567. normalPattern: RegExp;
  2568. /** @hidden */
  2569. vertexPattern: RegExp;
  2570. /**
  2571. * Defines the name of the plugin.
  2572. */
  2573. name: string;
  2574. /**
  2575. * Defines the extensions the stl loader is able to load.
  2576. * force data to come in as an ArrayBuffer
  2577. * we'll convert to string if it looks like it's an ASCII .stl
  2578. */
  2579. extensions: ISceneLoaderPluginExtensions;
  2580. /**
  2581. * Import meshes into a scene.
  2582. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2583. * @param scene The scene to import into
  2584. * @param data The data to import
  2585. * @param rootUrl The root url for scene and resources
  2586. * @param meshes The meshes array to import into
  2587. * @param particleSystems The particle systems array to import into
  2588. * @param skeletons The skeletons array to import into
  2589. * @param onError The callback when import fails
  2590. * @returns True if successful or false otherwise
  2591. */
  2592. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2593. /**
  2594. * Load into a scene.
  2595. * @param scene The scene to load into
  2596. * @param data The data to import
  2597. * @param rootUrl The root url for scene and resources
  2598. * @param onError The callback when import fails
  2599. * @returns true if successful or false otherwise
  2600. */
  2601. load(scene: Scene, data: any, rootUrl: string): boolean;
  2602. /**
  2603. * Load into an asset container.
  2604. * @param scene The scene to load into
  2605. * @param data The data to import
  2606. * @param rootUrl The root url for scene and resources
  2607. * @param onError The callback when import fails
  2608. * @returns The loaded asset container
  2609. */
  2610. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2611. private _isBinary;
  2612. private _parseBinary;
  2613. private _parseASCII;
  2614. }
  2615. }
  2616. declare module "babylonjs-loaders/STL/index" {
  2617. export * from "babylonjs-loaders/STL/stlFileLoader";
  2618. }
  2619. declare module "babylonjs-loaders/index" {
  2620. export * from "babylonjs-loaders/glTF/index";
  2621. export * from "babylonjs-loaders/OBJ/index";
  2622. export * from "babylonjs-loaders/STL/index";
  2623. }
  2624. declare module "babylonjs-loaders/legacy/legacy-glTF" {
  2625. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2626. export * from "babylonjs-loaders/glTF/glTFValidation";
  2627. }
  2628. declare module "babylonjs-loaders/legacy/legacy-glTF1" {
  2629. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2630. export { GLTF1 };
  2631. }
  2632. declare module "babylonjs-loaders/legacy/legacy-glTF1FileLoader" {
  2633. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2634. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2635. }
  2636. declare module "babylonjs-loaders/legacy/legacy-glTF2" {
  2637. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2638. export { GLTF2 };
  2639. }
  2640. declare module "babylonjs-loaders/legacy/legacy-glTF2FileLoader" {
  2641. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2642. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2643. }
  2644. declare module "babylonjs-loaders/legacy/legacy-glTFFileLoader" {
  2645. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2646. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2647. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2648. }
  2649. declare module "babylonjs-loaders/legacy/legacy-objFileLoader" {
  2650. export * from "babylonjs-loaders/OBJ/index";
  2651. }
  2652. declare module "babylonjs-loaders/legacy/legacy-stlFileLoader" {
  2653. export * from "babylonjs-loaders/STL/index";
  2654. }
  2655. declare module "babylonjs-loaders/legacy/legacy" {
  2656. import "babylonjs-loaders/index";
  2657. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2658. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2659. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2660. export * from "babylonjs-loaders/legacy/legacy-objFileLoader";
  2661. export * from "babylonjs-loaders/legacy/legacy-stlFileLoader";
  2662. }
  2663. declare module "babylonjs-loaders" {
  2664. export * from "babylonjs-loaders/legacy/legacy";
  2665. }
  2666. declare module BABYLON {
  2667. /**
  2668. * Configuration for glTF validation
  2669. */
  2670. export interface IGLTFValidationConfiguration {
  2671. /**
  2672. * The url of the glTF validator.
  2673. */
  2674. url: string;
  2675. }
  2676. /**
  2677. * glTF validation
  2678. */
  2679. export class GLTFValidation {
  2680. /**
  2681. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  2682. */
  2683. static Configuration: IGLTFValidationConfiguration;
  2684. private static _LoadScriptPromise;
  2685. /**
  2686. * Validate a glTF asset using the glTF-Validator.
  2687. * @param data The JSON of a glTF or the array buffer of a binary glTF
  2688. * @param rootUrl The root url for the glTF
  2689. * @param fileName The file name for the glTF
  2690. * @param getExternalResource The callback to get external resources for the glTF validator
  2691. * @returns A promise that resolves with the glTF validation results once complete
  2692. */
  2693. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  2694. }
  2695. }
  2696. declare module BABYLON {
  2697. /**
  2698. * Mode that determines the coordinate system to use.
  2699. */
  2700. export enum GLTFLoaderCoordinateSystemMode {
  2701. /**
  2702. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2703. */
  2704. AUTO = 0,
  2705. /**
  2706. * Sets the useRightHandedSystem flag on the scene.
  2707. */
  2708. FORCE_RIGHT_HANDED = 1
  2709. }
  2710. /**
  2711. * Mode that determines what animations will start.
  2712. */
  2713. export enum GLTFLoaderAnimationStartMode {
  2714. /**
  2715. * No animation will start.
  2716. */
  2717. NONE = 0,
  2718. /**
  2719. * The first animation will start.
  2720. */
  2721. FIRST = 1,
  2722. /**
  2723. * All animations will start.
  2724. */
  2725. ALL = 2
  2726. }
  2727. /**
  2728. * Interface that contains the data for the glTF asset.
  2729. */
  2730. export interface IGLTFLoaderData {
  2731. /**
  2732. * The object that represents the glTF JSON.
  2733. */
  2734. json: Object;
  2735. /**
  2736. * The BIN chunk of a binary glTF.
  2737. */
  2738. bin: Nullable<IDataBuffer>;
  2739. }
  2740. /**
  2741. * Interface for extending the loader.
  2742. */
  2743. export interface IGLTFLoaderExtension {
  2744. /**
  2745. * The name of this extension.
  2746. */
  2747. readonly name: string;
  2748. /**
  2749. * Defines whether this extension is enabled.
  2750. */
  2751. enabled: boolean;
  2752. /**
  2753. * Defines the order of this extension.
  2754. * The loader sorts the extensions using these values when loading.
  2755. */
  2756. order?: number;
  2757. }
  2758. /**
  2759. * Loader state.
  2760. */
  2761. export enum GLTFLoaderState {
  2762. /**
  2763. * The asset is loading.
  2764. */
  2765. LOADING = 0,
  2766. /**
  2767. * The asset is ready for rendering.
  2768. */
  2769. READY = 1,
  2770. /**
  2771. * The asset is completely loaded.
  2772. */
  2773. COMPLETE = 2
  2774. }
  2775. /** @hidden */
  2776. export interface IImportMeshAsyncOutput {
  2777. meshes: AbstractMesh[];
  2778. particleSystems: IParticleSystem[];
  2779. skeletons: Skeleton[];
  2780. animationGroups: AnimationGroup[];
  2781. lights: Light[];
  2782. transformNodes: TransformNode[];
  2783. }
  2784. /** @hidden */
  2785. export interface IGLTFLoader extends IDisposable {
  2786. readonly state: Nullable<GLTFLoaderState>;
  2787. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  2788. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  2789. }
  2790. /**
  2791. * File loader for loading glTF files into a scene.
  2792. */
  2793. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2794. /** @hidden */
  2795. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2796. /** @hidden */
  2797. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  2798. /**
  2799. * Raised when the asset has been parsed
  2800. */
  2801. onParsedObservable: Observable<IGLTFLoaderData>;
  2802. private _onParsedObserver;
  2803. /**
  2804. * Raised when the asset has been parsed
  2805. */
  2806. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  2807. /**
  2808. * 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.
  2809. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  2810. * Defaults to true.
  2811. * @hidden
  2812. */
  2813. static IncrementalLoading: boolean;
  2814. /**
  2815. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  2816. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  2817. * @hidden
  2818. */
  2819. static HomogeneousCoordinates: boolean;
  2820. /**
  2821. * The coordinate system mode. Defaults to AUTO.
  2822. */
  2823. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  2824. /**
  2825. * The animation start mode. Defaults to FIRST.
  2826. */
  2827. animationStartMode: GLTFLoaderAnimationStartMode;
  2828. /**
  2829. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  2830. */
  2831. compileMaterials: boolean;
  2832. /**
  2833. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  2834. */
  2835. useClipPlane: boolean;
  2836. /**
  2837. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  2838. */
  2839. compileShadowGenerators: boolean;
  2840. /**
  2841. * Defines if the Alpha blended materials are only applied as coverage.
  2842. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  2843. * If true, no extra effects are applied to transparent pixels.
  2844. */
  2845. transparencyAsCoverage: boolean;
  2846. /**
  2847. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  2848. * Enabling will disable offline support and glTF validator.
  2849. * Defaults to false.
  2850. */
  2851. useRangeRequests: boolean;
  2852. /**
  2853. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  2854. */
  2855. createInstances: boolean;
  2856. /**
  2857. * Function called before loading a url referenced by the asset.
  2858. */
  2859. preprocessUrlAsync: (url: string) => Promise<string>;
  2860. /**
  2861. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2862. */
  2863. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  2864. private _onMeshLoadedObserver;
  2865. /**
  2866. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  2867. */
  2868. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  2869. /**
  2870. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  2871. */
  2872. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  2873. private _onTextureLoadedObserver;
  2874. /**
  2875. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  2876. */
  2877. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  2878. /**
  2879. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  2880. */
  2881. readonly onMaterialLoadedObservable: Observable<Material>;
  2882. private _onMaterialLoadedObserver;
  2883. /**
  2884. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  2885. */
  2886. set onMaterialLoaded(callback: (material: Material) => void);
  2887. /**
  2888. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  2889. */
  2890. readonly onCameraLoadedObservable: Observable<Camera>;
  2891. private _onCameraLoadedObserver;
  2892. /**
  2893. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  2894. */
  2895. set onCameraLoaded(callback: (camera: Camera) => void);
  2896. /**
  2897. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  2898. * For assets with LODs, raised when all of the LODs are complete.
  2899. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2900. */
  2901. readonly onCompleteObservable: Observable<void>;
  2902. private _onCompleteObserver;
  2903. /**
  2904. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  2905. * For assets with LODs, raised when all of the LODs are complete.
  2906. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  2907. */
  2908. set onComplete(callback: () => void);
  2909. /**
  2910. * Observable raised when an error occurs.
  2911. */
  2912. readonly onErrorObservable: Observable<any>;
  2913. private _onErrorObserver;
  2914. /**
  2915. * Callback raised when an error occurs.
  2916. */
  2917. set onError(callback: (reason: any) => void);
  2918. /**
  2919. * Observable raised after the loader is disposed.
  2920. */
  2921. readonly onDisposeObservable: Observable<void>;
  2922. private _onDisposeObserver;
  2923. /**
  2924. * Callback raised after the loader is disposed.
  2925. */
  2926. set onDispose(callback: () => void);
  2927. /**
  2928. * Observable raised after a loader extension is created.
  2929. * Set additional options for a loader extension in this event.
  2930. */
  2931. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  2932. private _onExtensionLoadedObserver;
  2933. /**
  2934. * Callback raised after a loader extension is created.
  2935. */
  2936. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  2937. /**
  2938. * Defines if the loader logging is enabled.
  2939. */
  2940. get loggingEnabled(): boolean;
  2941. set loggingEnabled(value: boolean);
  2942. /**
  2943. * Defines if the loader should capture performance counters.
  2944. */
  2945. get capturePerformanceCounters(): boolean;
  2946. set capturePerformanceCounters(value: boolean);
  2947. /**
  2948. * Defines if the loader should validate the asset.
  2949. */
  2950. validate: boolean;
  2951. /**
  2952. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  2953. */
  2954. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  2955. private _onValidatedObserver;
  2956. /**
  2957. * Callback raised after a loader extension is created.
  2958. */
  2959. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  2960. private _loader;
  2961. /**
  2962. * Name of the loader ("gltf")
  2963. */
  2964. name: string;
  2965. /** @hidden */
  2966. extensions: ISceneLoaderPluginExtensions;
  2967. /**
  2968. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  2969. */
  2970. dispose(): void;
  2971. /** @hidden */
  2972. _clear(): void;
  2973. /** @hidden */
  2974. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  2975. /** @hidden */
  2976. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  2977. /** @hidden */
  2978. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2979. meshes: AbstractMesh[];
  2980. particleSystems: IParticleSystem[];
  2981. skeletons: Skeleton[];
  2982. animationGroups: AnimationGroup[];
  2983. }>;
  2984. /** @hidden */
  2985. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2986. /** @hidden */
  2987. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2988. /** @hidden */
  2989. canDirectLoad(data: string): boolean;
  2990. /** @hidden */
  2991. directLoad(scene: Scene, data: string): any;
  2992. /**
  2993. * The callback that allows custom handling of the root url based on the response url.
  2994. * @param rootUrl the original root url
  2995. * @param responseURL the response url if available
  2996. * @returns the new root url
  2997. */
  2998. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  2999. /** @hidden */
  3000. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  3001. /**
  3002. * The loader state or null if the loader is not active.
  3003. */
  3004. get loaderState(): Nullable<GLTFLoaderState>;
  3005. /**
  3006. * Returns a promise that resolves when the asset is completely loaded.
  3007. * @returns a promise that resolves when the asset is completely loaded.
  3008. */
  3009. whenCompleteAsync(): Promise<void>;
  3010. private _validate;
  3011. private _getLoader;
  3012. private _parseJson;
  3013. private _unpackBinaryAsync;
  3014. private _unpackBinaryV1Async;
  3015. private _unpackBinaryV2Async;
  3016. private static _parseVersion;
  3017. private static _compareVersion;
  3018. private static readonly _logSpaces;
  3019. private _logIndentLevel;
  3020. private _loggingEnabled;
  3021. /** @hidden */
  3022. _log: (message: string) => void;
  3023. /** @hidden */
  3024. _logOpen(message: string): void;
  3025. /** @hidden */
  3026. _logClose(): void;
  3027. private _logEnabled;
  3028. private _logDisabled;
  3029. private _capturePerformanceCounters;
  3030. /** @hidden */
  3031. _startPerformanceCounter: (counterName: string) => void;
  3032. /** @hidden */
  3033. _endPerformanceCounter: (counterName: string) => void;
  3034. private _startPerformanceCounterEnabled;
  3035. private _startPerformanceCounterDisabled;
  3036. private _endPerformanceCounterEnabled;
  3037. private _endPerformanceCounterDisabled;
  3038. }
  3039. }
  3040. declare module BABYLON.GLTF1 {
  3041. /**
  3042. * Enums
  3043. * @hidden
  3044. */
  3045. export enum EComponentType {
  3046. BYTE = 5120,
  3047. UNSIGNED_BYTE = 5121,
  3048. SHORT = 5122,
  3049. UNSIGNED_SHORT = 5123,
  3050. FLOAT = 5126
  3051. }
  3052. /** @hidden */
  3053. export enum EShaderType {
  3054. FRAGMENT = 35632,
  3055. VERTEX = 35633
  3056. }
  3057. /** @hidden */
  3058. export enum EParameterType {
  3059. BYTE = 5120,
  3060. UNSIGNED_BYTE = 5121,
  3061. SHORT = 5122,
  3062. UNSIGNED_SHORT = 5123,
  3063. INT = 5124,
  3064. UNSIGNED_INT = 5125,
  3065. FLOAT = 5126,
  3066. FLOAT_VEC2 = 35664,
  3067. FLOAT_VEC3 = 35665,
  3068. FLOAT_VEC4 = 35666,
  3069. INT_VEC2 = 35667,
  3070. INT_VEC3 = 35668,
  3071. INT_VEC4 = 35669,
  3072. BOOL = 35670,
  3073. BOOL_VEC2 = 35671,
  3074. BOOL_VEC3 = 35672,
  3075. BOOL_VEC4 = 35673,
  3076. FLOAT_MAT2 = 35674,
  3077. FLOAT_MAT3 = 35675,
  3078. FLOAT_MAT4 = 35676,
  3079. SAMPLER_2D = 35678
  3080. }
  3081. /** @hidden */
  3082. export enum ETextureWrapMode {
  3083. CLAMP_TO_EDGE = 33071,
  3084. MIRRORED_REPEAT = 33648,
  3085. REPEAT = 10497
  3086. }
  3087. /** @hidden */
  3088. export enum ETextureFilterType {
  3089. NEAREST = 9728,
  3090. LINEAR = 9728,
  3091. NEAREST_MIPMAP_NEAREST = 9984,
  3092. LINEAR_MIPMAP_NEAREST = 9985,
  3093. NEAREST_MIPMAP_LINEAR = 9986,
  3094. LINEAR_MIPMAP_LINEAR = 9987
  3095. }
  3096. /** @hidden */
  3097. export enum ETextureFormat {
  3098. ALPHA = 6406,
  3099. RGB = 6407,
  3100. RGBA = 6408,
  3101. LUMINANCE = 6409,
  3102. LUMINANCE_ALPHA = 6410
  3103. }
  3104. /** @hidden */
  3105. export enum ECullingType {
  3106. FRONT = 1028,
  3107. BACK = 1029,
  3108. FRONT_AND_BACK = 1032
  3109. }
  3110. /** @hidden */
  3111. export enum EBlendingFunction {
  3112. ZERO = 0,
  3113. ONE = 1,
  3114. SRC_COLOR = 768,
  3115. ONE_MINUS_SRC_COLOR = 769,
  3116. DST_COLOR = 774,
  3117. ONE_MINUS_DST_COLOR = 775,
  3118. SRC_ALPHA = 770,
  3119. ONE_MINUS_SRC_ALPHA = 771,
  3120. DST_ALPHA = 772,
  3121. ONE_MINUS_DST_ALPHA = 773,
  3122. CONSTANT_COLOR = 32769,
  3123. ONE_MINUS_CONSTANT_COLOR = 32770,
  3124. CONSTANT_ALPHA = 32771,
  3125. ONE_MINUS_CONSTANT_ALPHA = 32772,
  3126. SRC_ALPHA_SATURATE = 776
  3127. }
  3128. /** @hidden */
  3129. export interface IGLTFProperty {
  3130. extensions?: {
  3131. [key: string]: any;
  3132. };
  3133. extras?: Object;
  3134. }
  3135. /** @hidden */
  3136. export interface IGLTFChildRootProperty extends IGLTFProperty {
  3137. name?: string;
  3138. }
  3139. /** @hidden */
  3140. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  3141. bufferView: string;
  3142. byteOffset: number;
  3143. byteStride: number;
  3144. count: number;
  3145. type: string;
  3146. componentType: EComponentType;
  3147. max?: number[];
  3148. min?: number[];
  3149. name?: string;
  3150. }
  3151. /** @hidden */
  3152. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  3153. buffer: string;
  3154. byteOffset: number;
  3155. byteLength: number;
  3156. byteStride: number;
  3157. target?: number;
  3158. }
  3159. /** @hidden */
  3160. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  3161. uri: string;
  3162. byteLength?: number;
  3163. type?: string;
  3164. }
  3165. /** @hidden */
  3166. export interface IGLTFShader extends IGLTFChildRootProperty {
  3167. uri: string;
  3168. type: EShaderType;
  3169. }
  3170. /** @hidden */
  3171. export interface IGLTFProgram extends IGLTFChildRootProperty {
  3172. attributes: string[];
  3173. fragmentShader: string;
  3174. vertexShader: string;
  3175. }
  3176. /** @hidden */
  3177. export interface IGLTFTechniqueParameter {
  3178. type: number;
  3179. count?: number;
  3180. semantic?: string;
  3181. node?: string;
  3182. value?: number | boolean | string | Array<any>;
  3183. source?: string;
  3184. babylonValue?: any;
  3185. }
  3186. /** @hidden */
  3187. export interface IGLTFTechniqueCommonProfile {
  3188. lightingModel: string;
  3189. texcoordBindings: Object;
  3190. parameters?: Array<any>;
  3191. }
  3192. /** @hidden */
  3193. export interface IGLTFTechniqueStatesFunctions {
  3194. blendColor?: number[];
  3195. blendEquationSeparate?: number[];
  3196. blendFuncSeparate?: number[];
  3197. colorMask: boolean[];
  3198. cullFace: number[];
  3199. }
  3200. /** @hidden */
  3201. export interface IGLTFTechniqueStates {
  3202. enable: number[];
  3203. functions: IGLTFTechniqueStatesFunctions;
  3204. }
  3205. /** @hidden */
  3206. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  3207. parameters: {
  3208. [key: string]: IGLTFTechniqueParameter;
  3209. };
  3210. program: string;
  3211. attributes: {
  3212. [key: string]: string;
  3213. };
  3214. uniforms: {
  3215. [key: string]: string;
  3216. };
  3217. states: IGLTFTechniqueStates;
  3218. }
  3219. /** @hidden */
  3220. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  3221. technique?: string;
  3222. values: string[];
  3223. }
  3224. /** @hidden */
  3225. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  3226. attributes: {
  3227. [key: string]: string;
  3228. };
  3229. indices: string;
  3230. material: string;
  3231. mode?: number;
  3232. }
  3233. /** @hidden */
  3234. export interface IGLTFMesh extends IGLTFChildRootProperty {
  3235. primitives: IGLTFMeshPrimitive[];
  3236. }
  3237. /** @hidden */
  3238. export interface IGLTFImage extends IGLTFChildRootProperty {
  3239. uri: string;
  3240. }
  3241. /** @hidden */
  3242. export interface IGLTFSampler extends IGLTFChildRootProperty {
  3243. magFilter?: number;
  3244. minFilter?: number;
  3245. wrapS?: number;
  3246. wrapT?: number;
  3247. }
  3248. /** @hidden */
  3249. export interface IGLTFTexture extends IGLTFChildRootProperty {
  3250. sampler: string;
  3251. source: string;
  3252. format?: ETextureFormat;
  3253. internalFormat?: ETextureFormat;
  3254. target?: number;
  3255. type?: number;
  3256. babylonTexture?: Texture;
  3257. }
  3258. /** @hidden */
  3259. export interface IGLTFAmbienLight {
  3260. color?: number[];
  3261. }
  3262. /** @hidden */
  3263. export interface IGLTFDirectionalLight {
  3264. color?: number[];
  3265. }
  3266. /** @hidden */
  3267. export interface IGLTFPointLight {
  3268. color?: number[];
  3269. constantAttenuation?: number;
  3270. linearAttenuation?: number;
  3271. quadraticAttenuation?: number;
  3272. }
  3273. /** @hidden */
  3274. export interface IGLTFSpotLight {
  3275. color?: number[];
  3276. constantAttenuation?: number;
  3277. fallOfAngle?: number;
  3278. fallOffExponent?: number;
  3279. linearAttenuation?: number;
  3280. quadraticAttenuation?: number;
  3281. }
  3282. /** @hidden */
  3283. export interface IGLTFLight extends IGLTFChildRootProperty {
  3284. type: string;
  3285. }
  3286. /** @hidden */
  3287. export interface IGLTFCameraOrthographic {
  3288. xmag: number;
  3289. ymag: number;
  3290. zfar: number;
  3291. znear: number;
  3292. }
  3293. /** @hidden */
  3294. export interface IGLTFCameraPerspective {
  3295. aspectRatio: number;
  3296. yfov: number;
  3297. zfar: number;
  3298. znear: number;
  3299. }
  3300. /** @hidden */
  3301. export interface IGLTFCamera extends IGLTFChildRootProperty {
  3302. type: string;
  3303. }
  3304. /** @hidden */
  3305. export interface IGLTFAnimationChannelTarget {
  3306. id: string;
  3307. path: string;
  3308. }
  3309. /** @hidden */
  3310. export interface IGLTFAnimationChannel {
  3311. sampler: string;
  3312. target: IGLTFAnimationChannelTarget;
  3313. }
  3314. /** @hidden */
  3315. export interface IGLTFAnimationSampler {
  3316. input: string;
  3317. output: string;
  3318. interpolation?: string;
  3319. }
  3320. /** @hidden */
  3321. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  3322. channels?: IGLTFAnimationChannel[];
  3323. parameters?: {
  3324. [key: string]: string;
  3325. };
  3326. samplers?: {
  3327. [key: string]: IGLTFAnimationSampler;
  3328. };
  3329. }
  3330. /** @hidden */
  3331. export interface IGLTFNodeInstanceSkin {
  3332. skeletons: string[];
  3333. skin: string;
  3334. meshes: string[];
  3335. }
  3336. /** @hidden */
  3337. export interface IGLTFSkins extends IGLTFChildRootProperty {
  3338. bindShapeMatrix: number[];
  3339. inverseBindMatrices: string;
  3340. jointNames: string[];
  3341. babylonSkeleton?: Skeleton;
  3342. }
  3343. /** @hidden */
  3344. export interface IGLTFNode extends IGLTFChildRootProperty {
  3345. camera?: string;
  3346. children: string[];
  3347. skin?: string;
  3348. jointName?: string;
  3349. light?: string;
  3350. matrix: number[];
  3351. mesh?: string;
  3352. meshes?: string[];
  3353. rotation?: number[];
  3354. scale?: number[];
  3355. translation?: number[];
  3356. babylonNode?: Node;
  3357. }
  3358. /** @hidden */
  3359. export interface IGLTFScene extends IGLTFChildRootProperty {
  3360. nodes: string[];
  3361. }
  3362. /** @hidden */
  3363. export interface IGLTFRuntime {
  3364. extensions: {
  3365. [key: string]: any;
  3366. };
  3367. accessors: {
  3368. [key: string]: IGLTFAccessor;
  3369. };
  3370. buffers: {
  3371. [key: string]: IGLTFBuffer;
  3372. };
  3373. bufferViews: {
  3374. [key: string]: IGLTFBufferView;
  3375. };
  3376. meshes: {
  3377. [key: string]: IGLTFMesh;
  3378. };
  3379. lights: {
  3380. [key: string]: IGLTFLight;
  3381. };
  3382. cameras: {
  3383. [key: string]: IGLTFCamera;
  3384. };
  3385. nodes: {
  3386. [key: string]: IGLTFNode;
  3387. };
  3388. images: {
  3389. [key: string]: IGLTFImage;
  3390. };
  3391. textures: {
  3392. [key: string]: IGLTFTexture;
  3393. };
  3394. shaders: {
  3395. [key: string]: IGLTFShader;
  3396. };
  3397. programs: {
  3398. [key: string]: IGLTFProgram;
  3399. };
  3400. samplers: {
  3401. [key: string]: IGLTFSampler;
  3402. };
  3403. techniques: {
  3404. [key: string]: IGLTFTechnique;
  3405. };
  3406. materials: {
  3407. [key: string]: IGLTFMaterial;
  3408. };
  3409. animations: {
  3410. [key: string]: IGLTFAnimation;
  3411. };
  3412. skins: {
  3413. [key: string]: IGLTFSkins;
  3414. };
  3415. currentScene?: Object;
  3416. scenes: {
  3417. [key: string]: IGLTFScene;
  3418. };
  3419. extensionsUsed: string[];
  3420. extensionsRequired?: string[];
  3421. buffersCount: number;
  3422. shaderscount: number;
  3423. scene: Scene;
  3424. rootUrl: string;
  3425. loadedBufferCount: number;
  3426. loadedBufferViews: {
  3427. [name: string]: ArrayBufferView;
  3428. };
  3429. loadedShaderCount: number;
  3430. importOnlyMeshes: boolean;
  3431. importMeshesNames?: string[];
  3432. dummyNodes: Node[];
  3433. forAssetContainer: boolean;
  3434. }
  3435. /** @hidden */
  3436. export interface INodeToRoot {
  3437. bone: Bone;
  3438. node: IGLTFNode;
  3439. id: string;
  3440. }
  3441. /** @hidden */
  3442. export interface IJointNode {
  3443. node: IGLTFNode;
  3444. id: string;
  3445. }
  3446. }
  3447. declare module BABYLON.GLTF1 {
  3448. /**
  3449. * Utils functions for GLTF
  3450. * @hidden
  3451. */
  3452. export class GLTFUtils {
  3453. /**
  3454. * Sets the given "parameter" matrix
  3455. * @param scene: the Scene object
  3456. * @param source: the source node where to pick the matrix
  3457. * @param parameter: the GLTF technique parameter
  3458. * @param uniformName: the name of the shader's uniform
  3459. * @param shaderMaterial: the shader material
  3460. */
  3461. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  3462. /**
  3463. * Sets the given "parameter" matrix
  3464. * @param shaderMaterial: the shader material
  3465. * @param uniform: the name of the shader's uniform
  3466. * @param value: the value of the uniform
  3467. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3468. */
  3469. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  3470. /**
  3471. * Returns the wrap mode of the texture
  3472. * @param mode: the mode value
  3473. */
  3474. static GetWrapMode(mode: number): number;
  3475. /**
  3476. * Returns the byte stride giving an accessor
  3477. * @param accessor: the GLTF accessor objet
  3478. */
  3479. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  3480. /**
  3481. * Returns the texture filter mode giving a mode value
  3482. * @param mode: the filter mode value
  3483. */
  3484. static GetTextureFilterMode(mode: number): ETextureFilterType;
  3485. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  3486. /**
  3487. * Returns a buffer from its accessor
  3488. * @param gltfRuntime: the GLTF runtime
  3489. * @param accessor: the GLTF accessor
  3490. */
  3491. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  3492. /**
  3493. * Decodes a buffer view into a string
  3494. * @param view: the buffer view
  3495. */
  3496. static DecodeBufferToText(view: ArrayBufferView): string;
  3497. /**
  3498. * Returns the default material of gltf. Related to
  3499. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3500. * @param scene: the Babylon.js scene
  3501. */
  3502. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  3503. private static _DefaultMaterial;
  3504. }
  3505. }
  3506. declare module BABYLON.GLTF1 {
  3507. /**
  3508. * Implementation of the base glTF spec
  3509. * @hidden
  3510. */
  3511. export class GLTFLoaderBase {
  3512. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  3513. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3514. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  3515. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3516. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  3517. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3518. }
  3519. /**
  3520. * glTF V1 Loader
  3521. * @hidden
  3522. */
  3523. export class GLTFLoader implements IGLTFLoader {
  3524. static Extensions: {
  3525. [name: string]: GLTFLoaderExtension;
  3526. };
  3527. static RegisterExtension(extension: GLTFLoaderExtension): void;
  3528. state: Nullable<GLTFLoaderState>;
  3529. dispose(): void;
  3530. private _importMeshAsync;
  3531. /**
  3532. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3533. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3534. * @param scene the scene the meshes should be added to
  3535. * @param forAssetContainer defines if the entities must be stored in the scene
  3536. * @param data gltf data containing information of the meshes in a loaded file
  3537. * @param rootUrl root url to load from
  3538. * @param onProgress event that fires when loading progress has occured
  3539. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3540. */
  3541. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  3542. private _loadAsync;
  3543. /**
  3544. * Imports all objects from a loaded gltf file and adds them to the scene
  3545. * @param scene the scene the objects should be added to
  3546. * @param data gltf data containing information of the meshes in a loaded file
  3547. * @param rootUrl root url to load from
  3548. * @param onProgress event that fires when loading progress has occured
  3549. * @returns a promise which completes when objects have been loaded to the scene
  3550. */
  3551. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  3552. private _loadShadersAsync;
  3553. private _loadBuffersAsync;
  3554. private _createNodes;
  3555. }
  3556. /** @hidden */
  3557. export abstract class GLTFLoaderExtension {
  3558. private _name;
  3559. constructor(name: string);
  3560. get name(): string;
  3561. /**
  3562. * Defines an override for loading the runtime
  3563. * Return true to stop further extensions from loading the runtime
  3564. */
  3565. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  3566. /**
  3567. * Defines an onverride for creating gltf runtime
  3568. * Return true to stop further extensions from creating the runtime
  3569. */
  3570. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  3571. /**
  3572. * Defines an override for loading buffers
  3573. * Return true to stop further extensions from loading this buffer
  3574. */
  3575. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  3576. /**
  3577. * Defines an override for loading texture buffers
  3578. * Return true to stop further extensions from loading this texture data
  3579. */
  3580. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3581. /**
  3582. * Defines an override for creating textures
  3583. * Return true to stop further extensions from loading this texture
  3584. */
  3585. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  3586. /**
  3587. * Defines an override for loading shader strings
  3588. * Return true to stop further extensions from loading this shader data
  3589. */
  3590. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3591. /**
  3592. * Defines an override for loading materials
  3593. * Return true to stop further extensions from loading this material
  3594. */
  3595. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3596. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  3597. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  3598. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3599. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3600. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  3601. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3602. private static LoadTextureBufferAsync;
  3603. private static CreateTextureAsync;
  3604. private static ApplyExtensions;
  3605. }
  3606. }
  3607. declare module BABYLON.GLTF1 {
  3608. /** @hidden */
  3609. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  3610. private _bin;
  3611. constructor();
  3612. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  3613. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3614. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3615. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3616. }
  3617. }
  3618. declare module BABYLON.GLTF1 {
  3619. /** @hidden */
  3620. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  3621. constructor();
  3622. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  3623. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3624. private _loadTexture;
  3625. }
  3626. }
  3627. declare module BABYLON.GLTF2.Loader {
  3628. /**
  3629. * Loader interface with an index field.
  3630. */
  3631. export interface IArrayItem {
  3632. /**
  3633. * The index of this item in the array.
  3634. */
  3635. index: number;
  3636. }
  3637. /**
  3638. * Loader interface with additional members.
  3639. */
  3640. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3641. /** @hidden */
  3642. _data?: Promise<ArrayBufferView>;
  3643. /** @hidden */
  3644. _babylonVertexBuffer?: Promise<VertexBuffer>;
  3645. }
  3646. /**
  3647. * Loader interface with additional members.
  3648. */
  3649. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3650. }
  3651. /** @hidden */
  3652. export interface _IAnimationSamplerData {
  3653. input: Float32Array;
  3654. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3655. output: Float32Array;
  3656. }
  3657. /**
  3658. * Loader interface with additional members.
  3659. */
  3660. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3661. /** @hidden */
  3662. _data?: Promise<_IAnimationSamplerData>;
  3663. }
  3664. /**
  3665. * Loader interface with additional members.
  3666. */
  3667. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3668. channels: IAnimationChannel[];
  3669. samplers: IAnimationSampler[];
  3670. /** @hidden */
  3671. _babylonAnimationGroup?: AnimationGroup;
  3672. }
  3673. /**
  3674. * Loader interface with additional members.
  3675. */
  3676. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3677. /** @hidden */
  3678. _data?: Promise<ArrayBufferView>;
  3679. }
  3680. /**
  3681. * Loader interface with additional members.
  3682. */
  3683. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3684. /** @hidden */
  3685. _data?: Promise<ArrayBufferView>;
  3686. /** @hidden */
  3687. _babylonBuffer?: Promise<Buffer>;
  3688. }
  3689. /**
  3690. * Loader interface with additional members.
  3691. */
  3692. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3693. }
  3694. /**
  3695. * Loader interface with additional members.
  3696. */
  3697. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3698. /** @hidden */
  3699. _data?: Promise<ArrayBufferView>;
  3700. }
  3701. /**
  3702. * Loader interface with additional members.
  3703. */
  3704. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  3705. }
  3706. /**
  3707. * Loader interface with additional members.
  3708. */
  3709. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  3710. }
  3711. /**
  3712. * Loader interface with additional members.
  3713. */
  3714. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3715. baseColorTexture?: ITextureInfo;
  3716. metallicRoughnessTexture?: ITextureInfo;
  3717. }
  3718. /**
  3719. * Loader interface with additional members.
  3720. */
  3721. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3722. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3723. normalTexture?: IMaterialNormalTextureInfo;
  3724. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3725. emissiveTexture?: ITextureInfo;
  3726. /** @hidden */
  3727. _data?: {
  3728. [babylonDrawMode: number]: {
  3729. babylonMaterial: Material;
  3730. babylonMeshes: AbstractMesh[];
  3731. promise: Promise<void>;
  3732. };
  3733. };
  3734. }
  3735. /**
  3736. * Loader interface with additional members.
  3737. */
  3738. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3739. primitives: IMeshPrimitive[];
  3740. }
  3741. /**
  3742. * Loader interface with additional members.
  3743. */
  3744. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3745. /** @hidden */
  3746. _instanceData?: {
  3747. babylonSourceMesh: Mesh;
  3748. promise: Promise<any>;
  3749. };
  3750. }
  3751. /**
  3752. * Loader interface with additional members.
  3753. */
  3754. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  3755. /**
  3756. * The parent glTF node.
  3757. */
  3758. parent?: INode;
  3759. /** @hidden */
  3760. _babylonTransformNode?: TransformNode;
  3761. /** @hidden */
  3762. _primitiveBabylonMeshes?: AbstractMesh[];
  3763. /** @hidden */
  3764. _babylonBones?: Bone[];
  3765. /** @hidden */
  3766. _numMorphTargets?: number;
  3767. }
  3768. /** @hidden */
  3769. export interface _ISamplerData {
  3770. noMipMaps: boolean;
  3771. samplingMode: number;
  3772. wrapU: number;
  3773. wrapV: number;
  3774. }
  3775. /**
  3776. * Loader interface with additional members.
  3777. */
  3778. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  3779. /** @hidden */
  3780. _data?: _ISamplerData;
  3781. }
  3782. /**
  3783. * Loader interface with additional members.
  3784. */
  3785. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  3786. }
  3787. /**
  3788. * Loader interface with additional members.
  3789. */
  3790. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  3791. /** @hidden */
  3792. _data?: {
  3793. babylonSkeleton: Skeleton;
  3794. promise: Promise<void>;
  3795. };
  3796. }
  3797. /**
  3798. * Loader interface with additional members.
  3799. */
  3800. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  3801. }
  3802. /**
  3803. * Loader interface with additional members.
  3804. */
  3805. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  3806. }
  3807. /**
  3808. * Loader interface with additional members.
  3809. */
  3810. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  3811. accessors?: IAccessor[];
  3812. animations?: IAnimation[];
  3813. buffers?: IBuffer[];
  3814. bufferViews?: IBufferView[];
  3815. cameras?: ICamera[];
  3816. images?: IImage[];
  3817. materials?: IMaterial[];
  3818. meshes?: IMesh[];
  3819. nodes?: INode[];
  3820. samplers?: ISampler[];
  3821. scenes?: IScene[];
  3822. skins?: ISkin[];
  3823. textures?: ITexture[];
  3824. }
  3825. }
  3826. declare module BABYLON.GLTF2 {
  3827. /**
  3828. * Interface for a glTF loader extension.
  3829. */
  3830. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  3831. /**
  3832. * Called after the loader state changes to LOADING.
  3833. */
  3834. onLoading?(): void;
  3835. /**
  3836. * Called after the loader state changes to READY.
  3837. */
  3838. onReady?(): void;
  3839. /**
  3840. * Define this method to modify the default behavior when loading scenes.
  3841. * @param context The context when loading the asset
  3842. * @param scene The glTF scene property
  3843. * @returns A promise that resolves when the load is complete or null if not handled
  3844. */
  3845. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  3846. /**
  3847. * Define this method to modify the default behavior when loading nodes.
  3848. * @param context The context when loading the asset
  3849. * @param node The glTF node property
  3850. * @param assign A function called synchronously after parsing the glTF properties
  3851. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  3852. */
  3853. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  3854. /**
  3855. * Define this method to modify the default behavior when loading cameras.
  3856. * @param context The context when loading the asset
  3857. * @param camera The glTF camera property
  3858. * @param assign A function called synchronously after parsing the glTF properties
  3859. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  3860. */
  3861. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  3862. /**
  3863. * @hidden
  3864. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  3865. * @param context The context when loading the asset
  3866. * @param primitive The glTF mesh primitive property
  3867. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  3868. */
  3869. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  3870. /**
  3871. * @hidden
  3872. * Define this method to modify the default behavior when loading data for mesh primitives.
  3873. * @param context The context when loading the asset
  3874. * @param name The mesh name when loading the asset
  3875. * @param node The glTF node when loading the asset
  3876. * @param mesh The glTF mesh when loading the asset
  3877. * @param primitive The glTF mesh primitive property
  3878. * @param assign A function called synchronously after parsing the glTF properties
  3879. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  3880. */
  3881. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  3882. /**
  3883. * @hidden
  3884. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  3885. * @param context The context when loading the asset
  3886. * @param material The glTF material property
  3887. * @param assign A function called synchronously after parsing the glTF properties
  3888. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  3889. */
  3890. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  3891. /**
  3892. * Define this method to modify the default behavior when creating materials.
  3893. * @param context The context when loading the asset
  3894. * @param material The glTF material property
  3895. * @param babylonDrawMode The draw mode for the Babylon material
  3896. * @returns The Babylon material or null if not handled
  3897. */
  3898. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  3899. /**
  3900. * Define this method to modify the default behavior when loading material properties.
  3901. * @param context The context when loading the asset
  3902. * @param material The glTF material property
  3903. * @param babylonMaterial The Babylon material
  3904. * @returns A promise that resolves when the load is complete or null if not handled
  3905. */
  3906. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  3907. /**
  3908. * Define this method to modify the default behavior when loading texture infos.
  3909. * @param context The context when loading the asset
  3910. * @param textureInfo The glTF texture info property
  3911. * @param assign A function called synchronously after parsing the glTF properties
  3912. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  3913. */
  3914. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3915. /**
  3916. * @hidden
  3917. * Define this method to modify the default behavior when loading textures.
  3918. * @param context The context when loading the asset
  3919. * @param texture The glTF texture property
  3920. * @param assign A function called synchronously after parsing the glTF properties
  3921. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  3922. */
  3923. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  3924. /**
  3925. * Define this method to modify the default behavior when loading animations.
  3926. * @param context The context when loading the asset
  3927. * @param animation The glTF animation property
  3928. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  3929. */
  3930. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  3931. /**
  3932. * @hidden
  3933. * Define this method to modify the default behavior when loading skins.
  3934. * @param context The context when loading the asset
  3935. * @param node The glTF node property
  3936. * @param skin The glTF skin property
  3937. * @returns A promise that resolves when the load is complete or null if not handled
  3938. */
  3939. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  3940. /**
  3941. * @hidden
  3942. * Define this method to modify the default behavior when loading uris.
  3943. * @param context The context when loading the asset
  3944. * @param property The glTF property associated with the uri
  3945. * @param uri The uri to load
  3946. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3947. */
  3948. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  3949. /**
  3950. * Define this method to modify the default behavior when loading buffer views.
  3951. * @param context The context when loading the asset
  3952. * @param bufferView The glTF buffer view property
  3953. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3954. */
  3955. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  3956. /**
  3957. * Define this method to modify the default behavior when loading buffers.
  3958. * @param context The context when loading the asset
  3959. * @param buffer The glTF buffer property
  3960. * @param byteOffset The byte offset to load
  3961. * @param byteLength The byte length to load
  3962. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  3963. */
  3964. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  3965. }
  3966. }
  3967. declare module BABYLON.GLTF2 {
  3968. /**
  3969. * Helper class for working with arrays when loading the glTF asset
  3970. */
  3971. export class ArrayItem {
  3972. /**
  3973. * Gets an item from the given array.
  3974. * @param context The context when loading the asset
  3975. * @param array The array to get the item from
  3976. * @param index The index to the array
  3977. * @returns The array item
  3978. */
  3979. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  3980. /**
  3981. * Assign an `index` field to each item of the given array.
  3982. * @param array The array of items
  3983. */
  3984. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  3985. }
  3986. /**
  3987. * The glTF 2.0 loader
  3988. */
  3989. export class GLTFLoader implements IGLTFLoader {
  3990. /** @hidden */
  3991. _completePromises: Promise<any>[];
  3992. /** @hidden */
  3993. _forAssetContainer: boolean;
  3994. /** Storage */
  3995. _babylonLights: Light[];
  3996. private _disposed;
  3997. private _parent;
  3998. private _state;
  3999. private _extensions;
  4000. private _rootUrl;
  4001. private _fileName;
  4002. private _uniqueRootUrl;
  4003. private _gltf;
  4004. private _bin;
  4005. private _babylonScene;
  4006. private _rootBabylonMesh;
  4007. private _defaultBabylonMaterialData;
  4008. private _progressCallback?;
  4009. private _requests;
  4010. private static _RegisteredExtensions;
  4011. /**
  4012. * The default glTF sampler.
  4013. */
  4014. static readonly DefaultSampler: ISampler;
  4015. /**
  4016. * Registers a loader extension.
  4017. * @param name The name of the loader extension.
  4018. * @param factory The factory function that creates the loader extension.
  4019. */
  4020. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  4021. /**
  4022. * Unregisters a loader extension.
  4023. * @param name The name of the loader extension.
  4024. * @returns A boolean indicating whether the extension has been unregistered
  4025. */
  4026. static UnregisterExtension(name: string): boolean;
  4027. /**
  4028. * The loader state.
  4029. */
  4030. get state(): Nullable<GLTFLoaderState>;
  4031. /**
  4032. * The object that represents the glTF JSON.
  4033. */
  4034. get gltf(): IGLTF;
  4035. /**
  4036. * The BIN chunk of a binary glTF.
  4037. */
  4038. get bin(): Nullable<IDataBuffer>;
  4039. /**
  4040. * The parent file loader.
  4041. */
  4042. get parent(): GLTFFileLoader;
  4043. /**
  4044. * The Babylon scene when loading the asset.
  4045. */
  4046. get babylonScene(): Scene;
  4047. /**
  4048. * The root Babylon mesh when loading the asset.
  4049. */
  4050. get rootBabylonMesh(): Mesh;
  4051. /** @hidden */
  4052. constructor(parent: GLTFFileLoader);
  4053. /** @hidden */
  4054. dispose(): void;
  4055. /** @hidden */
  4056. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  4057. /** @hidden */
  4058. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4059. private _loadAsync;
  4060. private _loadData;
  4061. private _setupData;
  4062. private _loadExtensions;
  4063. private _checkExtensions;
  4064. private _setState;
  4065. private _createRootNode;
  4066. /**
  4067. * Loads a glTF scene.
  4068. * @param context The context when loading the asset
  4069. * @param scene The glTF scene property
  4070. * @returns A promise that resolves when the load is complete
  4071. */
  4072. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  4073. private _forEachPrimitive;
  4074. private _getMeshes;
  4075. private _getTransformNodes;
  4076. private _getSkeletons;
  4077. private _getAnimationGroups;
  4078. private _startAnimations;
  4079. /**
  4080. * Loads a glTF node.
  4081. * @param context The context when loading the asset
  4082. * @param node The glTF node property
  4083. * @param assign A function called synchronously after parsing the glTF properties
  4084. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  4085. */
  4086. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  4087. private _loadMeshAsync;
  4088. /**
  4089. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  4090. * @param context The context when loading the asset
  4091. * @param name The mesh name when loading the asset
  4092. * @param node The glTF node when loading the asset
  4093. * @param mesh The glTF mesh when loading the asset
  4094. * @param primitive The glTF mesh primitive property
  4095. * @param assign A function called synchronously after parsing the glTF properties
  4096. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  4097. */
  4098. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  4099. private _loadVertexDataAsync;
  4100. private _createMorphTargets;
  4101. private _loadMorphTargetsAsync;
  4102. private _loadMorphTargetVertexDataAsync;
  4103. private static _LoadTransform;
  4104. private _loadSkinAsync;
  4105. private _loadBones;
  4106. private _loadBone;
  4107. private _loadSkinInverseBindMatricesDataAsync;
  4108. private _updateBoneMatrices;
  4109. private _getNodeMatrix;
  4110. /**
  4111. * Loads a glTF camera.
  4112. * @param context The context when loading the asset
  4113. * @param camera The glTF camera property
  4114. * @param assign A function called synchronously after parsing the glTF properties
  4115. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  4116. */
  4117. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  4118. private _loadAnimationsAsync;
  4119. /**
  4120. * Loads a glTF animation.
  4121. * @param context The context when loading the asset
  4122. * @param animation The glTF animation property
  4123. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  4124. */
  4125. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  4126. /**
  4127. * @hidden Loads a glTF animation channel.
  4128. * @param context The context when loading the asset
  4129. * @param animationContext The context of the animation when loading the asset
  4130. * @param animation The glTF animation property
  4131. * @param channel The glTF animation channel property
  4132. * @param babylonAnimationGroup The babylon animation group property
  4133. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  4134. * @returns A void promise when the channel load is complete
  4135. */
  4136. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  4137. private _loadAnimationSamplerAsync;
  4138. private _loadBufferAsync;
  4139. /**
  4140. * Loads a glTF buffer view.
  4141. * @param context The context when loading the asset
  4142. * @param bufferView The glTF buffer view property
  4143. * @returns A promise that resolves with the loaded data when the load is complete
  4144. */
  4145. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  4146. private _loadAccessorAsync;
  4147. /** @hidden */
  4148. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  4149. private _loadIndicesAccessorAsync;
  4150. private _loadVertexBufferViewAsync;
  4151. private _loadVertexAccessorAsync;
  4152. private _loadMaterialMetallicRoughnessPropertiesAsync;
  4153. /** @hidden */
  4154. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  4155. private _createDefaultMaterial;
  4156. /**
  4157. * Creates a Babylon material from a glTF material.
  4158. * @param context The context when loading the asset
  4159. * @param material The glTF material property
  4160. * @param babylonDrawMode The draw mode for the Babylon material
  4161. * @returns The Babylon material
  4162. */
  4163. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  4164. /**
  4165. * Loads properties from a glTF material into a Babylon material.
  4166. * @param context The context when loading the asset
  4167. * @param material The glTF material property
  4168. * @param babylonMaterial The Babylon material
  4169. * @returns A promise that resolves when the load is complete
  4170. */
  4171. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  4172. /**
  4173. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  4174. * @param context The context when loading the asset
  4175. * @param material The glTF material property
  4176. * @param babylonMaterial The Babylon material
  4177. * @returns A promise that resolves when the load is complete
  4178. */
  4179. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  4180. /**
  4181. * Loads the alpha properties from a glTF material into a Babylon material.
  4182. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  4183. * @param context The context when loading the asset
  4184. * @param material The glTF material property
  4185. * @param babylonMaterial The Babylon material
  4186. */
  4187. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  4188. /**
  4189. * Loads a glTF texture info.
  4190. * @param context The context when loading the asset
  4191. * @param textureInfo The glTF texture info property
  4192. * @param assign A function called synchronously after parsing the glTF properties
  4193. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  4194. */
  4195. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4196. /** @hidden */
  4197. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4198. /** @hidden */
  4199. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4200. private _loadSampler;
  4201. /**
  4202. * Loads a glTF image.
  4203. * @param context The context when loading the asset
  4204. * @param image The glTF image property
  4205. * @returns A promise that resolves with the loaded data when the load is complete
  4206. */
  4207. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  4208. /**
  4209. * Loads a glTF uri.
  4210. * @param context The context when loading the asset
  4211. * @param property The glTF property associated with the uri
  4212. * @param uri The base64 or relative uri
  4213. * @returns A promise that resolves with the loaded data when the load is complete
  4214. */
  4215. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  4216. private _onProgress;
  4217. /**
  4218. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  4219. * @param babylonObject the Babylon object with metadata
  4220. * @param pointer the JSON pointer
  4221. */
  4222. static AddPointerMetadata(babylonObject: {
  4223. metadata: any;
  4224. }, pointer: string): void;
  4225. private static _GetTextureWrapMode;
  4226. private static _GetTextureSamplingMode;
  4227. private static _GetTypedArrayConstructor;
  4228. private static _GetTypedArray;
  4229. private static _GetNumComponents;
  4230. private static _ValidateUri;
  4231. private static _GetDrawMode;
  4232. private _compileMaterialsAsync;
  4233. private _compileShadowGeneratorsAsync;
  4234. private _forEachExtensions;
  4235. private _applyExtensions;
  4236. private _extensionsOnLoading;
  4237. private _extensionsOnReady;
  4238. private _extensionsLoadSceneAsync;
  4239. private _extensionsLoadNodeAsync;
  4240. private _extensionsLoadCameraAsync;
  4241. private _extensionsLoadVertexDataAsync;
  4242. private _extensionsLoadMeshPrimitiveAsync;
  4243. private _extensionsLoadMaterialAsync;
  4244. private _extensionsCreateMaterial;
  4245. private _extensionsLoadMaterialPropertiesAsync;
  4246. private _extensionsLoadTextureInfoAsync;
  4247. private _extensionsLoadTextureAsync;
  4248. private _extensionsLoadAnimationAsync;
  4249. private _extensionsLoadSkinAsync;
  4250. private _extensionsLoadUriAsync;
  4251. private _extensionsLoadBufferViewAsync;
  4252. private _extensionsLoadBufferAsync;
  4253. /**
  4254. * Helper method called by a loader extension to load an glTF extension.
  4255. * @param context The context when loading the asset
  4256. * @param property The glTF property to load the extension from
  4257. * @param extensionName The name of the extension to load
  4258. * @param actionAsync The action to run
  4259. * @returns The promise returned by actionAsync or null if the extension does not exist
  4260. */
  4261. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4262. /**
  4263. * Helper method called by a loader extension to load a glTF extra.
  4264. * @param context The context when loading the asset
  4265. * @param property The glTF property to load the extra from
  4266. * @param extensionName The name of the extension to load
  4267. * @param actionAsync The action to run
  4268. * @returns The promise returned by actionAsync or null if the extra does not exist
  4269. */
  4270. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4271. /**
  4272. * Checks for presence of an extension.
  4273. * @param name The name of the extension to check
  4274. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  4275. */
  4276. isExtensionUsed(name: string): boolean;
  4277. /**
  4278. * Increments the indentation level and logs a message.
  4279. * @param message The message to log
  4280. */
  4281. logOpen(message: string): void;
  4282. /**
  4283. * Decrements the indentation level.
  4284. */
  4285. logClose(): void;
  4286. /**
  4287. * Logs a message
  4288. * @param message The message to log
  4289. */
  4290. log(message: string): void;
  4291. /**
  4292. * Starts a performance counter.
  4293. * @param counterName The name of the performance counter
  4294. */
  4295. startPerformanceCounter(counterName: string): void;
  4296. /**
  4297. * Ends a performance counter.
  4298. * @param counterName The name of the performance counter
  4299. */
  4300. endPerformanceCounter(counterName: string): void;
  4301. }
  4302. }
  4303. declare module BABYLON.GLTF2.Loader.Extensions {
  4304. /**
  4305. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  4306. */
  4307. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  4308. /**
  4309. * The name of this extension.
  4310. */
  4311. readonly name: string;
  4312. /**
  4313. * Defines whether this extension is enabled.
  4314. */
  4315. enabled: boolean;
  4316. private _loader;
  4317. private _lights?;
  4318. /** @hidden */
  4319. constructor(loader: GLTFLoader);
  4320. /** @hidden */
  4321. dispose(): void;
  4322. /** @hidden */
  4323. onLoading(): void;
  4324. /** @hidden */
  4325. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4326. private _loadLightAsync;
  4327. }
  4328. }
  4329. declare module BABYLON.GLTF2.Loader.Extensions {
  4330. /**
  4331. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  4332. */
  4333. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  4334. /**
  4335. * The name of this extension.
  4336. */
  4337. readonly name: string;
  4338. /**
  4339. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  4340. */
  4341. dracoCompression?: DracoCompression;
  4342. /**
  4343. * Defines whether this extension is enabled.
  4344. */
  4345. enabled: boolean;
  4346. private _loader;
  4347. /** @hidden */
  4348. constructor(loader: GLTFLoader);
  4349. /** @hidden */
  4350. dispose(): void;
  4351. /** @hidden */
  4352. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  4353. }
  4354. }
  4355. declare module BABYLON.GLTF2.Loader.Extensions {
  4356. /**
  4357. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  4358. */
  4359. export class KHR_lights implements IGLTFLoaderExtension {
  4360. /**
  4361. * The name of this extension.
  4362. */
  4363. readonly name: string;
  4364. /**
  4365. * Defines whether this extension is enabled.
  4366. */
  4367. enabled: boolean;
  4368. private _loader;
  4369. private _lights?;
  4370. /** @hidden */
  4371. constructor(loader: GLTFLoader);
  4372. /** @hidden */
  4373. dispose(): void;
  4374. /** @hidden */
  4375. onLoading(): void;
  4376. /** @hidden */
  4377. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4378. }
  4379. }
  4380. declare module BABYLON.GLTF2.Loader.Extensions {
  4381. /**
  4382. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  4383. */
  4384. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  4385. /**
  4386. * The name of this extension.
  4387. */
  4388. readonly name: string;
  4389. /**
  4390. * Defines whether this extension is enabled.
  4391. */
  4392. enabled: boolean;
  4393. /**
  4394. * Defines a number that determines the order the extensions are applied.
  4395. */
  4396. order: number;
  4397. private _loader;
  4398. /** @hidden */
  4399. constructor(loader: GLTFLoader);
  4400. /** @hidden */
  4401. dispose(): void;
  4402. /** @hidden */
  4403. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4404. private _loadSpecularGlossinessPropertiesAsync;
  4405. }
  4406. }
  4407. declare module BABYLON.GLTF2.Loader.Extensions {
  4408. /**
  4409. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  4410. */
  4411. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  4412. /**
  4413. * The name of this extension.
  4414. */
  4415. readonly name: string;
  4416. /**
  4417. * Defines whether this extension is enabled.
  4418. */
  4419. enabled: boolean;
  4420. /**
  4421. * Defines a number that determines the order the extensions are applied.
  4422. */
  4423. order: number;
  4424. private _loader;
  4425. /** @hidden */
  4426. constructor(loader: GLTFLoader);
  4427. /** @hidden */
  4428. dispose(): void;
  4429. /** @hidden */
  4430. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4431. private _loadUnlitPropertiesAsync;
  4432. }
  4433. }
  4434. declare module BABYLON.GLTF2.Loader.Extensions {
  4435. /**
  4436. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  4437. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  4438. * !!! Experimental Extension Subject to Changes !!!
  4439. */
  4440. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  4441. /**
  4442. * The name of this extension.
  4443. */
  4444. readonly name: string;
  4445. /**
  4446. * Defines whether this extension is enabled.
  4447. */
  4448. enabled: boolean;
  4449. /**
  4450. * Defines a number that determines the order the extensions are applied.
  4451. */
  4452. order: number;
  4453. private _loader;
  4454. /** @hidden */
  4455. constructor(loader: GLTFLoader);
  4456. /** @hidden */
  4457. dispose(): void;
  4458. /** @hidden */
  4459. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4460. private _loadClearCoatPropertiesAsync;
  4461. }
  4462. }
  4463. declare module BABYLON.GLTF2.Loader.Extensions {
  4464. /**
  4465. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  4466. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  4467. * !!! Experimental Extension Subject to Changes !!!
  4468. */
  4469. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  4470. /**
  4471. * The name of this extension.
  4472. */
  4473. readonly name: string;
  4474. /**
  4475. * Defines whether this extension is enabled.
  4476. */
  4477. enabled: boolean;
  4478. /**
  4479. * Defines a number that determines the order the extensions are applied.
  4480. */
  4481. order: number;
  4482. private _loader;
  4483. /** @hidden */
  4484. constructor(loader: GLTFLoader);
  4485. /** @hidden */
  4486. dispose(): void;
  4487. /** @hidden */
  4488. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4489. private _loadSheenPropertiesAsync;
  4490. }
  4491. }
  4492. declare module BABYLON.GLTF2.Loader.Extensions {
  4493. /**
  4494. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  4495. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  4496. * !!! Experimental Extension Subject to Changes !!!
  4497. */
  4498. export class KHR_materials_specular implements IGLTFLoaderExtension {
  4499. /**
  4500. * The name of this extension.
  4501. */
  4502. readonly name: string;
  4503. /**
  4504. * Defines whether this extension is enabled.
  4505. */
  4506. enabled: boolean;
  4507. /**
  4508. * Defines a number that determines the order the extensions are applied.
  4509. */
  4510. order: number;
  4511. private _loader;
  4512. /** @hidden */
  4513. constructor(loader: GLTFLoader);
  4514. /** @hidden */
  4515. dispose(): void;
  4516. /** @hidden */
  4517. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4518. private _loadSpecularPropertiesAsync;
  4519. }
  4520. }
  4521. declare module BABYLON.GLTF2.Loader.Extensions {
  4522. /**
  4523. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  4524. * [Playground Sample](//TODO)
  4525. * !!! Experimental Extension Subject to Changes !!!
  4526. */
  4527. export class KHR_mesh_instancing implements IGLTFLoaderExtension {
  4528. /**
  4529. * The name of this extension.
  4530. */
  4531. readonly name: string;
  4532. /**
  4533. * Defines whether this extension is enabled.
  4534. */
  4535. enabled: boolean;
  4536. private _loader;
  4537. /** @hidden */
  4538. constructor(loader: GLTFLoader);
  4539. /** @hidden */
  4540. dispose(): void;
  4541. /** @hidden */
  4542. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4543. }
  4544. }
  4545. declare module BABYLON.GLTF2.Loader.Extensions {
  4546. /**
  4547. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  4548. */
  4549. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  4550. /**
  4551. * The name of this extension.
  4552. */
  4553. readonly name: string;
  4554. /**
  4555. * Defines whether this extension is enabled.
  4556. */
  4557. enabled: boolean;
  4558. /** @hidden */
  4559. constructor(loader: GLTFLoader);
  4560. /** @hidden */
  4561. dispose(): void;
  4562. }
  4563. }
  4564. declare module BABYLON.GLTF2.Loader.Extensions {
  4565. /**
  4566. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  4567. * !!! Experimental Extension Subject to Changes !!!
  4568. */
  4569. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  4570. /** The name of this extension. */
  4571. readonly name: string;
  4572. /** Defines whether this extension is enabled. */
  4573. enabled: boolean;
  4574. private _loader;
  4575. /** @hidden */
  4576. constructor(loader: GLTFLoader);
  4577. /** @hidden */
  4578. dispose(): void;
  4579. /** @hidden */
  4580. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4581. }
  4582. }
  4583. declare module BABYLON.GLTF2.Loader.Extensions {
  4584. /**
  4585. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  4586. */
  4587. export class KHR_texture_transform implements IGLTFLoaderExtension {
  4588. /**
  4589. * The name of this extension.
  4590. */
  4591. readonly name: string;
  4592. /**
  4593. * Defines whether this extension is enabled.
  4594. */
  4595. enabled: boolean;
  4596. private _loader;
  4597. /** @hidden */
  4598. constructor(loader: GLTFLoader);
  4599. /** @hidden */
  4600. dispose(): void;
  4601. /** @hidden */
  4602. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4603. }
  4604. }
  4605. declare module BABYLON.GLTF2.Loader.Extensions {
  4606. /**
  4607. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  4608. */
  4609. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  4610. /**
  4611. * The name of this extension.
  4612. */
  4613. readonly name: string;
  4614. /**
  4615. * Defines whether this extension is enabled.
  4616. */
  4617. enabled: boolean;
  4618. private _loader;
  4619. private _clips;
  4620. private _emitters;
  4621. /** @hidden */
  4622. constructor(loader: GLTFLoader);
  4623. /** @hidden */
  4624. dispose(): void;
  4625. /** @hidden */
  4626. onLoading(): void;
  4627. /** @hidden */
  4628. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4629. /** @hidden */
  4630. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4631. /** @hidden */
  4632. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  4633. private _loadClipAsync;
  4634. private _loadEmitterAsync;
  4635. private _getEventAction;
  4636. private _loadAnimationEventAsync;
  4637. }
  4638. }
  4639. declare module BABYLON.GLTF2.Loader.Extensions {
  4640. /**
  4641. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  4642. */
  4643. export class MSFT_lod implements IGLTFLoaderExtension {
  4644. /**
  4645. * The name of this extension.
  4646. */
  4647. readonly name: string;
  4648. /**
  4649. * Defines whether this extension is enabled.
  4650. */
  4651. enabled: boolean;
  4652. /**
  4653. * Defines a number that determines the order the extensions are applied.
  4654. */
  4655. order: number;
  4656. /**
  4657. * Maximum number of LODs to load, starting from the lowest LOD.
  4658. */
  4659. maxLODsToLoad: number;
  4660. /**
  4661. * Observable raised when all node LODs of one level are loaded.
  4662. * The event data is the index of the loaded LOD starting from zero.
  4663. * Dispose the loader to cancel the loading of the next level of LODs.
  4664. */
  4665. onNodeLODsLoadedObservable: Observable<number>;
  4666. /**
  4667. * Observable raised when all material LODs of one level are loaded.
  4668. * The event data is the index of the loaded LOD starting from zero.
  4669. * Dispose the loader to cancel the loading of the next level of LODs.
  4670. */
  4671. onMaterialLODsLoadedObservable: Observable<number>;
  4672. private _loader;
  4673. private _nodeIndexLOD;
  4674. private _nodeSignalLODs;
  4675. private _nodePromiseLODs;
  4676. private _materialIndexLOD;
  4677. private _materialSignalLODs;
  4678. private _materialPromiseLODs;
  4679. private _indexLOD;
  4680. private _bufferLODs;
  4681. /** @hidden */
  4682. constructor(loader: GLTFLoader);
  4683. /** @hidden */
  4684. dispose(): void;
  4685. /** @hidden */
  4686. onReady(): void;
  4687. /** @hidden */
  4688. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4689. /** @hidden */
  4690. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4691. /** @hidden */
  4692. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  4693. /** @hidden */
  4694. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  4695. /** @hidden */
  4696. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  4697. private _loadBufferLOD;
  4698. /**
  4699. * Gets an array of LOD properties from lowest to highest.
  4700. */
  4701. private _getLODs;
  4702. private _disposeTransformNode;
  4703. private _disposeMaterials;
  4704. }
  4705. }
  4706. declare module BABYLON.GLTF2.Loader.Extensions {
  4707. /** @hidden */
  4708. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  4709. readonly name: string;
  4710. enabled: boolean;
  4711. private _loader;
  4712. constructor(loader: GLTFLoader);
  4713. dispose(): void;
  4714. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4715. }
  4716. }
  4717. declare module BABYLON.GLTF2.Loader.Extensions {
  4718. /** @hidden */
  4719. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  4720. readonly name: string;
  4721. enabled: boolean;
  4722. private _loader;
  4723. constructor(loader: GLTFLoader);
  4724. dispose(): void;
  4725. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4726. }
  4727. }
  4728. declare module BABYLON.GLTF2.Loader.Extensions {
  4729. /**
  4730. * Store glTF extras (if present) in BJS objects' metadata
  4731. */
  4732. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  4733. /**
  4734. * The name of this extension.
  4735. */
  4736. readonly name: string;
  4737. /**
  4738. * Defines whether this extension is enabled.
  4739. */
  4740. enabled: boolean;
  4741. private _loader;
  4742. private _assignExtras;
  4743. /** @hidden */
  4744. constructor(loader: GLTFLoader);
  4745. /** @hidden */
  4746. dispose(): void;
  4747. /** @hidden */
  4748. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4749. /** @hidden */
  4750. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  4751. /** @hidden */
  4752. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  4753. }
  4754. }
  4755. declare module BABYLON {
  4756. /**
  4757. * Class reading and parsing the MTL file bundled with the obj file.
  4758. */
  4759. export class MTLFileLoader {
  4760. /**
  4761. * Invert Y-Axis of referenced textures on load
  4762. */
  4763. static INVERT_TEXTURE_Y: boolean;
  4764. /**
  4765. * All material loaded from the mtl will be set here
  4766. */
  4767. materials: StandardMaterial[];
  4768. /**
  4769. * This function will read the mtl file and create each material described inside
  4770. * This function could be improve by adding :
  4771. * -some component missing (Ni, Tf...)
  4772. * -including the specific options available
  4773. *
  4774. * @param scene defines the scene the material will be created in
  4775. * @param data defines the mtl data to parse
  4776. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  4777. * @param forAssetContainer defines if the material should be registered in the scene
  4778. */
  4779. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  4780. /**
  4781. * Gets the texture for the material.
  4782. *
  4783. * If the material is imported from input file,
  4784. * We sanitize the url to ensure it takes the textre from aside the material.
  4785. *
  4786. * @param rootUrl The root url to load from
  4787. * @param value The value stored in the mtl
  4788. * @return The Texture
  4789. */
  4790. private static _getTexture;
  4791. }
  4792. }
  4793. declare module BABYLON {
  4794. /**
  4795. * Options for loading OBJ/MTL files
  4796. */
  4797. type MeshLoadOptions = {
  4798. /**
  4799. * Defines if UVs are optimized by default during load.
  4800. */
  4801. OptimizeWithUV: boolean;
  4802. /**
  4803. * Defines custom scaling of UV coordinates of loaded meshes.
  4804. */
  4805. UVScaling: Vector2;
  4806. /**
  4807. * Invert model on y-axis (does a model scaling inversion)
  4808. */
  4809. InvertY: boolean;
  4810. /**
  4811. * Invert Y-Axis of referenced textures on load
  4812. */
  4813. InvertTextureY: boolean;
  4814. /**
  4815. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4816. */
  4817. ImportVertexColors: boolean;
  4818. /**
  4819. * Compute the normals for the model, even if normals are present in the file.
  4820. */
  4821. ComputeNormals: boolean;
  4822. /**
  4823. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4824. */
  4825. SkipMaterials: boolean;
  4826. /**
  4827. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4828. */
  4829. MaterialLoadingFailsSilently: boolean;
  4830. };
  4831. /**
  4832. * OBJ file type loader.
  4833. * This is a babylon scene loader plugin.
  4834. */
  4835. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  4836. /**
  4837. * Defines if UVs are optimized by default during load.
  4838. */
  4839. static OPTIMIZE_WITH_UV: boolean;
  4840. /**
  4841. * Invert model on y-axis (does a model scaling inversion)
  4842. */
  4843. static INVERT_Y: boolean;
  4844. /**
  4845. * Invert Y-Axis of referenced textures on load
  4846. */
  4847. static get INVERT_TEXTURE_Y(): boolean;
  4848. static set INVERT_TEXTURE_Y(value: boolean);
  4849. /**
  4850. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  4851. */
  4852. static IMPORT_VERTEX_COLORS: boolean;
  4853. /**
  4854. * Compute the normals for the model, even if normals are present in the file.
  4855. */
  4856. static COMPUTE_NORMALS: boolean;
  4857. /**
  4858. * Defines custom scaling of UV coordinates of loaded meshes.
  4859. */
  4860. static UV_SCALING: Vector2;
  4861. /**
  4862. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  4863. */
  4864. static SKIP_MATERIALS: boolean;
  4865. /**
  4866. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  4867. *
  4868. * Defaults to true for backwards compatibility.
  4869. */
  4870. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  4871. /**
  4872. * Defines the name of the plugin.
  4873. */
  4874. name: string;
  4875. /**
  4876. * Defines the extension the plugin is able to load.
  4877. */
  4878. extensions: string;
  4879. /** @hidden */
  4880. obj: RegExp;
  4881. /** @hidden */
  4882. group: RegExp;
  4883. /** @hidden */
  4884. mtllib: RegExp;
  4885. /** @hidden */
  4886. usemtl: RegExp;
  4887. /** @hidden */
  4888. smooth: RegExp;
  4889. /** @hidden */
  4890. vertexPattern: RegExp;
  4891. /** @hidden */
  4892. normalPattern: RegExp;
  4893. /** @hidden */
  4894. uvPattern: RegExp;
  4895. /** @hidden */
  4896. facePattern1: RegExp;
  4897. /** @hidden */
  4898. facePattern2: RegExp;
  4899. /** @hidden */
  4900. facePattern3: RegExp;
  4901. /** @hidden */
  4902. facePattern4: RegExp;
  4903. /** @hidden */
  4904. facePattern5: RegExp;
  4905. private _forAssetContainer;
  4906. private _meshLoadOptions;
  4907. /**
  4908. * Creates loader for .OBJ files
  4909. *
  4910. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  4911. */
  4912. constructor(meshLoadOptions?: MeshLoadOptions);
  4913. private static get currentMeshLoadOptions();
  4914. /**
  4915. * Calls synchronously the MTL file attached to this obj.
  4916. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  4917. * Without this function materials are not displayed in the first frame (but displayed after).
  4918. * In consequence it is impossible to get material information in your HTML file
  4919. *
  4920. * @param url The URL of the MTL file
  4921. * @param rootUrl
  4922. * @param onSuccess Callback function to be called when the MTL file is loaded
  4923. * @private
  4924. */
  4925. private _loadMTL;
  4926. /**
  4927. * Instantiates a OBJ file loader plugin.
  4928. * @returns the created plugin
  4929. */
  4930. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  4931. /**
  4932. * If the data string can be loaded directly.
  4933. *
  4934. * @param data string containing the file data
  4935. * @returns if the data can be loaded directly
  4936. */
  4937. canDirectLoad(data: string): boolean;
  4938. /**
  4939. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  4940. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  4941. * @param scene the scene the meshes should be added to
  4942. * @param data the OBJ data to load
  4943. * @param rootUrl root url to load from
  4944. * @param onProgress event that fires when loading progress has occured
  4945. * @param fileName Defines the name of the file to load
  4946. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  4947. */
  4948. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  4949. meshes: AbstractMesh[];
  4950. particleSystems: IParticleSystem[];
  4951. skeletons: Skeleton[];
  4952. animationGroups: AnimationGroup[];
  4953. }>;
  4954. /**
  4955. * Imports all objects from the loaded OBJ data and adds them to the scene
  4956. * @param scene the scene the objects should be added to
  4957. * @param data the OBJ data to load
  4958. * @param rootUrl root url to load from
  4959. * @param onProgress event that fires when loading progress has occured
  4960. * @param fileName Defines the name of the file to load
  4961. * @returns a promise which completes when objects have been loaded to the scene
  4962. */
  4963. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4964. /**
  4965. * Load into an asset container.
  4966. * @param scene The scene to load into
  4967. * @param data The data to import
  4968. * @param rootUrl The root url for scene and resources
  4969. * @param onProgress The callback when the load progresses
  4970. * @param fileName Defines the name of the file to load
  4971. * @returns The loaded asset container
  4972. */
  4973. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  4974. /**
  4975. * Read the OBJ file and create an Array of meshes.
  4976. * Each mesh contains all information given by the OBJ and the MTL file.
  4977. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  4978. *
  4979. * @param meshesNames
  4980. * @param scene Scene The scene where are displayed the data
  4981. * @param data String The content of the obj file
  4982. * @param rootUrl String The path to the folder
  4983. * @returns Array<AbstractMesh>
  4984. * @private
  4985. */
  4986. private _parseSolid;
  4987. }
  4988. }
  4989. declare module BABYLON {
  4990. /**
  4991. * STL file type loader.
  4992. * This is a babylon scene loader plugin.
  4993. */
  4994. export class STLFileLoader implements ISceneLoaderPlugin {
  4995. /** @hidden */
  4996. solidPattern: RegExp;
  4997. /** @hidden */
  4998. facetsPattern: RegExp;
  4999. /** @hidden */
  5000. normalPattern: RegExp;
  5001. /** @hidden */
  5002. vertexPattern: RegExp;
  5003. /**
  5004. * Defines the name of the plugin.
  5005. */
  5006. name: string;
  5007. /**
  5008. * Defines the extensions the stl loader is able to load.
  5009. * force data to come in as an ArrayBuffer
  5010. * we'll convert to string if it looks like it's an ASCII .stl
  5011. */
  5012. extensions: ISceneLoaderPluginExtensions;
  5013. /**
  5014. * Import meshes into a scene.
  5015. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  5016. * @param scene The scene to import into
  5017. * @param data The data to import
  5018. * @param rootUrl The root url for scene and resources
  5019. * @param meshes The meshes array to import into
  5020. * @param particleSystems The particle systems array to import into
  5021. * @param skeletons The skeletons array to import into
  5022. * @param onError The callback when import fails
  5023. * @returns True if successful or false otherwise
  5024. */
  5025. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  5026. /**
  5027. * Load into a scene.
  5028. * @param scene The scene to load into
  5029. * @param data The data to import
  5030. * @param rootUrl The root url for scene and resources
  5031. * @param onError The callback when import fails
  5032. * @returns true if successful or false otherwise
  5033. */
  5034. load(scene: Scene, data: any, rootUrl: string): boolean;
  5035. /**
  5036. * Load into an asset container.
  5037. * @param scene The scene to load into
  5038. * @param data The data to import
  5039. * @param rootUrl The root url for scene and resources
  5040. * @param onError The callback when import fails
  5041. * @returns The loaded asset container
  5042. */
  5043. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  5044. private _isBinary;
  5045. private _parseBinary;
  5046. private _parseASCII;
  5047. }
  5048. }