babylonjs.loaders.module.d.ts 227 KB

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