babylon.glTFFileLoaderInterfaces.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. module BABYLON {
  2. /**
  3. * Enums
  4. */
  5. export enum EComponentType {
  6. BYTE = 5120,
  7. UNSIGNED_BYTE = 5121,
  8. SHORT = 5122,
  9. UNSIGNED_SHORT = 5123,
  10. FLOAT = 5126
  11. }
  12. export enum EShaderType {
  13. FRAGMENT = 35632,
  14. VERTEX = 35633
  15. }
  16. export enum EParameterType {
  17. BYTE = 5120,
  18. UNSIGNED_BYTE = 5121,
  19. SHORT = 5122,
  20. UNSIGNED_SHORT = 5123,
  21. INT = 5124,
  22. UNSIGNED_INT = 5125,
  23. FLOAT = 5126,
  24. FLOAT_VEC2 = 35664,
  25. FLOAT_VEC3 = 35665,
  26. FLOAT_VEC4 = 35666,
  27. INT_VEC2 = 35667,
  28. INT_VEC3 = 35668,
  29. INT_VEC4 = 35669,
  30. BOOL = 35670,
  31. BOOL_VEC2 = 35671,
  32. BOOL_VEC3 = 35672,
  33. BOOL_VEC4 = 35673,
  34. FLOAT_MAT2 = 35674,
  35. FLOAT_MAT3 = 35675,
  36. FLOAT_MAT4 = 35676,
  37. SAMPLER_2D = 35678
  38. }
  39. export enum ETextureWrapMode {
  40. CLAMP_TO_EDGE = 33071,
  41. MIRRORED_REPEAT = 33648,
  42. REPEAT = 10497
  43. }
  44. export enum ETextureFilterType {
  45. NEAREST = 9728,
  46. LINEAR = 9728,
  47. NEAREST_MIPMAP_NEAREST = 9984,
  48. LINEAR_MIPMAP_NEAREST = 9985,
  49. NEAREST_MIPMAP_LINEAR = 9986,
  50. LINEAR_MIPMAP_LINEAR = 9987
  51. }
  52. export enum ETextureFormat {
  53. ALPHA = 6406,
  54. RGB = 6407,
  55. RGBA = 6408,
  56. LUMINANCE = 6409,
  57. LUMINANCE_ALPHA = 6410
  58. }
  59. export enum ECullingType {
  60. FRONT = 1028,
  61. BACK = 1029,
  62. FRONT_AND_BACK = 1032
  63. }
  64. export enum EBlendingFunction {
  65. ZERO = 0,
  66. ONE = 1,
  67. SRC_COLOR = 768,
  68. ONE_MINUS_SRC_COLOR = 769,
  69. DST_COLOR = 774,
  70. ONE_MINUS_DST_COLOR = 775,
  71. SRC_ALPHA = 770,
  72. ONE_MINUS_SRC_ALPHA = 771,
  73. DST_ALPHA = 772,
  74. ONE_MINUS_DST_ALPHA = 773,
  75. CONSTANT_COLOR = 32769,
  76. ONE_MINUS_CONSTANT_COLOR = 32770,
  77. CONSTANT_ALPHA = 32771,
  78. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79. SRC_ALPHA_SATURATE = 776
  80. }
  81. /**
  82. * Interfaces
  83. */
  84. export interface IGLTFProperty {
  85. extensions?: Object;
  86. extras?: Object;
  87. }
  88. export interface IGLTFChildRootProperty extends IGLTFProperty {
  89. name?: string;
  90. }
  91. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  92. bufferView: string;
  93. byteOffset: number;
  94. byteStride: number;
  95. count: number;
  96. type: string;
  97. componentType: EComponentType;
  98. max?: number[],
  99. min?: number[],
  100. name?: string;
  101. }
  102. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  103. buffer: string;
  104. byteOffset: number;
  105. byteLength: number;
  106. target?: number;
  107. }
  108. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  109. uri: string;
  110. byteLength?: number;
  111. type?: string;
  112. }
  113. export interface IGLTFShader extends IGLTFChildRootProperty {
  114. uri: string;
  115. type: EShaderType;
  116. }
  117. export interface IGLTFProgram extends IGLTFChildRootProperty {
  118. attributes: string[];
  119. fragmentShader: string;
  120. vertexShader: string;
  121. }
  122. export interface IGLTFTechniqueParameter {
  123. type: number;
  124. count?: number;
  125. semantic?: string;
  126. node?: string;
  127. value?: number|boolean|string|Array<any>;
  128. source?: string;
  129. babylonValue?: any;
  130. }
  131. export interface IGLTFTechniqueCommonProfile {
  132. lightingModel: string;
  133. texcoordBindings: Object;
  134. parameters?: Array<any>;
  135. }
  136. export interface IGLTFTechniqueStatesFunctions {
  137. blendColor?: number[];
  138. blendEquationSeparate?: number[];
  139. blendFuncSeparate?: number[];
  140. colorMask: boolean[];
  141. cullFace: number[];
  142. }
  143. export interface IGLTFTechniqueStates {
  144. enable: number[];
  145. functions: IGLTFTechniqueStatesFunctions;
  146. }
  147. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  148. parameters: Object;
  149. program: string;
  150. attributes: Object;
  151. uniforms: Object;
  152. states: IGLTFTechniqueStates;
  153. }
  154. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  155. technique?: string;
  156. values: string[];
  157. }
  158. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  159. attributes: Object;
  160. indices: string;
  161. material: string;
  162. mode?: number;
  163. }
  164. export interface IGLTFMesh extends IGLTFChildRootProperty {
  165. primitives: IGLTFMeshPrimitive[];
  166. }
  167. export interface IGLTFImage extends IGLTFChildRootProperty {
  168. uri: string;
  169. }
  170. export interface IGLTFSampler extends IGLTFChildRootProperty {
  171. magFilter?: number;
  172. minFilter?: number;
  173. wrapS?: number;
  174. wrapT?: number;
  175. }
  176. export interface IGLTFTexture extends IGLTFChildRootProperty {
  177. sampler: string;
  178. source: string;
  179. format?: ETextureFormat;
  180. internalFormat?: ETextureFormat;
  181. target?: number;
  182. type?: number;
  183. // Babylon.js values (optimize)
  184. babylonTexture?: Texture;
  185. }
  186. export interface IGLTFAmbienLight {
  187. color?: number[];
  188. }
  189. export interface IGLTFDirectionalLight {
  190. color?: number[];
  191. }
  192. export interface IGLTFPointLight {
  193. color?: number[];
  194. constantAttenuation?: number;
  195. linearAttenuation?: number;
  196. quadraticAttenuation?: number;
  197. }
  198. export interface IGLTFSpotLight {
  199. color?: number[];
  200. constantAttenuation?: number;
  201. fallOfAngle?: number;
  202. fallOffExponent?: number;
  203. linearAttenuation?: number;
  204. quadraticAttenuation?: number;
  205. }
  206. export interface IGLTFLight extends IGLTFChildRootProperty {
  207. type: string;
  208. }
  209. export interface IGLTFCameraOrthographic {
  210. xmag: number;
  211. ymag: number;
  212. zfar: number;
  213. znear: number;
  214. }
  215. export interface IGLTFCameraPerspective {
  216. aspectRatio: number;
  217. yfov: number;
  218. zfar: number;
  219. znear: number;
  220. }
  221. export interface IGLTFCamera extends IGLTFChildRootProperty {
  222. type: string;
  223. }
  224. export interface IGLTFAnimationChannelTarget {
  225. id: string;
  226. path: string;
  227. }
  228. export interface IGLTFAnimationChannel {
  229. sampler: string;
  230. target: IGLTFAnimationChannelTarget;
  231. }
  232. export interface IGLTFAnimationSampler {
  233. input: string;
  234. output: string;
  235. interpolation?: string;
  236. }
  237. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  238. channels?: IGLTFAnimationChannel[];
  239. parameters?: Object;
  240. samplers?: Object;
  241. }
  242. export interface IGLTFNodeInstanceSkin {
  243. skeletons: string[];
  244. skin: string;
  245. meshes: string[];
  246. }
  247. export interface IGLTFSkins extends IGLTFChildRootProperty {
  248. bindShapeMatrix: number[];
  249. inverseBindMatrices: string;
  250. jointNames: string[];
  251. babylonSkeleton?: Skeleton;
  252. }
  253. export interface IGLTFNode extends IGLTFChildRootProperty {
  254. camera?: string;
  255. children: string[];
  256. skin?: string;
  257. jointName?: string;
  258. light?: string;
  259. matrix: number[];
  260. mesh?: string;
  261. meshes?: string[];
  262. rotation?: number[];
  263. scale?: number[];
  264. translation?: number[];
  265. // Babylon.js values (optimize)
  266. babylonNode?: Node;
  267. }
  268. export interface IGLTFScene extends IGLTFChildRootProperty {
  269. nodes: string[];
  270. }
  271. /**
  272. * Runtime
  273. */
  274. export interface IGLTFRuntime {
  275. accessors: Object;
  276. buffers: Object;
  277. bufferViews: Object;
  278. meshes: Object;
  279. lights: Object;
  280. cameras: Object;
  281. nodes: Object;
  282. images: Object;
  283. textures: Object;
  284. shaders: Object;
  285. programs: Object;
  286. samplers: Object;
  287. techniques: Object;
  288. materials: Object;
  289. animations: Object;
  290. skins: Object;
  291. currentScene: Object;
  292. extensionsUsed: string[];
  293. buffersCount: number;
  294. shaderscount: number;
  295. scene: Scene;
  296. rootUrl: string;
  297. loadedBufferCount: number;
  298. loadedBufferViews: { [name: string]: ArrayBufferView };
  299. loadedShaderCount: number;
  300. importOnlyMeshes: boolean;
  301. importMeshesNames?: string[];
  302. dummyNodes: Node[];
  303. }
  304. /**
  305. * Bones
  306. */
  307. export interface INodeToRoot {
  308. bone: Bone;
  309. node: IGLTFNode;
  310. id: string;
  311. }
  312. export interface IJointNode {
  313. node: IGLTFNode;
  314. id: string;
  315. }
  316. /**
  317. * Extensions
  318. */
  319. export interface IGLTFExtension {
  320. /**
  321. * The name of the extension (example: "KHR_materials_pbr" cf. https://github.com/tsturm/glTF/tree/master/extensions/Vendor/FRAUNHOFER_materials_pbr)
  322. */
  323. extensionName: string;
  324. }
  325. export interface IGLTFLoaderExtension<ExtensionType extends Object, ExtensionObject extends Object> extends IGLTFExtension {
  326. /**
  327. * If the extensions needs the loader to skip its default behavior
  328. * Example, when loading materials, if the loader should use only the extension
  329. * or load the shader material and call the extension to customize the shader material
  330. */
  331. needToSkipDefaultLoaderBehavior(id: string, extension: ExtensionType): boolean;
  332. /**
  333. * Apply extension method
  334. */
  335. apply(gltfRuntime: IGLTFRuntime, id: string, name: string, extension: ExtensionType, object: ExtensionObject): ExtensionObject;
  336. }
  337. export enum EContentFormat {
  338. JSON = 0
  339. };
  340. export const BinaryExtensionName = "KHR_binary_glTF";
  341. export const BinaryExtensionBufferName = "binary_glTF";
  342. export interface IGLTFBinaryExtension {
  343. content: Object;
  344. body: Uint8Array;
  345. };
  346. export interface IGLTFBinaryExtensionShader {
  347. bufferView: string;
  348. };
  349. export interface IGLTFBinaryExtensionImage {
  350. bufferView: string;
  351. mimeType: string;
  352. height: number;
  353. width: number;
  354. };
  355. }