glTFLoaderInterfaces.ts 9.3 KB

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