babylonjs.loaders.module.d.ts 231 KB

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