@shapediver/viewer.rendering-engine.camera-engine 3.16.8 → 3.16.9

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 (60) hide show
  1. package/dist/implementation/CameraEngine.d.ts +42 -42
  2. package/dist/implementation/CameraEngine.js +607 -607
  3. package/dist/implementation/CameraEngine.js.map +1 -1
  4. package/dist/implementation/camera/AbstractCamera.d.ts +90 -90
  5. package/dist/implementation/camera/AbstractCamera.js +354 -354
  6. package/dist/implementation/camera/AbstractCamera.js.map +1 -1
  7. package/dist/implementation/camera/OrthographicCamera.d.ts +37 -37
  8. package/dist/implementation/camera/OrthographicCamera.js +268 -268
  9. package/dist/implementation/camera/OrthographicCamera.js.map +1 -1
  10. package/dist/implementation/camera/PerspectiveCamera.d.ts +28 -28
  11. package/dist/implementation/camera/PerspectiveCamera.js +250 -250
  12. package/dist/implementation/camera/PerspectiveCamera.js.map +1 -1
  13. package/dist/implementation/controls/AbstractCameraControls.d.ts +217 -217
  14. package/dist/implementation/controls/AbstractCameraControls.js +635 -635
  15. package/dist/implementation/controls/AbstractCameraControls.js.map +1 -1
  16. package/dist/implementation/controls/CameraControlsEventDistribution.d.ts +39 -39
  17. package/dist/implementation/controls/CameraControlsEventDistribution.d.ts.map +1 -1
  18. package/dist/implementation/controls/CameraControlsEventDistribution.js +287 -287
  19. package/dist/implementation/controls/CameraControlsEventDistribution.js.map +1 -1
  20. package/dist/implementation/controls/CameraControlsLogic.d.ts +36 -36
  21. package/dist/implementation/controls/CameraControlsLogic.js +530 -530
  22. package/dist/implementation/controls/CameraControlsLogic.js.map +1 -1
  23. package/dist/implementation/controls/OrthographicCameraControls.d.ts +7 -7
  24. package/dist/implementation/controls/OrthographicCameraControls.js +34 -34
  25. package/dist/implementation/controls/PerspectiveCameraControls.d.ts +7 -7
  26. package/dist/implementation/controls/PerspectiveCameraControls.js +34 -34
  27. package/dist/implementation/interpolation/CameraInterpolationManager.d.ts +22 -22
  28. package/dist/implementation/interpolation/CameraInterpolationManager.js +165 -155
  29. package/dist/implementation/interpolation/CameraInterpolationManager.js.map +1 -1
  30. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.d.ts +36 -36
  31. package/dist/implementation/interpolation/interpolationMethods/CameraCylindricalInterpolation.js +57 -57
  32. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.d.ts +26 -26
  33. package/dist/implementation/interpolation/interpolationMethods/CameraLinearInterpolation.js +31 -31
  34. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.d.ts +35 -35
  35. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js +45 -45
  36. package/dist/implementation/interpolation/interpolationMethods/CameraMultipleInterpolation.js.map +1 -1
  37. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.d.ts +26 -26
  38. package/dist/implementation/interpolation/interpolationMethods/CameraOrthographicInterpolation.js +31 -31
  39. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.d.ts +32 -32
  40. package/dist/implementation/interpolation/interpolationMethods/CameraSphericalInterpolation.js +42 -42
  41. package/dist/index.d.ts +16 -16
  42. package/dist/index.js +18 -18
  43. package/dist/interfaces/ICameraEngine.d.ts +12 -12
  44. package/dist/interfaces/ICameraEngine.js +3 -3
  45. package/dist/interfaces/camera/ICamera.d.ts +47 -47
  46. package/dist/interfaces/camera/ICamera.js +2 -2
  47. package/dist/interfaces/camera/IOrthographicCamera.d.ts +8 -8
  48. package/dist/interfaces/camera/IOrthographicCamera.js +3 -3
  49. package/dist/interfaces/camera/IPerspectiveCamera.d.ts +7 -7
  50. package/dist/interfaces/camera/IPerspectiveCamera.js +2 -2
  51. package/dist/interfaces/controls/ICameraControls.d.ts +105 -105
  52. package/dist/interfaces/controls/ICameraControls.d.ts.map +1 -1
  53. package/dist/interfaces/controls/ICameraControls.js +3 -3
  54. package/dist/interfaces/controls/ICameraControlsEventDistribution.d.ts +6 -6
  55. package/dist/interfaces/controls/ICameraControlsEventDistribution.js +2 -2
  56. package/dist/interfaces/controls/ICameraControlsLogic.d.ts +14 -14
  57. package/dist/interfaces/controls/ICameraControlsLogic.js +2 -2
  58. package/dist/interfaces/interpolation/ICameraInterpolation.d.ts +11 -11
  59. package/dist/interfaces/interpolation/ICameraInterpolation.js +2 -2
  60. package/package.json +8 -8
@@ -1,156 +1,166 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.CameraInterpolationManager = void 0;
27
- const TWEEN = __importStar(require("@tweenjs/tween.js"));
28
- const CameraCylindricalInterpolation_1 = require("./interpolationMethods/CameraCylindricalInterpolation");
29
- const CameraLinearInterpolation_1 = require("./interpolationMethods/CameraLinearInterpolation");
30
- const CameraMultipleInterpolation_1 = require("./interpolationMethods/CameraMultipleInterpolation");
31
- const CameraSphericalInterpolation_1 = require("./interpolationMethods/CameraSphericalInterpolation");
32
- class CameraInterpolationManager {
33
- // #endregion Properties (2)
34
- // #region Constructors (1)
35
- constructor(_camera, _cameraControls) {
36
- this._camera = _camera;
37
- this._cameraControls = _cameraControls;
38
- // #region Properties (2)
39
- this.TweenWrapper = class {
40
- constructor(options, cb, onComplete) {
41
- this._properties = { delta: 0 };
42
- this._tween = new TWEEN.Tween(this._properties);
43
- this._tween.easing(options.easing);
44
- this._tween.to({ delta: 1.0 }, options.duration);
45
- this._tween.onUpdate((v) => {
46
- cb.onUpdate(v);
47
- });
48
- this._tween.onStop((v) => {
49
- if (cb.onStop)
50
- cb.onStop(v);
51
- this._resolve(true);
52
- });
53
- this._tween.onComplete((v) => {
54
- if (cb.onComplete)
55
- cb.onComplete(v);
56
- onComplete();
57
- this._resolve(true);
58
- });
59
- }
60
- start() {
61
- return new Promise((resolve) => {
62
- this._resolve = resolve;
63
- this._tween.start();
64
- });
65
- }
66
- stop() {
67
- this._tween.stop();
68
- }
69
- };
70
- }
71
- // #endregion Constructors (1)
72
- // #region Public Methods (3)
73
- active() {
74
- return this._tween ? true : false;
75
- }
76
- /**
77
- * cameraTween
78
- */
79
- interpolate(path, options = {}) {
80
- const newPath = [];
81
- for (let i = 0; i < path.length; i++)
82
- newPath.push({
83
- position: path[i].position,
84
- target: path[i].target,
85
- });
86
- if (this._tween) {
87
- this._tween.stop();
88
- this._tween = null;
89
- }
90
- const parsedOptions = this.optionsParser(options);
91
- this._tween = new this.TweenWrapper(parsedOptions, newPath.length === 2
92
- ? this.getCameraInterpolation(newPath[0], newPath[1], parsedOptions.coordinates)
93
- : new CameraMultipleInterpolation_1.CameraMultipleInterpolation(this._camera, this._cameraControls, newPath, parsedOptions.interpolation), () => {
94
- this._tween = null;
95
- });
96
- return this._tween.start();
97
- }
98
- stop() {
99
- if (this._tween)
100
- this._tween.stop();
101
- this._tween = null;
102
- }
103
- // #endregion Public Methods (3)
104
- // #region Private Methods (2)
105
- getCameraInterpolation(from, to, type) {
106
- switch (type) {
107
- case "linear":
108
- return new CameraLinearInterpolation_1.CameraLinearInterpolation(this._camera, this._cameraControls, from, to);
109
- case "spherical":
110
- return new CameraSphericalInterpolation_1.CameraSphericalInterpolation(this._camera, this._cameraControls, from, to);
111
- case "cylindrical":
112
- return new CameraCylindricalInterpolation_1.CameraCylindricalInterpolation(this._camera, this._cameraControls, from, to);
113
- default:
114
- return new CameraMultipleInterpolation_1.CameraMultipleInterpolation(this._camera, this._cameraControls, [from, to], TWEEN.Interpolation.CatmullRom);
115
- }
116
- }
117
- optionsParser(options) {
118
- let easing = TWEEN.Easing.Quartic.InOut;
119
- if (typeof options.easing === "string") {
120
- const keys = options.easing.split(".");
121
- const easingFamily = TWEEN.Easing[keys[0]];
122
- if (easingFamily) {
123
- const easingFunction = easingFamily[keys[1]];
124
- if (easingFunction)
125
- easing = easingFunction;
126
- }
127
- }
128
- else if (typeof options.easing === "function") {
129
- easing = options.easing;
130
- }
131
- let interpolation = TWEEN.Interpolation.CatmullRom;
132
- if (typeof options.interpolation === "string") {
133
- const interpolationFunction = TWEEN.Interpolation[options.interpolation];
134
- if (interpolationFunction &&
135
- interpolationFunction !== TWEEN.Interpolation.Utils)
136
- interpolation = (interpolationFunction);
137
- }
138
- else if (typeof options.interpolation === "function") {
139
- interpolation = (options.interpolation);
140
- }
141
- return {
142
- duration: options.duration && options.duration >= 0
143
- ? options.duration
144
- : 0,
145
- easing,
146
- coordinates: options.coordinates !== "spherical" &&
147
- options.coordinates !== "linear" &&
148
- options.coordinates !== "cylindrical"
149
- ? "cylindrical"
150
- : options.coordinates,
151
- interpolation,
152
- };
153
- }
154
- }
155
- exports.CameraInterpolationManager = CameraInterpolationManager;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.CameraInterpolationManager = void 0;
37
+ const TWEEN = __importStar(require("@tweenjs/tween.js"));
38
+ const CameraCylindricalInterpolation_1 = require("./interpolationMethods/CameraCylindricalInterpolation");
39
+ const CameraLinearInterpolation_1 = require("./interpolationMethods/CameraLinearInterpolation");
40
+ const CameraMultipleInterpolation_1 = require("./interpolationMethods/CameraMultipleInterpolation");
41
+ const CameraSphericalInterpolation_1 = require("./interpolationMethods/CameraSphericalInterpolation");
42
+ class CameraInterpolationManager {
43
+ // #endregion Properties (2)
44
+ // #region Constructors (1)
45
+ constructor(_camera, _cameraControls) {
46
+ this._camera = _camera;
47
+ this._cameraControls = _cameraControls;
48
+ // #region Properties (2)
49
+ this.TweenWrapper = class {
50
+ constructor(options, cb, onComplete) {
51
+ this._properties = { delta: 0 };
52
+ this._tween = new TWEEN.Tween(this._properties);
53
+ this._tween.easing(options.easing);
54
+ this._tween.to({ delta: 1.0 }, options.duration);
55
+ this._tween.onUpdate((v) => {
56
+ cb.onUpdate(v);
57
+ });
58
+ this._tween.onStop((v) => {
59
+ if (cb.onStop)
60
+ cb.onStop(v);
61
+ this._resolve(true);
62
+ });
63
+ this._tween.onComplete((v) => {
64
+ if (cb.onComplete)
65
+ cb.onComplete(v);
66
+ onComplete();
67
+ this._resolve(true);
68
+ });
69
+ }
70
+ start() {
71
+ return new Promise((resolve) => {
72
+ this._resolve = resolve;
73
+ this._tween.start();
74
+ });
75
+ }
76
+ stop() {
77
+ this._tween.stop();
78
+ }
79
+ };
80
+ }
81
+ // #endregion Constructors (1)
82
+ // #region Public Methods (3)
83
+ active() {
84
+ return this._tween ? true : false;
85
+ }
86
+ /**
87
+ * cameraTween
88
+ */
89
+ interpolate(path, options = {}) {
90
+ const newPath = [];
91
+ for (let i = 0; i < path.length; i++)
92
+ newPath.push({
93
+ position: path[i].position,
94
+ target: path[i].target,
95
+ });
96
+ if (this._tween) {
97
+ this._tween.stop();
98
+ this._tween = null;
99
+ }
100
+ const parsedOptions = this.optionsParser(options);
101
+ this._tween = new this.TweenWrapper(parsedOptions, newPath.length === 2
102
+ ? this.getCameraInterpolation(newPath[0], newPath[1], parsedOptions.coordinates)
103
+ : new CameraMultipleInterpolation_1.CameraMultipleInterpolation(this._camera, this._cameraControls, newPath, parsedOptions.interpolation), () => {
104
+ this._tween = null;
105
+ });
106
+ return this._tween.start();
107
+ }
108
+ stop() {
109
+ if (this._tween)
110
+ this._tween.stop();
111
+ this._tween = null;
112
+ }
113
+ // #endregion Public Methods (3)
114
+ // #region Private Methods (2)
115
+ getCameraInterpolation(from, to, type) {
116
+ switch (type) {
117
+ case "linear":
118
+ return new CameraLinearInterpolation_1.CameraLinearInterpolation(this._camera, this._cameraControls, from, to);
119
+ case "spherical":
120
+ return new CameraSphericalInterpolation_1.CameraSphericalInterpolation(this._camera, this._cameraControls, from, to);
121
+ case "cylindrical":
122
+ return new CameraCylindricalInterpolation_1.CameraCylindricalInterpolation(this._camera, this._cameraControls, from, to);
123
+ default:
124
+ return new CameraMultipleInterpolation_1.CameraMultipleInterpolation(this._camera, this._cameraControls, [from, to], TWEEN.Interpolation.CatmullRom);
125
+ }
126
+ }
127
+ optionsParser(options) {
128
+ let easing = TWEEN.Easing.Quartic.InOut;
129
+ if (typeof options.easing === "string") {
130
+ const keys = options.easing.split(".");
131
+ const easingFamily = TWEEN.Easing[keys[0]];
132
+ if (easingFamily) {
133
+ const easingFunction = easingFamily[keys[1]];
134
+ if (easingFunction)
135
+ easing = easingFunction;
136
+ }
137
+ }
138
+ else if (typeof options.easing === "function") {
139
+ easing = options.easing;
140
+ }
141
+ let interpolation = TWEEN.Interpolation.CatmullRom;
142
+ if (typeof options.interpolation === "string") {
143
+ const interpolationFunction = TWEEN.Interpolation[options.interpolation];
144
+ if (interpolationFunction &&
145
+ interpolationFunction !== TWEEN.Interpolation.Utils)
146
+ interpolation = (interpolationFunction);
147
+ }
148
+ else if (typeof options.interpolation === "function") {
149
+ interpolation = (options.interpolation);
150
+ }
151
+ return {
152
+ duration: options.duration && options.duration >= 0
153
+ ? options.duration
154
+ : 0,
155
+ easing,
156
+ coordinates: options.coordinates !== "spherical" &&
157
+ options.coordinates !== "linear" &&
158
+ options.coordinates !== "cylindrical"
159
+ ? "cylindrical"
160
+ : options.coordinates,
161
+ interpolation,
162
+ };
163
+ }
164
+ }
165
+ exports.CameraInterpolationManager = CameraInterpolationManager;
156
166
  //# sourceMappingURL=CameraInterpolationManager.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CameraInterpolationManager.js","sourceRoot":"","sources":["../../../src/implementation/interpolation/CameraInterpolationManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AAK3C,0GAAqG;AACrG,gGAA2F;AAC3F,oGAA+F;AAC/F,sGAAiG;AAEjG,MAAa,0BAA0B;IAkDtC,4BAA4B;IAE5B,2BAA2B;IAE3B,YACkB,OAAgB,EAChB,eAAgC;QADhC,YAAO,GAAP,OAAO,CAAS;QAChB,oBAAe,GAAf,e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ACjB,MAAM,cAAc,GACnB,YAAY,CAA4B,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClD,IAAI,cAAc;oBAAE,MAAM,GAAG,cAAc,CAAC;aAC5C;SACD;aAAM,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;YAChD,MAAM,GAA+B,OAAO,CAAC,MAAM,CAAC;SACpD;QAED,IAAI,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC;QACnD,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,QAAQ,EAAE;YAC9C,MAAM,qBAAqB,GAC1B,KAAK,CAAC,aAAa,CACgB,OAAO,CAAC,aAAa,CACvD,CAAC;YACH,IACC,qBAAqB;gBACrB,qBAAqB,KAAK,KAAK,CAAC,aAAa,CAAC,KAAK;gBAEnD,aAAa,GAAuC,CACnD,qBAAqB,CACrB,CAAC;SACH;aAAM,IAAI,OAAO,OAAO,CAAC,aAAa,KAAK,UAAU,EAAE;YACvD,aAAa,GAAuC,CACnD,OAAO,CAAC,aAAa,CACrB,CAAC;SACF;QAED,OAAO;YACN,QAAQ,EACP,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,QAAQ,IAAI,CAAC;gBACxC,CAAC,CAAC,OAAO,CAAC,QAAQ;gBAClB,CAAC,CAAC,CAAC;YACL,MAAM;YACN,WAAW,EACV,OAAO,CAAC,WAAW,KAAK,WAAW;gBACnC,OAAO,CAAC,WAAW,KAAK,QAAQ;gBAChC,OAAO,CAAC,WAAW,KAAK,aAAa;gBACpC,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,OAAO,CAAC,WAAW;YACvB,aAAa;SACb,CAAC;IACH,CAAC;CAGD;AAlND,gEAkNC"}
1
+ {"version":3,"file":"CameraInterpolationManager.js","sourceRoot":"","sources":["../../../src/implementation/interpolation/CameraInterpolationManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,yDAA2C;AAK3C,0G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ACpC,CAAC,CAAC,aAAa;gBACf,CAAC,CAAC,OAAO,CAAC,WAAW;YACvB,aAAa;SACb,CAAC;IACH,CAAC;CAGD;AAlND,gEAkNC"}
@@ -1,37 +1,37 @@
1
- import { vec3 } from "gl-matrix";
2
- import { ICamera } from "../../../interfaces/camera/ICamera";
3
- import { ICameraControls } from "../../../interfaces/controls/ICameraControls";
4
- import { ICameraInterpolation } from "../../../interfaces/interpolation/ICameraInterpolation";
5
- export declare class CameraCylindricalInterpolation implements ICameraInterpolation {
6
- private readonly _camera;
7
- private readonly _cameraControls;
8
- private readonly _from;
9
- private readonly _to;
10
- private _dir_from;
11
- private _dir_to;
12
- private _from_position_heightAdjusted;
13
- private _h_from;
14
- private _h_to;
15
- private _lorr;
16
- private _r_from;
17
- private _r_to;
18
- private _shortest_angle;
19
- private _to_position_heightAdjusted;
20
- constructor(_camera: ICamera, _cameraControls: ICameraControls, _from: {
21
- position: vec3;
22
- target: vec3;
23
- }, _to: {
24
- position: vec3;
25
- target: vec3;
26
- });
27
- onComplete(value: {
28
- delta: number;
29
- }): void;
30
- onStop(value: {
31
- delta: number;
32
- }): void;
33
- onUpdate(value: {
34
- delta: number;
35
- }): void;
36
- }
1
+ import { vec3 } from "gl-matrix";
2
+ import { ICamera } from "../../../interfaces/camera/ICamera";
3
+ import { ICameraControls } from "../../../interfaces/controls/ICameraControls";
4
+ import { ICameraInterpolation } from "../../../interfaces/interpolation/ICameraInterpolation";
5
+ export declare class CameraCylindricalInterpolation implements ICameraInterpolation {
6
+ private readonly _camera;
7
+ private readonly _cameraControls;
8
+ private readonly _from;
9
+ private readonly _to;
10
+ private _dir_from;
11
+ private _dir_to;
12
+ private _from_position_heightAdjusted;
13
+ private _h_from;
14
+ private _h_to;
15
+ private _lorr;
16
+ private _r_from;
17
+ private _r_to;
18
+ private _shortest_angle;
19
+ private _to_position_heightAdjusted;
20
+ constructor(_camera: ICamera, _cameraControls: ICameraControls, _from: {
21
+ position: vec3;
22
+ target: vec3;
23
+ }, _to: {
24
+ position: vec3;
25
+ target: vec3;
26
+ });
27
+ onComplete(value: {
28
+ delta: number;
29
+ }): void;
30
+ onStop(value: {
31
+ delta: number;
32
+ }): void;
33
+ onUpdate(value: {
34
+ delta: number;
35
+ }): void;
36
+ }
37
37
  //# sourceMappingURL=CameraCylindricalInterpolation.d.ts.map
@@ -1,58 +1,58 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CameraCylindricalInterpolation = void 0;
4
- const gl_matrix_1 = require("gl-matrix");
5
- class CameraCylindricalInterpolation {
6
- // #endregion Properties (10)
7
- // #region Constructors (1)
8
- constructor(_camera, _cameraControls, _from, _to) {
9
- this._camera = _camera;
10
- this._cameraControls = _cameraControls;
11
- this._from = _from;
12
- this._to = _to;
13
- this._h_from = this._from.position[2] - this._from.target[2];
14
- this._from_position_heightAdjusted = gl_matrix_1.vec3.fromValues(this._from.position[0], this._from.position[1], this._from.target[2]);
15
- this._r_from = gl_matrix_1.vec3.distance(this._from_position_heightAdjusted, this._from.target);
16
- this._dir_from = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), this._from_position_heightAdjusted, this._from.target));
17
- this._h_to = this._to.position[2] - this._to.target[2];
18
- this._to_position_heightAdjusted = gl_matrix_1.vec3.fromValues(this._to.position[0], this._to.position[1], this._to.target[2]);
19
- this._r_to = gl_matrix_1.vec3.distance(this._to_position_heightAdjusted, this._to.target);
20
- this._dir_to = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), this._to_position_heightAdjusted, this._to.target));
21
- if (this._dir_from[0] === 0 &&
22
- this._dir_from[1] === 0 &&
23
- this._dir_from[2] === 0)
24
- this._dir_from = gl_matrix_1.vec3.fromValues(1, 0, 0);
25
- if (this._dir_to[0] === 0 &&
26
- this._dir_to[1] === 0 &&
27
- this._dir_to[2] === 0)
28
- this._dir_to = gl_matrix_1.vec3.fromValues(1, 0, 0);
29
- this._lorr = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), this._dir_to, this._dir_from);
30
- // This is why people hate JavaScript. The dot product of two normalized vector is larger than 1 on occasion due to precision errors...
31
- const dot1 = Math.min(1, Math.max(-1, gl_matrix_1.vec3.dot(this._dir_to, this._dir_from)));
32
- const dot2 = Math.min(1, Math.max(-1, gl_matrix_1.vec3.dot(this._lorr, gl_matrix_1.vec3.fromValues(0, 0, 1))));
33
- this._shortest_angle = dot2 > 0 ? -Math.acos(dot1) : Math.acos(dot1);
34
- }
35
- // #endregion Constructors (1)
36
- // #region Public Methods (3)
37
- onComplete(value) {
38
- const positionOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.fromValues(this._to.position[0], this._to.position[1], this._to.position[2]), this._cameraControls.getPositionWithUpdates());
39
- this._cameraControls.applyPositionVector(positionOffset);
40
- const targetOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.fromValues(this._to.target[0], this._to.target[1], this._to.target[2]), this._cameraControls.getTargetWithUpdates());
41
- this._cameraControls.applyTargetVector(targetOffset);
42
- }
43
- onStop(value) { }
44
- onUpdate(value) {
45
- const t = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), this._from.target, gl_matrix_1.vec3.fromValues(1 - value.delta, 1 - value.delta, 1 - value.delta)), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), this._to.target, gl_matrix_1.vec3.fromValues(value.delta, value.delta, value.delta)));
46
- const targetOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), t, this._cameraControls.getTargetWithUpdates());
47
- this._cameraControls.applyTargetVector(targetOffset);
48
- const angle = this._shortest_angle * value.delta;
49
- const dir = gl_matrix_1.vec3.transformQuat(gl_matrix_1.vec3.create(), this._dir_from, gl_matrix_1.quat.setAxisAngle(gl_matrix_1.quat.create(), gl_matrix_1.vec3.fromValues(0, 0, 1), angle));
50
- const scalar = this._r_from * (1 - value.delta) + this._r_to * value.delta;
51
- const p = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), t, gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), dir, gl_matrix_1.vec3.fromValues(scalar, scalar, scalar)));
52
- gl_matrix_1.vec3.add(p, p, gl_matrix_1.vec3.fromValues(0, 0, this._h_from * (1 - value.delta) + this._h_to * value.delta));
53
- const positionOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), p, this._cameraControls.getPositionWithUpdates());
54
- this._cameraControls.applyPositionVector(positionOffset);
55
- }
56
- }
57
- exports.CameraCylindricalInterpolation = CameraCylindricalInterpolation;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CameraCylindricalInterpolation = void 0;
4
+ const gl_matrix_1 = require("gl-matrix");
5
+ class CameraCylindricalInterpolation {
6
+ // #endregion Properties (10)
7
+ // #region Constructors (1)
8
+ constructor(_camera, _cameraControls, _from, _to) {
9
+ this._camera = _camera;
10
+ this._cameraControls = _cameraControls;
11
+ this._from = _from;
12
+ this._to = _to;
13
+ this._h_from = this._from.position[2] - this._from.target[2];
14
+ this._from_position_heightAdjusted = gl_matrix_1.vec3.fromValues(this._from.position[0], this._from.position[1], this._from.target[2]);
15
+ this._r_from = gl_matrix_1.vec3.distance(this._from_position_heightAdjusted, this._from.target);
16
+ this._dir_from = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), this._from_position_heightAdjusted, this._from.target));
17
+ this._h_to = this._to.position[2] - this._to.target[2];
18
+ this._to_position_heightAdjusted = gl_matrix_1.vec3.fromValues(this._to.position[0], this._to.position[1], this._to.target[2]);
19
+ this._r_to = gl_matrix_1.vec3.distance(this._to_position_heightAdjusted, this._to.target);
20
+ this._dir_to = gl_matrix_1.vec3.normalize(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), this._to_position_heightAdjusted, this._to.target));
21
+ if (this._dir_from[0] === 0 &&
22
+ this._dir_from[1] === 0 &&
23
+ this._dir_from[2] === 0)
24
+ this._dir_from = gl_matrix_1.vec3.fromValues(1, 0, 0);
25
+ if (this._dir_to[0] === 0 &&
26
+ this._dir_to[1] === 0 &&
27
+ this._dir_to[2] === 0)
28
+ this._dir_to = gl_matrix_1.vec3.fromValues(1, 0, 0);
29
+ this._lorr = gl_matrix_1.vec3.cross(gl_matrix_1.vec3.create(), this._dir_to, this._dir_from);
30
+ // This is why people hate JavaScript. The dot product of two normalized vector is larger than 1 on occasion due to precision errors...
31
+ const dot1 = Math.min(1, Math.max(-1, gl_matrix_1.vec3.dot(this._dir_to, this._dir_from)));
32
+ const dot2 = Math.min(1, Math.max(-1, gl_matrix_1.vec3.dot(this._lorr, gl_matrix_1.vec3.fromValues(0, 0, 1))));
33
+ this._shortest_angle = dot2 > 0 ? -Math.acos(dot1) : Math.acos(dot1);
34
+ }
35
+ // #endregion Constructors (1)
36
+ // #region Public Methods (3)
37
+ onComplete(value) {
38
+ const positionOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.fromValues(this._to.position[0], this._to.position[1], this._to.position[2]), this._cameraControls.getPositionWithUpdates());
39
+ this._cameraControls.applyPositionVector(positionOffset);
40
+ const targetOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.fromValues(this._to.target[0], this._to.target[1], this._to.target[2]), this._cameraControls.getTargetWithUpdates());
41
+ this._cameraControls.applyTargetVector(targetOffset);
42
+ }
43
+ onStop(value) { }
44
+ onUpdate(value) {
45
+ const t = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), this._from.target, gl_matrix_1.vec3.fromValues(1 - value.delta, 1 - value.delta, 1 - value.delta)), gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), this._to.target, gl_matrix_1.vec3.fromValues(value.delta, value.delta, value.delta)));
46
+ const targetOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), t, this._cameraControls.getTargetWithUpdates());
47
+ this._cameraControls.applyTargetVector(targetOffset);
48
+ const angle = this._shortest_angle * value.delta;
49
+ const dir = gl_matrix_1.vec3.transformQuat(gl_matrix_1.vec3.create(), this._dir_from, gl_matrix_1.quat.setAxisAngle(gl_matrix_1.quat.create(), gl_matrix_1.vec3.fromValues(0, 0, 1), angle));
50
+ const scalar = this._r_from * (1 - value.delta) + this._r_to * value.delta;
51
+ const p = gl_matrix_1.vec3.add(gl_matrix_1.vec3.create(), t, gl_matrix_1.vec3.multiply(gl_matrix_1.vec3.create(), dir, gl_matrix_1.vec3.fromValues(scalar, scalar, scalar)));
52
+ gl_matrix_1.vec3.add(p, p, gl_matrix_1.vec3.fromValues(0, 0, this._h_from * (1 - value.delta) + this._h_to * value.delta));
53
+ const positionOffset = gl_matrix_1.vec3.subtract(gl_matrix_1.vec3.create(), p, this._cameraControls.getPositionWithUpdates());
54
+ this._cameraControls.applyPositionVector(positionOffset);
55
+ }
56
+ }
57
+ exports.CameraCylindricalInterpolation = CameraCylindricalInterpolation;
58
58
  //# sourceMappingURL=CameraCylindricalInterpolation.js.map
@@ -1,27 +1,27 @@
1
- import { vec3 } from "gl-matrix";
2
- import { ICamera } from "../../../interfaces/camera/ICamera";
3
- import { ICameraControls } from "../../../interfaces/controls/ICameraControls";
4
- import { ICameraInterpolation } from "../../../interfaces/interpolation/ICameraInterpolation";
5
- export declare class CameraLinearInterpolation implements ICameraInterpolation {
6
- private readonly _camera;
7
- private readonly _cameraControls;
8
- private readonly _from;
9
- private readonly _to;
10
- constructor(_camera: ICamera, _cameraControls: ICameraControls, _from: {
11
- position: vec3;
12
- target: vec3;
13
- }, _to: {
14
- position: vec3;
15
- target: vec3;
16
- });
17
- onComplete(value: {
18
- delta: number;
19
- }): void;
20
- onStop(value: {
21
- delta: number;
22
- }): void;
23
- onUpdate(value: {
24
- delta: number;
25
- }): void;
26
- }
1
+ import { vec3 } from "gl-matrix";
2
+ import { ICamera } from "../../../interfaces/camera/ICamera";
3
+ import { ICameraControls } from "../../../interfaces/controls/ICameraControls";
4
+ import { ICameraInterpolation } from "../../../interfaces/interpolation/ICameraInterpolation";
5
+ export declare class CameraLinearInterpolation implements ICameraInterpolation {
6
+ private readonly _camera;
7
+ private readonly _cameraControls;
8
+ private readonly _from;
9
+ private readonly _to;
10
+ constructor(_camera: ICamera, _cameraControls: ICameraControls, _from: {
11
+ position: vec3;
12
+ target: vec3;
13
+ }, _to: {
14
+ position: vec3;
15
+ target: vec3;
16
+ });
17
+ onComplete(value: {
18
+ delta: number;
19
+ }): void;
20
+ onStop(value: {
21
+ delta: number;
22
+ }): void;
23
+ onUpdate(value: {
24
+ delta: number;
25
+ }): void;
26
+ }
27
27
  //# sourceMappingURL=CameraLinearInterpolation.d.ts.map