babylonjs.loaders.module.d.ts 218 KB

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