babylon.glTF1FileLoader.d.ts 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. declare module BABYLON {
  2. enum GLTFLoaderCoordinateSystemMode {
  3. /**
  4. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  5. */
  6. AUTO = 0,
  7. /**
  8. * Sets the useRightHandedSystem flag on the scene.
  9. */
  10. FORCE_RIGHT_HANDED = 1,
  11. }
  12. enum GLTFLoaderAnimationStartMode {
  13. /**
  14. * No animation will start.
  15. */
  16. NONE = 0,
  17. /**
  18. * The first animation will start.
  19. */
  20. FIRST = 1,
  21. /**
  22. * All animations will start.
  23. */
  24. ALL = 2,
  25. }
  26. interface IGLTFLoaderData {
  27. json: Object;
  28. bin: Nullable<ArrayBufferView>;
  29. }
  30. interface IGLTFLoader extends IDisposable {
  31. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void;
  32. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void) => void;
  33. }
  34. class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  35. static CreateGLTFLoaderV1: (parent: GLTFFileLoader) => IGLTFLoader;
  36. static CreateGLTFLoaderV2: (parent: GLTFFileLoader) => IGLTFLoader;
  37. /**
  38. * Raised when the asset has been parsed.
  39. * The data.json property stores the glTF JSON.
  40. * The data.bin property stores the BIN chunk from a glTF binary or null if the input is not a glTF binary.
  41. */
  42. onParsed: (data: IGLTFLoaderData) => void;
  43. static IncrementalLoading: boolean;
  44. static HomogeneousCoordinates: boolean;
  45. /**
  46. * The coordinate system mode (AUTO, FORCE_RIGHT_HANDED).
  47. */
  48. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  49. /**
  50. * The animation start mode (NONE, FIRST, ALL).
  51. */
  52. animationStartMode: GLTFLoaderAnimationStartMode;
  53. /**
  54. * Set to true to compile materials before raising the success callback.
  55. */
  56. compileMaterials: boolean;
  57. /**
  58. * Set to true to also compile materials with clip planes.
  59. */
  60. useClipPlane: boolean;
  61. /**
  62. * Set to true to compile shadow generators before raising the success callback.
  63. */
  64. compileShadowGenerators: boolean;
  65. /**
  66. * Raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  67. */
  68. onMeshLoaded: (mesh: AbstractMesh) => void;
  69. /**
  70. * Raised when the loader creates a texture after parsing the glTF properties of the texture.
  71. */
  72. onTextureLoaded: (texture: BaseTexture) => void;
  73. /**
  74. * Raised when the loader creates a material after parsing the glTF properties of the material.
  75. */
  76. onMaterialLoaded: (material: Material) => void;
  77. /**
  78. * Raised when the asset is completely loaded, immediately before the loader is disposed.
  79. * For assets with LODs, raised when all of the LODs are complete.
  80. * For assets without LODs, raised when the model is complete, immediately after onSuccess.
  81. */
  82. onComplete: () => void;
  83. private _loader;
  84. name: string;
  85. extensions: ISceneLoaderPluginExtensions;
  86. /**
  87. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  88. */
  89. dispose(): void;
  90. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;
  91. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;
  92. canDirectLoad(data: string): boolean;
  93. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  94. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  95. private static _parse(data);
  96. private _getLoader(loaderData);
  97. private static _parseBinary(data);
  98. private static _parseV1(binaryReader);
  99. private static _parseV2(binaryReader);
  100. private static _parseVersion(version);
  101. private static _compareVersion(a, b);
  102. private static _decodeBufferToText(buffer);
  103. }
  104. }
  105. declare module BABYLON.GLTF1 {
  106. /**
  107. * Enums
  108. */
  109. enum EComponentType {
  110. BYTE = 5120,
  111. UNSIGNED_BYTE = 5121,
  112. SHORT = 5122,
  113. UNSIGNED_SHORT = 5123,
  114. FLOAT = 5126,
  115. }
  116. enum EShaderType {
  117. FRAGMENT = 35632,
  118. VERTEX = 35633,
  119. }
  120. enum EParameterType {
  121. BYTE = 5120,
  122. UNSIGNED_BYTE = 5121,
  123. SHORT = 5122,
  124. UNSIGNED_SHORT = 5123,
  125. INT = 5124,
  126. UNSIGNED_INT = 5125,
  127. FLOAT = 5126,
  128. FLOAT_VEC2 = 35664,
  129. FLOAT_VEC3 = 35665,
  130. FLOAT_VEC4 = 35666,
  131. INT_VEC2 = 35667,
  132. INT_VEC3 = 35668,
  133. INT_VEC4 = 35669,
  134. BOOL = 35670,
  135. BOOL_VEC2 = 35671,
  136. BOOL_VEC3 = 35672,
  137. BOOL_VEC4 = 35673,
  138. FLOAT_MAT2 = 35674,
  139. FLOAT_MAT3 = 35675,
  140. FLOAT_MAT4 = 35676,
  141. SAMPLER_2D = 35678,
  142. }
  143. enum ETextureWrapMode {
  144. CLAMP_TO_EDGE = 33071,
  145. MIRRORED_REPEAT = 33648,
  146. REPEAT = 10497,
  147. }
  148. enum ETextureFilterType {
  149. NEAREST = 9728,
  150. LINEAR = 9728,
  151. NEAREST_MIPMAP_NEAREST = 9984,
  152. LINEAR_MIPMAP_NEAREST = 9985,
  153. NEAREST_MIPMAP_LINEAR = 9986,
  154. LINEAR_MIPMAP_LINEAR = 9987,
  155. }
  156. enum ETextureFormat {
  157. ALPHA = 6406,
  158. RGB = 6407,
  159. RGBA = 6408,
  160. LUMINANCE = 6409,
  161. LUMINANCE_ALPHA = 6410,
  162. }
  163. enum ECullingType {
  164. FRONT = 1028,
  165. BACK = 1029,
  166. FRONT_AND_BACK = 1032,
  167. }
  168. enum EBlendingFunction {
  169. ZERO = 0,
  170. ONE = 1,
  171. SRC_COLOR = 768,
  172. ONE_MINUS_SRC_COLOR = 769,
  173. DST_COLOR = 774,
  174. ONE_MINUS_DST_COLOR = 775,
  175. SRC_ALPHA = 770,
  176. ONE_MINUS_SRC_ALPHA = 771,
  177. DST_ALPHA = 772,
  178. ONE_MINUS_DST_ALPHA = 773,
  179. CONSTANT_COLOR = 32769,
  180. ONE_MINUS_CONSTANT_COLOR = 32770,
  181. CONSTANT_ALPHA = 32771,
  182. ONE_MINUS_CONSTANT_ALPHA = 32772,
  183. SRC_ALPHA_SATURATE = 776,
  184. }
  185. /**
  186. * Interfaces
  187. */
  188. interface IGLTFProperty {
  189. extensions?: {
  190. [key: string]: any;
  191. };
  192. extras?: Object;
  193. }
  194. interface IGLTFChildRootProperty extends IGLTFProperty {
  195. name?: string;
  196. }
  197. interface IGLTFAccessor extends IGLTFChildRootProperty {
  198. bufferView: string;
  199. byteOffset: number;
  200. byteStride: number;
  201. count: number;
  202. type: string;
  203. componentType: EComponentType;
  204. max?: number[];
  205. min?: number[];
  206. name?: string;
  207. }
  208. interface IGLTFBufferView extends IGLTFChildRootProperty {
  209. buffer: string;
  210. byteOffset: number;
  211. byteLength: number;
  212. byteStride: number;
  213. target?: number;
  214. }
  215. interface IGLTFBuffer extends IGLTFChildRootProperty {
  216. uri: string;
  217. byteLength?: number;
  218. type?: string;
  219. }
  220. interface IGLTFShader extends IGLTFChildRootProperty {
  221. uri: string;
  222. type: EShaderType;
  223. }
  224. interface IGLTFProgram extends IGLTFChildRootProperty {
  225. attributes: string[];
  226. fragmentShader: string;
  227. vertexShader: string;
  228. }
  229. interface IGLTFTechniqueParameter {
  230. type: number;
  231. count?: number;
  232. semantic?: string;
  233. node?: string;
  234. value?: number | boolean | string | Array<any>;
  235. source?: string;
  236. babylonValue?: any;
  237. }
  238. interface IGLTFTechniqueCommonProfile {
  239. lightingModel: string;
  240. texcoordBindings: Object;
  241. parameters?: Array<any>;
  242. }
  243. interface IGLTFTechniqueStatesFunctions {
  244. blendColor?: number[];
  245. blendEquationSeparate?: number[];
  246. blendFuncSeparate?: number[];
  247. colorMask: boolean[];
  248. cullFace: number[];
  249. }
  250. interface IGLTFTechniqueStates {
  251. enable: number[];
  252. functions: IGLTFTechniqueStatesFunctions;
  253. }
  254. interface IGLTFTechnique extends IGLTFChildRootProperty {
  255. parameters: {
  256. [key: string]: IGLTFTechniqueParameter;
  257. };
  258. program: string;
  259. attributes: {
  260. [key: string]: string;
  261. };
  262. uniforms: {
  263. [key: string]: string;
  264. };
  265. states: IGLTFTechniqueStates;
  266. }
  267. interface IGLTFMaterial extends IGLTFChildRootProperty {
  268. technique?: string;
  269. values: string[];
  270. }
  271. interface IGLTFMeshPrimitive extends IGLTFProperty {
  272. attributes: {
  273. [key: string]: string;
  274. };
  275. indices: string;
  276. material: string;
  277. mode?: number;
  278. }
  279. interface IGLTFMesh extends IGLTFChildRootProperty {
  280. primitives: IGLTFMeshPrimitive[];
  281. }
  282. interface IGLTFImage extends IGLTFChildRootProperty {
  283. uri: string;
  284. }
  285. interface IGLTFSampler extends IGLTFChildRootProperty {
  286. magFilter?: number;
  287. minFilter?: number;
  288. wrapS?: number;
  289. wrapT?: number;
  290. }
  291. interface IGLTFTexture extends IGLTFChildRootProperty {
  292. sampler: string;
  293. source: string;
  294. format?: ETextureFormat;
  295. internalFormat?: ETextureFormat;
  296. target?: number;
  297. type?: number;
  298. babylonTexture?: Texture;
  299. }
  300. interface IGLTFAmbienLight {
  301. color?: number[];
  302. }
  303. interface IGLTFDirectionalLight {
  304. color?: number[];
  305. }
  306. interface IGLTFPointLight {
  307. color?: number[];
  308. constantAttenuation?: number;
  309. linearAttenuation?: number;
  310. quadraticAttenuation?: number;
  311. }
  312. interface IGLTFSpotLight {
  313. color?: number[];
  314. constantAttenuation?: number;
  315. fallOfAngle?: number;
  316. fallOffExponent?: number;
  317. linearAttenuation?: number;
  318. quadraticAttenuation?: number;
  319. }
  320. interface IGLTFLight extends IGLTFChildRootProperty {
  321. type: string;
  322. }
  323. interface IGLTFCameraOrthographic {
  324. xmag: number;
  325. ymag: number;
  326. zfar: number;
  327. znear: number;
  328. }
  329. interface IGLTFCameraPerspective {
  330. aspectRatio: number;
  331. yfov: number;
  332. zfar: number;
  333. znear: number;
  334. }
  335. interface IGLTFCamera extends IGLTFChildRootProperty {
  336. type: string;
  337. }
  338. interface IGLTFAnimationChannelTarget {
  339. id: string;
  340. path: string;
  341. }
  342. interface IGLTFAnimationChannel {
  343. sampler: string;
  344. target: IGLTFAnimationChannelTarget;
  345. }
  346. interface IGLTFAnimationSampler {
  347. input: string;
  348. output: string;
  349. interpolation?: string;
  350. }
  351. interface IGLTFAnimation extends IGLTFChildRootProperty {
  352. channels?: IGLTFAnimationChannel[];
  353. parameters?: {
  354. [key: string]: string;
  355. };
  356. samplers?: {
  357. [key: string]: IGLTFAnimationSampler;
  358. };
  359. }
  360. interface IGLTFNodeInstanceSkin {
  361. skeletons: string[];
  362. skin: string;
  363. meshes: string[];
  364. }
  365. interface IGLTFSkins extends IGLTFChildRootProperty {
  366. bindShapeMatrix: number[];
  367. inverseBindMatrices: string;
  368. jointNames: string[];
  369. babylonSkeleton?: Skeleton;
  370. }
  371. interface IGLTFNode extends IGLTFChildRootProperty {
  372. camera?: string;
  373. children: string[];
  374. skin?: string;
  375. jointName?: string;
  376. light?: string;
  377. matrix: number[];
  378. mesh?: string;
  379. meshes?: string[];
  380. rotation?: number[];
  381. scale?: number[];
  382. translation?: number[];
  383. babylonNode?: Node;
  384. }
  385. interface IGLTFScene extends IGLTFChildRootProperty {
  386. nodes: string[];
  387. }
  388. /**
  389. * Runtime
  390. */
  391. interface IGLTFRuntime {
  392. extensions: {
  393. [key: string]: any;
  394. };
  395. accessors: {
  396. [key: string]: IGLTFAccessor;
  397. };
  398. buffers: {
  399. [key: string]: IGLTFBuffer;
  400. };
  401. bufferViews: {
  402. [key: string]: IGLTFBufferView;
  403. };
  404. meshes: {
  405. [key: string]: IGLTFMesh;
  406. };
  407. lights: {
  408. [key: string]: IGLTFLight;
  409. };
  410. cameras: {
  411. [key: string]: IGLTFCamera;
  412. };
  413. nodes: {
  414. [key: string]: IGLTFNode;
  415. };
  416. images: {
  417. [key: string]: IGLTFImage;
  418. };
  419. textures: {
  420. [key: string]: IGLTFTexture;
  421. };
  422. shaders: {
  423. [key: string]: IGLTFShader;
  424. };
  425. programs: {
  426. [key: string]: IGLTFProgram;
  427. };
  428. samplers: {
  429. [key: string]: IGLTFSampler;
  430. };
  431. techniques: {
  432. [key: string]: IGLTFTechnique;
  433. };
  434. materials: {
  435. [key: string]: IGLTFMaterial;
  436. };
  437. animations: {
  438. [key: string]: IGLTFAnimation;
  439. };
  440. skins: {
  441. [key: string]: IGLTFSkins;
  442. };
  443. currentScene?: Object;
  444. scenes: {
  445. [key: string]: IGLTFScene;
  446. };
  447. extensionsUsed: string[];
  448. extensionsRequired?: string[];
  449. buffersCount: number;
  450. shaderscount: number;
  451. scene: Scene;
  452. rootUrl: string;
  453. loadedBufferCount: number;
  454. loadedBufferViews: {
  455. [name: string]: ArrayBufferView;
  456. };
  457. loadedShaderCount: number;
  458. importOnlyMeshes: boolean;
  459. importMeshesNames?: string[];
  460. dummyNodes: Node[];
  461. }
  462. /**
  463. * Bones
  464. */
  465. interface INodeToRoot {
  466. bone: Bone;
  467. node: IGLTFNode;
  468. id: string;
  469. }
  470. interface IJointNode {
  471. node: IGLTFNode;
  472. id: string;
  473. }
  474. }
  475. declare module BABYLON.GLTF1 {
  476. /**
  477. * Implementation of the base glTF spec
  478. */
  479. class GLTFLoaderBase {
  480. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  481. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  482. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  483. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  484. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): void;
  485. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  486. }
  487. /**
  488. * glTF V1 Loader
  489. */
  490. class GLTFLoader implements IGLTFLoader {
  491. static Extensions: {
  492. [name: string]: GLTFLoaderExtension;
  493. };
  494. static RegisterExtension(extension: GLTFLoaderExtension): void;
  495. dispose(): void;
  496. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): boolean;
  497. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: () => void, onProgress: (event: ProgressEvent) => void, onError: (message: string) => void): void;
  498. private _loadShadersAsync(gltfRuntime, onload);
  499. private _loadBuffersAsync(gltfRuntime, onLoad, onProgress?);
  500. private _createNodes(gltfRuntime);
  501. }
  502. }
  503. declare module BABYLON.GLTF1 {
  504. /**
  505. * Utils functions for GLTF
  506. */
  507. class GLTFUtils {
  508. /**
  509. * Sets the given "parameter" matrix
  510. * @param scene: the {BABYLON.Scene} object
  511. * @param source: the source node where to pick the matrix
  512. * @param parameter: the GLTF technique parameter
  513. * @param uniformName: the name of the shader's uniform
  514. * @param shaderMaterial: the shader material
  515. */
  516. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  517. /**
  518. * Sets the given "parameter" matrix
  519. * @param shaderMaterial: the shader material
  520. * @param uniform: the name of the shader's uniform
  521. * @param value: the value of the uniform
  522. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  523. */
  524. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  525. /**
  526. * If the uri is a base64 string
  527. * @param uri: the uri to test
  528. */
  529. static IsBase64(uri: string): boolean;
  530. /**
  531. * Decode the base64 uri
  532. * @param uri: the uri to decode
  533. */
  534. static DecodeBase64(uri: string): ArrayBuffer;
  535. /**
  536. * Returns the wrap mode of the texture
  537. * @param mode: the mode value
  538. */
  539. static GetWrapMode(mode: number): number;
  540. /**
  541. * Returns the byte stride giving an accessor
  542. * @param accessor: the GLTF accessor objet
  543. */
  544. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  545. /**
  546. * Returns the texture filter mode giving a mode value
  547. * @param mode: the filter mode value
  548. */
  549. static GetTextureFilterMode(mode: number): ETextureFilterType;
  550. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  551. /**
  552. * Returns a buffer from its accessor
  553. * @param gltfRuntime: the GLTF runtime
  554. * @param accessor: the GLTF accessor
  555. */
  556. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  557. /**
  558. * Decodes a buffer view into a string
  559. * @param view: the buffer view
  560. */
  561. static DecodeBufferToText(view: ArrayBufferView): string;
  562. /**
  563. * Returns the default material of gltf. Related to
  564. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  565. * @param scene: the Babylon.js scene
  566. */
  567. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  568. private static _DefaultMaterial;
  569. }
  570. }
  571. declare module BABYLON.GLTF1 {
  572. abstract class GLTFLoaderExtension {
  573. private _name;
  574. constructor(name: string);
  575. readonly name: string;
  576. /**
  577. * Defines an override for loading the runtime
  578. * Return true to stop further extensions from loading the runtime
  579. */
  580. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  581. /**
  582. * Defines an onverride for creating gltf runtime
  583. * Return true to stop further extensions from creating the runtime
  584. */
  585. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  586. /**
  587. * Defines an override for loading buffers
  588. * Return true to stop further extensions from loading this buffer
  589. */
  590. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  591. /**
  592. * Defines an override for loading texture buffers
  593. * Return true to stop further extensions from loading this texture data
  594. */
  595. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  596. /**
  597. * Defines an override for creating textures
  598. * Return true to stop further extensions from loading this texture
  599. */
  600. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  601. /**
  602. * Defines an override for loading shader strings
  603. * Return true to stop further extensions from loading this shader data
  604. */
  605. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  606. /**
  607. * Defines an override for loading materials
  608. * Return true to stop further extensions from loading this material
  609. */
  610. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  611. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): void;
  612. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): void;
  613. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  614. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  615. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string) => void, onError: (message: string) => void): void;
  616. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  617. private static LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError);
  618. private static CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError);
  619. private static ApplyExtensions(func, defaultFunc);
  620. }
  621. }
  622. declare module BABYLON.GLTF1 {
  623. class GLTFBinaryExtension extends GLTFLoaderExtension {
  624. private _bin;
  625. constructor();
  626. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  627. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  628. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  629. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  630. }
  631. }
  632. declare module BABYLON.GLTF1 {
  633. class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  634. constructor();
  635. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  636. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  637. private _loadTexture(gltfRuntime, id, material, propertyPath, onError);
  638. }
  639. }