@antv/g 5.0.22-alpha.5 → 5.0.22-alpha.6
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.
- package/dist/index.umd.min.js +30 -0
- package/es/AbstractRenderer.js +3 -1
- package/es/Canvas.d.ts +1 -1
- package/es/Canvas.js +5 -3
- package/es/DisplayObjectPool.js +3 -1
- package/es/camera/Camera.d.ts +105 -66
- package/es/camera/Camera.js +307 -171
- package/es/camera/Landmark.d.ts +18 -25
- package/es/camera/Landmark.js +1 -72
- package/es/canvas-module.js +2 -4
- package/es/components/Cullable.js +3 -1
- package/es/components/Geometry.js +3 -1
- package/es/components/Renderable.js +3 -1
- package/es/components/Sortable.js +3 -1
- package/es/components/Transform.js +3 -1
- package/es/css/LayoutRegistry.js +3 -1
- package/es/css/StyleValueRegistry.d.ts +8 -0
- package/es/css/StyleValueRegistry.js +24 -19
- package/es/css/cssom/CSSColorValue.js +3 -1
- package/es/css/cssom/CSSGradientValue.js +8 -6
- package/es/css/cssom/CSSKeywordValue.js +3 -1
- package/es/css/cssom/CSSMathInvert.js +3 -1
- package/es/css/cssom/CSSMathMax.js +3 -1
- package/es/css/cssom/CSSMathMin.js +3 -1
- package/es/css/cssom/CSSMathNegate.js +3 -1
- package/es/css/cssom/CSSMathProduct.js +3 -1
- package/es/css/cssom/CSSMathSum.js +3 -1
- package/es/css/cssom/CSSMathValue.js +3 -1
- package/es/css/cssom/CSSMathVariadic.js +3 -1
- package/es/css/cssom/CSSNumericValue.js +3 -1
- package/es/css/cssom/CSSNumericValueType.d.ts +1 -1
- package/es/css/cssom/CSSNumericValueType.js +3 -1
- package/es/css/cssom/CSSRGB.js +4 -2
- package/es/css/cssom/CSSStyleValue.d.ts +1 -1
- package/es/css/cssom/CSSStyleValue.js +3 -1
- package/es/css/cssom/CSSTransformComponent.js +3 -1
- package/es/css/cssom/CSSTransformValue.js +3 -1
- package/es/css/cssom/CSSTranslate.js +3 -1
- package/es/css/cssom/CSSUnitValue.js +4 -2
- package/es/css/parser/color.js +2 -2
- package/es/css/parser/dimension.d.ts +1 -1
- package/es/css/parser/dimension.js +2 -2
- package/es/css/parser/numeric.js +1 -1
- package/es/css/parser/points.js +1 -1
- package/es/css/parser/transform-origin.js +1 -1
- package/es/css/properties/CSSPropertyAnchor.js +3 -1
- package/es/css/properties/CSSPropertyClipPath.js +3 -1
- package/es/css/properties/CSSPropertyColor.js +3 -1
- package/es/css/properties/CSSPropertyFilter.js +3 -1
- package/es/css/properties/CSSPropertyLengthOrPercentage.js +3 -1
- package/es/css/properties/CSSPropertyLineDash.js +3 -1
- package/es/css/properties/CSSPropertyLocalPosition.js +3 -1
- package/es/css/properties/CSSPropertyOffsetDistance.js +3 -1
- package/es/css/properties/CSSPropertyOffsetPath.js +3 -1
- package/es/css/properties/CSSPropertyOpacity.js +3 -1
- package/es/css/properties/CSSPropertyPath.js +3 -1
- package/es/css/properties/CSSPropertyPoints.js +3 -1
- package/es/css/properties/CSSPropertyShadowBlur.js +3 -1
- package/es/css/properties/CSSPropertyText.d.ts +1 -1
- package/es/css/properties/CSSPropertyText.js +4 -2
- package/es/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/es/css/properties/CSSPropertyTextTransform.js +3 -1
- package/es/css/properties/CSSPropertyTransform.js +4 -2
- package/es/css/properties/CSSPropertyTransformOrigin.js +3 -1
- package/es/css/properties/CSSPropertyVisibility.js +3 -1
- package/es/css/properties/CSSPropertyZIndex.js +3 -1
- package/es/display-objects/Circle.js +3 -1
- package/es/display-objects/CustomElement.js +3 -1
- package/es/display-objects/DisplayObject.js +7 -4
- package/es/display-objects/Ellipse.js +3 -1
- package/es/display-objects/Group.js +3 -1
- package/es/display-objects/HTML.js +6 -3
- package/es/display-objects/Image.js +3 -1
- package/es/display-objects/Line.js +3 -1
- package/es/display-objects/Path.js +5 -3
- package/es/display-objects/Polygon.js +3 -1
- package/es/display-objects/Polyline.js +3 -1
- package/es/display-objects/Rect.js +3 -1
- package/es/display-objects/Text.js +6 -3
- package/es/dom/Animation.js +4 -2
- package/es/dom/AnimationEffectTiming.js +3 -1
- package/es/dom/AnimationEvent.js +3 -1
- package/es/dom/AnimationTimeline.js +3 -1
- package/es/dom/CustomElementRegistry.js +3 -1
- package/es/dom/CustomEvent.js +3 -1
- package/es/dom/Document.js +3 -1
- package/es/dom/Element.js +7 -5
- package/es/dom/EventTarget.js +6 -4
- package/es/dom/FederatedEvent.js +3 -1
- package/es/dom/FederatedMouseEvent.js +3 -1
- package/es/dom/FederatedPointerEvent.js +3 -1
- package/es/dom/FederatedTouchEvent.d.ts +13 -0
- package/es/dom/FederatedTouchEvent.js +19 -0
- package/es/dom/FederatedWheelEvent.js +3 -1
- package/es/dom/KeyframeEffect.js +3 -1
- package/es/dom/KeyframeList.js +1 -1
- package/es/dom/MutationEvent.js +3 -1
- package/es/dom/MutationObserver.js +10 -3
- package/es/dom/MutationRecord.js +3 -1
- package/es/dom/Node.js +4 -2
- package/es/plugins/CullingPlugin.js +3 -1
- package/es/plugins/DirtyCheckPlugin.js +3 -1
- package/es/plugins/EventPlugin.js +4 -2
- package/es/plugins/FrustumCullingStrategy.js +3 -1
- package/es/plugins/PrepareRendererPlugin.js +3 -1
- package/es/services/EventService.js +5 -3
- package/es/services/OffscreenCanvasCreator.js +3 -1
- package/es/services/RenderingService.js +3 -1
- package/es/services/SceneGraphSelector.js +3 -1
- package/es/services/SceneGraphService.js +4 -2
- package/es/services/TextService.js +5 -3
- package/es/services/aabb/CircleUpdater.js +3 -1
- package/es/services/aabb/EllipseUpdater.js +3 -1
- package/es/services/aabb/LineUpdater.js +3 -1
- package/es/services/aabb/PathUpdater.js +3 -1
- package/es/services/aabb/PolylineUpdater.js +3 -1
- package/es/services/aabb/RectUpdater.js +4 -2
- package/es/services/aabb/TextUpdater.js +3 -1
- package/es/shapes/AABB.js +3 -1
- package/es/shapes/BoundingSphere.js +3 -1
- package/es/shapes/Frustum.js +3 -1
- package/es/shapes/Plane.js +3 -1
- package/es/shapes/Point.js +3 -1
- package/es/shapes/Ray.js +3 -1
- package/es/shapes/Rectangle.js +3 -1
- package/es/types.d.ts +4 -0
- package/es/utils/custom-easing.js +1 -1
- package/es/utils/math.d.ts +1 -2
- package/es/utils/math.js +11 -6
- package/es/utils/path.d.ts +1 -1
- package/es/utils/path.js +3 -3
- package/es/utils/text.js +4 -4
- package/lib/AbstractRenderer.js +3 -1
- package/lib/Canvas.d.ts +1 -1
- package/lib/Canvas.js +5 -3
- package/lib/DisplayObjectPool.js +3 -1
- package/lib/camera/Camera.d.ts +105 -66
- package/lib/camera/Camera.js +314 -179
- package/lib/camera/Landmark.d.ts +18 -25
- package/lib/camera/Landmark.js +1 -75
- package/lib/canvas-module.js +1 -3
- package/lib/components/Cullable.js +4 -2
- package/lib/components/Geometry.js +3 -1
- package/lib/components/Renderable.js +3 -1
- package/lib/components/Sortable.js +3 -1
- package/lib/components/Transform.js +3 -1
- package/lib/css/LayoutRegistry.js +3 -1
- package/lib/css/StyleValueRegistry.d.ts +8 -0
- package/lib/css/StyleValueRegistry.js +27 -20
- package/lib/css/cssom/CSSColorValue.js +3 -1
- package/lib/css/cssom/CSSGradientValue.js +9 -7
- package/lib/css/cssom/CSSKeywordValue.js +3 -1
- package/lib/css/cssom/CSSMathInvert.js +3 -1
- package/lib/css/cssom/CSSMathMax.js +3 -1
- package/lib/css/cssom/CSSMathMin.js +3 -1
- package/lib/css/cssom/CSSMathNegate.js +3 -1
- package/lib/css/cssom/CSSMathOperator.js +1 -1
- package/lib/css/cssom/CSSMathProduct.js +3 -1
- package/lib/css/cssom/CSSMathSum.js +3 -1
- package/lib/css/cssom/CSSMathValue.js +3 -1
- package/lib/css/cssom/CSSMathVariadic.js +4 -2
- package/lib/css/cssom/CSSNumericValue.js +3 -1
- package/lib/css/cssom/CSSNumericValueType.d.ts +1 -1
- package/lib/css/cssom/CSSNumericValueType.js +5 -3
- package/lib/css/cssom/CSSRGB.js +4 -2
- package/lib/css/cssom/CSSStyleValue.d.ts +1 -1
- package/lib/css/cssom/CSSStyleValue.js +4 -2
- package/lib/css/cssom/CSSTransformComponent.js +4 -2
- package/lib/css/cssom/CSSTransformValue.js +3 -1
- package/lib/css/cssom/CSSTranslate.js +3 -1
- package/lib/css/cssom/CSSUnitValue.js +4 -2
- package/lib/css/cssom/types.js +1 -1
- package/lib/css/parser/color.js +7 -7
- package/lib/css/parser/dimension.d.ts +1 -1
- package/lib/css/parser/dimension.js +9 -8
- package/lib/css/parser/numeric.js +6 -6
- package/lib/css/parser/path.js +1 -1
- package/lib/css/parser/points.js +2 -2
- package/lib/css/parser/transform-origin.js +2 -2
- package/lib/css/parser/transform.js +2 -2
- package/lib/css/properties/CSSPropertyAnchor.js +3 -1
- package/lib/css/properties/CSSPropertyClipPath.js +3 -1
- package/lib/css/properties/CSSPropertyColor.js +3 -1
- package/lib/css/properties/CSSPropertyFilter.js +3 -1
- package/lib/css/properties/CSSPropertyLengthOrPercentage.js +3 -1
- package/lib/css/properties/CSSPropertyLineDash.js +3 -1
- package/lib/css/properties/CSSPropertyLocalPosition.js +3 -1
- package/lib/css/properties/CSSPropertyOffsetDistance.js +3 -1
- package/lib/css/properties/CSSPropertyOffsetPath.js +3 -1
- package/lib/css/properties/CSSPropertyOpacity.js +3 -1
- package/lib/css/properties/CSSPropertyPath.js +3 -1
- package/lib/css/properties/CSSPropertyPoints.js +3 -1
- package/lib/css/properties/CSSPropertyShadowBlur.js +3 -1
- package/lib/css/properties/CSSPropertyText.d.ts +1 -1
- package/lib/css/properties/CSSPropertyText.js +4 -2
- package/lib/css/properties/CSSPropertyTextTransform.d.ts +2 -2
- package/lib/css/properties/CSSPropertyTextTransform.js +3 -1
- package/lib/css/properties/CSSPropertyTransform.js +4 -2
- package/lib/css/properties/CSSPropertyTransformOrigin.js +3 -1
- package/lib/css/properties/CSSPropertyVisibility.js +3 -1
- package/lib/css/properties/CSSPropertyZIndex.js +3 -1
- package/lib/display-objects/Circle.js +3 -1
- package/lib/display-objects/CustomElement.js +3 -1
- package/lib/display-objects/DisplayObject.js +14 -11
- package/lib/display-objects/Ellipse.js +3 -1
- package/lib/display-objects/Group.js +3 -1
- package/lib/display-objects/HTML.js +6 -4
- package/lib/display-objects/Image.js +3 -1
- package/lib/display-objects/Line.js +3 -1
- package/lib/display-objects/Path.js +8 -6
- package/lib/display-objects/Polygon.js +3 -1
- package/lib/display-objects/Polyline.js +3 -1
- package/lib/display-objects/Rect.js +3 -1
- package/lib/display-objects/Text.js +6 -4
- package/lib/dom/Animation.js +4 -2
- package/lib/dom/AnimationEffectTiming.js +3 -1
- package/lib/dom/AnimationEvent.js +3 -1
- package/lib/dom/AnimationTimeline.js +4 -2
- package/lib/dom/CustomElementRegistry.js +3 -1
- package/lib/dom/CustomEvent.js +3 -1
- package/lib/dom/Document.js +3 -1
- package/lib/dom/Element.js +8 -6
- package/lib/dom/EventTarget.js +13 -11
- package/lib/dom/FederatedEvent.js +3 -1
- package/lib/dom/FederatedMouseEvent.js +3 -1
- package/lib/dom/FederatedPointerEvent.js +3 -1
- package/lib/dom/FederatedTouchEvent.d.ts +13 -0
- package/lib/dom/FederatedTouchEvent.js +27 -0
- package/lib/dom/FederatedWheelEvent.js +3 -1
- package/lib/dom/KeyframeEffect.js +4 -2
- package/lib/dom/KeyframeList.js +1 -1
- package/lib/dom/MutationEvent.js +3 -1
- package/lib/dom/MutationObserver.js +11 -4
- package/lib/dom/MutationRecord.js +3 -1
- package/lib/dom/Node.js +4 -2
- package/lib/index.js +1 -1
- package/lib/plugins/CullingPlugin.js +4 -2
- package/lib/plugins/DirtyCheckPlugin.js +3 -1
- package/lib/plugins/EventPlugin.js +26 -24
- package/lib/plugins/FrustumCullingStrategy.js +3 -1
- package/lib/plugins/PrepareRendererPlugin.js +3 -1
- package/lib/services/EventService.js +5 -3
- package/lib/services/OffscreenCanvasCreator.js +3 -1
- package/lib/services/RenderingService.js +3 -1
- package/lib/services/SceneGraphSelector.js +4 -2
- package/lib/services/SceneGraphService.js +7 -5
- package/lib/services/TextService.js +5 -3
- package/lib/services/aabb/CircleUpdater.js +3 -1
- package/lib/services/aabb/EllipseUpdater.js +3 -1
- package/lib/services/aabb/LineUpdater.js +3 -1
- package/lib/services/aabb/PathUpdater.js +3 -1
- package/lib/services/aabb/PolylineUpdater.js +3 -1
- package/lib/services/aabb/RectUpdater.js +5 -3
- package/lib/services/aabb/TextUpdater.js +3 -1
- package/lib/services/aabb/index.js +10 -10
- package/lib/services/aabb/interfaces.js +1 -1
- package/lib/shapes/AABB.js +3 -1
- package/lib/shapes/BoundingSphere.js +3 -1
- package/lib/shapes/Frustum.js +4 -2
- package/lib/shapes/Plane.js +3 -1
- package/lib/shapes/Point.js +3 -1
- package/lib/shapes/Ray.js +3 -1
- package/lib/shapes/Rectangle.js +3 -1
- package/lib/types.d.ts +4 -0
- package/lib/types.js +1 -1
- package/lib/utils/animation.js +3 -2
- package/lib/utils/bezier-easing.js +1 -1
- package/lib/utils/custom-easing.js +2 -2
- package/lib/utils/math.d.ts +1 -2
- package/lib/utils/math.js +20 -17
- package/lib/utils/path.d.ts +1 -1
- package/lib/utils/path.js +6 -6
- package/lib/utils/text.js +5 -5
- package/package.json +7 -5
package/lib/camera/Camera.js
CHANGED
|
@@ -3,55 +3,83 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
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
|
-
|
|
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
|
|
30
|
-
exports.
|
|
28
|
+
var CameraType;
|
|
29
|
+
exports.CameraType = CameraType;
|
|
31
30
|
|
|
32
|
-
(function (
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
|
49
|
-
exports.
|
|
76
|
+
var CameraProjectionMode;
|
|
77
|
+
exports.CameraProjectionMode = CameraProjectionMode;
|
|
50
78
|
|
|
51
|
-
(function (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
})(
|
|
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 =
|
|
102
|
+
var Camera =
|
|
103
|
+
/** @class */
|
|
104
|
+
function (_super) {
|
|
72
105
|
(0, _tslib.__extends)(Camera, _super);
|
|
73
106
|
|
|
74
|
-
function Camera() {
|
|
75
|
-
|
|
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,
|
|
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;
|
|
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;
|
|
204
|
+
_this.jitteredProjectionMatrix = undefined;
|
|
205
|
+
_this.enableUpdate = true; // private following = undefined;
|
|
166
206
|
|
|
167
|
-
_this.type =
|
|
168
|
-
_this.trackingMode =
|
|
169
|
-
_this.projectionMode =
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 !==
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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 =
|
|
552
|
+
y = this.position[1];
|
|
493
553
|
}
|
|
494
554
|
|
|
495
555
|
if (z === void 0) {
|
|
496
|
-
z =
|
|
556
|
+
z = this.position[2];
|
|
497
557
|
}
|
|
498
558
|
|
|
499
|
-
|
|
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 ===
|
|
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 <
|
|
558
|
-
this.distance =
|
|
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
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
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
|
-
*
|
|
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 ===
|
|
704
|
+
if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
|
|
626
705
|
this._getPosition();
|
|
627
|
-
} else if (this.type ===
|
|
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 ===
|
|
728
|
+
if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
|
|
650
729
|
this._getPosition();
|
|
651
|
-
} else if (this.type ===
|
|
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 ===
|
|
752
|
+
if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
|
|
670
753
|
this._getPosition();
|
|
671
|
-
} else if (this.type ===
|
|
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 ===
|
|
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 ===
|
|
809
|
+
if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
|
|
722
810
|
this._getPosition();
|
|
723
|
-
} else if (this.type ===
|
|
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 ===
|
|
858
|
+
if (this.type === CameraType.ORBITING || this.type === CameraType.EXPLORING) {
|
|
771
859
|
// 重新计算视点距离
|
|
772
860
|
this._getDistance();
|
|
773
|
-
} else if (this.type ===
|
|
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
|
|
788
|
-
|
|
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 =
|
|
792
|
-
camera.
|
|
793
|
-
camera.
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
camera.
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
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,
|
|
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,
|
|
922
|
+
var _a = (0, _lodashEs.isNumber)(options) ? {
|
|
827
923
|
duration: options
|
|
828
924
|
} : options,
|
|
829
925
|
_b = _a.easing,
|
|
830
|
-
easing = _b === void 0 ? '
|
|
926
|
+
easing = _b === void 0 ? 'linear' : _b,
|
|
831
927
|
_c = _a.duration,
|
|
832
|
-
duration_1 = _c === void 0 ?
|
|
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
|
-
|
|
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
|
-
}
|
|
844
|
-
// this.interactor.disconnect();
|
|
845
|
-
|
|
949
|
+
}
|
|
846
950
|
|
|
847
|
-
var destPosition_1 = landmark.
|
|
848
|
-
var destFocalPoint_1 = landmark.
|
|
849
|
-
var destZoom_1 = landmark.
|
|
850
|
-
var destRoll_1 = landmark.
|
|
851
|
-
var
|
|
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;
|
|
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 =
|
|
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
|
-
|
|
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 !==
|
|
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 !==
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
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 !==
|
|
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
|
-
|
|
1082
|
-
|
|
1199
|
+
if (this.enableUpdate) {
|
|
1200
|
+
// update frustum
|
|
1201
|
+
var viewMatrix = this.getViewTransform();
|
|
1083
1202
|
|
|
1084
|
-
|
|
1203
|
+
var vpMatrix = _glMatrix.mat4.multiply(_glMatrix.mat4.create(), this.getPerspective(), viewMatrix);
|
|
1085
1204
|
|
|
1086
|
-
|
|
1087
|
-
|
|
1205
|
+
this.getFrustum().extractFromVPMatrix(vpMatrix);
|
|
1206
|
+
this.emit(CameraEvent.UPDATED);
|
|
1207
|
+
}
|
|
1088
1208
|
};
|
|
1089
1209
|
|
|
1090
|
-
Camera.
|
|
1091
|
-
|
|
1092
|
-
|
|
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
|
|