babylonjs.loaders.module.d.ts 231 KB

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