babylonjs.loaders.module.d.ts 190 KB

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