@vived/app 2.50.1 → 2.51.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 -0
- package/lib/Entities/MemoizedColor.d.ts +9 -0
- package/lib/Entities/MemoizedColor.js +23 -0
- package/lib/Entities/ModelMesh.d.ts +53 -0
- package/lib/Entities/ModelMesh.js +106 -0
- package/lib/Entities/SceneModelObject.d.ts +40 -0
- package/lib/Entities/SceneModelObject.js +77 -0
- package/lib/PresentationManagers/SceneModel/SceneMeshOverlayPM.d.ts +1 -1
- package/lib/PresentationManagers/SceneModel/SceneMeshOverlayPM.js +2 -2
- package/lib/UseCases/SceneModel/PeelSceneMeshBase.d.ts +20 -0
- package/lib/UseCases/SceneModel/PeelSceneMeshBase.js +66 -0
- package/lib/UseCases/SceneModel/setActiveSceneModel.d.ts +2 -0
- package/lib/UseCases/SceneModel/setActiveSceneModel.js +90 -0
- package/lib/UseCases/SceneModel/setupSceneModelFromData.d.ts +2 -0
- package/lib/UseCases/SceneModel/setupSceneModelFromData.js +72 -0
- package/lib/UseCases/SceneObject/PeelSceneObjectBase.d.ts +20 -0
- package/lib/UseCases/SceneObject/PeelSceneObjectBase.js +66 -0
- package/lib/UseCases/SceneObject/index.d.ts +1 -0
- package/lib/UseCases/{FocusCamera → SceneObject}/index.js +1 -7
- package/lib/UseCases/SceneRoot/initializeSceneRoot.d.ts +2 -0
- package/lib/UseCases/SceneRoot/initializeSceneRoot.js +9 -0
- package/package.json +1 -1
- package/lib/Entities/FocusCamera.d.ts +0 -70
- package/lib/Entities/FocusCamera.js +0 -272
- package/lib/Entities/MeshModel.d.ts +0 -68
- package/lib/Entities/MeshModel.js +0 -174
- package/lib/Entities/ModelObject.d.ts +0 -10
- package/lib/Entities/ModelObject.js +0 -42
- package/lib/PresentationManagers/FocusCameraPM.d.ts +0 -15
- package/lib/PresentationManagers/FocusCameraPM.js +0 -31
- package/lib/PresentationManagers/FocusCameraPosRotPM.d.ts +0 -13
- package/lib/PresentationManagers/FocusCameraPosRotPM.js +0 -28
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +0 -17
- package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +0 -64
- package/lib/UseCases/FocusCamera/LerpFocusCamera.d.ts +0 -36
- package/lib/UseCases/FocusCamera/LerpFocusCamera.js +0 -71
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +0 -36
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +0 -36
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +0 -26
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +0 -11
- package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +0 -33
- package/lib/UseCases/FocusCamera/SerializeFocusCamera.d.ts +0 -22
- package/lib/UseCases/FocusCamera/SerializeFocusCamera.js +0 -81
- package/lib/UseCases/FocusCamera/index.d.ts +0 -7
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PeelSceneObjectBase = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../../ValueObjects");
|
|
5
|
+
class PeelSceneObjectBase {
|
|
6
|
+
constructor(babylon, sceneObjectRepo) {
|
|
7
|
+
this.babylon = babylon;
|
|
8
|
+
this.sceneObjectRepo = sceneObjectRepo;
|
|
9
|
+
this._didPeel = false;
|
|
10
|
+
this._doPeel = false;
|
|
11
|
+
this._transformToPeel = undefined;
|
|
12
|
+
this._peelPlane = ValueObjects_1.ParametricPlane.XY();
|
|
13
|
+
this._pickOffset = ValueObjects_1.Vector3.Zero();
|
|
14
|
+
this.tryInitializePeel = (pickRay) => {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
this._doPeel = false;
|
|
17
|
+
this._didPeel = false;
|
|
18
|
+
this._transformToPeel = undefined;
|
|
19
|
+
const sceneObjectID = this.babylon.sceneObjectRayPick(pickRay);
|
|
20
|
+
if (!sceneObjectID)
|
|
21
|
+
return;
|
|
22
|
+
const sceneObject = this.sceneObjectRepo.get(sceneObjectID);
|
|
23
|
+
if (!sceneObject)
|
|
24
|
+
return;
|
|
25
|
+
this._sceneObject = sceneObject;
|
|
26
|
+
this._transformToPeel = sceneObject.transform;
|
|
27
|
+
const scenePick = this.babylon.sceneRayPick(pickRay);
|
|
28
|
+
if (!scenePick)
|
|
29
|
+
return;
|
|
30
|
+
const pickPlaneDirection = ValueObjects_1.Vector3.Backward();
|
|
31
|
+
const planePickPos = (_a = scenePick.worldPickPoint) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
32
|
+
this._peelPlane = ValueObjects_1.ParametricPlane.FromPointNormal(planePickPos, pickPlaneDirection);
|
|
33
|
+
const pick = (_b = this._peelPlane.intersectLine(pickRay)) !== null && _b !== void 0 ? _b : ValueObjects_1.Vector3.Zero();
|
|
34
|
+
this._rootPos = this._transformToPeel.worldPosition;
|
|
35
|
+
this._pickOffset = ValueObjects_1.Vector3.Subtract(this._rootPos, pick);
|
|
36
|
+
this._doPeel = true;
|
|
37
|
+
};
|
|
38
|
+
this.updatePeel = (pickRay) => {
|
|
39
|
+
var _a;
|
|
40
|
+
if (!this._doPeel)
|
|
41
|
+
return;
|
|
42
|
+
if (!this._transformToPeel)
|
|
43
|
+
return;
|
|
44
|
+
const pick = (_a = this._peelPlane.intersectLine(pickRay)) !== null && _a !== void 0 ? _a : ValueObjects_1.Vector3.Zero();
|
|
45
|
+
this._transformToPeel.worldPosition = ValueObjects_1.Vector3.Add(pick, this._pickOffset);
|
|
46
|
+
this._didPeel = true;
|
|
47
|
+
};
|
|
48
|
+
this.stopPeel = () => {
|
|
49
|
+
this._doPeel = false;
|
|
50
|
+
this._didPeel = false;
|
|
51
|
+
this._transformToPeel = undefined;
|
|
52
|
+
this._rootPos = undefined;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
get peeledSceneObjectID() {
|
|
56
|
+
var _a;
|
|
57
|
+
return (_a = this._sceneObject) === null || _a === void 0 ? void 0 : _a.id;
|
|
58
|
+
}
|
|
59
|
+
get didPeel() {
|
|
60
|
+
return this._didPeel;
|
|
61
|
+
}
|
|
62
|
+
get peelingTransform() {
|
|
63
|
+
return this._transformToPeel;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.PeelSceneObjectBase = PeelSceneObjectBase;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./PeelSceneObjectBase";
|
|
@@ -10,10 +10,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./
|
|
14
|
-
__exportStar(require("./LerpFocusCamera"), exports);
|
|
15
|
-
__exportStar(require("./SerializeFocusCamera"), exports);
|
|
16
|
-
__exportStar(require("./PixelDollyFocusCamera"), exports);
|
|
17
|
-
__exportStar(require("./BumpDollyFocusCamera"), exports);
|
|
18
|
-
__exportStar(require("./PinchDollyFocusCamera"), exports);
|
|
19
|
-
__exportStar(require("./PixelOrbitFocusCamera"), exports);
|
|
13
|
+
__exportStar(require("./PeelSceneObjectBase"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initializeSceneRoot = void 0;
|
|
4
|
+
const Entities_1 = require("../../Entities");
|
|
5
|
+
function initializeSceneRoot(defaultData, sceneRoot, sceneObjectRepo) {
|
|
6
|
+
sceneRoot.applyDefaultData(defaultData);
|
|
7
|
+
sceneObjectRepo.add(Entities_1.SCENE_ROOT_ID, sceneRoot.sceneObject);
|
|
8
|
+
}
|
|
9
|
+
exports.initializeSceneRoot = initializeSceneRoot;
|
package/package.json
CHANGED
|
@@ -1,70 +0,0 @@
|
|
|
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;
|
|
@@ -1,272 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeFocusCamera = void 0;
|
|
4
|
-
const _1 = require(".");
|
|
5
|
-
const ValueObjects_1 = require("../ValueObjects");
|
|
6
|
-
function makeFocusCamera() {
|
|
7
|
-
return new FocusCameraImp();
|
|
8
|
-
}
|
|
9
|
-
exports.makeFocusCamera = makeFocusCamera;
|
|
10
|
-
class FocusCameraImp {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.farClip = 100;
|
|
13
|
-
this.nearClip = 0.01;
|
|
14
|
-
this.defaultAlpha = 0;
|
|
15
|
-
this.defaultBeta = 30;
|
|
16
|
-
this.defaultRadius = 8;
|
|
17
|
-
this.defaultTarget = ValueObjects_1.Vector3.Zero();
|
|
18
|
-
this.limitRadius = false;
|
|
19
|
-
this.minRadius = 0;
|
|
20
|
-
this.maxRadius = 0;
|
|
21
|
-
this.limitAlpha = false;
|
|
22
|
-
this.minAlpha = 0;
|
|
23
|
-
this.maxAlpha = 0;
|
|
24
|
-
this.limitBeta = false;
|
|
25
|
-
this.minBeta = 0;
|
|
26
|
-
this.maxBeta = 0;
|
|
27
|
-
this.limitTarget = false;
|
|
28
|
-
this.maxTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
29
|
-
this.minTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
30
|
-
this.observers = new _1.ObserverList();
|
|
31
|
-
this.memoizedAlpha = new _1.MemoizedNumber(0, this.observers.notify);
|
|
32
|
-
this.memoizedBeta = new _1.MemoizedNumber(0, this.observers.notify);
|
|
33
|
-
this.memoizedRadius = new _1.MemoizedNumber(1, this.observers.notify);
|
|
34
|
-
this.memoizedTarget = new _1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.observers.notify);
|
|
35
|
-
this.setRadiusLimits = (min, max) => {
|
|
36
|
-
let minToUse = min;
|
|
37
|
-
let maxToUse = max;
|
|
38
|
-
if (min < 0) {
|
|
39
|
-
console.warn("[Orbit Camera Entity] Mininum Radius must be greater >= 0, forcing to 0");
|
|
40
|
-
minToUse = 0;
|
|
41
|
-
}
|
|
42
|
-
if (max < minToUse) {
|
|
43
|
-
console.warn(`[Orbit Camera] Max radius must be >= min radius. Forcing to ${minToUse}`);
|
|
44
|
-
maxToUse = minToUse;
|
|
45
|
-
}
|
|
46
|
-
this.maxRadius = maxToUse;
|
|
47
|
-
this.minRadius = minToUse;
|
|
48
|
-
this.limitRadius = true;
|
|
49
|
-
this.radius = this.radius;
|
|
50
|
-
};
|
|
51
|
-
this.clearRadiusLimits = () => {
|
|
52
|
-
this.maxRadius = 0;
|
|
53
|
-
this.minRadius = 0;
|
|
54
|
-
this.limitRadius = false;
|
|
55
|
-
};
|
|
56
|
-
this.setAlphaLimits = (min, max) => {
|
|
57
|
-
let minToUse = min;
|
|
58
|
-
let maxToUse = max;
|
|
59
|
-
if (min < -180) {
|
|
60
|
-
minToUse = -180;
|
|
61
|
-
console.warn("[Orbit Camera] Min alpha must be >= -180. Forcing to -180");
|
|
62
|
-
}
|
|
63
|
-
if (max > 180) {
|
|
64
|
-
maxToUse = 180;
|
|
65
|
-
console.warn("[Orbit Camera] Max alpha must be <= 180. Forcing to 180");
|
|
66
|
-
}
|
|
67
|
-
if (minToUse > maxToUse) {
|
|
68
|
-
const absMin = Math.abs(minToUse);
|
|
69
|
-
const absMax = Math.abs(maxToUse);
|
|
70
|
-
const closestToZero = absMin < absMax ? minToUse : maxToUse;
|
|
71
|
-
minToUse = closestToZero;
|
|
72
|
-
maxToUse = closestToZero;
|
|
73
|
-
console.warn(`[Orbit Camera] Max alpha must be <= Min Alpha. Forcing to ${closestToZero}`);
|
|
74
|
-
}
|
|
75
|
-
this.maxAlpha = maxToUse;
|
|
76
|
-
this.minAlpha = minToUse;
|
|
77
|
-
this.limitAlpha = true;
|
|
78
|
-
this.alpha = this.alpha;
|
|
79
|
-
};
|
|
80
|
-
this.clearAlphaLimits = () => {
|
|
81
|
-
this.maxAlpha = 0;
|
|
82
|
-
this.minAlpha = 0;
|
|
83
|
-
this.limitAlpha = false;
|
|
84
|
-
};
|
|
85
|
-
this.setBetaLimits = (min, max) => {
|
|
86
|
-
let minToUse = min;
|
|
87
|
-
let maxToUse = max;
|
|
88
|
-
if (min < -180) {
|
|
89
|
-
minToUse = -180;
|
|
90
|
-
console.warn("[Orbit Camera] Min beta must be >= -180. Forcing to -180");
|
|
91
|
-
}
|
|
92
|
-
if (max > 180) {
|
|
93
|
-
maxToUse = 180;
|
|
94
|
-
console.warn("[Orbit Camera] Max beta must be <= 180. Forcing to 180");
|
|
95
|
-
}
|
|
96
|
-
if (minToUse > maxToUse) {
|
|
97
|
-
const absMin = Math.abs(minToUse);
|
|
98
|
-
const absMax = Math.abs(maxToUse);
|
|
99
|
-
const closestToZero = absMin < absMax ? minToUse : maxToUse;
|
|
100
|
-
minToUse = closestToZero;
|
|
101
|
-
maxToUse = closestToZero;
|
|
102
|
-
console.warn(`[Orbit Camera] Max beta must be <= Min beta. Forcing to ${closestToZero}`);
|
|
103
|
-
}
|
|
104
|
-
this.maxBeta = maxToUse;
|
|
105
|
-
this.minBeta = minToUse;
|
|
106
|
-
this.limitBeta = true;
|
|
107
|
-
this.beta = this.beta;
|
|
108
|
-
};
|
|
109
|
-
this.clearBetaLimits = () => {
|
|
110
|
-
this.maxBeta = 0;
|
|
111
|
-
this.minBeta = 0;
|
|
112
|
-
this.limitBeta = false;
|
|
113
|
-
};
|
|
114
|
-
this.setTargetLimits = (min, max) => {
|
|
115
|
-
const minArray = min.array;
|
|
116
|
-
const maxArray = max.array;
|
|
117
|
-
for (let i = 0; i < 3; i++) {
|
|
118
|
-
if (minArray[i] > maxArray[i]) {
|
|
119
|
-
console.warn("[Orbit Camera] Target limit min's components must all be <= the max. Limits not set");
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
this.maxTargetPosition = max;
|
|
124
|
-
this.minTargetPosition = min;
|
|
125
|
-
this.limitTarget = true;
|
|
126
|
-
this.target = this.target;
|
|
127
|
-
};
|
|
128
|
-
this.clearTargetLimits = () => {
|
|
129
|
-
this.maxTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
130
|
-
this.minTargetPosition = ValueObjects_1.Vector3.Zero();
|
|
131
|
-
this.limitTarget = false;
|
|
132
|
-
};
|
|
133
|
-
this.registerLerp = (lerper) => {
|
|
134
|
-
if (this.currentLerp) {
|
|
135
|
-
this.currentLerp.cancelLerp();
|
|
136
|
-
}
|
|
137
|
-
this.currentLerp = lerper;
|
|
138
|
-
};
|
|
139
|
-
this.lerpCompleted = () => {
|
|
140
|
-
this.currentLerp = undefined;
|
|
141
|
-
};
|
|
142
|
-
this.cancelLerp = () => {
|
|
143
|
-
var _a;
|
|
144
|
-
(_a = this.currentLerp) === null || _a === void 0 ? void 0 : _a.cancelLerp();
|
|
145
|
-
this.currentLerp = undefined;
|
|
146
|
-
};
|
|
147
|
-
this.applyData = (data) => {
|
|
148
|
-
if (data.defaultAlpha !== undefined) {
|
|
149
|
-
this.defaultAlpha = data.defaultAlpha;
|
|
150
|
-
}
|
|
151
|
-
if (data.defaultBeta !== undefined) {
|
|
152
|
-
this.defaultBeta = data.defaultBeta;
|
|
153
|
-
}
|
|
154
|
-
if (data.defaultRadius !== undefined) {
|
|
155
|
-
this.defaultRadius = data.defaultRadius;
|
|
156
|
-
}
|
|
157
|
-
if (data.defaultTarget !== undefined) {
|
|
158
|
-
const { x, y, z } = data.defaultTarget;
|
|
159
|
-
this.defaultTarget = new ValueObjects_1.Vector3(x, y, z);
|
|
160
|
-
}
|
|
161
|
-
if (data.nearClip !== undefined) {
|
|
162
|
-
this.nearClip = data.nearClip;
|
|
163
|
-
}
|
|
164
|
-
if (data.farClip !== undefined) {
|
|
165
|
-
this.farClip = data.farClip;
|
|
166
|
-
}
|
|
167
|
-
if (data.alphaLimit !== undefined) {
|
|
168
|
-
this.setAlphaLimits(data.alphaLimit.min, data.alphaLimit.max);
|
|
169
|
-
}
|
|
170
|
-
if (data.betaLimit !== undefined) {
|
|
171
|
-
this.setBetaLimits(data.betaLimit.min, data.betaLimit.max);
|
|
172
|
-
}
|
|
173
|
-
if (data.radiusLimit !== undefined) {
|
|
174
|
-
this.setRadiusLimits(data.radiusLimit.min, data.radiusLimit.max);
|
|
175
|
-
}
|
|
176
|
-
if (data.targetLimit !== undefined) {
|
|
177
|
-
const { max, min } = data.targetLimit;
|
|
178
|
-
this.setTargetLimits(new ValueObjects_1.Vector3(min.x, min.y, min.z), new ValueObjects_1.Vector3(max.x, max.y, max.z));
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
this.addObserver = (observer) => {
|
|
182
|
-
this.observers.add(observer);
|
|
183
|
-
};
|
|
184
|
-
this.removeObserver = (observer) => {
|
|
185
|
-
this.observers.remove(observer);
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
get alpha() {
|
|
189
|
-
return this.memoizedAlpha.val;
|
|
190
|
-
}
|
|
191
|
-
set alpha(val) {
|
|
192
|
-
let valToUse = val;
|
|
193
|
-
if (this.limitAlpha) {
|
|
194
|
-
valToUse = Math.min(valToUse, this.maxAlpha);
|
|
195
|
-
valToUse = Math.max(valToUse, this.minAlpha);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
valToUse = this.clampAngle(val);
|
|
199
|
-
}
|
|
200
|
-
this.memoizedAlpha.val = valToUse;
|
|
201
|
-
}
|
|
202
|
-
get beta() {
|
|
203
|
-
return this.memoizedBeta.val;
|
|
204
|
-
}
|
|
205
|
-
set beta(val) {
|
|
206
|
-
let valToUse = val;
|
|
207
|
-
if (this.limitBeta) {
|
|
208
|
-
valToUse = Math.min(valToUse, this.maxBeta);
|
|
209
|
-
valToUse = Math.max(valToUse, this.minBeta);
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
valToUse = this.clampAngle(val);
|
|
213
|
-
}
|
|
214
|
-
this.memoizedBeta.val = valToUse;
|
|
215
|
-
}
|
|
216
|
-
get radius() {
|
|
217
|
-
return this.memoizedRadius.val;
|
|
218
|
-
}
|
|
219
|
-
set radius(val) {
|
|
220
|
-
let clampedVal = Math.max(val, 0);
|
|
221
|
-
if (this.limitRadius) {
|
|
222
|
-
clampedVal = Math.min(clampedVal, this.maxRadius);
|
|
223
|
-
clampedVal = Math.max(clampedVal, this.minRadius);
|
|
224
|
-
}
|
|
225
|
-
this.memoizedRadius.val = clampedVal;
|
|
226
|
-
}
|
|
227
|
-
get target() {
|
|
228
|
-
return this.memoizedTarget.val;
|
|
229
|
-
}
|
|
230
|
-
set target(val) {
|
|
231
|
-
const targetVals = val.array;
|
|
232
|
-
if (this.limitTarget) {
|
|
233
|
-
const maxVals = this.maxTargetPosition.array;
|
|
234
|
-
const minVals = this.minTargetPosition.array;
|
|
235
|
-
for (let i = 0; i < 3; i++) {
|
|
236
|
-
let v = targetVals[i];
|
|
237
|
-
v = Math.min(v, maxVals[i]);
|
|
238
|
-
v = Math.max(v, minVals[i]);
|
|
239
|
-
targetVals[i] = v;
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
this.memoizedTarget.val = ValueObjects_1.Vector3.FromArray(targetVals);
|
|
243
|
-
}
|
|
244
|
-
get direction() {
|
|
245
|
-
const yLength = -Math.sin(this.degToRad(this.beta));
|
|
246
|
-
const horizontalLenght = Math.cos(this.degToRad(this.beta));
|
|
247
|
-
const alphaRadians = this.degToRad(this.alpha);
|
|
248
|
-
const xLength = horizontalLenght * Math.sin(alphaRadians);
|
|
249
|
-
const zLength = horizontalLenght * Math.cos(alphaRadians);
|
|
250
|
-
return new ValueObjects_1.Vector3(xLength, yLength, zLength);
|
|
251
|
-
}
|
|
252
|
-
get cameraPosition() {
|
|
253
|
-
const localOffset = ValueObjects_1.Vector3.NewVectorOfLength(this.direction, -this.radius);
|
|
254
|
-
return ValueObjects_1.Vector3.Add(this.target, localOffset);
|
|
255
|
-
}
|
|
256
|
-
degToRad(degrees) {
|
|
257
|
-
return (degrees * Math.PI) / 180;
|
|
258
|
-
}
|
|
259
|
-
clampAngle(angle) {
|
|
260
|
-
const isNegative = angle < 0 ? true : false;
|
|
261
|
-
const absAngle = Math.abs(angle);
|
|
262
|
-
const revolutions = Math.floor(absAngle / 360);
|
|
263
|
-
let angleWithoutRevolutions = absAngle - revolutions * 360;
|
|
264
|
-
if (angleWithoutRevolutions > 180) {
|
|
265
|
-
angleWithoutRevolutions = angleWithoutRevolutions - 360;
|
|
266
|
-
}
|
|
267
|
-
if (isNegative) {
|
|
268
|
-
angleWithoutRevolutions *= -1;
|
|
269
|
-
}
|
|
270
|
-
return angleWithoutRevolutions;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { Quaternion, Vector3 } from "../ValueObjects";
|
|
2
|
-
import { ModelObject } from "./ModelObject";
|
|
3
|
-
import { ObservableEntity } from "./ObservableEntity";
|
|
4
|
-
export interface MeshModelData {
|
|
5
|
-
version: number;
|
|
6
|
-
objects: ObjectData[];
|
|
7
|
-
name: string;
|
|
8
|
-
description: string;
|
|
9
|
-
bounds_min: {
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
z: number;
|
|
13
|
-
};
|
|
14
|
-
bounds_max: {
|
|
15
|
-
x: number;
|
|
16
|
-
y: number;
|
|
17
|
-
z: number;
|
|
18
|
-
};
|
|
19
|
-
defaultPosition: {
|
|
20
|
-
x: number;
|
|
21
|
-
y: number;
|
|
22
|
-
z: number;
|
|
23
|
-
};
|
|
24
|
-
defaultRotation: {
|
|
25
|
-
x: number;
|
|
26
|
-
y: number;
|
|
27
|
-
z: number;
|
|
28
|
-
w: number;
|
|
29
|
-
};
|
|
30
|
-
defaultScale: number;
|
|
31
|
-
}
|
|
32
|
-
export interface ObjectData {
|
|
33
|
-
id: string;
|
|
34
|
-
meshPaths: string[];
|
|
35
|
-
label: string;
|
|
36
|
-
}
|
|
37
|
-
export declare abstract class MeshModel extends ObservableEntity {
|
|
38
|
-
abstract readonly objects: ModelObject[];
|
|
39
|
-
abstract hasObject(id: string): boolean;
|
|
40
|
-
abstract getObjectById(id: string): ModelObject | undefined;
|
|
41
|
-
abstract getObjectByPath(path: string): ModelObject | undefined;
|
|
42
|
-
abstract addObject(object: ModelObject): void;
|
|
43
|
-
abstract deleteObject(id: string): void;
|
|
44
|
-
abstract get modelFile(): File | undefined;
|
|
45
|
-
abstract set modelFile(file: File | undefined);
|
|
46
|
-
abstract get version(): number;
|
|
47
|
-
abstract set version(scale: number);
|
|
48
|
-
abstract get name(): string;
|
|
49
|
-
abstract set name(name: string);
|
|
50
|
-
abstract get description(): string;
|
|
51
|
-
abstract set description(name: string);
|
|
52
|
-
abstract get image(): Blob | undefined;
|
|
53
|
-
abstract set image(image: Blob | undefined);
|
|
54
|
-
abstract get imageURL(): string | undefined;
|
|
55
|
-
abstract get bounds_min(): Vector3;
|
|
56
|
-
abstract set bounds_min(position: Vector3);
|
|
57
|
-
abstract get bounds_max(): Vector3;
|
|
58
|
-
abstract set bounds_max(position: Vector3);
|
|
59
|
-
abstract get defaultPosition(): Vector3;
|
|
60
|
-
abstract set defaultPosition(position: Vector3);
|
|
61
|
-
abstract get defaultRotation(): Quaternion;
|
|
62
|
-
abstract set defaultRotation(rotation: Quaternion);
|
|
63
|
-
abstract get defaultScale(): number;
|
|
64
|
-
abstract set defaultScale(scale: number);
|
|
65
|
-
abstract getData(): MeshModelData;
|
|
66
|
-
abstract setData(data: MeshModelData): void;
|
|
67
|
-
}
|
|
68
|
-
export declare function makeMeshModel(): MeshModel;
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makeMeshModel = exports.MeshModel = void 0;
|
|
4
|
-
const ValueObjects_1 = require("../ValueObjects");
|
|
5
|
-
const MemoizedNumber_1 = require("./MemoizedNumber");
|
|
6
|
-
const MemoizedString_1 = require("./MemoizedString");
|
|
7
|
-
const MemoizedVector3_1 = require("./MemoizedVector3");
|
|
8
|
-
const ModelObject_1 = require("./ModelObject");
|
|
9
|
-
const ObservableEntity_1 = require("./ObservableEntity");
|
|
10
|
-
class MeshModel extends ObservableEntity_1.ObservableEntity {
|
|
11
|
-
}
|
|
12
|
-
exports.MeshModel = MeshModel;
|
|
13
|
-
function makeMeshModel() {
|
|
14
|
-
return new MeshModelImp();
|
|
15
|
-
}
|
|
16
|
-
exports.makeMeshModel = makeMeshModel;
|
|
17
|
-
class MeshModelImp extends MeshModel {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.objects = [];
|
|
21
|
-
this._modelFile = undefined;
|
|
22
|
-
this._memoizedVersion = new MemoizedNumber_1.MemoizedNumber(0, this.notify);
|
|
23
|
-
this._memoizedName = new MemoizedString_1.MemoizedString("", this.notify);
|
|
24
|
-
this._memoizedDescription = new MemoizedString_1.MemoizedString("", this.notify);
|
|
25
|
-
this._image = undefined;
|
|
26
|
-
this._memoizedBoundsMin = new MemoizedVector3_1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.notify);
|
|
27
|
-
this._memoizedBoundsMax = new MemoizedVector3_1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.notify);
|
|
28
|
-
this._memoizedDefaultPosition = new MemoizedVector3_1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.notify);
|
|
29
|
-
this._defaultRotation = ValueObjects_1.Quaternion.Identity();
|
|
30
|
-
this._memoizedDefaultScale = new MemoizedNumber_1.MemoizedNumber(1, this.notify);
|
|
31
|
-
this._imageURL = undefined;
|
|
32
|
-
}
|
|
33
|
-
hasObject(id) {
|
|
34
|
-
return !!this.objects.find((obj) => obj.id === id);
|
|
35
|
-
}
|
|
36
|
-
getObjectById(id) {
|
|
37
|
-
return this.objects.find((obj) => obj.id === id);
|
|
38
|
-
}
|
|
39
|
-
getObjectByPath(path) {
|
|
40
|
-
let rVal;
|
|
41
|
-
this.objects.forEach((obj) => {
|
|
42
|
-
if (obj.meshPaths.includes(path)) {
|
|
43
|
-
rVal = obj;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return rVal;
|
|
47
|
-
}
|
|
48
|
-
addObject(object) {
|
|
49
|
-
object.addObserver(this.notify);
|
|
50
|
-
this.objects.push(object);
|
|
51
|
-
this.notify();
|
|
52
|
-
}
|
|
53
|
-
deleteObject(id) {
|
|
54
|
-
this.objects = this.objects.filter((obj) => {
|
|
55
|
-
if (obj.id === id) {
|
|
56
|
-
obj.removeObserver(this.notify);
|
|
57
|
-
return false;
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
});
|
|
61
|
-
this.notify();
|
|
62
|
-
}
|
|
63
|
-
get modelFile() {
|
|
64
|
-
return this._modelFile;
|
|
65
|
-
}
|
|
66
|
-
set modelFile(file) {
|
|
67
|
-
this._modelFile = file;
|
|
68
|
-
this.notify();
|
|
69
|
-
}
|
|
70
|
-
get version() {
|
|
71
|
-
return this._memoizedVersion.val;
|
|
72
|
-
}
|
|
73
|
-
set version(version) {
|
|
74
|
-
this._memoizedVersion.val = version;
|
|
75
|
-
}
|
|
76
|
-
get name() {
|
|
77
|
-
return this._memoizedName.val;
|
|
78
|
-
}
|
|
79
|
-
set name(name) {
|
|
80
|
-
this._memoizedName.val = name;
|
|
81
|
-
}
|
|
82
|
-
get description() {
|
|
83
|
-
return this._memoizedDescription.val;
|
|
84
|
-
}
|
|
85
|
-
set description(description) {
|
|
86
|
-
this._memoizedDescription.val = description;
|
|
87
|
-
}
|
|
88
|
-
get image() {
|
|
89
|
-
return this._image;
|
|
90
|
-
}
|
|
91
|
-
set image(image) {
|
|
92
|
-
if (!this._image && !image)
|
|
93
|
-
return;
|
|
94
|
-
if (this._image && image && this._image.size === image.size)
|
|
95
|
-
return;
|
|
96
|
-
this._image = image;
|
|
97
|
-
if (image === undefined) {
|
|
98
|
-
this._imageURL = undefined;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
this._imageURL = URL.createObjectURL(image);
|
|
102
|
-
}
|
|
103
|
-
this.notify();
|
|
104
|
-
}
|
|
105
|
-
get imageURL() {
|
|
106
|
-
return this._imageURL;
|
|
107
|
-
}
|
|
108
|
-
get bounds_min() {
|
|
109
|
-
return this._memoizedBoundsMin.val;
|
|
110
|
-
}
|
|
111
|
-
set bounds_min(bounds_min) {
|
|
112
|
-
this._memoizedBoundsMin.val = bounds_min;
|
|
113
|
-
}
|
|
114
|
-
get bounds_max() {
|
|
115
|
-
return this._memoizedBoundsMax.val;
|
|
116
|
-
}
|
|
117
|
-
set bounds_max(bounds_max) {
|
|
118
|
-
this._memoizedBoundsMax.val = bounds_max;
|
|
119
|
-
}
|
|
120
|
-
get defaultPosition() {
|
|
121
|
-
return this._memoizedDefaultPosition.val;
|
|
122
|
-
}
|
|
123
|
-
set defaultPosition(position) {
|
|
124
|
-
this._memoizedDefaultPosition.val = position;
|
|
125
|
-
}
|
|
126
|
-
get defaultRotation() {
|
|
127
|
-
return this._defaultRotation;
|
|
128
|
-
}
|
|
129
|
-
set defaultRotation(rotation) {
|
|
130
|
-
if (ValueObjects_1.Quaternion.Equal(this._defaultRotation, rotation))
|
|
131
|
-
return;
|
|
132
|
-
this._defaultRotation = rotation;
|
|
133
|
-
this.notify();
|
|
134
|
-
}
|
|
135
|
-
get defaultScale() {
|
|
136
|
-
return this._memoizedDefaultScale.val;
|
|
137
|
-
}
|
|
138
|
-
set defaultScale(scale) {
|
|
139
|
-
this._memoizedDefaultScale.val = scale;
|
|
140
|
-
}
|
|
141
|
-
getData() {
|
|
142
|
-
return {
|
|
143
|
-
version: this.version,
|
|
144
|
-
objects: this.objects.map((obj) => ({
|
|
145
|
-
id: obj.id,
|
|
146
|
-
label: obj.label,
|
|
147
|
-
meshPaths: [...obj.meshPaths],
|
|
148
|
-
})),
|
|
149
|
-
name: this.name,
|
|
150
|
-
description: this.description,
|
|
151
|
-
bounds_min: this.bounds_min,
|
|
152
|
-
bounds_max: this.bounds_max,
|
|
153
|
-
defaultPosition: this.defaultPosition,
|
|
154
|
-
defaultRotation: this.defaultRotation,
|
|
155
|
-
defaultScale: this.defaultScale,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
setData(data) {
|
|
159
|
-
this.version = data.version;
|
|
160
|
-
data.objects.forEach((obj) => {
|
|
161
|
-
const modelObject = ModelObject_1.makeModelObject(obj.id);
|
|
162
|
-
modelObject.label = obj.label;
|
|
163
|
-
obj.meshPaths.forEach((path) => modelObject.addMeshPath(path));
|
|
164
|
-
this.addObject(modelObject);
|
|
165
|
-
});
|
|
166
|
-
this.name = data.name;
|
|
167
|
-
this.description = data.description;
|
|
168
|
-
this.bounds_min = data.bounds_min;
|
|
169
|
-
this.bounds_max = data.bounds_max;
|
|
170
|
-
this.defaultPosition = data.defaultPosition;
|
|
171
|
-
this.defaultRotation = data.defaultRotation;
|
|
172
|
-
this.defaultScale = data.defaultScale;
|
|
173
|
-
}
|
|
174
|
-
}
|