babylonjs.loaders.module.d.ts 231 KB

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