babylonjs.loaders.module.d.ts 176 KB

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