@vived/app 2.8.0 → 2.10.0
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/lib/Entities/Babylon.d.ts +14 -0
- package/lib/Entities/Babylon.js +18 -0
- package/lib/Entities/FocusCamera.d.ts +70 -0
- package/lib/Entities/FocusCamera.js +243 -0
- package/lib/Entities/MouseInput.d.ts +15 -0
- package/lib/Entities/MouseInput.js +116 -0
- package/lib/Entities/MouseSceneInput.d.ts +5 -14
- package/lib/Entities/MouseSceneInput.js +6 -24
- package/lib/Entities/OrbitCamera.d.ts +59 -0
- package/lib/Entities/OrbitCamera.js +173 -4
- package/lib/Entities/TouchInput.d.ts +20 -0
- package/lib/Entities/TouchInput.js +111 -0
- package/lib/Entities/index.d.ts +3 -2
- package/lib/Entities/index.js +3 -2
- package/lib/Interface/Controllers/makeAppHandler.d.ts +1 -1
- package/lib/Interface/Controllers/makeAppHandler.js +12 -10
- package/lib/PresentationManagers/FocusCameraPM.d.ts +14 -0
- package/lib/PresentationManagers/FocusCameraPM.js +31 -0
- package/lib/PresentationManagers/index.d.ts +1 -1
- package/lib/PresentationManagers/index.js +1 -1
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +16 -0
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +63 -0
- package/lib/UseCases/FocusCamera/LerpFocusCamera.d.ts +36 -0
- package/lib/UseCases/FocusCamera/LerpFocusCamera.js +71 -0
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.d.ts +10 -0
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +35 -0
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +10 -0
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +36 -0
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +10 -0
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +24 -0
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +10 -0
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +32 -0
- package/lib/UseCases/FocusCamera/SerializeFocusCamera.d.ts +22 -0
- package/lib/UseCases/FocusCamera/SerializeFocusCamera.js +81 -0
- package/lib/UseCases/FocusCamera/index.d.ts +7 -0
- package/lib/UseCases/FocusCamera/index.js +19 -0
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +36 -0
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +71 -0
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +9 -0
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +31 -0
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +10 -0
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +31 -0
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +22 -0
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +81 -0
- package/lib/UseCases/OrbitCamera/index.d.ts +4 -0
- package/lib/UseCases/OrbitCamera/index.js +16 -0
- package/lib/UseCases/index.d.ts +1 -2
- package/lib/UseCases/index.js +1 -2
- package/package.json +1 -1
|
@@ -3,14 +3,73 @@ export declare type OnOrbitCameraChange = () => void;
|
|
|
3
3
|
export interface CameraLerper {
|
|
4
4
|
cancelLerp: () => void;
|
|
5
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
|
+
}
|
|
6
46
|
export interface OrbitCamera {
|
|
7
47
|
alpha: number;
|
|
8
48
|
beta: number;
|
|
9
49
|
radius: number;
|
|
10
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;
|
|
11
69
|
registerLerp: (lerper: CameraLerper) => void;
|
|
12
70
|
lerpCompleted: () => void;
|
|
13
71
|
cancelLerp: () => void;
|
|
72
|
+
applyData: (data: CameraData) => void;
|
|
14
73
|
addObserver: (observer: OnOrbitCameraChange) => void;
|
|
15
74
|
removeObserver: (observer: OnOrbitCameraChange) => void;
|
|
16
75
|
}
|
|
@@ -8,11 +8,108 @@ function makeOrbitCamera() {
|
|
|
8
8
|
exports.makeOrbitCamera = makeOrbitCamera;
|
|
9
9
|
class OrbitCameraImp {
|
|
10
10
|
constructor() {
|
|
11
|
+
this.farClip = 100;
|
|
12
|
+
this.nearClip = 0.01;
|
|
13
|
+
this.defaultAlpha = 0;
|
|
14
|
+
this.defaultBeta = 30;
|
|
15
|
+
this.defaultRadius = 8;
|
|
16
|
+
this.defaultTarget = _1.Vector3.Zero();
|
|
17
|
+
this.orbitPixelSensitivity = 0.5;
|
|
18
|
+
this.dollyPixelSensitivity = 0.01;
|
|
19
|
+
this.dollyRollSensitivity = 0.001;
|
|
20
|
+
this.dollyPinchSensitivity = 0.005;
|
|
21
|
+
this.limitRadius = false;
|
|
22
|
+
this.minRadius = 0;
|
|
23
|
+
this.maxRadius = 0;
|
|
24
|
+
this.limitAlpha = false;
|
|
25
|
+
this.minAlpha = 0;
|
|
26
|
+
this.maxAlpha = 0;
|
|
27
|
+
this.limitBeta = false;
|
|
28
|
+
this.minBeta = 0;
|
|
29
|
+
this.maxBeta = 0;
|
|
30
|
+
this.limitTarget = false;
|
|
31
|
+
this.maxTargetPosition = _1.Vector3.Zero();
|
|
32
|
+
this.minTargetPosition = _1.Vector3.Zero();
|
|
11
33
|
this.observers = new _1.ObserverList();
|
|
12
34
|
this.memoizedAlpha = new _1.MemoizedNumber(0, this.observers.notify);
|
|
13
35
|
this.memoizedBeta = new _1.MemoizedNumber(0, this.observers.notify);
|
|
14
36
|
this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
|
|
15
37
|
this.memoizedTarget = new _1.MemoizedVector3(_1.Vector3.Zero(), this.observers.notify);
|
|
38
|
+
this.setRadiusLimits = (min, max) => {
|
|
39
|
+
if (min < 0) {
|
|
40
|
+
throw new Error("[Orbit Camera] Mininum Radius must be greater >= 0");
|
|
41
|
+
}
|
|
42
|
+
if (max < min) {
|
|
43
|
+
throw new Error("[Orbit Camera] Max radius must be >= min radius");
|
|
44
|
+
}
|
|
45
|
+
this.maxRadius = max;
|
|
46
|
+
this.minRadius = min;
|
|
47
|
+
this.limitRadius = true;
|
|
48
|
+
this.radius = this.radius;
|
|
49
|
+
};
|
|
50
|
+
this.clearRadiusLimits = () => {
|
|
51
|
+
this.maxRadius = 0;
|
|
52
|
+
this.minRadius = 0;
|
|
53
|
+
this.limitRadius = false;
|
|
54
|
+
};
|
|
55
|
+
this.setAlphaLimits = (min, max) => {
|
|
56
|
+
if (min > max) {
|
|
57
|
+
throw new Error("[Orbit Camera] Max alpha must be >= min alpha");
|
|
58
|
+
}
|
|
59
|
+
if (min < -180) {
|
|
60
|
+
throw new Error("[Orbit Camera] Min alpha must be >= -180");
|
|
61
|
+
}
|
|
62
|
+
if (max > 180) {
|
|
63
|
+
throw new Error("[Orbit Camera] Max alpha must be <= 180");
|
|
64
|
+
}
|
|
65
|
+
this.maxAlpha = max;
|
|
66
|
+
this.minAlpha = min;
|
|
67
|
+
this.limitAlpha = true;
|
|
68
|
+
this.alpha = this.alpha;
|
|
69
|
+
};
|
|
70
|
+
this.clearAlphaLimits = () => {
|
|
71
|
+
this.maxAlpha = 0;
|
|
72
|
+
this.minAlpha = 0;
|
|
73
|
+
this.limitAlpha = false;
|
|
74
|
+
};
|
|
75
|
+
this.setBetaLimits = (min, max) => {
|
|
76
|
+
if (min > max) {
|
|
77
|
+
throw new Error("[Orbit Camera] Max beta must be >= min beta");
|
|
78
|
+
}
|
|
79
|
+
if (min < -180) {
|
|
80
|
+
throw new Error("[Orbit Camera] Min beta must be >= -180");
|
|
81
|
+
}
|
|
82
|
+
if (max > 180) {
|
|
83
|
+
throw new Error("[Orbit Camera] Max beta must be <= 180");
|
|
84
|
+
}
|
|
85
|
+
this.maxBeta = max;
|
|
86
|
+
this.minBeta = min;
|
|
87
|
+
this.limitBeta = true;
|
|
88
|
+
this.beta = this.beta;
|
|
89
|
+
};
|
|
90
|
+
this.clearBetaLimits = () => {
|
|
91
|
+
this.maxBeta = 0;
|
|
92
|
+
this.minBeta = 0;
|
|
93
|
+
this.limitBeta = false;
|
|
94
|
+
};
|
|
95
|
+
this.setTargetLimits = (min, max) => {
|
|
96
|
+
const minArray = min.asArray();
|
|
97
|
+
const maxArray = max.asArray();
|
|
98
|
+
for (let i = 0; i < 3; i++) {
|
|
99
|
+
if (minArray[i] > maxArray[i]) {
|
|
100
|
+
throw new Error("[Orbit Camera] Min target must be less than the max target");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
this.maxTargetPosition = max;
|
|
104
|
+
this.minTargetPosition = min;
|
|
105
|
+
this.limitTarget = true;
|
|
106
|
+
this.target = this.target;
|
|
107
|
+
};
|
|
108
|
+
this.clearTargetLimits = () => {
|
|
109
|
+
this.maxTargetPosition = _1.Vector3.Zero();
|
|
110
|
+
this.minTargetPosition = _1.Vector3.Zero();
|
|
111
|
+
this.limitTarget = false;
|
|
112
|
+
};
|
|
16
113
|
this.registerLerp = (lerper) => {
|
|
17
114
|
if (this.currentLerp) {
|
|
18
115
|
this.currentLerp.cancelLerp();
|
|
@@ -27,6 +124,52 @@ class OrbitCameraImp {
|
|
|
27
124
|
(_a = this.currentLerp) === null || _a === void 0 ? void 0 : _a.cancelLerp();
|
|
28
125
|
this.currentLerp = undefined;
|
|
29
126
|
};
|
|
127
|
+
this.applyData = (data) => {
|
|
128
|
+
if (data.defaultAlpha !== undefined) {
|
|
129
|
+
this.defaultAlpha = data.defaultAlpha;
|
|
130
|
+
}
|
|
131
|
+
if (data.defaultBeta !== undefined) {
|
|
132
|
+
this.defaultBeta = data.defaultBeta;
|
|
133
|
+
}
|
|
134
|
+
if (data.defaultRadius !== undefined) {
|
|
135
|
+
this.defaultRadius = data.defaultRadius;
|
|
136
|
+
}
|
|
137
|
+
if (data.defaultTarget !== undefined) {
|
|
138
|
+
const { x, y, z } = data.defaultTarget;
|
|
139
|
+
this.defaultTarget = new _1.Vector3(x, y, z);
|
|
140
|
+
}
|
|
141
|
+
if (data.nearClip !== undefined) {
|
|
142
|
+
this.nearClip = data.nearClip;
|
|
143
|
+
}
|
|
144
|
+
if (data.farClip !== undefined) {
|
|
145
|
+
this.farClip = data.farClip;
|
|
146
|
+
}
|
|
147
|
+
if (data.alphaLimit !== undefined) {
|
|
148
|
+
this.setAlphaLimits(data.alphaLimit.min, data.alphaLimit.max);
|
|
149
|
+
}
|
|
150
|
+
if (data.betaLimit !== undefined) {
|
|
151
|
+
this.setBetaLimits(data.betaLimit.min, data.betaLimit.max);
|
|
152
|
+
}
|
|
153
|
+
if (data.radiusLimit !== undefined) {
|
|
154
|
+
this.setRadiusLimits(data.radiusLimit.min, data.radiusLimit.max);
|
|
155
|
+
}
|
|
156
|
+
if (data.targetLimit !== undefined) {
|
|
157
|
+
const { max, min } = data.targetLimit;
|
|
158
|
+
this.setTargetLimits(new _1.Vector3(min.x, min.y, min.z), new _1.Vector3(max.x, max.y, max.z));
|
|
159
|
+
}
|
|
160
|
+
if (data.dollyRollSensitivity !== undefined) {
|
|
161
|
+
this.dollyRollSensitivity = data.dollyRollSensitivity;
|
|
162
|
+
}
|
|
163
|
+
if (data.dollyPixelSensitivity !== undefined) {
|
|
164
|
+
this.dollyPixelSensitivity = data.dollyPixelSensitivity;
|
|
165
|
+
}
|
|
166
|
+
if (data.dollyPinchSensitivity !== undefined) {
|
|
167
|
+
this.dollyPinchSensitivity = data.dollyPinchSensitivity;
|
|
168
|
+
}
|
|
169
|
+
if (data.orbitPixelSensitivity !== undefined) {
|
|
170
|
+
this.orbitPixelSensitivity = data.orbitPixelSensitivity;
|
|
171
|
+
}
|
|
172
|
+
};
|
|
30
173
|
this.addObserver = (observer) => {
|
|
31
174
|
this.observers.add(observer);
|
|
32
175
|
};
|
|
@@ -38,25 +181,51 @@ class OrbitCameraImp {
|
|
|
38
181
|
return this.memoizedAlpha.val;
|
|
39
182
|
}
|
|
40
183
|
set alpha(val) {
|
|
41
|
-
|
|
184
|
+
let clampedVal = this.clampAngle(val);
|
|
185
|
+
if (this.limitAlpha) {
|
|
186
|
+
clampedVal = Math.min(clampedVal, this.maxAlpha);
|
|
187
|
+
clampedVal = Math.max(clampedVal, this.minAlpha);
|
|
188
|
+
}
|
|
189
|
+
this.memoizedAlpha.val = clampedVal;
|
|
42
190
|
}
|
|
43
191
|
get beta() {
|
|
44
192
|
return this.memoizedBeta.val;
|
|
45
193
|
}
|
|
46
194
|
set beta(val) {
|
|
47
|
-
|
|
195
|
+
let clampedVal = this.clampAngle(val);
|
|
196
|
+
if (this.limitBeta) {
|
|
197
|
+
clampedVal = Math.min(clampedVal, this.maxBeta);
|
|
198
|
+
clampedVal = Math.max(clampedVal, this.minBeta);
|
|
199
|
+
}
|
|
200
|
+
this.memoizedBeta.val = clampedVal;
|
|
48
201
|
}
|
|
49
202
|
get radius() {
|
|
50
203
|
return this.memoizedRadius.val;
|
|
51
204
|
}
|
|
52
205
|
set radius(val) {
|
|
53
|
-
|
|
206
|
+
let clampedVal = Math.max(val, 0);
|
|
207
|
+
if (this.limitRadius) {
|
|
208
|
+
clampedVal = Math.min(clampedVal, this.maxRadius);
|
|
209
|
+
clampedVal = Math.max(clampedVal, this.minRadius);
|
|
210
|
+
}
|
|
211
|
+
this.memoizedRadius.val = clampedVal;
|
|
54
212
|
}
|
|
55
213
|
get target() {
|
|
56
214
|
return this.memoizedTarget.getVector();
|
|
57
215
|
}
|
|
58
216
|
set target(val) {
|
|
59
|
-
|
|
217
|
+
const targetVals = val.asArray();
|
|
218
|
+
if (this.limitTarget) {
|
|
219
|
+
const maxVals = this.maxTargetPosition.asArray();
|
|
220
|
+
const minVals = this.minTargetPosition.asArray();
|
|
221
|
+
for (let i = 0; i < 3; i++) {
|
|
222
|
+
let v = targetVals[i];
|
|
223
|
+
v = Math.min(v, maxVals[i]);
|
|
224
|
+
v = Math.max(v, minVals[i]);
|
|
225
|
+
targetVals[i] = v;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
this.memoizedTarget.setVector(new _1.Vector3(targetVals[0], targetVals[1], targetVals[2]));
|
|
60
229
|
}
|
|
61
230
|
clampAngle(angle) {
|
|
62
231
|
const isNegative = angle < 0 ? true : false;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Vector2 } from ".";
|
|
2
|
+
export interface TouchController {
|
|
3
|
+
onTouchStart?: (e: TouchEvent) => void;
|
|
4
|
+
onTouchMove?: (e: TouchEvent) => void;
|
|
5
|
+
onTouchEnd?: (e: TouchEvent) => void;
|
|
6
|
+
onTouchCancel?: (e: TouchEvent) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface TouchInput {
|
|
9
|
+
eventElement: HTMLElement | undefined;
|
|
10
|
+
eventElementBounds?: DOMRect;
|
|
11
|
+
setEventElement: (eventElement: HTMLElement) => void;
|
|
12
|
+
clearInputElement: () => void;
|
|
13
|
+
updateInputElementBounds: () => void;
|
|
14
|
+
getTouchOffsetPosition: (touch: Touch) => Vector2;
|
|
15
|
+
getDistatnceBetweenTouches: (touch1: Touch, touch2: Touch) => number;
|
|
16
|
+
getTouchsCenter: (touches: TouchList) => Vector2;
|
|
17
|
+
registerController: (controller: TouchController) => void;
|
|
18
|
+
removeController: (controller: TouchController) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function makeTouchInput(): TouchInput;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTouchInput = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
function makeTouchInput() {
|
|
6
|
+
return new TouchInputImp();
|
|
7
|
+
}
|
|
8
|
+
exports.makeTouchInput = makeTouchInput;
|
|
9
|
+
class TouchInputImp {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.controllers = [];
|
|
12
|
+
this._eventElement = undefined;
|
|
13
|
+
this.updateInputElementBounds = () => {
|
|
14
|
+
if (!this._eventElement)
|
|
15
|
+
return;
|
|
16
|
+
this.eventElementBounds = this._eventElement.getBoundingClientRect(); // Expensive so we cache
|
|
17
|
+
};
|
|
18
|
+
this.getTouchOffsetPosition = (touch) => {
|
|
19
|
+
if (!this.eventElementBounds) {
|
|
20
|
+
console.warn("No target bounds");
|
|
21
|
+
return _1.Vector2.Zero();
|
|
22
|
+
}
|
|
23
|
+
const x = touch.clientX - this.eventElementBounds.x;
|
|
24
|
+
const y = touch.clientY - this.eventElementBounds.y;
|
|
25
|
+
return new _1.Vector2(x, y);
|
|
26
|
+
};
|
|
27
|
+
this.getDistatnceBetweenTouches = (touch1, touch2) => {
|
|
28
|
+
const t1 = this.getTouchOffsetPosition(touch1);
|
|
29
|
+
const t2 = this.getTouchOffsetPosition(touch2);
|
|
30
|
+
const delta = t2.subtract(t1);
|
|
31
|
+
return delta.magnitued;
|
|
32
|
+
};
|
|
33
|
+
this.getTouchsCenter = (touches) => {
|
|
34
|
+
const touchCount = touches.length;
|
|
35
|
+
if (touchCount === 0)
|
|
36
|
+
return _1.Vector2.Zero();
|
|
37
|
+
let sumX = 0;
|
|
38
|
+
let sumY = 0;
|
|
39
|
+
for (let i = 0; i < touchCount; i++) {
|
|
40
|
+
const touch = touches[i];
|
|
41
|
+
const touchPos = this.getTouchOffsetPosition(touch);
|
|
42
|
+
sumX += touchPos.x;
|
|
43
|
+
sumY += touchPos.y;
|
|
44
|
+
}
|
|
45
|
+
return new _1.Vector2(sumX / touches.length, sumY / touches.length);
|
|
46
|
+
};
|
|
47
|
+
this.setEventElement = (eventElement) => {
|
|
48
|
+
if (this._eventElement)
|
|
49
|
+
this.clearInputElement();
|
|
50
|
+
eventElement.addEventListener("touchstart", this.onTouchStart, false);
|
|
51
|
+
eventElement.addEventListener("touchmove", this.onTouchMove, false);
|
|
52
|
+
eventElement.addEventListener("touchend", this.onTouchEnd, false);
|
|
53
|
+
eventElement.addEventListener("touchcancel", this.onTouchCancel, false);
|
|
54
|
+
this.eventElementBounds = eventElement.getBoundingClientRect();
|
|
55
|
+
this._eventElement = eventElement;
|
|
56
|
+
};
|
|
57
|
+
this.onTouchStart = (e) => {
|
|
58
|
+
e.preventDefault();
|
|
59
|
+
this.controllers.forEach((c) => {
|
|
60
|
+
if (c.onTouchStart) {
|
|
61
|
+
c.onTouchStart(e);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
this.onTouchMove = (e) => {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
this.controllers.forEach((c) => {
|
|
68
|
+
if (c.onTouchMove) {
|
|
69
|
+
c.onTouchMove(e);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
this.onTouchEnd = (e) => {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
this.controllers.forEach((c) => {
|
|
76
|
+
if (c.onTouchEnd) {
|
|
77
|
+
c.onTouchEnd(e);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
this.onTouchCancel = (e) => {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
this.controllers.forEach((c) => {
|
|
84
|
+
if (c.onTouchCancel) {
|
|
85
|
+
c.onTouchCancel(e);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
this.clearInputElement = () => {
|
|
90
|
+
if (!this._eventElement)
|
|
91
|
+
return;
|
|
92
|
+
this._eventElement.removeEventListener("touchstart", this.onTouchStart);
|
|
93
|
+
this._eventElement.removeEventListener("touchmove", this.onTouchMove);
|
|
94
|
+
this._eventElement.removeEventListener("touchend", this.onTouchEnd);
|
|
95
|
+
this._eventElement.removeEventListener("touchcancel", this.onTouchCancel);
|
|
96
|
+
this._eventElement = undefined;
|
|
97
|
+
};
|
|
98
|
+
this.registerController = (controller) => {
|
|
99
|
+
this.controllers.push(controller);
|
|
100
|
+
};
|
|
101
|
+
this.removeController = (controller) => {
|
|
102
|
+
const index = this.controllers.indexOf(controller);
|
|
103
|
+
if (index >= 0) {
|
|
104
|
+
this.controllers.splice(index, 1);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
get eventElement() {
|
|
109
|
+
return this._eventElement;
|
|
110
|
+
}
|
|
111
|
+
}
|
package/lib/Entities/index.d.ts
CHANGED
|
@@ -10,11 +10,12 @@ export * from "./MemoizedString";
|
|
|
10
10
|
export * from "./MemoizedVector2";
|
|
11
11
|
export * from "./MemoizedVector3";
|
|
12
12
|
export * from "./ObserverList";
|
|
13
|
-
export * from "./
|
|
13
|
+
export * from "./FocusCamera";
|
|
14
14
|
export * from "./ParametricLine";
|
|
15
15
|
export * from "./ParametricPlane";
|
|
16
16
|
export * from "./StateMachine";
|
|
17
17
|
export * from "./UndoRedo";
|
|
18
18
|
export * from "./Vector2";
|
|
19
19
|
export * from "./Vector3";
|
|
20
|
-
export * from "./
|
|
20
|
+
export * from "./MouseInput";
|
|
21
|
+
export * from "./TouchInput";
|
package/lib/Entities/index.js
CHANGED
|
@@ -22,11 +22,12 @@ __exportStar(require("./MemoizedString"), exports);
|
|
|
22
22
|
__exportStar(require("./MemoizedVector2"), exports);
|
|
23
23
|
__exportStar(require("./MemoizedVector3"), exports);
|
|
24
24
|
__exportStar(require("./ObserverList"), exports);
|
|
25
|
-
__exportStar(require("./
|
|
25
|
+
__exportStar(require("./FocusCamera"), exports);
|
|
26
26
|
__exportStar(require("./ParametricLine"), exports);
|
|
27
27
|
__exportStar(require("./ParametricPlane"), exports);
|
|
28
28
|
__exportStar(require("./StateMachine"), exports);
|
|
29
29
|
__exportStar(require("./UndoRedo"), exports);
|
|
30
30
|
__exportStar(require("./Vector2"), exports);
|
|
31
31
|
__exportStar(require("./Vector3"), exports);
|
|
32
|
-
__exportStar(require("./
|
|
32
|
+
__exportStar(require("./MouseInput"), exports);
|
|
33
|
+
__exportStar(require("./TouchInput"), exports);
|
|
@@ -9,4 +9,4 @@ export interface AppHandlerFunctions {
|
|
|
9
9
|
setState: (finalState: string, duration?: number) => void;
|
|
10
10
|
setDevicePreview: (x: number, y: number) => void;
|
|
11
11
|
}
|
|
12
|
-
export declare function makeAppHandler(functions: AppHandlerFunctions): Handler;
|
|
12
|
+
export declare function makeAppHandler(functions: AppHandlerFunctions, verbose?: boolean): Handler;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeAppHandler = exports.appPayloadVersions = void 0;
|
|
4
4
|
const app_host_boundary_1 = require("@vived/app-host-boundary");
|
|
5
|
-
const verbose = false;
|
|
6
5
|
exports.appPayloadVersions = {
|
|
7
6
|
disposeApp: 1,
|
|
8
7
|
setDevicePreview: 1,
|
|
@@ -12,10 +11,13 @@ exports.appPayloadVersions = {
|
|
|
12
11
|
stopApp: 1,
|
|
13
12
|
setState: 2,
|
|
14
13
|
};
|
|
15
|
-
function makeAppHandler(functions) {
|
|
14
|
+
function makeAppHandler(functions, verbose = false) {
|
|
16
15
|
const handler = (request) => {
|
|
16
|
+
if (verbose) {
|
|
17
|
+
console.log(request);
|
|
18
|
+
}
|
|
17
19
|
switch (request.type) {
|
|
18
|
-
case
|
|
20
|
+
case 'SHOW_BABYLON_INSPECTOR':
|
|
19
21
|
if (request.version === exports.appPayloadVersions.showBabylonInspector) {
|
|
20
22
|
const payload = request.payload;
|
|
21
23
|
functions.showBabylonInspector(payload.showBabylonInspector);
|
|
@@ -24,7 +26,7 @@ function makeAppHandler(functions) {
|
|
|
24
26
|
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
25
27
|
}
|
|
26
28
|
break;
|
|
27
|
-
case
|
|
29
|
+
case 'SET_IS_AUTHORING':
|
|
28
30
|
if (request.version === exports.appPayloadVersions.setIsAuthoring) {
|
|
29
31
|
const payload = request.payload;
|
|
30
32
|
functions.setIsAuthoring(payload.isAuthoring);
|
|
@@ -33,7 +35,7 @@ function makeAppHandler(functions) {
|
|
|
33
35
|
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
34
36
|
}
|
|
35
37
|
break;
|
|
36
|
-
case
|
|
38
|
+
case 'DISPOSE_APP':
|
|
37
39
|
if (request.version === exports.appPayloadVersions.disposeApp) {
|
|
38
40
|
functions.disposeApp();
|
|
39
41
|
}
|
|
@@ -41,7 +43,7 @@ function makeAppHandler(functions) {
|
|
|
41
43
|
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
42
44
|
}
|
|
43
45
|
break;
|
|
44
|
-
case
|
|
46
|
+
case 'STOP_APP':
|
|
45
47
|
if (request.version === exports.appPayloadVersions.stopApp) {
|
|
46
48
|
functions.stopApp();
|
|
47
49
|
}
|
|
@@ -49,7 +51,7 @@ function makeAppHandler(functions) {
|
|
|
49
51
|
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
50
52
|
}
|
|
51
53
|
break;
|
|
52
|
-
case
|
|
54
|
+
case 'SET_DEVICE_PREVIEW':
|
|
53
55
|
if (request.version === exports.appPayloadVersions.setDevicePreview) {
|
|
54
56
|
const payload = request.payload;
|
|
55
57
|
functions.setDevicePreview(payload.x, payload.y);
|
|
@@ -58,7 +60,7 @@ function makeAppHandler(functions) {
|
|
|
58
60
|
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
59
61
|
}
|
|
60
62
|
break;
|
|
61
|
-
case
|
|
63
|
+
case 'START_APP':
|
|
62
64
|
if (request.version === exports.appPayloadVersions.startApp) {
|
|
63
65
|
const payload = request.payload;
|
|
64
66
|
functions.startApp(payload.container);
|
|
@@ -67,7 +69,7 @@ function makeAppHandler(functions) {
|
|
|
67
69
|
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
68
70
|
}
|
|
69
71
|
break;
|
|
70
|
-
case
|
|
72
|
+
case 'SET_APP_STATE':
|
|
71
73
|
if (request.version === exports.appPayloadVersions.setState) {
|
|
72
74
|
const payload = request.payload;
|
|
73
75
|
functions.setState(payload.finalState, payload.duration);
|
|
@@ -76,7 +78,7 @@ function makeAppHandler(functions) {
|
|
|
76
78
|
throw new app_host_boundary_1.UnsupportedRequestVerion(request.type, request.version);
|
|
77
79
|
}
|
|
78
80
|
break;
|
|
79
|
-
case
|
|
81
|
+
case 'GET_APP_PAYLOAD_VERSION':
|
|
80
82
|
if (request.version === 1) {
|
|
81
83
|
const payload = request.payload;
|
|
82
84
|
payload.callback(exports.appPayloadVersions);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FocusCamera, Vector3 } from "../Entities";
|
|
2
|
+
export interface FocusCameraVM {
|
|
3
|
+
alphaEuler: Vector3;
|
|
4
|
+
betaEuler: Vector3;
|
|
5
|
+
cameraLocalPosition: Vector3;
|
|
6
|
+
target: Vector3;
|
|
7
|
+
}
|
|
8
|
+
export declare class FocusCameraPM {
|
|
9
|
+
private orbitCam;
|
|
10
|
+
private view;
|
|
11
|
+
dispose(): void;
|
|
12
|
+
private doUpdateView;
|
|
13
|
+
constructor(orbitCamera: FocusCamera, view: (vm: FocusCameraVM) => void);
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FocusCameraPM = void 0;
|
|
4
|
+
const Entities_1 = require("../Entities");
|
|
5
|
+
const Utilities_1 = require("../Utilities");
|
|
6
|
+
class FocusCameraPM {
|
|
7
|
+
constructor(orbitCamera, view) {
|
|
8
|
+
this.doUpdateView = () => {
|
|
9
|
+
const { alpha, beta, radius, target } = this.orbitCam;
|
|
10
|
+
const alphaRadians = Utilities_1.degreesToRadians(alpha);
|
|
11
|
+
const alphaEuler = new Entities_1.Vector3(0, alphaRadians, 0);
|
|
12
|
+
const betaRadians = Utilities_1.degreesToRadians(beta);
|
|
13
|
+
const betaEuler = new Entities_1.Vector3(betaRadians, 0, 0);
|
|
14
|
+
const cameraLocalPosition = new Entities_1.Vector3(0, 0, -radius);
|
|
15
|
+
this.view({
|
|
16
|
+
alphaEuler,
|
|
17
|
+
betaEuler,
|
|
18
|
+
cameraLocalPosition,
|
|
19
|
+
target,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
this.orbitCam = orbitCamera;
|
|
23
|
+
this.view = view;
|
|
24
|
+
this.doUpdateView();
|
|
25
|
+
this.orbitCam.addObserver(this.doUpdateView);
|
|
26
|
+
}
|
|
27
|
+
dispose() {
|
|
28
|
+
this.orbitCam.removeObserver(this.doUpdateView);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.FocusCameraPM = FocusCameraPM;
|
|
@@ -15,4 +15,4 @@ __exportStar(require("./IsAuthoringPM"), exports);
|
|
|
15
15
|
__exportStar(require("./ShowBabylonInspectorPM"), exports);
|
|
16
16
|
__exportStar(require("./HasRedoPM"), exports);
|
|
17
17
|
__exportStar(require("./HasUndoPM"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./FocusCameraPM"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FocusCamera, Vector3 } from "../../Entities";
|
|
2
|
+
export declare class BumpDollyFocusCamera {
|
|
3
|
+
private focusCamera;
|
|
4
|
+
bumpDurationMS: number;
|
|
5
|
+
bumpLerp: (percent: number) => number;
|
|
6
|
+
bumpAmount: number;
|
|
7
|
+
private interval?;
|
|
8
|
+
private chrono;
|
|
9
|
+
private delta;
|
|
10
|
+
private initialRadius;
|
|
11
|
+
private finalRadius;
|
|
12
|
+
private pickPoint?;
|
|
13
|
+
private onTick;
|
|
14
|
+
bump(direction: "IN" | "OUT", target?: Vector3): void;
|
|
15
|
+
constructor(focusCamera: FocusCamera);
|
|
16
|
+
}
|