babylonjs.loaders.module.d.ts 230 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503
  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, 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. private _loadBufferAsync;
  1566. /**
  1567. * Loads a glTF buffer view.
  1568. * @param context The context when loading the asset
  1569. * @param bufferView The glTF buffer view property
  1570. * @returns A promise that resolves with the loaded data when the load is complete
  1571. */
  1572. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1573. private _loadAccessorAsync;
  1574. /** @hidden */
  1575. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  1576. private _loadIndicesAccessorAsync;
  1577. private _loadVertexBufferViewAsync;
  1578. private _loadVertexAccessorAsync;
  1579. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1580. /** @hidden */
  1581. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1582. private _createDefaultMaterial;
  1583. /**
  1584. * Creates a Babylon material from a glTF material.
  1585. * @param context The context when loading the asset
  1586. * @param material The glTF material property
  1587. * @param babylonDrawMode The draw mode for the Babylon material
  1588. * @returns The Babylon material
  1589. */
  1590. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1591. /**
  1592. * Loads properties from a glTF material into a Babylon material.
  1593. * @param context The context when loading the asset
  1594. * @param material The glTF material property
  1595. * @param babylonMaterial The Babylon material
  1596. * @returns A promise that resolves when the load is complete
  1597. */
  1598. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1599. /**
  1600. * Loads the normal, occlusion, and emissive 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. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1607. /**
  1608. * Loads the alpha properties from a glTF material into a Babylon material.
  1609. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1610. * @param context The context when loading the asset
  1611. * @param material The glTF material property
  1612. * @param babylonMaterial The Babylon material
  1613. */
  1614. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1615. /**
  1616. * Loads a glTF texture info.
  1617. * @param context The context when loading the asset
  1618. * @param textureInfo The glTF texture info property
  1619. * @param assign A function called synchronously after parsing the glTF properties
  1620. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1621. */
  1622. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1623. /** @hidden */
  1624. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1625. /** @hidden */
  1626. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  1627. private _loadSampler;
  1628. /**
  1629. * Loads a glTF image.
  1630. * @param context The context when loading the asset
  1631. * @param image The glTF image property
  1632. * @returns A promise that resolves with the loaded data when the load is complete
  1633. */
  1634. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1635. /**
  1636. * Loads a glTF uri.
  1637. * @param context The context when loading the asset
  1638. * @param property The glTF property associated with the uri
  1639. * @param uri The base64 or relative uri
  1640. * @returns A promise that resolves with the loaded data when the load is complete
  1641. */
  1642. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  1643. /**
  1644. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1645. * @param babylonObject the Babylon object with metadata
  1646. * @param pointer the JSON pointer
  1647. */
  1648. static AddPointerMetadata(babylonObject: {
  1649. metadata: any;
  1650. }, pointer: string): void;
  1651. private static _GetTextureWrapMode;
  1652. private static _GetTextureSamplingMode;
  1653. private static _GetTypedArrayConstructor;
  1654. private static _GetTypedArray;
  1655. private static _GetNumComponents;
  1656. private static _ValidateUri;
  1657. /** @hidden */
  1658. static _GetDrawMode(context: string, mode: number | undefined): number;
  1659. private _compileMaterialsAsync;
  1660. private _compileShadowGeneratorsAsync;
  1661. private _forEachExtensions;
  1662. private _applyExtensions;
  1663. private _extensionsOnLoading;
  1664. private _extensionsOnReady;
  1665. private _extensionsLoadSceneAsync;
  1666. private _extensionsLoadNodeAsync;
  1667. private _extensionsLoadCameraAsync;
  1668. private _extensionsLoadVertexDataAsync;
  1669. private _extensionsLoadMeshPrimitiveAsync;
  1670. private _extensionsLoadMaterialAsync;
  1671. private _extensionsCreateMaterial;
  1672. private _extensionsLoadMaterialPropertiesAsync;
  1673. private _extensionsLoadTextureInfoAsync;
  1674. private _extensionsLoadTextureAsync;
  1675. private _extensionsLoadAnimationAsync;
  1676. private _extensionsLoadSkinAsync;
  1677. private _extensionsLoadUriAsync;
  1678. private _extensionsLoadBufferViewAsync;
  1679. private _extensionsLoadBufferAsync;
  1680. /**
  1681. * Helper method called by a loader extension to load an glTF extension.
  1682. * @param context The context when loading the asset
  1683. * @param property The glTF property to load the extension from
  1684. * @param extensionName The name of the extension to load
  1685. * @param actionAsync The action to run
  1686. * @returns The promise returned by actionAsync or null if the extension does not exist
  1687. */
  1688. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1689. /**
  1690. * Helper method called by a loader extension to load a glTF extra.
  1691. * @param context The context when loading the asset
  1692. * @param property The glTF property to load the extra from
  1693. * @param extensionName The name of the extension to load
  1694. * @param actionAsync The action to run
  1695. * @returns The promise returned by actionAsync or null if the extra does not exist
  1696. */
  1697. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1698. /**
  1699. * Checks for presence of an extension.
  1700. * @param name The name of the extension to check
  1701. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  1702. */
  1703. isExtensionUsed(name: string): boolean;
  1704. /**
  1705. * Increments the indentation level and logs a message.
  1706. * @param message The message to log
  1707. */
  1708. logOpen(message: string): void;
  1709. /**
  1710. * Decrements the indentation level.
  1711. */
  1712. logClose(): void;
  1713. /**
  1714. * Logs a message
  1715. * @param message The message to log
  1716. */
  1717. log(message: string): void;
  1718. /**
  1719. * Starts a performance counter.
  1720. * @param counterName The name of the performance counter
  1721. */
  1722. startPerformanceCounter(counterName: string): void;
  1723. /**
  1724. * Ends a performance counter.
  1725. * @param counterName The name of the performance counter
  1726. */
  1727. endPerformanceCounter(counterName: string): void;
  1728. }
  1729. }
  1730. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based" {
  1731. import { Nullable } from "babylonjs/types";
  1732. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1733. import { IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1734. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1735. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1736. module "babylonjs-gltf2interface" {
  1737. /** @hidden */
  1738. interface IEXTLightsImageBased_LightImageBased {
  1739. _babylonTexture?: BaseTexture;
  1740. _loaded?: Promise<void>;
  1741. }
  1742. }
  1743. /**
  1744. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  1745. */
  1746. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1747. /**
  1748. * The name of this extension.
  1749. */
  1750. readonly name: string;
  1751. /**
  1752. * Defines whether this extension is enabled.
  1753. */
  1754. enabled: boolean;
  1755. private _loader;
  1756. private _lights?;
  1757. /** @hidden */
  1758. constructor(loader: GLTFLoader);
  1759. /** @hidden */
  1760. dispose(): void;
  1761. /** @hidden */
  1762. onLoading(): void;
  1763. /** @hidden */
  1764. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1765. private _loadLightAsync;
  1766. }
  1767. }
  1768. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_mesh_gpu_instancing" {
  1769. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1770. import { Nullable } from "babylonjs/types";
  1771. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1772. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1773. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1774. /**
  1775. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  1776. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  1777. * !!! Experimental Extension Subject to Changes !!!
  1778. */
  1779. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  1780. /**
  1781. * The name of this extension.
  1782. */
  1783. readonly name: string;
  1784. /**
  1785. * Defines whether this extension is enabled.
  1786. */
  1787. enabled: boolean;
  1788. private _loader;
  1789. /** @hidden */
  1790. constructor(loader: GLTFLoader);
  1791. /** @hidden */
  1792. dispose(): void;
  1793. /** @hidden */
  1794. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1795. }
  1796. }
  1797. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_meshopt_compression" {
  1798. import { Nullable } from "babylonjs/types";
  1799. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1800. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1801. import { IBufferView } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1802. /**
  1803. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  1804. *
  1805. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  1806. */
  1807. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  1808. /**
  1809. * The name of this extension.
  1810. */
  1811. readonly name: string;
  1812. /**
  1813. * Defines whether this extension is enabled.
  1814. */
  1815. enabled: boolean;
  1816. /**
  1817. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.module.js
  1818. */
  1819. static DecoderPath: string;
  1820. private _loader;
  1821. private _decoder;
  1822. /** @hidden */
  1823. constructor(loader: GLTFLoader);
  1824. /** @hidden */
  1825. dispose(): void;
  1826. /** @hidden */
  1827. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  1828. }
  1829. }
  1830. declare module "babylonjs-loaders/glTF/2.0/Extensions/EXT_texture_webp" {
  1831. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1832. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1833. import { ITexture } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  1835. import { Nullable } from "babylonjs/types";
  1836. /**
  1837. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  1838. */
  1839. export class EXT_texture_webp implements IGLTFLoaderExtension {
  1840. /** The name of this extension. */
  1841. readonly name: string;
  1842. /** Defines whether this extension is enabled. */
  1843. enabled: boolean;
  1844. private _loader;
  1845. /** @hidden */
  1846. constructor(loader: GLTFLoader);
  1847. /** @hidden */
  1848. dispose(): void;
  1849. /** @hidden */
  1850. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1851. }
  1852. }
  1853. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression" {
  1854. import { DracoCompression } from "babylonjs/Meshes/Compression/dracoCompression";
  1855. import { Nullable } from "babylonjs/types";
  1856. import { Geometry } from "babylonjs/Meshes/geometry";
  1857. import { Mesh } from "babylonjs/Meshes/mesh";
  1858. import { IMeshPrimitive } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1859. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1860. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1861. /**
  1862. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1863. */
  1864. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1865. /**
  1866. * The name of this extension.
  1867. */
  1868. readonly name: string;
  1869. /**
  1870. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  1871. */
  1872. dracoCompression?: DracoCompression;
  1873. /**
  1874. * Defines whether this extension is enabled.
  1875. */
  1876. enabled: boolean;
  1877. private _loader;
  1878. /** @hidden */
  1879. constructor(loader: GLTFLoader);
  1880. /** @hidden */
  1881. dispose(): void;
  1882. /** @hidden */
  1883. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1884. }
  1885. }
  1886. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual" {
  1887. import { Nullable } from "babylonjs/types";
  1888. import { TransformNode } from "babylonjs/Meshes/transformNode";
  1889. import { INode } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1890. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1891. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1892. /**
  1893. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  1894. */
  1895. export class KHR_lights implements IGLTFLoaderExtension {
  1896. /**
  1897. * The name of this extension.
  1898. */
  1899. readonly name: string;
  1900. /**
  1901. * Defines whether this extension is enabled.
  1902. */
  1903. enabled: boolean;
  1904. private _loader;
  1905. private _lights?;
  1906. /** @hidden */
  1907. constructor(loader: GLTFLoader);
  1908. /** @hidden */
  1909. dispose(): void;
  1910. /** @hidden */
  1911. onLoading(): void;
  1912. /** @hidden */
  1913. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1914. }
  1915. }
  1916. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness" {
  1917. import { Nullable } from "babylonjs/types";
  1918. import { Material } from "babylonjs/Materials/material";
  1919. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1920. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1921. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1922. /**
  1923. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1924. */
  1925. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1926. /**
  1927. * The name of this extension.
  1928. */
  1929. readonly name: string;
  1930. /**
  1931. * Defines whether this extension is enabled.
  1932. */
  1933. enabled: boolean;
  1934. /**
  1935. * Defines a number that determines the order the extensions are applied.
  1936. */
  1937. order: number;
  1938. private _loader;
  1939. /** @hidden */
  1940. constructor(loader: GLTFLoader);
  1941. /** @hidden */
  1942. dispose(): void;
  1943. /** @hidden */
  1944. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1945. private _loadSpecularGlossinessPropertiesAsync;
  1946. }
  1947. }
  1948. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit" {
  1949. import { Nullable } from "babylonjs/types";
  1950. import { Material } from "babylonjs/Materials/material";
  1951. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1952. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1953. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1954. /**
  1955. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1956. */
  1957. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1958. /**
  1959. * The name of this extension.
  1960. */
  1961. readonly name: string;
  1962. /**
  1963. * Defines whether this extension is enabled.
  1964. */
  1965. enabled: boolean;
  1966. /**
  1967. * Defines a number that determines the order the extensions are applied.
  1968. */
  1969. order: number;
  1970. private _loader;
  1971. /** @hidden */
  1972. constructor(loader: GLTFLoader);
  1973. /** @hidden */
  1974. dispose(): void;
  1975. /** @hidden */
  1976. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1977. private _loadUnlitPropertiesAsync;
  1978. }
  1979. }
  1980. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_clearcoat" {
  1981. import { Nullable } from "babylonjs/types";
  1982. import { Material } from "babylonjs/Materials/material";
  1983. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  1984. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  1985. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  1986. /**
  1987. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  1988. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  1989. */
  1990. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  1991. /**
  1992. * The name of this extension.
  1993. */
  1994. readonly name: string;
  1995. /**
  1996. * Defines whether this extension is enabled.
  1997. */
  1998. enabled: boolean;
  1999. /**
  2000. * Defines a number that determines the order the extensions are applied.
  2001. */
  2002. order: number;
  2003. private _loader;
  2004. /** @hidden */
  2005. constructor(loader: GLTFLoader);
  2006. /** @hidden */
  2007. dispose(): void;
  2008. /** @hidden */
  2009. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2010. private _loadClearCoatPropertiesAsync;
  2011. }
  2012. }
  2013. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_sheen" {
  2014. import { Nullable } from "babylonjs/types";
  2015. import { Material } from "babylonjs/Materials/material";
  2016. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2017. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2018. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2019. /**
  2020. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  2021. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  2022. * !!! Experimental Extension Subject to Changes !!!
  2023. */
  2024. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  2025. /**
  2026. * The name of this extension.
  2027. */
  2028. readonly name: string;
  2029. /**
  2030. * Defines whether this extension is enabled.
  2031. */
  2032. enabled: boolean;
  2033. /**
  2034. * Defines a number that determines the order the extensions are applied.
  2035. */
  2036. order: number;
  2037. private _loader;
  2038. /** @hidden */
  2039. constructor(loader: GLTFLoader);
  2040. /** @hidden */
  2041. dispose(): void;
  2042. /** @hidden */
  2043. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2044. private _loadSheenPropertiesAsync;
  2045. }
  2046. }
  2047. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular" {
  2048. import { Nullable } from "babylonjs/types";
  2049. import { Material } from "babylonjs/Materials/material";
  2050. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2051. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2052. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2053. /**
  2054. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  2055. * !!! Experimental Extension Subject to Changes !!!
  2056. */
  2057. export class KHR_materials_specular implements IGLTFLoaderExtension {
  2058. /**
  2059. * The name of this extension.
  2060. */
  2061. readonly name: string;
  2062. /**
  2063. * Defines whether this extension is enabled.
  2064. */
  2065. enabled: boolean;
  2066. /**
  2067. * Defines a number that determines the order the extensions are applied.
  2068. */
  2069. order: number;
  2070. private _loader;
  2071. /** @hidden */
  2072. constructor(loader: GLTFLoader);
  2073. /** @hidden */
  2074. dispose(): void;
  2075. /** @hidden */
  2076. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2077. private _loadSpecularPropertiesAsync;
  2078. }
  2079. }
  2080. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_ior" {
  2081. import { Nullable } from "babylonjs/types";
  2082. import { Material } from "babylonjs/Materials/material";
  2083. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2084. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2085. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2086. /**
  2087. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  2088. * !!! Experimental Extension Subject to Changes !!!
  2089. */
  2090. export class KHR_materials_ior implements IGLTFLoaderExtension {
  2091. /**
  2092. * Default ior Value from the spec.
  2093. */
  2094. private static readonly _DEFAULT_IOR;
  2095. /**
  2096. * The name of this extension.
  2097. */
  2098. readonly name: string;
  2099. /**
  2100. * Defines whether this extension is enabled.
  2101. */
  2102. enabled: boolean;
  2103. /**
  2104. * Defines a number that determines the order the extensions are applied.
  2105. */
  2106. order: number;
  2107. private _loader;
  2108. /** @hidden */
  2109. constructor(loader: GLTFLoader);
  2110. /** @hidden */
  2111. dispose(): void;
  2112. /** @hidden */
  2113. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2114. private _loadIorPropertiesAsync;
  2115. }
  2116. }
  2117. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_variants" {
  2118. import { Nullable } from "babylonjs/types";
  2119. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2120. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2121. import { Mesh } from 'babylonjs/Meshes/mesh';
  2122. import { AbstractMesh } from 'babylonjs/Meshes/abstractMesh';
  2123. import { INode, IMeshPrimitive, IMesh } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2124. /**
  2125. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  2126. */
  2127. export class KHR_materials_variants implements IGLTFLoaderExtension {
  2128. /**
  2129. * The name of this extension.
  2130. */
  2131. readonly name: string;
  2132. /**
  2133. * Defines whether this extension is enabled.
  2134. */
  2135. enabled: boolean;
  2136. private _loader;
  2137. private _variants?;
  2138. /** @hidden */
  2139. constructor(loader: GLTFLoader);
  2140. /** @hidden */
  2141. dispose(): void;
  2142. /**
  2143. * Gets the list of available variant names for this asset.
  2144. * @param rootMesh The glTF root mesh
  2145. * @returns the list of all the variant names for this model
  2146. */
  2147. static GetAvailableVariants(rootMesh: Mesh): string[];
  2148. /**
  2149. * Gets the list of available variant names for this asset.
  2150. * @param rootMesh The glTF root mesh
  2151. * @returns the list of all the variant names for this model
  2152. */
  2153. getAvailableVariants(rootMesh: Mesh): string[];
  2154. /**
  2155. * Select a variant given a variant name or a list of variant names.
  2156. * @param rootMesh The glTF root mesh
  2157. * @param variantName The variant name(s) to select.
  2158. */
  2159. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  2160. /**
  2161. * Select a variant given a variant name or a list of variant names.
  2162. * @param rootMesh The glTF root mesh
  2163. * @param variantName The variant name(s) to select.
  2164. */
  2165. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  2166. /**
  2167. * Reset back to the original before selecting a variant.
  2168. * @param rootMesh The glTF root mesh
  2169. */
  2170. static Reset(rootMesh: Mesh): void;
  2171. /**
  2172. * Reset back to the original before selecting a variant.
  2173. * @param rootMesh The glTF root mesh
  2174. */
  2175. reset(rootMesh: Mesh): void;
  2176. /**
  2177. * Gets the last selected variant name(s) or null if original.
  2178. * @param rootMesh The glTF root mesh
  2179. * @returns The selected variant name(s).
  2180. */
  2181. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  2182. /**
  2183. * Gets the last selected variant name(s) or null if original.
  2184. * @param rootMesh The glTF root mesh
  2185. * @returns The selected variant name(s).
  2186. */
  2187. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  2188. private static _GetExtensionMetadata;
  2189. /** @hidden */
  2190. onLoading(): void;
  2191. /** @hidden */
  2192. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  2193. }
  2194. }
  2195. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_transmission" {
  2196. import { Nullable } from "babylonjs/types";
  2197. import { Material } from "babylonjs/Materials/material";
  2198. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2199. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2200. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2201. /**
  2202. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  2203. */
  2204. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  2205. /**
  2206. * The name of this extension.
  2207. */
  2208. readonly name: string;
  2209. /**
  2210. * Defines whether this extension is enabled.
  2211. */
  2212. enabled: boolean;
  2213. /**
  2214. * Defines a number that determines the order the extensions are applied.
  2215. */
  2216. order: number;
  2217. private _loader;
  2218. /** @hidden */
  2219. constructor(loader: GLTFLoader);
  2220. /** @hidden */
  2221. dispose(): void;
  2222. /** @hidden */
  2223. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2224. private _loadTransparentPropertiesAsync;
  2225. }
  2226. }
  2227. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_translucency" {
  2228. import { Nullable } from "babylonjs/types";
  2229. import { Material } from "babylonjs/Materials/material";
  2230. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2231. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2232. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2233. /**
  2234. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  2235. * !!! Experimental Extension Subject to Changes !!!
  2236. */
  2237. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  2238. /**
  2239. * The name of this extension.
  2240. */
  2241. readonly name: string;
  2242. /**
  2243. * Defines whether this extension is enabled.
  2244. */
  2245. enabled: boolean;
  2246. /**
  2247. * Defines a number that determines the order the extensions are applied.
  2248. */
  2249. order: number;
  2250. private _loader;
  2251. /** @hidden */
  2252. constructor(loader: GLTFLoader);
  2253. /** @hidden */
  2254. dispose(): void;
  2255. /** @hidden */
  2256. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2257. private _loadTranslucentPropertiesAsync;
  2258. }
  2259. }
  2260. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_quantization" {
  2261. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2262. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2263. /**
  2264. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  2265. */
  2266. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  2267. /**
  2268. * The name of this extension.
  2269. */
  2270. readonly name: string;
  2271. /**
  2272. * Defines whether this extension is enabled.
  2273. */
  2274. enabled: boolean;
  2275. /** @hidden */
  2276. constructor(loader: GLTFLoader);
  2277. /** @hidden */
  2278. dispose(): void;
  2279. }
  2280. }
  2281. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_basisu" {
  2282. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2283. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2284. import { ITexture } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  2286. import { Nullable } from "babylonjs/types";
  2287. /**
  2288. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  2289. * !!! Experimental Extension Subject to Changes !!!
  2290. */
  2291. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  2292. /** The name of this extension. */
  2293. readonly name: string;
  2294. /** Defines whether this extension is enabled. */
  2295. enabled: boolean;
  2296. private _loader;
  2297. /** @hidden */
  2298. constructor(loader: GLTFLoader);
  2299. /** @hidden */
  2300. dispose(): void;
  2301. /** @hidden */
  2302. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  2303. }
  2304. }
  2305. declare module "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform" {
  2306. import { Nullable } from "babylonjs/types";
  2307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  2308. import { ITextureInfo } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2309. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2310. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2311. /**
  2312. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  2313. */
  2314. export class KHR_texture_transform implements IGLTFLoaderExtension {
  2315. /**
  2316. * The name of this extension.
  2317. */
  2318. readonly name: string;
  2319. /**
  2320. * Defines whether this extension is enabled.
  2321. */
  2322. enabled: boolean;
  2323. private _loader;
  2324. /** @hidden */
  2325. constructor(loader: GLTFLoader);
  2326. /** @hidden */
  2327. dispose(): void;
  2328. /** @hidden */
  2329. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  2330. }
  2331. }
  2332. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter" {
  2333. import { Nullable } from "babylonjs/types";
  2334. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  2335. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2336. import { IScene, INode, IAnimation } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2337. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2338. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2339. /**
  2340. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  2341. */
  2342. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  2343. /**
  2344. * The name of this extension.
  2345. */
  2346. readonly name: string;
  2347. /**
  2348. * Defines whether this extension is enabled.
  2349. */
  2350. enabled: boolean;
  2351. private _loader;
  2352. private _clips;
  2353. private _emitters;
  2354. /** @hidden */
  2355. constructor(loader: GLTFLoader);
  2356. /** @hidden */
  2357. dispose(): void;
  2358. /** @hidden */
  2359. onLoading(): void;
  2360. /** @hidden */
  2361. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  2362. /** @hidden */
  2363. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2364. /** @hidden */
  2365. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  2366. private _loadClipAsync;
  2367. private _loadEmitterAsync;
  2368. private _getEventAction;
  2369. private _loadAnimationEventAsync;
  2370. }
  2371. }
  2372. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod" {
  2373. import { Nullable } from "babylonjs/types";
  2374. import { Observable } from "babylonjs/Misc/observable";
  2375. import { Material } from "babylonjs/Materials/material";
  2376. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2377. import { Mesh } from "babylonjs/Meshes/mesh";
  2378. import { INode, IMaterial, IBuffer, IScene } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2379. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2380. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2381. import { IProperty } from 'babylonjs-gltf2interface';
  2382. /**
  2383. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  2384. */
  2385. export class MSFT_lod implements IGLTFLoaderExtension {
  2386. /**
  2387. * The name of this extension.
  2388. */
  2389. readonly name: string;
  2390. /**
  2391. * Defines whether this extension is enabled.
  2392. */
  2393. enabled: boolean;
  2394. /**
  2395. * Defines a number that determines the order the extensions are applied.
  2396. */
  2397. order: number;
  2398. /**
  2399. * Maximum number of LODs to load, starting from the lowest LOD.
  2400. */
  2401. maxLODsToLoad: number;
  2402. /**
  2403. * Observable raised when all node LODs of one level are loaded.
  2404. * The event data is the index of the loaded LOD starting from zero.
  2405. * Dispose the loader to cancel the loading of the next level of LODs.
  2406. */
  2407. onNodeLODsLoadedObservable: Observable<number>;
  2408. /**
  2409. * Observable raised when all material LODs of one level are loaded.
  2410. * The event data is the index of the loaded LOD starting from zero.
  2411. * Dispose the loader to cancel the loading of the next level of LODs.
  2412. */
  2413. onMaterialLODsLoadedObservable: Observable<number>;
  2414. private _loader;
  2415. private _bufferLODs;
  2416. private _nodeIndexLOD;
  2417. private _nodeSignalLODs;
  2418. private _nodePromiseLODs;
  2419. private _nodeBufferLODs;
  2420. private _materialIndexLOD;
  2421. private _materialSignalLODs;
  2422. private _materialPromiseLODs;
  2423. private _materialBufferLODs;
  2424. /** @hidden */
  2425. constructor(loader: GLTFLoader);
  2426. /** @hidden */
  2427. dispose(): void;
  2428. /** @hidden */
  2429. onReady(): void;
  2430. /** @hidden */
  2431. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  2432. /** @hidden */
  2433. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2434. /** @hidden */
  2435. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  2436. /** @hidden */
  2437. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  2438. /** @hidden */
  2439. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  2440. private _loadBufferLOD;
  2441. /**
  2442. * Gets an array of LOD properties from lowest to highest.
  2443. */
  2444. private _getLODs;
  2445. private _disposeTransformNode;
  2446. private _disposeMaterials;
  2447. }
  2448. }
  2449. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh" {
  2450. import { Nullable } from "babylonjs/types";
  2451. import { Material } from "babylonjs/Materials/material";
  2452. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2453. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2454. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2455. /** @hidden */
  2456. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  2457. readonly name: string;
  2458. enabled: boolean;
  2459. private _loader;
  2460. constructor(loader: GLTFLoader);
  2461. dispose(): void;
  2462. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2463. }
  2464. }
  2465. declare module "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors" {
  2466. import { Nullable } from "babylonjs/types";
  2467. import { Material } from "babylonjs/Materials/material";
  2468. import { IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2469. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2470. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2471. /** @hidden */
  2472. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  2473. readonly name: string;
  2474. enabled: boolean;
  2475. private _loader;
  2476. constructor(loader: GLTFLoader);
  2477. dispose(): void;
  2478. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  2479. }
  2480. }
  2481. declare module "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata" {
  2482. import { Nullable } from "babylonjs/types";
  2483. import { TransformNode } from "babylonjs/Meshes/transformNode";
  2484. import { Camera } from "babylonjs/Cameras/camera";
  2485. import { INode, ICamera, IMaterial } from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2486. import { IGLTFLoaderExtension } from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2487. import { GLTFLoader } from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2488. import { Material } from "babylonjs/Materials/material";
  2489. /**
  2490. * Store glTF extras (if present) in BJS objects' metadata
  2491. */
  2492. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  2493. /**
  2494. * The name of this extension.
  2495. */
  2496. readonly name: string;
  2497. /**
  2498. * Defines whether this extension is enabled.
  2499. */
  2500. enabled: boolean;
  2501. private _loader;
  2502. private _assignExtras;
  2503. /** @hidden */
  2504. constructor(loader: GLTFLoader);
  2505. /** @hidden */
  2506. dispose(): void;
  2507. /** @hidden */
  2508. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  2509. /** @hidden */
  2510. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  2511. /** @hidden */
  2512. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  2513. }
  2514. }
  2515. declare module "babylonjs-loaders/glTF/2.0/Extensions/index" {
  2516. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_lights_image_based";
  2517. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_mesh_gpu_instancing";
  2518. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_meshopt_compression";
  2519. export * from "babylonjs-loaders/glTF/2.0/Extensions/EXT_texture_webp";
  2520. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_draco_mesh_compression";
  2521. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_lights_punctual";
  2522. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness";
  2523. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_unlit";
  2524. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_clearcoat";
  2525. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_sheen";
  2526. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_specular";
  2527. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_ior";
  2528. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_variants";
  2529. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_transmission";
  2530. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_materials_translucency";
  2531. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_mesh_quantization";
  2532. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_basisu";
  2533. export * from "babylonjs-loaders/glTF/2.0/Extensions/KHR_texture_transform";
  2534. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_audio_emitter";
  2535. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_lod";
  2536. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_minecraftMesh";
  2537. export * from "babylonjs-loaders/glTF/2.0/Extensions/MSFT_sRGBFactors";
  2538. export * from "babylonjs-loaders/glTF/2.0/Extensions/ExtrasAsMetadata";
  2539. }
  2540. declare module "babylonjs-loaders/glTF/2.0/index" {
  2541. export * from "babylonjs-loaders/glTF/2.0/glTFLoader";
  2542. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderExtension";
  2543. export * from "babylonjs-loaders/glTF/2.0/glTFLoaderInterfaces";
  2544. export * from "babylonjs-loaders/glTF/2.0/Extensions/index";
  2545. }
  2546. declare module "babylonjs-loaders/glTF/index" {
  2547. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2548. export * from "babylonjs-loaders/glTF/glTFValidation";
  2549. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2550. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2551. export { GLTF1, GLTF2 };
  2552. }
  2553. declare module "babylonjs-loaders/OBJ/mtlFileLoader" {
  2554. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  2555. import { Scene } from "babylonjs/scene";
  2556. /**
  2557. * Class reading and parsing the MTL file bundled with the obj file.
  2558. */
  2559. export class MTLFileLoader {
  2560. /**
  2561. * Invert Y-Axis of referenced textures on load
  2562. */
  2563. static INVERT_TEXTURE_Y: boolean;
  2564. /**
  2565. * All material loaded from the mtl will be set here
  2566. */
  2567. materials: StandardMaterial[];
  2568. /**
  2569. * This function will read the mtl file and create each material described inside
  2570. * This function could be improve by adding :
  2571. * -some component missing (Ni, Tf...)
  2572. * -including the specific options available
  2573. *
  2574. * @param scene defines the scene the material will be created in
  2575. * @param data defines the mtl data to parse
  2576. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  2577. * @param forAssetContainer defines if the material should be registered in the scene
  2578. */
  2579. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  2580. /**
  2581. * Gets the texture for the material.
  2582. *
  2583. * If the material is imported from input file,
  2584. * We sanitize the url to ensure it takes the textre from aside the material.
  2585. *
  2586. * @param rootUrl The root url to load from
  2587. * @param value The value stored in the mtl
  2588. * @return The Texture
  2589. */
  2590. private static _getTexture;
  2591. }
  2592. }
  2593. declare module "babylonjs-loaders/OBJ/objFileLoader" {
  2594. import { Vector2 } from "babylonjs/Maths/math.vector";
  2595. import { ISceneLoaderPluginAsync, ISceneLoaderProgressEvent, ISceneLoaderPluginFactory, ISceneLoaderPlugin, ISceneLoaderAsyncResult } from "babylonjs/Loading/sceneLoader";
  2596. import { AssetContainer } from "babylonjs/assetContainer";
  2597. import { Scene } from "babylonjs/scene";
  2598. /**
  2599. * Options for loading OBJ/MTL files
  2600. */
  2601. type MeshLoadOptions = {
  2602. /**
  2603. * Defines if UVs are optimized by default during load.
  2604. */
  2605. OptimizeWithUV: boolean;
  2606. /**
  2607. * Defines custom scaling of UV coordinates of loaded meshes.
  2608. */
  2609. UVScaling: Vector2;
  2610. /**
  2611. * Invert model on y-axis (does a model scaling inversion)
  2612. */
  2613. InvertY: boolean;
  2614. /**
  2615. * Invert Y-Axis of referenced textures on load
  2616. */
  2617. InvertTextureY: boolean;
  2618. /**
  2619. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2620. */
  2621. ImportVertexColors: boolean;
  2622. /**
  2623. * Compute the normals for the model, even if normals are present in the file.
  2624. */
  2625. ComputeNormals: boolean;
  2626. /**
  2627. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2628. */
  2629. SkipMaterials: boolean;
  2630. /**
  2631. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2632. */
  2633. MaterialLoadingFailsSilently: boolean;
  2634. };
  2635. /**
  2636. * OBJ file type loader.
  2637. * This is a babylon scene loader plugin.
  2638. */
  2639. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2640. /**
  2641. * Defines if UVs are optimized by default during load.
  2642. */
  2643. static OPTIMIZE_WITH_UV: boolean;
  2644. /**
  2645. * Invert model on y-axis (does a model scaling inversion)
  2646. */
  2647. static INVERT_Y: boolean;
  2648. /**
  2649. * Invert Y-Axis of referenced textures on load
  2650. */
  2651. static get INVERT_TEXTURE_Y(): boolean;
  2652. static set INVERT_TEXTURE_Y(value: boolean);
  2653. /**
  2654. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2655. */
  2656. static IMPORT_VERTEX_COLORS: boolean;
  2657. /**
  2658. * Compute the normals for the model, even if normals are present in the file.
  2659. */
  2660. static COMPUTE_NORMALS: boolean;
  2661. /**
  2662. * Defines custom scaling of UV coordinates of loaded meshes.
  2663. */
  2664. static UV_SCALING: Vector2;
  2665. /**
  2666. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2667. */
  2668. static SKIP_MATERIALS: boolean;
  2669. /**
  2670. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2671. *
  2672. * Defaults to true for backwards compatibility.
  2673. */
  2674. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2675. /**
  2676. * Defines the name of the plugin.
  2677. */
  2678. name: string;
  2679. /**
  2680. * Defines the extension the plugin is able to load.
  2681. */
  2682. extensions: string;
  2683. /** @hidden */
  2684. obj: RegExp;
  2685. /** @hidden */
  2686. group: RegExp;
  2687. /** @hidden */
  2688. mtllib: RegExp;
  2689. /** @hidden */
  2690. usemtl: RegExp;
  2691. /** @hidden */
  2692. smooth: RegExp;
  2693. /** @hidden */
  2694. vertexPattern: RegExp;
  2695. /** @hidden */
  2696. normalPattern: RegExp;
  2697. /** @hidden */
  2698. uvPattern: RegExp;
  2699. /** @hidden */
  2700. facePattern1: RegExp;
  2701. /** @hidden */
  2702. facePattern2: RegExp;
  2703. /** @hidden */
  2704. facePattern3: RegExp;
  2705. /** @hidden */
  2706. facePattern4: RegExp;
  2707. /** @hidden */
  2708. facePattern5: RegExp;
  2709. private _forAssetContainer;
  2710. private _meshLoadOptions;
  2711. /**
  2712. * Creates loader for .OBJ files
  2713. *
  2714. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2715. */
  2716. constructor(meshLoadOptions?: MeshLoadOptions);
  2717. private static get currentMeshLoadOptions();
  2718. /**
  2719. * Calls synchronously the MTL file attached to this obj.
  2720. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2721. * Without this function materials are not displayed in the first frame (but displayed after).
  2722. * In consequence it is impossible to get material information in your HTML file
  2723. *
  2724. * @param url The URL of the MTL file
  2725. * @param rootUrl
  2726. * @param onSuccess Callback function to be called when the MTL file is loaded
  2727. * @private
  2728. */
  2729. private _loadMTL;
  2730. /**
  2731. * Instantiates a OBJ file loader plugin.
  2732. * @returns the created plugin
  2733. */
  2734. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2735. /**
  2736. * If the data string can be loaded directly.
  2737. *
  2738. * @param data string containing the file data
  2739. * @returns if the data can be loaded directly
  2740. */
  2741. canDirectLoad(data: string): boolean;
  2742. /**
  2743. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2744. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2745. * @param scene the scene the meshes should be added to
  2746. * @param data the OBJ data to load
  2747. * @param rootUrl root url to load from
  2748. * @param onProgress event that fires when loading progress has occured
  2749. * @param fileName Defines the name of the file to load
  2750. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2751. */
  2752. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  2753. /**
  2754. * Imports all objects from the loaded OBJ data and adds them to the scene
  2755. * @param scene the scene the objects should be added to
  2756. * @param data the OBJ data to load
  2757. * @param rootUrl root url to load from
  2758. * @param onProgress event that fires when loading progress has occured
  2759. * @param fileName Defines the name of the file to load
  2760. * @returns a promise which completes when objects have been loaded to the scene
  2761. */
  2762. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2763. /**
  2764. * Load into an asset container.
  2765. * @param scene The scene to load into
  2766. * @param data The data to import
  2767. * @param rootUrl The root url for scene and resources
  2768. * @param onProgress The callback when the load progresses
  2769. * @param fileName Defines the name of the file to load
  2770. * @returns The loaded asset container
  2771. */
  2772. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2773. /**
  2774. * Read the OBJ file and create an Array of meshes.
  2775. * Each mesh contains all information given by the OBJ and the MTL file.
  2776. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2777. *
  2778. * @param meshesNames
  2779. * @param scene Scene The scene where are displayed the data
  2780. * @param data String The content of the obj file
  2781. * @param rootUrl String The path to the folder
  2782. * @returns Array<AbstractMesh>
  2783. * @private
  2784. */
  2785. private _parseSolid;
  2786. }
  2787. }
  2788. declare module "babylonjs-loaders/OBJ/index" {
  2789. export * from "babylonjs-loaders/OBJ/mtlFileLoader";
  2790. export * from "babylonjs-loaders/OBJ/objFileLoader";
  2791. }
  2792. declare module "babylonjs-loaders/STL/stlFileLoader" {
  2793. import { Nullable } from "babylonjs/types";
  2794. import { Skeleton } from "babylonjs/Bones/skeleton";
  2795. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  2796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  2797. import { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from "babylonjs/Loading/sceneLoader";
  2798. import { AssetContainer } from "babylonjs/assetContainer";
  2799. import { Scene } from "babylonjs/scene";
  2800. /**
  2801. * STL file type loader.
  2802. * This is a babylon scene loader plugin.
  2803. */
  2804. export class STLFileLoader implements ISceneLoaderPlugin {
  2805. /** @hidden */
  2806. solidPattern: RegExp;
  2807. /** @hidden */
  2808. facetsPattern: RegExp;
  2809. /** @hidden */
  2810. normalPattern: RegExp;
  2811. /** @hidden */
  2812. vertexPattern: RegExp;
  2813. /**
  2814. * Defines the name of the plugin.
  2815. */
  2816. name: string;
  2817. /**
  2818. * Defines the extensions the stl loader is able to load.
  2819. * force data to come in as an ArrayBuffer
  2820. * we'll convert to string if it looks like it's an ASCII .stl
  2821. */
  2822. extensions: ISceneLoaderPluginExtensions;
  2823. /**
  2824. * Import meshes into a scene.
  2825. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2826. * @param scene The scene to import into
  2827. * @param data The data to import
  2828. * @param rootUrl The root url for scene and resources
  2829. * @param meshes The meshes array to import into
  2830. * @param particleSystems The particle systems array to import into
  2831. * @param skeletons The skeletons array to import into
  2832. * @param onError The callback when import fails
  2833. * @returns True if successful or false otherwise
  2834. */
  2835. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2836. /**
  2837. * Load into a scene.
  2838. * @param scene The scene to load into
  2839. * @param data The data to import
  2840. * @param rootUrl The root url for scene and resources
  2841. * @param onError The callback when import fails
  2842. * @returns true if successful or false otherwise
  2843. */
  2844. load(scene: Scene, data: any, rootUrl: string): boolean;
  2845. /**
  2846. * Load into an asset container.
  2847. * @param scene The scene to load into
  2848. * @param data The data to import
  2849. * @param rootUrl The root url for scene and resources
  2850. * @param onError The callback when import fails
  2851. * @returns The loaded asset container
  2852. */
  2853. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2854. private _isBinary;
  2855. private _parseBinary;
  2856. private _parseASCII;
  2857. }
  2858. }
  2859. declare module "babylonjs-loaders/STL/index" {
  2860. export * from "babylonjs-loaders/STL/stlFileLoader";
  2861. }
  2862. declare module "babylonjs-loaders/index" {
  2863. export * from "babylonjs-loaders/glTF/index";
  2864. export * from "babylonjs-loaders/OBJ/index";
  2865. export * from "babylonjs-loaders/STL/index";
  2866. }
  2867. declare module "babylonjs-loaders/legacy/legacy-glTF" {
  2868. export * from "babylonjs-loaders/glTF/glTFFileLoader";
  2869. export * from "babylonjs-loaders/glTF/glTFValidation";
  2870. }
  2871. declare module "babylonjs-loaders/legacy/legacy-glTF1" {
  2872. import * as GLTF1 from "babylonjs-loaders/glTF/1.0/index";
  2873. export { GLTF1 };
  2874. }
  2875. declare module "babylonjs-loaders/legacy/legacy-glTF1FileLoader" {
  2876. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2877. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2878. }
  2879. declare module "babylonjs-loaders/legacy/legacy-glTF2" {
  2880. import * as GLTF2 from "babylonjs-loaders/glTF/2.0/index";
  2881. export { GLTF2 };
  2882. }
  2883. declare module "babylonjs-loaders/legacy/legacy-glTF2FileLoader" {
  2884. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2885. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2886. }
  2887. declare module "babylonjs-loaders/legacy/legacy-glTFFileLoader" {
  2888. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2889. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2890. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2891. }
  2892. declare module "babylonjs-loaders/legacy/legacy-objFileLoader" {
  2893. export * from "babylonjs-loaders/OBJ/index";
  2894. }
  2895. declare module "babylonjs-loaders/legacy/legacy-stlFileLoader" {
  2896. export * from "babylonjs-loaders/STL/index";
  2897. }
  2898. declare module "babylonjs-loaders/legacy/legacy" {
  2899. import "babylonjs-loaders/index";
  2900. export * from "babylonjs-loaders/legacy/legacy-glTF";
  2901. export * from "babylonjs-loaders/legacy/legacy-glTF1";
  2902. export * from "babylonjs-loaders/legacy/legacy-glTF2";
  2903. export * from "babylonjs-loaders/legacy/legacy-objFileLoader";
  2904. export * from "babylonjs-loaders/legacy/legacy-stlFileLoader";
  2905. }
  2906. declare module "babylonjs-loaders" {
  2907. export * from "babylonjs-loaders/legacy/legacy";
  2908. }
  2909. declare module BABYLON {
  2910. /**
  2911. * Configuration for glTF validation
  2912. */
  2913. export interface IGLTFValidationConfiguration {
  2914. /**
  2915. * The url of the glTF validator.
  2916. */
  2917. url: string;
  2918. }
  2919. /**
  2920. * glTF validation
  2921. */
  2922. export class GLTFValidation {
  2923. /**
  2924. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  2925. */
  2926. static Configuration: IGLTFValidationConfiguration;
  2927. private static _LoadScriptPromise;
  2928. /**
  2929. * Validate a glTF asset using the glTF-Validator.
  2930. * @param data The JSON of a glTF or the array buffer of a binary glTF
  2931. * @param rootUrl The root url for the glTF
  2932. * @param fileName The file name for the glTF
  2933. * @param getExternalResource The callback to get external resources for the glTF validator
  2934. * @returns A promise that resolves with the glTF validation results once complete
  2935. */
  2936. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  2937. }
  2938. }
  2939. declare module BABYLON {
  2940. /**
  2941. * Mode that determines the coordinate system to use.
  2942. */
  2943. export enum GLTFLoaderCoordinateSystemMode {
  2944. /**
  2945. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  2946. */
  2947. AUTO = 0,
  2948. /**
  2949. * Sets the useRightHandedSystem flag on the scene.
  2950. */
  2951. FORCE_RIGHT_HANDED = 1
  2952. }
  2953. /**
  2954. * Mode that determines what animations will start.
  2955. */
  2956. export enum GLTFLoaderAnimationStartMode {
  2957. /**
  2958. * No animation will start.
  2959. */
  2960. NONE = 0,
  2961. /**
  2962. * The first animation will start.
  2963. */
  2964. FIRST = 1,
  2965. /**
  2966. * All animations will start.
  2967. */
  2968. ALL = 2
  2969. }
  2970. /**
  2971. * Interface that contains the data for the glTF asset.
  2972. */
  2973. export interface IGLTFLoaderData {
  2974. /**
  2975. * The object that represents the glTF JSON.
  2976. */
  2977. json: Object;
  2978. /**
  2979. * The BIN chunk of a binary glTF.
  2980. */
  2981. bin: Nullable<IDataBuffer>;
  2982. }
  2983. /**
  2984. * Interface for extending the loader.
  2985. */
  2986. export interface IGLTFLoaderExtension {
  2987. /**
  2988. * The name of this extension.
  2989. */
  2990. readonly name: string;
  2991. /**
  2992. * Defines whether this extension is enabled.
  2993. */
  2994. enabled: boolean;
  2995. /**
  2996. * Defines the order of this extension.
  2997. * The loader sorts the extensions using these values when loading.
  2998. */
  2999. order?: number;
  3000. }
  3001. /**
  3002. * Loader state.
  3003. */
  3004. export enum GLTFLoaderState {
  3005. /**
  3006. * The asset is loading.
  3007. */
  3008. LOADING = 0,
  3009. /**
  3010. * The asset is ready for rendering.
  3011. */
  3012. READY = 1,
  3013. /**
  3014. * The asset is completely loaded.
  3015. */
  3016. COMPLETE = 2
  3017. }
  3018. /** @hidden */
  3019. export interface IGLTFLoader extends IDisposable {
  3020. readonly state: Nullable<GLTFLoaderState>;
  3021. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  3022. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  3023. }
  3024. /**
  3025. * File loader for loading glTF files into a scene.
  3026. */
  3027. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  3028. /** @hidden */
  3029. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  3030. /** @hidden */
  3031. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  3032. /**
  3033. * Raised when the asset has been parsed
  3034. */
  3035. onParsedObservable: Observable<IGLTFLoaderData>;
  3036. private _onParsedObserver;
  3037. /**
  3038. * Raised when the asset has been parsed
  3039. */
  3040. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  3041. /**
  3042. * 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.
  3043. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  3044. * Defaults to true.
  3045. * @hidden
  3046. */
  3047. static IncrementalLoading: boolean;
  3048. /**
  3049. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  3050. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  3051. * @hidden
  3052. */
  3053. static HomogeneousCoordinates: boolean;
  3054. /**
  3055. * The coordinate system mode. Defaults to AUTO.
  3056. */
  3057. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  3058. /**
  3059. * The animation start mode. Defaults to FIRST.
  3060. */
  3061. animationStartMode: GLTFLoaderAnimationStartMode;
  3062. /**
  3063. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  3064. */
  3065. compileMaterials: boolean;
  3066. /**
  3067. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  3068. */
  3069. useClipPlane: boolean;
  3070. /**
  3071. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  3072. */
  3073. compileShadowGenerators: boolean;
  3074. /**
  3075. * Defines if the Alpha blended materials are only applied as coverage.
  3076. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  3077. * If true, no extra effects are applied to transparent pixels.
  3078. */
  3079. transparencyAsCoverage: boolean;
  3080. /**
  3081. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  3082. * Enabling will disable offline support and glTF validator.
  3083. * Defaults to false.
  3084. */
  3085. useRangeRequests: boolean;
  3086. /**
  3087. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  3088. */
  3089. createInstances: boolean;
  3090. /**
  3091. * 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.
  3092. */
  3093. alwaysComputeBoundingBox: boolean;
  3094. /**
  3095. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  3096. */
  3097. loadAllMaterials: boolean;
  3098. /**
  3099. * Function called before loading a url referenced by the asset.
  3100. */
  3101. preprocessUrlAsync: (url: string) => Promise<string>;
  3102. /**
  3103. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  3104. * 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, ...)
  3105. */
  3106. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  3107. private _onMeshLoadedObserver;
  3108. /**
  3109. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  3110. * 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, ...)
  3111. */
  3112. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  3113. /**
  3114. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  3115. */
  3116. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  3117. private _onTextureLoadedObserver;
  3118. /**
  3119. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  3120. */
  3121. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  3122. /**
  3123. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  3124. */
  3125. readonly onMaterialLoadedObservable: Observable<Material>;
  3126. private _onMaterialLoadedObserver;
  3127. /**
  3128. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  3129. */
  3130. set onMaterialLoaded(callback: (material: Material) => void);
  3131. /**
  3132. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  3133. */
  3134. readonly onCameraLoadedObservable: Observable<Camera>;
  3135. private _onCameraLoadedObserver;
  3136. /**
  3137. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  3138. */
  3139. set onCameraLoaded(callback: (camera: Camera) => void);
  3140. /**
  3141. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  3142. * For assets with LODs, raised when all of the LODs are complete.
  3143. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  3144. */
  3145. readonly onCompleteObservable: Observable<void>;
  3146. private _onCompleteObserver;
  3147. /**
  3148. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  3149. * For assets with LODs, raised when all of the LODs are complete.
  3150. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  3151. */
  3152. set onComplete(callback: () => void);
  3153. /**
  3154. * Observable raised when an error occurs.
  3155. */
  3156. readonly onErrorObservable: Observable<any>;
  3157. private _onErrorObserver;
  3158. /**
  3159. * Callback raised when an error occurs.
  3160. */
  3161. set onError(callback: (reason: any) => void);
  3162. /**
  3163. * Observable raised after the loader is disposed.
  3164. */
  3165. readonly onDisposeObservable: Observable<void>;
  3166. private _onDisposeObserver;
  3167. /**
  3168. * Callback raised after the loader is disposed.
  3169. */
  3170. set onDispose(callback: () => void);
  3171. /**
  3172. * Observable raised after a loader extension is created.
  3173. * Set additional options for a loader extension in this event.
  3174. */
  3175. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  3176. private _onExtensionLoadedObserver;
  3177. /**
  3178. * Callback raised after a loader extension is created.
  3179. */
  3180. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  3181. /**
  3182. * Defines if the loader logging is enabled.
  3183. */
  3184. get loggingEnabled(): boolean;
  3185. set loggingEnabled(value: boolean);
  3186. /**
  3187. * Defines if the loader should capture performance counters.
  3188. */
  3189. get capturePerformanceCounters(): boolean;
  3190. set capturePerformanceCounters(value: boolean);
  3191. /**
  3192. * Defines if the loader should validate the asset.
  3193. */
  3194. validate: boolean;
  3195. /**
  3196. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  3197. */
  3198. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  3199. private _onValidatedObserver;
  3200. /**
  3201. * Callback raised after a loader extension is created.
  3202. */
  3203. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  3204. private _loader;
  3205. private _progressCallback?;
  3206. private _requests;
  3207. private static magicBase64Encoded;
  3208. /**
  3209. * Name of the loader ("gltf")
  3210. */
  3211. name: string;
  3212. /** @hidden */
  3213. extensions: ISceneLoaderPluginExtensions;
  3214. /**
  3215. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  3216. */
  3217. dispose(): void;
  3218. /** @hidden */
  3219. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  3220. /** @hidden */
  3221. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  3222. /** @hidden */
  3223. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  3224. /** @hidden */
  3225. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  3226. /** @hidden */
  3227. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  3228. /** @hidden */
  3229. canDirectLoad(data: string): boolean;
  3230. /** @hidden */
  3231. directLoad(scene: Scene, data: string): Promise<any>;
  3232. /**
  3233. * The callback that allows custom handling of the root url based on the response url.
  3234. * @param rootUrl the original root url
  3235. * @param responseURL the response url if available
  3236. * @returns the new root url
  3237. */
  3238. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  3239. /** @hidden */
  3240. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  3241. /**
  3242. * The loader state or null if the loader is not active.
  3243. */
  3244. get loaderState(): Nullable<GLTFLoaderState>;
  3245. /**
  3246. * Returns a promise that resolves when the asset is completely loaded.
  3247. * @returns a promise that resolves when the asset is completely loaded.
  3248. */
  3249. whenCompleteAsync(): Promise<void>;
  3250. /** @hidden */
  3251. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  3252. /** @hidden */
  3253. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  3254. private _onProgress;
  3255. private _validate;
  3256. private _getLoader;
  3257. private _parseJson;
  3258. private _unpackBinaryAsync;
  3259. private _unpackBinaryV1Async;
  3260. private _unpackBinaryV2Async;
  3261. private static _parseVersion;
  3262. private static _compareVersion;
  3263. private static readonly _logSpaces;
  3264. private _logIndentLevel;
  3265. private _loggingEnabled;
  3266. /** @hidden */
  3267. _log: (message: string) => void;
  3268. /** @hidden */
  3269. _logOpen(message: string): void;
  3270. /** @hidden */
  3271. _logClose(): void;
  3272. private _logEnabled;
  3273. private _logDisabled;
  3274. private _capturePerformanceCounters;
  3275. /** @hidden */
  3276. _startPerformanceCounter: (counterName: string) => void;
  3277. /** @hidden */
  3278. _endPerformanceCounter: (counterName: string) => void;
  3279. private _startPerformanceCounterEnabled;
  3280. private _startPerformanceCounterDisabled;
  3281. private _endPerformanceCounterEnabled;
  3282. private _endPerformanceCounterDisabled;
  3283. }
  3284. }
  3285. declare module BABYLON.GLTF1 {
  3286. /**
  3287. * Enums
  3288. * @hidden
  3289. */
  3290. export enum EComponentType {
  3291. BYTE = 5120,
  3292. UNSIGNED_BYTE = 5121,
  3293. SHORT = 5122,
  3294. UNSIGNED_SHORT = 5123,
  3295. FLOAT = 5126
  3296. }
  3297. /** @hidden */
  3298. export enum EShaderType {
  3299. FRAGMENT = 35632,
  3300. VERTEX = 35633
  3301. }
  3302. /** @hidden */
  3303. export enum EParameterType {
  3304. BYTE = 5120,
  3305. UNSIGNED_BYTE = 5121,
  3306. SHORT = 5122,
  3307. UNSIGNED_SHORT = 5123,
  3308. INT = 5124,
  3309. UNSIGNED_INT = 5125,
  3310. FLOAT = 5126,
  3311. FLOAT_VEC2 = 35664,
  3312. FLOAT_VEC3 = 35665,
  3313. FLOAT_VEC4 = 35666,
  3314. INT_VEC2 = 35667,
  3315. INT_VEC3 = 35668,
  3316. INT_VEC4 = 35669,
  3317. BOOL = 35670,
  3318. BOOL_VEC2 = 35671,
  3319. BOOL_VEC3 = 35672,
  3320. BOOL_VEC4 = 35673,
  3321. FLOAT_MAT2 = 35674,
  3322. FLOAT_MAT3 = 35675,
  3323. FLOAT_MAT4 = 35676,
  3324. SAMPLER_2D = 35678
  3325. }
  3326. /** @hidden */
  3327. export enum ETextureWrapMode {
  3328. CLAMP_TO_EDGE = 33071,
  3329. MIRRORED_REPEAT = 33648,
  3330. REPEAT = 10497
  3331. }
  3332. /** @hidden */
  3333. export enum ETextureFilterType {
  3334. NEAREST = 9728,
  3335. LINEAR = 9728,
  3336. NEAREST_MIPMAP_NEAREST = 9984,
  3337. LINEAR_MIPMAP_NEAREST = 9985,
  3338. NEAREST_MIPMAP_LINEAR = 9986,
  3339. LINEAR_MIPMAP_LINEAR = 9987
  3340. }
  3341. /** @hidden */
  3342. export enum ETextureFormat {
  3343. ALPHA = 6406,
  3344. RGB = 6407,
  3345. RGBA = 6408,
  3346. LUMINANCE = 6409,
  3347. LUMINANCE_ALPHA = 6410
  3348. }
  3349. /** @hidden */
  3350. export enum ECullingType {
  3351. FRONT = 1028,
  3352. BACK = 1029,
  3353. FRONT_AND_BACK = 1032
  3354. }
  3355. /** @hidden */
  3356. export enum EBlendingFunction {
  3357. ZERO = 0,
  3358. ONE = 1,
  3359. SRC_COLOR = 768,
  3360. ONE_MINUS_SRC_COLOR = 769,
  3361. DST_COLOR = 774,
  3362. ONE_MINUS_DST_COLOR = 775,
  3363. SRC_ALPHA = 770,
  3364. ONE_MINUS_SRC_ALPHA = 771,
  3365. DST_ALPHA = 772,
  3366. ONE_MINUS_DST_ALPHA = 773,
  3367. CONSTANT_COLOR = 32769,
  3368. ONE_MINUS_CONSTANT_COLOR = 32770,
  3369. CONSTANT_ALPHA = 32771,
  3370. ONE_MINUS_CONSTANT_ALPHA = 32772,
  3371. SRC_ALPHA_SATURATE = 776
  3372. }
  3373. /** @hidden */
  3374. export interface IGLTFProperty {
  3375. extensions?: {
  3376. [key: string]: any;
  3377. };
  3378. extras?: Object;
  3379. }
  3380. /** @hidden */
  3381. export interface IGLTFChildRootProperty extends IGLTFProperty {
  3382. name?: string;
  3383. }
  3384. /** @hidden */
  3385. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  3386. bufferView: string;
  3387. byteOffset: number;
  3388. byteStride: number;
  3389. count: number;
  3390. type: string;
  3391. componentType: EComponentType;
  3392. max?: number[];
  3393. min?: number[];
  3394. name?: string;
  3395. }
  3396. /** @hidden */
  3397. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  3398. buffer: string;
  3399. byteOffset: number;
  3400. byteLength: number;
  3401. byteStride: number;
  3402. target?: number;
  3403. }
  3404. /** @hidden */
  3405. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  3406. uri: string;
  3407. byteLength?: number;
  3408. type?: string;
  3409. }
  3410. /** @hidden */
  3411. export interface IGLTFShader extends IGLTFChildRootProperty {
  3412. uri: string;
  3413. type: EShaderType;
  3414. }
  3415. /** @hidden */
  3416. export interface IGLTFProgram extends IGLTFChildRootProperty {
  3417. attributes: string[];
  3418. fragmentShader: string;
  3419. vertexShader: string;
  3420. }
  3421. /** @hidden */
  3422. export interface IGLTFTechniqueParameter {
  3423. type: number;
  3424. count?: number;
  3425. semantic?: string;
  3426. node?: string;
  3427. value?: number | boolean | string | Array<any>;
  3428. source?: string;
  3429. babylonValue?: any;
  3430. }
  3431. /** @hidden */
  3432. export interface IGLTFTechniqueCommonProfile {
  3433. lightingModel: string;
  3434. texcoordBindings: Object;
  3435. parameters?: Array<any>;
  3436. }
  3437. /** @hidden */
  3438. export interface IGLTFTechniqueStatesFunctions {
  3439. blendColor?: number[];
  3440. blendEquationSeparate?: number[];
  3441. blendFuncSeparate?: number[];
  3442. colorMask: boolean[];
  3443. cullFace: number[];
  3444. }
  3445. /** @hidden */
  3446. export interface IGLTFTechniqueStates {
  3447. enable: number[];
  3448. functions: IGLTFTechniqueStatesFunctions;
  3449. }
  3450. /** @hidden */
  3451. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  3452. parameters: {
  3453. [key: string]: IGLTFTechniqueParameter;
  3454. };
  3455. program: string;
  3456. attributes: {
  3457. [key: string]: string;
  3458. };
  3459. uniforms: {
  3460. [key: string]: string;
  3461. };
  3462. states: IGLTFTechniqueStates;
  3463. }
  3464. /** @hidden */
  3465. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  3466. technique?: string;
  3467. values: string[];
  3468. }
  3469. /** @hidden */
  3470. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  3471. attributes: {
  3472. [key: string]: string;
  3473. };
  3474. indices: string;
  3475. material: string;
  3476. mode?: number;
  3477. }
  3478. /** @hidden */
  3479. export interface IGLTFMesh extends IGLTFChildRootProperty {
  3480. primitives: IGLTFMeshPrimitive[];
  3481. }
  3482. /** @hidden */
  3483. export interface IGLTFImage extends IGLTFChildRootProperty {
  3484. uri: string;
  3485. }
  3486. /** @hidden */
  3487. export interface IGLTFSampler extends IGLTFChildRootProperty {
  3488. magFilter?: number;
  3489. minFilter?: number;
  3490. wrapS?: number;
  3491. wrapT?: number;
  3492. }
  3493. /** @hidden */
  3494. export interface IGLTFTexture extends IGLTFChildRootProperty {
  3495. sampler: string;
  3496. source: string;
  3497. format?: ETextureFormat;
  3498. internalFormat?: ETextureFormat;
  3499. target?: number;
  3500. type?: number;
  3501. babylonTexture?: Texture;
  3502. }
  3503. /** @hidden */
  3504. export interface IGLTFAmbienLight {
  3505. color?: number[];
  3506. }
  3507. /** @hidden */
  3508. export interface IGLTFDirectionalLight {
  3509. color?: number[];
  3510. }
  3511. /** @hidden */
  3512. export interface IGLTFPointLight {
  3513. color?: number[];
  3514. constantAttenuation?: number;
  3515. linearAttenuation?: number;
  3516. quadraticAttenuation?: number;
  3517. }
  3518. /** @hidden */
  3519. export interface IGLTFSpotLight {
  3520. color?: number[];
  3521. constantAttenuation?: number;
  3522. fallOfAngle?: number;
  3523. fallOffExponent?: number;
  3524. linearAttenuation?: number;
  3525. quadraticAttenuation?: number;
  3526. }
  3527. /** @hidden */
  3528. export interface IGLTFLight extends IGLTFChildRootProperty {
  3529. type: string;
  3530. }
  3531. /** @hidden */
  3532. export interface IGLTFCameraOrthographic {
  3533. xmag: number;
  3534. ymag: number;
  3535. zfar: number;
  3536. znear: number;
  3537. }
  3538. /** @hidden */
  3539. export interface IGLTFCameraPerspective {
  3540. aspectRatio: number;
  3541. yfov: number;
  3542. zfar: number;
  3543. znear: number;
  3544. }
  3545. /** @hidden */
  3546. export interface IGLTFCamera extends IGLTFChildRootProperty {
  3547. type: string;
  3548. }
  3549. /** @hidden */
  3550. export interface IGLTFAnimationChannelTarget {
  3551. id: string;
  3552. path: string;
  3553. }
  3554. /** @hidden */
  3555. export interface IGLTFAnimationChannel {
  3556. sampler: string;
  3557. target: IGLTFAnimationChannelTarget;
  3558. }
  3559. /** @hidden */
  3560. export interface IGLTFAnimationSampler {
  3561. input: string;
  3562. output: string;
  3563. interpolation?: string;
  3564. }
  3565. /** @hidden */
  3566. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  3567. channels?: IGLTFAnimationChannel[];
  3568. parameters?: {
  3569. [key: string]: string;
  3570. };
  3571. samplers?: {
  3572. [key: string]: IGLTFAnimationSampler;
  3573. };
  3574. }
  3575. /** @hidden */
  3576. export interface IGLTFNodeInstanceSkin {
  3577. skeletons: string[];
  3578. skin: string;
  3579. meshes: string[];
  3580. }
  3581. /** @hidden */
  3582. export interface IGLTFSkins extends IGLTFChildRootProperty {
  3583. bindShapeMatrix: number[];
  3584. inverseBindMatrices: string;
  3585. jointNames: string[];
  3586. babylonSkeleton?: Skeleton;
  3587. }
  3588. /** @hidden */
  3589. export interface IGLTFNode extends IGLTFChildRootProperty {
  3590. camera?: string;
  3591. children: string[];
  3592. skin?: string;
  3593. jointName?: string;
  3594. light?: string;
  3595. matrix: number[];
  3596. mesh?: string;
  3597. meshes?: string[];
  3598. rotation?: number[];
  3599. scale?: number[];
  3600. translation?: number[];
  3601. babylonNode?: Node;
  3602. }
  3603. /** @hidden */
  3604. export interface IGLTFScene extends IGLTFChildRootProperty {
  3605. nodes: string[];
  3606. }
  3607. /** @hidden */
  3608. export interface IGLTFRuntime {
  3609. extensions: {
  3610. [key: string]: any;
  3611. };
  3612. accessors: {
  3613. [key: string]: IGLTFAccessor;
  3614. };
  3615. buffers: {
  3616. [key: string]: IGLTFBuffer;
  3617. };
  3618. bufferViews: {
  3619. [key: string]: IGLTFBufferView;
  3620. };
  3621. meshes: {
  3622. [key: string]: IGLTFMesh;
  3623. };
  3624. lights: {
  3625. [key: string]: IGLTFLight;
  3626. };
  3627. cameras: {
  3628. [key: string]: IGLTFCamera;
  3629. };
  3630. nodes: {
  3631. [key: string]: IGLTFNode;
  3632. };
  3633. images: {
  3634. [key: string]: IGLTFImage;
  3635. };
  3636. textures: {
  3637. [key: string]: IGLTFTexture;
  3638. };
  3639. shaders: {
  3640. [key: string]: IGLTFShader;
  3641. };
  3642. programs: {
  3643. [key: string]: IGLTFProgram;
  3644. };
  3645. samplers: {
  3646. [key: string]: IGLTFSampler;
  3647. };
  3648. techniques: {
  3649. [key: string]: IGLTFTechnique;
  3650. };
  3651. materials: {
  3652. [key: string]: IGLTFMaterial;
  3653. };
  3654. animations: {
  3655. [key: string]: IGLTFAnimation;
  3656. };
  3657. skins: {
  3658. [key: string]: IGLTFSkins;
  3659. };
  3660. currentScene?: Object;
  3661. scenes: {
  3662. [key: string]: IGLTFScene;
  3663. };
  3664. extensionsUsed: string[];
  3665. extensionsRequired?: string[];
  3666. buffersCount: number;
  3667. shaderscount: number;
  3668. scene: Scene;
  3669. rootUrl: string;
  3670. loadedBufferCount: number;
  3671. loadedBufferViews: {
  3672. [name: string]: ArrayBufferView;
  3673. };
  3674. loadedShaderCount: number;
  3675. importOnlyMeshes: boolean;
  3676. importMeshesNames?: string[];
  3677. dummyNodes: Node[];
  3678. forAssetContainer: boolean;
  3679. }
  3680. /** @hidden */
  3681. export interface INodeToRoot {
  3682. bone: Bone;
  3683. node: IGLTFNode;
  3684. id: string;
  3685. }
  3686. /** @hidden */
  3687. export interface IJointNode {
  3688. node: IGLTFNode;
  3689. id: string;
  3690. }
  3691. }
  3692. declare module BABYLON.GLTF1 {
  3693. /**
  3694. * Utils functions for GLTF
  3695. * @hidden
  3696. */
  3697. export class GLTFUtils {
  3698. /**
  3699. * Sets the given "parameter" matrix
  3700. * @param scene: the Scene object
  3701. * @param source: the source node where to pick the matrix
  3702. * @param parameter: the GLTF technique parameter
  3703. * @param uniformName: the name of the shader's uniform
  3704. * @param shaderMaterial: the shader material
  3705. */
  3706. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  3707. /**
  3708. * Sets the given "parameter" matrix
  3709. * @param shaderMaterial: the shader material
  3710. * @param uniform: the name of the shader's uniform
  3711. * @param value: the value of the uniform
  3712. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  3713. */
  3714. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  3715. /**
  3716. * Returns the wrap mode of the texture
  3717. * @param mode: the mode value
  3718. */
  3719. static GetWrapMode(mode: number): number;
  3720. /**
  3721. * Returns the byte stride giving an accessor
  3722. * @param accessor: the GLTF accessor objet
  3723. */
  3724. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  3725. /**
  3726. * Returns the texture filter mode giving a mode value
  3727. * @param mode: the filter mode value
  3728. */
  3729. static GetTextureFilterMode(mode: number): ETextureFilterType;
  3730. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  3731. /**
  3732. * Returns a buffer from its accessor
  3733. * @param gltfRuntime: the GLTF runtime
  3734. * @param accessor: the GLTF accessor
  3735. */
  3736. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  3737. /**
  3738. * Decodes a buffer view into a string
  3739. * @param view: the buffer view
  3740. */
  3741. static DecodeBufferToText(view: ArrayBufferView): string;
  3742. /**
  3743. * Returns the default material of gltf. Related to
  3744. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  3745. * @param scene: the Babylon.js scene
  3746. */
  3747. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  3748. private static _DefaultMaterial;
  3749. }
  3750. }
  3751. declare module BABYLON.GLTF1 {
  3752. /**
  3753. * Implementation of the base glTF spec
  3754. * @hidden
  3755. */
  3756. export class GLTFLoaderBase {
  3757. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  3758. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3759. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  3760. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3761. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  3762. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3763. }
  3764. /**
  3765. * glTF V1 Loader
  3766. * @hidden
  3767. */
  3768. export class GLTFLoader implements IGLTFLoader {
  3769. static Extensions: {
  3770. [name: string]: GLTFLoaderExtension;
  3771. };
  3772. static RegisterExtension(extension: GLTFLoaderExtension): void;
  3773. state: Nullable<GLTFLoaderState>;
  3774. dispose(): void;
  3775. private _importMeshAsync;
  3776. /**
  3777. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  3778. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  3779. * @param scene the scene the meshes should be added to
  3780. * @param forAssetContainer defines if the entities must be stored in the scene
  3781. * @param data gltf data containing information of the meshes in a loaded file
  3782. * @param rootUrl root url to load from
  3783. * @param onProgress event that fires when loading progress has occured
  3784. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  3785. */
  3786. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  3787. private _loadAsync;
  3788. /**
  3789. * Imports all objects from a loaded gltf file and adds them to the scene
  3790. * @param scene the scene the objects should be added to
  3791. * @param data gltf data containing information of the meshes in a loaded file
  3792. * @param rootUrl root url to load from
  3793. * @param onProgress event that fires when loading progress has occured
  3794. * @returns a promise which completes when objects have been loaded to the scene
  3795. */
  3796. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  3797. private _loadShadersAsync;
  3798. private _loadBuffersAsync;
  3799. private _createNodes;
  3800. }
  3801. /** @hidden */
  3802. export abstract class GLTFLoaderExtension {
  3803. private _name;
  3804. constructor(name: string);
  3805. get name(): string;
  3806. /**
  3807. * Defines an override for loading the runtime
  3808. * Return true to stop further extensions from loading the runtime
  3809. */
  3810. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  3811. /**
  3812. * Defines an onverride for creating gltf runtime
  3813. * Return true to stop further extensions from creating the runtime
  3814. */
  3815. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  3816. /**
  3817. * Defines an override for loading buffers
  3818. * Return true to stop further extensions from loading this buffer
  3819. */
  3820. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  3821. /**
  3822. * Defines an override for loading texture buffers
  3823. * Return true to stop further extensions from loading this texture data
  3824. */
  3825. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3826. /**
  3827. * Defines an override for creating textures
  3828. * Return true to stop further extensions from loading this texture
  3829. */
  3830. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  3831. /**
  3832. * Defines an override for loading shader strings
  3833. * Return true to stop further extensions from loading this shader data
  3834. */
  3835. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3836. /**
  3837. * Defines an override for loading materials
  3838. * Return true to stop further extensions from loading this material
  3839. */
  3840. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3841. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  3842. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  3843. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  3844. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  3845. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  3846. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  3847. private static LoadTextureBufferAsync;
  3848. private static CreateTextureAsync;
  3849. private static ApplyExtensions;
  3850. }
  3851. }
  3852. declare module BABYLON.GLTF1 {
  3853. /** @hidden */
  3854. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  3855. private _bin;
  3856. constructor();
  3857. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  3858. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3859. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  3860. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  3861. }
  3862. }
  3863. declare module BABYLON.GLTF1 {
  3864. /** @hidden */
  3865. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  3866. constructor();
  3867. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  3868. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  3869. private _loadTexture;
  3870. }
  3871. }
  3872. declare module BABYLON.GLTF2.Loader {
  3873. /**
  3874. * Loader interface with an index field.
  3875. */
  3876. export interface IArrayItem {
  3877. /**
  3878. * The index of this item in the array.
  3879. */
  3880. index: number;
  3881. }
  3882. /**
  3883. * Loader interface with additional members.
  3884. */
  3885. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  3886. /** @hidden */
  3887. _data?: Promise<ArrayBufferView>;
  3888. /** @hidden */
  3889. _babylonVertexBuffer?: Promise<VertexBuffer>;
  3890. }
  3891. /**
  3892. * Loader interface with additional members.
  3893. */
  3894. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  3895. }
  3896. /** @hidden */
  3897. export interface _IAnimationSamplerData {
  3898. input: Float32Array;
  3899. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  3900. output: Float32Array;
  3901. }
  3902. /**
  3903. * Loader interface with additional members.
  3904. */
  3905. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  3906. /** @hidden */
  3907. _data?: Promise<_IAnimationSamplerData>;
  3908. }
  3909. /**
  3910. * Loader interface with additional members.
  3911. */
  3912. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  3913. channels: IAnimationChannel[];
  3914. samplers: IAnimationSampler[];
  3915. /** @hidden */
  3916. _babylonAnimationGroup?: AnimationGroup;
  3917. }
  3918. /**
  3919. * Loader interface with additional members.
  3920. */
  3921. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  3922. /** @hidden */
  3923. _data?: Promise<ArrayBufferView>;
  3924. }
  3925. /**
  3926. * Loader interface with additional members.
  3927. */
  3928. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  3929. /** @hidden */
  3930. _data?: Promise<ArrayBufferView>;
  3931. /** @hidden */
  3932. _babylonBuffer?: Promise<Buffer>;
  3933. }
  3934. /**
  3935. * Loader interface with additional members.
  3936. */
  3937. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  3938. }
  3939. /**
  3940. * Loader interface with additional members.
  3941. */
  3942. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  3943. /** @hidden */
  3944. _data?: Promise<ArrayBufferView>;
  3945. }
  3946. /**
  3947. * Loader interface with additional members.
  3948. */
  3949. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  3950. }
  3951. /**
  3952. * Loader interface with additional members.
  3953. */
  3954. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  3955. }
  3956. /**
  3957. * Loader interface with additional members.
  3958. */
  3959. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  3960. baseColorTexture?: ITextureInfo;
  3961. metallicRoughnessTexture?: ITextureInfo;
  3962. }
  3963. /**
  3964. * Loader interface with additional members.
  3965. */
  3966. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  3967. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  3968. normalTexture?: IMaterialNormalTextureInfo;
  3969. occlusionTexture?: IMaterialOcclusionTextureInfo;
  3970. emissiveTexture?: ITextureInfo;
  3971. /** @hidden */
  3972. _data?: {
  3973. [babylonDrawMode: number]: {
  3974. babylonMaterial: Material;
  3975. babylonMeshes: AbstractMesh[];
  3976. promise: Promise<void>;
  3977. };
  3978. };
  3979. }
  3980. /**
  3981. * Loader interface with additional members.
  3982. */
  3983. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  3984. primitives: IMeshPrimitive[];
  3985. }
  3986. /**
  3987. * Loader interface with additional members.
  3988. */
  3989. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  3990. /** @hidden */
  3991. _instanceData?: {
  3992. babylonSourceMesh: Mesh;
  3993. promise: Promise<any>;
  3994. };
  3995. }
  3996. /**
  3997. * Loader interface with additional members.
  3998. */
  3999. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  4000. /**
  4001. * The parent glTF node.
  4002. */
  4003. parent?: INode;
  4004. /** @hidden */
  4005. _babylonTransformNode?: TransformNode;
  4006. /** @hidden */
  4007. _primitiveBabylonMeshes?: AbstractMesh[];
  4008. /** @hidden */
  4009. _babylonBones?: Bone[];
  4010. /** @hidden */
  4011. _numMorphTargets?: number;
  4012. }
  4013. /** @hidden */
  4014. export interface _ISamplerData {
  4015. noMipMaps: boolean;
  4016. samplingMode: number;
  4017. wrapU: number;
  4018. wrapV: number;
  4019. }
  4020. /**
  4021. * Loader interface with additional members.
  4022. */
  4023. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  4024. /** @hidden */
  4025. _data?: _ISamplerData;
  4026. }
  4027. /**
  4028. * Loader interface with additional members.
  4029. */
  4030. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  4031. }
  4032. /**
  4033. * Loader interface with additional members.
  4034. */
  4035. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  4036. /** @hidden */
  4037. _data?: {
  4038. babylonSkeleton: Skeleton;
  4039. promise: Promise<void>;
  4040. };
  4041. }
  4042. /**
  4043. * Loader interface with additional members.
  4044. */
  4045. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  4046. /** @hidden */
  4047. _textureInfo: ITextureInfo;
  4048. }
  4049. /**
  4050. * Loader interface with additional members.
  4051. */
  4052. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  4053. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  4054. nonColorData?: boolean;
  4055. }
  4056. /**
  4057. * Loader interface with additional members.
  4058. */
  4059. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  4060. accessors?: IAccessor[];
  4061. animations?: IAnimation[];
  4062. buffers?: IBuffer[];
  4063. bufferViews?: IBufferView[];
  4064. cameras?: ICamera[];
  4065. images?: IImage[];
  4066. materials?: IMaterial[];
  4067. meshes?: IMesh[];
  4068. nodes?: INode[];
  4069. samplers?: ISampler[];
  4070. scenes?: IScene[];
  4071. skins?: ISkin[];
  4072. textures?: ITexture[];
  4073. }
  4074. }
  4075. declare module BABYLON.GLTF2 {
  4076. /**
  4077. * Interface for a glTF loader extension.
  4078. */
  4079. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  4080. /**
  4081. * Called after the loader state changes to LOADING.
  4082. */
  4083. onLoading?(): void;
  4084. /**
  4085. * Called after the loader state changes to READY.
  4086. */
  4087. onReady?(): void;
  4088. /**
  4089. * Define this method to modify the default behavior when loading scenes.
  4090. * @param context The context when loading the asset
  4091. * @param scene The glTF scene property
  4092. * @returns A promise that resolves when the load is complete or null if not handled
  4093. */
  4094. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  4095. /**
  4096. * Define this method to modify the default behavior when loading nodes.
  4097. * @param context The context when loading the asset
  4098. * @param node The glTF node property
  4099. * @param assign A function called synchronously after parsing the glTF properties
  4100. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  4101. */
  4102. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4103. /**
  4104. * Define this method to modify the default behavior when loading cameras.
  4105. * @param context The context when loading the asset
  4106. * @param camera The glTF camera property
  4107. * @param assign A function called synchronously after parsing the glTF properties
  4108. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  4109. */
  4110. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  4111. /**
  4112. * @hidden
  4113. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  4114. * @param context The context when loading the asset
  4115. * @param primitive The glTF mesh primitive property
  4116. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  4117. */
  4118. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  4119. /**
  4120. * @hidden
  4121. * Define this method to modify the default behavior when loading data for mesh primitives.
  4122. * @param context The context when loading the asset
  4123. * @param name The mesh name when loading the asset
  4124. * @param node The glTF node when loading the asset
  4125. * @param mesh The glTF mesh when loading the asset
  4126. * @param primitive The glTF mesh primitive property
  4127. * @param assign A function called synchronously after parsing the glTF properties
  4128. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  4129. */
  4130. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  4131. /**
  4132. * @hidden
  4133. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  4134. * @param context The context when loading the asset
  4135. * @param material The glTF material property
  4136. * @param assign A function called synchronously after parsing the glTF properties
  4137. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  4138. */
  4139. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  4140. /**
  4141. * Define this method to modify the default behavior when creating materials.
  4142. * @param context The context when loading the asset
  4143. * @param material The glTF material property
  4144. * @param babylonDrawMode The draw mode for the Babylon material
  4145. * @returns The Babylon material or null if not handled
  4146. */
  4147. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  4148. /**
  4149. * Define this method to modify the default behavior when loading material properties.
  4150. * @param context The context when loading the asset
  4151. * @param material The glTF material property
  4152. * @param babylonMaterial The Babylon material
  4153. * @returns A promise that resolves when the load is complete or null if not handled
  4154. */
  4155. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4156. /**
  4157. * Define this method to modify the default behavior when loading texture infos.
  4158. * @param context The context when loading the asset
  4159. * @param textureInfo The glTF texture info property
  4160. * @param assign A function called synchronously after parsing the glTF properties
  4161. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  4162. */
  4163. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4164. /**
  4165. * @hidden
  4166. * Define this method to modify the default behavior when loading textures.
  4167. * @param context The context when loading the asset
  4168. * @param texture The glTF texture property
  4169. * @param assign A function called synchronously after parsing the glTF properties
  4170. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  4171. */
  4172. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4173. /**
  4174. * Define this method to modify the default behavior when loading animations.
  4175. * @param context The context when loading the asset
  4176. * @param animation The glTF animation property
  4177. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  4178. */
  4179. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  4180. /**
  4181. * @hidden
  4182. * Define this method to modify the default behavior when loading skins.
  4183. * @param context The context when loading the asset
  4184. * @param node The glTF node property
  4185. * @param skin The glTF skin property
  4186. * @returns A promise that resolves when the load is complete or null if not handled
  4187. */
  4188. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  4189. /**
  4190. * @hidden
  4191. * Define this method to modify the default behavior when loading uris.
  4192. * @param context The context when loading the asset
  4193. * @param property The glTF property associated with the uri
  4194. * @param uri The uri to load
  4195. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  4196. */
  4197. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  4198. /**
  4199. * Define this method to modify the default behavior when loading buffer views.
  4200. * @param context The context when loading the asset
  4201. * @param bufferView The glTF buffer view property
  4202. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  4203. */
  4204. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  4205. /**
  4206. * Define this method to modify the default behavior when loading buffers.
  4207. * @param context The context when loading the asset
  4208. * @param buffer The glTF buffer property
  4209. * @param byteOffset The byte offset to load
  4210. * @param byteLength The byte length to load
  4211. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  4212. */
  4213. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  4214. }
  4215. }
  4216. declare module BABYLON.GLTF2 {
  4217. /**
  4218. * Helper class for working with arrays when loading the glTF asset
  4219. */
  4220. export class ArrayItem {
  4221. /**
  4222. * Gets an item from the given array.
  4223. * @param context The context when loading the asset
  4224. * @param array The array to get the item from
  4225. * @param index The index to the array
  4226. * @returns The array item
  4227. */
  4228. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  4229. /**
  4230. * Assign an `index` field to each item of the given array.
  4231. * @param array The array of items
  4232. */
  4233. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  4234. }
  4235. /**
  4236. * The glTF 2.0 loader
  4237. */
  4238. export class GLTFLoader implements IGLTFLoader {
  4239. /** @hidden */
  4240. _completePromises: Promise<any>[];
  4241. /** @hidden */
  4242. _forAssetContainer: boolean;
  4243. /** Storage */
  4244. _babylonLights: Light[];
  4245. /** @hidden */
  4246. _disableInstancedMesh: number;
  4247. private _disposed;
  4248. private _parent;
  4249. private _state;
  4250. private _extensions;
  4251. private _rootUrl;
  4252. private _fileName;
  4253. private _uniqueRootUrl;
  4254. private _gltf;
  4255. private _bin;
  4256. private _babylonScene;
  4257. private _rootBabylonMesh;
  4258. private _defaultBabylonMaterialData;
  4259. private static _RegisteredExtensions;
  4260. /**
  4261. * The default glTF sampler.
  4262. */
  4263. static readonly DefaultSampler: ISampler;
  4264. /**
  4265. * Registers a loader extension.
  4266. * @param name The name of the loader extension.
  4267. * @param factory The factory function that creates the loader extension.
  4268. */
  4269. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  4270. /**
  4271. * Unregisters a loader extension.
  4272. * @param name The name of the loader extension.
  4273. * @returns A boolean indicating whether the extension has been unregistered
  4274. */
  4275. static UnregisterExtension(name: string): boolean;
  4276. /**
  4277. * The loader state.
  4278. */
  4279. get state(): Nullable<GLTFLoaderState>;
  4280. /**
  4281. * The object that represents the glTF JSON.
  4282. */
  4283. get gltf(): IGLTF;
  4284. /**
  4285. * The BIN chunk of a binary glTF.
  4286. */
  4287. get bin(): Nullable<IDataBuffer>;
  4288. /**
  4289. * The parent file loader.
  4290. */
  4291. get parent(): GLTFFileLoader;
  4292. /**
  4293. * The Babylon scene when loading the asset.
  4294. */
  4295. get babylonScene(): Scene;
  4296. /**
  4297. * The root Babylon mesh when loading the asset.
  4298. */
  4299. get rootBabylonMesh(): Mesh;
  4300. /** @hidden */
  4301. constructor(parent: GLTFFileLoader);
  4302. /** @hidden */
  4303. dispose(): void;
  4304. /** @hidden */
  4305. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  4306. /** @hidden */
  4307. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  4308. private _loadAsync;
  4309. private _loadData;
  4310. private _setupData;
  4311. private _loadExtensions;
  4312. private _checkExtensions;
  4313. private _setState;
  4314. private _createRootNode;
  4315. /**
  4316. * Loads a glTF scene.
  4317. * @param context The context when loading the asset
  4318. * @param scene The glTF scene property
  4319. * @returns A promise that resolves when the load is complete
  4320. */
  4321. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  4322. private _forEachPrimitive;
  4323. private _getGeometries;
  4324. private _getMeshes;
  4325. private _getTransformNodes;
  4326. private _getSkeletons;
  4327. private _getAnimationGroups;
  4328. private _startAnimations;
  4329. /**
  4330. * Loads a glTF node.
  4331. * @param context The context when loading the asset
  4332. * @param node The glTF node property
  4333. * @param assign A function called synchronously after parsing the glTF properties
  4334. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  4335. */
  4336. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  4337. private _loadMeshAsync;
  4338. /**
  4339. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  4340. * @param context The context when loading the asset
  4341. * @param name The mesh name when loading the asset
  4342. * @param node The glTF node when loading the asset
  4343. * @param mesh The glTF mesh when loading the asset
  4344. * @param primitive The glTF mesh primitive property
  4345. * @param assign A function called synchronously after parsing the glTF properties
  4346. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  4347. */
  4348. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  4349. private _loadVertexDataAsync;
  4350. private _createMorphTargets;
  4351. private _loadMorphTargetsAsync;
  4352. private _loadMorphTargetVertexDataAsync;
  4353. private static _LoadTransform;
  4354. private _loadSkinAsync;
  4355. private _loadBones;
  4356. private _loadBone;
  4357. private _loadSkinInverseBindMatricesDataAsync;
  4358. private _updateBoneMatrices;
  4359. private _getNodeMatrix;
  4360. /**
  4361. * Loads a glTF camera.
  4362. * @param context The context when loading the asset
  4363. * @param camera The glTF camera property
  4364. * @param assign A function called synchronously after parsing the glTF properties
  4365. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  4366. */
  4367. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  4368. private _loadAnimationsAsync;
  4369. /**
  4370. * Loads a glTF animation.
  4371. * @param context The context when loading the asset
  4372. * @param animation The glTF animation property
  4373. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  4374. */
  4375. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  4376. /**
  4377. * @hidden Loads a glTF animation channel.
  4378. * @param context The context when loading the asset
  4379. * @param animationContext The context of the animation when loading the asset
  4380. * @param animation The glTF animation property
  4381. * @param channel The glTF animation channel property
  4382. * @param babylonAnimationGroup The babylon animation group property
  4383. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  4384. * @returns A void promise when the channel load is complete
  4385. */
  4386. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  4387. private _loadAnimationSamplerAsync;
  4388. private _loadBufferAsync;
  4389. /**
  4390. * Loads a glTF buffer view.
  4391. * @param context The context when loading the asset
  4392. * @param bufferView The glTF buffer view property
  4393. * @returns A promise that resolves with the loaded data when the load is complete
  4394. */
  4395. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  4396. private _loadAccessorAsync;
  4397. /** @hidden */
  4398. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  4399. private _loadIndicesAccessorAsync;
  4400. private _loadVertexBufferViewAsync;
  4401. private _loadVertexAccessorAsync;
  4402. private _loadMaterialMetallicRoughnessPropertiesAsync;
  4403. /** @hidden */
  4404. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  4405. private _createDefaultMaterial;
  4406. /**
  4407. * Creates a Babylon material from a glTF material.
  4408. * @param context The context when loading the asset
  4409. * @param material The glTF material property
  4410. * @param babylonDrawMode The draw mode for the Babylon material
  4411. * @returns The Babylon material
  4412. */
  4413. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  4414. /**
  4415. * Loads properties from a glTF material into a Babylon material.
  4416. * @param context The context when loading the asset
  4417. * @param material The glTF material property
  4418. * @param babylonMaterial The Babylon material
  4419. * @returns A promise that resolves when the load is complete
  4420. */
  4421. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  4422. /**
  4423. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  4424. * @param context The context when loading the asset
  4425. * @param material The glTF material property
  4426. * @param babylonMaterial The Babylon material
  4427. * @returns A promise that resolves when the load is complete
  4428. */
  4429. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  4430. /**
  4431. * Loads the alpha properties from a glTF material into a Babylon material.
  4432. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  4433. * @param context The context when loading the asset
  4434. * @param material The glTF material property
  4435. * @param babylonMaterial The Babylon material
  4436. */
  4437. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  4438. /**
  4439. * Loads a glTF texture info.
  4440. * @param context The context when loading the asset
  4441. * @param textureInfo The glTF texture info property
  4442. * @param assign A function called synchronously after parsing the glTF properties
  4443. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  4444. */
  4445. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4446. /** @hidden */
  4447. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  4448. /** @hidden */
  4449. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  4450. private _loadSampler;
  4451. /**
  4452. * Loads a glTF image.
  4453. * @param context The context when loading the asset
  4454. * @param image The glTF image property
  4455. * @returns A promise that resolves with the loaded data when the load is complete
  4456. */
  4457. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  4458. /**
  4459. * Loads a glTF uri.
  4460. * @param context The context when loading the asset
  4461. * @param property The glTF property associated with the uri
  4462. * @param uri The base64 or relative uri
  4463. * @returns A promise that resolves with the loaded data when the load is complete
  4464. */
  4465. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  4466. /**
  4467. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  4468. * @param babylonObject the Babylon object with metadata
  4469. * @param pointer the JSON pointer
  4470. */
  4471. static AddPointerMetadata(babylonObject: {
  4472. metadata: any;
  4473. }, pointer: string): void;
  4474. private static _GetTextureWrapMode;
  4475. private static _GetTextureSamplingMode;
  4476. private static _GetTypedArrayConstructor;
  4477. private static _GetTypedArray;
  4478. private static _GetNumComponents;
  4479. private static _ValidateUri;
  4480. /** @hidden */
  4481. static _GetDrawMode(context: string, mode: number | undefined): number;
  4482. private _compileMaterialsAsync;
  4483. private _compileShadowGeneratorsAsync;
  4484. private _forEachExtensions;
  4485. private _applyExtensions;
  4486. private _extensionsOnLoading;
  4487. private _extensionsOnReady;
  4488. private _extensionsLoadSceneAsync;
  4489. private _extensionsLoadNodeAsync;
  4490. private _extensionsLoadCameraAsync;
  4491. private _extensionsLoadVertexDataAsync;
  4492. private _extensionsLoadMeshPrimitiveAsync;
  4493. private _extensionsLoadMaterialAsync;
  4494. private _extensionsCreateMaterial;
  4495. private _extensionsLoadMaterialPropertiesAsync;
  4496. private _extensionsLoadTextureInfoAsync;
  4497. private _extensionsLoadTextureAsync;
  4498. private _extensionsLoadAnimationAsync;
  4499. private _extensionsLoadSkinAsync;
  4500. private _extensionsLoadUriAsync;
  4501. private _extensionsLoadBufferViewAsync;
  4502. private _extensionsLoadBufferAsync;
  4503. /**
  4504. * Helper method called by a loader extension to load an glTF extension.
  4505. * @param context The context when loading the asset
  4506. * @param property The glTF property to load the extension from
  4507. * @param extensionName The name of the extension to load
  4508. * @param actionAsync The action to run
  4509. * @returns The promise returned by actionAsync or null if the extension does not exist
  4510. */
  4511. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4512. /**
  4513. * Helper method called by a loader extension to load a glTF extra.
  4514. * @param context The context when loading the asset
  4515. * @param property The glTF property to load the extra from
  4516. * @param extensionName The name of the extension to load
  4517. * @param actionAsync The action to run
  4518. * @returns The promise returned by actionAsync or null if the extra does not exist
  4519. */
  4520. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  4521. /**
  4522. * Checks for presence of an extension.
  4523. * @param name The name of the extension to check
  4524. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  4525. */
  4526. isExtensionUsed(name: string): boolean;
  4527. /**
  4528. * Increments the indentation level and logs a message.
  4529. * @param message The message to log
  4530. */
  4531. logOpen(message: string): void;
  4532. /**
  4533. * Decrements the indentation level.
  4534. */
  4535. logClose(): void;
  4536. /**
  4537. * Logs a message
  4538. * @param message The message to log
  4539. */
  4540. log(message: string): void;
  4541. /**
  4542. * Starts a performance counter.
  4543. * @param counterName The name of the performance counter
  4544. */
  4545. startPerformanceCounter(counterName: string): void;
  4546. /**
  4547. * Ends a performance counter.
  4548. * @param counterName The name of the performance counter
  4549. */
  4550. endPerformanceCounter(counterName: string): void;
  4551. }
  4552. }
  4553. declare module BABYLON.GLTF2.Loader.Extensions {
  4554. /** @hidden */
  4555. interface IEXTLightsImageBased_LightImageBased {
  4556. _babylonTexture?: BaseTexture;
  4557. _loaded?: Promise<void>;
  4558. }
  4559. /**
  4560. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  4561. */
  4562. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  4563. /**
  4564. * The name of this extension.
  4565. */
  4566. readonly name: string;
  4567. /**
  4568. * Defines whether this extension is enabled.
  4569. */
  4570. enabled: boolean;
  4571. private _loader;
  4572. private _lights?;
  4573. /** @hidden */
  4574. constructor(loader: GLTFLoader);
  4575. /** @hidden */
  4576. dispose(): void;
  4577. /** @hidden */
  4578. onLoading(): void;
  4579. /** @hidden */
  4580. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  4581. private _loadLightAsync;
  4582. }
  4583. }
  4584. declare module BABYLON.GLTF2.Loader.Extensions {
  4585. /**
  4586. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  4587. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  4588. * !!! Experimental Extension Subject to Changes !!!
  4589. */
  4590. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  4591. /**
  4592. * The name of this extension.
  4593. */
  4594. readonly name: string;
  4595. /**
  4596. * Defines whether this extension is enabled.
  4597. */
  4598. enabled: boolean;
  4599. private _loader;
  4600. /** @hidden */
  4601. constructor(loader: GLTFLoader);
  4602. /** @hidden */
  4603. dispose(): void;
  4604. /** @hidden */
  4605. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4606. }
  4607. }
  4608. declare module BABYLON.GLTF2.Loader.Extensions {
  4609. /**
  4610. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  4611. *
  4612. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  4613. */
  4614. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  4615. /**
  4616. * The name of this extension.
  4617. */
  4618. readonly name: string;
  4619. /**
  4620. * Defines whether this extension is enabled.
  4621. */
  4622. enabled: boolean;
  4623. /**
  4624. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.module.js
  4625. */
  4626. static DecoderPath: string;
  4627. private _loader;
  4628. private _decoder;
  4629. /** @hidden */
  4630. constructor(loader: GLTFLoader);
  4631. /** @hidden */
  4632. dispose(): void;
  4633. /** @hidden */
  4634. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  4635. }
  4636. }
  4637. declare module BABYLON.GLTF2.Loader.Extensions {
  4638. /**
  4639. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  4640. */
  4641. export class EXT_texture_webp implements IGLTFLoaderExtension {
  4642. /** The name of this extension. */
  4643. readonly name: string;
  4644. /** Defines whether this extension is enabled. */
  4645. enabled: boolean;
  4646. private _loader;
  4647. /** @hidden */
  4648. constructor(loader: GLTFLoader);
  4649. /** @hidden */
  4650. dispose(): void;
  4651. /** @hidden */
  4652. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  4653. }
  4654. }
  4655. declare module BABYLON.GLTF2.Loader.Extensions {
  4656. /**
  4657. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  4658. */
  4659. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  4660. /**
  4661. * The name of this extension.
  4662. */
  4663. readonly name: string;
  4664. /**
  4665. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  4666. */
  4667. dracoCompression?: DracoCompression;
  4668. /**
  4669. * Defines whether this extension is enabled.
  4670. */
  4671. enabled: boolean;
  4672. private _loader;
  4673. /** @hidden */
  4674. constructor(loader: GLTFLoader);
  4675. /** @hidden */
  4676. dispose(): void;
  4677. /** @hidden */
  4678. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  4679. }
  4680. }
  4681. declare module BABYLON.GLTF2.Loader.Extensions {
  4682. /**
  4683. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  4684. */
  4685. export class KHR_lights implements IGLTFLoaderExtension {
  4686. /**
  4687. * The name of this extension.
  4688. */
  4689. readonly name: string;
  4690. /**
  4691. * Defines whether this extension is enabled.
  4692. */
  4693. enabled: boolean;
  4694. private _loader;
  4695. private _lights?;
  4696. /** @hidden */
  4697. constructor(loader: GLTFLoader);
  4698. /** @hidden */
  4699. dispose(): void;
  4700. /** @hidden */
  4701. onLoading(): void;
  4702. /** @hidden */
  4703. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  4704. }
  4705. }
  4706. declare module BABYLON.GLTF2.Loader.Extensions {
  4707. /**
  4708. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  4709. */
  4710. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  4711. /**
  4712. * The name of this extension.
  4713. */
  4714. readonly name: string;
  4715. /**
  4716. * Defines whether this extension is enabled.
  4717. */
  4718. enabled: boolean;
  4719. /**
  4720. * Defines a number that determines the order the extensions are applied.
  4721. */
  4722. order: number;
  4723. private _loader;
  4724. /** @hidden */
  4725. constructor(loader: GLTFLoader);
  4726. /** @hidden */
  4727. dispose(): void;
  4728. /** @hidden */
  4729. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4730. private _loadSpecularGlossinessPropertiesAsync;
  4731. }
  4732. }
  4733. declare module BABYLON.GLTF2.Loader.Extensions {
  4734. /**
  4735. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  4736. */
  4737. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  4738. /**
  4739. * The name of this extension.
  4740. */
  4741. readonly name: string;
  4742. /**
  4743. * Defines whether this extension is enabled.
  4744. */
  4745. enabled: boolean;
  4746. /**
  4747. * Defines a number that determines the order the extensions are applied.
  4748. */
  4749. order: number;
  4750. private _loader;
  4751. /** @hidden */
  4752. constructor(loader: GLTFLoader);
  4753. /** @hidden */
  4754. dispose(): void;
  4755. /** @hidden */
  4756. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4757. private _loadUnlitPropertiesAsync;
  4758. }
  4759. }
  4760. declare module BABYLON.GLTF2.Loader.Extensions {
  4761. /**
  4762. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  4763. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  4764. */
  4765. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  4766. /**
  4767. * The name of this extension.
  4768. */
  4769. readonly name: string;
  4770. /**
  4771. * Defines whether this extension is enabled.
  4772. */
  4773. enabled: boolean;
  4774. /**
  4775. * Defines a number that determines the order the extensions are applied.
  4776. */
  4777. order: number;
  4778. private _loader;
  4779. /** @hidden */
  4780. constructor(loader: GLTFLoader);
  4781. /** @hidden */
  4782. dispose(): void;
  4783. /** @hidden */
  4784. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4785. private _loadClearCoatPropertiesAsync;
  4786. }
  4787. }
  4788. declare module BABYLON.GLTF2.Loader.Extensions {
  4789. /**
  4790. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  4791. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  4792. * !!! Experimental Extension Subject to Changes !!!
  4793. */
  4794. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  4795. /**
  4796. * The name of this extension.
  4797. */
  4798. readonly name: string;
  4799. /**
  4800. * Defines whether this extension is enabled.
  4801. */
  4802. enabled: boolean;
  4803. /**
  4804. * Defines a number that determines the order the extensions are applied.
  4805. */
  4806. order: number;
  4807. private _loader;
  4808. /** @hidden */
  4809. constructor(loader: GLTFLoader);
  4810. /** @hidden */
  4811. dispose(): void;
  4812. /** @hidden */
  4813. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4814. private _loadSheenPropertiesAsync;
  4815. }
  4816. }
  4817. declare module BABYLON.GLTF2.Loader.Extensions {
  4818. /**
  4819. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  4820. * !!! Experimental Extension Subject to Changes !!!
  4821. */
  4822. export class KHR_materials_specular implements IGLTFLoaderExtension {
  4823. /**
  4824. * The name of this extension.
  4825. */
  4826. readonly name: string;
  4827. /**
  4828. * Defines whether this extension is enabled.
  4829. */
  4830. enabled: boolean;
  4831. /**
  4832. * Defines a number that determines the order the extensions are applied.
  4833. */
  4834. order: number;
  4835. private _loader;
  4836. /** @hidden */
  4837. constructor(loader: GLTFLoader);
  4838. /** @hidden */
  4839. dispose(): void;
  4840. /** @hidden */
  4841. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4842. private _loadSpecularPropertiesAsync;
  4843. }
  4844. }
  4845. declare module BABYLON.GLTF2.Loader.Extensions {
  4846. /**
  4847. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  4848. * !!! Experimental Extension Subject to Changes !!!
  4849. */
  4850. export class KHR_materials_ior implements IGLTFLoaderExtension {
  4851. /**
  4852. * Default ior Value from the spec.
  4853. */
  4854. private static readonly _DEFAULT_IOR;
  4855. /**
  4856. * The name of this extension.
  4857. */
  4858. readonly name: string;
  4859. /**
  4860. * Defines whether this extension is enabled.
  4861. */
  4862. enabled: boolean;
  4863. /**
  4864. * Defines a number that determines the order the extensions are applied.
  4865. */
  4866. order: number;
  4867. private _loader;
  4868. /** @hidden */
  4869. constructor(loader: GLTFLoader);
  4870. /** @hidden */
  4871. dispose(): void;
  4872. /** @hidden */
  4873. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4874. private _loadIorPropertiesAsync;
  4875. }
  4876. }
  4877. declare module BABYLON.GLTF2.Loader.Extensions {
  4878. /**
  4879. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  4880. */
  4881. export class KHR_materials_variants 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. private _loader;
  4891. private _variants?;
  4892. /** @hidden */
  4893. constructor(loader: GLTFLoader);
  4894. /** @hidden */
  4895. dispose(): void;
  4896. /**
  4897. * Gets the list of available variant names for this asset.
  4898. * @param rootMesh The glTF root mesh
  4899. * @returns the list of all the variant names for this model
  4900. */
  4901. static GetAvailableVariants(rootMesh: Mesh): string[];
  4902. /**
  4903. * Gets the list of available variant names for this asset.
  4904. * @param rootMesh The glTF root mesh
  4905. * @returns the list of all the variant names for this model
  4906. */
  4907. getAvailableVariants(rootMesh: Mesh): string[];
  4908. /**
  4909. * Select a variant given a variant name or a list of variant names.
  4910. * @param rootMesh The glTF root mesh
  4911. * @param variantName The variant name(s) to select.
  4912. */
  4913. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  4914. /**
  4915. * Select a variant given a variant name or a list of variant names.
  4916. * @param rootMesh The glTF root mesh
  4917. * @param variantName The variant name(s) to select.
  4918. */
  4919. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  4920. /**
  4921. * Reset back to the original before selecting a variant.
  4922. * @param rootMesh The glTF root mesh
  4923. */
  4924. static Reset(rootMesh: Mesh): void;
  4925. /**
  4926. * Reset back to the original before selecting a variant.
  4927. * @param rootMesh The glTF root mesh
  4928. */
  4929. reset(rootMesh: Mesh): void;
  4930. /**
  4931. * Gets the last selected variant name(s) or null if original.
  4932. * @param rootMesh The glTF root mesh
  4933. * @returns The selected variant name(s).
  4934. */
  4935. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  4936. /**
  4937. * Gets the last selected variant name(s) or null if original.
  4938. * @param rootMesh The glTF root mesh
  4939. * @returns The selected variant name(s).
  4940. */
  4941. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  4942. private static _GetExtensionMetadata;
  4943. /** @hidden */
  4944. onLoading(): void;
  4945. /** @hidden */
  4946. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  4947. }
  4948. }
  4949. declare module BABYLON.GLTF2.Loader.Extensions {
  4950. /**
  4951. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  4952. */
  4953. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  4954. /**
  4955. * The name of this extension.
  4956. */
  4957. readonly name: string;
  4958. /**
  4959. * Defines whether this extension is enabled.
  4960. */
  4961. enabled: boolean;
  4962. /**
  4963. * Defines a number that determines the order the extensions are applied.
  4964. */
  4965. order: number;
  4966. private _loader;
  4967. /** @hidden */
  4968. constructor(loader: GLTFLoader);
  4969. /** @hidden */
  4970. dispose(): void;
  4971. /** @hidden */
  4972. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  4973. private _loadTransparentPropertiesAsync;
  4974. }
  4975. }
  4976. declare module BABYLON.GLTF2.Loader.Extensions {
  4977. /**
  4978. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  4979. * !!! Experimental Extension Subject to Changes !!!
  4980. */
  4981. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  4982. /**
  4983. * The name of this extension.
  4984. */
  4985. readonly name: string;
  4986. /**
  4987. * Defines whether this extension is enabled.
  4988. */
  4989. enabled: boolean;
  4990. /**
  4991. * Defines a number that determines the order the extensions are applied.
  4992. */
  4993. order: number;
  4994. private _loader;
  4995. /** @hidden */
  4996. constructor(loader: GLTFLoader);
  4997. /** @hidden */
  4998. dispose(): void;
  4999. /** @hidden */
  5000. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  5001. private _loadTranslucentPropertiesAsync;
  5002. }
  5003. }
  5004. declare module BABYLON.GLTF2.Loader.Extensions {
  5005. /**
  5006. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  5007. */
  5008. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  5009. /**
  5010. * The name of this extension.
  5011. */
  5012. readonly name: string;
  5013. /**
  5014. * Defines whether this extension is enabled.
  5015. */
  5016. enabled: boolean;
  5017. /** @hidden */
  5018. constructor(loader: GLTFLoader);
  5019. /** @hidden */
  5020. dispose(): void;
  5021. }
  5022. }
  5023. declare module BABYLON.GLTF2.Loader.Extensions {
  5024. /**
  5025. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  5026. * !!! Experimental Extension Subject to Changes !!!
  5027. */
  5028. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  5029. /** The name of this extension. */
  5030. readonly name: string;
  5031. /** Defines whether this extension is enabled. */
  5032. enabled: boolean;
  5033. private _loader;
  5034. /** @hidden */
  5035. constructor(loader: GLTFLoader);
  5036. /** @hidden */
  5037. dispose(): void;
  5038. /** @hidden */
  5039. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  5040. }
  5041. }
  5042. declare module BABYLON.GLTF2.Loader.Extensions {
  5043. /**
  5044. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  5045. */
  5046. export class KHR_texture_transform implements IGLTFLoaderExtension {
  5047. /**
  5048. * The name of this extension.
  5049. */
  5050. readonly name: string;
  5051. /**
  5052. * Defines whether this extension is enabled.
  5053. */
  5054. enabled: boolean;
  5055. private _loader;
  5056. /** @hidden */
  5057. constructor(loader: GLTFLoader);
  5058. /** @hidden */
  5059. dispose(): void;
  5060. /** @hidden */
  5061. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  5062. }
  5063. }
  5064. declare module BABYLON.GLTF2.Loader.Extensions {
  5065. /**
  5066. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  5067. */
  5068. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  5069. /**
  5070. * The name of this extension.
  5071. */
  5072. readonly name: string;
  5073. /**
  5074. * Defines whether this extension is enabled.
  5075. */
  5076. enabled: boolean;
  5077. private _loader;
  5078. private _clips;
  5079. private _emitters;
  5080. /** @hidden */
  5081. constructor(loader: GLTFLoader);
  5082. /** @hidden */
  5083. dispose(): void;
  5084. /** @hidden */
  5085. onLoading(): void;
  5086. /** @hidden */
  5087. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  5088. /** @hidden */
  5089. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  5090. /** @hidden */
  5091. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  5092. private _loadClipAsync;
  5093. private _loadEmitterAsync;
  5094. private _getEventAction;
  5095. private _loadAnimationEventAsync;
  5096. }
  5097. }
  5098. declare module BABYLON.GLTF2.Loader.Extensions {
  5099. /**
  5100. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  5101. */
  5102. export class MSFT_lod implements IGLTFLoaderExtension {
  5103. /**
  5104. * The name of this extension.
  5105. */
  5106. readonly name: string;
  5107. /**
  5108. * Defines whether this extension is enabled.
  5109. */
  5110. enabled: boolean;
  5111. /**
  5112. * Defines a number that determines the order the extensions are applied.
  5113. */
  5114. order: number;
  5115. /**
  5116. * Maximum number of LODs to load, starting from the lowest LOD.
  5117. */
  5118. maxLODsToLoad: number;
  5119. /**
  5120. * Observable raised when all node LODs of one level are loaded.
  5121. * The event data is the index of the loaded LOD starting from zero.
  5122. * Dispose the loader to cancel the loading of the next level of LODs.
  5123. */
  5124. onNodeLODsLoadedObservable: Observable<number>;
  5125. /**
  5126. * Observable raised when all material LODs of one level are loaded.
  5127. * The event data is the index of the loaded LOD starting from zero.
  5128. * Dispose the loader to cancel the loading of the next level of LODs.
  5129. */
  5130. onMaterialLODsLoadedObservable: Observable<number>;
  5131. private _loader;
  5132. private _bufferLODs;
  5133. private _nodeIndexLOD;
  5134. private _nodeSignalLODs;
  5135. private _nodePromiseLODs;
  5136. private _nodeBufferLODs;
  5137. private _materialIndexLOD;
  5138. private _materialSignalLODs;
  5139. private _materialPromiseLODs;
  5140. private _materialBufferLODs;
  5141. /** @hidden */
  5142. constructor(loader: GLTFLoader);
  5143. /** @hidden */
  5144. dispose(): void;
  5145. /** @hidden */
  5146. onReady(): void;
  5147. /** @hidden */
  5148. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  5149. /** @hidden */
  5150. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  5151. /** @hidden */
  5152. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  5153. /** @hidden */
  5154. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  5155. /** @hidden */
  5156. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  5157. private _loadBufferLOD;
  5158. /**
  5159. * Gets an array of LOD properties from lowest to highest.
  5160. */
  5161. private _getLODs;
  5162. private _disposeTransformNode;
  5163. private _disposeMaterials;
  5164. }
  5165. }
  5166. declare module BABYLON.GLTF2.Loader.Extensions {
  5167. /** @hidden */
  5168. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  5169. readonly name: string;
  5170. enabled: boolean;
  5171. private _loader;
  5172. constructor(loader: GLTFLoader);
  5173. dispose(): void;
  5174. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  5175. }
  5176. }
  5177. declare module BABYLON.GLTF2.Loader.Extensions {
  5178. /** @hidden */
  5179. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  5180. readonly name: string;
  5181. enabled: boolean;
  5182. private _loader;
  5183. constructor(loader: GLTFLoader);
  5184. dispose(): void;
  5185. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  5186. }
  5187. }
  5188. declare module BABYLON.GLTF2.Loader.Extensions {
  5189. /**
  5190. * Store glTF extras (if present) in BJS objects' metadata
  5191. */
  5192. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  5193. /**
  5194. * The name of this extension.
  5195. */
  5196. readonly name: string;
  5197. /**
  5198. * Defines whether this extension is enabled.
  5199. */
  5200. enabled: boolean;
  5201. private _loader;
  5202. private _assignExtras;
  5203. /** @hidden */
  5204. constructor(loader: GLTFLoader);
  5205. /** @hidden */
  5206. dispose(): void;
  5207. /** @hidden */
  5208. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  5209. /** @hidden */
  5210. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  5211. /** @hidden */
  5212. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  5213. }
  5214. }
  5215. declare module BABYLON {
  5216. /**
  5217. * Class reading and parsing the MTL file bundled with the obj file.
  5218. */
  5219. export class MTLFileLoader {
  5220. /**
  5221. * Invert Y-Axis of referenced textures on load
  5222. */
  5223. static INVERT_TEXTURE_Y: boolean;
  5224. /**
  5225. * All material loaded from the mtl will be set here
  5226. */
  5227. materials: StandardMaterial[];
  5228. /**
  5229. * This function will read the mtl file and create each material described inside
  5230. * This function could be improve by adding :
  5231. * -some component missing (Ni, Tf...)
  5232. * -including the specific options available
  5233. *
  5234. * @param scene defines the scene the material will be created in
  5235. * @param data defines the mtl data to parse
  5236. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  5237. * @param forAssetContainer defines if the material should be registered in the scene
  5238. */
  5239. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  5240. /**
  5241. * Gets the texture for the material.
  5242. *
  5243. * If the material is imported from input file,
  5244. * We sanitize the url to ensure it takes the textre from aside the material.
  5245. *
  5246. * @param rootUrl The root url to load from
  5247. * @param value The value stored in the mtl
  5248. * @return The Texture
  5249. */
  5250. private static _getTexture;
  5251. }
  5252. }
  5253. declare module BABYLON {
  5254. /**
  5255. * Options for loading OBJ/MTL files
  5256. */
  5257. type MeshLoadOptions = {
  5258. /**
  5259. * Defines if UVs are optimized by default during load.
  5260. */
  5261. OptimizeWithUV: boolean;
  5262. /**
  5263. * Defines custom scaling of UV coordinates of loaded meshes.
  5264. */
  5265. UVScaling: Vector2;
  5266. /**
  5267. * Invert model on y-axis (does a model scaling inversion)
  5268. */
  5269. InvertY: boolean;
  5270. /**
  5271. * Invert Y-Axis of referenced textures on load
  5272. */
  5273. InvertTextureY: boolean;
  5274. /**
  5275. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  5276. */
  5277. ImportVertexColors: boolean;
  5278. /**
  5279. * Compute the normals for the model, even if normals are present in the file.
  5280. */
  5281. ComputeNormals: boolean;
  5282. /**
  5283. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  5284. */
  5285. SkipMaterials: boolean;
  5286. /**
  5287. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  5288. */
  5289. MaterialLoadingFailsSilently: boolean;
  5290. };
  5291. /**
  5292. * OBJ file type loader.
  5293. * This is a babylon scene loader plugin.
  5294. */
  5295. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  5296. /**
  5297. * Defines if UVs are optimized by default during load.
  5298. */
  5299. static OPTIMIZE_WITH_UV: boolean;
  5300. /**
  5301. * Invert model on y-axis (does a model scaling inversion)
  5302. */
  5303. static INVERT_Y: boolean;
  5304. /**
  5305. * Invert Y-Axis of referenced textures on load
  5306. */
  5307. static get INVERT_TEXTURE_Y(): boolean;
  5308. static set INVERT_TEXTURE_Y(value: boolean);
  5309. /**
  5310. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  5311. */
  5312. static IMPORT_VERTEX_COLORS: boolean;
  5313. /**
  5314. * Compute the normals for the model, even if normals are present in the file.
  5315. */
  5316. static COMPUTE_NORMALS: boolean;
  5317. /**
  5318. * Defines custom scaling of UV coordinates of loaded meshes.
  5319. */
  5320. static UV_SCALING: Vector2;
  5321. /**
  5322. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  5323. */
  5324. static SKIP_MATERIALS: boolean;
  5325. /**
  5326. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  5327. *
  5328. * Defaults to true for backwards compatibility.
  5329. */
  5330. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  5331. /**
  5332. * Defines the name of the plugin.
  5333. */
  5334. name: string;
  5335. /**
  5336. * Defines the extension the plugin is able to load.
  5337. */
  5338. extensions: string;
  5339. /** @hidden */
  5340. obj: RegExp;
  5341. /** @hidden */
  5342. group: RegExp;
  5343. /** @hidden */
  5344. mtllib: RegExp;
  5345. /** @hidden */
  5346. usemtl: RegExp;
  5347. /** @hidden */
  5348. smooth: RegExp;
  5349. /** @hidden */
  5350. vertexPattern: RegExp;
  5351. /** @hidden */
  5352. normalPattern: RegExp;
  5353. /** @hidden */
  5354. uvPattern: RegExp;
  5355. /** @hidden */
  5356. facePattern1: RegExp;
  5357. /** @hidden */
  5358. facePattern2: RegExp;
  5359. /** @hidden */
  5360. facePattern3: RegExp;
  5361. /** @hidden */
  5362. facePattern4: RegExp;
  5363. /** @hidden */
  5364. facePattern5: RegExp;
  5365. private _forAssetContainer;
  5366. private _meshLoadOptions;
  5367. /**
  5368. * Creates loader for .OBJ files
  5369. *
  5370. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  5371. */
  5372. constructor(meshLoadOptions?: MeshLoadOptions);
  5373. private static get currentMeshLoadOptions();
  5374. /**
  5375. * Calls synchronously the MTL file attached to this obj.
  5376. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  5377. * Without this function materials are not displayed in the first frame (but displayed after).
  5378. * In consequence it is impossible to get material information in your HTML file
  5379. *
  5380. * @param url The URL of the MTL file
  5381. * @param rootUrl
  5382. * @param onSuccess Callback function to be called when the MTL file is loaded
  5383. * @private
  5384. */
  5385. private _loadMTL;
  5386. /**
  5387. * Instantiates a OBJ file loader plugin.
  5388. * @returns the created plugin
  5389. */
  5390. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  5391. /**
  5392. * If the data string can be loaded directly.
  5393. *
  5394. * @param data string containing the file data
  5395. * @returns if the data can be loaded directly
  5396. */
  5397. canDirectLoad(data: string): boolean;
  5398. /**
  5399. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  5400. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  5401. * @param scene the scene the meshes should be added to
  5402. * @param data the OBJ data to load
  5403. * @param rootUrl root url to load from
  5404. * @param onProgress event that fires when loading progress has occured
  5405. * @param fileName Defines the name of the file to load
  5406. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  5407. */
  5408. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  5409. /**
  5410. * Imports all objects from the loaded OBJ data and adds them to the scene
  5411. * @param scene the scene the objects should be added to
  5412. * @param data the OBJ data to load
  5413. * @param rootUrl root url to load from
  5414. * @param onProgress event that fires when loading progress has occured
  5415. * @param fileName Defines the name of the file to load
  5416. * @returns a promise which completes when objects have been loaded to the scene
  5417. */
  5418. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  5419. /**
  5420. * Load into an asset container.
  5421. * @param scene The scene to load into
  5422. * @param data The data to import
  5423. * @param rootUrl The root url for scene and resources
  5424. * @param onProgress The callback when the load progresses
  5425. * @param fileName Defines the name of the file to load
  5426. * @returns The loaded asset container
  5427. */
  5428. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  5429. /**
  5430. * Read the OBJ file and create an Array of meshes.
  5431. * Each mesh contains all information given by the OBJ and the MTL file.
  5432. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  5433. *
  5434. * @param meshesNames
  5435. * @param scene Scene The scene where are displayed the data
  5436. * @param data String The content of the obj file
  5437. * @param rootUrl String The path to the folder
  5438. * @returns Array<AbstractMesh>
  5439. * @private
  5440. */
  5441. private _parseSolid;
  5442. }
  5443. }
  5444. declare module BABYLON {
  5445. /**
  5446. * STL file type loader.
  5447. * This is a babylon scene loader plugin.
  5448. */
  5449. export class STLFileLoader implements ISceneLoaderPlugin {
  5450. /** @hidden */
  5451. solidPattern: RegExp;
  5452. /** @hidden */
  5453. facetsPattern: RegExp;
  5454. /** @hidden */
  5455. normalPattern: RegExp;
  5456. /** @hidden */
  5457. vertexPattern: RegExp;
  5458. /**
  5459. * Defines the name of the plugin.
  5460. */
  5461. name: string;
  5462. /**
  5463. * Defines the extensions the stl loader is able to load.
  5464. * force data to come in as an ArrayBuffer
  5465. * we'll convert to string if it looks like it's an ASCII .stl
  5466. */
  5467. extensions: ISceneLoaderPluginExtensions;
  5468. /**
  5469. * Import meshes into a scene.
  5470. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  5471. * @param scene The scene to import into
  5472. * @param data The data to import
  5473. * @param rootUrl The root url for scene and resources
  5474. * @param meshes The meshes array to import into
  5475. * @param particleSystems The particle systems array to import into
  5476. * @param skeletons The skeletons array to import into
  5477. * @param onError The callback when import fails
  5478. * @returns True if successful or false otherwise
  5479. */
  5480. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  5481. /**
  5482. * Load into a scene.
  5483. * @param scene The scene to load into
  5484. * @param data The data to import
  5485. * @param rootUrl The root url for scene and resources
  5486. * @param onError The callback when import fails
  5487. * @returns true if successful or false otherwise
  5488. */
  5489. load(scene: Scene, data: any, rootUrl: string): boolean;
  5490. /**
  5491. * Load into an asset container.
  5492. * @param scene The scene to load into
  5493. * @param data The data to import
  5494. * @param rootUrl The root url for scene and resources
  5495. * @param onError The callback when import fails
  5496. * @returns The loaded asset container
  5497. */
  5498. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  5499. private _isBinary;
  5500. private _parseBinary;
  5501. private _parseASCII;
  5502. }
  5503. }