babylonjs.loaders.module.d.ts 212 KB

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