babylonjs.loaders.module.d.ts 223 KB

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