babylonjs.loaders.module.d.ts 204 KB

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