@vived/app 2.29.0 → 2.29.1
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/package.json +1 -1
- package/lib/Core/BaseApp/Boundary.d.ts +0 -49
- package/lib/Core/BaseApp/Boundary.js +0 -2
- package/lib/Core/BaseApp/Entity.d.ts +0 -11
- package/lib/Core/BaseApp/Entity.js +0 -2
- package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.d.ts +0 -3
- package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.js +0 -12
- package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.d.ts +0 -3
- package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.js +0 -10
- package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.d.ts +0 -3
- package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.js +0 -10
- package/lib/Core/BaseApp/Errors/index.d.ts +0 -3
- package/lib/Core/BaseApp/Errors/index.js +0 -15
- package/lib/Core/BaseApp/UseCase.d.ts +0 -43
- package/lib/Core/BaseApp/UseCase.js +0 -250
- package/lib/Core/BaseAppState/Boundary.d.ts +0 -14
- package/lib/Core/BaseAppState/Boundary.js +0 -2
- package/lib/Core/BaseAppState/Entity.d.ts +0 -5
- package/lib/Core/BaseAppState/Entity.js +0 -2
- package/lib/Core/BaseAppState/UseCase.d.ts +0 -16
- package/lib/Core/BaseAppState/UseCase.js +0 -54
- package/lib/Core/BaseAppState/UseCase_Imp.d.ts +0 -16
- package/lib/Core/BaseAppState/UseCase_Imp.js +0 -54
- package/lib/Core/DevicePreview/DevicePreviewUC_Imp.d.ts +0 -16
- package/lib/Core/DevicePreview/DevicePreviewUC_Imp.js +0 -56
- package/lib/Core/DevicePreview/boundary.d.ts +0 -14
- package/lib/Core/DevicePreview/boundary.js +0 -2
- package/lib/Core/DevicePreview/entity.d.ts +0 -5
- package/lib/Core/DevicePreview/entity.js +0 -2
- package/lib/Core/DispatchToHost/Entity.d.ts +0 -4
- package/lib/Core/DispatchToHost/Entity.js +0 -2
- package/lib/Core/DispatchToHost/UseCase.d.ts +0 -12
- package/lib/Core/DispatchToHost/UseCase.js +0 -70
- package/lib/Core/DispatchToHost/boundary.d.ts +0 -9
- package/lib/Core/DispatchToHost/boundary.js +0 -2
- package/lib/Core/Serilization/Boundary.d.ts +0 -20
- package/lib/Core/Serilization/Boundary.js +0 -2
- package/lib/Core/Serilization/Entity.d.ts +0 -3
- package/lib/Core/Serilization/Entity.js +0 -2
- package/lib/Core/Serilization/ErrorDuplicateSystemName.d.ts +0 -3
- package/lib/Core/Serilization/ErrorDuplicateSystemName.js +0 -12
- package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.d.ts +0 -3
- package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.js +0 -10
- package/lib/Core/Serilization/Errors.d.ts +0 -6
- package/lib/Core/Serilization/Errors.js +0 -19
- package/lib/Core/Serilization/UseCase.d.ts +0 -10
- package/lib/Core/Serilization/UseCase.js +0 -52
- package/lib/Core/Serilization/UseCase_Imp.d.ts +0 -10
- package/lib/Core/Serilization/UseCase_Imp.js +0 -51
- package/lib/Core/index.d.ts +0 -3
- package/lib/Core/index.js +0 -19
- package/lib/Entities/Color.d.ts +0 -20
- package/lib/Entities/Color.js +0 -59
- package/lib/Entities/FocusCamera.d.ts +0 -70
- package/lib/Entities/FocusCamera.js +0 -272
- package/lib/Entities/LineSegment2D.d.ts +0 -11
- package/lib/Entities/LineSegment2D.js +0 -70
- package/lib/Entities/MouseSceneInput.d.ts +0 -15
- package/lib/Entities/MouseSceneInput.js +0 -109
- package/lib/Entities/OrbitCamera.d.ts +0 -76
- package/lib/Entities/OrbitCamera.js +0 -243
- package/lib/Entities/ParametricLine.d.ts +0 -29
- package/lib/Entities/ParametricLine.js +0 -79
- package/lib/Entities/ParametricPlane.d.ts +0 -20
- package/lib/Entities/ParametricPlane.js +0 -63
- package/lib/Entities/Vector2.d.ts +0 -21
- package/lib/Entities/Vector2.js +0 -83
- package/lib/Entities/Vector3.d.ts +0 -19
- package/lib/Entities/Vector3.js +0 -75
- package/lib/Interface/Controllers/appHandler.d.ts +0 -12
- package/lib/Interface/Controllers/appHandler.js +0 -94
- package/lib/Interface/Controllers/defaultAppHanlderFunctions.d.ts +0 -3
- package/lib/Interface/Controllers/defaultAppHanlderFunctions.js +0 -31
- package/lib/Interface/Controllers/dispatchStateChange.d.ts +0 -2
- package/lib/Interface/Controllers/dispatchStateChange.js +0 -10
- package/lib/Interface/Controllers/index.d.ts +0 -9
- package/lib/Interface/Controllers/index.js +0 -21
- package/lib/Interface/Controllers/makeAppHandler.d.ts +0 -12
- package/lib/Interface/Controllers/makeAppHandler.js +0 -96
- package/lib/Interface/Controllers/setDevicePreview.d.ts +0 -2
- package/lib/Interface/Controllers/setDevicePreview.js +0 -14
- package/lib/Interface/Controllers/setIsAuthoring.d.ts +0 -2
- package/lib/Interface/Controllers/setIsAuthoring.js +0 -14
- package/lib/Interface/Controllers/setState.d.ts +0 -2
- package/lib/Interface/Controllers/setState.js +0 -21
- package/lib/Interface/Controllers/showBabylonInspector.d.ts +0 -2
- package/lib/Interface/Controllers/showBabylonInspector.js +0 -9
- package/lib/Interface/Controllers/startApp.d.ts +0 -1
- package/lib/Interface/Controllers/startApp.js +0 -9
- package/lib/Interface/Controllers/stopApp.d.ts +0 -2
- package/lib/Interface/Controllers/stopApp.js +0 -10
- package/lib/Interface/PresentationManagers/DevicePreviewPM.d.ts +0 -13
- package/lib/Interface/PresentationManagers/DevicePreviewPM.js +0 -25
- package/lib/Interface/PresentationManagers/IsAuthoringPM.d.ts +0 -10
- package/lib/Interface/PresentationManagers/IsAuthoringPM.js +0 -23
- package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.d.ts +0 -10
- package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.js +0 -23
- package/lib/Interface/PresentationManagers/index.d.ts +0 -3
- package/lib/Interface/PresentationManagers/index.js +0 -15
- package/lib/Interface/appHandler.d.ts +0 -12
- package/lib/Interface/appHandler.js +0 -94
- package/lib/Interface/index.d.ts +0 -2
- package/lib/Interface/index.js +0 -14
- package/lib/PresentationManagers/FocusCameraPM.d.ts +0 -15
- package/lib/PresentationManagers/FocusCameraPM.js +0 -31
- package/lib/PresentationManagers/FocusCameraPosRotPM.d.ts +0 -13
- package/lib/PresentationManagers/FocusCameraPosRotPM.js +0 -28
- package/lib/PresentationManagers/HoverLabelPM.d.ts +0 -17
- package/lib/PresentationManagers/HoverLabelPM.js +0 -32
- package/lib/PresentationManagers/OrbitCameraPM.d.ts +0 -14
- package/lib/PresentationManagers/OrbitCameraPM.js +0 -31
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +0 -17
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +0 -64
- package/lib/UseCases/FocusCamera/LerpFocusCamera.d.ts +0 -36
- package/lib/UseCases/FocusCamera/LerpFocusCamera.js +0 -71
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +0 -36
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +0 -36
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +0 -26
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +0 -33
- package/lib/UseCases/FocusCamera/SerializeFocusCamera.d.ts +0 -22
- package/lib/UseCases/FocusCamera/SerializeFocusCamera.js +0 -81
- package/lib/UseCases/FocusCamera/index.d.ts +0 -7
- package/lib/UseCases/FocusCamera/index.js +0 -19
- package/lib/UseCases/LerpOrbitCamera.d.ts +0 -36
- package/lib/UseCases/LerpOrbitCamera.js +0 -71
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +0 -36
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +0 -71
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +0 -9
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +0 -31
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +0 -10
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +0 -31
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +0 -22
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +0 -81
- package/lib/UseCases/OrbitCamera/index.d.ts +0 -4
- package/lib/UseCases/OrbitCamera/index.js +0 -16
- package/lib/UseCases/SerializeCamera.d.ts +0 -21
- package/lib/UseCases/SerializeCamera.js +0 -59
- package/lib/UseCases/SerializeOrbitCamera.d.ts +0 -21
- package/lib/UseCases/SerializeOrbitCamera.js +0 -59
- package/lib/UseCases/SerializedCamDemo.d.ts +0 -0
- package/lib/UseCases/SerializedCamDemo.js +0 -1
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeFocusCamera = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
const ValueObjects_1 = require("../ValueObjects");
|
|
6
|
-
function makeFocusCamera() {
|
|
7
|
-
return new FocusCameraImp();
|
|
8
|
-
}
|
|
9
|
-
exports.makeFocusCamera = makeFocusCamera;
|
|
10
|
-
class FocusCameraImp {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.farClip = 100;
|
|
13
|
-
this.nearClip = 0.01;
|
|
14
|
-
this.defaultAlpha = 0;
|
|
15
|
-
this.defaultBeta = 30;
|
|
16
|
-
this.defaultRadius = 8;
|
|
17
|
-
this.defaultTarget = ValueObjects_1.Vector3.Zero();
|
|
18
|
-
this.limitRadius = false;
|
|
19
|
-
this.minRadius = 0;
|
|
20
|
-
this.maxRadius = 0;
|
|
21
|
-
this.limitAlpha = false;
|
|
22
|
-
this.minAlpha = 0;
|
|
23
|
-
this.maxAlpha = 0;
|
|
24
|
-
this.limitBeta = false;
|
|
25
|
-
this.minBeta = 0;
|
|
26
|
-
this.maxBeta = 0;
|
|
27
|
-
this.limitTarget = false;
|
|
28
|
-
this.maxTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
29
|
-
this.minTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
30
|
-
this.observers = new _1.ObserverList();
|
|
31
|
-
this.memoizedAlpha = new _1.MemoizedNumber(0, this.observers.notify);
|
|
32
|
-
this.memoizedBeta = new _1.MemoizedNumber(0, this.observers.notify);
|
|
33
|
-
this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
|
|
34
|
-
this.memoizedTarget = new _1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.observers.notify);
|
|
35
|
-
this.setRadiusLimits = (min, max) => {
|
|
36
|
-
let minToUse = min;
|
|
37
|
-
let maxToUse = max;
|
|
38
|
-
if (min < 0) {
|
|
39
|
-
console.warn("[Orbit Camera Entity] Mininum Radius must be greater >= 0, forcing to 0");
|
|
40
|
-
minToUse = 0;
|
|
41
|
-
}
|
|
42
|
-
if (max < minToUse) {
|
|
43
|
-
console.warn(`[Orbit Camera] Max radius must be >= min radius. Forcing to ${minToUse}`);
|
|
44
|
-
maxToUse = minToUse;
|
|
45
|
-
}
|
|
46
|
-
this.maxRadius = maxToUse;
|
|
47
|
-
this.minRadius = minToUse;
|
|
48
|
-
this.limitRadius = true;
|
|
49
|
-
this.radius = this.radius;
|
|
50
|
-
};
|
|
51
|
-
this.clearRadiusLimits = () => {
|
|
52
|
-
this.maxRadius = 0;
|
|
53
|
-
this.minRadius = 0;
|
|
54
|
-
this.limitRadius = false;
|
|
55
|
-
};
|
|
56
|
-
this.setAlphaLimits = (min, max) => {
|
|
57
|
-
let minToUse = min;
|
|
58
|
-
let maxToUse = max;
|
|
59
|
-
if (min < -180) {
|
|
60
|
-
minToUse = -180;
|
|
61
|
-
console.warn("[Orbit Camera] Min alpha must be >= -180. Forcing to -180");
|
|
62
|
-
}
|
|
63
|
-
if (max > 180) {
|
|
64
|
-
maxToUse = 180;
|
|
65
|
-
console.warn("[Orbit Camera] Max alpha must be <= 180. Forcing to 180");
|
|
66
|
-
}
|
|
67
|
-
if (minToUse > maxToUse) {
|
|
68
|
-
const absMin = Math.abs(minToUse);
|
|
69
|
-
const absMax = Math.abs(maxToUse);
|
|
70
|
-
const closestToZero = absMin < absMax ? minToUse : maxToUse;
|
|
71
|
-
minToUse = closestToZero;
|
|
72
|
-
maxToUse = closestToZero;
|
|
73
|
-
console.warn(`[Orbit Camera] Max alpha must be <= Min Alpha. Forcing to ${closestToZero}`);
|
|
74
|
-
}
|
|
75
|
-
this.maxAlpha = maxToUse;
|
|
76
|
-
this.minAlpha = minToUse;
|
|
77
|
-
this.limitAlpha = true;
|
|
78
|
-
this.alpha = this.alpha;
|
|
79
|
-
};
|
|
80
|
-
this.clearAlphaLimits = () => {
|
|
81
|
-
this.maxAlpha = 0;
|
|
82
|
-
this.minAlpha = 0;
|
|
83
|
-
this.limitAlpha = false;
|
|
84
|
-
};
|
|
85
|
-
this.setBetaLimits = (min, max) => {
|
|
86
|
-
let minToUse = min;
|
|
87
|
-
let maxToUse = max;
|
|
88
|
-
if (min < -180) {
|
|
89
|
-
minToUse = -180;
|
|
90
|
-
console.warn("[Orbit Camera] Min beta must be >= -180. Forcing to -180");
|
|
91
|
-
}
|
|
92
|
-
if (max > 180) {
|
|
93
|
-
maxToUse = 180;
|
|
94
|
-
console.warn("[Orbit Camera] Max beta must be <= 180. Forcing to 180");
|
|
95
|
-
}
|
|
96
|
-
if (minToUse > maxToUse) {
|
|
97
|
-
const absMin = Math.abs(minToUse);
|
|
98
|
-
const absMax = Math.abs(maxToUse);
|
|
99
|
-
const closestToZero = absMin < absMax ? minToUse : maxToUse;
|
|
100
|
-
minToUse = closestToZero;
|
|
101
|
-
maxToUse = closestToZero;
|
|
102
|
-
console.warn(`[Orbit Camera] Max beta must be <= Min beta. Forcing to ${closestToZero}`);
|
|
103
|
-
}
|
|
104
|
-
this.maxBeta = maxToUse;
|
|
105
|
-
this.minBeta = minToUse;
|
|
106
|
-
this.limitBeta = true;
|
|
107
|
-
this.beta = this.beta;
|
|
108
|
-
};
|
|
109
|
-
this.clearBetaLimits = () => {
|
|
110
|
-
this.maxBeta = 0;
|
|
111
|
-
this.minBeta = 0;
|
|
112
|
-
this.limitBeta = false;
|
|
113
|
-
};
|
|
114
|
-
this.setTargetLimits = (min, max) => {
|
|
115
|
-
const minArray = min.array;
|
|
116
|
-
const maxArray = max.array;
|
|
117
|
-
for (let i = 0; i < 3; i++) {
|
|
118
|
-
if (minArray[i] > maxArray[i]) {
|
|
119
|
-
console.warn("[Orbit Camera] Target limit min's components must all be <= the max. Limits not set");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
this.maxTargetPosition = max;
|
|
124
|
-
this.minTargetPosition = min;
|
|
125
|
-
this.limitTarget = true;
|
|
126
|
-
this.target = this.target;
|
|
127
|
-
};
|
|
128
|
-
this.clearTargetLimits = () => {
|
|
129
|
-
this.maxTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
130
|
-
this.minTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
131
|
-
this.limitTarget = false;
|
|
132
|
-
};
|
|
133
|
-
this.registerLerp = (lerper) => {
|
|
134
|
-
if (this.currentLerp) {
|
|
135
|
-
this.currentLerp.cancelLerp();
|
|
136
|
-
}
|
|
137
|
-
this.currentLerp = lerper;
|
|
138
|
-
};
|
|
139
|
-
this.lerpCompleted = () => {
|
|
140
|
-
this.currentLerp = undefined;
|
|
141
|
-
};
|
|
142
|
-
this.cancelLerp = () => {
|
|
143
|
-
var _a;
|
|
144
|
-
(_a = this.currentLerp) === null || _a === void 0 ? void 0 : _a.cancelLerp();
|
|
145
|
-
this.currentLerp = undefined;
|
|
146
|
-
};
|
|
147
|
-
this.applyData = (data) => {
|
|
148
|
-
if (data.defaultAlpha !== undefined) {
|
|
149
|
-
this.defaultAlpha = data.defaultAlpha;
|
|
150
|
-
}
|
|
151
|
-
if (data.defaultBeta !== undefined) {
|
|
152
|
-
this.defaultBeta = data.defaultBeta;
|
|
153
|
-
}
|
|
154
|
-
if (data.defaultRadius !== undefined) {
|
|
155
|
-
this.defaultRadius = data.defaultRadius;
|
|
156
|
-
}
|
|
157
|
-
if (data.defaultTarget !== undefined) {
|
|
158
|
-
const { x, y, z } = data.defaultTarget;
|
|
159
|
-
this.defaultTarget = new ValueObjects_1.Vector3(x, y, z);
|
|
160
|
-
}
|
|
161
|
-
if (data.nearClip !== undefined) {
|
|
162
|
-
this.nearClip = data.nearClip;
|
|
163
|
-
}
|
|
164
|
-
if (data.farClip !== undefined) {
|
|
165
|
-
this.farClip = data.farClip;
|
|
166
|
-
}
|
|
167
|
-
if (data.alphaLimit !== undefined) {
|
|
168
|
-
this.setAlphaLimits(data.alphaLimit.min, data.alphaLimit.max);
|
|
169
|
-
}
|
|
170
|
-
if (data.betaLimit !== undefined) {
|
|
171
|
-
this.setBetaLimits(data.betaLimit.min, data.betaLimit.max);
|
|
172
|
-
}
|
|
173
|
-
if (data.radiusLimit !== undefined) {
|
|
174
|
-
this.setRadiusLimits(data.radiusLimit.min, data.radiusLimit.max);
|
|
175
|
-
}
|
|
176
|
-
if (data.targetLimit !== undefined) {
|
|
177
|
-
const { max, min } = data.targetLimit;
|
|
178
|
-
this.setTargetLimits(new ValueObjects_1.Vector3(min.x, min.y, min.z), new ValueObjects_1.Vector3(max.x, max.y, max.z));
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
this.addObserver = (observer) => {
|
|
182
|
-
this.observers.add(observer);
|
|
183
|
-
};
|
|
184
|
-
this.removeObserver = (observer) => {
|
|
185
|
-
this.observers.remove(observer);
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
get alpha() {
|
|
189
|
-
return this.memoizedAlpha.val;
|
|
190
|
-
}
|
|
191
|
-
set alpha(val) {
|
|
192
|
-
let valToUse = val;
|
|
193
|
-
if (this.limitAlpha) {
|
|
194
|
-
valToUse = Math.min(valToUse, this.maxAlpha);
|
|
195
|
-
valToUse = Math.max(valToUse, this.minAlpha);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
valToUse = this.clampAngle(val);
|
|
199
|
-
}
|
|
200
|
-
this.memoizedAlpha.val = valToUse;
|
|
201
|
-
}
|
|
202
|
-
get beta() {
|
|
203
|
-
return this.memoizedBeta.val;
|
|
204
|
-
}
|
|
205
|
-
set beta(val) {
|
|
206
|
-
let valToUse = val;
|
|
207
|
-
if (this.limitBeta) {
|
|
208
|
-
valToUse = Math.min(valToUse, this.maxBeta);
|
|
209
|
-
valToUse = Math.max(valToUse, this.minBeta);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
valToUse = this.clampAngle(val);
|
|
213
|
-
}
|
|
214
|
-
this.memoizedBeta.val = valToUse;
|
|
215
|
-
}
|
|
216
|
-
get radius() {
|
|
217
|
-
return this.memoizedRadius.val;
|
|
218
|
-
}
|
|
219
|
-
set radius(val) {
|
|
220
|
-
let clampedVal = Math.max(val, 0);
|
|
221
|
-
if (this.limitRadius) {
|
|
222
|
-
clampedVal = Math.min(clampedVal, this.maxRadius);
|
|
223
|
-
clampedVal = Math.max(clampedVal, this.minRadius);
|
|
224
|
-
}
|
|
225
|
-
this.memoizedRadius.val = clampedVal;
|
|
226
|
-
}
|
|
227
|
-
get target() {
|
|
228
|
-
return this.memoizedTarget.val;
|
|
229
|
-
}
|
|
230
|
-
set target(val) {
|
|
231
|
-
const targetVals = val.array;
|
|
232
|
-
if (this.limitTarget) {
|
|
233
|
-
const maxVals = this.maxTargetPosition.array;
|
|
234
|
-
const minVals = this.minTargetPosition.array;
|
|
235
|
-
for (let i = 0; i < 3; i++) {
|
|
236
|
-
let v = targetVals[i];
|
|
237
|
-
v = Math.min(v, maxVals[i]);
|
|
238
|
-
v = Math.max(v, minVals[i]);
|
|
239
|
-
targetVals[i] = v;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
this.memoizedTarget.val = ValueObjects_1.Vector3.FromArray(targetVals);
|
|
243
|
-
}
|
|
244
|
-
get direction() {
|
|
245
|
-
const yLength = -Math.sin(this.degToRad(this.beta));
|
|
246
|
-
const horizontalLenght = Math.cos(this.degToRad(this.beta));
|
|
247
|
-
const alphaRadians = this.degToRad(this.alpha);
|
|
248
|
-
const xLength = horizontalLenght * Math.sin(alphaRadians);
|
|
249
|
-
const zLength = horizontalLenght * Math.cos(alphaRadians);
|
|
250
|
-
return new ValueObjects_1.Vector3(xLength, yLength, zLength);
|
|
251
|
-
}
|
|
252
|
-
get cameraPosition() {
|
|
253
|
-
const localOffset = ValueObjects_1.Vector3.NewVectorOfLength(this.direction, -this.radius);
|
|
254
|
-
return ValueObjects_1.Vector3.Add(this.target, localOffset);
|
|
255
|
-
}
|
|
256
|
-
degToRad(degrees) {
|
|
257
|
-
return (degrees * Math.PI) / 180;
|
|
258
|
-
}
|
|
259
|
-
clampAngle(angle) {
|
|
260
|
-
const isNegative = angle < 0 ? true : false;
|
|
261
|
-
const absAngle = Math.abs(angle);
|
|
262
|
-
const revolutions = Math.floor(absAngle / 360);
|
|
263
|
-
let angleWithoutRevolutions = absAngle - revolutions * 360;
|
|
264
|
-
if (angleWithoutRevolutions > 180) {
|
|
265
|
-
angleWithoutRevolutions = angleWithoutRevolutions - 360;
|
|
266
|
-
}
|
|
267
|
-
if (isNegative) {
|
|
268
|
-
angleWithoutRevolutions *= -1;
|
|
269
|
-
}
|
|
270
|
-
return angleWithoutRevolutions;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Vector2 } from "./Vector2";
|
|
2
|
-
export declare class LineSegment2D {
|
|
3
|
-
start: Vector2;
|
|
4
|
-
end: Vector2;
|
|
5
|
-
get length(): number;
|
|
6
|
-
get direction(): Vector2;
|
|
7
|
-
getPositionAtPercent(percent: number): Vector2;
|
|
8
|
-
closestPointOnLine(point: Vector2): Vector2;
|
|
9
|
-
intersect(otherLine: LineSegment2D, tolerance?: number): Vector2 | undefined;
|
|
10
|
-
constructor(start: Vector2, end: Vector2);
|
|
11
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LineSegment2D = void 0;
|
|
4
|
-
const Vector2_1 = require("./Vector2");
|
|
5
|
-
class LineSegment2D {
|
|
6
|
-
constructor(start, end) {
|
|
7
|
-
this.start = start;
|
|
8
|
-
this.end = end;
|
|
9
|
-
}
|
|
10
|
-
get length() {
|
|
11
|
-
return this.end.subtract(this.start).magnitued;
|
|
12
|
-
}
|
|
13
|
-
get direction() {
|
|
14
|
-
return this.end.subtract(this.start).unit;
|
|
15
|
-
}
|
|
16
|
-
getPositionAtPercent(percent) {
|
|
17
|
-
const dir = this.direction;
|
|
18
|
-
const length = percent * this.length;
|
|
19
|
-
dir.setLength(length);
|
|
20
|
-
return this.start.add(dir);
|
|
21
|
-
}
|
|
22
|
-
closestPointOnLine(point) {
|
|
23
|
-
// see https://monkeyproofsolutions.nl/wordpress/how-to-calculate-the-shortest-distance-between-a-point-and-a-line/
|
|
24
|
-
const direction = this.end.subtract(this.start);
|
|
25
|
-
const tNumerator = direction.dot(point.subtract(this.start));
|
|
26
|
-
const tDenominator = direction.dot(direction);
|
|
27
|
-
const t = tNumerator / tDenominator;
|
|
28
|
-
if (t < 0) {
|
|
29
|
-
return this.start.copy();
|
|
30
|
-
}
|
|
31
|
-
else if (t > 1) {
|
|
32
|
-
return this.end.copy();
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
const length = t * direction.magnitued;
|
|
36
|
-
direction.setLength(length);
|
|
37
|
-
return this.start.add(direction);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
intersect(otherLine, tolerance = 0) {
|
|
41
|
-
// See https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
|
|
42
|
-
const x1 = this.start.x;
|
|
43
|
-
const y1 = this.start.y;
|
|
44
|
-
const x2 = this.end.x;
|
|
45
|
-
const y2 = this.end.y;
|
|
46
|
-
const x3 = otherLine.start.x;
|
|
47
|
-
const y3 = otherLine.start.y;
|
|
48
|
-
const x4 = otherLine.end.x;
|
|
49
|
-
const y4 = otherLine.end.y;
|
|
50
|
-
const denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
|
|
51
|
-
if (denominator === 0) {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
const tNumerator = (x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4);
|
|
55
|
-
const t = tNumerator / denominator;
|
|
56
|
-
const tTolearnce = tolerance / this.length;
|
|
57
|
-
if (t < -tTolearnce || t > 1 + tTolearnce) {
|
|
58
|
-
return undefined;
|
|
59
|
-
}
|
|
60
|
-
const uNumerator = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
|
|
61
|
-
const u = uNumerator / denominator;
|
|
62
|
-
const uTolearnce = tolerance / otherLine.length;
|
|
63
|
-
if (u < -uTolearnce || u > 1 + uTolearnce)
|
|
64
|
-
return undefined;
|
|
65
|
-
const px = x1 + t * (x2 - x1);
|
|
66
|
-
const py = y1 + t * (y2 - y1);
|
|
67
|
-
return new Vector2_1.Vector2(px, py);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
exports.LineSegment2D = LineSegment2D;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface MouseController {
|
|
2
|
-
onClick?: (e: MouseEvent) => void;
|
|
3
|
-
onDown?: (e: MouseEvent) => void;
|
|
4
|
-
onUp?: (e: MouseEvent) => void;
|
|
5
|
-
onMove?: (e: MouseEvent) => void;
|
|
6
|
-
onWheel?: (e: WheelEvent) => void;
|
|
7
|
-
}
|
|
8
|
-
export interface MouseSceneInput {
|
|
9
|
-
eventElement: HTMLElement | undefined;
|
|
10
|
-
setEventElement: (eventElement: HTMLElement) => void;
|
|
11
|
-
clearInputElement: () => void;
|
|
12
|
-
registerController: (controller: MouseController) => void;
|
|
13
|
-
removeController: (controller: MouseController) => void;
|
|
14
|
-
}
|
|
15
|
-
export declare function makeMouseSceneInput(): MouseSceneInput;
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeMouseSceneInput = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
function makeMouseSceneInput() {
|
|
6
|
-
return new MouseSceneInputImp();
|
|
7
|
-
}
|
|
8
|
-
exports.makeMouseSceneInput = makeMouseSceneInput;
|
|
9
|
-
class MouseSceneInputImp {
|
|
10
|
-
constructor() {
|
|
11
|
-
this.controllers = [];
|
|
12
|
-
this.maxClickMovement = 5; // pixels
|
|
13
|
-
this._eventElement = undefined;
|
|
14
|
-
this.setEventElement = (eventElement) => {
|
|
15
|
-
if (this._eventElement)
|
|
16
|
-
this.clearInputElement();
|
|
17
|
-
eventElement.addEventListener("mousedown", this.onMouseDown);
|
|
18
|
-
eventElement.addEventListener("mouseup", this.onMouseUp);
|
|
19
|
-
eventElement.addEventListener("mousemove", this.onMouseMove);
|
|
20
|
-
eventElement.addEventListener("mouseout", this.onMouseOut);
|
|
21
|
-
eventElement.addEventListener("wheel", this.onWheel);
|
|
22
|
-
this._eventElement = eventElement;
|
|
23
|
-
};
|
|
24
|
-
this.clearInputElement = () => {
|
|
25
|
-
if (!this._eventElement)
|
|
26
|
-
return;
|
|
27
|
-
this._eventElement.removeEventListener("mousedown", this.onMouseDown);
|
|
28
|
-
this._eventElement.removeEventListener("mouseup", this.onMouseUp);
|
|
29
|
-
this._eventElement.removeEventListener("mousemove", this.onMouseMove);
|
|
30
|
-
this._eventElement.removeEventListener("mouseout", this.onMouseOut);
|
|
31
|
-
this._eventElement.removeEventListener("wheel", this.onWheel);
|
|
32
|
-
this._eventElement = undefined;
|
|
33
|
-
};
|
|
34
|
-
this.registerController = (controller) => {
|
|
35
|
-
this.controllers.push(controller);
|
|
36
|
-
};
|
|
37
|
-
this.removeController = (controller) => {
|
|
38
|
-
const index = this.controllers.indexOf(controller);
|
|
39
|
-
if (index >= 0) {
|
|
40
|
-
this.controllers.splice(index, 1);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
this.onMouseDown = (e) => {
|
|
44
|
-
const mousePos = new _1.Vector2(e.offsetX, e.offsetY);
|
|
45
|
-
this.controllers.forEach((c) => {
|
|
46
|
-
if (c.onDown) {
|
|
47
|
-
c.onDown(e);
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
this.pressEvent = e;
|
|
51
|
-
};
|
|
52
|
-
this.onMouseUp = (e) => {
|
|
53
|
-
this.controllers.forEach((c) => {
|
|
54
|
-
if (c.onUp) {
|
|
55
|
-
c.onUp(e);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
if (!this.pressEvent)
|
|
59
|
-
return;
|
|
60
|
-
const deltaX = this.pressEvent.screenX - e.screenX;
|
|
61
|
-
const deltaY = this.pressEvent.screenY - e.screenY;
|
|
62
|
-
const delta = new _1.Vector2(deltaX, deltaY);
|
|
63
|
-
if (delta.magnitued < this.maxClickMovement) {
|
|
64
|
-
this.controllers.forEach((c) => {
|
|
65
|
-
if (c.onClick) {
|
|
66
|
-
c.onClick(e);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
this.pressEvent = undefined;
|
|
71
|
-
};
|
|
72
|
-
this.onMouseMove = (e) => {
|
|
73
|
-
this.controllers.forEach((c) => {
|
|
74
|
-
if (c.onMove) {
|
|
75
|
-
c.onMove(e);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
if (!this.pressEvent)
|
|
79
|
-
return;
|
|
80
|
-
const deltaX = this.pressEvent.screenX - e.screenX;
|
|
81
|
-
const deltaY = this.pressEvent.screenY - e.screenY;
|
|
82
|
-
const delta = new _1.Vector2(deltaX, deltaY);
|
|
83
|
-
if (delta.magnitued > this.maxClickMovement) {
|
|
84
|
-
this.pressEvent = undefined;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
this.onMouseOut = (e) => {
|
|
88
|
-
if (!this.pressEvent)
|
|
89
|
-
return;
|
|
90
|
-
const mousePos = new _1.Vector2(e.offsetX, e.offsetY);
|
|
91
|
-
this.controllers.forEach((c) => {
|
|
92
|
-
if (c.onUp) {
|
|
93
|
-
c.onUp(e);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
this.pressEvent = undefined;
|
|
97
|
-
};
|
|
98
|
-
this.onWheel = (e) => {
|
|
99
|
-
this.controllers.forEach((c) => {
|
|
100
|
-
if (c.onWheel) {
|
|
101
|
-
c.onWheel(e);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
get eventElement() {
|
|
107
|
-
return this._eventElement;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from ".";
|
|
2
|
-
export declare type OnOrbitCameraChange = () => void;
|
|
3
|
-
export interface CameraLerper {
|
|
4
|
-
cancelLerp: () => void;
|
|
5
|
-
}
|
|
6
|
-
export interface CameraData {
|
|
7
|
-
defaultAlpha?: number;
|
|
8
|
-
defaultBeta?: number;
|
|
9
|
-
defaultRadius?: number;
|
|
10
|
-
defaultTarget?: {
|
|
11
|
-
x: number;
|
|
12
|
-
y: number;
|
|
13
|
-
z: number;
|
|
14
|
-
};
|
|
15
|
-
nearClip?: number;
|
|
16
|
-
farClip?: number;
|
|
17
|
-
alphaLimit?: {
|
|
18
|
-
min: number;
|
|
19
|
-
max: number;
|
|
20
|
-
};
|
|
21
|
-
betaLimit?: {
|
|
22
|
-
min: number;
|
|
23
|
-
max: number;
|
|
24
|
-
};
|
|
25
|
-
radiusLimit?: {
|
|
26
|
-
min: number;
|
|
27
|
-
max: number;
|
|
28
|
-
};
|
|
29
|
-
targetLimit?: {
|
|
30
|
-
min: {
|
|
31
|
-
x: number;
|
|
32
|
-
y: number;
|
|
33
|
-
z: number;
|
|
34
|
-
};
|
|
35
|
-
max: {
|
|
36
|
-
x: number;
|
|
37
|
-
y: number;
|
|
38
|
-
z: number;
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
dollyRollSensitivity?: number;
|
|
42
|
-
dollyPixelSensitivity?: number;
|
|
43
|
-
orbitPixelSensitivity?: number;
|
|
44
|
-
dollyPinchSensitivity?: number;
|
|
45
|
-
}
|
|
46
|
-
export interface OrbitCamera {
|
|
47
|
-
alpha: number;
|
|
48
|
-
beta: number;
|
|
49
|
-
radius: number;
|
|
50
|
-
target: Vector3;
|
|
51
|
-
nearClip: number;
|
|
52
|
-
farClip: number;
|
|
53
|
-
defaultAlpha: number;
|
|
54
|
-
defaultBeta: number;
|
|
55
|
-
defaultRadius: number;
|
|
56
|
-
defaultTarget: Vector3;
|
|
57
|
-
dollyRollSensitivity: number;
|
|
58
|
-
dollyPixelSensitivity: number;
|
|
59
|
-
dollyPinchSensitivity: number;
|
|
60
|
-
orbitPixelSensitivity: number;
|
|
61
|
-
setAlphaLimits: (min: number, max: number) => void;
|
|
62
|
-
clearAlphaLimits: () => void;
|
|
63
|
-
setBetaLimits: (min: number, max: number) => void;
|
|
64
|
-
clearBetaLimits: () => void;
|
|
65
|
-
setRadiusLimits: (min: number, max: number) => void;
|
|
66
|
-
clearRadiusLimits: () => void;
|
|
67
|
-
setTargetLimits: (min: Vector3, max: Vector3) => void;
|
|
68
|
-
clearTargetLimits: () => void;
|
|
69
|
-
registerLerp: (lerper: CameraLerper) => void;
|
|
70
|
-
lerpCompleted: () => void;
|
|
71
|
-
cancelLerp: () => void;
|
|
72
|
-
applyData: (data: CameraData) => void;
|
|
73
|
-
addObserver: (observer: OnOrbitCameraChange) => void;
|
|
74
|
-
removeObserver: (observer: OnOrbitCameraChange) => void;
|
|
75
|
-
}
|
|
76
|
-
export declare function makeOrbitCamera(): OrbitCamera;
|