@vived/app 2.45.0 → 2.46.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/ModelMesh.d.ts +53 -0
- package/lib/Entities/ModelMesh.js +106 -0
- package/lib/Entities/SceneModel.d.ts +7 -7
- package/lib/Entities/SceneModel.js +16 -14
- package/lib/Entities/SceneModelMesh.d.ts +65 -0
- package/lib/Entities/SceneModelMesh.js +159 -0
- package/lib/Entities/SceneObject.d.ts +1 -4
- package/lib/Entities/SceneObject.js +0 -17
- package/lib/Entities/SceneRoot.d.ts +19 -59
- package/lib/Entities/SceneRoot.js +94 -26
- package/lib/Entities/index.d.ts +1 -1
- package/lib/Entities/index.js +1 -1
- package/lib/PresentationManagers/SceneObject/SceneObjectPM.d.ts +17 -0
- package/lib/PresentationManagers/SceneObject/SceneObjectPM.js +40 -0
- package/lib/PresentationManagers/SceneObject/index.d.ts +1 -0
- package/lib/PresentationManagers/SceneObject/index.js +13 -0
- package/lib/PresentationManagers/index.d.ts +1 -0
- package/lib/PresentationManagers/index.js +1 -0
- package/lib/UseCases/SceneModel/PeelSceneMeshBase.d.ts +20 -0
- package/lib/UseCases/SceneModel/PeelSceneMeshBase.js +66 -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/index.d.ts +4 -2
- package/lib/UseCases/SceneModel/index.js +3 -1
- package/lib/UseCases/SceneModel/loadNewModel.d.ts +2 -0
- package/lib/UseCases/SceneModel/loadNewModel.js +84 -0
- package/lib/UseCases/SceneModel/setActiveSceneModel.js +4 -3
- package/lib/UseCases/SceneModel/setupSceneModelFromData.d.ts +2 -0
- package/lib/UseCases/SceneModel/setupSceneModelFromData.js +72 -0
- 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/lib/UseCases/SceneRoot/SerializeSceneRoot.d.ts +15 -0
- package/lib/UseCases/SceneRoot/SerializeSceneRoot.js +26 -7
- package/lib/UseCases/SceneRoot/index.d.ts +1 -0
- package/lib/UseCases/SceneRoot/index.js +1 -0
- package/lib/UseCases/SceneRoot/initializeSceneRoot.d.ts +2 -0
- package/lib/UseCases/SceneRoot/initializeSceneRoot.js +9 -0
- package/lib/UseCases/SceneRoot/setupSceneRoot.d.ts +2 -0
- package/lib/UseCases/SceneRoot/setupSceneRoot.js +11 -0
- package/lib/UseCases/index.d.ts +1 -1
- package/lib/UseCases/index.js +1 -1
- package/lib/ValueObjects/Vector3.d.ts +7 -10
- package/lib/ValueObjects/Vector3.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Vector3 } from "../ValueObjects";
|
|
2
|
+
import { ObservableEntity } from "./ObservableEntity";
|
|
3
|
+
import { SceneObject } from "./SceneObject";
|
|
4
|
+
export declare abstract class ModelMesh extends ObservableEntity {
|
|
5
|
+
abstract readonly id: string;
|
|
6
|
+
abstract label: string;
|
|
7
|
+
abstract position: Vector3;
|
|
8
|
+
abstract get canBeStuck(): boolean;
|
|
9
|
+
abstract stick(durationMS: number, easeFn: (val: number) => number, onStickComplete?: () => void): void;
|
|
10
|
+
abstract shown: boolean;
|
|
11
|
+
abstract meshPaths: string[];
|
|
12
|
+
abstract addMeshPath(path: string): void;
|
|
13
|
+
abstract hasMeshPath(path: string): boolean;
|
|
14
|
+
abstract removeMeshPath(path: string): void;
|
|
15
|
+
abstract toData(): ModelMeshDTO;
|
|
16
|
+
abstract applyData(data: ModelMeshDTO): void;
|
|
17
|
+
abstract readonly sceneObject: SceneObject;
|
|
18
|
+
}
|
|
19
|
+
export declare function makeModelMesh(dto: ModelMeshDTO, sceneObject: SceneObject): ModelMeshImp;
|
|
20
|
+
declare class ModelMeshImp extends ModelMesh {
|
|
21
|
+
readonly id: string;
|
|
22
|
+
readonly sceneObject: SceneObject;
|
|
23
|
+
get label(): string;
|
|
24
|
+
set label(l: string);
|
|
25
|
+
get position(): Vector3;
|
|
26
|
+
set position(p: Vector3);
|
|
27
|
+
get shown(): boolean;
|
|
28
|
+
set shown(show: boolean);
|
|
29
|
+
get canBeStuck(): boolean;
|
|
30
|
+
stick: (durationMS: number, easeFn: (val: number) => number, onStickComplete?: (() => void) | undefined) => void;
|
|
31
|
+
private _meshPaths;
|
|
32
|
+
get meshPaths(): string[];
|
|
33
|
+
set meshPaths(paths: string[]);
|
|
34
|
+
addMeshPath: (path: string) => void;
|
|
35
|
+
hasMeshPath: (path: string) => boolean;
|
|
36
|
+
removeMeshPath: (path: string) => void;
|
|
37
|
+
toData: () => ModelMeshDTO;
|
|
38
|
+
applyData: (data: ModelMeshDTO) => void;
|
|
39
|
+
constructor(dto: ModelMeshDTO, sceneObject: SceneObject);
|
|
40
|
+
}
|
|
41
|
+
export declare type ModelMeshDTO = ModelMeshDTOv0 | ModelMeshDTOv1;
|
|
42
|
+
export interface ModelMeshDTOv1 {
|
|
43
|
+
version: number;
|
|
44
|
+
id: string;
|
|
45
|
+
meshPaths: string[];
|
|
46
|
+
label: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ModelMeshDTOv0 {
|
|
49
|
+
id: string;
|
|
50
|
+
meshPaths: string[];
|
|
51
|
+
label: string;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeModelMesh = exports.ModelMesh = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
|
+
const ObservableEntity_1 = require("./ObservableEntity");
|
|
6
|
+
class ModelMesh extends ObservableEntity_1.ObservableEntity {
|
|
7
|
+
}
|
|
8
|
+
exports.ModelMesh = ModelMesh;
|
|
9
|
+
function makeModelMesh(dto, sceneObject) {
|
|
10
|
+
return new ModelMeshImp(dto, sceneObject);
|
|
11
|
+
}
|
|
12
|
+
exports.makeModelMesh = makeModelMesh;
|
|
13
|
+
class ModelMeshImp extends ModelMesh {
|
|
14
|
+
constructor(dto, sceneObject) {
|
|
15
|
+
super();
|
|
16
|
+
this.stick = (durationMS, easeFn, onStickComplete) => {
|
|
17
|
+
if (!this.canBeStuck) {
|
|
18
|
+
if (onStickComplete)
|
|
19
|
+
onStickComplete();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
this.sceneObject.transform.lerp(durationMS, easeFn, ValueObjects_1.Vector3.Zero(), undefined, undefined, onStickComplete);
|
|
23
|
+
};
|
|
24
|
+
this._meshPaths = [];
|
|
25
|
+
this.addMeshPath = (path) => {
|
|
26
|
+
if (this._meshPaths.includes(path))
|
|
27
|
+
return;
|
|
28
|
+
this._meshPaths.push(path);
|
|
29
|
+
this.notify();
|
|
30
|
+
};
|
|
31
|
+
this.hasMeshPath = (path) => {
|
|
32
|
+
return this._meshPaths.includes(path);
|
|
33
|
+
};
|
|
34
|
+
this.removeMeshPath = (path) => {
|
|
35
|
+
const index = this._meshPaths.indexOf(path);
|
|
36
|
+
if (index >= 0) {
|
|
37
|
+
this._meshPaths.splice(index, 1);
|
|
38
|
+
this.notify();
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
this.toData = () => {
|
|
42
|
+
const dto = {
|
|
43
|
+
version: 1,
|
|
44
|
+
id: this.id,
|
|
45
|
+
label: this.sceneObject.name,
|
|
46
|
+
meshPaths: [...this._meshPaths],
|
|
47
|
+
};
|
|
48
|
+
return dto;
|
|
49
|
+
};
|
|
50
|
+
this.applyData = (data) => {
|
|
51
|
+
this.sceneObject.name = data.label;
|
|
52
|
+
this.meshPaths = data.meshPaths;
|
|
53
|
+
};
|
|
54
|
+
this.id = dto.id;
|
|
55
|
+
this.sceneObject = sceneObject;
|
|
56
|
+
this.sceneObject.name = dto.label;
|
|
57
|
+
this.sceneObject.addObserver(this.notify);
|
|
58
|
+
this._meshPaths = [...dto.meshPaths];
|
|
59
|
+
}
|
|
60
|
+
get label() {
|
|
61
|
+
return this.sceneObject.name;
|
|
62
|
+
}
|
|
63
|
+
set label(l) {
|
|
64
|
+
this.sceneObject.name = l;
|
|
65
|
+
}
|
|
66
|
+
get position() {
|
|
67
|
+
return this.sceneObject.position;
|
|
68
|
+
}
|
|
69
|
+
set position(p) {
|
|
70
|
+
this.sceneObject.position = p;
|
|
71
|
+
}
|
|
72
|
+
get shown() {
|
|
73
|
+
return this.sceneObject.shown;
|
|
74
|
+
}
|
|
75
|
+
set shown(show) {
|
|
76
|
+
this.sceneObject.shown = show;
|
|
77
|
+
}
|
|
78
|
+
get canBeStuck() {
|
|
79
|
+
if (ValueObjects_1.Vector3.Equal(this.sceneObject.position, ValueObjects_1.Vector3.Zero())) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
get meshPaths() {
|
|
87
|
+
return [...this._meshPaths];
|
|
88
|
+
}
|
|
89
|
+
set meshPaths(paths) {
|
|
90
|
+
let pathsHaveChanged = false;
|
|
91
|
+
if (paths.length !== this._meshPaths.length) {
|
|
92
|
+
pathsHaveChanged = true;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
paths.forEach((path, i) => {
|
|
96
|
+
if (path !== this._meshPaths[i]) {
|
|
97
|
+
pathsHaveChanged = true;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if (!pathsHaveChanged)
|
|
102
|
+
return;
|
|
103
|
+
this._meshPaths = paths;
|
|
104
|
+
this.notify();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Quaternion, Vector3 } from "../ValueObjects";
|
|
2
2
|
import { ObservableEntity } from "./ObservableEntity";
|
|
3
|
-
import { SceneModelObjectDTOv1, SceneModelObjectDTOv0 as SceneModelObjectDTOv0,
|
|
3
|
+
import { SceneModelObjectDTOv1, SceneModelObjectDTOv0 as SceneModelObjectDTOv0, SceneModelMesh } from "./SceneModelMesh";
|
|
4
4
|
export declare enum SceneModelState {
|
|
5
5
|
INIT = "Initialized",
|
|
6
6
|
LOADING = "Loading",
|
|
@@ -17,12 +17,12 @@ export declare abstract class SceneModel extends ObservableEntity {
|
|
|
17
17
|
abstract defaultPosition: Vector3;
|
|
18
18
|
abstract defaultRotation: Quaternion;
|
|
19
19
|
abstract defaultScale: number;
|
|
20
|
-
abstract
|
|
21
|
-
abstract
|
|
22
|
-
abstract
|
|
23
|
-
abstract
|
|
24
|
-
abstract
|
|
25
|
-
abstract
|
|
20
|
+
abstract hasMesh(id: string): boolean;
|
|
21
|
+
abstract getMeshById(id: string): SceneModelMesh | undefined;
|
|
22
|
+
abstract getMeshByPath(path: string): SceneModelMesh | undefined;
|
|
23
|
+
abstract addMesh(object: SceneModelMesh): void;
|
|
24
|
+
abstract removeMesh(id: string): void;
|
|
25
|
+
abstract getAllMeshes(): SceneModelMesh[];
|
|
26
26
|
abstract applyData(data: SceneModelDTO): void;
|
|
27
27
|
abstract toData(): SceneModelDTO;
|
|
28
28
|
}
|
|
@@ -7,7 +7,7 @@ const MemoizedQuaternion_1 = require("./MemoizedQuaternion");
|
|
|
7
7
|
const MemoizedString_1 = require("./MemoizedString");
|
|
8
8
|
const MemoizedVector3_1 = require("./MemoizedVector3");
|
|
9
9
|
const ObservableEntity_1 = require("./ObservableEntity");
|
|
10
|
-
const
|
|
10
|
+
const SceneModelMesh_1 = require("./SceneModelMesh");
|
|
11
11
|
var SceneModelState;
|
|
12
12
|
(function (SceneModelState) {
|
|
13
13
|
SceneModelState["INIT"] = "Initialized";
|
|
@@ -33,13 +33,13 @@ class SceneModelImp extends SceneModel {
|
|
|
33
33
|
this._defaultScale = new MemoizedNumber_1.MemoizedNumber(1, this.notify);
|
|
34
34
|
this._state = new MemoizedString_1.MemoizedString(SceneModelState.INIT, this.notify);
|
|
35
35
|
this.sceneModelObjectLookup = new Map();
|
|
36
|
-
this.
|
|
36
|
+
this.hasMesh = (id) => {
|
|
37
37
|
return this.sceneModelObjectLookup.has(id);
|
|
38
38
|
};
|
|
39
|
-
this.
|
|
39
|
+
this.getMeshById = (id) => {
|
|
40
40
|
return this.sceneModelObjectLookup.get(id);
|
|
41
41
|
};
|
|
42
|
-
this.
|
|
42
|
+
this.getMeshByPath = (path) => {
|
|
43
43
|
let rVal;
|
|
44
44
|
this.sceneModelObjectLookup.forEach((sceneModelObject) => {
|
|
45
45
|
if (sceneModelObject.hasMeshPath(path)) {
|
|
@@ -48,7 +48,7 @@ class SceneModelImp extends SceneModel {
|
|
|
48
48
|
});
|
|
49
49
|
return rVal;
|
|
50
50
|
};
|
|
51
|
-
this.
|
|
51
|
+
this.addMesh = (object) => {
|
|
52
52
|
if (this.sceneModelObjectLookup.has(object.id)) {
|
|
53
53
|
const orig = this.sceneModelObjectLookup.get(object.id);
|
|
54
54
|
orig === null || orig === void 0 ? void 0 : orig.removeObserver(this.notify);
|
|
@@ -57,7 +57,7 @@ class SceneModelImp extends SceneModel {
|
|
|
57
57
|
object.addObserver(this.notify);
|
|
58
58
|
this.notify();
|
|
59
59
|
};
|
|
60
|
-
this.
|
|
60
|
+
this.removeMesh = (id) => {
|
|
61
61
|
const orig = this.sceneModelObjectLookup.get(id);
|
|
62
62
|
if (orig) {
|
|
63
63
|
this.sceneModelObjectLookup.delete(id);
|
|
@@ -65,7 +65,7 @@ class SceneModelImp extends SceneModel {
|
|
|
65
65
|
this.notify();
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
|
-
this.
|
|
68
|
+
this.getAllMeshes = () => {
|
|
69
69
|
return Array.from(this.sceneModelObjectLookup.values());
|
|
70
70
|
};
|
|
71
71
|
this.applyData = (data) => {
|
|
@@ -88,7 +88,7 @@ class SceneModelImp extends SceneModel {
|
|
|
88
88
|
defaultRotation: this.defaultRotation.dto,
|
|
89
89
|
defaultScale: this.defaultScale,
|
|
90
90
|
name: this.name,
|
|
91
|
-
objects: this.
|
|
91
|
+
objects: this.getAllMeshes().map((obj) => obj.toData()),
|
|
92
92
|
};
|
|
93
93
|
return data;
|
|
94
94
|
};
|
|
@@ -157,15 +157,16 @@ class SceneModelImp extends SceneModel {
|
|
|
157
157
|
existingObj.applyData(objectDTO);
|
|
158
158
|
}
|
|
159
159
|
else {
|
|
160
|
-
const newObj =
|
|
161
|
-
|
|
160
|
+
const newObj = SceneModelMesh_1.makeSceneModelMesh(objectDTO.id);
|
|
161
|
+
newObj.applyData(objectDTO);
|
|
162
|
+
this.addMesh(newObj);
|
|
162
163
|
}
|
|
163
164
|
objectsToKeep.push(objectDTO.id);
|
|
164
165
|
});
|
|
165
166
|
const allObjects = Array.from(this.sceneModelObjectLookup.keys());
|
|
166
167
|
allObjects.forEach((obj) => {
|
|
167
168
|
if (!objectsToKeep.includes(obj)) {
|
|
168
|
-
this.
|
|
169
|
+
this.removeMesh(obj);
|
|
169
170
|
}
|
|
170
171
|
});
|
|
171
172
|
this.notify();
|
|
@@ -184,15 +185,16 @@ class SceneModelImp extends SceneModel {
|
|
|
184
185
|
existingObj.applyData(objectDTO);
|
|
185
186
|
}
|
|
186
187
|
else {
|
|
187
|
-
const newObj =
|
|
188
|
-
|
|
188
|
+
const newObj = SceneModelMesh_1.makeSceneModelMesh(objectDTO.id);
|
|
189
|
+
newObj.applyData(objectDTO);
|
|
190
|
+
this.addMesh(newObj);
|
|
189
191
|
}
|
|
190
192
|
objectsToKeep.push(objectDTO.id);
|
|
191
193
|
});
|
|
192
194
|
const allObjects = Array.from(this.sceneModelObjectLookup.keys());
|
|
193
195
|
allObjects.forEach((obj) => {
|
|
194
196
|
if (!objectsToKeep.includes(obj)) {
|
|
195
|
-
this.
|
|
197
|
+
this.removeMesh(obj);
|
|
196
198
|
}
|
|
197
199
|
});
|
|
198
200
|
this.notify();
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Vector3, Vector3DTO } from "../ValueObjects";
|
|
2
|
+
import { ObservableEntity } from "./ObservableEntity";
|
|
3
|
+
import { SceneObject } from "./SceneObject";
|
|
4
|
+
export interface SceneModelMeshStateDTO {
|
|
5
|
+
id: string;
|
|
6
|
+
shown: boolean;
|
|
7
|
+
position: Vector3DTO;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class SceneModelMesh extends ObservableEntity {
|
|
10
|
+
abstract readonly id: string;
|
|
11
|
+
abstract label: string;
|
|
12
|
+
abstract meshPaths: string[];
|
|
13
|
+
abstract sceneObject: SceneObject | undefined;
|
|
14
|
+
abstract shown: boolean;
|
|
15
|
+
abstract position: Vector3;
|
|
16
|
+
abstract get canBeStuck(): boolean;
|
|
17
|
+
abstract stick(durationMS: number, easeFn: (val: number) => number, onStickComplete?: () => void): void;
|
|
18
|
+
abstract moveTo(position: Vector3, durationMS: number, easeFn: (val: number) => number, onStickComplete?: () => void): void;
|
|
19
|
+
abstract addMeshPath(path: string): void;
|
|
20
|
+
abstract hasMeshPath(path: string): boolean;
|
|
21
|
+
abstract removeMeshPath(path: string): void;
|
|
22
|
+
abstract toData(): SceneModelObjectDTO;
|
|
23
|
+
abstract applyData(data: SceneModelObjectDTO): void;
|
|
24
|
+
abstract getState(): SceneModelMeshStateDTO | null;
|
|
25
|
+
}
|
|
26
|
+
export declare function makeSceneModelMesh(id: string): SceneModelMeshImp;
|
|
27
|
+
declare class SceneModelMeshImp extends SceneModelMesh {
|
|
28
|
+
readonly id: string;
|
|
29
|
+
private _sceneObject;
|
|
30
|
+
get sceneObject(): SceneObject | undefined;
|
|
31
|
+
set sceneObject(so: SceneObject | undefined);
|
|
32
|
+
get position(): Vector3;
|
|
33
|
+
set position(p: Vector3);
|
|
34
|
+
get canBeStuck(): boolean;
|
|
35
|
+
moveTo(position: Vector3, durationMS: number, easeFn: (val: number) => number, onMoveComplete?: () => void): void;
|
|
36
|
+
stick: (durationMS: number, easeFn: (val: number) => number, onStickComplete?: (() => void) | undefined) => void;
|
|
37
|
+
get shown(): boolean;
|
|
38
|
+
set shown(s: boolean);
|
|
39
|
+
private _label;
|
|
40
|
+
get label(): string;
|
|
41
|
+
set label(label: string);
|
|
42
|
+
private _meshPaths;
|
|
43
|
+
get meshPaths(): string[];
|
|
44
|
+
set meshPaths(paths: string[]);
|
|
45
|
+
getState(): SceneModelMeshStateDTO | null;
|
|
46
|
+
addMeshPath: (path: string) => void;
|
|
47
|
+
hasMeshPath: (path: string) => boolean;
|
|
48
|
+
removeMeshPath: (path: string) => void;
|
|
49
|
+
toData: () => SceneModelObjectDTO;
|
|
50
|
+
applyData: (data: SceneModelObjectDTO) => void;
|
|
51
|
+
constructor(id: string);
|
|
52
|
+
}
|
|
53
|
+
export declare type SceneModelObjectDTO = SceneModelObjectDTOv0 | SceneModelObjectDTOv1;
|
|
54
|
+
export interface SceneModelObjectDTOv1 {
|
|
55
|
+
version: number;
|
|
56
|
+
id: string;
|
|
57
|
+
meshPaths: string[];
|
|
58
|
+
label: string;
|
|
59
|
+
}
|
|
60
|
+
export interface SceneModelObjectDTOv0 {
|
|
61
|
+
id: string;
|
|
62
|
+
meshPaths: string[];
|
|
63
|
+
label: string;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeSceneModelMesh = exports.SceneModelMesh = void 0;
|
|
4
|
+
const ValueObjects_1 = require("../ValueObjects");
|
|
5
|
+
const MemoizedString_1 = require("./MemoizedString");
|
|
6
|
+
const ObservableEntity_1 = require("./ObservableEntity");
|
|
7
|
+
class SceneModelMesh extends ObservableEntity_1.ObservableEntity {
|
|
8
|
+
}
|
|
9
|
+
exports.SceneModelMesh = SceneModelMesh;
|
|
10
|
+
function makeSceneModelMesh(id) {
|
|
11
|
+
return new SceneModelMeshImp(id);
|
|
12
|
+
}
|
|
13
|
+
exports.makeSceneModelMesh = makeSceneModelMesh;
|
|
14
|
+
class SceneModelMeshImp extends SceneModelMesh {
|
|
15
|
+
constructor(id) {
|
|
16
|
+
super();
|
|
17
|
+
this.stick = (durationMS, easeFn, onStickComplete) => {
|
|
18
|
+
this.moveTo(ValueObjects_1.Vector3.Zero(), durationMS, easeFn, onStickComplete);
|
|
19
|
+
};
|
|
20
|
+
this._label = new MemoizedString_1.MemoizedString("", this.notify);
|
|
21
|
+
this._meshPaths = [];
|
|
22
|
+
this.addMeshPath = (path) => {
|
|
23
|
+
if (this._meshPaths.includes(path))
|
|
24
|
+
return;
|
|
25
|
+
this._meshPaths.push(path);
|
|
26
|
+
this.notify();
|
|
27
|
+
};
|
|
28
|
+
this.hasMeshPath = (path) => {
|
|
29
|
+
return this._meshPaths.includes(path);
|
|
30
|
+
};
|
|
31
|
+
this.removeMeshPath = (path) => {
|
|
32
|
+
const index = this._meshPaths.indexOf(path);
|
|
33
|
+
if (index >= 0) {
|
|
34
|
+
this._meshPaths.splice(index, 1);
|
|
35
|
+
this.notify();
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
this.toData = () => {
|
|
39
|
+
const dto = {
|
|
40
|
+
version: 1,
|
|
41
|
+
id: this.id,
|
|
42
|
+
label: this.label,
|
|
43
|
+
meshPaths: [...this._meshPaths],
|
|
44
|
+
};
|
|
45
|
+
return dto;
|
|
46
|
+
};
|
|
47
|
+
this.applyData = (data) => {
|
|
48
|
+
this.label = data.label;
|
|
49
|
+
this.meshPaths = data.meshPaths;
|
|
50
|
+
};
|
|
51
|
+
this.id = id;
|
|
52
|
+
}
|
|
53
|
+
get sceneObject() {
|
|
54
|
+
return this._sceneObject;
|
|
55
|
+
}
|
|
56
|
+
set sceneObject(so) {
|
|
57
|
+
if (this._sceneObject) {
|
|
58
|
+
this._sceneObject.removeObserver(this.notify);
|
|
59
|
+
}
|
|
60
|
+
this._sceneObject = so;
|
|
61
|
+
if (this._sceneObject) {
|
|
62
|
+
this._sceneObject.addObserver(this.notify);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
get position() {
|
|
66
|
+
if (!this._sceneObject) {
|
|
67
|
+
console.warn("Scene Mesh doea not have a scene object");
|
|
68
|
+
return ValueObjects_1.Vector3.Zero();
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return this._sceneObject.transform.localPosition;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
set position(p) {
|
|
75
|
+
if (!this._sceneObject) {
|
|
76
|
+
console.warn("Scene Mesh doea not have a scene object");
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
this._sceneObject.transform.localPosition = p;
|
|
80
|
+
}
|
|
81
|
+
get canBeStuck() {
|
|
82
|
+
if (!this._sceneObject) {
|
|
83
|
+
console.warn("Scene Mesh doea not have a scene object");
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (ValueObjects_1.Vector3.Equal(this._sceneObject.transform.localPosition, ValueObjects_1.Vector3.Zero())) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
moveTo(position, durationMS, easeFn, onMoveComplete) {
|
|
94
|
+
if (!this._sceneObject) {
|
|
95
|
+
console.warn("Scene Mesh doea not have a scene object");
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (ValueObjects_1.Vector3.Equal(position, this.position)) {
|
|
99
|
+
if (onMoveComplete)
|
|
100
|
+
onMoveComplete();
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this._sceneObject.transform.lerp(durationMS, easeFn, position, undefined, undefined, onMoveComplete);
|
|
104
|
+
}
|
|
105
|
+
get shown() {
|
|
106
|
+
if (!this._sceneObject) {
|
|
107
|
+
console.warn("Scene Mesh doea not have a scene object");
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
return this._sceneObject.shown;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
set shown(s) {
|
|
115
|
+
if (!this._sceneObject) {
|
|
116
|
+
console.warn("Scene Mesh doea not have a scene object");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this._sceneObject.shown = s;
|
|
120
|
+
}
|
|
121
|
+
get label() {
|
|
122
|
+
return this._label.val;
|
|
123
|
+
}
|
|
124
|
+
set label(label) {
|
|
125
|
+
this._label.val = label;
|
|
126
|
+
}
|
|
127
|
+
get meshPaths() {
|
|
128
|
+
return [...this._meshPaths];
|
|
129
|
+
}
|
|
130
|
+
set meshPaths(paths) {
|
|
131
|
+
let pathsHaveChanged = false;
|
|
132
|
+
if (paths.length !== this._meshPaths.length) {
|
|
133
|
+
pathsHaveChanged = true;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
paths.forEach((path, i) => {
|
|
137
|
+
if (path !== this._meshPaths[i]) {
|
|
138
|
+
pathsHaveChanged = true;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
if (!pathsHaveChanged)
|
|
143
|
+
return;
|
|
144
|
+
this._meshPaths = paths;
|
|
145
|
+
this.notify();
|
|
146
|
+
}
|
|
147
|
+
getState() {
|
|
148
|
+
if (ValueObjects_1.Vector3.Equal(this.position, ValueObjects_1.Vector3.Zero()) && this.shown) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return {
|
|
153
|
+
id: this.id,
|
|
154
|
+
position: this.position.dto,
|
|
155
|
+
shown: this.shown,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -2,14 +2,11 @@ import { ObservableEntity } from "./ObservableEntity";
|
|
|
2
2
|
import { TransformNode } from "./TransformNode";
|
|
3
3
|
export declare abstract class SceneObject extends ObservableEntity {
|
|
4
4
|
abstract readonly id: string;
|
|
5
|
-
abstract get label(): string;
|
|
6
|
-
abstract set label(label: string);
|
|
7
5
|
abstract get shown(): boolean;
|
|
8
6
|
abstract set shown(shown: boolean);
|
|
9
7
|
abstract get enabled(): boolean;
|
|
10
8
|
abstract set enabled(enabled: boolean);
|
|
11
|
-
abstract get canBeStuck(): boolean;
|
|
12
|
-
abstract stick(durationMS: number, easeFn: (val: number) => number, onStickComplete?: () => void): void;
|
|
13
9
|
abstract transform: TransformNode;
|
|
10
|
+
abstract sceneTransform: unknown;
|
|
14
11
|
}
|
|
15
12
|
export declare function makeSceneObject(id: string): SceneObject;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.makeSceneObject = exports.SceneObject = void 0;
|
|
4
|
-
const ValueObjects_1 = require("../ValueObjects");
|
|
5
4
|
const MemoizedBoolean_1 = require("./MemoizedBoolean");
|
|
6
5
|
const MemoizedString_1 = require("./MemoizedString");
|
|
7
6
|
const ObservableEntity_1 = require("./ObservableEntity");
|
|
@@ -20,14 +19,6 @@ class SceneObjectImp extends SceneObject {
|
|
|
20
19
|
this.memoizedShown = new MemoizedBoolean_1.MemoizedBoolean(true, this.notify);
|
|
21
20
|
this.memoizedEnabled = new MemoizedBoolean_1.MemoizedBoolean(true, this.notify);
|
|
22
21
|
this.transform = TransformNode_1.makeTransformNode();
|
|
23
|
-
this.stick = (durationMS, easeFn, onStickComplete) => {
|
|
24
|
-
if (!this.canBeStuck) {
|
|
25
|
-
if (onStickComplete)
|
|
26
|
-
onStickComplete();
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
this.transform.lerp(durationMS, easeFn, ValueObjects_1.Vector3.Zero(), undefined, undefined, onStickComplete);
|
|
30
|
-
};
|
|
31
22
|
this.id = id;
|
|
32
23
|
this.transform.addObserver(this.notify);
|
|
33
24
|
}
|
|
@@ -49,12 +40,4 @@ class SceneObjectImp extends SceneObject {
|
|
|
49
40
|
set enabled(enabled) {
|
|
50
41
|
this.memoizedEnabled.val = enabled;
|
|
51
42
|
}
|
|
52
|
-
get canBeStuck() {
|
|
53
|
-
if (ValueObjects_1.Vector3.Equal(this.transform.localPosition, ValueObjects_1.Vector3.Zero())) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
return true;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
43
|
}
|
|
@@ -1,69 +1,29 @@
|
|
|
1
1
|
import { Quaternion, Vector3 } from "../ValueObjects";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ObservableEntity } from "./ObservableEntity";
|
|
3
|
+
import { SceneObject } from "./SceneObject";
|
|
4
|
+
import { EaseFn } from "./TransformNode";
|
|
5
|
+
export declare const SCENE_ROOT_ID = "scene-root";
|
|
4
6
|
export interface DefaultSceneRootData {
|
|
5
7
|
position: [number, number, number];
|
|
6
8
|
rotation: [number, number, number, number];
|
|
7
9
|
scale: number;
|
|
8
|
-
id: string;
|
|
9
10
|
minScale: number;
|
|
10
11
|
maxScale: number;
|
|
11
12
|
}
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
minScale: number;
|
|
29
|
-
/**
|
|
30
|
-
* The maximum scale allowed for the scene root
|
|
31
|
-
*/
|
|
32
|
-
maxScale: number;
|
|
33
|
-
/**
|
|
34
|
-
* The identifier for the scene root
|
|
35
|
-
*/
|
|
36
|
-
id: string;
|
|
37
|
-
/**
|
|
38
|
-
* Transform node for the scene root
|
|
39
|
-
*/
|
|
40
|
-
transform: TransformNode;
|
|
41
|
-
/**
|
|
42
|
-
* Applies the default data to this entity. This will not trigger a notification
|
|
43
|
-
*/
|
|
44
|
-
applyDefaultData: (data: DefaultSceneRootData) => void;
|
|
45
|
-
/**
|
|
46
|
-
* Smoothly moves the transform so that the point is a the world origin
|
|
47
|
-
* @param point The point to center on in world coordinates
|
|
48
|
-
* @param durationMS The duration of the transition in milliseconds
|
|
49
|
-
* @param easeFn The easing funciton
|
|
50
|
-
* @param onCompleted An optional callback function when the ease is completed
|
|
51
|
-
*/
|
|
52
|
-
centerOnPoint: (point: Vector3, durationMS: number, easeFn: EaseFn, onCompleted?: () => void) => void;
|
|
53
|
-
/**
|
|
54
|
-
* Smoothly moves the transform so that it is back in the default pose
|
|
55
|
-
* @param durationMS The duration of the transition in milliseconds
|
|
56
|
-
* @param easeFn The easing funciton
|
|
57
|
-
* @param onCompleted An optional callback function when the ease is completed
|
|
58
|
-
*/
|
|
59
|
-
lerpToDefault: (durationMS: number, easeFn: EaseFn, onCompleted?: () => void) => void;
|
|
60
|
-
/**
|
|
61
|
-
* Bumps the scale of the root by a specific amount. Note this will enforce the min and max limits
|
|
62
|
-
* @param amount The world amount to bump the scale by. It will be applied uniformly
|
|
63
|
-
* @param worldPoint The world position about which to apply the scaling
|
|
64
|
-
*/
|
|
65
|
-
bumpScaleAboutPoint: (amount: number, worldPoint: Vector3) => void;
|
|
66
|
-
addObserver: (observer: OnSceneRootChange) => void;
|
|
67
|
-
removeObserver: (observer: OnSceneRootChange) => void;
|
|
13
|
+
export declare abstract class SceneRoot extends ObservableEntity {
|
|
14
|
+
abstract defaultPosition: Vector3;
|
|
15
|
+
abstract defaultRoation: Quaternion;
|
|
16
|
+
abstract defaultScale: number;
|
|
17
|
+
abstract minScale: number;
|
|
18
|
+
abstract maxScale: number;
|
|
19
|
+
abstract id: string;
|
|
20
|
+
abstract sceneObject: SceneObject | undefined;
|
|
21
|
+
abstract position: Vector3;
|
|
22
|
+
abstract rotation: Quaternion;
|
|
23
|
+
abstract scale: number;
|
|
24
|
+
abstract applyDefaultData: (data: DefaultSceneRootData) => void;
|
|
25
|
+
abstract centerOnPoint: (point: Vector3, durationMS: number, easeFn: EaseFn, onCompleted?: () => void) => void;
|
|
26
|
+
abstract lerpToDefault: (durationMS: number, easeFn: EaseFn, onCompleted?: () => void) => void;
|
|
27
|
+
abstract bumpScaleAboutPoint: (amount: number, worldPoint: Vector3) => void;
|
|
68
28
|
}
|
|
69
29
|
export declare function makeSceneRoot(): SceneRoot;
|