babylonjs.loaders.d.ts 90 KB

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