babylonjs.loaders.module.d.ts 45 KB

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