babylonjs.loaders.module.d.ts 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215
  1. /// <reference types="babylonjs"/>
  2. declare module 'babylonjs-loaders' {
  3. export = BABYLON;
  4. }
  5. declare module BABYLON {
  6. class STLFileLoader implements ISceneLoaderPlugin {
  7. solidPattern: RegExp;
  8. facetsPattern: RegExp;
  9. normalPattern: RegExp;
  10. vertexPattern: RegExp;
  11. name: string;
  12. extensions: ISceneLoaderPluginExtensions;
  13. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  14. load(scene: Scene, data: any, rootUrl: string): boolean;
  15. loadAssets(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): Nullable<AssetContainer>;
  16. private isBinary(data);
  17. private parseBinary(mesh, data);
  18. private parseASCII(mesh, solidData);
  19. }
  20. }
  21. declare module BABYLON {
  22. /**
  23. * Class reading and parsing the MTL file bundled with the obj file.
  24. */
  25. class MTLFileLoader {
  26. materials: BABYLON.StandardMaterial[];
  27. /**
  28. * This function will read the mtl file and create each material described inside
  29. * This function could be improve by adding :
  30. * -some component missing (Ni, Tf...)
  31. * -including the specific options available
  32. *
  33. * @param scene
  34. * @param data
  35. * @param rootUrl
  36. */
  37. parseMTL(scene: BABYLON.Scene, data: string, rootUrl: string): void;
  38. /**
  39. * Gets the texture for the material.
  40. *
  41. * If the material is imported from input file,
  42. * We sanitize the url to ensure it takes the textre from aside the material.
  43. *
  44. * @param rootUrl The root url to load from
  45. * @param value The value stored in the mtl
  46. * @return The Texture
  47. */
  48. private static _getTexture(rootUrl, value, scene);
  49. }
  50. class OBJFileLoader implements ISceneLoaderPlugin {
  51. static OPTIMIZE_WITH_UV: boolean;
  52. name: string;
  53. extensions: string;
  54. obj: RegExp;
  55. group: RegExp;
  56. mtllib: RegExp;
  57. usemtl: RegExp;
  58. smooth: RegExp;
  59. vertexPattern: RegExp;
  60. normalPattern: RegExp;
  61. uvPattern: RegExp;
  62. facePattern1: RegExp;
  63. facePattern2: RegExp;
  64. facePattern3: RegExp;
  65. facePattern4: RegExp;
  66. /**
  67. * Calls synchronously the MTL file attached to this obj.
  68. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  69. * Without this function materials are not displayed in the first frame (but displayed after).
  70. * In consequence it is impossible to get material information in your HTML file
  71. *
  72. * @param url The URL of the MTL file
  73. * @param rootUrl
  74. * @param onSuccess Callback function to be called when the MTL file is loaded
  75. * @private
  76. */
  77. private _loadMTL(url, rootUrl, onSuccess);
  78. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  79. load(scene: Scene, data: string, rootUrl: string): boolean;
  80. loadAssets(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): Nullable<AssetContainer>;
  81. /**
  82. * Read the OBJ file and create an Array of meshes.
  83. * Each mesh contains all information given by the OBJ and the MTL file.
  84. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  85. *
  86. * @param meshesNames
  87. * @param scene BABYLON.Scene The scene where are displayed the data
  88. * @param data String The content of the obj file
  89. * @param rootUrl String The path to the folder
  90. * @returns Array<AbstractMesh>
  91. * @private
  92. */
  93. private _parseSolid(meshesNames, scene, data, rootUrl);
  94. }
  95. }
  96. declare module BABYLON {
  97. enum GLTFLoaderCoordinateSystemMode {
  98. /**
  99. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  100. */
  101. AUTO = 0,
  102. /**
  103. * Sets the useRightHandedSystem flag on the scene.
  104. */
  105. FORCE_RIGHT_HANDED = 1,
  106. }
  107. enum GLTFLoaderAnimationStartMode {
  108. /**
  109. * No animation will start.
  110. */
  111. NONE = 0,
  112. /**
  113. * The first animation will start.
  114. */
  115. FIRST = 1,
  116. /**
  117. * All animations will start.
  118. */
  119. ALL = 2,
  120. }
  121. interface IGLTFLoaderData {
  122. json: Object;
  123. bin: Nullable<ArrayBufferView>;
  124. }
  125. interface IGLTFLoader extends IDisposable {
  126. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  127. animationStartMode: GLTFLoaderAnimationStartMode;
  128. compileMaterials: boolean;
  129. useClipPlane: boolean;
  130. compileShadowGenerators: boolean;
  131. onDisposeObservable: Observable<IGLTFLoader>;
  132. onMeshLoadedObservable: Observable<AbstractMesh>;
  133. onTextureLoadedObservable: Observable<BaseTexture>;
  134. onMaterialLoadedObservable: Observable<Material>;
  135. onCompleteObservable: Observable<IGLTFLoader>;
  136. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  137. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  138. }
  139. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  140. static CreateGLTFLoaderV1: () => IGLTFLoader;
  141. static CreateGLTFLoaderV2: () => IGLTFLoader;
  142. /**
  143. * Raised when the asset has been parsed.
  144. * The data.json property stores the glTF JSON.
  145. * The data.bin property stores the BIN chunk from a glTF binary or null if the input is not a glTF binary.
  146. */
  147. onParsedObservable: Observable<IGLTFLoaderData>;
  148. private _onParsedObserver;
  149. onParsed: (loaderData: IGLTFLoaderData) => void;
  150. static IncrementalLoading: boolean;
  151. static HomogeneousCoordinates: boolean;
  152. /**
  153. * The coordinate system mode (AUTO, FORCE_RIGHT_HANDED).
  154. */
  155. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  156. /**
  157. * The animation start mode (NONE, FIRST, ALL).
  158. */
  159. animationStartMode: GLTFLoaderAnimationStartMode;
  160. /**
  161. * Set to true to compile materials before raising the success callback.
  162. */
  163. compileMaterials: boolean;
  164. /**
  165. * Set to true to also compile materials with clip planes.
  166. */
  167. useClipPlane: boolean;
  168. /**
  169. * Set to true to compile shadow generators before raising the success callback.
  170. */
  171. compileShadowGenerators: boolean;
  172. /**
  173. * Raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  174. */
  175. onMeshLoadedObservable: Observable<AbstractMesh>;
  176. private _onMeshLoadedObserver;
  177. onMeshLoaded: (mesh: AbstractMesh) => void;
  178. /**
  179. * Raised when the loader creates a texture after parsing the glTF properties of the texture.
  180. */
  181. onTextureLoadedObservable: Observable<BaseTexture>;
  182. private _onTextureLoadedObserver;
  183. onTextureLoaded: (Texture: BaseTexture) => void;
  184. /**
  185. * Raised when the loader creates a material after parsing the glTF properties of the material.
  186. */
  187. onMaterialLoadedObservable: Observable<Material>;
  188. private _onMaterialLoadedObserver;
  189. onMaterialLoaded: (Material: Material) => void;
  190. /**
  191. * Raised when the asset is completely loaded, immediately before the loader is disposed.
  192. * For assets with LODs, raised when all of the LODs are complete.
  193. * For assets without LODs, raised when the model is complete, immediately after onSuccess.
  194. */
  195. onCompleteObservable: Observable<GLTFFileLoader>;
  196. private _onCompleteObserver;
  197. onComplete: () => void;
  198. /**
  199. * Raised when the loader is disposed.
  200. */
  201. onDisposeObservable: Observable<GLTFFileLoader>;
  202. private _onDisposeObserver;
  203. onDispose: () => void;
  204. private _loader;
  205. name: string;
  206. extensions: ISceneLoaderPluginExtensions;
  207. /**
  208. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  209. */
  210. dispose(): void;
  211. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
  212. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
  213. loadAssetsAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: (assets: AssetContainer) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
  214. canDirectLoad(data: string): boolean;
  215. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  216. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  217. private _parse(data);
  218. private _getLoader(loaderData);
  219. private static _parseBinary(data);
  220. private static _parseV1(binaryReader);
  221. private static _parseV2(binaryReader);
  222. private static _parseVersion(version);
  223. private static _compareVersion(a, b);
  224. private static _decodeBufferToText(buffer);
  225. }
  226. }
  227. declare module BABYLON.GLTF1 {
  228. /**
  229. * Enums
  230. */
  231. enum EComponentType {
  232. BYTE = 5120,
  233. UNSIGNED_BYTE = 5121,
  234. SHORT = 5122,
  235. UNSIGNED_SHORT = 5123,
  236. FLOAT = 5126,
  237. }
  238. enum EShaderType {
  239. FRAGMENT = 35632,
  240. VERTEX = 35633,
  241. }
  242. enum EParameterType {
  243. BYTE = 5120,
  244. UNSIGNED_BYTE = 5121,
  245. SHORT = 5122,
  246. UNSIGNED_SHORT = 5123,
  247. INT = 5124,
  248. UNSIGNED_INT = 5125,
  249. FLOAT = 5126,
  250. FLOAT_VEC2 = 35664,
  251. FLOAT_VEC3 = 35665,
  252. FLOAT_VEC4 = 35666,
  253. INT_VEC2 = 35667,
  254. INT_VEC3 = 35668,
  255. INT_VEC4 = 35669,
  256. BOOL = 35670,
  257. BOOL_VEC2 = 35671,
  258. BOOL_VEC3 = 35672,
  259. BOOL_VEC4 = 35673,
  260. FLOAT_MAT2 = 35674,
  261. FLOAT_MAT3 = 35675,
  262. FLOAT_MAT4 = 35676,
  263. SAMPLER_2D = 35678,
  264. }
  265. enum ETextureWrapMode {
  266. CLAMP_TO_EDGE = 33071,
  267. MIRRORED_REPEAT = 33648,
  268. REPEAT = 10497,
  269. }
  270. enum ETextureFilterType {
  271. NEAREST = 9728,
  272. LINEAR = 9728,
  273. NEAREST_MIPMAP_NEAREST = 9984,
  274. LINEAR_MIPMAP_NEAREST = 9985,
  275. NEAREST_MIPMAP_LINEAR = 9986,
  276. LINEAR_MIPMAP_LINEAR = 9987,
  277. }
  278. enum ETextureFormat {
  279. ALPHA = 6406,
  280. RGB = 6407,
  281. RGBA = 6408,
  282. LUMINANCE = 6409,
  283. LUMINANCE_ALPHA = 6410,
  284. }
  285. enum ECullingType {
  286. FRONT = 1028,
  287. BACK = 1029,
  288. FRONT_AND_BACK = 1032,
  289. }
  290. enum EBlendingFunction {
  291. ZERO = 0,
  292. ONE = 1,
  293. SRC_COLOR = 768,
  294. ONE_MINUS_SRC_COLOR = 769,
  295. DST_COLOR = 774,
  296. ONE_MINUS_DST_COLOR = 775,
  297. SRC_ALPHA = 770,
  298. ONE_MINUS_SRC_ALPHA = 771,
  299. DST_ALPHA = 772,
  300. ONE_MINUS_DST_ALPHA = 773,
  301. CONSTANT_COLOR = 32769,
  302. ONE_MINUS_CONSTANT_COLOR = 32770,
  303. CONSTANT_ALPHA = 32771,
  304. ONE_MINUS_CONSTANT_ALPHA = 32772,
  305. SRC_ALPHA_SATURATE = 776,
  306. }
  307. /**
  308. * Interfaces
  309. */
  310. interface IGLTFProperty {
  311. extensions?: {
  312. [key: string]: any;
  313. };
  314. extras?: Object;
  315. }
  316. interface IGLTFChildRootProperty extends IGLTFProperty {
  317. name?: string;
  318. }
  319. interface IGLTFAccessor extends IGLTFChildRootProperty {
  320. bufferView: string;
  321. byteOffset: number;
  322. byteStride: number;
  323. count: number;
  324. type: string;
  325. componentType: EComponentType;
  326. max?: number[];
  327. min?: number[];
  328. name?: string;
  329. }
  330. interface IGLTFBufferView extends IGLTFChildRootProperty {
  331. buffer: string;
  332. byteOffset: number;
  333. byteLength: number;
  334. byteStride: number;
  335. target?: number;
  336. }
  337. interface IGLTFBuffer extends IGLTFChildRootProperty {
  338. uri: string;
  339. byteLength?: number;
  340. type?: string;
  341. }
  342. interface IGLTFShader extends IGLTFChildRootProperty {
  343. uri: string;
  344. type: EShaderType;
  345. }
  346. interface IGLTFProgram extends IGLTFChildRootProperty {
  347. attributes: string[];
  348. fragmentShader: string;
  349. vertexShader: string;
  350. }
  351. interface IGLTFTechniqueParameter {
  352. type: number;
  353. count?: number;
  354. semantic?: string;
  355. node?: string;
  356. value?: number | boolean | string | Array<any>;
  357. source?: string;
  358. babylonValue?: any;
  359. }
  360. interface IGLTFTechniqueCommonProfile {
  361. lightingModel: string;
  362. texcoordBindings: Object;
  363. parameters?: Array<any>;
  364. }
  365. interface IGLTFTechniqueStatesFunctions {
  366. blendColor?: number[];
  367. blendEquationSeparate?: number[];
  368. blendFuncSeparate?: number[];
  369. colorMask: boolean[];
  370. cullFace: number[];
  371. }
  372. interface IGLTFTechniqueStates {
  373. enable: number[];
  374. functions: IGLTFTechniqueStatesFunctions;
  375. }
  376. interface IGLTFTechnique extends IGLTFChildRootProperty {
  377. parameters: {
  378. [key: string]: IGLTFTechniqueParameter;
  379. };
  380. program: string;
  381. attributes: {
  382. [key: string]: string;
  383. };
  384. uniforms: {
  385. [key: string]: string;
  386. };
  387. states: IGLTFTechniqueStates;
  388. }
  389. interface IGLTFMaterial extends IGLTFChildRootProperty {
  390. technique?: string;
  391. values: string[];
  392. }
  393. interface IGLTFMeshPrimitive extends IGLTFProperty {
  394. attributes: {
  395. [key: string]: string;
  396. };
  397. indices: string;
  398. material: string;
  399. mode?: number;
  400. }
  401. interface IGLTFMesh extends IGLTFChildRootProperty {
  402. primitives: IGLTFMeshPrimitive[];
  403. }
  404. interface IGLTFImage extends IGLTFChildRootProperty {
  405. uri: string;
  406. }
  407. interface IGLTFSampler extends IGLTFChildRootProperty {
  408. magFilter?: number;
  409. minFilter?: number;
  410. wrapS?: number;
  411. wrapT?: number;
  412. }
  413. interface IGLTFTexture extends IGLTFChildRootProperty {
  414. sampler: string;
  415. source: string;
  416. format?: ETextureFormat;
  417. internalFormat?: ETextureFormat;
  418. target?: number;
  419. type?: number;
  420. babylonTexture?: Texture;
  421. }
  422. interface IGLTFAmbienLight {
  423. color?: number[];
  424. }
  425. interface IGLTFDirectionalLight {
  426. color?: number[];
  427. }
  428. interface IGLTFPointLight {
  429. color?: number[];
  430. constantAttenuation?: number;
  431. linearAttenuation?: number;
  432. quadraticAttenuation?: number;
  433. }
  434. interface IGLTFSpotLight {
  435. color?: number[];
  436. constantAttenuation?: number;
  437. fallOfAngle?: number;
  438. fallOffExponent?: number;
  439. linearAttenuation?: number;
  440. quadraticAttenuation?: number;
  441. }
  442. interface IGLTFLight extends IGLTFChildRootProperty {
  443. type: string;
  444. }
  445. interface IGLTFCameraOrthographic {
  446. xmag: number;
  447. ymag: number;
  448. zfar: number;
  449. znear: number;
  450. }
  451. interface IGLTFCameraPerspective {
  452. aspectRatio: number;
  453. yfov: number;
  454. zfar: number;
  455. znear: number;
  456. }
  457. interface IGLTFCamera extends IGLTFChildRootProperty {
  458. type: string;
  459. }
  460. interface IGLTFAnimationChannelTarget {
  461. id: string;
  462. path: string;
  463. }
  464. interface IGLTFAnimationChannel {
  465. sampler: string;
  466. target: IGLTFAnimationChannelTarget;
  467. }
  468. interface IGLTFAnimationSampler {
  469. input: string;
  470. output: string;
  471. interpolation?: string;
  472. }
  473. interface IGLTFAnimation extends IGLTFChildRootProperty {
  474. channels?: IGLTFAnimationChannel[];
  475. parameters?: {
  476. [key: string]: string;
  477. };
  478. samplers?: {
  479. [key: string]: IGLTFAnimationSampler;
  480. };
  481. }
  482. interface IGLTFNodeInstanceSkin {
  483. skeletons: string[];
  484. skin: string;
  485. meshes: string[];
  486. }
  487. interface IGLTFSkins extends IGLTFChildRootProperty {
  488. bindShapeMatrix: number[];
  489. inverseBindMatrices: string;
  490. jointNames: string[];
  491. babylonSkeleton?: Skeleton;
  492. }
  493. interface IGLTFNode extends IGLTFChildRootProperty {
  494. camera?: string;
  495. children: string[];
  496. skin?: string;
  497. jointName?: string;
  498. light?: string;
  499. matrix: number[];
  500. mesh?: string;
  501. meshes?: string[];
  502. rotation?: number[];
  503. scale?: number[];
  504. translation?: number[];
  505. babylonNode?: Node;
  506. }
  507. interface IGLTFScene extends IGLTFChildRootProperty {
  508. nodes: string[];
  509. }
  510. /**
  511. * Runtime
  512. */
  513. interface IGLTFRuntime {
  514. extensions: {
  515. [key: string]: any;
  516. };
  517. accessors: {
  518. [key: string]: IGLTFAccessor;
  519. };
  520. buffers: {
  521. [key: string]: IGLTFBuffer;
  522. };
  523. bufferViews: {
  524. [key: string]: IGLTFBufferView;
  525. };
  526. meshes: {
  527. [key: string]: IGLTFMesh;
  528. };
  529. lights: {
  530. [key: string]: IGLTFLight;
  531. };
  532. cameras: {
  533. [key: string]: IGLTFCamera;
  534. };
  535. nodes: {
  536. [key: string]: IGLTFNode;
  537. };
  538. images: {
  539. [key: string]: IGLTFImage;
  540. };
  541. textures: {
  542. [key: string]: IGLTFTexture;
  543. };
  544. shaders: {
  545. [key: string]: IGLTFShader;
  546. };
  547. programs: {
  548. [key: string]: IGLTFProgram;
  549. };
  550. samplers: {
  551. [key: string]: IGLTFSampler;
  552. };
  553. techniques: {
  554. [key: string]: IGLTFTechnique;
  555. };
  556. materials: {
  557. [key: string]: IGLTFMaterial;
  558. };
  559. animations: {
  560. [key: string]: IGLTFAnimation;
  561. };
  562. skins: {
  563. [key: string]: IGLTFSkins;
  564. };
  565. currentScene?: Object;
  566. scenes: {
  567. [key: string]: IGLTFScene;
  568. };
  569. extensionsUsed: string[];
  570. extensionsRequired?: string[];
  571. buffersCount: number;
  572. shaderscount: number;
  573. scene: Scene;
  574. rootUrl: string;
  575. loadedBufferCount: number;
  576. loadedBufferViews: {
  577. [name: string]: ArrayBufferView;
  578. };
  579. loadedShaderCount: number;
  580. importOnlyMeshes: boolean;
  581. importMeshesNames?: string[];
  582. dummyNodes: Node[];
  583. }
  584. /**
  585. * Bones
  586. */
  587. interface INodeToRoot {
  588. bone: Bone;
  589. node: IGLTFNode;
  590. id: string;
  591. }
  592. interface IJointNode {
  593. node: IGLTFNode;
  594. id: string;
  595. }
  596. }
  597. declare module BABYLON.GLTF1 {
  598. /**
  599. * Implementation of the base glTF spec
  600. */
  601. class GLTFLoaderBase {
  602. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  603. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  604. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  605. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  606. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): void;
  607. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  608. }
  609. /**
  610. * glTF V1 Loader
  611. */
  612. class GLTFLoader implements IGLTFLoader {
  613. static Extensions: {
  614. [name: string]: GLTFLoaderExtension;
  615. };
  616. static RegisterExtension(extension: GLTFLoaderExtension): void;
  617. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  618. animationStartMode: GLTFLoaderAnimationStartMode;
  619. compileMaterials: boolean;
  620. useClipPlane: boolean;
  621. compileShadowGenerators: boolean;
  622. onDisposeObservable: Observable<IGLTFLoader>;
  623. onMeshLoadedObservable: Observable<AbstractMesh>;
  624. onTextureLoadedObservable: Observable<BaseTexture>;
  625. onMaterialLoadedObservable: Observable<Material>;
  626. onCompleteObservable: Observable<IGLTFLoader>;
  627. dispose(): void;
  628. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: SceneLoaderProgressEvent) => void, onError: (message: string) => void): boolean;
  629. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: SceneLoaderProgressEvent) => void, onError: (message: string) => void): void;
  630. private _loadShadersAsync(gltfRuntime, onload);
  631. private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
  632. private _createNodes(gltfRuntime);
  633. }
  634. }
  635. declare module BABYLON.GLTF1 {
  636. /**
  637. * Utils functions for GLTF
  638. */
  639. class GLTFUtils {
  640. /**
  641. * Sets the given "parameter" matrix
  642. * @param scene: the {BABYLON.Scene} object
  643. * @param source: the source node where to pick the matrix
  644. * @param parameter: the GLTF technique parameter
  645. * @param uniformName: the name of the shader's uniform
  646. * @param shaderMaterial: the shader material
  647. */
  648. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  649. /**
  650. * Sets the given "parameter" matrix
  651. * @param shaderMaterial: the shader material
  652. * @param uniform: the name of the shader's uniform
  653. * @param value: the value of the uniform
  654. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  655. */
  656. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  657. /**
  658. * If the uri is a base64 string
  659. * @param uri: the uri to test
  660. */
  661. static IsBase64(uri: string): boolean;
  662. /**
  663. * Decode the base64 uri
  664. * @param uri: the uri to decode
  665. */
  666. static DecodeBase64(uri: string): ArrayBuffer;
  667. /**
  668. * Returns the wrap mode of the texture
  669. * @param mode: the mode value
  670. */
  671. static GetWrapMode(mode: number): number;
  672. /**
  673. * Returns the byte stride giving an accessor
  674. * @param accessor: the GLTF accessor objet
  675. */
  676. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  677. /**
  678. * Returns the texture filter mode giving a mode value
  679. * @param mode: the filter mode value
  680. */
  681. static GetTextureFilterMode(mode: number): ETextureFilterType;
  682. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  683. /**
  684. * Returns a buffer from its accessor
  685. * @param gltfRuntime: the GLTF runtime
  686. * @param accessor: the GLTF accessor
  687. */
  688. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  689. /**
  690. * Decodes a buffer view into a string
  691. * @param view: the buffer view
  692. */
  693. static DecodeBufferToText(view: ArrayBufferView): string;
  694. /**
  695. * Returns the default material of gltf. Related to
  696. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  697. * @param scene: the Babylon.js scene
  698. */
  699. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  700. private static _DefaultMaterial;
  701. }
  702. }
  703. declare module BABYLON.GLTF1 {
  704. abstract class GLTFLoaderExtension {
  705. private _name;
  706. constructor(name: string);
  707. readonly name: string;
  708. /**
  709. * Defines an override for loading the runtime
  710. * Return true to stop further extensions from loading the runtime
  711. */
  712. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  713. /**
  714. * Defines an onverride for creating gltf runtime
  715. * Return true to stop further extensions from creating the runtime
  716. */
  717. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  718. /**
  719. * Defines an override for loading buffers
  720. * Return true to stop further extensions from loading this buffer
  721. */
  722. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  723. /**
  724. * Defines an override for loading texture buffers
  725. * Return true to stop further extensions from loading this texture data
  726. */
  727. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  728. /**
  729. * Defines an override for creating textures
  730. * Return true to stop further extensions from loading this texture
  731. */
  732. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  733. /**
  734. * Defines an override for loading shader strings
  735. * Return true to stop further extensions from loading this shader data
  736. */
  737. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  738. /**
  739. * Defines an override for loading materials
  740. * Return true to stop further extensions from loading this material
  741. */
  742. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  743. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): void;
  744. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): void;
  745. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  746. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  747. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string) => void, onError: (message: string) => void): void;
  748. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  749. private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
  750. private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  751. private static ApplyExtensions(func, defaultFunc);
  752. }
  753. }
  754. declare module BABYLON.GLTF1 {
  755. class GLTFBinaryExtension extends GLTFLoaderExtension {
  756. private _bin;
  757. constructor();
  758. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  759. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  760. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  761. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  762. }
  763. }
  764. declare module BABYLON.GLTF1 {
  765. class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  766. constructor();
  767. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  768. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  769. private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
  770. }
  771. }
  772. declare module BABYLON.GLTF2 {
  773. /**
  774. * Enums
  775. */
  776. enum EComponentType {
  777. BYTE = 5120,
  778. UNSIGNED_BYTE = 5121,
  779. SHORT = 5122,
  780. UNSIGNED_SHORT = 5123,
  781. UNSIGNED_INT = 5125,
  782. FLOAT = 5126,
  783. }
  784. enum EMeshPrimitiveMode {
  785. POINTS = 0,
  786. LINES = 1,
  787. LINE_LOOP = 2,
  788. LINE_STRIP = 3,
  789. TRIANGLES = 4,
  790. TRIANGLE_STRIP = 5,
  791. TRIANGLE_FAN = 6,
  792. }
  793. enum ETextureMagFilter {
  794. NEAREST = 9728,
  795. LINEAR = 9729,
  796. }
  797. enum ETextureMinFilter {
  798. NEAREST = 9728,
  799. LINEAR = 9729,
  800. NEAREST_MIPMAP_NEAREST = 9984,
  801. LINEAR_MIPMAP_NEAREST = 9985,
  802. NEAREST_MIPMAP_LINEAR = 9986,
  803. LINEAR_MIPMAP_LINEAR = 9987,
  804. }
  805. enum ETextureWrapMode {
  806. CLAMP_TO_EDGE = 33071,
  807. MIRRORED_REPEAT = 33648,
  808. REPEAT = 10497,
  809. }
  810. /**
  811. * Interfaces
  812. */
  813. interface IGLTFProperty {
  814. extensions?: {
  815. [key: string]: any;
  816. };
  817. extras?: any;
  818. }
  819. interface IGLTFChildRootProperty extends IGLTFProperty {
  820. name?: string;
  821. }
  822. interface IGLTFAccessorSparseIndices extends IGLTFProperty {
  823. bufferView: number;
  824. byteOffset?: number;
  825. componentType: EComponentType;
  826. }
  827. interface IGLTFAccessorSparseValues extends IGLTFProperty {
  828. bufferView: number;
  829. byteOffset?: number;
  830. }
  831. interface IGLTFAccessorSparse extends IGLTFProperty {
  832. count: number;
  833. indices: IGLTFAccessorSparseIndices;
  834. values: IGLTFAccessorSparseValues;
  835. }
  836. interface IGLTFAccessor extends IGLTFChildRootProperty {
  837. bufferView?: number;
  838. byteOffset?: number;
  839. componentType: EComponentType;
  840. normalized?: boolean;
  841. count: number;
  842. type: string;
  843. max: number[];
  844. min: number[];
  845. sparse?: IGLTFAccessorSparse;
  846. index: number;
  847. }
  848. interface IGLTFAnimationChannel extends IGLTFProperty {
  849. sampler: number;
  850. target: IGLTFAnimationChannelTarget;
  851. }
  852. interface IGLTFAnimationChannelTarget extends IGLTFProperty {
  853. node: number;
  854. path: string;
  855. }
  856. interface IGLTFAnimationSampler extends IGLTFProperty {
  857. input: number;
  858. interpolation?: string;
  859. output: number;
  860. }
  861. interface IGLTFAnimation extends IGLTFChildRootProperty {
  862. channels: IGLTFAnimationChannel[];
  863. samplers: IGLTFAnimationSampler[];
  864. index: number;
  865. babylonAnimationGroup: AnimationGroup;
  866. }
  867. interface IGLTFAsset extends IGLTFChildRootProperty {
  868. copyright?: string;
  869. generator?: string;
  870. version: string;
  871. minVersion?: string;
  872. }
  873. interface IGLTFBuffer extends IGLTFChildRootProperty {
  874. uri?: string;
  875. byteLength: number;
  876. index: number;
  877. loadedData?: ArrayBufferView;
  878. loadedObservable?: Observable<IGLTFBuffer>;
  879. }
  880. interface IGLTFBufferView extends IGLTFChildRootProperty {
  881. buffer: number;
  882. byteOffset?: number;
  883. byteLength: number;
  884. byteStride?: number;
  885. index: number;
  886. }
  887. interface IGLTFCameraOrthographic extends IGLTFProperty {
  888. xmag: number;
  889. ymag: number;
  890. zfar: number;
  891. znear: number;
  892. }
  893. interface IGLTFCameraPerspective extends IGLTFProperty {
  894. aspectRatio: number;
  895. yfov: number;
  896. zfar: number;
  897. znear: number;
  898. }
  899. interface IGLTFCamera extends IGLTFChildRootProperty {
  900. orthographic?: IGLTFCameraOrthographic;
  901. perspective?: IGLTFCameraPerspective;
  902. type: string;
  903. }
  904. interface IGLTFImage extends IGLTFChildRootProperty {
  905. uri?: string;
  906. mimeType?: string;
  907. bufferView?: number;
  908. index: number;
  909. }
  910. interface IGLTFMaterialNormalTextureInfo extends IGLTFTextureInfo {
  911. scale: number;
  912. }
  913. interface IGLTFMaterialOcclusionTextureInfo extends IGLTFTextureInfo {
  914. strength: number;
  915. }
  916. interface IGLTFMaterialPbrMetallicRoughness {
  917. baseColorFactor: number[];
  918. baseColorTexture: IGLTFTextureInfo;
  919. metallicFactor: number;
  920. roughnessFactor: number;
  921. metallicRoughnessTexture: IGLTFTextureInfo;
  922. }
  923. interface IGLTFMaterial extends IGLTFChildRootProperty {
  924. pbrMetallicRoughness?: IGLTFMaterialPbrMetallicRoughness;
  925. normalTexture?: IGLTFMaterialNormalTextureInfo;
  926. occlusionTexture?: IGLTFMaterialOcclusionTextureInfo;
  927. emissiveTexture?: IGLTFTextureInfo;
  928. emissiveFactor?: number[];
  929. alphaMode?: string;
  930. alphaCutoff: number;
  931. doubleSided?: boolean;
  932. index: number;
  933. babylonMaterial: Material;
  934. }
  935. interface IGLTFMeshPrimitive extends IGLTFProperty {
  936. attributes: {
  937. [name: string]: number;
  938. };
  939. indices?: number;
  940. material?: number;
  941. mode?: EMeshPrimitiveMode;
  942. targets?: {
  943. [name: string]: number;
  944. }[];
  945. vertexData: VertexData;
  946. targetsVertexData: VertexData[];
  947. }
  948. interface IGLTFMesh extends IGLTFChildRootProperty {
  949. primitives: IGLTFMeshPrimitive[];
  950. weights?: number[];
  951. index: number;
  952. hasVertexAlpha: boolean;
  953. }
  954. interface IGLTFNode extends IGLTFChildRootProperty {
  955. camera?: number;
  956. children?: number[];
  957. skin?: number;
  958. matrix?: number[];
  959. mesh?: number;
  960. rotation?: number[];
  961. scale?: number[];
  962. translation?: number[];
  963. weights?: number[];
  964. index: number;
  965. parent: IGLTFNode;
  966. babylonMesh: Mesh;
  967. babylonAnimationTargets?: Node[];
  968. }
  969. interface IGLTFSampler extends IGLTFChildRootProperty {
  970. magFilter?: ETextureMagFilter;
  971. minFilter?: ETextureMinFilter;
  972. wrapS?: ETextureWrapMode;
  973. wrapT?: ETextureWrapMode;
  974. index: number;
  975. noMipMaps: boolean;
  976. samplingMode: number;
  977. wrapU: number;
  978. wrapV: number;
  979. }
  980. interface IGLTFScene extends IGLTFChildRootProperty {
  981. nodes: number[];
  982. index: number;
  983. }
  984. interface IGLTFSkin extends IGLTFChildRootProperty {
  985. inverseBindMatrices?: number;
  986. skeleton?: number;
  987. joints: number[];
  988. index: number;
  989. babylonSkeleton: Skeleton;
  990. }
  991. interface IGLTFTexture extends IGLTFChildRootProperty {
  992. sampler?: number;
  993. source: number;
  994. index: number;
  995. url?: string;
  996. dataReadyObservable?: Observable<IGLTFTexture>;
  997. }
  998. interface IGLTFTextureInfo {
  999. index: number;
  1000. texCoord?: number;
  1001. }
  1002. interface _IGLTF extends IGLTFProperty {
  1003. accessors?: IGLTFAccessor[];
  1004. animations?: IGLTFAnimation[];
  1005. asset: IGLTFAsset;
  1006. buffers?: IGLTFBuffer[];
  1007. bufferViews?: IGLTFBufferView[];
  1008. cameras?: IGLTFCamera[];
  1009. extensionsUsed?: string[];
  1010. extensionsRequired?: string[];
  1011. images?: IGLTFImage[];
  1012. materials?: IGLTFMaterial[];
  1013. meshes?: IGLTFMesh[];
  1014. nodes?: IGLTFNode[];
  1015. samplers?: IGLTFSampler[];
  1016. scene?: number;
  1017. scenes?: IGLTFScene[];
  1018. skins?: IGLTFSkin[];
  1019. textures?: IGLTFTexture[];
  1020. }
  1021. }
  1022. declare module BABYLON.GLTF2 {
  1023. class GLTFLoader implements IGLTFLoader {
  1024. _gltf: _IGLTF;
  1025. _babylonScene: Scene;
  1026. private _disposed;
  1027. private _rootUrl;
  1028. private _defaultMaterial;
  1029. private _defaultSampler;
  1030. private _rootNode;
  1031. private _successCallback?;
  1032. private _progressCallback?;
  1033. private _errorCallback?;
  1034. private _renderReady;
  1035. private _requests;
  1036. private _renderReadyObservable;
  1037. private _renderPendingCount;
  1038. private _loaderPendingCount;
  1039. private _loaderTrackers;
  1040. static Extensions: {
  1041. [name: string]: GLTFLoaderExtension;
  1042. };
  1043. static RegisterExtension(extension: GLTFLoaderExtension): void;
  1044. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  1045. animationStartMode: GLTFLoaderAnimationStartMode;
  1046. compileMaterials: boolean;
  1047. useClipPlane: boolean;
  1048. compileShadowGenerators: boolean;
  1049. onDisposeObservable: Observable<IGLTFLoader>;
  1050. onMeshLoadedObservable: Observable<AbstractMesh>;
  1051. onTextureLoadedObservable: Observable<BaseTexture>;
  1052. onMaterialLoadedObservable: Observable<Material>;
  1053. onCompleteObservable: Observable<IGLTFLoader>;
  1054. dispose(): void;
  1055. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
  1056. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void): void;
  1057. private _loadAsync(nodeNames, scene, data, rootUrl, onSuccess?, onProgress?, onError?);
  1058. private _onProgress();
  1059. _executeWhenRenderReady(func: () => void): void;
  1060. private _onRenderReady();
  1061. private _onComplete();
  1062. private _loadData(data);
  1063. private _getMeshes();
  1064. private _getSkeletons();
  1065. private _startAnimations();
  1066. private _loadDefaultScene(nodeNames);
  1067. private _loadScene(context, scene, nodeNames);
  1068. _loadNode(context: string, node: IGLTFNode): void;
  1069. private _loadMesh(context, node, mesh);
  1070. private _loadAllVertexDataAsync(context, mesh, onSuccess);
  1071. /**
  1072. * Converts a data bufferview into a Float4 Texture Coordinate Array, based on the accessor component type
  1073. * @param {ArrayBufferView} data
  1074. * @param {IGLTFAccessor} accessor
  1075. */
  1076. private _convertToFloat4TextureCoordArray(context, data, accessor);
  1077. /**
  1078. * Converts a data bufferview into a Float4 Color Array, based on the accessor component type
  1079. * @param {ArrayBufferView} data
  1080. * @param {IGLTFAccessor} accessor
  1081. */
  1082. private _convertToFloat4ColorArray(context, data, accessor);
  1083. private _loadVertexDataAsync(context, mesh, primitive, onSuccess);
  1084. private _createMorphTargets(context, node, mesh);
  1085. private _loadMorphTargets(context, node, mesh);
  1086. private _loadAllMorphTargetVertexDataAsync(context, node, mesh, onSuccess);
  1087. private _loadMorphTargetVertexDataAsync(context, vertexData, attributes, onSuccess);
  1088. private _loadTransform(node);
  1089. private _loadSkinAsync(context, skin, onSuccess);
  1090. private _createBone(node, skin, parent, localMatrix, baseMatrix, index);
  1091. private _loadBones(context, skin, inverseBindMatrixData);
  1092. private _loadBone(node, skin, inverseBindMatrixData, babylonBones);
  1093. private _getNodeMatrix(node);
  1094. private _traverseNodes(context, indices, action, parentNode);
  1095. _traverseNode(context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): void;
  1096. private _loadAnimations();
  1097. private _loadAnimation(context, animation);
  1098. private _loadAnimationChannel(animation, channelContext, channel, samplerContext, sampler);
  1099. private _loadBufferAsync(context, buffer, onSuccess);
  1100. private _loadBufferViewAsync(context, bufferView, onSuccess);
  1101. private _loadAccessorAsync(context, accessor, onSuccess);
  1102. private _buildArrayBuffer<T>(typedArray, data, byteOffset, count, numComponents, byteStride?);
  1103. _addPendingData(data: any): void;
  1104. _removePendingData(data: any): void;
  1105. _addLoaderPendingData(data: any): void;
  1106. _removeLoaderPendingData(data: any): void;
  1107. _whenAction(action: () => void, onComplete: () => void): void;
  1108. private _getDefaultMaterial();
  1109. private _loadMaterialMetallicRoughnessProperties(context, material);
  1110. _loadMaterial(context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): void;
  1111. _createPbrMaterial(material: IGLTFMaterial): void;
  1112. _loadMaterialBaseProperties(context: string, material: IGLTFMaterial): void;
  1113. _loadMaterialAlphaProperties(context: string, material: IGLTFMaterial, colorFactor: number[]): void;
  1114. _loadTexture(context: string, texture: IGLTFTexture, coordinatesIndex?: number): Texture;
  1115. private _loadSampler(context, sampler);
  1116. private _loadImageAsync(context, image, onSuccess);
  1117. _loadUriAsync(context: string, uri: string, onSuccess: (data: ArrayBufferView) => void): void;
  1118. _tryCatchOnError(handler: () => void): void;
  1119. private static _AssignIndices(array?);
  1120. static _GetProperty<T extends IGLTFProperty>(array?: ArrayLike<T>, index?: number): Nullable<T>;
  1121. private static _GetTextureWrapMode(context, mode?);
  1122. private static _GetTextureSamplingMode(context, magFilter?, minFilter?);
  1123. private static _GetNumComponents(context, type);
  1124. private _compileMaterialAsync(babylonMaterial, babylonMesh, onSuccess);
  1125. private _compileMaterialsAsync(onSuccess);
  1126. private _compileShadowGeneratorsAsync(onSuccess);
  1127. private _abortRequests();
  1128. private _releaseResources();
  1129. }
  1130. }
  1131. declare module BABYLON.GLTF2 {
  1132. /**
  1133. * Utils functions for GLTF
  1134. */
  1135. class GLTFUtils {
  1136. /**
  1137. * If the uri is a base64 string
  1138. * @param uri: the uri to test
  1139. */
  1140. static IsBase64(uri: string): boolean;
  1141. /**
  1142. * Decode the base64 uri
  1143. * @param uri: the uri to decode
  1144. */
  1145. static DecodeBase64(uri: string): ArrayBuffer;
  1146. static ValidateUri(uri: string): boolean;
  1147. }
  1148. }
  1149. declare module BABYLON.GLTF2 {
  1150. abstract class GLTFLoaderExtension {
  1151. enabled: boolean;
  1152. readonly abstract name: string;
  1153. protected _traverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean;
  1154. protected _loadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean;
  1155. protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
  1156. protected _loadExtension<T>(context: string, property: IGLTFProperty, action: (context: string, extension: T, onComplete: () => void) => void): boolean;
  1157. static _Extensions: GLTFLoaderExtension[];
  1158. static TraverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean;
  1159. static LoadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean;
  1160. static LoadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
  1161. private static _ApplyExtensions(action);
  1162. }
  1163. }
  1164. declare module BABYLON.GLTF2.Extensions {
  1165. class MSFTLOD extends GLTFLoaderExtension {
  1166. /**
  1167. * Specify the minimal delay between LODs in ms (default = 250)
  1168. */
  1169. Delay: number;
  1170. readonly name: string;
  1171. protected _traverseNode(loader: GLTFLoader, context: string, node: IGLTFNode, action: (node: IGLTFNode, parentNode: IGLTFNode) => boolean, parentNode: IGLTFNode): boolean;
  1172. protected _loadNode(loader: GLTFLoader, context: string, node: IGLTFNode): boolean;
  1173. private _loadNodeLOD(loader, context, nodes, index, onComplete);
  1174. protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
  1175. private _loadMaterialLOD(loader, context, materials, index, assign, onComplete);
  1176. }
  1177. }
  1178. declare module BABYLON.GLTF2.Extensions {
  1179. class KHRMaterialsPbrSpecularGlossiness extends GLTFLoaderExtension {
  1180. readonly name: string;
  1181. protected _loadMaterial(loader: GLTFLoader, context: string, material: IGLTFMaterial, assign: (babylonMaterial: Material, isNew: boolean) => void): boolean;
  1182. private _loadSpecularGlossinessProperties(loader, context, material, properties);
  1183. }
  1184. }