babylonjs.loaders.d.ts 91 KB

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