@vived/app 4.18.0 → 4.19.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.
@@ -1,5 +1,5 @@
1
1
  import { AppObject, AppObjectEntity, AppObjectRepo } from "../../../AppObject";
2
- import { Quaternion, Vector3 } from "../../../ValueObjects";
2
+ import { Quaternion, QuaternionDTO, Vector3, Vector3DTO } from "../../../ValueObjects";
3
3
  import { ChannelModelObject } from "./ChannelModelObject";
4
4
  export declare enum ChannelModelState {
5
5
  INIT = "Initialized",
@@ -27,8 +27,10 @@ export declare abstract class ChannelModelEntity extends AppObjectEntity {
27
27
  abstract get modelError(): Error | undefined;
28
28
  abstract set modelError(val: Error | undefined);
29
29
  abstract get modelObjectIds(): string[];
30
- abstract get data(): ChannelModelDTOv2;
31
- abstract setupFromData(data: ChannelModelDTOv0 | ChannelModelDTOv1 | ChannelModelDTOv2): void;
30
+ abstract get rootRotation(): Quaternion;
31
+ abstract set rootRotation(val: Quaternion);
32
+ abstract get data(): ChannelModelDTO;
33
+ abstract setupFromData(data: object): void;
32
34
  abstract originalCollectionID?: string;
33
35
  abstract modelObjectFactory(id: string): ChannelModelObject;
34
36
  abstract addModelObject(id?: string): ChannelModelObject;
@@ -38,6 +40,24 @@ export declare abstract class ChannelModelEntity extends AppObjectEntity {
38
40
  static get(id: string, appObjects: AppObjectRepo): ChannelModelEntity | undefined;
39
41
  }
40
42
  export declare function makeChannelModelEntity(appObject: AppObject): ChannelModelEntity;
43
+ export interface ChannelModelDTO {
44
+ bounds_min: Vector3DTO;
45
+ bounds_max: Vector3DTO;
46
+ version: number;
47
+ objects: ChannelModelObjectDTO[];
48
+ name: string;
49
+ defaultPosition: Vector3DTO;
50
+ defaultRotation: QuaternionDTO;
51
+ defaultScale: number;
52
+ originalCollectionID?: string;
53
+ rootRotation: QuaternionDTO;
54
+ }
55
+ export interface ChannelModelObjectDTO {
56
+ id: string;
57
+ meshPaths: string[];
58
+ label: string;
59
+ tags: string[];
60
+ }
41
61
  export interface ChannelModelDTOv2 {
42
62
  version: 2;
43
63
  objects: ChannelModelDataMeshDTOv2[];
@@ -38,17 +38,92 @@ class ChannelModelEntityImp extends ChannelModelEntity {
38
38
  this._defaultPosition = new Entities_1.MemoizedVector3(ValueObjects_1.Vector3.Zero(), this.notifyOnChange);
39
39
  this._defaultRotation = new Entities_1.MemoizedQuaternion(ValueObjects_1.Quaternion.Identity(), this.notifyOnChange);
40
40
  this._defaultScale = new Entities_1.MemoizedNumber(1, this.notifyOnChange);
41
+ this._rootRotation = new Entities_1.MemoizedQuaternion(ValueObjects_1.Quaternion.Identity(), this.notifyOnChange);
41
42
  this._state = new Entities_1.MemoizedString(ChannelModelState.INIT, this.notifyOnChange);
42
43
  this.modelObjectLookup = new Map();
44
+ this.modelObjectFactory = (id) => {
45
+ const ao = this.appObjects.getOrCreate(id);
46
+ return ChannelModelObject_1.makeChannelModelObject(ao);
47
+ };
48
+ this.addModelObject = (id) => {
49
+ const idToUse = id !== null && id !== void 0 ? id : Utilities_1.generateUniqueID();
50
+ const obj = this.modelObjectFactory(idToUse);
51
+ this.modelObjectLookup.set(idToUse, obj);
52
+ obj.addChangeObserver(this.notifyOnChange);
53
+ this.notifyOnChange();
54
+ return obj;
55
+ };
56
+ this.getModelObject = (id) => {
57
+ return this.modelObjectLookup.get(id);
58
+ };
59
+ this.hasModelObject = (id) => {
60
+ return this.modelObjectLookup.has(id);
61
+ };
62
+ this.modelObjects = () => {
63
+ return Array.from(this.modelObjectLookup.values());
64
+ };
43
65
  this.setupFromData = (data) => {
44
- if (data.version === 2) {
45
- this.setupDataV2(data);
66
+ if ("bounds_max" in data) {
67
+ this.bounds_max = ValueObjects_1.Vector3.FromDTO(data.bounds_max);
68
+ }
69
+ else {
70
+ this.bounds_max = ValueObjects_1.Vector3.Zero();
71
+ }
72
+ if ("bounds_min" in data) {
73
+ this.bounds_min = ValueObjects_1.Vector3.FromDTO(data.bounds_min);
74
+ }
75
+ else {
76
+ this.bounds_min = ValueObjects_1.Vector3.Zero();
77
+ }
78
+ if ("defaultPosition" in data) {
79
+ this.defaultPosition = ValueObjects_1.Vector3.FromDTO(data.defaultPosition);
80
+ }
81
+ else {
82
+ this.defaultPosition = ValueObjects_1.Vector3.Zero();
46
83
  }
47
- else if (data.version === 1) {
48
- this.setupDataV2(this.mapDataV1toV2(data));
84
+ if ("defaultRotation" in data) {
85
+ this.defaultRotation = ValueObjects_1.Quaternion.FromDTO(data.defaultRotation);
49
86
  }
50
- else if (data.version === 0) {
51
- this.setupDataV2(this.mapDataV0toV2(data));
87
+ else {
88
+ this.defaultRotation = ValueObjects_1.Quaternion.Identity();
89
+ }
90
+ if ("rootRotation" in data) {
91
+ this.rootRotation = ValueObjects_1.Quaternion.FromDTO(data.rootRotation);
92
+ }
93
+ else {
94
+ this.rootRotation = ValueObjects_1.Quaternion.Identity();
95
+ }
96
+ if ("defaultScale" in data) {
97
+ this.defaultScale = data.defaultScale;
98
+ }
99
+ else {
100
+ this.defaultScale = 1;
101
+ }
102
+ if ("name" in data) {
103
+ this.name = data.name;
104
+ }
105
+ else {
106
+ this.name = "Unnamed Channel";
107
+ }
108
+ if ("originalCollectionID" in data) {
109
+ this.originalCollectionID = data.originalCollectionID;
110
+ }
111
+ if ("objects" in data) {
112
+ const objects = data.objects;
113
+ objects.forEach((obj) => {
114
+ if ("id" in obj) {
115
+ const modelObj = this.addModelObject(obj.id);
116
+ if ("label" in obj) {
117
+ modelObj.label = obj.label;
118
+ }
119
+ if ("meshPaths" in obj) {
120
+ modelObj.subMeshPaths = obj.meshPaths;
121
+ }
122
+ if ("tags" in obj) {
123
+ modelObj.tags = obj.tags;
124
+ }
125
+ }
126
+ });
52
127
  }
53
128
  };
54
129
  }
@@ -91,6 +166,12 @@ class ChannelModelEntityImp extends ChannelModelEntity {
91
166
  set defaultScale(scale) {
92
167
  this._defaultScale.val = scale;
93
168
  }
169
+ get rootRotation() {
170
+ return this._rootRotation.val;
171
+ }
172
+ set rootRotation(rotation) {
173
+ this._rootRotation.val = rotation;
174
+ }
94
175
  get state() {
95
176
  return this._state.val;
96
177
  }
@@ -104,27 +185,6 @@ class ChannelModelEntityImp extends ChannelModelEntity {
104
185
  this._error = val;
105
186
  this._state.val = ChannelModelState.ERROR;
106
187
  }
107
- modelObjectFactory(id) {
108
- const ao = this.appObjects.getOrCreate(id);
109
- return ChannelModelObject_1.makeChannelModelObject(ao);
110
- }
111
- addModelObject(id) {
112
- const idToUse = id !== null && id !== void 0 ? id : Utilities_1.generateUniqueID();
113
- const obj = this.modelObjectFactory(idToUse);
114
- this.modelObjectLookup.set(idToUse, obj);
115
- obj.addChangeObserver(this.notifyOnChange);
116
- this.notifyOnChange();
117
- return obj;
118
- }
119
- getModelObject(id) {
120
- return this.modelObjectLookup.get(id);
121
- }
122
- hasModelObject(id) {
123
- return this.modelObjectLookup.has(id);
124
- }
125
- modelObjects() {
126
- return Array.from(this.modelObjectLookup.values());
127
- }
128
188
  get modelObjectIds() {
129
189
  return Array.from(this.modelObjectLookup.keys());
130
190
  }
@@ -146,69 +206,9 @@ class ChannelModelEntityImp extends ChannelModelEntity {
146
206
  defaultScale: this._defaultScale.val,
147
207
  name: this._name.val,
148
208
  objects,
149
- version: 2,
209
+ version: 1,
150
210
  originalCollectionID: this.originalCollectionID,
151
- };
152
- }
153
- setupDataV2(data) {
154
- const { bounds_max, bounds_min, defaultPosition, defaultRotation, defaultScale, name, objects, originalCollectionID, } = data;
155
- this.bounds_max = ValueObjects_1.Vector3.FromDTO(bounds_max);
156
- this.bounds_min = ValueObjects_1.Vector3.FromDTO(bounds_min);
157
- this.defaultPosition = ValueObjects_1.Vector3.FromDTO(defaultPosition);
158
- this.defaultRotation = ValueObjects_1.Quaternion.FromDTO(defaultRotation);
159
- this.defaultScale = defaultScale;
160
- this.name = name;
161
- this.originalCollectionID = originalCollectionID;
162
- objects.forEach((obj) => {
163
- const { id, label, meshPaths, tags } = obj;
164
- const modelObj = this.addModelObject(id);
165
- modelObj.label = label;
166
- modelObj.subMeshPaths = meshPaths;
167
- modelObj.tags = tags;
168
- });
169
- }
170
- mapDataV1toV2(data) {
171
- const { bounds_max, bounds_min, defaultPosition, defaultRotation, defaultScale, name, objects, } = data;
172
- const mappedObject = objects.map((obj) => {
173
- const { id, label, meshPaths } = obj;
174
- return {
175
- id,
176
- label,
177
- meshPaths,
178
- tags: [],
179
- };
180
- });
181
- return {
182
- bounds_max,
183
- bounds_min,
184
- defaultPosition,
185
- defaultRotation,
186
- defaultScale,
187
- name,
188
- objects: mappedObject,
189
- version: 2,
190
- };
191
- }
192
- mapDataV0toV2(data) {
193
- const { bounds_max, bounds_min, defaultPosition, defaultRotation, defaultScale, name, objects, } = data;
194
- const mappedObject = objects.map((obj) => {
195
- const { id, label, meshPaths } = obj;
196
- return {
197
- id,
198
- label,
199
- meshPaths,
200
- tags: [],
201
- };
202
- });
203
- return {
204
- bounds_max,
205
- bounds_min,
206
- defaultPosition,
207
- defaultRotation,
208
- defaultScale,
209
- name,
210
- objects: mappedObject,
211
- version: 2,
211
+ rootRotation: this._rootRotation.val.dto,
212
212
  };
213
213
  }
214
214
  }
@@ -0,0 +1,9 @@
1
+ /// <reference types="jest" />
2
+ import { AppObject, AppObjectRepo } from "../../../AppObject";
3
+ import { ChannelModelViewFactory } from "../UC/ChannelModelViewFactory";
4
+ export declare class ChannelModelViewFactoryMock extends ChannelModelViewFactory {
5
+ disposeView: jest.Mock<any, any>;
6
+ initializeView: jest.Mock<any, any>;
7
+ constructor(appObject: AppObject);
8
+ }
9
+ export declare function makeChannelModelViewFactoryMock(appObjects: AppObjectRepo): ChannelModelViewFactoryMock;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeChannelModelViewFactoryMock = exports.ChannelModelViewFactoryMock = void 0;
4
+ const ChannelModelViewFactory_1 = require("../UC/ChannelModelViewFactory");
5
+ class ChannelModelViewFactoryMock extends ChannelModelViewFactory_1.ChannelModelViewFactory {
6
+ constructor(appObject) {
7
+ super(appObject, ChannelModelViewFactory_1.ChannelModelViewFactory.type);
8
+ this.disposeView = jest.fn();
9
+ this.initializeView = jest.fn();
10
+ }
11
+ }
12
+ exports.ChannelModelViewFactoryMock = ChannelModelViewFactoryMock;
13
+ function makeChannelModelViewFactoryMock(appObjects) {
14
+ return new ChannelModelViewFactoryMock(appObjects.getOrCreate("ChannelModelViewFactoryMock"));
15
+ }
16
+ exports.makeChannelModelViewFactoryMock = makeChannelModelViewFactoryMock;
@@ -1,3 +1,3 @@
1
1
  export * from "./ChannelModelObjectPMMock";
2
2
  export * from "./ChannelModelPMMock";
3
- export * from "./ProcessChannelModelUCMock";
3
+ export * from "./ChannelModelViewFactoryMock";
@@ -12,4 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./ChannelModelObjectPMMock"), exports);
14
14
  __exportStar(require("./ChannelModelPMMock"), exports);
15
- __exportStar(require("./ProcessChannelModelUCMock"), exports);
15
+ __exportStar(require("./ChannelModelViewFactoryMock"), exports);
@@ -0,0 +1,8 @@
1
+ import { AppObjectRepo, AppObjectUC } from "../../../AppObject";
2
+ import { ChannelModelEntity } from "../Entities";
3
+ export declare abstract class ChannelModelViewFactory extends AppObjectUC {
4
+ static type: string;
5
+ abstract initializeView(channelModel: ChannelModelEntity): void;
6
+ abstract disposeView(id: string): void;
7
+ static get(appObjects: AppObjectRepo): ChannelModelViewFactory | undefined;
8
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChannelModelViewFactory = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ class ChannelModelViewFactory extends AppObject_1.AppObjectUC {
6
+ static get(appObjects) {
7
+ return AppObject_1.getSingletonComponent(ChannelModelViewFactory.type, appObjects);
8
+ }
9
+ }
10
+ exports.ChannelModelViewFactory = ChannelModelViewFactory;
11
+ ChannelModelViewFactory.type = "ChannelModelViewFactory";
@@ -1,3 +1 @@
1
- export * from "./ProcessChannelModelUC";
2
- export * from "./SelectChannelModelUC";
3
- export * from "./SetupChannelModelUC";
1
+ export * from "./ChannelModelViewFactory";
@@ -10,6 +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("./ProcessChannelModelUC"), exports);
14
- __exportStar(require("./SelectChannelModelUC"), exports);
15
- __exportStar(require("./SetupChannelModelUC"), exports);
13
+ __exportStar(require("./ChannelModelViewFactory"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "4.18.0",
3
+ "version": "4.19.0",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",