babylonjs.loaders.module.d.ts 222 KB

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