interfaces.d.ts 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. import type EventEmitter from 'eventemitter3';
  2. import type { mat4, vec2, vec3 } from 'gl-matrix';
  3. import type { TypeEasingFunction } from '..';
  4. import type { ICanvas } from '../dom';
  5. import type { Frustum } from '../shapes';
  6. import type { Landmark } from './Landmark';
  7. /**
  8. * Different type of cameras, eg. simple camera used in 2D scene or
  9. * advanced camera which can do actions & switch between landmarks.
  10. */
  11. export declare enum CameraType {
  12. /**
  13. * Performs all the rotational operations with the focal point instead of the camera position.
  14. * This type of camera is useful in applications(like CAD) where 3D objects are being designed or explored.
  15. * Camera cannot orbits over the north & south poles.
  16. * @see http://voxelent.com/tutorial-cameras/
  17. *
  18. * In Three.js it's used in OrbitControls.
  19. * @see https://threejs.org/docs/#examples/zh/controls/OrbitControls
  20. */
  21. ORBITING = 0,
  22. /**
  23. * It's similar to the ORBITING camera, but it allows the camera to orbit over the north or south poles.
  24. *
  25. * In Three.js it's used in OrbitControls.
  26. * @see https://threejs.org/docs/#examples/en/controls/TrackballControls
  27. */
  28. EXPLORING = 1,
  29. /**
  30. * Performs all the rotational operations with the camera position.
  31. * It's useful in first person shooting games.
  32. * Camera cannot orbits over the north & south poles.
  33. *
  34. * In Three.js it's used in FirstPersonControls.
  35. * @see https://threejs.org/docs/#examples/en/controls/FirstPersonControls
  36. */
  37. TRACKING = 2
  38. }
  39. /**
  40. * CameraType must be TRACKING
  41. */
  42. export declare enum CameraTrackingMode {
  43. DEFAULT = 0,
  44. ROTATIONAL = 1,
  45. TRANSLATIONAL = 2,
  46. CINEMATIC = 3
  47. }
  48. export declare enum CameraProjectionMode {
  49. ORTHOGRAPHIC = 0,
  50. PERSPECTIVE = 1
  51. }
  52. export declare const CameraEvent: {
  53. UPDATED: string;
  54. };
  55. export interface ICamera {
  56. canvas: ICanvas;
  57. eventEmitter: EventEmitter;
  58. isOrtho: () => boolean;
  59. getProjectionMode: () => CameraProjectionMode;
  60. getPerspective: () => mat4;
  61. getPerspectiveInverse: () => mat4;
  62. getFrustum: () => Frustum;
  63. getPosition: () => vec3;
  64. getFocalPoint: () => vec3;
  65. getDollyingStep: () => number;
  66. getNear: () => number;
  67. getFar: () => number;
  68. getZoom: () => number;
  69. getOrthoMatrix: () => mat4;
  70. getView: () => {
  71. enabled: boolean;
  72. fullWidth: number;
  73. fullHeight: number;
  74. offsetX: number;
  75. offsetY: number;
  76. width: number;
  77. height: number;
  78. };
  79. setEnableUpdate: (enabled: boolean) => void;
  80. setType: (type: CameraType, trackingMode?: CameraTrackingMode) => this;
  81. setProjectionMode: (projectionMode: CameraProjectionMode) => this;
  82. setTrackingMode: (trackingMode: CameraTrackingMode) => this;
  83. /**
  84. * If flag is true, it reverses the azimuth and elevation angles.
  85. * Subsequent calls to rotate, setAzimuth, setElevation,
  86. * changeAzimuth or changeElevation will cause the inverted effect.
  87. * setRoll or changeRoll is not affected by this method.
  88. *
  89. * This inversion is useful when one wants to simulate that the world
  90. * is moving, instead of the camera.
  91. *
  92. * By default the camera angles are not reversed.
  93. * @param {Boolean} flag the boolean flag to reverse the angles.
  94. */
  95. setWorldRotation: (flag: boolean) => this;
  96. /**
  97. * 计算 MV 矩阵,为相机矩阵的逆矩阵
  98. */
  99. getViewTransform: () => mat4;
  100. getWorldTransform: () => mat4;
  101. jitterProjectionMatrix: (x: number, y: number) => void;
  102. clearJitterProjectionMatrix: () => void;
  103. /**
  104. * 设置相机矩阵
  105. */
  106. setMatrix: (matrix: mat4) => this;
  107. setFov: (fov: number) => this;
  108. setAspect: (aspect: number) => this;
  109. setNear: (near: number) => this;
  110. setFar: (far: number) => this;
  111. /**
  112. * Sets an offset in a larger frustum, used in PixelPicking
  113. */
  114. setViewOffset: (fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number) => this;
  115. clearViewOffset: () => this;
  116. setZoom: (zoom: number) => this;
  117. setZoomByViewportPoint: (zoom: number, viewportPoint: vec2) => this;
  118. setPerspective: (near: number, far: number, fov: number, aspect: number) => this;
  119. setOrthographic: (l: number, r: number, t: number, b: number, near: number, far: number) => this;
  120. /**
  121. * Move the camera in world coordinates.
  122. * It will keep looking at the current focal point.
  123. *
  124. * support scalars or vectors.
  125. * @example
  126. * setPosition(1, 2, 3);
  127. * setPosition([1, 2, 3]);
  128. */
  129. setPosition: (x: number | vec2 | vec3, y?: number, z?: number) => this;
  130. /**
  131. * Sets the focal point of this camera in world coordinates.
  132. *
  133. * support scalars or vectors.
  134. * @example
  135. * setFocalPoint(1, 2, 3);
  136. * setFocalPoint([1, 2, 3]);
  137. */
  138. setFocalPoint: (x: number | vec2 | vec3, y?: number, z?: number) => this;
  139. getDistance: () => number;
  140. getDistanceVector: () => vec3;
  141. /**
  142. * Moves the camera towards/from the focal point.
  143. */
  144. setDistance: (d: number) => this;
  145. setMaxDistance: (d: number) => this;
  146. setMinDistance: (d: number) => this;
  147. /**
  148. * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
  149. * the azimuth in degrees
  150. */
  151. setAzimuth: (az: number) => this;
  152. getAzimuth: () => number;
  153. /**
  154. * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
  155. */
  156. setElevation: (el: number) => this;
  157. getElevation: () => number;
  158. /**
  159. * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
  160. */
  161. setRoll: (angle: number) => this;
  162. getRoll: () => number;
  163. /**
  164. * Changes the azimuth and elevation with respect to the current camera axes
  165. * @param {Number} azimuth the relative azimuth
  166. * @param {Number} elevation the relative elevation
  167. * @param {Number} roll the relative roll
  168. */
  169. rotate: (azimuth: number, elevation: number, roll: number) => this;
  170. /**
  171. * 沿水平(right) & 垂直(up)平移相机
  172. */
  173. pan: (tx: number, ty: number) => this;
  174. /**
  175. * 沿 n 轴移动,当距离视点远时移动速度较快,离视点越近速度越慢
  176. */
  177. dolly: (value: number) => this;
  178. createLandmark: (name: string, params?: Partial<{
  179. position: vec3 | vec2;
  180. focalPoint: vec3 | vec2;
  181. zoom: number;
  182. roll: number;
  183. }>) => Landmark;
  184. gotoLandmark: (name: string | Landmark, options?: number | Partial<{
  185. easing: string;
  186. easingFunction: TypeEasingFunction;
  187. duration: number;
  188. onfinish: () => void;
  189. }>) => void;
  190. /**
  191. * Stop camera animation immediately.
  192. */
  193. cancelLandmarkAnimation: () => void;
  194. }
  195. //# sourceMappingURL=interfaces.d.ts.map