@vived/app 2.10.0 → 2.12.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 +1 -2
- package/lib/Entities/Babylon.js +6 -7
- package/lib/Entities/DevicePreview.d.ts +1 -1
- package/lib/Entities/DevicePreview.js +5 -5
- package/lib/Entities/FocusCamera.d.ts +1 -1
- package/lib/Entities/FocusCamera.js +19 -19
- package/lib/Entities/KeyboardInput.d.ts +6 -8
- package/lib/Entities/KeyboardInput.js +28 -50
- package/lib/Entities/MemoizedVector2.d.ts +3 -7
- package/lib/Entities/MemoizedVector2.js +7 -24
- package/lib/Entities/MemoizedVector3.d.ts +3 -9
- package/lib/Entities/MemoizedVector3.js +7 -33
- package/lib/Entities/MouseInput.js +3 -3
- package/lib/Entities/ParametricLine.d.ts +1 -1
- package/lib/Entities/ParametricLine.js +8 -8
- package/lib/Entities/ParametricPlane.d.ts +3 -3
- package/lib/Entities/ParametricPlane.js +10 -10
- package/lib/Entities/TouchInput.d.ts +1 -1
- package/lib/Entities/TouchInput.js +6 -6
- package/lib/Entities/index.d.ts +0 -6
- package/lib/Entities/index.js +0 -6
- package/lib/PresentationManagers/FocusCameraPM.d.ts +2 -1
- package/lib/PresentationManagers/FocusCameraPM.js +4 -4
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +2 -1
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +4 -3
- package/lib/UseCases/FocusCamera/LerpFocusCamera.js +2 -2
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.d.ts +2 -1
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +4 -3
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +2 -1
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +5 -5
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +2 -1
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +2 -1
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +2 -1
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +4 -4
- package/lib/UseCases/FocusCamera/SerializeFocusCamera.js +2 -2
- package/lib/Utilities/LengthConverters.d.ts +4 -0
- package/lib/Utilities/LengthConverters.js +21 -0
- package/lib/Utilities/index.d.ts +1 -0
- package/lib/Utilities/index.js +1 -0
- package/lib/ValueObjects/Angle.d.ts +8 -0
- package/lib/ValueObjects/Angle.js +22 -0
- package/lib/ValueObjects/Color.d.ts +23 -0
- package/lib/ValueObjects/Color.js +791 -0
- package/lib/ValueObjects/LineSegment2D.d.ts +12 -0
- package/lib/ValueObjects/LineSegment2D.js +55 -0
- package/lib/ValueObjects/ParametricLine.d.ts +27 -0
- package/lib/ValueObjects/ParametricLine.js +66 -0
- package/lib/ValueObjects/ParametricPlane.d.ts +20 -0
- package/lib/ValueObjects/ParametricPlane.js +64 -0
- package/lib/ValueObjects/Vector2.d.ts +22 -0
- package/lib/ValueObjects/Vector2.js +87 -0
- package/lib/ValueObjects/Vector3.d.ts +25 -0
- package/lib/ValueObjects/Vector3.js +91 -0
- package/lib/ValueObjects/index.d.ts +7 -0
- package/lib/ValueObjects/index.js +19 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/package.json +1 -1
package/lib/Entities/Babylon.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeBabylon = void 0;
|
|
4
|
-
const
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
5
|
const MemoizedBoolean_1 = require("./MemoizedBoolean");
|
|
6
6
|
const MemoizedVector2_1 = require("./MemoizedVector2");
|
|
7
7
|
const ObserverList_1 = require("./ObserverList");
|
|
8
|
-
const Vector2_1 = require("./Vector2");
|
|
9
8
|
function makeBabylon() {
|
|
10
9
|
return new BabylonImp();
|
|
11
10
|
}
|
|
@@ -15,13 +14,13 @@ class BabylonImp {
|
|
|
15
14
|
this.scenePick = () => {
|
|
16
15
|
console.warn("orignal scene picker");
|
|
17
16
|
return {
|
|
18
|
-
mouseRay:
|
|
17
|
+
mouseRay: ValueObjects_1.ParametricLine.Forward(),
|
|
19
18
|
hit: false,
|
|
20
19
|
};
|
|
21
20
|
};
|
|
22
21
|
this.sceneRay = () => {
|
|
23
22
|
console.warn("orignal scene ray");
|
|
24
|
-
return
|
|
23
|
+
return ValueObjects_1.ParametricLine.Forward();
|
|
25
24
|
};
|
|
26
25
|
this.observers = new ObserverList_1.ObserverList();
|
|
27
26
|
this.updateCanvasSize = () => {
|
|
@@ -79,7 +78,7 @@ class BabylonImp {
|
|
|
79
78
|
this.sceneRay = rayer;
|
|
80
79
|
};
|
|
81
80
|
this.memoizedShowInspector = new MemoizedBoolean_1.MemoizedBoolean(false, this.observers.notify);
|
|
82
|
-
this.memoizedCanvasSize = new MemoizedVector2_1.MemoizedVector2(
|
|
81
|
+
this.memoizedCanvasSize = new MemoizedVector2_1.MemoizedVector2(ValueObjects_1.Vector2.one(), this.observers.notify);
|
|
83
82
|
}
|
|
84
83
|
get showInspector() {
|
|
85
84
|
return this.memoizedShowInspector.val;
|
|
@@ -91,9 +90,9 @@ class BabylonImp {
|
|
|
91
90
|
return this._renderCanvas;
|
|
92
91
|
}
|
|
93
92
|
get canvasSize() {
|
|
94
|
-
return this.memoizedCanvasSize.
|
|
93
|
+
return this.memoizedCanvasSize.val;
|
|
95
94
|
}
|
|
96
95
|
set canvasSize(val) {
|
|
97
|
-
this.memoizedCanvasSize.
|
|
96
|
+
this.memoizedCanvasSize.val = val;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeDevicePreview = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
6
|
function makeDevicePreview() {
|
|
6
7
|
return new DevicePreviewImp();
|
|
7
8
|
}
|
|
@@ -10,21 +11,20 @@ class DevicePreviewImp {
|
|
|
10
11
|
constructor() {
|
|
11
12
|
this.observers = new _1.ObserverList();
|
|
12
13
|
this._usePreview = false;
|
|
13
|
-
this._previewSize =
|
|
14
|
+
this._previewSize = ValueObjects_1.Vector2.zero();
|
|
14
15
|
this.setDevicePreview = (x, y) => {
|
|
15
16
|
if (this._usePreview &&
|
|
16
17
|
this._previewSize.x === x &&
|
|
17
18
|
this._previewSize.y === y)
|
|
18
19
|
return;
|
|
19
20
|
this._usePreview = true;
|
|
20
|
-
this._previewSize
|
|
21
|
-
this._previewSize.y = y;
|
|
21
|
+
this._previewSize = new ValueObjects_1.Vector2(x, y);
|
|
22
22
|
this.observers.notify();
|
|
23
23
|
};
|
|
24
24
|
this.clearDevicePreview = () => {
|
|
25
25
|
if (!this._usePreview)
|
|
26
26
|
return;
|
|
27
|
-
this._previewSize =
|
|
27
|
+
this._previewSize = ValueObjects_1.Vector2.zero();
|
|
28
28
|
this._usePreview = false;
|
|
29
29
|
this.observers.notify();
|
|
30
30
|
};
|
|
@@ -39,6 +39,6 @@ class DevicePreviewImp {
|
|
|
39
39
|
return this._usePreview;
|
|
40
40
|
}
|
|
41
41
|
get previewSize() {
|
|
42
|
-
return this._previewSize
|
|
42
|
+
return this._previewSize;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeFocusCamera = void 0;
|
|
4
4
|
const _1 = require(".");
|
|
5
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
6
|
function makeFocusCamera() {
|
|
6
7
|
return new FocusCameraImp();
|
|
7
8
|
}
|
|
@@ -13,7 +14,7 @@ class FocusCameraImp {
|
|
|
13
14
|
this.defaultAlpha = 0;
|
|
14
15
|
this.defaultBeta = 30;
|
|
15
16
|
this.defaultRadius = 8;
|
|
16
|
-
this.defaultTarget =
|
|
17
|
+
this.defaultTarget = ValueObjects_1.Vector3.zero();
|
|
17
18
|
this.limitRadius = false;
|
|
18
19
|
this.minRadius = 0;
|
|
19
20
|
this.maxRadius = 0;
|
|
@@ -24,13 +25,13 @@ class FocusCameraImp {
|
|
|
24
25
|
this.minBeta = 0;
|
|
25
26
|
this.maxBeta = 0;
|
|
26
27
|
this.limitTarget = false;
|
|
27
|
-
this.maxTargetPosition =
|
|
28
|
-
this.minTargetPosition =
|
|
28
|
+
this.maxTargetPosition = ValueObjects_1.Vector3.zero();
|
|
29
|
+
this.minTargetPosition = ValueObjects_1.Vector3.zero();
|
|
29
30
|
this.observers = new _1.ObserverList();
|
|
30
31
|
this.memoizedAlpha = new _1.MemoizedNumber(0, this.observers.notify);
|
|
31
32
|
this.memoizedBeta = new _1.MemoizedNumber(0, this.observers.notify);
|
|
32
33
|
this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
|
|
33
|
-
this.memoizedTarget = new _1.MemoizedVector3(
|
|
34
|
+
this.memoizedTarget = new _1.MemoizedVector3(ValueObjects_1.Vector3.zero(), this.observers.notify);
|
|
34
35
|
this.setRadiusLimits = (min, max) => {
|
|
35
36
|
if (min < 0) {
|
|
36
37
|
throw new Error("[Orbit Camera] Mininum Radius must be greater >= 0");
|
|
@@ -89,8 +90,8 @@ class FocusCameraImp {
|
|
|
89
90
|
this.limitBeta = false;
|
|
90
91
|
};
|
|
91
92
|
this.setTargetLimits = (min, max) => {
|
|
92
|
-
const minArray = min.
|
|
93
|
-
const maxArray = max.
|
|
93
|
+
const minArray = min.array;
|
|
94
|
+
const maxArray = max.array;
|
|
94
95
|
for (let i = 0; i < 3; i++) {
|
|
95
96
|
if (minArray[i] > maxArray[i]) {
|
|
96
97
|
throw new Error("[Orbit Camera] Min target must be less than the max target");
|
|
@@ -102,8 +103,8 @@ class FocusCameraImp {
|
|
|
102
103
|
this.target = this.target;
|
|
103
104
|
};
|
|
104
105
|
this.clearTargetLimits = () => {
|
|
105
|
-
this.maxTargetPosition =
|
|
106
|
-
this.minTargetPosition =
|
|
106
|
+
this.maxTargetPosition = ValueObjects_1.Vector3.zero();
|
|
107
|
+
this.minTargetPosition = ValueObjects_1.Vector3.zero();
|
|
107
108
|
this.limitTarget = false;
|
|
108
109
|
};
|
|
109
110
|
this.registerLerp = (lerper) => {
|
|
@@ -132,7 +133,7 @@ class FocusCameraImp {
|
|
|
132
133
|
}
|
|
133
134
|
if (data.defaultTarget !== undefined) {
|
|
134
135
|
const { x, y, z } = data.defaultTarget;
|
|
135
|
-
this.defaultTarget = new
|
|
136
|
+
this.defaultTarget = new ValueObjects_1.Vector3(x, y, z);
|
|
136
137
|
}
|
|
137
138
|
if (data.nearClip !== undefined) {
|
|
138
139
|
this.nearClip = data.nearClip;
|
|
@@ -151,7 +152,7 @@ class FocusCameraImp {
|
|
|
151
152
|
}
|
|
152
153
|
if (data.targetLimit !== undefined) {
|
|
153
154
|
const { max, min } = data.targetLimit;
|
|
154
|
-
this.setTargetLimits(new
|
|
155
|
+
this.setTargetLimits(new ValueObjects_1.Vector3(min.x, min.y, min.z), new ValueObjects_1.Vector3(max.x, max.y, max.z));
|
|
155
156
|
}
|
|
156
157
|
};
|
|
157
158
|
this.addObserver = (observer) => {
|
|
@@ -195,13 +196,13 @@ class FocusCameraImp {
|
|
|
195
196
|
this.memoizedRadius.val = clampedVal;
|
|
196
197
|
}
|
|
197
198
|
get target() {
|
|
198
|
-
return this.memoizedTarget.
|
|
199
|
+
return this.memoizedTarget.val;
|
|
199
200
|
}
|
|
200
201
|
set target(val) {
|
|
201
|
-
const targetVals = val.
|
|
202
|
+
const targetVals = val.array;
|
|
202
203
|
if (this.limitTarget) {
|
|
203
|
-
const maxVals = this.maxTargetPosition.
|
|
204
|
-
const minVals = this.minTargetPosition.
|
|
204
|
+
const maxVals = this.maxTargetPosition.array;
|
|
205
|
+
const minVals = this.minTargetPosition.array;
|
|
205
206
|
for (let i = 0; i < 3; i++) {
|
|
206
207
|
let v = targetVals[i];
|
|
207
208
|
v = Math.min(v, maxVals[i]);
|
|
@@ -209,7 +210,7 @@ class FocusCameraImp {
|
|
|
209
210
|
targetVals[i] = v;
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
|
-
this.memoizedTarget.
|
|
213
|
+
this.memoizedTarget.val = ValueObjects_1.Vector3.fromArray(targetVals);
|
|
213
214
|
}
|
|
214
215
|
get direction() {
|
|
215
216
|
const yLength = -Math.sin(this.degToRad(this.beta));
|
|
@@ -217,12 +218,11 @@ class FocusCameraImp {
|
|
|
217
218
|
const alphaRadians = this.degToRad(this.alpha);
|
|
218
219
|
const xLength = -horizontalLenght * Math.sin(alphaRadians);
|
|
219
220
|
const zLength = horizontalLenght * Math.cos(alphaRadians);
|
|
220
|
-
return new
|
|
221
|
+
return new ValueObjects_1.Vector3(xLength, yLength, zLength);
|
|
221
222
|
}
|
|
222
223
|
get cameraPosition() {
|
|
223
|
-
const localOffset = this.direction.
|
|
224
|
-
|
|
225
|
-
return this.target.add(localOffset);
|
|
224
|
+
const localOffset = ValueObjects_1.Vector3.newVectorOfLength(this.direction, -this.radius);
|
|
225
|
+
return ValueObjects_1.Vector3.add(this.target, localOffset);
|
|
226
226
|
}
|
|
227
227
|
degToRad(degrees) {
|
|
228
228
|
return (degrees * Math.PI) / 180;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export interface KeyboardController {
|
|
2
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
3
|
+
onKeyUp?: (e: KeyboardEvent) => void;
|
|
4
|
+
}
|
|
3
5
|
export interface KeyboardInput {
|
|
4
6
|
eventElement: HTMLElement | undefined;
|
|
5
7
|
setEventElement: (eventElement: HTMLElement) => void;
|
|
6
|
-
removeEventElement: (eventElement: HTMLElement) => void;
|
|
7
8
|
clearInputElement: () => void;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
removeKeyDownObserver: (observer: OnKeyDown) => void;
|
|
11
|
-
addKeyUpObserver: (observer: OnKeyUp) => void;
|
|
12
|
-
removeKeyUpObserver: (observer: OnKeyUp) => void;
|
|
9
|
+
registerController: (controller: KeyboardController) => void;
|
|
10
|
+
removeController: (controller: KeyboardController) => void;
|
|
13
11
|
}
|
|
14
12
|
export declare function makeKeyboardInput(): KeyboardInput;
|
|
@@ -1,73 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeKeyboardInput = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
4
|
function makeKeyboardInput() {
|
|
6
5
|
return new KeyboardInputImp();
|
|
7
6
|
}
|
|
8
7
|
exports.makeKeyboardInput = makeKeyboardInput;
|
|
9
8
|
class KeyboardInputImp {
|
|
10
9
|
constructor() {
|
|
10
|
+
this.controllers = [];
|
|
11
11
|
this._eventElement = undefined;
|
|
12
12
|
this.setEventElement = (element) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
element.onkeydown = (e) => {
|
|
18
|
-
this.submitKeyDown(e.code);
|
|
19
|
-
};
|
|
20
|
-
element.onkeyup = (e) => {
|
|
21
|
-
this.submitKeyUp(e.code);
|
|
22
|
-
};
|
|
13
|
+
this.clearInputElement();
|
|
14
|
+
element.addEventListener("keydown", this.submitKeyDown, false);
|
|
15
|
+
element.addEventListener("keyup", this.submitKeyUp, false);
|
|
23
16
|
this._eventElement = element;
|
|
24
17
|
};
|
|
25
|
-
this.removeEventElement = (eventElement) => {
|
|
26
|
-
if (this._eventElement !== eventElement)
|
|
27
|
-
return;
|
|
28
|
-
this._eventElement.onkeydown = null;
|
|
29
|
-
this._eventElement.onkeyup = null;
|
|
30
|
-
this._eventElement = undefined;
|
|
31
|
-
};
|
|
32
18
|
this.clearInputElement = () => {
|
|
33
19
|
if (!this._eventElement)
|
|
34
20
|
return;
|
|
35
|
-
this._eventElement.
|
|
36
|
-
this._eventElement.
|
|
21
|
+
this._eventElement.removeEventListener("keydown", this.submitKeyDown);
|
|
22
|
+
this._eventElement.removeEventListener("keyup", this.submitKeyUp);
|
|
37
23
|
this._eventElement = undefined;
|
|
38
24
|
};
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
25
|
+
this.submitKeyDown = (e) => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
this.controllers.forEach((c) => {
|
|
28
|
+
if (c.onKeyDown) {
|
|
29
|
+
c.onKeyDown(e);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
this.submitKeyUp = (e) => {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
this.controllers.forEach((c) => {
|
|
36
|
+
if (c.onKeyUp) {
|
|
37
|
+
c.onKeyUp(e);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
this.registerController = (controller) => {
|
|
42
|
+
this.controllers.push(controller);
|
|
43
|
+
};
|
|
44
|
+
this.removeController = (controller) => {
|
|
45
|
+
const index = this.controllers.indexOf(controller);
|
|
52
46
|
if (index >= 0) {
|
|
53
|
-
this.
|
|
47
|
+
this.controllers.splice(index, 1);
|
|
54
48
|
}
|
|
55
|
-
this.upObservers.notify(key);
|
|
56
|
-
};
|
|
57
|
-
this.isKeyPressed = (key) => {
|
|
58
|
-
return this.pressedKeys.includes(key);
|
|
59
|
-
};
|
|
60
|
-
this.addKeyDownObserver = (observer) => {
|
|
61
|
-
this.downObservers.add(observer);
|
|
62
|
-
};
|
|
63
|
-
this.removeKeyDownObserver = (observer) => {
|
|
64
|
-
this.downObservers.remove(observer);
|
|
65
|
-
};
|
|
66
|
-
this.addKeyUpObserver = (observer) => {
|
|
67
|
-
this.upObservers.add(observer);
|
|
68
|
-
};
|
|
69
|
-
this.removeKeyUpObserver = (observer) => {
|
|
70
|
-
this.upObservers.remove(observer);
|
|
71
49
|
};
|
|
72
50
|
}
|
|
73
51
|
get eventElement() {
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import { Vector2 } from "
|
|
1
|
+
import { Vector2 } from "../ValueObjects";
|
|
2
2
|
export declare class MemoizedVector2 {
|
|
3
3
|
private _val;
|
|
4
|
-
get
|
|
5
|
-
set
|
|
6
|
-
get y(): number;
|
|
7
|
-
set y(y: number);
|
|
8
|
-
getVector(): Vector2;
|
|
9
|
-
setVector(vec: Vector2): void;
|
|
4
|
+
get val(): Vector2;
|
|
5
|
+
set val(v: Vector2);
|
|
10
6
|
private onChangeCallback;
|
|
11
7
|
constructor(initialValue: Vector2, onChangeCallback: () => void);
|
|
12
8
|
}
|
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MemoizedVector2 = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
4
5
|
class MemoizedVector2 {
|
|
5
6
|
constructor(initialValue, onChangeCallback) {
|
|
6
|
-
this._val = initialValue
|
|
7
|
+
this._val = initialValue;
|
|
7
8
|
this.onChangeCallback = onChangeCallback;
|
|
8
9
|
}
|
|
9
|
-
get
|
|
10
|
-
return this._val
|
|
10
|
+
get val() {
|
|
11
|
+
return this._val;
|
|
11
12
|
}
|
|
12
|
-
set
|
|
13
|
-
if (this._val
|
|
13
|
+
set val(v) {
|
|
14
|
+
if (ValueObjects_1.Vector2.equal(v, this._val))
|
|
14
15
|
return;
|
|
15
|
-
this._val
|
|
16
|
-
this.onChangeCallback();
|
|
17
|
-
}
|
|
18
|
-
get y() {
|
|
19
|
-
return this._val.y;
|
|
20
|
-
}
|
|
21
|
-
set y(y) {
|
|
22
|
-
if (this._val.y === y)
|
|
23
|
-
return;
|
|
24
|
-
this._val.y = y;
|
|
25
|
-
this.onChangeCallback();
|
|
26
|
-
}
|
|
27
|
-
getVector() {
|
|
28
|
-
return this._val.copy();
|
|
29
|
-
}
|
|
30
|
-
setVector(vec) {
|
|
31
|
-
if (vec.x === this._val.x && vec.y === this._val.y)
|
|
32
|
-
return;
|
|
33
|
-
this._val = vec.copy();
|
|
16
|
+
this._val = v;
|
|
34
17
|
this.onChangeCallback();
|
|
35
18
|
}
|
|
36
19
|
}
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import { Vector3 } from "
|
|
1
|
+
import { Vector3 } from "../ValueObjects/Vector3";
|
|
2
2
|
export declare class MemoizedVector3 {
|
|
3
3
|
private _val;
|
|
4
|
-
get
|
|
5
|
-
set
|
|
6
|
-
get y(): number;
|
|
7
|
-
set y(y: number);
|
|
8
|
-
get z(): number;
|
|
9
|
-
set z(z: number);
|
|
10
|
-
getVector(): Vector3;
|
|
11
|
-
setVector(vec: Vector3): void;
|
|
4
|
+
get val(): Vector3;
|
|
5
|
+
set val(v: Vector3);
|
|
12
6
|
private onChangeCallback;
|
|
13
7
|
constructor(initialValue: Vector3, onChangeCallback: () => void);
|
|
14
8
|
}
|
|
@@ -1,45 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MemoizedVector3 = void 0;
|
|
4
|
+
const Vector3_1 = require("../ValueObjects/Vector3");
|
|
4
5
|
class MemoizedVector3 {
|
|
5
6
|
constructor(initialValue, onChangeCallback) {
|
|
6
|
-
this._val = initialValue
|
|
7
|
+
this._val = initialValue;
|
|
7
8
|
this.onChangeCallback = onChangeCallback;
|
|
8
9
|
}
|
|
9
|
-
get
|
|
10
|
-
return this._val
|
|
10
|
+
get val() {
|
|
11
|
+
return this._val;
|
|
11
12
|
}
|
|
12
|
-
set
|
|
13
|
-
if (this._val
|
|
13
|
+
set val(v) {
|
|
14
|
+
if (Vector3_1.Vector3.equal(v, this._val))
|
|
14
15
|
return;
|
|
15
|
-
this._val
|
|
16
|
-
this.onChangeCallback();
|
|
17
|
-
}
|
|
18
|
-
get y() {
|
|
19
|
-
return this._val.y;
|
|
20
|
-
}
|
|
21
|
-
set y(y) {
|
|
22
|
-
if (this._val.y === y)
|
|
23
|
-
return;
|
|
24
|
-
this._val.y = y;
|
|
25
|
-
this.onChangeCallback();
|
|
26
|
-
}
|
|
27
|
-
get z() {
|
|
28
|
-
return this._val.z;
|
|
29
|
-
}
|
|
30
|
-
set z(z) {
|
|
31
|
-
if (this._val.z === z)
|
|
32
|
-
return;
|
|
33
|
-
this._val.z = z;
|
|
34
|
-
this.onChangeCallback();
|
|
35
|
-
}
|
|
36
|
-
getVector() {
|
|
37
|
-
return this._val.copy();
|
|
38
|
-
}
|
|
39
|
-
setVector(vec) {
|
|
40
|
-
if (vec.x === this._val.x && vec.y === this._val.y && vec.z === this._val.z)
|
|
41
|
-
return;
|
|
42
|
-
this._val = vec.copy();
|
|
16
|
+
this._val = v;
|
|
43
17
|
this.onChangeCallback();
|
|
44
18
|
}
|
|
45
19
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeMouseInput = void 0;
|
|
4
|
-
const
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
5
|
function makeMouseInput() {
|
|
6
6
|
return new MouseInputImp();
|
|
7
7
|
}
|
|
@@ -63,7 +63,7 @@ class MouseInputImp {
|
|
|
63
63
|
return;
|
|
64
64
|
const deltaX = this.pressEvent.screenX - e.screenX;
|
|
65
65
|
const deltaY = this.pressEvent.screenY - e.screenY;
|
|
66
|
-
const delta = new
|
|
66
|
+
const delta = new ValueObjects_1.Vector2(deltaX, deltaY);
|
|
67
67
|
if (delta.magnitued < this.maxClickMovement) {
|
|
68
68
|
this.controllers.forEach((c) => {
|
|
69
69
|
if (c.onClick) {
|
|
@@ -84,7 +84,7 @@ class MouseInputImp {
|
|
|
84
84
|
return;
|
|
85
85
|
const deltaX = this.pressEvent.screenX - e.screenX;
|
|
86
86
|
const deltaY = this.pressEvent.screenY - e.screenY;
|
|
87
|
-
const delta = new
|
|
87
|
+
const delta = new ValueObjects_1.Vector2(deltaX, deltaY);
|
|
88
88
|
if (delta.magnitued > this.maxClickMovement) {
|
|
89
89
|
this.pressEvent = undefined;
|
|
90
90
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParametricLine = void 0;
|
|
4
|
-
const Vector3_1 = require("
|
|
4
|
+
const Vector3_1 = require("../ValueObjects/Vector3");
|
|
5
5
|
class ParametricLine {
|
|
6
6
|
constructor(parameters) {
|
|
7
7
|
this.x0 = parameters.x0;
|
|
@@ -12,7 +12,7 @@ class ParametricLine {
|
|
|
12
12
|
this.c = parameters.c;
|
|
13
13
|
}
|
|
14
14
|
static FromTwoPoint(p1, p2) {
|
|
15
|
-
const dir =
|
|
15
|
+
const dir = Vector3_1.Vector3.subtract(p2, p1).unit;
|
|
16
16
|
return this.FromPointDirection(p1, dir);
|
|
17
17
|
}
|
|
18
18
|
static FromPointDirection(point, direction) {
|
|
@@ -26,32 +26,32 @@ class ParametricLine {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
static Forward() {
|
|
29
|
-
const p = Vector3_1.Vector3.
|
|
29
|
+
const p = Vector3_1.Vector3.zero();
|
|
30
30
|
const d = new Vector3_1.Vector3(0, 0, 1);
|
|
31
31
|
return this.FromPointDirection(p, d);
|
|
32
32
|
}
|
|
33
33
|
static Backward() {
|
|
34
|
-
const p = Vector3_1.Vector3.
|
|
34
|
+
const p = Vector3_1.Vector3.zero();
|
|
35
35
|
const d = new Vector3_1.Vector3(0, 0, -1);
|
|
36
36
|
return this.FromPointDirection(p, d);
|
|
37
37
|
}
|
|
38
38
|
static Up() {
|
|
39
|
-
const p = Vector3_1.Vector3.
|
|
39
|
+
const p = Vector3_1.Vector3.zero();
|
|
40
40
|
const d = new Vector3_1.Vector3(0, 1, 0);
|
|
41
41
|
return this.FromPointDirection(p, d);
|
|
42
42
|
}
|
|
43
43
|
static Down() {
|
|
44
|
-
const p = Vector3_1.Vector3.
|
|
44
|
+
const p = Vector3_1.Vector3.zero();
|
|
45
45
|
const d = new Vector3_1.Vector3(0, -1, 0);
|
|
46
46
|
return this.FromPointDirection(p, d);
|
|
47
47
|
}
|
|
48
48
|
static Left() {
|
|
49
|
-
const p = Vector3_1.Vector3.
|
|
49
|
+
const p = Vector3_1.Vector3.zero();
|
|
50
50
|
const d = new Vector3_1.Vector3(-1, 0, 0);
|
|
51
51
|
return this.FromPointDirection(p, d);
|
|
52
52
|
}
|
|
53
53
|
static Right() {
|
|
54
|
-
const p = Vector3_1.Vector3.
|
|
54
|
+
const p = Vector3_1.Vector3.zero();
|
|
55
55
|
const d = new Vector3_1.Vector3(1, 0, 0);
|
|
56
56
|
return this.FromPointDirection(p, d);
|
|
57
57
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ParametricLine } from "./ParametricLine";
|
|
2
|
-
import { Vector3 } from "
|
|
2
|
+
import { Vector3 } from "../ValueObjects/Vector3";
|
|
3
3
|
export interface PlaneParameters {
|
|
4
4
|
a: number;
|
|
5
5
|
b: number;
|
|
@@ -7,13 +7,13 @@ export interface PlaneParameters {
|
|
|
7
7
|
d: number;
|
|
8
8
|
}
|
|
9
9
|
export declare class ParametricPlane {
|
|
10
|
+
private point;
|
|
11
|
+
private normal;
|
|
10
12
|
static FromPointNormal(point: Vector3, normal: Vector3): ParametricPlane;
|
|
11
13
|
static FromThreePoints(A: Vector3, B: Vector3, C: Vector3): ParametricPlane;
|
|
12
14
|
static XY(): ParametricPlane;
|
|
13
15
|
static ZX(): ParametricPlane;
|
|
14
16
|
static YZ(): ParametricPlane;
|
|
15
|
-
private point;
|
|
16
|
-
private normal;
|
|
17
17
|
getParameters(): PlaneParameters;
|
|
18
18
|
intersectLine(line: ParametricLine): Vector3 | undefined;
|
|
19
19
|
constructor(point: Vector3, normal: Vector3);
|
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ParametricPlane = void 0;
|
|
4
|
-
const Vector3_1 = require("
|
|
4
|
+
const Vector3_1 = require("../ValueObjects/Vector3");
|
|
5
5
|
class ParametricPlane {
|
|
6
6
|
constructor(point, normal) {
|
|
7
|
-
this.point = point
|
|
8
|
-
this.normal = normal
|
|
7
|
+
this.point = point;
|
|
8
|
+
this.normal = normal;
|
|
9
9
|
}
|
|
10
10
|
static FromPointNormal(point, normal) {
|
|
11
11
|
return new ParametricPlane(point, normal);
|
|
12
12
|
}
|
|
13
13
|
static FromThreePoints(A, B, C) {
|
|
14
14
|
const point = A;
|
|
15
|
-
const AB =
|
|
16
|
-
const AC =
|
|
17
|
-
const normal =
|
|
15
|
+
const AB = Vector3_1.Vector3.subtract(B, A);
|
|
16
|
+
const AC = Vector3_1.Vector3.subtract(C, A);
|
|
17
|
+
const normal = Vector3_1.Vector3.cross(AB, AC);
|
|
18
18
|
return new ParametricPlane(point, normal);
|
|
19
19
|
}
|
|
20
20
|
static XY() {
|
|
21
|
-
const p = Vector3_1.Vector3.
|
|
21
|
+
const p = Vector3_1.Vector3.zero();
|
|
22
22
|
const n = new Vector3_1.Vector3(0, 0, 1);
|
|
23
23
|
return new ParametricPlane(p, n);
|
|
24
24
|
}
|
|
25
25
|
static ZX() {
|
|
26
|
-
const p = Vector3_1.Vector3.
|
|
26
|
+
const p = Vector3_1.Vector3.zero();
|
|
27
27
|
const n = new Vector3_1.Vector3(0, 1, 0);
|
|
28
28
|
return new ParametricPlane(p, n);
|
|
29
29
|
}
|
|
30
30
|
static YZ() {
|
|
31
|
-
const p = Vector3_1.Vector3.
|
|
31
|
+
const p = Vector3_1.Vector3.zero();
|
|
32
32
|
const n = new Vector3_1.Vector3(1, 0, 0);
|
|
33
33
|
return new ParametricPlane(p, n);
|
|
34
34
|
}
|
|
@@ -36,7 +36,7 @@ class ParametricPlane {
|
|
|
36
36
|
const a = this.normal.x;
|
|
37
37
|
const b = this.normal.y;
|
|
38
38
|
const c = this.normal.z;
|
|
39
|
-
let d =
|
|
39
|
+
let d = Vector3_1.Vector3.dot(this.point, this.normal);
|
|
40
40
|
if (d !== 0) {
|
|
41
41
|
d *= -1;
|
|
42
42
|
}
|