babylonjs.loaders.module.d.ts 221 KB

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