babylonjs.loaders.module.d.ts 225 KB

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