babylonjs.loaders.d.ts 93 KB

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