babylonjs.loaders.module.d.ts 235 KB

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