@antv/g 5.0.22-alpha.4 → 5.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (312) hide show
  1. package/dist/index.umd.min.js +30 -0
  2. package/es/AbstractRenderer.js +3 -1
  3. package/es/Canvas.d.ts +1 -1
  4. package/es/Canvas.js +5 -3
  5. package/es/DisplayObjectPool.js +3 -1
  6. package/es/camera/Camera.d.ts +105 -66
  7. package/es/camera/Camera.js +307 -171
  8. package/es/camera/Landmark.d.ts +18 -25
  9. package/es/camera/Landmark.js +1 -72
  10. package/es/canvas-module.js +2 -4
  11. package/es/components/Cullable.js +3 -1
  12. package/es/components/Geometry.js +3 -1
  13. package/es/components/Renderable.js +3 -1
  14. package/es/components/Sortable.js +3 -1
  15. package/es/components/Transform.js +3 -1
  16. package/es/css/LayoutRegistry.js +3 -1
  17. package/es/css/StyleValueRegistry.d.ts +8 -0
  18. package/es/css/StyleValueRegistry.js +24 -19
  19. package/es/css/cssom/CSSColorValue.js +3 -1
  20. package/es/css/cssom/CSSGradientValue.js +8 -6
  21. package/es/css/cssom/CSSKeywordValue.js +3 -1
  22. package/es/css/cssom/CSSMathInvert.js +3 -1
  23. package/es/css/cssom/CSSMathMax.js +3 -1
  24. package/es/css/cssom/CSSMathMin.js +3 -1
  25. package/es/css/cssom/CSSMathNegate.js +3 -1
  26. package/es/css/cssom/CSSMathProduct.js +3 -1
  27. package/es/css/cssom/CSSMathSum.js +3 -1
  28. package/es/css/cssom/CSSMathValue.js +3 -1
  29. package/es/css/cssom/CSSMathVariadic.js +3 -1
  30. package/es/css/cssom/CSSNumericValue.js +3 -1
  31. package/es/css/cssom/CSSNumericValueType.d.ts +1 -1
  32. package/es/css/cssom/CSSNumericValueType.js +3 -1
  33. package/es/css/cssom/CSSRGB.js +4 -2
  34. package/es/css/cssom/CSSStyleValue.d.ts +1 -1
  35. package/es/css/cssom/CSSStyleValue.js +3 -1
  36. package/es/css/cssom/CSSTransformComponent.js +3 -1
  37. package/es/css/cssom/CSSTransformValue.js +3 -1
  38. package/es/css/cssom/CSSTranslate.js +3 -1
  39. package/es/css/cssom/CSSUnitValue.js +4 -2
  40. package/es/css/parser/color.js +2 -2
  41. package/es/css/parser/dimension.d.ts +2 -1
  42. package/es/css/parser/dimension.js +2 -2
  43. package/es/css/parser/numeric.js +1 -1
  44. package/es/css/parser/path.d.ts +1 -1
  45. package/es/css/parser/points.js +1 -1
  46. package/es/css/parser/transform-origin.js +1 -1
  47. package/es/css/properties/CSSPropertyAnchor.d.ts +4 -2
  48. package/es/css/properties/CSSPropertyAnchor.js +5 -2
  49. package/es/css/properties/CSSPropertyClipPath.d.ts +2 -1
  50. package/es/css/properties/CSSPropertyClipPath.js +4 -2
  51. package/es/css/properties/CSSPropertyColor.d.ts +3 -2
  52. package/es/css/properties/CSSPropertyColor.js +4 -2
  53. package/es/css/properties/CSSPropertyFilter.d.ts +3 -2
  54. package/es/css/properties/CSSPropertyFilter.js +4 -2
  55. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +4 -2
  56. package/es/css/properties/CSSPropertyLengthOrPercentage.js +5 -2
  57. package/es/css/properties/CSSPropertyLineDash.d.ts +4 -2
  58. package/es/css/properties/CSSPropertyLineDash.js +4 -2
  59. package/es/css/properties/CSSPropertyLocalPosition.d.ts +4 -2
  60. package/es/css/properties/CSSPropertyLocalPosition.js +4 -2
  61. package/es/css/properties/CSSPropertyOffsetDistance.d.ts +4 -2
  62. package/es/css/properties/CSSPropertyOffsetDistance.js +5 -2
  63. package/es/css/properties/CSSPropertyOffsetPath.d.ts +2 -1
  64. package/es/css/properties/CSSPropertyOffsetPath.js +3 -1
  65. package/es/css/properties/CSSPropertyOpacity.d.ts +3 -2
  66. package/es/css/properties/CSSPropertyOpacity.js +4 -2
  67. package/es/css/properties/CSSPropertyPath.d.ts +3 -2
  68. package/es/css/properties/CSSPropertyPath.js +6 -2
  69. package/es/css/properties/CSSPropertyPoints.d.ts +3 -2
  70. package/es/css/properties/CSSPropertyPoints.js +4 -2
  71. package/es/css/properties/CSSPropertyShadowBlur.d.ts +1 -1
  72. package/es/css/properties/CSSPropertyShadowBlur.js +4 -2
  73. package/es/css/properties/CSSPropertyText.d.ts +3 -2
  74. package/es/css/properties/CSSPropertyText.js +5 -3
  75. package/es/css/properties/CSSPropertyTextTransform.d.ts +2 -1
  76. package/es/css/properties/CSSPropertyTextTransform.js +4 -2
  77. package/es/css/properties/CSSPropertyTransform.d.ts +3 -2
  78. package/es/css/properties/CSSPropertyTransform.js +5 -3
  79. package/es/css/properties/CSSPropertyTransformOrigin.d.ts +3 -2
  80. package/es/css/properties/CSSPropertyTransformOrigin.js +4 -2
  81. package/es/css/properties/CSSPropertyVisibility.d.ts +3 -1
  82. package/es/css/properties/CSSPropertyVisibility.js +3 -1
  83. package/es/css/properties/CSSPropertyZIndex.d.ts +4 -2
  84. package/es/css/properties/CSSPropertyZIndex.js +4 -2
  85. package/es/display-objects/Circle.js +3 -1
  86. package/es/display-objects/CustomElement.js +3 -1
  87. package/es/display-objects/DisplayObject.js +7 -4
  88. package/es/display-objects/Ellipse.js +3 -1
  89. package/es/display-objects/Group.js +3 -1
  90. package/es/display-objects/HTML.js +6 -3
  91. package/es/display-objects/Image.js +3 -1
  92. package/es/display-objects/Line.js +3 -1
  93. package/es/display-objects/Path.js +5 -3
  94. package/es/display-objects/Polygon.js +3 -1
  95. package/es/display-objects/Polyline.js +3 -1
  96. package/es/display-objects/Rect.js +3 -1
  97. package/es/display-objects/Text.js +6 -3
  98. package/es/dom/Animation.js +4 -2
  99. package/es/dom/AnimationEffectTiming.js +3 -1
  100. package/es/dom/AnimationEvent.js +3 -1
  101. package/es/dom/AnimationTimeline.js +3 -1
  102. package/es/dom/CustomElementRegistry.js +3 -1
  103. package/es/dom/CustomEvent.js +3 -1
  104. package/es/dom/Document.js +3 -1
  105. package/es/dom/Element.js +7 -5
  106. package/es/dom/EventTarget.js +6 -4
  107. package/es/dom/FederatedEvent.js +3 -1
  108. package/es/dom/FederatedMouseEvent.js +3 -1
  109. package/es/dom/FederatedPointerEvent.js +3 -1
  110. package/es/dom/FederatedTouchEvent.d.ts +13 -0
  111. package/es/dom/FederatedTouchEvent.js +19 -0
  112. package/es/dom/FederatedWheelEvent.js +3 -1
  113. package/es/dom/KeyframeEffect.js +3 -1
  114. package/es/dom/KeyframeList.js +1 -1
  115. package/es/dom/MutationEvent.js +3 -1
  116. package/es/dom/MutationObserver.js +10 -3
  117. package/es/dom/MutationRecord.js +3 -1
  118. package/es/dom/Node.js +4 -2
  119. package/es/plugins/CullingPlugin.js +3 -1
  120. package/es/plugins/DirtyCheckPlugin.js +3 -1
  121. package/es/plugins/EventPlugin.js +4 -2
  122. package/es/plugins/FrustumCullingStrategy.js +3 -1
  123. package/es/plugins/PrepareRendererPlugin.js +3 -1
  124. package/es/services/EventService.js +5 -3
  125. package/es/services/OffscreenCanvasCreator.js +3 -1
  126. package/es/services/RenderingService.js +3 -1
  127. package/es/services/SceneGraphSelector.js +3 -1
  128. package/es/services/SceneGraphService.js +4 -2
  129. package/es/services/TextService.js +5 -3
  130. package/es/services/aabb/CircleUpdater.js +3 -1
  131. package/es/services/aabb/EllipseUpdater.js +3 -1
  132. package/es/services/aabb/LineUpdater.js +3 -1
  133. package/es/services/aabb/PathUpdater.js +3 -1
  134. package/es/services/aabb/PolylineUpdater.js +3 -1
  135. package/es/services/aabb/RectUpdater.js +4 -2
  136. package/es/services/aabb/TextUpdater.d.ts +1 -2
  137. package/es/services/aabb/TextUpdater.js +3 -1
  138. package/es/shapes/AABB.js +3 -1
  139. package/es/shapes/BoundingSphere.js +3 -1
  140. package/es/shapes/Frustum.js +3 -1
  141. package/es/shapes/Plane.js +3 -1
  142. package/es/shapes/Point.js +3 -1
  143. package/es/shapes/Ray.js +3 -1
  144. package/es/shapes/Rectangle.js +3 -1
  145. package/es/types.d.ts +4 -0
  146. package/es/utils/custom-easing.js +1 -1
  147. package/es/utils/math.d.ts +1 -2
  148. package/es/utils/math.js +11 -6
  149. package/es/utils/path.d.ts +1 -1
  150. package/es/utils/path.js +3 -3
  151. package/es/utils/text.js +4 -4
  152. package/lib/AbstractRenderer.js +3 -1
  153. package/lib/Canvas.d.ts +1 -1
  154. package/lib/Canvas.js +5 -3
  155. package/lib/DisplayObjectPool.js +3 -1
  156. package/lib/camera/Camera.d.ts +105 -66
  157. package/lib/camera/Camera.js +314 -179
  158. package/lib/camera/Landmark.d.ts +18 -25
  159. package/lib/camera/Landmark.js +1 -75
  160. package/lib/canvas-module.js +1 -3
  161. package/lib/components/Cullable.js +4 -2
  162. package/lib/components/Geometry.js +3 -1
  163. package/lib/components/Renderable.js +3 -1
  164. package/lib/components/Sortable.js +3 -1
  165. package/lib/components/Transform.js +3 -1
  166. package/lib/css/LayoutRegistry.js +3 -1
  167. package/lib/css/StyleValueRegistry.d.ts +8 -0
  168. package/lib/css/StyleValueRegistry.js +27 -20
  169. package/lib/css/cssom/CSSColorValue.js +3 -1
  170. package/lib/css/cssom/CSSGradientValue.js +9 -7
  171. package/lib/css/cssom/CSSKeywordValue.js +3 -1
  172. package/lib/css/cssom/CSSMathInvert.js +3 -1
  173. package/lib/css/cssom/CSSMathMax.js +3 -1
  174. package/lib/css/cssom/CSSMathMin.js +3 -1
  175. package/lib/css/cssom/CSSMathNegate.js +3 -1
  176. package/lib/css/cssom/CSSMathOperator.js +1 -1
  177. package/lib/css/cssom/CSSMathProduct.js +3 -1
  178. package/lib/css/cssom/CSSMathSum.js +3 -1
  179. package/lib/css/cssom/CSSMathValue.js +3 -1
  180. package/lib/css/cssom/CSSMathVariadic.js +4 -2
  181. package/lib/css/cssom/CSSNumericValue.js +3 -1
  182. package/lib/css/cssom/CSSNumericValueType.d.ts +1 -1
  183. package/lib/css/cssom/CSSNumericValueType.js +5 -3
  184. package/lib/css/cssom/CSSRGB.js +4 -2
  185. package/lib/css/cssom/CSSStyleValue.d.ts +1 -1
  186. package/lib/css/cssom/CSSStyleValue.js +4 -2
  187. package/lib/css/cssom/CSSTransformComponent.js +4 -2
  188. package/lib/css/cssom/CSSTransformValue.js +3 -1
  189. package/lib/css/cssom/CSSTranslate.js +3 -1
  190. package/lib/css/cssom/CSSUnitValue.js +4 -2
  191. package/lib/css/cssom/types.js +1 -1
  192. package/lib/css/parser/color.js +7 -7
  193. package/lib/css/parser/dimension.d.ts +2 -1
  194. package/lib/css/parser/dimension.js +9 -8
  195. package/lib/css/parser/numeric.js +6 -6
  196. package/lib/css/parser/path.d.ts +1 -1
  197. package/lib/css/parser/path.js +1 -1
  198. package/lib/css/parser/points.js +2 -2
  199. package/lib/css/parser/transform-origin.js +2 -2
  200. package/lib/css/parser/transform.js +2 -2
  201. package/lib/css/properties/CSSPropertyAnchor.d.ts +4 -2
  202. package/lib/css/properties/CSSPropertyAnchor.js +8 -4
  203. package/lib/css/properties/CSSPropertyClipPath.d.ts +2 -1
  204. package/lib/css/properties/CSSPropertyClipPath.js +5 -3
  205. package/lib/css/properties/CSSPropertyColor.d.ts +3 -2
  206. package/lib/css/properties/CSSPropertyColor.js +6 -4
  207. package/lib/css/properties/CSSPropertyFilter.d.ts +3 -2
  208. package/lib/css/properties/CSSPropertyFilter.js +5 -3
  209. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +4 -2
  210. package/lib/css/properties/CSSPropertyLengthOrPercentage.js +14 -10
  211. package/lib/css/properties/CSSPropertyLineDash.d.ts +4 -2
  212. package/lib/css/properties/CSSPropertyLineDash.js +6 -4
  213. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +4 -2
  214. package/lib/css/properties/CSSPropertyLocalPosition.js +6 -4
  215. package/lib/css/properties/CSSPropertyOffsetDistance.d.ts +4 -2
  216. package/lib/css/properties/CSSPropertyOffsetDistance.js +9 -5
  217. package/lib/css/properties/CSSPropertyOffsetPath.d.ts +2 -1
  218. package/lib/css/properties/CSSPropertyOffsetPath.js +3 -1
  219. package/lib/css/properties/CSSPropertyOpacity.d.ts +3 -2
  220. package/lib/css/properties/CSSPropertyOpacity.js +6 -4
  221. package/lib/css/properties/CSSPropertyPath.d.ts +3 -2
  222. package/lib/css/properties/CSSPropertyPath.js +12 -6
  223. package/lib/css/properties/CSSPropertyPoints.d.ts +3 -2
  224. package/lib/css/properties/CSSPropertyPoints.js +5 -3
  225. package/lib/css/properties/CSSPropertyShadowBlur.d.ts +1 -1
  226. package/lib/css/properties/CSSPropertyShadowBlur.js +5 -3
  227. package/lib/css/properties/CSSPropertyText.d.ts +3 -2
  228. package/lib/css/properties/CSSPropertyText.js +6 -4
  229. package/lib/css/properties/CSSPropertyTextTransform.d.ts +2 -1
  230. package/lib/css/properties/CSSPropertyTextTransform.js +8 -6
  231. package/lib/css/properties/CSSPropertyTransform.d.ts +3 -2
  232. package/lib/css/properties/CSSPropertyTransform.js +26 -24
  233. package/lib/css/properties/CSSPropertyTransformOrigin.d.ts +3 -2
  234. package/lib/css/properties/CSSPropertyTransformOrigin.js +5 -3
  235. package/lib/css/properties/CSSPropertyVisibility.d.ts +3 -1
  236. package/lib/css/properties/CSSPropertyVisibility.js +3 -1
  237. package/lib/css/properties/CSSPropertyZIndex.d.ts +4 -2
  238. package/lib/css/properties/CSSPropertyZIndex.js +5 -3
  239. package/lib/display-objects/Circle.js +3 -1
  240. package/lib/display-objects/CustomElement.js +3 -1
  241. package/lib/display-objects/DisplayObject.js +14 -11
  242. package/lib/display-objects/Ellipse.js +3 -1
  243. package/lib/display-objects/Group.js +3 -1
  244. package/lib/display-objects/HTML.js +6 -4
  245. package/lib/display-objects/Image.js +3 -1
  246. package/lib/display-objects/Line.js +3 -1
  247. package/lib/display-objects/Path.js +8 -6
  248. package/lib/display-objects/Polygon.js +3 -1
  249. package/lib/display-objects/Polyline.js +3 -1
  250. package/lib/display-objects/Rect.js +3 -1
  251. package/lib/display-objects/Text.js +6 -4
  252. package/lib/dom/Animation.js +4 -2
  253. package/lib/dom/AnimationEffectTiming.js +3 -1
  254. package/lib/dom/AnimationEvent.js +3 -1
  255. package/lib/dom/AnimationTimeline.js +4 -2
  256. package/lib/dom/CustomElementRegistry.js +3 -1
  257. package/lib/dom/CustomEvent.js +3 -1
  258. package/lib/dom/Document.js +3 -1
  259. package/lib/dom/Element.js +8 -6
  260. package/lib/dom/EventTarget.js +13 -11
  261. package/lib/dom/FederatedEvent.js +3 -1
  262. package/lib/dom/FederatedMouseEvent.js +3 -1
  263. package/lib/dom/FederatedPointerEvent.js +3 -1
  264. package/lib/dom/FederatedTouchEvent.d.ts +13 -0
  265. package/lib/dom/FederatedTouchEvent.js +27 -0
  266. package/lib/dom/FederatedWheelEvent.js +3 -1
  267. package/lib/dom/KeyframeEffect.js +4 -2
  268. package/lib/dom/KeyframeList.js +1 -1
  269. package/lib/dom/MutationEvent.js +3 -1
  270. package/lib/dom/MutationObserver.js +11 -4
  271. package/lib/dom/MutationRecord.js +3 -1
  272. package/lib/dom/Node.js +4 -2
  273. package/lib/index.js +1 -1
  274. package/lib/plugins/CullingPlugin.js +4 -2
  275. package/lib/plugins/DirtyCheckPlugin.js +3 -1
  276. package/lib/plugins/EventPlugin.js +26 -24
  277. package/lib/plugins/FrustumCullingStrategy.js +3 -1
  278. package/lib/plugins/PrepareRendererPlugin.js +3 -1
  279. package/lib/services/EventService.js +5 -3
  280. package/lib/services/OffscreenCanvasCreator.js +3 -1
  281. package/lib/services/RenderingService.js +3 -1
  282. package/lib/services/SceneGraphSelector.js +4 -2
  283. package/lib/services/SceneGraphService.js +7 -5
  284. package/lib/services/TextService.js +5 -3
  285. package/lib/services/aabb/CircleUpdater.js +3 -1
  286. package/lib/services/aabb/EllipseUpdater.js +3 -1
  287. package/lib/services/aabb/LineUpdater.js +3 -1
  288. package/lib/services/aabb/PathUpdater.js +3 -1
  289. package/lib/services/aabb/PolylineUpdater.js +3 -1
  290. package/lib/services/aabb/RectUpdater.js +5 -3
  291. package/lib/services/aabb/TextUpdater.d.ts +1 -2
  292. package/lib/services/aabb/TextUpdater.js +3 -1
  293. package/lib/services/aabb/index.js +10 -10
  294. package/lib/services/aabb/interfaces.js +1 -1
  295. package/lib/shapes/AABB.js +3 -1
  296. package/lib/shapes/BoundingSphere.js +3 -1
  297. package/lib/shapes/Frustum.js +4 -2
  298. package/lib/shapes/Plane.js +3 -1
  299. package/lib/shapes/Point.js +3 -1
  300. package/lib/shapes/Ray.js +3 -1
  301. package/lib/shapes/Rectangle.js +3 -1
  302. package/lib/types.d.ts +4 -0
  303. package/lib/types.js +1 -1
  304. package/lib/utils/animation.js +3 -2
  305. package/lib/utils/bezier-easing.js +1 -1
  306. package/lib/utils/custom-easing.js +2 -2
  307. package/lib/utils/math.d.ts +1 -2
  308. package/lib/utils/math.js +20 -17
  309. package/lib/utils/path.d.ts +1 -1
  310. package/lib/utils/path.js +6 -6
  311. package/lib/utils/text.js +5 -5
  312. package/package.json +7 -5
@@ -3,55 +3,83 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.Camera = exports.CameraEvent = exports.CAMERA_PROJECTION_MODE = exports.CAMERA_TRACKING_MODE = exports.CAMERA_TYPE = exports.DefaultCamera = void 0;
6
+ exports.DefaultCamera = exports.CameraType = exports.CameraTrackingMode = exports.CameraProjectionMode = exports.CameraEvent = exports.Camera = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
10
+ var _lodashEs = require("lodash-es");
11
+
12
+ var _manaSyringe = require("mana-syringe");
13
+
10
14
  var _eventemitter = require("eventemitter3");
11
15
 
12
16
  var _glMatrix = require("gl-matrix");
13
17
 
14
- var _Landmark = require("./Landmark");
15
-
16
18
  var _shapes = require("../shapes");
17
19
 
18
20
  var _math = require("../utils/math");
19
21
 
20
22
  var _animation = require("../utils/animation");
21
23
 
22
- var _util = require("@antv/util");
23
-
24
- var _manaSyringe = require("mana-syringe");
25
-
24
+ // import { DisplayObject } from '../display-objects';
26
25
  var DefaultCamera = _manaSyringe.Syringe.defineToken('DefaultCamera');
27
26
 
28
27
  exports.DefaultCamera = DefaultCamera;
29
- var CAMERA_TYPE;
30
- exports.CAMERA_TYPE = CAMERA_TYPE;
28
+ var CameraType;
29
+ exports.CameraType = CameraType;
31
30
 
32
- (function (CAMERA_TYPE) {
33
- CAMERA_TYPE["ORBITING"] = "ORBITING";
34
- CAMERA_TYPE["EXPLORING"] = "EXPLORING";
35
- CAMERA_TYPE["TRACKING"] = "TRACKING";
36
- })(CAMERA_TYPE || (exports.CAMERA_TYPE = CAMERA_TYPE = {}));
31
+ (function (CameraType) {
32
+ /**
33
+ * Performs all the rotational operations with the focal point instead of the camera position.
34
+ * This type of camera is useful in applications(like CAD) where 3D objects are being designed or explored.
35
+ * Camera cannot orbits over the north & south poles.
36
+ * @see http://voxelent.com/tutorial-cameras/
37
+ *
38
+ * In Three.js it's used in OrbitControls.
39
+ * @see https://threejs.org/docs/#examples/zh/controls/OrbitControls
40
+ */
41
+ CameraType[CameraType["ORBITING"] = 0] = "ORBITING";
42
+ /**
43
+ * It's similar to the ORBITING camera, but it allows the camera to orbit over the north or south poles.
44
+ *
45
+ * In Three.js it's used in OrbitControls.
46
+ * @see https://threejs.org/docs/#examples/en/controls/TrackballControls
47
+ */
37
48
 
38
- var CAMERA_TRACKING_MODE;
39
- exports.CAMERA_TRACKING_MODE = CAMERA_TRACKING_MODE;
49
+ CameraType[CameraType["EXPLORING"] = 1] = "EXPLORING";
50
+ /**
51
+ * Performs all the rotational operations with the camera position.
52
+ * It's useful in first person shooting games.
53
+ * Camera cannot orbits over the north & south poles.
54
+ *
55
+ * In Three.js it's used in FirstPersonControls.
56
+ * @see https://threejs.org/docs/#examples/en/controls/FirstPersonControls
57
+ */
40
58
 
41
- (function (CAMERA_TRACKING_MODE) {
42
- CAMERA_TRACKING_MODE["DEFAULT"] = "DEFAULT";
43
- CAMERA_TRACKING_MODE["ROTATIONAL"] = "ROTATIONAL";
44
- CAMERA_TRACKING_MODE["TRANSLATIONAL"] = "TRANSLATIONAL";
45
- CAMERA_TRACKING_MODE["CINEMATIC"] = "CINEMATIC";
46
- })(CAMERA_TRACKING_MODE || (exports.CAMERA_TRACKING_MODE = CAMERA_TRACKING_MODE = {}));
59
+ CameraType[CameraType["TRACKING"] = 2] = "TRACKING";
60
+ })(CameraType || (exports.CameraType = CameraType = {}));
61
+ /**
62
+ * CameraType must be TRACKING
63
+ */
64
+
65
+
66
+ var CameraTrackingMode;
67
+ exports.CameraTrackingMode = CameraTrackingMode;
68
+
69
+ (function (CameraTrackingMode) {
70
+ CameraTrackingMode[CameraTrackingMode["DEFAULT"] = 0] = "DEFAULT";
71
+ CameraTrackingMode[CameraTrackingMode["ROTATIONAL"] = 1] = "ROTATIONAL";
72
+ CameraTrackingMode[CameraTrackingMode["TRANSLATIONAL"] = 2] = "TRANSLATIONAL";
73
+ CameraTrackingMode[CameraTrackingMode["CINEMATIC"] = 3] = "CINEMATIC";
74
+ })(CameraTrackingMode || (exports.CameraTrackingMode = CameraTrackingMode = {}));
47
75
 
48
- var CAMERA_PROJECTION_MODE;
49
- exports.CAMERA_PROJECTION_MODE = CAMERA_PROJECTION_MODE;
76
+ var CameraProjectionMode;
77
+ exports.CameraProjectionMode = CameraProjectionMode;
50
78
 
51
- (function (CAMERA_PROJECTION_MODE) {
52
- CAMERA_PROJECTION_MODE["ORTHOGRAPHIC"] = "ORTHOGRAPHIC";
53
- CAMERA_PROJECTION_MODE["PERSPECTIVE"] = "PERSPECTIVE";
54
- })(CAMERA_PROJECTION_MODE || (exports.CAMERA_PROJECTION_MODE = CAMERA_PROJECTION_MODE = {}));
79
+ (function (CameraProjectionMode) {
80
+ CameraProjectionMode[CameraProjectionMode["ORTHOGRAPHIC"] = 0] = "ORTHOGRAPHIC";
81
+ CameraProjectionMode[CameraProjectionMode["PERSPECTIVE"] = 1] = "PERSPECTIVE";
82
+ })(CameraProjectionMode || (exports.CameraProjectionMode = CameraProjectionMode = {}));
55
83
 
56
84
  var CameraEvent = {
57
85
  UPDATED: 'updated'
@@ -59,8 +87,11 @@ var CameraEvent = {
59
87
  exports.CameraEvent = CameraEvent;
60
88
  var DEG_2_RAD = Math.PI / 180;
61
89
  var RAD_2_DEG = 180 / Math.PI;
90
+ var MIN_DISTANCE = 0.0002;
62
91
  /**
63
92
  * 参考「WebGL Insights - 23.Designing Cameras for WebGL Applications」,基于 Responsible Camera 思路设计
93
+ * @see https://github.com/d13g0/nucleo.js/blob/master/source/camera/Camera.js
94
+ *
64
95
  * 保存相机参数,定义相机动作:
65
96
  * 1. dolly 沿 n 轴移动
66
97
  * 2. pan 沿 u v 轴移动
@@ -68,11 +99,21 @@ var RAD_2_DEG = 180 / Math.PI;
68
99
  * 4. 移动到 Landmark,具有平滑的动画效果,其间禁止其他用户交互
69
100
  */
70
101
 
71
- var Camera = function (_super) {
102
+ var Camera =
103
+ /** @class */
104
+ function (_super) {
72
105
  (0, _tslib.__extends)(Camera, _super);
73
106
 
74
- function Camera() {
75
- var _this = _super !== null && _super.apply(this, arguments) || this;
107
+ function Camera(type, trackingMode) {
108
+ if (type === void 0) {
109
+ type = CameraType.EXPLORING;
110
+ }
111
+
112
+ if (trackingMode === void 0) {
113
+ trackingMode = CameraTrackingMode.DEFAULT;
114
+ }
115
+
116
+ var _this = _super.call(this) || this;
76
117
  /**
77
118
  * 相机矩阵
78
119
  */
@@ -106,11 +147,11 @@ var Camera = function (_super) {
106
147
 
107
148
  _this.focalPoint = _glMatrix.vec3.fromValues(0, 0, 0);
108
149
  /**
109
- * 相机位置到视点向量
150
+ * 视点到相机位置的向量
110
151
  * focalPoint - position
111
152
  */
112
153
 
113
- _this.distanceVector = _glMatrix.vec3.fromValues(0, 0, 0);
154
+ _this.distanceVector = _glMatrix.vec3.fromValues(0, 0, -1);
114
155
  /**
115
156
  * 相机位置到视点距离
116
157
  * length(focalPoint - position)
@@ -144,9 +185,7 @@ var Camera = function (_super) {
144
185
  * invert the horizontal coordinate system HCS
145
186
  */
146
187
 
147
- _this.rotateWorld = false; // @inject(IDENTIFIER.InteractorService)
148
- // interactor: IInteractorService;
149
-
188
+ _this.rotateWorld = false;
150
189
  /**
151
190
  * 投影矩阵参数
152
191
  */
@@ -162,11 +201,12 @@ var Camera = function (_super) {
162
201
  _this.aspect = 1;
163
202
  _this.projectionMatrix = _glMatrix.mat4.create();
164
203
  _this.projectionMatrixInverse = _glMatrix.mat4.create();
165
- _this.jitteredProjectionMatrix = undefined; // private following = undefined;
204
+ _this.jitteredProjectionMatrix = undefined;
205
+ _this.enableUpdate = true; // private following = undefined;
166
206
 
167
- _this.type = CAMERA_TYPE.EXPLORING;
168
- _this.trackingMode = CAMERA_TRACKING_MODE.DEFAULT;
169
- _this.projectionMode = CAMERA_PROJECTION_MODE.PERSPECTIVE;
207
+ _this.type = CameraType.EXPLORING;
208
+ _this.trackingMode = CameraTrackingMode.DEFAULT;
209
+ _this.projectionMode = CameraProjectionMode.PERSPECTIVE;
170
210
  /**
171
211
  * for culling use
172
212
  */
@@ -182,18 +222,14 @@ var Camera = function (_super) {
182
222
  */
183
223
 
184
224
  _this.orthoMatrix = _glMatrix.mat4.create();
225
+
226
+ _this.setType(type, trackingMode);
227
+
185
228
  return _this;
186
229
  }
187
230
 
188
231
  Camera.prototype.isOrtho = function () {
189
- return this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC;
190
- };
191
-
192
- Camera.prototype.clone = function () {
193
- var camera = new Camera();
194
- camera.setType(this.type, undefined); // camera.interactor = this.interactor;
195
-
196
- return camera;
232
+ return this.projectionMode === CameraProjectionMode.ORTHOGRAPHIC;
197
233
  };
198
234
 
199
235
  Camera.prototype.getProjectionMode = function () {
@@ -221,6 +257,10 @@ var Camera = function (_super) {
221
257
  return this.focalPoint;
222
258
  };
223
259
 
260
+ Camera.prototype.getDollyingStep = function () {
261
+ return this.dollyingStep;
262
+ };
263
+
224
264
  Camera.prototype.getNear = function () {
225
265
  return this.near;
226
266
  };
@@ -237,10 +277,18 @@ var Camera = function (_super) {
237
277
  return this.orthoMatrix;
238
278
  };
239
279
 
280
+ Camera.prototype.getView = function () {
281
+ return this.view;
282
+ };
283
+
284
+ Camera.prototype.setEnableUpdate = function (enabled) {
285
+ this.enableUpdate = enabled;
286
+ };
287
+
240
288
  Camera.prototype.setType = function (type, trackingMode) {
241
289
  this.type = type;
242
290
 
243
- if (this.type === CAMERA_TYPE.EXPLORING) {
291
+ if (this.type === CameraType.EXPLORING) {
244
292
  this.setWorldRotation(true);
245
293
  } else {
246
294
  this.setWorldRotation(false);
@@ -248,7 +296,7 @@ var Camera = function (_super) {
248
296
 
249
297
  this._getAngles();
250
298
 
251
- if (this.type === CAMERA_TYPE.TRACKING && trackingMode !== undefined) {
299
+ if (this.type === CameraType.TRACKING && trackingMode !== undefined) {
252
300
  this.setTrackingMode(trackingMode);
253
301
  }
254
302
 
@@ -261,7 +309,7 @@ var Camera = function (_super) {
261
309
  };
262
310
 
263
311
  Camera.prototype.setTrackingMode = function (trackingMode) {
264
- if (this.type !== CAMERA_TYPE.TRACKING) {
312
+ if (this.type !== CameraType.TRACKING) {
265
313
  throw new Error('Impossible to set a tracking mode if the camera is not of tracking type');
266
314
  }
267
315
 
@@ -286,6 +334,8 @@ var Camera = function (_super) {
286
334
  this.rotateWorld = flag;
287
335
 
288
336
  this._getAngles();
337
+
338
+ return this;
289
339
  };
290
340
  /**
291
341
  * 计算 MV 矩阵,为相机矩阵的逆矩阵
@@ -333,7 +383,7 @@ var Camera = function (_super) {
333
383
  };
334
384
 
335
385
  Camera.prototype.setNear = function (near) {
336
- if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
386
+ if (this.projectionMode === CameraProjectionMode.PERSPECTIVE) {
337
387
  this.setPerspective(near, this.far, this.fov, this.aspect);
338
388
  } else {
339
389
  this.setOrthographic(this.left, this.rright, this.top, this.bottom, near, this.far);
@@ -343,7 +393,7 @@ var Camera = function (_super) {
343
393
  };
344
394
 
345
395
  Camera.prototype.setFar = function (far) {
346
- if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
396
+ if (this.projectionMode === CameraProjectionMode.PERSPECTIVE) {
347
397
  this.setPerspective(this.near, far, this.fov, this.aspect);
348
398
  } else {
349
399
  this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, far);
@@ -379,7 +429,7 @@ var Camera = function (_super) {
379
429
  this.view.width = width;
380
430
  this.view.height = height;
381
431
 
382
- if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
432
+ if (this.projectionMode === CameraProjectionMode.PERSPECTIVE) {
383
433
  this.setPerspective(this.near, this.far, this.fov, this.aspect);
384
434
  } else {
385
435
  this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, this.far);
@@ -393,7 +443,7 @@ var Camera = function (_super) {
393
443
  this.view.enabled = false;
394
444
  }
395
445
 
396
- if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
446
+ if (this.projectionMode === CameraProjectionMode.PERSPECTIVE) {
397
447
  this.setPerspective(this.near, this.far, this.fov, this.aspect);
398
448
  } else {
399
449
  this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, this.far);
@@ -405,9 +455,9 @@ var Camera = function (_super) {
405
455
  Camera.prototype.setZoom = function (zoom) {
406
456
  this.zoom = zoom;
407
457
 
408
- if (this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
458
+ if (this.projectionMode === CameraProjectionMode.ORTHOGRAPHIC) {
409
459
  this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, this.far);
410
- } else if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
460
+ } else if (this.projectionMode === CameraProjectionMode.PERSPECTIVE) {
411
461
  this.setPerspective(this.near, this.far, this.fov, this.aspect);
412
462
  }
413
463
 
@@ -415,7 +465,9 @@ var Camera = function (_super) {
415
465
  };
416
466
 
417
467
  Camera.prototype.setPerspective = function (near, far, fov, aspect) {
418
- this.projectionMode = CAMERA_PROJECTION_MODE.PERSPECTIVE;
468
+ var _a;
469
+
470
+ this.projectionMode = CameraProjectionMode.PERSPECTIVE;
419
471
  this.fov = fov;
420
472
  this.near = near;
421
473
  this.far = far;
@@ -425,7 +477,7 @@ var Camera = function (_super) {
425
477
  var width = this.aspect * height;
426
478
  var left = -0.5 * width;
427
479
 
428
- if (this.view !== undefined && this.view.enabled) {
480
+ if ((_a = this.view) === null || _a === void 0 ? void 0 : _a.enabled) {
429
481
  var fullWidth = this.view.fullWidth;
430
482
  var fullHeight = this.view.fullHeight;
431
483
  left += this.view.offsetX * width / fullWidth;
@@ -445,7 +497,9 @@ var Camera = function (_super) {
445
497
  };
446
498
 
447
499
  Camera.prototype.setOrthographic = function (l, r, t, b, near, far) {
448
- this.projectionMode = CAMERA_PROJECTION_MODE.ORTHOGRAPHIC;
500
+ var _a;
501
+
502
+ this.projectionMode = CameraProjectionMode.ORTHOGRAPHIC;
449
503
  this.rright = r;
450
504
  this.left = l;
451
505
  this.top = t;
@@ -461,7 +515,7 @@ var Camera = function (_super) {
461
515
  var top = cy + dy;
462
516
  var bottom = cy - dy;
463
517
 
464
- if (this.view !== undefined && this.view.enabled) {
518
+ if ((_a = this.view) === null || _a === void 0 ? void 0 : _a.enabled) {
465
519
  var scaleW = (this.rright - this.left) / this.view.fullWidth / this.zoom;
466
520
  var scaleH = (this.top - this.bottom) / this.view.fullHeight / this.zoom;
467
521
  left += scaleW * this.view.offsetX;
@@ -483,35 +537,57 @@ var Camera = function (_super) {
483
537
  return this;
484
538
  };
485
539
  /**
486
- * 设置相机位置
540
+ * Move the camera in world coordinates.
541
+ * It will keep looking at the current focal point.
542
+ *
543
+ * support scalars or vectors.
544
+ * @example
545
+ * setPosition(1, 2, 3);
546
+ * setPosition([1, 2, 3]);
487
547
  */
488
548
 
489
549
 
490
550
  Camera.prototype.setPosition = function (x, y, z) {
491
551
  if (y === void 0) {
492
- y = 0;
552
+ y = this.position[1];
493
553
  }
494
554
 
495
555
  if (z === void 0) {
496
- z = 0;
556
+ z = this.position[2];
497
557
  }
498
558
 
499
- this._setPosition(x, y, z);
559
+ var position = (0, _math.createVec3)(x, y, z);
560
+
561
+ this._setPosition(position);
500
562
 
501
563
  this.setFocalPoint(this.focalPoint);
564
+ this.triggerUpdate();
502
565
  return this;
503
566
  };
504
567
  /**
505
- * 设置视点位置
568
+ * Sets the focal point of this camera in world coordinates.
569
+ *
570
+ * support scalars or vectors.
571
+ * @example
572
+ * setFocalPoint(1, 2, 3);
573
+ * setFocalPoint([1, 2, 3]);
506
574
  */
507
575
 
508
576
 
509
577
  Camera.prototype.setFocalPoint = function (x, y, z) {
578
+ if (y === void 0) {
579
+ y = this.focalPoint[1];
580
+ }
581
+
582
+ if (z === void 0) {
583
+ z = this.focalPoint[2];
584
+ }
585
+
510
586
  var up = _glMatrix.vec3.fromValues(0, 1, 0);
511
587
 
512
588
  this.focalPoint = (0, _math.createVec3)(x, y, z);
513
589
 
514
- if (this.trackingMode === CAMERA_TRACKING_MODE.CINEMATIC) {
590
+ if (this.trackingMode === CameraTrackingMode.CINEMATIC) {
515
591
  var d = _glMatrix.vec3.subtract(_glMatrix.vec3.create(), this.focalPoint, this.position);
516
592
 
517
593
  x = d[0];
@@ -540,22 +616,27 @@ var Camera = function (_super) {
540
616
 
541
617
  this._getAngles();
542
618
 
619
+ this.triggerUpdate();
543
620
  return this;
544
621
  };
622
+
623
+ Camera.prototype.getDistance = function () {
624
+ return this.distance;
625
+ };
545
626
  /**
546
- * 固定当前视点,按指定距离放置相机
627
+ * Moves the camera towards/from the focal point.
547
628
  */
548
629
 
549
630
 
550
631
  Camera.prototype.setDistance = function (d) {
551
632
  if (this.distance === d || d < 0) {
552
- return;
633
+ return this;
553
634
  }
554
635
 
555
636
  this.distance = d;
556
637
 
557
- if (this.distance < 0.0002) {
558
- this.distance = 0.0002;
638
+ if (this.distance < MIN_DISTANCE) {
639
+ this.distance = MIN_DISTANCE;
559
640
  }
560
641
 
561
642
  this.dollyingStep = this.distance / 100;
@@ -571,6 +652,7 @@ var Camera = function (_super) {
571
652
 
572
653
  this._setPosition(pos);
573
654
 
655
+ this.triggerUpdate();
574
656
  return this;
575
657
  };
576
658
 
@@ -582,37 +664,34 @@ var Camera = function (_super) {
582
664
  Camera.prototype.setMinDistance = function (d) {
583
665
  this.minDistance = d;
584
666
  return this;
585
- };
586
- /**
587
- * Changes the initial azimuth of the camera
588
- */
589
-
590
-
591
- Camera.prototype.changeAzimuth = function (az) {
592
- this.setAzimuth(this.azimuth + az);
593
- return this;
594
- };
595
- /**
596
- * Changes the initial elevation of the camera
597
- */
598
-
599
-
600
- Camera.prototype.changeElevation = function (el) {
601
- this.setElevation(this.elevation + el);
602
- return this;
603
- };
604
- /**
605
- * Changes the initial roll of the camera
606
- */
667
+ }; // /**
668
+ // * Changes the initial azimuth of the camera
669
+ // */
670
+ // changeAzimuth(az: number) {
671
+ // this.setAzimuth(this.azimuth + az);
672
+ // this.triggerUpdate();
673
+ // return this;
674
+ // }
675
+ // /**
676
+ // * Changes the initial elevation of the camera
677
+ // */
678
+ // changeElevation(el: number) {
679
+ // this.setElevation(this.elevation + el);
680
+ // this.triggerUpdate();
681
+ // return this;
682
+ // }
683
+ // /**
684
+ // * Changes the initial roll of the camera
685
+ // */
686
+ // changeRoll(rl: number) {
687
+ // this.setRoll(this.roll + rl);
688
+ // this.triggerUpdate();
689
+ // return this;
690
+ // }
607
691
 
608
-
609
- Camera.prototype.changeRoll = function (rl) {
610
- this.setRoll(this.roll + rl);
611
- return this;
612
- };
613
692
  /**
614
693
  * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
615
- * @param {Number} el the azimuth in degrees
694
+ * the azimuth in degrees
616
695
  */
617
696
 
618
697
 
@@ -622,12 +701,13 @@ var Camera = function (_super) {
622
701
 
623
702
  this._getAxes();
624
703
 
625
- if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
704
+ if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
626
705
  this._getPosition();
627
- } else if (this.type === CAMERA_TYPE.TRACKING) {
706
+ } else if (this.type === CameraType.TRACKING) {
628
707
  this._getFocalPoint();
629
708
  }
630
709
 
710
+ this.triggerUpdate();
631
711
  return this;
632
712
  };
633
713
 
@@ -636,7 +716,6 @@ var Camera = function (_super) {
636
716
  };
637
717
  /**
638
718
  * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
639
- * @param {Number} el the elevation in degrees
640
719
  */
641
720
 
642
721
 
@@ -646,17 +725,21 @@ var Camera = function (_super) {
646
725
 
647
726
  this._getAxes();
648
727
 
649
- if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
728
+ if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
650
729
  this._getPosition();
651
- } else if (this.type === CAMERA_TYPE.TRACKING) {
730
+ } else if (this.type === CameraType.TRACKING) {
652
731
  this._getFocalPoint();
653
732
  }
654
733
 
734
+ this.triggerUpdate();
655
735
  return this;
656
736
  };
737
+
738
+ Camera.prototype.getElevation = function () {
739
+ return this.elevation;
740
+ };
657
741
  /**
658
742
  * 设置相机方位角,不同相机模式下需要重新计算相机位置或者是视点位置
659
- * @param {Number} angle the roll angle
660
743
  */
661
744
 
662
745
 
@@ -666,14 +749,19 @@ var Camera = function (_super) {
666
749
 
667
750
  this._getAxes();
668
751
 
669
- if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
752
+ if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
670
753
  this._getPosition();
671
- } else if (this.type === CAMERA_TYPE.TRACKING) {
754
+ } else if (this.type === CameraType.TRACKING) {
672
755
  this._getFocalPoint();
673
756
  }
674
757
 
758
+ this.triggerUpdate();
675
759
  return this;
676
760
  };
761
+
762
+ Camera.prototype.getRoll = function () {
763
+ return this.roll;
764
+ };
677
765
  /**
678
766
  * Changes the azimuth and elevation with respect to the current camera axes
679
767
  * @param {Number} azimuth the relative azimuth
@@ -690,7 +778,7 @@ var Camera = function (_super) {
690
778
  this.azimuth += this.relAzimuth;
691
779
  this.roll += this.relRoll;
692
780
 
693
- if (this.type === CAMERA_TYPE.EXPLORING) {
781
+ if (this.type === CameraType.EXPLORING) {
694
782
  var rotX = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [1, 0, 0], (this.rotateWorld ? 1 : -1) * this.relElevation * DEG_2_RAD);
695
783
 
696
784
  var rotY = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [0, 1, 0], (this.rotateWorld ? 1 : -1) * this.relAzimuth * DEG_2_RAD);
@@ -710,7 +798,7 @@ var Camera = function (_super) {
710
798
  _glMatrix.mat4.translate(this.matrix, this.matrix, [0, 0, this.distance]);
711
799
  } else {
712
800
  if (Math.abs(this.elevation) > 90) {
713
- return;
801
+ return this;
714
802
  }
715
803
 
716
804
  this.computeMatrix();
@@ -718,9 +806,9 @@ var Camera = function (_super) {
718
806
 
719
807
  this._getAxes();
720
808
 
721
- if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
809
+ if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
722
810
  this._getPosition();
723
- } else if (this.type === CAMERA_TYPE.TRACKING) {
811
+ } else if (this.type === CameraType.TRACKING) {
724
812
  this._getFocalPoint();
725
813
  }
726
814
 
@@ -767,10 +855,10 @@ var Camera = function (_super) {
767
855
 
768
856
  this._setPosition(pos);
769
857
 
770
- if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
858
+ if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
771
859
  // 重新计算视点距离
772
860
  this._getDistance();
773
- } else if (this.type === CAMERA_TYPE.TRACKING) {
861
+ } else if (this.type === CameraType.TRACKING) {
774
862
  // 保持视距,移动视点位置
775
863
  _glMatrix.vec3.add(this.focalPoint, pos, this.distanceVector);
776
864
  }
@@ -784,33 +872,41 @@ var Camera = function (_super) {
784
872
  params = {};
785
873
  }
786
874
 
787
- var position = params.position,
788
- focalPoint = params.focalPoint,
875
+ var _a = params.position,
876
+ position = _a === void 0 ? this.position : _a,
877
+ _b = params.focalPoint,
878
+ focalPoint = _b === void 0 ? this.focalPoint : _b,
789
879
  roll = params.roll,
790
880
  zoom = params.zoom;
791
- var camera = this.clone();
792
- camera.setPosition(_glMatrix.vec3.fromValues(position[0], position[1], position[2] || this.position[2]));
793
- camera.setFocalPoint(_glMatrix.vec3.fromValues(focalPoint[0], focalPoint[1], focalPoint[2] || this.focalPoint[2]));
794
-
795
- if (!(0, _util.isUndefined)(roll)) {
796
- camera.setRoll(roll);
797
- }
798
-
799
- if (!(0, _util.isUndefined)(zoom)) {
800
- camera.setZoom(zoom);
801
- }
802
-
803
- var landmark = new _Landmark.Landmark(name, camera);
881
+ var camera = new Camera();
882
+ camera.setType(this.type, undefined);
883
+ camera.setPosition(position[0], position[1] || this.position[1], position[2] || this.position[2]);
884
+ camera.setFocalPoint(focalPoint[0], focalPoint[1] || this.focalPoint[1], focalPoint[2] || this.focalPoint[2]);
885
+ camera.setRoll(roll || this.roll);
886
+ camera.setZoom(zoom || this.zoom);
887
+ var landmark = {
888
+ name: name,
889
+ matrix: _glMatrix.mat4.clone(camera.matrix),
890
+ right: _glMatrix.vec3.clone(camera.right),
891
+ up: _glMatrix.vec3.clone(camera.up),
892
+ forward: _glMatrix.vec3.clone(camera.forward),
893
+ position: _glMatrix.vec3.clone(camera.position),
894
+ focalPoint: _glMatrix.vec3.clone(camera.focalPoint),
895
+ distanceVector: _glMatrix.vec3.clone(camera.distanceVector),
896
+ distance: camera.distance,
897
+ dollyingStep: camera.dollyingStep,
898
+ azimuth: camera.azimuth,
899
+ elevation: camera.elevation,
900
+ roll: camera.roll,
901
+ relAzimuth: camera.relAzimuth,
902
+ relElevation: camera.relElevation,
903
+ relRoll: camera.relRoll,
904
+ zoom: camera.zoom
905
+ };
804
906
  this.landmarks.push(landmark);
805
907
  return landmark;
806
908
  };
807
909
 
808
- Camera.prototype.setLandmark = function (name) {
809
- var landmark = new _Landmark.Landmark(name, this);
810
- this.landmarks.push(landmark);
811
- return this;
812
- };
813
-
814
910
  Camera.prototype.gotoLandmark = function (name, options) {
815
911
  var _this = this;
816
912
 
@@ -818,47 +914,79 @@ var Camera = function (_super) {
818
914
  options = {};
819
915
  }
820
916
 
821
- var landmark = (0, _util.isString)(name) ? this.landmarks.find(function (l) {
917
+ var landmark = (0, _lodashEs.isString)(name) ? this.landmarks.find(function (l) {
822
918
  return l.name === name;
823
919
  }) : name;
824
920
 
825
921
  if (landmark) {
826
- var _a = (0, _util.isNumber)(options) ? {
922
+ var _a = (0, _lodashEs.isNumber)(options) ? {
827
923
  duration: options
828
924
  } : options,
829
925
  _b = _a.easing,
830
- easing = _b === void 0 ? 'ease' : _b,
926
+ easing = _b === void 0 ? 'linear' : _b,
831
927
  _c = _a.duration,
832
- duration_1 = _c === void 0 ? 1000 : _c;
928
+ duration_1 = _c === void 0 ? 100 : _c,
929
+ _d = _a.easingFunction,
930
+ easingFunction = _d === void 0 ? undefined : _d,
931
+ _e = _a.onfinish,
932
+ onfinish_1 = _e === void 0 ? undefined : _e;
833
933
 
834
934
  var epsilon_1 = 0.01;
835
935
 
836
936
  if (duration_1 === 0) {
837
- landmark.retrieve(this);
937
+ this.syncFromLandmark(landmark);
938
+
939
+ if (onfinish_1) {
940
+ onfinish_1();
941
+ }
942
+
838
943
  return;
839
- }
944
+ } // cancel ongoing animation
945
+
840
946
 
841
947
  if (this.landmarkAnimationID !== undefined) {
842
948
  this.canvas.cancelAnimationFrame(this.landmarkAnimationID);
843
- } // TODO: do not process events during animation
844
- // this.interactor.disconnect();
845
-
949
+ }
846
950
 
847
- var destPosition_1 = landmark.getPosition();
848
- var destFocalPoint_1 = landmark.getFocalPoint();
849
- var destZoom_1 = landmark.getZoom();
850
- var destRoll_1 = landmark.getRoll();
851
- var easingFunction_1 = (0, _animation.parseEasingFunction)(easing);
951
+ var destPosition_1 = landmark.position;
952
+ var destFocalPoint_1 = landmark.focalPoint;
953
+ var destZoom_1 = landmark.zoom;
954
+ var destRoll_1 = landmark.roll;
955
+ var easingFunc_1 = easingFunction || (0, _animation.parseEasingFunction)(easing);
852
956
  var timeStart_1;
853
957
 
958
+ var endAnimation_1 = function endAnimation_1() {
959
+ _this.setFocalPoint(destFocalPoint_1);
960
+
961
+ _this.setPosition(destPosition_1);
962
+
963
+ _this.setRoll(destRoll_1);
964
+
965
+ _this.setZoom(destZoom_1);
966
+
967
+ _this.computeMatrix();
968
+
969
+ _this.triggerUpdate();
970
+
971
+ if (onfinish_1) {
972
+ onfinish_1();
973
+ }
974
+ };
975
+
854
976
  var animate_1 = function animate_1(timestamp) {
855
977
  if (timeStart_1 === undefined) {
856
978
  timeStart_1 = timestamp;
857
979
  }
858
980
 
859
- var elapsed = timestamp - timeStart_1; // use the same ease function in animatio system
981
+ var elapsed = timestamp - timeStart_1;
982
+
983
+ if (elapsed > duration_1) {
984
+ endAnimation_1();
985
+ return;
986
+ } // use the same ease function in animation system
987
+
860
988
 
861
- var t = easingFunction_1(elapsed / duration_1);
989
+ var t = easingFunc_1(elapsed / duration_1);
862
990
 
863
991
  var interFocalPoint = _glMatrix.vec3.create();
864
992
 
@@ -882,27 +1010,17 @@ var Camera = function (_super) {
882
1010
 
883
1011
  _this.setZoom(interZoom);
884
1012
 
885
- _this.computeMatrix();
886
-
887
- _this.triggerUpdate();
888
-
889
1013
  var dist = _glMatrix.vec3.dist(interFocalPoint, destFocalPoint_1) + _glMatrix.vec3.dist(interPosition, destPosition_1);
890
1014
 
891
1015
  if (dist <= epsilon_1) {
892
- _this.setFocalPoint(destFocalPoint_1);
893
-
894
- _this.setPosition(destPosition_1);
895
-
896
- _this.setRoll(destRoll_1);
897
-
898
- _this.setZoom(destZoom_1);
899
-
900
- _this.computeMatrix(); // this.interactor.connect();
901
-
902
-
1016
+ endAnimation_1();
903
1017
  return;
904
1018
  }
905
1019
 
1020
+ _this.computeMatrix();
1021
+
1022
+ _this.triggerUpdate();
1023
+
906
1024
  if (elapsed < duration_1) {
907
1025
  _this.landmarkAnimationID = _this.canvas.requestAnimationFrame(animate_1);
908
1026
  }
@@ -942,9 +1060,9 @@ var Camera = function (_super) {
942
1060
  _glMatrix.mat4.identity(this.matrix); // only consider HCS for EXPLORING and ORBITING cameras
943
1061
 
944
1062
 
945
- var rotX = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [1, 0, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.elevation * DEG_2_RAD);
1063
+ var rotX = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [1, 0, 0], (this.rotateWorld && this.type !== CameraType.TRACKING || this.type === CameraType.TRACKING ? 1 : -1) * this.elevation * DEG_2_RAD);
946
1064
 
947
- var rotY = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [0, 1, 0], (this.rotateWorld && this.type !== CAMERA_TYPE.TRACKING || this.type === CAMERA_TYPE.TRACKING ? 1 : -1) * this.azimuth * DEG_2_RAD);
1065
+ var rotY = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [0, 1, 0], (this.rotateWorld && this.type !== CameraType.TRACKING || this.type === CameraType.TRACKING ? 1 : -1) * this.azimuth * DEG_2_RAD);
948
1066
 
949
1067
  var rotQ = _glMatrix.quat.multiply(_glMatrix.quat.create(), rotY, rotX);
950
1068
 
@@ -952,13 +1070,13 @@ var Camera = function (_super) {
952
1070
 
953
1071
  var rotMatrix = _glMatrix.mat4.fromQuat(_glMatrix.mat4.create(), rotQ);
954
1072
 
955
- if (this.type === CAMERA_TYPE.ORBITING || this.type === CAMERA_TYPE.EXPLORING) {
1073
+ if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
956
1074
  _glMatrix.mat4.translate(this.matrix, this.matrix, this.focalPoint);
957
1075
 
958
1076
  _glMatrix.mat4.multiply(this.matrix, this.matrix, rotMatrix);
959
1077
 
960
1078
  _glMatrix.mat4.translate(this.matrix, this.matrix, [0, 0, this.distance]);
961
- } else if (this.type === CAMERA_TYPE.TRACKING) {
1079
+ } else if (this.type === CameraType.TRACKING) {
962
1080
  _glMatrix.mat4.translate(this.matrix, this.matrix, this.position);
963
1081
 
964
1082
  _glMatrix.mat4.multiply(this.matrix, this.matrix, rotMatrix);
@@ -1017,7 +1135,7 @@ var Camera = function (_super) {
1017
1135
  return;
1018
1136
  }
1019
1137
 
1020
- if (this.type === CAMERA_TYPE.TRACKING) {
1138
+ if (this.type === CameraType.TRACKING) {
1021
1139
  this.elevation = Math.asin(y / r) * RAD_2_DEG;
1022
1140
  this.azimuth = Math.atan2(-x, -z) * RAD_2_DEG;
1023
1141
  } else {
@@ -1066,7 +1184,7 @@ var Camera = function (_super) {
1066
1184
  };
1067
1185
 
1068
1186
  Camera.prototype._getOrthoMatrix = function () {
1069
- if (this.projectionMode !== CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
1187
+ if (this.projectionMode !== CameraProjectionMode.ORTHOGRAPHIC) {
1070
1188
  return;
1071
1189
  }
1072
1190
 
@@ -1078,19 +1196,36 @@ var Camera = function (_super) {
1078
1196
  };
1079
1197
 
1080
1198
  Camera.prototype.triggerUpdate = function () {
1081
- // update frustum
1082
- var viewMatrix = this.getViewTransform();
1199
+ if (this.enableUpdate) {
1200
+ // update frustum
1201
+ var viewMatrix = this.getViewTransform();
1083
1202
 
1084
- var vpMatrix = _glMatrix.mat4.multiply(_glMatrix.mat4.create(), this.getPerspective(), viewMatrix);
1203
+ var vpMatrix = _glMatrix.mat4.multiply(_glMatrix.mat4.create(), this.getPerspective(), viewMatrix);
1085
1204
 
1086
- this.getFrustum().extractFromVPMatrix(vpMatrix);
1087
- this.emit(CameraEvent.UPDATED);
1205
+ this.getFrustum().extractFromVPMatrix(vpMatrix);
1206
+ this.emit(CameraEvent.UPDATED);
1207
+ }
1088
1208
  };
1089
1209
 
1090
- Camera.ProjectionMode = {
1091
- ORTHOGRAPHIC: 'ORTHOGRAPHIC',
1092
- PERSPECTIVE: 'PERSPECTIVE'
1210
+ Camera.prototype.syncFromLandmark = function (landmark) {
1211
+ this.matrix = _glMatrix.mat4.copy(this.matrix, landmark.matrix);
1212
+ this.right = _glMatrix.vec3.copy(this.right, landmark.right);
1213
+ this.up = _glMatrix.vec3.copy(this.up, landmark.up);
1214
+ this.forward = _glMatrix.vec3.copy(this.forward, landmark.forward);
1215
+ this.position = _glMatrix.vec3.copy(this.position, landmark.position);
1216
+ this.focalPoint = _glMatrix.vec3.copy(this.focalPoint, landmark.focalPoint);
1217
+ this.distanceVector = _glMatrix.vec3.copy(this.distanceVector, landmark.distanceVector);
1218
+ this.azimuth = landmark.azimuth;
1219
+ this.elevation = landmark.elevation;
1220
+ this.roll = landmark.roll;
1221
+ this.relAzimuth = landmark.relAzimuth;
1222
+ this.relElevation = landmark.relElevation;
1223
+ this.relRoll = landmark.relRoll;
1224
+ this.dollyingStep = landmark.dollyingStep;
1225
+ this.distance = landmark.distance;
1226
+ this.zoom = landmark.zoom;
1093
1227
  };
1228
+
1094
1229
  return Camera;
1095
1230
  }(_eventemitter.EventEmitter);
1096
1231