glTFLoaderInterfaces.d.ts 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. import type { AnimationGroup } from "@babylonjs/core/Animations/animationGroup.js";
  2. import type { Skeleton } from "@babylonjs/core/Bones/skeleton.js";
  3. import type { Material } from "@babylonjs/core/Materials/material.js";
  4. import type { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
  5. import type { Buffer, VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
  6. import type { AbstractMesh } from "@babylonjs/core/Meshes/abstractMesh.js";
  7. import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
  8. import type { Camera } from "@babylonjs/core/Cameras/camera.js";
  9. import type { Light } from "@babylonjs/core/Lights/light.js";
  10. import type * as GLTF2 from "babylonjs-gltf2interface";
  11. /**
  12. * Loader interface with an index field.
  13. */
  14. export interface IArrayItem {
  15. /**
  16. * The index of this item in the array.
  17. */
  18. index: number;
  19. }
  20. /**
  21. * Loader interface with additional members.
  22. */
  23. export interface IAccessor extends GLTF2.IAccessor, IArrayItem {
  24. /** @internal */
  25. _data?: Promise<ArrayBufferView>;
  26. /** @internal */
  27. _babylonVertexBuffer?: {
  28. [kind: string]: Promise<VertexBuffer>;
  29. };
  30. }
  31. /**
  32. * Loader interface with additional members.
  33. */
  34. export interface IAnimationChannel extends GLTF2.IAnimationChannel, IArrayItem {
  35. }
  36. /** @internal */
  37. export interface _IAnimationSamplerData {
  38. /** @internal */
  39. input: Float32Array;
  40. /** @internal */
  41. interpolation: GLTF2.AnimationSamplerInterpolation;
  42. /** @internal */
  43. output: Float32Array;
  44. }
  45. /**
  46. * Loader interface with additional members.
  47. */
  48. export interface IAnimationSampler extends GLTF2.IAnimationSampler, IArrayItem {
  49. /** @internal */
  50. _data?: Promise<_IAnimationSamplerData>;
  51. }
  52. /**
  53. * Loader interface with additional members.
  54. */
  55. export interface IAnimation extends GLTF2.IAnimation, IArrayItem {
  56. /** @internal */
  57. channels: IAnimationChannel[];
  58. /** @internal */
  59. samplers: IAnimationSampler[];
  60. /** @internal */
  61. _babylonAnimationGroup?: AnimationGroup;
  62. }
  63. /**
  64. * Loader interface with additional members.
  65. */
  66. export interface IBuffer extends GLTF2.IBuffer, IArrayItem {
  67. /** @internal */
  68. _data?: Promise<ArrayBufferView>;
  69. }
  70. /**
  71. * Loader interface with additional members.
  72. */
  73. export interface IBufferView extends GLTF2.IBufferView, IArrayItem {
  74. /** @internal */
  75. _data?: Promise<ArrayBufferView>;
  76. /** @internal */
  77. _babylonBuffer?: Promise<Buffer>;
  78. }
  79. /**
  80. * Loader interface with additional members.
  81. */
  82. export interface ICamera extends GLTF2.ICamera, IArrayItem {
  83. /** @internal */
  84. _babylonCamera?: Camera;
  85. }
  86. /**
  87. * Loader interface with additional members.
  88. */
  89. export interface IImage extends GLTF2.IImage, IArrayItem {
  90. /** @internal */
  91. _data?: Promise<ArrayBufferView>;
  92. }
  93. /**
  94. * Loader interface with additional members.
  95. */
  96. export interface IMaterialNormalTextureInfo extends GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  97. }
  98. /**
  99. * Loader interface with additional members.
  100. */
  101. export interface IMaterialOcclusionTextureInfo extends GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  102. }
  103. /**
  104. * Loader interface with additional members.
  105. */
  106. export interface IMaterialPbrMetallicRoughness extends GLTF2.IMaterialPbrMetallicRoughness {
  107. /** @internal */
  108. baseColorTexture?: ITextureInfo;
  109. /** @internal */
  110. metallicRoughnessTexture?: ITextureInfo;
  111. }
  112. /**
  113. * Loader interface with additional members.
  114. */
  115. export interface IMaterial extends GLTF2.IMaterial, IArrayItem {
  116. /** @internal */
  117. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  118. /** @internal */
  119. normalTexture?: IMaterialNormalTextureInfo;
  120. /** @internal */
  121. occlusionTexture?: IMaterialOcclusionTextureInfo;
  122. /** @internal */
  123. emissiveTexture?: ITextureInfo;
  124. /** @internal */
  125. _data?: {
  126. [babylonDrawMode: number]: {
  127. babylonMaterial: Material;
  128. babylonMeshes: AbstractMesh[];
  129. promise: Promise<void>;
  130. };
  131. };
  132. }
  133. /**
  134. * Loader interface with additional members.
  135. */
  136. export interface IMesh extends GLTF2.IMesh, IArrayItem {
  137. /** @internal */
  138. primitives: IMeshPrimitive[];
  139. }
  140. /**
  141. * Loader interface with additional members.
  142. */
  143. export interface IMeshPrimitive extends GLTF2.IMeshPrimitive, IArrayItem {
  144. /** @internal */
  145. _instanceData?: {
  146. babylonSourceMesh: Mesh;
  147. promise: Promise<any>;
  148. };
  149. }
  150. /**
  151. * Loader interface with additional members.
  152. */
  153. export interface INode extends GLTF2.INode, IArrayItem {
  154. /** @internal */
  155. parent?: INode;
  156. /** @internal */
  157. _babylonTransformNode?: TransformNode;
  158. /** @internal */
  159. _babylonTransformNodeForSkin?: TransformNode;
  160. /** @internal */
  161. _primitiveBabylonMeshes?: AbstractMesh[];
  162. /** @internal */
  163. _numMorphTargets?: number;
  164. }
  165. /** @internal */
  166. export interface _ISamplerData {
  167. /** @internal */
  168. noMipMaps: boolean;
  169. /** @internal */
  170. samplingMode: number;
  171. /** @internal */
  172. wrapU: number;
  173. /** @internal */
  174. wrapV: number;
  175. }
  176. /**
  177. * Loader interface with additional members.
  178. */
  179. export interface ISampler extends GLTF2.ISampler, IArrayItem {
  180. /** @internal */
  181. _data?: _ISamplerData;
  182. }
  183. /**
  184. * Loader interface with additional members.
  185. */
  186. export interface IScene extends GLTF2.IScene, IArrayItem {
  187. }
  188. /**
  189. * Loader interface with additional members.
  190. */
  191. export interface ISkin extends GLTF2.ISkin, IArrayItem {
  192. /** @internal */
  193. _data?: {
  194. babylonSkeleton: Skeleton;
  195. promise: Promise<void>;
  196. };
  197. }
  198. /**
  199. * Loader interface with additional members.
  200. */
  201. export interface ITexture extends GLTF2.ITexture, IArrayItem {
  202. /** @internal */
  203. _textureInfo: ITextureInfo;
  204. }
  205. /**
  206. * Loader interface with additional members.
  207. */
  208. export interface ITextureInfo extends GLTF2.ITextureInfo {
  209. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  210. nonColorData?: boolean;
  211. }
  212. /**
  213. * Loader interface with additional members.
  214. */
  215. export interface IGLTF extends GLTF2.IGLTF {
  216. /** @internal */
  217. accessors?: IAccessor[];
  218. /** @internal */
  219. animations?: IAnimation[];
  220. /** @internal */
  221. buffers?: IBuffer[];
  222. /** @internal */
  223. bufferViews?: IBufferView[];
  224. /** @internal */
  225. cameras?: ICamera[];
  226. /** @internal */
  227. images?: IImage[];
  228. /** @internal */
  229. materials?: IMaterial[];
  230. /** @internal */
  231. meshes?: IMesh[];
  232. /** @internal */
  233. nodes?: INode[];
  234. /** @internal */
  235. samplers?: ISampler[];
  236. /** @internal */
  237. scenes?: IScene[];
  238. /** @internal */
  239. skins?: ISkin[];
  240. /** @internal */
  241. textures?: ITexture[];
  242. }
  243. /**
  244. * Loader interface with additional members.
  245. */
  246. export interface IKHRLightsPunctual_Light extends GLTF2.IKHRLightsPunctual_Light, IArrayItem {
  247. /** @hidden */
  248. _babylonLight?: Light;
  249. }