@vived/app 2.16.0 → 2.18.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/lib/Entities/TouchInput.js +8 -4
- package/lib/UseCases/LerpVector3.d.ts +26 -0
- package/lib/UseCases/LerpVector3.js +66 -0
- package/lib/UseCases/index.d.ts +1 -0
- package/lib/UseCases/index.js +1 -0
- package/lib/Utilities/lerpNumber.d.ts +1 -0
- package/lib/Utilities/lerpNumber.js +18 -0
- package/lib/ValueObjects/Vector3.d.ts +1 -0
- package/lib/ValueObjects/Vector3.js +7 -0
- 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/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/OrbitCameraPM.d.ts +0 -14
- package/lib/PresentationManagers/OrbitCameraPM.js +0 -31
- 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
package/lib/Entities/Color.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Color = void 0;
|
|
4
|
-
class Color {
|
|
5
|
-
constructor(r, g, b, a = 255) {
|
|
6
|
-
this.equal = (otherColor) => {
|
|
7
|
-
if (otherColor.r === this.r &&
|
|
8
|
-
otherColor.g === this.g &&
|
|
9
|
-
otherColor.b === this.b &&
|
|
10
|
-
otherColor.a === this.a) {
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
this.copy = () => {
|
|
18
|
-
return new Color(this.r, this.g, this.b, this.a);
|
|
19
|
-
};
|
|
20
|
-
this.r = r;
|
|
21
|
-
this.g = g;
|
|
22
|
-
this.b = b;
|
|
23
|
-
this.a = a;
|
|
24
|
-
}
|
|
25
|
-
static White() {
|
|
26
|
-
return new Color(255, 255, 255, 255);
|
|
27
|
-
}
|
|
28
|
-
static Black() {
|
|
29
|
-
return new Color(0, 0, 0, 255);
|
|
30
|
-
}
|
|
31
|
-
static Red() {
|
|
32
|
-
return new Color(255, 0, 0, 255);
|
|
33
|
-
}
|
|
34
|
-
static Green() {
|
|
35
|
-
return new Color(0, 255, 0, 255);
|
|
36
|
-
}
|
|
37
|
-
static Blue() {
|
|
38
|
-
return new Color(0, 0, 255, 255);
|
|
39
|
-
}
|
|
40
|
-
static Yellow() {
|
|
41
|
-
return new Color(255, 0, 255, 255);
|
|
42
|
-
}
|
|
43
|
-
static Gray() {
|
|
44
|
-
return new Color(192, 192, 192, 255);
|
|
45
|
-
}
|
|
46
|
-
get rPercent() {
|
|
47
|
-
return this.r / 255;
|
|
48
|
-
}
|
|
49
|
-
get gPercent() {
|
|
50
|
-
return this.g / 255;
|
|
51
|
-
}
|
|
52
|
-
get bPercent() {
|
|
53
|
-
return this.b / 255;
|
|
54
|
-
}
|
|
55
|
-
get aPercent() {
|
|
56
|
-
return this.a / 255;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
exports.Color = Color;
|
|
@@ -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;
|
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeOrbitCamera = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
function makeOrbitCamera() {
|
|
6
|
-
return new OrbitCameraImp();
|
|
7
|
-
}
|
|
8
|
-
exports.makeOrbitCamera = makeOrbitCamera;
|
|
9
|
-
class OrbitCameraImp {
|
|
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();
|
|
33
|
-
this.observers = new _1.ObserverList();
|
|
34
|
-
this.memoizedAlpha = new _1.MemoizedNumber(0, this.observers.notify);
|
|
35
|
-
this.memoizedBeta = new _1.MemoizedNumber(0, this.observers.notify);
|
|
36
|
-
this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
|
|
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
|
-
};
|
|
113
|
-
this.registerLerp = (lerper) => {
|
|
114
|
-
if (this.currentLerp) {
|
|
115
|
-
this.currentLerp.cancelLerp();
|
|
116
|
-
}
|
|
117
|
-
this.currentLerp = lerper;
|
|
118
|
-
};
|
|
119
|
-
this.lerpCompleted = () => {
|
|
120
|
-
this.currentLerp = undefined;
|
|
121
|
-
};
|
|
122
|
-
this.cancelLerp = () => {
|
|
123
|
-
var _a;
|
|
124
|
-
(_a = this.currentLerp) === null || _a === void 0 ? void 0 : _a.cancelLerp();
|
|
125
|
-
this.currentLerp = undefined;
|
|
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
|
-
};
|
|
173
|
-
this.addObserver = (observer) => {
|
|
174
|
-
this.observers.add(observer);
|
|
175
|
-
};
|
|
176
|
-
this.removeObserver = (observer) => {
|
|
177
|
-
this.observers.remove(observer);
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
get alpha() {
|
|
181
|
-
return this.memoizedAlpha.val;
|
|
182
|
-
}
|
|
183
|
-
set alpha(val) {
|
|
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;
|
|
190
|
-
}
|
|
191
|
-
get beta() {
|
|
192
|
-
return this.memoizedBeta.val;
|
|
193
|
-
}
|
|
194
|
-
set beta(val) {
|
|
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;
|
|
201
|
-
}
|
|
202
|
-
get radius() {
|
|
203
|
-
return this.memoizedRadius.val;
|
|
204
|
-
}
|
|
205
|
-
set radius(val) {
|
|
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;
|
|
212
|
-
}
|
|
213
|
-
get target() {
|
|
214
|
-
return this.memoizedTarget.getVector();
|
|
215
|
-
}
|
|
216
|
-
set target(val) {
|
|
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]));
|
|
229
|
-
}
|
|
230
|
-
clampAngle(angle) {
|
|
231
|
-
const isNegative = angle < 0 ? true : false;
|
|
232
|
-
const absAngle = Math.abs(angle);
|
|
233
|
-
const revolutions = Math.floor(absAngle / 360);
|
|
234
|
-
let angleWithoutRevolutions = absAngle - revolutions * 360;
|
|
235
|
-
if (angleWithoutRevolutions > 180) {
|
|
236
|
-
angleWithoutRevolutions = angleWithoutRevolutions - 360;
|
|
237
|
-
}
|
|
238
|
-
if (isNegative) {
|
|
239
|
-
angleWithoutRevolutions *= -1;
|
|
240
|
-
}
|
|
241
|
-
return angleWithoutRevolutions;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Vector3 } from "../ValueObjects/Vector3";
|
|
2
|
-
export interface LineParameters {
|
|
3
|
-
x0: number;
|
|
4
|
-
y0: number;
|
|
5
|
-
z0: number;
|
|
6
|
-
a: number;
|
|
7
|
-
b: number;
|
|
8
|
-
c: number;
|
|
9
|
-
}
|
|
10
|
-
export declare class ParametricLine {
|
|
11
|
-
private x0;
|
|
12
|
-
private y0;
|
|
13
|
-
private z0;
|
|
14
|
-
private a;
|
|
15
|
-
private b;
|
|
16
|
-
private c;
|
|
17
|
-
static FromTwoPoint(p1: Vector3, p2: Vector3): ParametricLine;
|
|
18
|
-
static FromPointDirection(point: Vector3, direction: Vector3): ParametricLine;
|
|
19
|
-
static Forward(): ParametricLine;
|
|
20
|
-
static Backward(): ParametricLine;
|
|
21
|
-
static Up(): ParametricLine;
|
|
22
|
-
static Down(): ParametricLine;
|
|
23
|
-
static Left(): ParametricLine;
|
|
24
|
-
static Right(): ParametricLine;
|
|
25
|
-
getPointAtDistance(distance: number): Vector3;
|
|
26
|
-
getParameters(): LineParameters;
|
|
27
|
-
copy(): ParametricLine;
|
|
28
|
-
constructor(parameters: LineParameters);
|
|
29
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParametricLine = void 0;
|
|
4
|
-
const Vector3_1 = require("../ValueObjects/Vector3");
|
|
5
|
-
class ParametricLine {
|
|
6
|
-
constructor(parameters) {
|
|
7
|
-
this.x0 = parameters.x0;
|
|
8
|
-
this.y0 = parameters.y0;
|
|
9
|
-
this.z0 = parameters.z0;
|
|
10
|
-
this.a = parameters.a;
|
|
11
|
-
this.b = parameters.b;
|
|
12
|
-
this.c = parameters.c;
|
|
13
|
-
}
|
|
14
|
-
static FromTwoPoint(p1, p2) {
|
|
15
|
-
const dir = Vector3_1.Vector3.subtract(p2, p1).unit;
|
|
16
|
-
return this.FromPointDirection(p1, dir);
|
|
17
|
-
}
|
|
18
|
-
static FromPointDirection(point, direction) {
|
|
19
|
-
return new ParametricLine({
|
|
20
|
-
x0: point.x,
|
|
21
|
-
y0: point.y,
|
|
22
|
-
z0: point.z,
|
|
23
|
-
a: direction.x,
|
|
24
|
-
b: direction.y,
|
|
25
|
-
c: direction.z,
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
static Forward() {
|
|
29
|
-
const p = Vector3_1.Vector3.zero();
|
|
30
|
-
const d = new Vector3_1.Vector3(0, 0, 1);
|
|
31
|
-
return this.FromPointDirection(p, d);
|
|
32
|
-
}
|
|
33
|
-
static Backward() {
|
|
34
|
-
const p = Vector3_1.Vector3.zero();
|
|
35
|
-
const d = new Vector3_1.Vector3(0, 0, -1);
|
|
36
|
-
return this.FromPointDirection(p, d);
|
|
37
|
-
}
|
|
38
|
-
static Up() {
|
|
39
|
-
const p = Vector3_1.Vector3.zero();
|
|
40
|
-
const d = new Vector3_1.Vector3(0, 1, 0);
|
|
41
|
-
return this.FromPointDirection(p, d);
|
|
42
|
-
}
|
|
43
|
-
static Down() {
|
|
44
|
-
const p = Vector3_1.Vector3.zero();
|
|
45
|
-
const d = new Vector3_1.Vector3(0, -1, 0);
|
|
46
|
-
return this.FromPointDirection(p, d);
|
|
47
|
-
}
|
|
48
|
-
static Left() {
|
|
49
|
-
const p = Vector3_1.Vector3.zero();
|
|
50
|
-
const d = new Vector3_1.Vector3(-1, 0, 0);
|
|
51
|
-
return this.FromPointDirection(p, d);
|
|
52
|
-
}
|
|
53
|
-
static Right() {
|
|
54
|
-
const p = Vector3_1.Vector3.zero();
|
|
55
|
-
const d = new Vector3_1.Vector3(1, 0, 0);
|
|
56
|
-
return this.FromPointDirection(p, d);
|
|
57
|
-
}
|
|
58
|
-
getPointAtDistance(distance) {
|
|
59
|
-
const x = this.x0 + this.a * distance;
|
|
60
|
-
const y = this.y0 + this.b * distance;
|
|
61
|
-
const z = this.z0 + this.c * distance;
|
|
62
|
-
return new Vector3_1.Vector3(x, y, z);
|
|
63
|
-
}
|
|
64
|
-
getParameters() {
|
|
65
|
-
return {
|
|
66
|
-
x0: this.x0,
|
|
67
|
-
y0: this.y0,
|
|
68
|
-
z0: this.z0,
|
|
69
|
-
a: this.a,
|
|
70
|
-
b: this.b,
|
|
71
|
-
c: this.c,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
copy() {
|
|
75
|
-
const parameters = this.getParameters();
|
|
76
|
-
return new ParametricLine(parameters);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.ParametricLine = ParametricLine;
|