@vived/app 3.5.0 → 3.5.2
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/AppObjectComponents/SceneRoot/UC/SerializeSceneRoot.js +22 -6
- package/lib/AppObjectComponents/StoredView/Entities/StoredView.d.ts +13 -0
- package/lib/AppObjectComponents/StoredView/Entities/StoredView.js +64 -0
- package/lib/AppObjectComponents/StoredView/UC/SerializeStoredView.d.ts +27 -0
- package/lib/AppObjectComponents/StoredView/UC/SerializeStoredView.js +82 -0
- package/lib/AppObjectComponents/StoredView/index.d.ts +2 -0
- package/lib/AppObjectComponents/StoredView/index.js +14 -0
- package/lib/Entities/FocusCamera.d.ts +70 -0
- package/lib/Entities/FocusCamera.js +272 -0
- package/lib/Entities/MemoizedBoolean.d.ts +8 -0
- package/lib/Entities/MemoizedBoolean.js +22 -0
- package/lib/Entities/MemoizedNumber.d.ts +8 -0
- package/lib/Entities/MemoizedNumber.js +22 -0
- package/lib/Entities/MemoizedQuaternion.d.ts +9 -0
- package/lib/Entities/MemoizedQuaternion.js +23 -0
- package/lib/Entities/MemoizedString.d.ts +8 -0
- package/lib/Entities/MemoizedString.js +22 -0
- package/lib/Entities/MemoizedVector2.d.ts +9 -0
- package/lib/Entities/MemoizedVector2.js +23 -0
- package/lib/Entities/MemoizedVector3.d.ts +9 -0
- package/lib/Entities/MemoizedVector3.js +23 -0
- package/lib/Entities/MeshModel.d.ts +68 -0
- package/lib/Entities/MeshModel.js +174 -0
- package/lib/Entities/ModelObject.d.ts +10 -0
- package/lib/Entities/ModelObject.js +42 -0
- package/lib/PresentationManagers/FocusCameraPM.d.ts +15 -0
- package/lib/PresentationManagers/FocusCameraPM.js +31 -0
- package/lib/PresentationManagers/FocusCameraPosRotPM.d.ts +13 -0
- package/lib/PresentationManagers/FocusCameraPosRotPM.js +28 -0
- package/lib/PresentationManagers/SceneModel/SceneMeshOverlayPM.d.ts +15 -0
- package/lib/PresentationManagers/SceneModel/SceneMeshOverlayPM.js +34 -0
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +17 -0
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +64 -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 +11 -0
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +36 -0
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +11 -0
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +36 -0
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +11 -0
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +26 -0
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +11 -0
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +33 -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/SceneModel/SerializeActiveModel.d.ts +18 -0
- package/lib/UseCases/SceneModel/SerializeActiveModel.js +74 -0
- package/lib/UseCases/SceneModel/SetMeshesEnabledHook.d.ts +7 -0
- package/lib/UseCases/SceneModel/SetMeshesEnabledHook.js +22 -0
- package/lib/UseCases/SceneModel/SetSceneModelMeshOverlayColor.d.ts +2 -0
- package/lib/UseCases/SceneModel/SetSceneModelMeshOverlayColor.js +13 -0
- package/lib/UseCases/SceneModel/index.d.ts +3 -0
- package/lib/UseCases/SceneModel/index.js +3 -0
- package/lib/UseCases/SceneModel/loadNewModel.d.ts +2 -2
- package/lib/UseCases/SceneModel/loadNewModel.js +17 -15
- package/lib/UseCases/SceneObjects/PeelSceneObject.d.ts +18 -0
- package/lib/UseCases/SceneObjects/PeelSceneObject.js +61 -0
- package/lib/UseCases/SceneObjects/index.d.ts +1 -0
- package/lib/UseCases/SceneObjects/index.js +13 -0
- package/package.json +1 -1
- package/lib/AppObject/IsEnabledPM.d.ts +0 -11
- package/lib/AppObject/IsEnabledPM.js +0 -29
- package/lib/AppObjectComponents/Transform3D/UseCases/getStickUC.d.ts +0 -3
- package/lib/AppObjectComponents/Transform3D/UseCases/getStickUC.js +0 -8
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.makeSerializeSceneRoot = exports.SerializeSceneRoot = void 0;
|
|
4
4
|
const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
|
|
5
5
|
const ValueObjects_1 = require("../../../ValueObjects");
|
|
6
|
+
const StoredView_1 = require("../../StoredView");
|
|
6
7
|
const SceneRoot_1 = require("../Entities/SceneRoot");
|
|
7
8
|
class SerializeSceneRoot extends AppObjectUC_1.AppObjectUC {
|
|
8
9
|
constructor() {
|
|
@@ -27,6 +28,11 @@ class SerializeSceneRootImp extends SerializeSceneRoot {
|
|
|
27
28
|
this.dispose();
|
|
28
29
|
return;
|
|
29
30
|
}
|
|
31
|
+
this.storedView = appObject.getComponent(StoredView_1.StoredView.type);
|
|
32
|
+
if (!this.storedView) {
|
|
33
|
+
console.warn("SerializeSceneRoot UC has been added to an App Object that does not have a StoredView Entity. Stored view won't work until one is added to the UC");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
30
36
|
stateMachine.registerSerializedSystem(this);
|
|
31
37
|
}
|
|
32
38
|
getSystemState() {
|
|
@@ -34,12 +40,22 @@ class SerializeSceneRootImp extends SerializeSceneRoot {
|
|
|
34
40
|
console.warn("[SerializeSceneRoot] No scene root entity");
|
|
35
41
|
return {};
|
|
36
42
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
if (this.storedView && this.storedView.hasStoredView) {
|
|
44
|
+
const data = {
|
|
45
|
+
position: this.storedView.position.dto,
|
|
46
|
+
rotation: this.storedView.rotation.dto,
|
|
47
|
+
scale: this.storedView.scale,
|
|
48
|
+
};
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
const data = {
|
|
53
|
+
position: this.sceneRoot.position.dto,
|
|
54
|
+
rotation: this.sceneRoot.rotation.dto,
|
|
55
|
+
scale: this.sceneRoot.scale,
|
|
56
|
+
};
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
43
59
|
}
|
|
44
60
|
applySystemState(serializedState, version, transitionTime) {
|
|
45
61
|
try {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AppObject } from "../../../AppObject/AppObject";
|
|
2
|
+
import { AppObjectEntity } from "../../../AppObject/AppObjectEntity";
|
|
3
|
+
import { AppObjectRepo } from "../../../AppObject/AppObjectRepo";
|
|
4
|
+
import { Quaternion, Vector3 } from "../../../ValueObjects";
|
|
5
|
+
export declare abstract class StoredView extends AppObjectEntity {
|
|
6
|
+
static readonly type = "STORED_VIEW";
|
|
7
|
+
abstract position: Vector3;
|
|
8
|
+
abstract rotation: Quaternion;
|
|
9
|
+
abstract scale: number;
|
|
10
|
+
abstract hasStoredView: boolean;
|
|
11
|
+
static get(appObjects: AppObjectRepo): StoredView | undefined;
|
|
12
|
+
}
|
|
13
|
+
export declare function makeStoredView(appObj: AppObject): StoredView;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeStoredView = exports.StoredView = void 0;
|
|
4
|
+
const AppObjectEntity_1 = require("../../../AppObject/AppObjectEntity");
|
|
5
|
+
const Entities_1 = require("../../../Entities");
|
|
6
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
7
|
+
class StoredView extends AppObjectEntity_1.AppObjectEntity {
|
|
8
|
+
static get(appObjects) {
|
|
9
|
+
const repo = appObjects.getAllComponents(StoredView.type);
|
|
10
|
+
if (repo.length === 0) {
|
|
11
|
+
console.warn("[StoredView] Unable to find Scene Root Entity. Add one on Mount");
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
else if (repo.length > 1) {
|
|
15
|
+
console.warn("[StoredView] Multiple Scene Root Entity have been found. There should only be one. Using the first one");
|
|
16
|
+
}
|
|
17
|
+
return repo[0];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.StoredView = StoredView;
|
|
21
|
+
StoredView.type = "STORED_VIEW";
|
|
22
|
+
function makeStoredView(appObj) {
|
|
23
|
+
return new StoredViewImp(appObj);
|
|
24
|
+
}
|
|
25
|
+
exports.makeStoredView = makeStoredView;
|
|
26
|
+
class StoredViewImp extends StoredView {
|
|
27
|
+
constructor(appObject) {
|
|
28
|
+
super(appObject, StoredView.type);
|
|
29
|
+
this._position = ValueObjects_1.Vector3.Zero();
|
|
30
|
+
this._rotation = ValueObjects_1.Quaternion.Identity();
|
|
31
|
+
this._memoizedScale = new Entities_1.MemoizedNumber(1, this.notifyOnChange);
|
|
32
|
+
this._memoizedHasStoredView = new Entities_1.MemoizedBoolean(false, this.notifyOnChange);
|
|
33
|
+
}
|
|
34
|
+
get position() {
|
|
35
|
+
return this._position;
|
|
36
|
+
}
|
|
37
|
+
set position(p) {
|
|
38
|
+
if (ValueObjects_1.Vector3.Equal(this._position, p))
|
|
39
|
+
return;
|
|
40
|
+
this._position = p;
|
|
41
|
+
this.notifyOnChange();
|
|
42
|
+
}
|
|
43
|
+
get rotation() {
|
|
44
|
+
return this._rotation;
|
|
45
|
+
}
|
|
46
|
+
set rotation(r) {
|
|
47
|
+
if (ValueObjects_1.Quaternion.Equal(this._rotation, r))
|
|
48
|
+
return;
|
|
49
|
+
this._rotation = r;
|
|
50
|
+
this.notifyOnChange();
|
|
51
|
+
}
|
|
52
|
+
get scale() {
|
|
53
|
+
return this._memoizedScale.val;
|
|
54
|
+
}
|
|
55
|
+
set scale(s) {
|
|
56
|
+
this._memoizedScale.val = s;
|
|
57
|
+
}
|
|
58
|
+
get hasStoredView() {
|
|
59
|
+
return this._memoizedHasStoredView.val;
|
|
60
|
+
}
|
|
61
|
+
set hasStoredView(hasStoredValue) {
|
|
62
|
+
this._memoizedHasStoredView.val = hasStoredValue;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AppObject } from "../../../AppObject/AppObject";
|
|
2
|
+
import { AppObjectUC } from "../../../AppObject/AppObjectUC";
|
|
3
|
+
import { SerializedSystem, StateMachine } from "../../../Entities";
|
|
4
|
+
export declare abstract class SerializeStoredView extends AppObjectUC implements SerializedSystem {
|
|
5
|
+
static readonly type = "SerializeStoredView";
|
|
6
|
+
name: string;
|
|
7
|
+
abstract seriliziationVersion: number;
|
|
8
|
+
abstract getSystemState(): object;
|
|
9
|
+
abstract applySystemState(state: object, version: number): void;
|
|
10
|
+
abstract applyDefaultState(transitionDuration: number): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function makeSerializeStoredView(appObject: AppObject, stateMachine: StateMachine): SerializeStoredView;
|
|
13
|
+
export interface StoredViewDataV1 {
|
|
14
|
+
position: {
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
z: number;
|
|
18
|
+
};
|
|
19
|
+
rotation: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
z: number;
|
|
23
|
+
w: number;
|
|
24
|
+
};
|
|
25
|
+
scale: number;
|
|
26
|
+
hasStoredView: boolean;
|
|
27
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSerializeStoredView = exports.SerializeStoredView = void 0;
|
|
4
|
+
const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
|
|
5
|
+
const ValueObjects_1 = require("../../../ValueObjects");
|
|
6
|
+
const StoredView_1 = require("../Entities/StoredView");
|
|
7
|
+
class SerializeStoredView extends AppObjectUC_1.AppObjectUC {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.name = "storedView";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.SerializeStoredView = SerializeStoredView;
|
|
14
|
+
SerializeStoredView.type = "SerializeStoredView";
|
|
15
|
+
function makeSerializeStoredView(appObject, stateMachine) {
|
|
16
|
+
return new SerializeStoredViewImp(appObject, stateMachine);
|
|
17
|
+
}
|
|
18
|
+
exports.makeSerializeStoredView = makeSerializeStoredView;
|
|
19
|
+
class SerializeStoredViewImp extends SerializeStoredView {
|
|
20
|
+
constructor(appObject, stateMachine) {
|
|
21
|
+
super(appObject, SerializeStoredView.type);
|
|
22
|
+
this.seriliziationVersion = 1;
|
|
23
|
+
this.storedView = appObject.getComponent(StoredView_1.StoredView.type);
|
|
24
|
+
if (!this.storedView) {
|
|
25
|
+
console.warn("SerializeStoredView UC has been added to an App Object that does not have a StoredView Entity. Add one before adding the UC");
|
|
26
|
+
this.dispose();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
stateMachine.registerSerializedSystem(this);
|
|
30
|
+
}
|
|
31
|
+
getSystemState() {
|
|
32
|
+
if (!this.storedView) {
|
|
33
|
+
console.warn("[SerializeStoredView] No stored view entity");
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
const data = {
|
|
37
|
+
position: this.storedView.position.dto,
|
|
38
|
+
rotation: this.storedView.rotation.dto,
|
|
39
|
+
scale: this.storedView.scale,
|
|
40
|
+
hasStoredView: this.storedView.hasStoredView,
|
|
41
|
+
};
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
applySystemState(serializedState, version) {
|
|
45
|
+
try {
|
|
46
|
+
if (version === 1) {
|
|
47
|
+
const castState = serializedState;
|
|
48
|
+
this.applyV1Data(castState);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
console.warn(`[SerializeStoredView] Unsupported version number ${version}. Defaulting`);
|
|
52
|
+
this.applyDefaultState();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
console.warn(`[SerializeStoredView] Caught when deserializing ${e}. Defaulting`);
|
|
57
|
+
this.applyDefaultState();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
applyDefaultState() {
|
|
61
|
+
if (!this.storedView) {
|
|
62
|
+
console.warn("[SerializeStoredView] No stored view entity");
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
this.storedView.position = ValueObjects_1.Vector3.Zero();
|
|
66
|
+
this.storedView.rotation = ValueObjects_1.Quaternion.Identity();
|
|
67
|
+
this.storedView.scale = 1;
|
|
68
|
+
this.storedView.hasStoredView = false;
|
|
69
|
+
}
|
|
70
|
+
applyV1Data(data) {
|
|
71
|
+
if (!this.storedView) {
|
|
72
|
+
console.warn("[SerializeStoredView] No stored view entity");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const pos = ValueObjects_1.Vector3.FromDTO(data.position);
|
|
76
|
+
const rot = ValueObjects_1.Quaternion.FromDTO(data.rotation);
|
|
77
|
+
this.storedView.position = pos;
|
|
78
|
+
this.storedView.rotation = rot;
|
|
79
|
+
this.storedView.scale = data.scale;
|
|
80
|
+
this.storedView.hasStoredView = data.hasStoredView;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./Entities/StoredView"), exports);
|
|
14
|
+
__exportStar(require("./UC/SerializeStoredView"), exports);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Vector3 } from "../ValueObjects";
|
|
2
|
+
export declare type OnFocusCameraChange = () => void;
|
|
3
|
+
export interface FocusCameraLerper {
|
|
4
|
+
cancelLerp: () => void;
|
|
5
|
+
}
|
|
6
|
+
export interface FocusCameraData {
|
|
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
|
+
}
|
|
42
|
+
export interface FocusCamera {
|
|
43
|
+
alpha: number;
|
|
44
|
+
beta: number;
|
|
45
|
+
radius: number;
|
|
46
|
+
target: Vector3;
|
|
47
|
+
direction: Vector3;
|
|
48
|
+
cameraPosition: Vector3;
|
|
49
|
+
nearClip: number;
|
|
50
|
+
farClip: number;
|
|
51
|
+
defaultAlpha: number;
|
|
52
|
+
defaultBeta: number;
|
|
53
|
+
defaultRadius: number;
|
|
54
|
+
defaultTarget: Vector3;
|
|
55
|
+
setAlphaLimits: (min: number, max: number) => void;
|
|
56
|
+
clearAlphaLimits: () => void;
|
|
57
|
+
setBetaLimits: (min: number, max: number) => void;
|
|
58
|
+
clearBetaLimits: () => void;
|
|
59
|
+
setRadiusLimits: (min: number, max: number) => void;
|
|
60
|
+
clearRadiusLimits: () => void;
|
|
61
|
+
setTargetLimits: (min: Vector3, max: Vector3) => void;
|
|
62
|
+
clearTargetLimits: () => void;
|
|
63
|
+
registerLerp: (lerper: FocusCameraLerper) => void;
|
|
64
|
+
lerpCompleted: () => void;
|
|
65
|
+
cancelLerp: () => void;
|
|
66
|
+
applyData: (data: FocusCameraData) => void;
|
|
67
|
+
addObserver: (observer: OnFocusCameraChange) => void;
|
|
68
|
+
removeObserver: (observer: OnFocusCameraChange) => void;
|
|
69
|
+
}
|
|
70
|
+
export declare function makeFocusCamera(): FocusCamera;
|
|
@@ -0,0 +1,272 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoizedBoolean = void 0;
|
|
4
|
+
class MemoizedBoolean {
|
|
5
|
+
constructor(initialValue, onChangeCallback) {
|
|
6
|
+
this._val = initialValue;
|
|
7
|
+
this.onChangeCallback = onChangeCallback;
|
|
8
|
+
}
|
|
9
|
+
get val() {
|
|
10
|
+
return this._val;
|
|
11
|
+
}
|
|
12
|
+
set val(b) {
|
|
13
|
+
if (this._val === b)
|
|
14
|
+
return;
|
|
15
|
+
this._val = b;
|
|
16
|
+
this.onChangeCallback();
|
|
17
|
+
}
|
|
18
|
+
setValQuietly(val) {
|
|
19
|
+
this._val = val;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.MemoizedBoolean = MemoizedBoolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MemoizedNumber = void 0;
|
|
4
|
+
class MemoizedNumber {
|
|
5
|
+
constructor(initialValue, onChangeCallback) {
|
|
6
|
+
this._val = initialValue;
|
|
7
|
+
this.onChangeCallback = onChangeCallback;
|
|
8
|
+
}
|
|
9
|
+
get val() {
|
|
10
|
+
return this._val;
|
|
11
|
+
}
|
|
12
|
+
set val(b) {
|
|
13
|
+
if (this._val === b)
|
|
14
|
+
return;
|
|
15
|
+
this._val = b;
|
|
16
|
+
this.onChangeCallback();
|
|
17
|
+
}
|
|
18
|
+
setValQuietly(val) {
|
|
19
|
+
this._val = val;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.MemoizedNumber = MemoizedNumber;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Quaternion } from "../ValueObjects";
|
|
2
|
+
export declare class MemoizedQuaternion {
|
|
3
|
+
private _val;
|
|
4
|
+
get val(): Quaternion;
|
|
5
|
+
set val(v: Quaternion);
|
|
6
|
+
setValQuietly(val: Quaternion): void;
|
|
7
|
+
private onChangeCallback;
|
|
8
|
+
constructor(initialValue: Quaternion, onChangeCallback: () => void);
|
|
9
|
+
}
|