babylonjs.loaders.d.ts 91 KB

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