babylonjs.loaders.module.d.ts 229 KB

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