babylon.glTF1FileLoader.d.ts 27 KB

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