babylon.glTFLoaderInterfaces.ts 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. /// <reference path="../../../../dist/preview release/babylon.d.ts"/>
  2. module BABYLON.GLTF2 {
  3. /**
  4. * Enums
  5. */
  6. export enum EComponentType {
  7. BYTE = 5120,
  8. UNSIGNED_BYTE = 5121,
  9. SHORT = 5122,
  10. UNSIGNED_SHORT = 5123,
  11. UNSIGNED_INT = 5125,
  12. FLOAT = 5126
  13. }
  14. export enum EMeshPrimitiveMode {
  15. POINTS = 0,
  16. LINES = 1,
  17. LINE_LOOP = 2,
  18. LINE_STRIP = 3,
  19. TRIANGLES = 4,
  20. TRIANGLE_STRIP = 5,
  21. TRIANGLE_FAN = 6
  22. }
  23. export enum ETextureMagFilter {
  24. NEAREST = 9728,
  25. LINEAR = 9729,
  26. }
  27. export enum ETextureMinFilter {
  28. NEAREST = 9728,
  29. LINEAR = 9729,
  30. NEAREST_MIPMAP_NEAREST = 9984,
  31. LINEAR_MIPMAP_NEAREST = 9985,
  32. NEAREST_MIPMAP_LINEAR = 9986,
  33. LINEAR_MIPMAP_LINEAR = 9987
  34. }
  35. export enum ETextureWrapMode {
  36. CLAMP_TO_EDGE = 33071,
  37. MIRRORED_REPEAT = 33648,
  38. REPEAT = 10497
  39. }
  40. /**
  41. * Interfaces
  42. */
  43. export interface IGLTFProperty {
  44. extensions?: Object;
  45. extras?: any;
  46. }
  47. export interface IGLTFChildRootProperty extends IGLTFProperty {
  48. name?: string;
  49. }
  50. export interface IGLTFAccessorSparseIndices extends IGLTFProperty {
  51. bufferView: number;
  52. byteOffset?: number;
  53. componentType: EComponentType;
  54. }
  55. export interface IGLTFAccessorSparseValues extends IGLTFProperty {
  56. bufferView: number;
  57. byteOffset?: number;
  58. }
  59. export interface IGLTFAccessorSparse extends IGLTFProperty {
  60. count: number;
  61. indices: IGLTFAccessorSparseIndices;
  62. values: IGLTFAccessorSparseValues;
  63. }
  64. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  65. bufferView?: number;
  66. byteOffset?: number;
  67. componentType: EComponentType;
  68. normalized?: boolean;
  69. count: number;
  70. type: string;
  71. max: number[];
  72. min: number[];
  73. sparse?: IGLTFAccessorSparse;
  74. }
  75. export interface IGLTFAnimationChannel extends IGLTFProperty {
  76. sampler: number;
  77. target: IGLTFAnimationChannelTarget;
  78. }
  79. export interface IGLTFAnimationChannelTarget extends IGLTFProperty {
  80. node: number;
  81. path: string;
  82. }
  83. export interface IGLTFAnimationSampler extends IGLTFProperty {
  84. input: number;
  85. interpolation?: string;
  86. output: number;
  87. }
  88. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  89. channels: IGLTFAnimationChannel[];
  90. samplers: IGLTFAnimationSampler[];
  91. }
  92. export interface IGLTFAssetProfile extends IGLTFProperty {
  93. api?: string;
  94. version?: string;
  95. }
  96. export interface IGLTFAsset extends IGLTFChildRootProperty {
  97. copyright?: string;
  98. generator?: string;
  99. profile?: IGLTFAssetProfile;
  100. version: string;
  101. }
  102. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  103. uri?: string;
  104. byteLength: number;
  105. // Loaded buffer (optimize)
  106. loadedBufferView: ArrayBufferView
  107. }
  108. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  109. buffer: number;
  110. byteOffset?: number;
  111. byteLength: number;
  112. byteStride?: number;
  113. }
  114. export interface IGLTFCameraOrthographic extends IGLTFProperty {
  115. xmag: number;
  116. ymag: number;
  117. zfar: number;
  118. znear: number;
  119. }
  120. export interface IGLTFCameraPerspective extends IGLTFProperty {
  121. aspectRatio: number;
  122. yfov: number;
  123. zfar: number;
  124. znear: number;
  125. }
  126. export interface IGLTFCamera extends IGLTFChildRootProperty {
  127. orthographic?: IGLTFCameraOrthographic;
  128. perspective?: IGLTFCameraPerspective;
  129. type: string;
  130. }
  131. export interface IGLTFImage extends IGLTFChildRootProperty {
  132. uri?: string;
  133. mimeType?: string;
  134. bufferView?: number;
  135. }
  136. export interface IGLTFMaterialNormalTextureInfo extends IGLTFTextureInfo {
  137. scale: number;
  138. }
  139. export interface IGLTFMaterialOcclusionTextureInfo extends IGLTFTextureInfo {
  140. strength: number;
  141. }
  142. export interface IGLTFMaterialPbrMetallicRoughness {
  143. baseColorFactor: number[];
  144. baseColorTexture: IGLTFTextureInfo;
  145. metallicFactor: number;
  146. roughnessFactor: number;
  147. metallicRoughnessTexture: IGLTFTextureInfo;
  148. }
  149. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  150. pbrMetallicRoughness?: IGLTFMaterialPbrMetallicRoughness;
  151. normalTexture?: IGLTFMaterialNormalTextureInfo;
  152. occlusionTexture?: IGLTFMaterialOcclusionTextureInfo;
  153. emissiveTexture?: IGLTFTextureInfo;
  154. emissiveFactor?: number[];
  155. alphaMode?: string;
  156. alphaCutoff: number;
  157. doubleSided?: boolean;
  158. // Babylon.js values (optimize)
  159. babylonMaterial?: PBRMaterial;
  160. }
  161. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  162. attributes: { [name: string]: number };
  163. indices?: number;
  164. material?: number;
  165. mode?: EMeshPrimitiveMode;
  166. targets?: [ { [name: string]: number } ];
  167. }
  168. export interface IGLTFMesh extends IGLTFChildRootProperty {
  169. primitives: IGLTFMeshPrimitive[];
  170. weights?: number[];
  171. }
  172. export interface IGLTFNode extends IGLTFChildRootProperty {
  173. camera?: number;
  174. children?: number[];
  175. skin?: number;
  176. matrix?: number[];
  177. mesh?: number;
  178. rotation?: number[];
  179. scale?: number[];
  180. translation?: number[];
  181. weights?: number[];
  182. // Babylon.js values (optimize)
  183. babylonNode?: Node;
  184. }
  185. export interface IGLTFSampler extends IGLTFChildRootProperty {
  186. magFilter?: ETextureMagFilter;
  187. minFilter?: ETextureMinFilter;
  188. wrapS?: ETextureWrapMode;
  189. wrapT?: ETextureWrapMode;
  190. }
  191. export interface IGLTFScene extends IGLTFChildRootProperty {
  192. nodes: number[];
  193. }
  194. export interface IGLTFSkin extends IGLTFChildRootProperty {
  195. inverseBindMatrices?: number;
  196. skeleton?: number;
  197. joints: number[];
  198. // Babylon.js values (optimize)
  199. babylonSkeleton?: Skeleton;
  200. }
  201. export interface IGLTFTexture extends IGLTFChildRootProperty {
  202. sampler?: number;
  203. source: number;
  204. // Babylon.js values (optimize, one per coordinate index)
  205. babylonTextures: Texture[];
  206. blobURL: string;
  207. }
  208. export interface IGLTFTextureInfo {
  209. index: number;
  210. texCoord?: number;
  211. }
  212. export interface IGLTF extends IGLTFProperty {
  213. accessors?: IGLTFAccessor[];
  214. animations?: IGLTFAnimation[];
  215. asset: IGLTFAsset;
  216. buffers?: IGLTFBuffer[];
  217. bufferViews?: IGLTFBufferView[];
  218. cameras?: IGLTFCamera[];
  219. extensionsUsed?: string[];
  220. extensionsRequired?: string[];
  221. glExtensionsUsed?: string[];
  222. images?: IGLTFImage[];
  223. materials?: IGLTFMaterial[];
  224. meshes?: IGLTFMesh[];
  225. nodes?: IGLTFNode[];
  226. samplers?: IGLTFSampler[];
  227. scene?: number;
  228. scenes?: IGLTFScene[];
  229. skins?: IGLTFSkin[];
  230. textures?: IGLTFTexture[];
  231. }
  232. export interface IGLTFRuntime {
  233. gltf: IGLTF;
  234. babylonScene: Scene;
  235. rootUrl: string;
  236. importOnlyMeshes: boolean;
  237. importMeshesNames?: string[];
  238. defaultMaterial?: PBRMaterial;
  239. }
  240. /**
  241. * Bones
  242. */
  243. export interface INodeToRoot {
  244. bone: Bone;
  245. node: IGLTFNode;
  246. index: number;
  247. }
  248. export interface IJointNode {
  249. node: IGLTFNode;
  250. index: number;
  251. }
  252. }