babylonjs.loaders.module.d.ts 228 KB

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