babylonjs.loaders.d.ts 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275
  1. declare module BABYLON {
  2. /**
  3. * Mode that determines the coordinate system to use.
  4. */
  5. export enum GLTFLoaderCoordinateSystemMode {
  6. /**
  7. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  8. */
  9. AUTO = 0,
  10. /**
  11. * Sets the useRightHandedSystem flag on the scene.
  12. */
  13. FORCE_RIGHT_HANDED = 1
  14. }
  15. /**
  16. * Mode that determines what animations will start.
  17. */
  18. export enum GLTFLoaderAnimationStartMode {
  19. /**
  20. * No animation will start.
  21. */
  22. NONE = 0,
  23. /**
  24. * The first animation will start.
  25. */
  26. FIRST = 1,
  27. /**
  28. * All animations will start.
  29. */
  30. ALL = 2
  31. }
  32. /**
  33. * Interface that contains the data for the glTF asset.
  34. */
  35. export interface IGLTFLoaderData {
  36. /**
  37. * The object that represents the glTF JSON.
  38. */
  39. json: Object;
  40. /**
  41. * The BIN chunk of a binary glTF.
  42. */
  43. bin: Nullable<IDataBuffer>;
  44. }
  45. /**
  46. * Interface for extending the loader.
  47. */
  48. export interface IGLTFLoaderExtension {
  49. /**
  50. * The name of this extension.
  51. */
  52. readonly name: string;
  53. /**
  54. * Defines whether this extension is enabled.
  55. */
  56. enabled: boolean;
  57. /**
  58. * Defines the order of this extension.
  59. * The loader sorts the extensions using these values when loading.
  60. */
  61. order?: number;
  62. }
  63. /**
  64. * Loader state.
  65. */
  66. export enum GLTFLoaderState {
  67. /**
  68. * The asset is loading.
  69. */
  70. LOADING = 0,
  71. /**
  72. * The asset is ready for rendering.
  73. */
  74. READY = 1,
  75. /**
  76. * The asset is completely loaded.
  77. */
  78. COMPLETE = 2
  79. }
  80. /** @hidden */
  81. export interface IGLTFLoader extends IDisposable {
  82. readonly state: Nullable<GLTFLoaderState>;
  83. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  84. meshes: AbstractMesh[];
  85. particleSystems: IParticleSystem[];
  86. skeletons: Skeleton[];
  87. animationGroups: AnimationGroup[];
  88. }>;
  89. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  90. }
  91. /**
  92. * File loader for loading glTF files into a scene.
  93. */
  94. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  95. /** @hidden */
  96. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  97. /** @hidden */
  98. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  99. /**
  100. * Raised when the asset has been parsed
  101. */
  102. onParsedObservable: Observable<IGLTFLoaderData>;
  103. private _onParsedObserver;
  104. /**
  105. * Raised when the asset has been parsed
  106. */
  107. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  108. /**
  109. * 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.
  110. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  111. * Defaults to true.
  112. * @hidden
  113. */
  114. static IncrementalLoading: boolean;
  115. /**
  116. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  117. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  118. * @hidden
  119. */
  120. static HomogeneousCoordinates: boolean;
  121. /**
  122. * The coordinate system mode. Defaults to AUTO.
  123. */
  124. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  125. /**
  126. * The animation start mode. Defaults to FIRST.
  127. */
  128. animationStartMode: GLTFLoaderAnimationStartMode;
  129. /**
  130. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  131. */
  132. compileMaterials: boolean;
  133. /**
  134. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  135. */
  136. useClipPlane: boolean;
  137. /**
  138. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  139. */
  140. compileShadowGenerators: boolean;
  141. /**
  142. * Defines if the Alpha blended materials are only applied as coverage.
  143. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  144. * If true, no extra effects are applied to transparent pixels.
  145. */
  146. transparencyAsCoverage: boolean;
  147. /**
  148. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  149. * Enabling will disable offline support and glTF validator.
  150. * Defaults to false.
  151. */
  152. useRangeRequests: boolean;
  153. /**
  154. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  155. */
  156. createInstances: boolean;
  157. /**
  158. * Function called before loading a url referenced by the asset.
  159. */
  160. preprocessUrlAsync: (url: string) => Promise<string>;
  161. /**
  162. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  163. */
  164. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  165. private _onMeshLoadedObserver;
  166. /**
  167. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  168. */
  169. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  170. /**
  171. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  172. */
  173. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  174. private _onTextureLoadedObserver;
  175. /**
  176. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  177. */
  178. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  179. /**
  180. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  181. */
  182. readonly onMaterialLoadedObservable: Observable<Material>;
  183. private _onMaterialLoadedObserver;
  184. /**
  185. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  186. */
  187. set onMaterialLoaded(callback: (material: Material) => void);
  188. /**
  189. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  190. */
  191. readonly onCameraLoadedObservable: Observable<Camera>;
  192. private _onCameraLoadedObserver;
  193. /**
  194. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  195. */
  196. set onCameraLoaded(callback: (camera: Camera) => void);
  197. /**
  198. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  199. * For assets with LODs, raised when all of the LODs are complete.
  200. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  201. */
  202. readonly onCompleteObservable: Observable<void>;
  203. private _onCompleteObserver;
  204. /**
  205. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  206. * For assets with LODs, raised when all of the LODs are complete.
  207. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  208. */
  209. set onComplete(callback: () => void);
  210. /**
  211. * Observable raised when an error occurs.
  212. */
  213. readonly onErrorObservable: Observable<any>;
  214. private _onErrorObserver;
  215. /**
  216. * Callback raised when an error occurs.
  217. */
  218. set onError(callback: (reason: any) => void);
  219. /**
  220. * Observable raised after the loader is disposed.
  221. */
  222. readonly onDisposeObservable: Observable<void>;
  223. private _onDisposeObserver;
  224. /**
  225. * Callback raised after the loader is disposed.
  226. */
  227. set onDispose(callback: () => void);
  228. /**
  229. * Observable raised after a loader extension is created.
  230. * Set additional options for a loader extension in this event.
  231. */
  232. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  233. private _onExtensionLoadedObserver;
  234. /**
  235. * Callback raised after a loader extension is created.
  236. */
  237. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  238. /**
  239. * Defines if the loader logging is enabled.
  240. */
  241. get loggingEnabled(): boolean;
  242. set loggingEnabled(value: boolean);
  243. /**
  244. * Defines if the loader should capture performance counters.
  245. */
  246. get capturePerformanceCounters(): boolean;
  247. set capturePerformanceCounters(value: boolean);
  248. /**
  249. * Defines if the loader should validate the asset.
  250. */
  251. validate: boolean;
  252. /**
  253. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  254. */
  255. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  256. private _onValidatedObserver;
  257. /**
  258. * Callback raised after a loader extension is created.
  259. */
  260. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  261. private _loader;
  262. /**
  263. * Name of the loader ("gltf")
  264. */
  265. name: string;
  266. /** @hidden */
  267. extensions: ISceneLoaderPluginExtensions;
  268. /**
  269. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  270. */
  271. dispose(): void;
  272. /** @hidden */
  273. _clear(): void;
  274. /** @hidden */
  275. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  276. /** @hidden */
  277. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  278. /** @hidden */
  279. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  280. meshes: AbstractMesh[];
  281. particleSystems: IParticleSystem[];
  282. skeletons: Skeleton[];
  283. animationGroups: AnimationGroup[];
  284. }>;
  285. /** @hidden */
  286. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  287. /** @hidden */
  288. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  289. /** @hidden */
  290. canDirectLoad(data: string): boolean;
  291. /** @hidden */
  292. directLoad(scene: Scene, data: string): any;
  293. /**
  294. * The callback that allows custom handling of the root url based on the response url.
  295. * @param rootUrl the original root url
  296. * @param responseURL the response url if available
  297. * @returns the new root url
  298. */
  299. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  300. /** @hidden */
  301. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  302. /**
  303. * The loader state or null if the loader is not active.
  304. */
  305. get loaderState(): Nullable<GLTFLoaderState>;
  306. /**
  307. * Returns a promise that resolves when the asset is completely loaded.
  308. * @returns a promise that resolves when the asset is completely loaded.
  309. */
  310. whenCompleteAsync(): Promise<void>;
  311. private _validateAsync;
  312. private _getLoader;
  313. private _parseJson;
  314. private _unpackBinaryAsync;
  315. private _unpackBinaryV1Async;
  316. private _unpackBinaryV2Async;
  317. private static _parseVersion;
  318. private static _compareVersion;
  319. private static readonly _logSpaces;
  320. private _logIndentLevel;
  321. private _loggingEnabled;
  322. /** @hidden */
  323. _log: (message: string) => void;
  324. /** @hidden */
  325. _logOpen(message: string): void;
  326. /** @hidden */
  327. _logClose(): void;
  328. private _logEnabled;
  329. private _logDisabled;
  330. private _capturePerformanceCounters;
  331. /** @hidden */
  332. _startPerformanceCounter: (counterName: string) => void;
  333. /** @hidden */
  334. _endPerformanceCounter: (counterName: string) => void;
  335. private _startPerformanceCounterEnabled;
  336. private _startPerformanceCounterDisabled;
  337. private _endPerformanceCounterEnabled;
  338. private _endPerformanceCounterDisabled;
  339. }
  340. }
  341. declare module BABYLON.GLTF1 {
  342. /**
  343. * Enums
  344. * @hidden
  345. */
  346. export enum EComponentType {
  347. BYTE = 5120,
  348. UNSIGNED_BYTE = 5121,
  349. SHORT = 5122,
  350. UNSIGNED_SHORT = 5123,
  351. FLOAT = 5126
  352. }
  353. /** @hidden */
  354. export enum EShaderType {
  355. FRAGMENT = 35632,
  356. VERTEX = 35633
  357. }
  358. /** @hidden */
  359. export enum EParameterType {
  360. BYTE = 5120,
  361. UNSIGNED_BYTE = 5121,
  362. SHORT = 5122,
  363. UNSIGNED_SHORT = 5123,
  364. INT = 5124,
  365. UNSIGNED_INT = 5125,
  366. FLOAT = 5126,
  367. FLOAT_VEC2 = 35664,
  368. FLOAT_VEC3 = 35665,
  369. FLOAT_VEC4 = 35666,
  370. INT_VEC2 = 35667,
  371. INT_VEC3 = 35668,
  372. INT_VEC4 = 35669,
  373. BOOL = 35670,
  374. BOOL_VEC2 = 35671,
  375. BOOL_VEC3 = 35672,
  376. BOOL_VEC4 = 35673,
  377. FLOAT_MAT2 = 35674,
  378. FLOAT_MAT3 = 35675,
  379. FLOAT_MAT4 = 35676,
  380. SAMPLER_2D = 35678
  381. }
  382. /** @hidden */
  383. export enum ETextureWrapMode {
  384. CLAMP_TO_EDGE = 33071,
  385. MIRRORED_REPEAT = 33648,
  386. REPEAT = 10497
  387. }
  388. /** @hidden */
  389. export enum ETextureFilterType {
  390. NEAREST = 9728,
  391. LINEAR = 9728,
  392. NEAREST_MIPMAP_NEAREST = 9984,
  393. LINEAR_MIPMAP_NEAREST = 9985,
  394. NEAREST_MIPMAP_LINEAR = 9986,
  395. LINEAR_MIPMAP_LINEAR = 9987
  396. }
  397. /** @hidden */
  398. export enum ETextureFormat {
  399. ALPHA = 6406,
  400. RGB = 6407,
  401. RGBA = 6408,
  402. LUMINANCE = 6409,
  403. LUMINANCE_ALPHA = 6410
  404. }
  405. /** @hidden */
  406. export enum ECullingType {
  407. FRONT = 1028,
  408. BACK = 1029,
  409. FRONT_AND_BACK = 1032
  410. }
  411. /** @hidden */
  412. export enum EBlendingFunction {
  413. ZERO = 0,
  414. ONE = 1,
  415. SRC_COLOR = 768,
  416. ONE_MINUS_SRC_COLOR = 769,
  417. DST_COLOR = 774,
  418. ONE_MINUS_DST_COLOR = 775,
  419. SRC_ALPHA = 770,
  420. ONE_MINUS_SRC_ALPHA = 771,
  421. DST_ALPHA = 772,
  422. ONE_MINUS_DST_ALPHA = 773,
  423. CONSTANT_COLOR = 32769,
  424. ONE_MINUS_CONSTANT_COLOR = 32770,
  425. CONSTANT_ALPHA = 32771,
  426. ONE_MINUS_CONSTANT_ALPHA = 32772,
  427. SRC_ALPHA_SATURATE = 776
  428. }
  429. /** @hidden */
  430. export interface IGLTFProperty {
  431. extensions?: {
  432. [key: string]: any;
  433. };
  434. extras?: Object;
  435. }
  436. /** @hidden */
  437. export interface IGLTFChildRootProperty extends IGLTFProperty {
  438. name?: string;
  439. }
  440. /** @hidden */
  441. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  442. bufferView: string;
  443. byteOffset: number;
  444. byteStride: number;
  445. count: number;
  446. type: string;
  447. componentType: EComponentType;
  448. max?: number[];
  449. min?: number[];
  450. name?: string;
  451. }
  452. /** @hidden */
  453. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  454. buffer: string;
  455. byteOffset: number;
  456. byteLength: number;
  457. byteStride: number;
  458. target?: number;
  459. }
  460. /** @hidden */
  461. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  462. uri: string;
  463. byteLength?: number;
  464. type?: string;
  465. }
  466. /** @hidden */
  467. export interface IGLTFShader extends IGLTFChildRootProperty {
  468. uri: string;
  469. type: EShaderType;
  470. }
  471. /** @hidden */
  472. export interface IGLTFProgram extends IGLTFChildRootProperty {
  473. attributes: string[];
  474. fragmentShader: string;
  475. vertexShader: string;
  476. }
  477. /** @hidden */
  478. export interface IGLTFTechniqueParameter {
  479. type: number;
  480. count?: number;
  481. semantic?: string;
  482. node?: string;
  483. value?: number | boolean | string | Array<any>;
  484. source?: string;
  485. babylonValue?: any;
  486. }
  487. /** @hidden */
  488. export interface IGLTFTechniqueCommonProfile {
  489. lightingModel: string;
  490. texcoordBindings: Object;
  491. parameters?: Array<any>;
  492. }
  493. /** @hidden */
  494. export interface IGLTFTechniqueStatesFunctions {
  495. blendColor?: number[];
  496. blendEquationSeparate?: number[];
  497. blendFuncSeparate?: number[];
  498. colorMask: boolean[];
  499. cullFace: number[];
  500. }
  501. /** @hidden */
  502. export interface IGLTFTechniqueStates {
  503. enable: number[];
  504. functions: IGLTFTechniqueStatesFunctions;
  505. }
  506. /** @hidden */
  507. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  508. parameters: {
  509. [key: string]: IGLTFTechniqueParameter;
  510. };
  511. program: string;
  512. attributes: {
  513. [key: string]: string;
  514. };
  515. uniforms: {
  516. [key: string]: string;
  517. };
  518. states: IGLTFTechniqueStates;
  519. }
  520. /** @hidden */
  521. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  522. technique?: string;
  523. values: string[];
  524. }
  525. /** @hidden */
  526. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  527. attributes: {
  528. [key: string]: string;
  529. };
  530. indices: string;
  531. material: string;
  532. mode?: number;
  533. }
  534. /** @hidden */
  535. export interface IGLTFMesh extends IGLTFChildRootProperty {
  536. primitives: IGLTFMeshPrimitive[];
  537. }
  538. /** @hidden */
  539. export interface IGLTFImage extends IGLTFChildRootProperty {
  540. uri: string;
  541. }
  542. /** @hidden */
  543. export interface IGLTFSampler extends IGLTFChildRootProperty {
  544. magFilter?: number;
  545. minFilter?: number;
  546. wrapS?: number;
  547. wrapT?: number;
  548. }
  549. /** @hidden */
  550. export interface IGLTFTexture extends IGLTFChildRootProperty {
  551. sampler: string;
  552. source: string;
  553. format?: ETextureFormat;
  554. internalFormat?: ETextureFormat;
  555. target?: number;
  556. type?: number;
  557. babylonTexture?: Texture;
  558. }
  559. /** @hidden */
  560. export interface IGLTFAmbienLight {
  561. color?: number[];
  562. }
  563. /** @hidden */
  564. export interface IGLTFDirectionalLight {
  565. color?: number[];
  566. }
  567. /** @hidden */
  568. export interface IGLTFPointLight {
  569. color?: number[];
  570. constantAttenuation?: number;
  571. linearAttenuation?: number;
  572. quadraticAttenuation?: number;
  573. }
  574. /** @hidden */
  575. export interface IGLTFSpotLight {
  576. color?: number[];
  577. constantAttenuation?: number;
  578. fallOfAngle?: number;
  579. fallOffExponent?: number;
  580. linearAttenuation?: number;
  581. quadraticAttenuation?: number;
  582. }
  583. /** @hidden */
  584. export interface IGLTFLight extends IGLTFChildRootProperty {
  585. type: string;
  586. }
  587. /** @hidden */
  588. export interface IGLTFCameraOrthographic {
  589. xmag: number;
  590. ymag: number;
  591. zfar: number;
  592. znear: number;
  593. }
  594. /** @hidden */
  595. export interface IGLTFCameraPerspective {
  596. aspectRatio: number;
  597. yfov: number;
  598. zfar: number;
  599. znear: number;
  600. }
  601. /** @hidden */
  602. export interface IGLTFCamera extends IGLTFChildRootProperty {
  603. type: string;
  604. }
  605. /** @hidden */
  606. export interface IGLTFAnimationChannelTarget {
  607. id: string;
  608. path: string;
  609. }
  610. /** @hidden */
  611. export interface IGLTFAnimationChannel {
  612. sampler: string;
  613. target: IGLTFAnimationChannelTarget;
  614. }
  615. /** @hidden */
  616. export interface IGLTFAnimationSampler {
  617. input: string;
  618. output: string;
  619. interpolation?: string;
  620. }
  621. /** @hidden */
  622. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  623. channels?: IGLTFAnimationChannel[];
  624. parameters?: {
  625. [key: string]: string;
  626. };
  627. samplers?: {
  628. [key: string]: IGLTFAnimationSampler;
  629. };
  630. }
  631. /** @hidden */
  632. export interface IGLTFNodeInstanceSkin {
  633. skeletons: string[];
  634. skin: string;
  635. meshes: string[];
  636. }
  637. /** @hidden */
  638. export interface IGLTFSkins extends IGLTFChildRootProperty {
  639. bindShapeMatrix: number[];
  640. inverseBindMatrices: string;
  641. jointNames: string[];
  642. babylonSkeleton?: Skeleton;
  643. }
  644. /** @hidden */
  645. export interface IGLTFNode extends IGLTFChildRootProperty {
  646. camera?: string;
  647. children: string[];
  648. skin?: string;
  649. jointName?: string;
  650. light?: string;
  651. matrix: number[];
  652. mesh?: string;
  653. meshes?: string[];
  654. rotation?: number[];
  655. scale?: number[];
  656. translation?: number[];
  657. babylonNode?: Node;
  658. }
  659. /** @hidden */
  660. export interface IGLTFScene extends IGLTFChildRootProperty {
  661. nodes: string[];
  662. }
  663. /** @hidden */
  664. export interface IGLTFRuntime {
  665. extensions: {
  666. [key: string]: any;
  667. };
  668. accessors: {
  669. [key: string]: IGLTFAccessor;
  670. };
  671. buffers: {
  672. [key: string]: IGLTFBuffer;
  673. };
  674. bufferViews: {
  675. [key: string]: IGLTFBufferView;
  676. };
  677. meshes: {
  678. [key: string]: IGLTFMesh;
  679. };
  680. lights: {
  681. [key: string]: IGLTFLight;
  682. };
  683. cameras: {
  684. [key: string]: IGLTFCamera;
  685. };
  686. nodes: {
  687. [key: string]: IGLTFNode;
  688. };
  689. images: {
  690. [key: string]: IGLTFImage;
  691. };
  692. textures: {
  693. [key: string]: IGLTFTexture;
  694. };
  695. shaders: {
  696. [key: string]: IGLTFShader;
  697. };
  698. programs: {
  699. [key: string]: IGLTFProgram;
  700. };
  701. samplers: {
  702. [key: string]: IGLTFSampler;
  703. };
  704. techniques: {
  705. [key: string]: IGLTFTechnique;
  706. };
  707. materials: {
  708. [key: string]: IGLTFMaterial;
  709. };
  710. animations: {
  711. [key: string]: IGLTFAnimation;
  712. };
  713. skins: {
  714. [key: string]: IGLTFSkins;
  715. };
  716. currentScene?: Object;
  717. scenes: {
  718. [key: string]: IGLTFScene;
  719. };
  720. extensionsUsed: string[];
  721. extensionsRequired?: string[];
  722. buffersCount: number;
  723. shaderscount: number;
  724. scene: Scene;
  725. rootUrl: string;
  726. loadedBufferCount: number;
  727. loadedBufferViews: {
  728. [name: string]: ArrayBufferView;
  729. };
  730. loadedShaderCount: number;
  731. importOnlyMeshes: boolean;
  732. importMeshesNames?: string[];
  733. dummyNodes: Node[];
  734. }
  735. /** @hidden */
  736. export interface INodeToRoot {
  737. bone: Bone;
  738. node: IGLTFNode;
  739. id: string;
  740. }
  741. /** @hidden */
  742. export interface IJointNode {
  743. node: IGLTFNode;
  744. id: string;
  745. }
  746. }
  747. declare module BABYLON.GLTF1 {
  748. /**
  749. * Utils functions for GLTF
  750. * @hidden
  751. */
  752. export class GLTFUtils {
  753. /**
  754. * Sets the given "parameter" matrix
  755. * @param scene: the Scene object
  756. * @param source: the source node where to pick the matrix
  757. * @param parameter: the GLTF technique parameter
  758. * @param uniformName: the name of the shader's uniform
  759. * @param shaderMaterial: the shader material
  760. */
  761. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  762. /**
  763. * Sets the given "parameter" matrix
  764. * @param shaderMaterial: the shader material
  765. * @param uniform: the name of the shader's uniform
  766. * @param value: the value of the uniform
  767. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  768. */
  769. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  770. /**
  771. * Returns the wrap mode of the texture
  772. * @param mode: the mode value
  773. */
  774. static GetWrapMode(mode: number): number;
  775. /**
  776. * Returns the byte stride giving an accessor
  777. * @param accessor: the GLTF accessor objet
  778. */
  779. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  780. /**
  781. * Returns the texture filter mode giving a mode value
  782. * @param mode: the filter mode value
  783. */
  784. static GetTextureFilterMode(mode: number): ETextureFilterType;
  785. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  786. /**
  787. * Returns a buffer from its accessor
  788. * @param gltfRuntime: the GLTF runtime
  789. * @param accessor: the GLTF accessor
  790. */
  791. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  792. /**
  793. * Decodes a buffer view into a string
  794. * @param view: the buffer view
  795. */
  796. static DecodeBufferToText(view: ArrayBufferView): string;
  797. /**
  798. * Returns the default material of gltf. Related to
  799. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  800. * @param scene: the Babylon.js scene
  801. */
  802. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  803. private static _DefaultMaterial;
  804. }
  805. }
  806. declare module BABYLON.GLTF1 {
  807. /**
  808. * Implementation of the base glTF spec
  809. * @hidden
  810. */
  811. export class GLTFLoaderBase {
  812. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  813. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  814. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  815. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  816. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  817. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  818. }
  819. /**
  820. * glTF V1 Loader
  821. * @hidden
  822. */
  823. export class GLTFLoader implements IGLTFLoader {
  824. static Extensions: {
  825. [name: string]: GLTFLoaderExtension;
  826. };
  827. static RegisterExtension(extension: GLTFLoaderExtension): void;
  828. state: Nullable<GLTFLoaderState>;
  829. dispose(): void;
  830. private _importMeshAsync;
  831. /**
  832. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  833. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  834. * @param scene the scene the meshes should be added to
  835. * @param data gltf data containing information of the meshes in a loaded file
  836. * @param rootUrl root url to load from
  837. * @param onProgress event that fires when loading progress has occured
  838. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  839. */
  840. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  841. meshes: AbstractMesh[];
  842. particleSystems: IParticleSystem[];
  843. skeletons: Skeleton[];
  844. animationGroups: AnimationGroup[];
  845. }>;
  846. private _loadAsync;
  847. /**
  848. * Imports all objects from a loaded gltf file and adds them to the scene
  849. * @param scene the scene the objects should be added to
  850. * @param data gltf data containing information of the meshes in a loaded file
  851. * @param rootUrl root url to load from
  852. * @param onProgress event that fires when loading progress has occured
  853. * @returns a promise which completes when objects have been loaded to the scene
  854. */
  855. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  856. private _loadShadersAsync;
  857. private _loadBuffersAsync;
  858. private _createNodes;
  859. }
  860. /** @hidden */
  861. export abstract class GLTFLoaderExtension {
  862. private _name;
  863. constructor(name: string);
  864. get name(): string;
  865. /**
  866. * Defines an override for loading the runtime
  867. * Return true to stop further extensions from loading the runtime
  868. */
  869. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  870. /**
  871. * Defines an onverride for creating gltf runtime
  872. * Return true to stop further extensions from creating the runtime
  873. */
  874. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  875. /**
  876. * Defines an override for loading buffers
  877. * Return true to stop further extensions from loading this buffer
  878. */
  879. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  880. /**
  881. * Defines an override for loading texture buffers
  882. * Return true to stop further extensions from loading this texture data
  883. */
  884. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  885. /**
  886. * Defines an override for creating textures
  887. * Return true to stop further extensions from loading this texture
  888. */
  889. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  890. /**
  891. * Defines an override for loading shader strings
  892. * Return true to stop further extensions from loading this shader data
  893. */
  894. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  895. /**
  896. * Defines an override for loading materials
  897. * Return true to stop further extensions from loading this material
  898. */
  899. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  900. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  901. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  902. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  903. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  904. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  905. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  906. private static LoadTextureBufferAsync;
  907. private static CreateTextureAsync;
  908. private static ApplyExtensions;
  909. }
  910. }
  911. declare module BABYLON.GLTF1 {
  912. /** @hidden */
  913. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  914. private _bin;
  915. constructor();
  916. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  917. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  918. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  919. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  920. }
  921. }
  922. declare module BABYLON.GLTF1 {
  923. /** @hidden */
  924. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  925. constructor();
  926. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  927. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  928. private _loadTexture;
  929. }
  930. }
  931. declare module BABYLON.GLTF2.Loader {
  932. /**
  933. * Loader interface with an index field.
  934. */
  935. export interface IArrayItem {
  936. /**
  937. * The index of this item in the array.
  938. */
  939. index: number;
  940. }
  941. /**
  942. * Loader interface with additional members.
  943. */
  944. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  945. /** @hidden */
  946. _data?: Promise<ArrayBufferView>;
  947. /** @hidden */
  948. _babylonVertexBuffer?: Promise<VertexBuffer>;
  949. }
  950. /**
  951. * Loader interface with additional members.
  952. */
  953. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  954. }
  955. /** @hidden */
  956. export interface _IAnimationSamplerData {
  957. input: Float32Array;
  958. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  959. output: Float32Array;
  960. }
  961. /**
  962. * Loader interface with additional members.
  963. */
  964. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  965. /** @hidden */
  966. _data?: Promise<_IAnimationSamplerData>;
  967. }
  968. /**
  969. * Loader interface with additional members.
  970. */
  971. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  972. channels: IAnimationChannel[];
  973. samplers: IAnimationSampler[];
  974. /** @hidden */
  975. _babylonAnimationGroup?: AnimationGroup;
  976. }
  977. /**
  978. * Loader interface with additional members.
  979. */
  980. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  981. /** @hidden */
  982. _data?: Promise<ArrayBufferView>;
  983. }
  984. /**
  985. * Loader interface with additional members.
  986. */
  987. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  988. /** @hidden */
  989. _data?: Promise<ArrayBufferView>;
  990. /** @hidden */
  991. _babylonBuffer?: Promise<Buffer>;
  992. }
  993. /**
  994. * Loader interface with additional members.
  995. */
  996. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  997. }
  998. /**
  999. * Loader interface with additional members.
  1000. */
  1001. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  1002. /** @hidden */
  1003. _data?: Promise<ArrayBufferView>;
  1004. }
  1005. /**
  1006. * Loader interface with additional members.
  1007. */
  1008. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  1009. }
  1010. /**
  1011. * Loader interface with additional members.
  1012. */
  1013. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  1014. }
  1015. /**
  1016. * Loader interface with additional members.
  1017. */
  1018. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  1019. baseColorTexture?: ITextureInfo;
  1020. metallicRoughnessTexture?: ITextureInfo;
  1021. }
  1022. /**
  1023. * Loader interface with additional members.
  1024. */
  1025. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  1026. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  1027. normalTexture?: IMaterialNormalTextureInfo;
  1028. occlusionTexture?: IMaterialOcclusionTextureInfo;
  1029. emissiveTexture?: ITextureInfo;
  1030. /** @hidden */
  1031. _data?: {
  1032. [babylonDrawMode: number]: {
  1033. babylonMaterial: Material;
  1034. babylonMeshes: AbstractMesh[];
  1035. promise: Promise<void>;
  1036. };
  1037. };
  1038. }
  1039. /**
  1040. * Loader interface with additional members.
  1041. */
  1042. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  1043. primitives: IMeshPrimitive[];
  1044. }
  1045. /**
  1046. * Loader interface with additional members.
  1047. */
  1048. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  1049. /** @hidden */
  1050. _instanceData?: {
  1051. babylonSourceMesh: Mesh;
  1052. promise: Promise<any>;
  1053. };
  1054. }
  1055. /**
  1056. * Loader interface with additional members.
  1057. */
  1058. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  1059. /**
  1060. * The parent glTF node.
  1061. */
  1062. parent?: INode;
  1063. /** @hidden */
  1064. _babylonTransformNode?: TransformNode;
  1065. /** @hidden */
  1066. _primitiveBabylonMeshes?: AbstractMesh[];
  1067. /** @hidden */
  1068. _babylonBones?: Bone[];
  1069. /** @hidden */
  1070. _numMorphTargets?: number;
  1071. }
  1072. /** @hidden */
  1073. export interface _ISamplerData {
  1074. noMipMaps: boolean;
  1075. samplingMode: number;
  1076. wrapU: number;
  1077. wrapV: number;
  1078. }
  1079. /**
  1080. * Loader interface with additional members.
  1081. */
  1082. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  1083. /** @hidden */
  1084. _data?: _ISamplerData;
  1085. }
  1086. /**
  1087. * Loader interface with additional members.
  1088. */
  1089. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  1090. }
  1091. /**
  1092. * Loader interface with additional members.
  1093. */
  1094. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  1095. /** @hidden */
  1096. _data?: {
  1097. babylonSkeleton: Skeleton;
  1098. promise: Promise<void>;
  1099. };
  1100. }
  1101. /**
  1102. * Loader interface with additional members.
  1103. */
  1104. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  1105. }
  1106. /**
  1107. * Loader interface with additional members.
  1108. */
  1109. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  1110. }
  1111. /**
  1112. * Loader interface with additional members.
  1113. */
  1114. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  1115. accessors?: IAccessor[];
  1116. animations?: IAnimation[];
  1117. buffers?: IBuffer[];
  1118. bufferViews?: IBufferView[];
  1119. cameras?: ICamera[];
  1120. images?: IImage[];
  1121. materials?: IMaterial[];
  1122. meshes?: IMesh[];
  1123. nodes?: INode[];
  1124. samplers?: ISampler[];
  1125. scenes?: IScene[];
  1126. skins?: ISkin[];
  1127. textures?: ITexture[];
  1128. }
  1129. }
  1130. declare module BABYLON.GLTF2 {
  1131. /**
  1132. * Interface for a glTF loader extension.
  1133. */
  1134. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  1135. /**
  1136. * Called after the loader state changes to LOADING.
  1137. */
  1138. onLoading?(): void;
  1139. /**
  1140. * Called after the loader state changes to READY.
  1141. */
  1142. onReady?(): void;
  1143. /**
  1144. * Define this method to modify the default behavior when loading scenes.
  1145. * @param context The context when loading the asset
  1146. * @param scene The glTF scene property
  1147. * @returns A promise that resolves when the load is complete or null if not handled
  1148. */
  1149. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  1150. /**
  1151. * Define this method to modify the default behavior when loading nodes.
  1152. * @param context The context when loading the asset
  1153. * @param node The glTF node property
  1154. * @param assign A function called synchronously after parsing the glTF properties
  1155. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  1156. */
  1157. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1158. /**
  1159. * Define this method to modify the default behavior when loading cameras.
  1160. * @param context The context when loading the asset
  1161. * @param camera The glTF camera property
  1162. * @param assign A function called synchronously after parsing the glTF properties
  1163. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  1164. */
  1165. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1166. /**
  1167. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  1168. * @param context The context when loading the asset
  1169. * @param primitive The glTF mesh primitive property
  1170. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  1171. */
  1172. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1173. /**
  1174. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  1175. * @param context The context when loading the asset
  1176. * @param name The mesh name when loading the asset
  1177. * @param node The glTF node when loading the asset
  1178. * @param mesh The glTF mesh when loading the asset
  1179. * @param primitive The glTF mesh primitive property
  1180. * @param assign A function called synchronously after parsing the glTF properties
  1181. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  1182. */
  1183. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  1184. /**
  1185. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  1186. * @param context The context when loading the asset
  1187. * @param material The glTF material property
  1188. * @param assign A function called synchronously after parsing the glTF properties
  1189. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  1190. */
  1191. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1192. /**
  1193. * Define this method to modify the default behavior when creating materials.
  1194. * @param context The context when loading the asset
  1195. * @param material The glTF material property
  1196. * @param babylonDrawMode The draw mode for the Babylon material
  1197. * @returns The Babylon material or null if not handled
  1198. */
  1199. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1200. /**
  1201. * Define this method to modify the default behavior when loading material properties.
  1202. * @param context The context when loading the asset
  1203. * @param material The glTF material property
  1204. * @param babylonMaterial The Babylon material
  1205. * @returns A promise that resolves when the load is complete or null if not handled
  1206. */
  1207. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1208. /**
  1209. * Define this method to modify the default behavior when loading texture infos.
  1210. * @param context The context when loading the asset
  1211. * @param textureInfo The glTF texture info property
  1212. * @param assign A function called synchronously after parsing the glTF properties
  1213. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  1214. */
  1215. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1216. /**
  1217. * Define this method to modify the default behavior when loading animations.
  1218. * @param context The context when loading the asset
  1219. * @param animation The glTF animation property
  1220. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  1221. */
  1222. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1223. /**
  1224. * @hidden Define this method to modify the default behavior when loading skins.
  1225. * @param context The context when loading the asset
  1226. * @param node The glTF node property
  1227. * @param skin The glTF skin property
  1228. * @returns A promise that resolves when the load is complete or null if not handled
  1229. */
  1230. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  1231. /**
  1232. * @hidden Define this method to modify the default behavior when loading uris.
  1233. * @param context The context when loading the asset
  1234. * @param property The glTF property associated with the uri
  1235. * @param uri The uri to load
  1236. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1237. */
  1238. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1239. /**
  1240. * Define this method to modify the default behavior when loading buffer views.
  1241. * @param context The context when loading the asset
  1242. * @param bufferView The glTF buffer view property
  1243. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1244. */
  1245. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  1246. /**
  1247. * Define this method to modify the default behavior when loading buffers.
  1248. * @param context The context when loading the asset
  1249. * @param buffer The glTF buffer property
  1250. * @param byteOffset The byte offset to load
  1251. * @param byteLength The byte length to load
  1252. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  1253. */
  1254. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  1255. }
  1256. }
  1257. declare module BABYLON.GLTF2 {
  1258. /**
  1259. * Helper class for working with arrays when loading the glTF asset
  1260. */
  1261. export class ArrayItem {
  1262. /**
  1263. * Gets an item from the given array.
  1264. * @param context The context when loading the asset
  1265. * @param array The array to get the item from
  1266. * @param index The index to the array
  1267. * @returns The array item
  1268. */
  1269. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  1270. /**
  1271. * Assign an `index` field to each item of the given array.
  1272. * @param array The array of items
  1273. */
  1274. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  1275. }
  1276. /**
  1277. * The glTF 2.0 loader
  1278. */
  1279. export class GLTFLoader implements IGLTFLoader {
  1280. /** @hidden */
  1281. _completePromises: Promise<any>[];
  1282. private _disposed;
  1283. private _parent;
  1284. private _state;
  1285. private _extensions;
  1286. private _rootUrl;
  1287. private _fileName;
  1288. private _uniqueRootUrl;
  1289. private _gltf;
  1290. private _bin;
  1291. private _babylonScene;
  1292. private _rootBabylonMesh;
  1293. private _defaultBabylonMaterialData;
  1294. private _progressCallback?;
  1295. private _requests;
  1296. private static readonly _DefaultSampler;
  1297. private static _RegisteredExtensions;
  1298. /**
  1299. * Registers a loader extension.
  1300. * @param name The name of the loader extension.
  1301. * @param factory The factory function that creates the loader extension.
  1302. */
  1303. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  1304. /**
  1305. * Unregisters a loader extension.
  1306. * @param name The name of the loader extension.
  1307. * @returns A boolean indicating whether the extension has been unregistered
  1308. */
  1309. static UnregisterExtension(name: string): boolean;
  1310. /**
  1311. * Gets the loader state.
  1312. */
  1313. get state(): Nullable<GLTFLoaderState>;
  1314. /**
  1315. * The object that represents the glTF JSON.
  1316. */
  1317. get gltf(): IGLTF;
  1318. /**
  1319. * The BIN chunk of a binary glTF.
  1320. */
  1321. get bin(): Nullable<IDataBuffer>;
  1322. /**
  1323. * The parent file loader.
  1324. */
  1325. get parent(): GLTFFileLoader;
  1326. /**
  1327. * The Babylon scene when loading the asset.
  1328. */
  1329. get babylonScene(): Scene;
  1330. /**
  1331. * The root Babylon mesh when loading the asset.
  1332. */
  1333. get rootBabylonMesh(): Mesh;
  1334. /** @hidden */
  1335. constructor(parent: GLTFFileLoader);
  1336. /** @hidden */
  1337. dispose(): void;
  1338. /** @hidden */
  1339. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  1340. meshes: AbstractMesh[];
  1341. particleSystems: IParticleSystem[];
  1342. skeletons: Skeleton[];
  1343. animationGroups: AnimationGroup[];
  1344. }>;
  1345. /** @hidden */
  1346. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  1347. private _loadAsync;
  1348. private _loadData;
  1349. private _setupData;
  1350. private _loadExtensions;
  1351. private _checkExtensions;
  1352. private _setState;
  1353. private _createRootNode;
  1354. /**
  1355. * Loads a glTF scene.
  1356. * @param context The context when loading the asset
  1357. * @param scene The glTF scene property
  1358. * @returns A promise that resolves when the load is complete
  1359. */
  1360. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  1361. private _forEachPrimitive;
  1362. private _getMeshes;
  1363. private _getSkeletons;
  1364. private _getAnimationGroups;
  1365. private _startAnimations;
  1366. /**
  1367. * Loads a glTF node.
  1368. * @param context The context when loading the asset
  1369. * @param node The glTF node property
  1370. * @param assign A function called synchronously after parsing the glTF properties
  1371. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  1372. */
  1373. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  1374. private _loadMeshAsync;
  1375. /**
  1376. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  1377. * @param context The context when loading the asset
  1378. * @param name The mesh name when loading the asset
  1379. * @param node The glTF node when loading the asset
  1380. * @param mesh The glTF mesh when loading the asset
  1381. * @param primitive The glTF mesh primitive property
  1382. * @param assign A function called synchronously after parsing the glTF properties
  1383. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  1384. */
  1385. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  1386. private _loadVertexDataAsync;
  1387. private _createMorphTargets;
  1388. private _loadMorphTargetsAsync;
  1389. private _loadMorphTargetVertexDataAsync;
  1390. private static _LoadTransform;
  1391. private _loadSkinAsync;
  1392. private _loadBones;
  1393. private _loadBone;
  1394. private _loadSkinInverseBindMatricesDataAsync;
  1395. private _updateBoneMatrices;
  1396. private _getNodeMatrix;
  1397. /**
  1398. * Loads a glTF camera.
  1399. * @param context The context when loading the asset
  1400. * @param camera The glTF camera property
  1401. * @param assign A function called synchronously after parsing the glTF properties
  1402. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  1403. */
  1404. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  1405. private _loadAnimationsAsync;
  1406. /**
  1407. * Loads a glTF animation.
  1408. * @param context The context when loading the asset
  1409. * @param animation The glTF animation property
  1410. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  1411. */
  1412. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  1413. /**
  1414. * @hidden Loads a glTF animation channel.
  1415. * @param context The context when loading the asset
  1416. * @param animationContext The context of the animation when loading the asset
  1417. * @param animation The glTF animation property
  1418. * @param channel The glTF animation channel property
  1419. * @param babylonAnimationGroup The babylon animation group property
  1420. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  1421. * @returns A void promise when the channel load is complete
  1422. */
  1423. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  1424. private _loadAnimationSamplerAsync;
  1425. private _loadBufferAsync;
  1426. /**
  1427. * Loads a glTF buffer view.
  1428. * @param context The context when loading the asset
  1429. * @param bufferView The glTF buffer view property
  1430. * @returns A promise that resolves with the loaded data when the load is complete
  1431. */
  1432. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  1433. private _loadAccessorAsync;
  1434. private _loadFloatAccessorAsync;
  1435. private _loadIndicesAccessorAsync;
  1436. private _loadVertexBufferViewAsync;
  1437. private _loadVertexAccessorAsync;
  1438. private _loadMaterialMetallicRoughnessPropertiesAsync;
  1439. /** @hidden */
  1440. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  1441. private _createDefaultMaterial;
  1442. /**
  1443. * Creates a Babylon material from a glTF material.
  1444. * @param context The context when loading the asset
  1445. * @param material The glTF material property
  1446. * @param babylonDrawMode The draw mode for the Babylon material
  1447. * @returns The Babylon material
  1448. */
  1449. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  1450. /**
  1451. * Loads properties from a glTF material into a Babylon material.
  1452. * @param context The context when loading the asset
  1453. * @param material The glTF material property
  1454. * @param babylonMaterial The Babylon material
  1455. * @returns A promise that resolves when the load is complete
  1456. */
  1457. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1458. /**
  1459. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  1460. * @param context The context when loading the asset
  1461. * @param material The glTF material property
  1462. * @param babylonMaterial The Babylon material
  1463. * @returns A promise that resolves when the load is complete
  1464. */
  1465. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  1466. /**
  1467. * Loads the alpha properties from a glTF material into a Babylon material.
  1468. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  1469. * @param context The context when loading the asset
  1470. * @param material The glTF material property
  1471. * @param babylonMaterial The Babylon material
  1472. */
  1473. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  1474. /**
  1475. * Loads a glTF texture info.
  1476. * @param context The context when loading the asset
  1477. * @param textureInfo The glTF texture info property
  1478. * @param assign A function called synchronously after parsing the glTF properties
  1479. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  1480. */
  1481. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  1482. private _loadTextureAsync;
  1483. private _loadSampler;
  1484. /**
  1485. * Loads a glTF image.
  1486. * @param context The context when loading the asset
  1487. * @param image The glTF image property
  1488. * @returns A promise that resolves with the loaded data when the load is complete
  1489. */
  1490. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  1491. /**
  1492. * Loads a glTF uri.
  1493. * @param context The context when loading the asset
  1494. * @param property The glTF property associated with the uri
  1495. * @param uri The base64 or relative uri
  1496. * @returns A promise that resolves with the loaded data when the load is complete
  1497. */
  1498. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  1499. private _onProgress;
  1500. /**
  1501. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  1502. * @param babylonObject the Babylon object with metadata
  1503. * @param pointer the JSON pointer
  1504. */
  1505. static AddPointerMetadata(babylonObject: {
  1506. metadata: any;
  1507. }, pointer: string): void;
  1508. private static _GetTextureWrapMode;
  1509. private static _GetTextureSamplingMode;
  1510. private static _GetTypedArrayConstructor;
  1511. private static _GetTypedArray;
  1512. private static _GetNumComponents;
  1513. private static _ValidateUri;
  1514. private static _GetDrawMode;
  1515. private _compileMaterialsAsync;
  1516. private _compileShadowGeneratorsAsync;
  1517. private _forEachExtensions;
  1518. private _applyExtensions;
  1519. private _extensionsOnLoading;
  1520. private _extensionsOnReady;
  1521. private _extensionsLoadSceneAsync;
  1522. private _extensionsLoadNodeAsync;
  1523. private _extensionsLoadCameraAsync;
  1524. private _extensionsLoadVertexDataAsync;
  1525. private _extensionsLoadMeshPrimitiveAsync;
  1526. private _extensionsLoadMaterialAsync;
  1527. private _extensionsCreateMaterial;
  1528. private _extensionsLoadMaterialPropertiesAsync;
  1529. private _extensionsLoadTextureInfoAsync;
  1530. private _extensionsLoadAnimationAsync;
  1531. private _extensionsLoadSkinAsync;
  1532. private _extensionsLoadUriAsync;
  1533. private _extensionsLoadBufferViewAsync;
  1534. private _extensionsLoadBufferAsync;
  1535. /**
  1536. * Helper method called by a loader extension to load an glTF extension.
  1537. * @param context The context when loading the asset
  1538. * @param property The glTF property to load the extension from
  1539. * @param extensionName The name of the extension to load
  1540. * @param actionAsync The action to run
  1541. * @returns The promise returned by actionAsync or null if the extension does not exist
  1542. */
  1543. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1544. /**
  1545. * Helper method called by a loader extension to load a glTF extra.
  1546. * @param context The context when loading the asset
  1547. * @param property The glTF property to load the extra from
  1548. * @param extensionName The name of the extension to load
  1549. * @param actionAsync The action to run
  1550. * @returns The promise returned by actionAsync or null if the extra does not exist
  1551. */
  1552. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  1553. /**
  1554. * Checks for presence of an extension.
  1555. * @param name The name of the extension to check
  1556. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  1557. */
  1558. isExtensionUsed(name: string): boolean;
  1559. /**
  1560. * Increments the indentation level and logs a message.
  1561. * @param message The message to log
  1562. */
  1563. logOpen(message: string): void;
  1564. /**
  1565. * Decrements the indentation level.
  1566. */
  1567. logClose(): void;
  1568. /**
  1569. * Logs a message
  1570. * @param message The message to log
  1571. */
  1572. log(message: string): void;
  1573. /**
  1574. * Starts a performance counter.
  1575. * @param counterName The name of the performance counter
  1576. */
  1577. startPerformanceCounter(counterName: string): void;
  1578. /**
  1579. * Ends a performance counter.
  1580. * @param counterName The name of the performance counter
  1581. */
  1582. endPerformanceCounter(counterName: string): void;
  1583. }
  1584. }
  1585. declare module BABYLON.GLTF2.Loader.Extensions {
  1586. /**
  1587. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  1588. */
  1589. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  1590. /**
  1591. * The name of this extension.
  1592. */
  1593. readonly name: string;
  1594. /**
  1595. * Defines whether this extension is enabled.
  1596. */
  1597. enabled: boolean;
  1598. private _loader;
  1599. private _lights?;
  1600. /** @hidden */
  1601. constructor(loader: GLTFLoader);
  1602. /** @hidden */
  1603. dispose(): void;
  1604. /** @hidden */
  1605. onLoading(): void;
  1606. /** @hidden */
  1607. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1608. private _loadLightAsync;
  1609. }
  1610. }
  1611. declare module BABYLON.GLTF2.Loader.Extensions {
  1612. /**
  1613. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  1614. */
  1615. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  1616. /**
  1617. * The name of this extension.
  1618. */
  1619. readonly name: string;
  1620. /**
  1621. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  1622. */
  1623. dracoCompression?: DracoCompression;
  1624. /**
  1625. * Defines whether this extension is enabled.
  1626. */
  1627. enabled: boolean;
  1628. private _loader;
  1629. /** @hidden */
  1630. constructor(loader: GLTFLoader);
  1631. /** @hidden */
  1632. dispose(): void;
  1633. /** @hidden */
  1634. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  1635. }
  1636. }
  1637. declare module BABYLON.GLTF2.Loader.Extensions {
  1638. /**
  1639. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  1640. */
  1641. export class KHR_lights implements IGLTFLoaderExtension {
  1642. /**
  1643. * The name of this extension.
  1644. */
  1645. readonly name: string;
  1646. /**
  1647. * Defines whether this extension is enabled.
  1648. */
  1649. enabled: boolean;
  1650. private _loader;
  1651. private _lights?;
  1652. /** @hidden */
  1653. constructor(loader: GLTFLoader);
  1654. /** @hidden */
  1655. dispose(): void;
  1656. /** @hidden */
  1657. onLoading(): void;
  1658. /** @hidden */
  1659. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1660. }
  1661. }
  1662. declare module BABYLON.GLTF2.Loader.Extensions {
  1663. /**
  1664. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  1665. */
  1666. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  1667. /**
  1668. * The name of this extension.
  1669. */
  1670. readonly name: string;
  1671. /**
  1672. * Defines whether this extension is enabled.
  1673. */
  1674. enabled: boolean;
  1675. /**
  1676. * Defines a number that determines the order the extensions are applied.
  1677. */
  1678. order: number;
  1679. private _loader;
  1680. /** @hidden */
  1681. constructor(loader: GLTFLoader);
  1682. /** @hidden */
  1683. dispose(): void;
  1684. /** @hidden */
  1685. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1686. private _loadSpecularGlossinessPropertiesAsync;
  1687. }
  1688. }
  1689. declare module BABYLON.GLTF2.Loader.Extensions {
  1690. /**
  1691. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  1692. */
  1693. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  1694. /**
  1695. * The name of this extension.
  1696. */
  1697. readonly name: string;
  1698. /**
  1699. * Defines whether this extension is enabled.
  1700. */
  1701. enabled: boolean;
  1702. /**
  1703. * Defines a number that determines the order the extensions are applied.
  1704. */
  1705. order: number;
  1706. private _loader;
  1707. /** @hidden */
  1708. constructor(loader: GLTFLoader);
  1709. /** @hidden */
  1710. dispose(): void;
  1711. /** @hidden */
  1712. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1713. private _loadUnlitPropertiesAsync;
  1714. }
  1715. }
  1716. declare module BABYLON.GLTF2.Loader.Extensions {
  1717. /**
  1718. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1719. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  1720. * !!! Experimental Extension Subject to Changes !!!
  1721. */
  1722. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  1723. /**
  1724. * The name of this extension.
  1725. */
  1726. readonly name: string;
  1727. /**
  1728. * Defines whether this extension is enabled.
  1729. */
  1730. enabled: boolean;
  1731. /**
  1732. * Defines a number that determines the order the extensions are applied.
  1733. */
  1734. order: number;
  1735. private _loader;
  1736. /** @hidden */
  1737. constructor(loader: GLTFLoader);
  1738. /** @hidden */
  1739. dispose(): void;
  1740. /** @hidden */
  1741. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1742. private _loadClearCoatPropertiesAsync;
  1743. }
  1744. }
  1745. declare module BABYLON.GLTF2.Loader.Extensions {
  1746. /**
  1747. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  1748. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  1749. * !!! Experimental Extension Subject to Changes !!!
  1750. */
  1751. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  1752. /**
  1753. * The name of this extension.
  1754. */
  1755. readonly name: string;
  1756. /**
  1757. * Defines whether this extension is enabled.
  1758. */
  1759. enabled: boolean;
  1760. /**
  1761. * Defines a number that determines the order the extensions are applied.
  1762. */
  1763. order: number;
  1764. private _loader;
  1765. /** @hidden */
  1766. constructor(loader: GLTFLoader);
  1767. /** @hidden */
  1768. dispose(): void;
  1769. /** @hidden */
  1770. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1771. private _loadSheenPropertiesAsync;
  1772. }
  1773. }
  1774. declare module BABYLON.GLTF2.Loader.Extensions {
  1775. /**
  1776. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  1777. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  1778. * !!! Experimental Extension Subject to Changes !!!
  1779. */
  1780. export class KHR_materials_specular implements IGLTFLoaderExtension {
  1781. /**
  1782. * The name of this extension.
  1783. */
  1784. readonly name: string;
  1785. /**
  1786. * Defines whether this extension is enabled.
  1787. */
  1788. enabled: boolean;
  1789. /**
  1790. * Defines a number that determines the order the extensions are applied.
  1791. */
  1792. order: number;
  1793. private _loader;
  1794. /** @hidden */
  1795. constructor(loader: GLTFLoader);
  1796. /** @hidden */
  1797. dispose(): void;
  1798. /** @hidden */
  1799. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1800. private _loadSpecularPropertiesAsync;
  1801. }
  1802. }
  1803. declare module BABYLON.GLTF2.Loader.Extensions {
  1804. /**
  1805. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  1806. */
  1807. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  1808. /**
  1809. * The name of this extension.
  1810. */
  1811. readonly name: string;
  1812. /**
  1813. * Defines whether this extension is enabled.
  1814. */
  1815. enabled: boolean;
  1816. /** @hidden */
  1817. constructor(loader: GLTFLoader);
  1818. /** @hidden */
  1819. dispose(): void;
  1820. }
  1821. }
  1822. declare module BABYLON.GLTF2.Loader.Extensions {
  1823. /**
  1824. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  1825. */
  1826. export class KHR_texture_transform implements IGLTFLoaderExtension {
  1827. /**
  1828. * The name of this extension.
  1829. */
  1830. readonly name: string;
  1831. /**
  1832. * Defines whether this extension is enabled.
  1833. */
  1834. enabled: boolean;
  1835. private _loader;
  1836. /** @hidden */
  1837. constructor(loader: GLTFLoader);
  1838. /** @hidden */
  1839. dispose(): void;
  1840. /** @hidden */
  1841. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  1842. }
  1843. }
  1844. declare module BABYLON.GLTF2.Loader.Extensions {
  1845. /**
  1846. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  1847. */
  1848. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  1849. /**
  1850. * The name of this extension.
  1851. */
  1852. readonly name: string;
  1853. /**
  1854. * Defines whether this extension is enabled.
  1855. */
  1856. enabled: boolean;
  1857. private _loader;
  1858. private _clips;
  1859. private _emitters;
  1860. /** @hidden */
  1861. constructor(loader: GLTFLoader);
  1862. /** @hidden */
  1863. dispose(): void;
  1864. /** @hidden */
  1865. onLoading(): void;
  1866. /** @hidden */
  1867. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  1868. /** @hidden */
  1869. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1870. /** @hidden */
  1871. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  1872. private _loadClipAsync;
  1873. private _loadEmitterAsync;
  1874. private _getEventAction;
  1875. private _loadAnimationEventAsync;
  1876. }
  1877. }
  1878. declare module BABYLON.GLTF2.Loader.Extensions {
  1879. /**
  1880. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  1881. */
  1882. export class MSFT_lod implements IGLTFLoaderExtension {
  1883. /**
  1884. * The name of this extension.
  1885. */
  1886. readonly name: string;
  1887. /**
  1888. * Defines whether this extension is enabled.
  1889. */
  1890. enabled: boolean;
  1891. /**
  1892. * Defines a number that determines the order the extensions are applied.
  1893. */
  1894. order: number;
  1895. /**
  1896. * Maximum number of LODs to load, starting from the lowest LOD.
  1897. */
  1898. maxLODsToLoad: number;
  1899. /**
  1900. * Observable raised when all node LODs of one level are loaded.
  1901. * The event data is the index of the loaded LOD starting from zero.
  1902. * Dispose the loader to cancel the loading of the next level of LODs.
  1903. */
  1904. onNodeLODsLoadedObservable: Observable<number>;
  1905. /**
  1906. * Observable raised when all material LODs of one level are loaded.
  1907. * The event data is the index of the loaded LOD starting from zero.
  1908. * Dispose the loader to cancel the loading of the next level of LODs.
  1909. */
  1910. onMaterialLODsLoadedObservable: Observable<number>;
  1911. private _loader;
  1912. private _nodeIndexLOD;
  1913. private _nodeSignalLODs;
  1914. private _nodePromiseLODs;
  1915. private _materialIndexLOD;
  1916. private _materialSignalLODs;
  1917. private _materialPromiseLODs;
  1918. private _indexLOD;
  1919. private _bufferLODs;
  1920. /** @hidden */
  1921. constructor(loader: GLTFLoader);
  1922. /** @hidden */
  1923. dispose(): void;
  1924. /** @hidden */
  1925. onReady(): void;
  1926. /** @hidden */
  1927. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1928. /** @hidden */
  1929. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  1930. /** @hidden */
  1931. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  1932. /** @hidden */
  1933. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  1934. private _loadBufferLOD;
  1935. /**
  1936. * Gets an array of LOD properties from lowest to highest.
  1937. */
  1938. private _getLODs;
  1939. private _disposeUnusedMaterials;
  1940. }
  1941. }
  1942. declare module BABYLON.GLTF2.Loader.Extensions {
  1943. /** @hidden */
  1944. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  1945. readonly name: string;
  1946. enabled: boolean;
  1947. private _loader;
  1948. constructor(loader: GLTFLoader);
  1949. dispose(): void;
  1950. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1951. }
  1952. }
  1953. declare module BABYLON.GLTF2.Loader.Extensions {
  1954. /** @hidden */
  1955. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  1956. readonly name: string;
  1957. enabled: boolean;
  1958. private _loader;
  1959. constructor(loader: GLTFLoader);
  1960. dispose(): void;
  1961. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  1962. }
  1963. }
  1964. declare module BABYLON.GLTF2.Loader.Extensions {
  1965. /**
  1966. * Store glTF extras (if present) in BJS objects' metadata
  1967. */
  1968. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  1969. /**
  1970. * The name of this extension.
  1971. */
  1972. readonly name: string;
  1973. /**
  1974. * Defines whether this extension is enabled.
  1975. */
  1976. enabled: boolean;
  1977. private _loader;
  1978. private _assignExtras;
  1979. /** @hidden */
  1980. constructor(loader: GLTFLoader);
  1981. /** @hidden */
  1982. dispose(): void;
  1983. /** @hidden */
  1984. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  1985. /** @hidden */
  1986. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  1987. /** @hidden */
  1988. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  1989. }
  1990. }
  1991. declare module BABYLON {
  1992. /**
  1993. * Class reading and parsing the MTL file bundled with the obj file.
  1994. */
  1995. export class MTLFileLoader {
  1996. /**
  1997. * All material loaded from the mtl will be set here
  1998. */
  1999. materials: StandardMaterial[];
  2000. /**
  2001. * This function will read the mtl file and create each material described inside
  2002. * This function could be improve by adding :
  2003. * -some component missing (Ni, Tf...)
  2004. * -including the specific options available
  2005. *
  2006. * @param scene defines the scene the material will be created in
  2007. * @param data defines the mtl data to parse
  2008. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  2009. */
  2010. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  2011. /**
  2012. * Gets the texture for the material.
  2013. *
  2014. * If the material is imported from input file,
  2015. * We sanitize the url to ensure it takes the textre from aside the material.
  2016. *
  2017. * @param rootUrl The root url to load from
  2018. * @param value The value stored in the mtl
  2019. * @return The Texture
  2020. */
  2021. private static _getTexture;
  2022. }
  2023. /**
  2024. * Options for loading OBJ/MTL files
  2025. */
  2026. type MeshLoadOptions = {
  2027. /**
  2028. * Defines if UVs are optimized by default during load.
  2029. */
  2030. OptimizeWithUV: boolean;
  2031. /**
  2032. * Defines custom scaling of UV coordinates of loaded meshes.
  2033. */
  2034. UVScaling: Vector2;
  2035. /**
  2036. * Invert model on y-axis (does a model scaling inversion)
  2037. */
  2038. InvertY: boolean;
  2039. /**
  2040. * Invert Y-Axis of referenced textures on load
  2041. */
  2042. InvertTextureY: boolean;
  2043. /**
  2044. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2045. */
  2046. ImportVertexColors: boolean;
  2047. /**
  2048. * Compute the normals for the model, even if normals are present in the file.
  2049. */
  2050. ComputeNormals: boolean;
  2051. /**
  2052. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2053. */
  2054. SkipMaterials: boolean;
  2055. /**
  2056. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2057. */
  2058. MaterialLoadingFailsSilently: boolean;
  2059. };
  2060. /**
  2061. * OBJ file type loader.
  2062. * This is a babylon scene loader plugin.
  2063. */
  2064. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  2065. /**
  2066. * Defines if UVs are optimized by default during load.
  2067. */
  2068. static OPTIMIZE_WITH_UV: boolean;
  2069. /**
  2070. * Invert model on y-axis (does a model scaling inversion)
  2071. */
  2072. static INVERT_Y: boolean;
  2073. /**
  2074. * Invert Y-Axis of referenced textures on load
  2075. */
  2076. static INVERT_TEXTURE_Y: boolean;
  2077. /**
  2078. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  2079. */
  2080. static IMPORT_VERTEX_COLORS: boolean;
  2081. /**
  2082. * Compute the normals for the model, even if normals are present in the file.
  2083. */
  2084. static COMPUTE_NORMALS: boolean;
  2085. /**
  2086. * Defines custom scaling of UV coordinates of loaded meshes.
  2087. */
  2088. static UV_SCALING: Vector2;
  2089. /**
  2090. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  2091. */
  2092. static SKIP_MATERIALS: boolean;
  2093. /**
  2094. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  2095. *
  2096. * Defaults to true for backwards compatibility.
  2097. */
  2098. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  2099. /**
  2100. * Defines the name of the plugin.
  2101. */
  2102. name: string;
  2103. /**
  2104. * Defines the extension the plugin is able to load.
  2105. */
  2106. extensions: string;
  2107. /** @hidden */
  2108. obj: RegExp;
  2109. /** @hidden */
  2110. group: RegExp;
  2111. /** @hidden */
  2112. mtllib: RegExp;
  2113. /** @hidden */
  2114. usemtl: RegExp;
  2115. /** @hidden */
  2116. smooth: RegExp;
  2117. /** @hidden */
  2118. vertexPattern: RegExp;
  2119. /** @hidden */
  2120. normalPattern: RegExp;
  2121. /** @hidden */
  2122. uvPattern: RegExp;
  2123. /** @hidden */
  2124. facePattern1: RegExp;
  2125. /** @hidden */
  2126. facePattern2: RegExp;
  2127. /** @hidden */
  2128. facePattern3: RegExp;
  2129. /** @hidden */
  2130. facePattern4: RegExp;
  2131. /** @hidden */
  2132. facePattern5: RegExp;
  2133. private _meshLoadOptions;
  2134. /**
  2135. * Creates loader for .OBJ files
  2136. *
  2137. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  2138. */
  2139. constructor(meshLoadOptions?: MeshLoadOptions);
  2140. private static get currentMeshLoadOptions();
  2141. /**
  2142. * Calls synchronously the MTL file attached to this obj.
  2143. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  2144. * Without this function materials are not displayed in the first frame (but displayed after).
  2145. * In consequence it is impossible to get material information in your HTML file
  2146. *
  2147. * @param url The URL of the MTL file
  2148. * @param rootUrl
  2149. * @param onSuccess Callback function to be called when the MTL file is loaded
  2150. * @private
  2151. */
  2152. private _loadMTL;
  2153. /**
  2154. * Instantiates a OBJ file loader plugin.
  2155. * @returns the created plugin
  2156. */
  2157. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  2158. /**
  2159. * If the data string can be loaded directly.
  2160. *
  2161. * @param data string containing the file data
  2162. * @returns if the data can be loaded directly
  2163. */
  2164. canDirectLoad(data: string): boolean;
  2165. /**
  2166. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  2167. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  2168. * @param scene the scene the meshes should be added to
  2169. * @param data the OBJ data to load
  2170. * @param rootUrl root url to load from
  2171. * @param onProgress event that fires when loading progress has occured
  2172. * @param fileName Defines the name of the file to load
  2173. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  2174. */
  2175. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  2176. meshes: AbstractMesh[];
  2177. particleSystems: IParticleSystem[];
  2178. skeletons: Skeleton[];
  2179. animationGroups: AnimationGroup[];
  2180. }>;
  2181. /**
  2182. * Imports all objects from the loaded OBJ data and adds them to the scene
  2183. * @param scene the scene the objects should be added to
  2184. * @param data the OBJ data to load
  2185. * @param rootUrl root url to load from
  2186. * @param onProgress event that fires when loading progress has occured
  2187. * @param fileName Defines the name of the file to load
  2188. * @returns a promise which completes when objects have been loaded to the scene
  2189. */
  2190. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  2191. /**
  2192. * Load into an asset container.
  2193. * @param scene The scene to load into
  2194. * @param data The data to import
  2195. * @param rootUrl The root url for scene and resources
  2196. * @param onProgress The callback when the load progresses
  2197. * @param fileName Defines the name of the file to load
  2198. * @returns The loaded asset container
  2199. */
  2200. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  2201. /**
  2202. * Read the OBJ file and create an Array of meshes.
  2203. * Each mesh contains all information given by the OBJ and the MTL file.
  2204. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  2205. *
  2206. * @param meshesNames
  2207. * @param scene Scene The scene where are displayed the data
  2208. * @param data String The content of the obj file
  2209. * @param rootUrl String The path to the folder
  2210. * @returns Array<AbstractMesh>
  2211. * @private
  2212. */
  2213. private _parseSolid;
  2214. }
  2215. }
  2216. declare module BABYLON {
  2217. /**
  2218. * STL file type loader.
  2219. * This is a babylon scene loader plugin.
  2220. */
  2221. export class STLFileLoader implements ISceneLoaderPlugin {
  2222. /** @hidden */
  2223. solidPattern: RegExp;
  2224. /** @hidden */
  2225. facetsPattern: RegExp;
  2226. /** @hidden */
  2227. normalPattern: RegExp;
  2228. /** @hidden */
  2229. vertexPattern: RegExp;
  2230. /**
  2231. * Defines the name of the plugin.
  2232. */
  2233. name: string;
  2234. /**
  2235. * Defines the extensions the stl loader is able to load.
  2236. * force data to come in as an ArrayBuffer
  2237. * we'll convert to string if it looks like it's an ASCII .stl
  2238. */
  2239. extensions: ISceneLoaderPluginExtensions;
  2240. /**
  2241. * Import meshes into a scene.
  2242. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  2243. * @param scene The scene to import into
  2244. * @param data The data to import
  2245. * @param rootUrl The root url for scene and resources
  2246. * @param meshes The meshes array to import into
  2247. * @param particleSystems The particle systems array to import into
  2248. * @param skeletons The skeletons array to import into
  2249. * @param onError The callback when import fails
  2250. * @returns True if successful or false otherwise
  2251. */
  2252. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  2253. /**
  2254. * Load into a scene.
  2255. * @param scene The scene to load into
  2256. * @param data The data to import
  2257. * @param rootUrl The root url for scene and resources
  2258. * @param onError The callback when import fails
  2259. * @returns true if successful or false otherwise
  2260. */
  2261. load(scene: Scene, data: any, rootUrl: string): boolean;
  2262. /**
  2263. * Load into an asset container.
  2264. * @param scene The scene to load into
  2265. * @param data The data to import
  2266. * @param rootUrl The root url for scene and resources
  2267. * @param onError The callback when import fails
  2268. * @returns The loaded asset container
  2269. */
  2270. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  2271. private _isBinary;
  2272. private _parseBinary;
  2273. private _parseASCII;
  2274. }
  2275. }