babylonjs.loaders.module.d.ts 228 KB

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