@vived/app 4.34.8 → 4.34.10

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.
@@ -8,6 +8,7 @@ export declare abstract class CalloutRepo extends AppObjectEntityRepo<CalloutEnt
8
8
  abstract calloutFactory(id: string): CalloutEntity;
9
9
  abstract makeCallout(id?: string): CalloutEntity;
10
10
  abstract deleteCallout(id: string): void;
11
+ abstract applySurrogateTransform(transform: Transform3D): void;
11
12
  static get(appObj: AppObject): CalloutRepo | undefined;
12
13
  static getById(id: string, appObjects: AppObjectRepo): CalloutRepo | undefined;
13
14
  static addIfMissing(appObject: AppObject): CalloutRepo;
@@ -32,12 +32,15 @@ exports.makeCalloutRepoEntity = makeCalloutRepoEntity;
32
32
  class CalloutRepoImp extends CalloutRepo {
33
33
  constructor(appObject) {
34
34
  super(appObject, CalloutRepo.type);
35
+ this.applySurrogateTransform = (transform) => {
36
+ this._transform = transform;
37
+ };
35
38
  this.makeCallout = (id) => {
36
39
  const idToUse = id !== null && id !== void 0 ? id : generateUniqueID_1.generateUniqueID();
37
40
  const callout = this.calloutFactory(idToUse);
38
41
  callout.inRepo = this;
39
- callout.rootTransform.parent = this.transform;
40
- callout.labelTransform.parent = this.transform;
42
+ callout.rootTransform.parent = this._transform;
43
+ callout.labelTransform.parent = this._transform;
41
44
  this.add(callout);
42
45
  return callout;
43
46
  };
@@ -45,7 +48,10 @@ class CalloutRepoImp extends CalloutRepo {
45
48
  const ao = this.appObjects.getOrCreate(id);
46
49
  return CalloutEntity_1.makeCalloutEntity(ao);
47
50
  };
48
- this.transform = Transform3D_1.Transform3D.addIfMissing(appObject);
51
+ this._transform = Transform3D_1.Transform3D.addIfMissing(appObject);
52
+ }
53
+ get transform() {
54
+ return this._transform;
49
55
  }
50
56
  deleteCallout(id) {
51
57
  const callout = this.getForAppObject(id);
@@ -31,8 +31,8 @@ class LookAtCameraUCIMP extends LookAtCameraUC {
31
31
  return;
32
32
  }
33
33
  const worldDir = ValueObjects_1.Vector3.Subtract(this.cameraPos, this.callout.labelTransform.worldPosition);
34
- const localDir = parent.worldDirectionToLocal(worldDir);
35
- const desiredQ = ValueObjects_1.Quaternion.FromDirectionVector(localDir);
34
+ // const localDir = parent.worldDirectionToLocal(worldDir);
35
+ const desiredQ = ValueObjects_1.Quaternion.FromDirectionVector(worldDir);
36
36
  if (ValueObjects_1.Quaternion.Close(this.targetQ, desiredQ)) {
37
37
  return;
38
38
  }
@@ -43,7 +43,7 @@ class LookAtCameraUCIMP extends LookAtCameraUC {
43
43
  };
44
44
  this.stopSlerping = () => {
45
45
  if (this.callout) {
46
- this.callout.labelTransform.localRotation = this.targetQ;
46
+ this.callout.labelTransform.worldRotation = this.targetQ;
47
47
  }
48
48
  if (this.slerpInterval) {
49
49
  clearInterval(this.slerpInterval);
@@ -75,9 +75,9 @@ class LookAtCameraUCIMP extends LookAtCameraUC {
75
75
  const transform = (_a = this.callout) === null || _a === void 0 ? void 0 : _a.labelTransform;
76
76
  if (!transform)
77
77
  return;
78
- let previousError = ValueObjects_1.Quaternion.AngleBetween(transform.localRotation, this.targetQ).degrees;
78
+ let previousError = ValueObjects_1.Quaternion.AngleBetween(transform.worldRotation, this.targetQ).degrees;
79
79
  this.slerpInterval = setInterval(() => {
80
- const error = ValueObjects_1.Quaternion.AngleBetween(transform.localRotation, this.targetQ).degrees;
80
+ const error = ValueObjects_1.Quaternion.AngleBetween(transform.worldRotation, this.targetQ).degrees;
81
81
  if (error < 0.15) {
82
82
  this.stopSlerping();
83
83
  return;
@@ -96,8 +96,8 @@ class LookAtCameraUCIMP extends LookAtCameraUC {
96
96
  if (slerpPercent > 1) {
97
97
  slerpPercent = 1;
98
98
  }
99
- const slerpedQ = ValueObjects_1.Quaternion.Slerp(transform.localRotation, this.targetQ, slerpPercent);
100
- transform.localRotation = slerpedQ;
99
+ const slerpedQ = ValueObjects_1.Quaternion.Slerp(transform.worldRotation, this.targetQ, slerpPercent);
100
+ transform.worldRotation = slerpedQ;
101
101
  previousError = error;
102
102
  }, 10);
103
103
  }
@@ -4,10 +4,11 @@ import { LandmarkEntity } from "./LandmarkEntity";
4
4
  export declare type LandmarkFactory = (id: string) => LandmarkEntity;
5
5
  export declare abstract class LandmarkRepo extends AppObjectEntityRepo<LandmarkEntity> {
6
6
  static readonly type = "LANDMARK_REPO";
7
- abstract readonly transform: Transform3D;
7
+ abstract get transform(): Transform3D;
8
8
  abstract landmarkFactory(id: string): LandmarkEntity;
9
9
  abstract createLandmark(id?: string): LandmarkEntity;
10
10
  abstract deleteLandmark(id: string): void;
11
+ abstract applySurrogateTransform(transform: Transform3D): void;
11
12
  static get(appObj: AppObject): LandmarkRepo | undefined;
12
13
  static getByID(id: string, appObjects: AppObjectRepo): LandmarkRepo | undefined;
13
14
  static addIfMissing(appObject: AppObject): LandmarkRepo;
@@ -43,7 +43,13 @@ class LandmarkRepoImp extends LandmarkRepo {
43
43
  const ao = this.appObjects.getOrCreate(id);
44
44
  return LandmarkEntity_1.makeLandmarkEntity(ao);
45
45
  };
46
- this.transform = Transform3D_1.Transform3D.addIfMissing(this.appObject);
46
+ this._transform = Transform3D_1.Transform3D.addIfMissing(this.appObject);
47
+ }
48
+ get transform() {
49
+ return this._transform;
50
+ }
51
+ applySurrogateTransform(transform) {
52
+ this._transform = transform;
47
53
  }
48
54
  deleteLandmark(id) {
49
55
  const landmark = this.getForAppObject(id);
@@ -5,6 +5,7 @@ export interface SelectableStateVM {
5
5
  isSelected: boolean;
6
6
  isPressed: boolean;
7
7
  isHovered: boolean;
8
+ somethingElseIsSelected: boolean;
8
9
  }
9
10
  export declare const defaultSelectableStateVM: SelectableStateVM;
10
11
  export declare abstract class SelectableStatePM extends AppObjectPM<SelectableStateVM> {
@@ -2,11 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeSelectableStatePM = exports.SelectableStatePM = exports.defaultSelectableStateVM = void 0;
4
4
  const AppObjectPM_1 = require("../../../AppObject/AppObjectPM");
5
- const Selectable_1 = require("../Entities/Selectable");
5
+ const Entities_1 = require("../Entities");
6
6
  exports.defaultSelectableStateVM = {
7
7
  isHovered: false,
8
8
  isPressed: false,
9
9
  isSelected: false,
10
+ somethingElseIsSelected: false,
10
11
  };
11
12
  class SelectableStatePM extends AppObjectPM_1.AppObjectPM {
12
13
  static get(id, appObjects) {
@@ -23,28 +24,39 @@ function makeSelectableStatePM(appObject) {
23
24
  exports.makeSelectableStatePM = makeSelectableStatePM;
24
25
  class SelectableStatePMImp extends SelectableStatePM {
25
26
  constructor(appObject) {
26
- var _a;
27
+ var _a, _b;
27
28
  super(appObject, SelectableStatePM.type);
28
29
  this.onSelectionChange = () => {
29
- if (!this.selectable)
30
+ if (!this.selectable || !this.selection)
30
31
  return;
32
+ let somethingElseIsSelected = false;
33
+ const selectedObject = this.selection.selectedObjectId;
34
+ if (selectedObject !== null && selectedObject !== this.appObject.id) {
35
+ somethingElseIsSelected = true;
36
+ }
31
37
  const vm = {
32
38
  isHovered: this.selectable.hovered,
33
39
  isPressed: this.selectable.pressed,
34
40
  isSelected: this.selectable.selected,
41
+ somethingElseIsSelected,
35
42
  };
36
43
  this.doUpdateView(vm);
37
44
  };
38
45
  this.dispose = () => {
39
- var _a;
46
+ var _a, _b;
40
47
  super.dispose();
41
48
  (_a = this.selectable) === null || _a === void 0 ? void 0 : _a.removeChangeObserver(this.onSelectionChange);
49
+ (_b = this.selection) === null || _b === void 0 ? void 0 : _b.removeChangeObserver(this.onSelectionChange);
42
50
  };
43
51
  (_a = this.selectable) === null || _a === void 0 ? void 0 : _a.addChangeObserver(this.onSelectionChange);
52
+ (_b = this.selection) === null || _b === void 0 ? void 0 : _b.addChangeObserver(this.onSelectionChange);
44
53
  this.onSelectionChange();
45
54
  }
46
55
  get selectable() {
47
- return this.getCachedLocalComponent(Selectable_1.Selectable.type);
56
+ return this.getCachedLocalComponent(Entities_1.Selectable.type);
57
+ }
58
+ get selection() {
59
+ return this.getCachedSingleton(Entities_1.Selection.type);
48
60
  }
49
61
  vmsAreEqual(a, b) {
50
62
  if (a.isHovered !== b.isHovered)
@@ -53,6 +65,8 @@ class SelectableStatePMImp extends SelectableStatePM {
53
65
  return false;
54
66
  if (a.isSelected !== b.isSelected)
55
67
  return false;
68
+ if (a.somethingElseIsSelected !== b.somethingElseIsSelected)
69
+ return false;
56
70
  return true;
57
71
  }
58
72
  }
@@ -5,6 +5,7 @@ const AppObjectUC_1 = require("../../../AppObject/AppObjectUC");
5
5
  const ValueObjects_1 = require("../../../ValueObjects");
6
6
  const StateMachineEntity_1 = require("../../StateMachine/Entities/StateMachineEntity");
7
7
  const StoredView_1 = require("../Entities/StoredView");
8
+ const RestoreStoredViewUC_1 = require("./RestoreStoredViewUC");
8
9
  class SerializeStoredView extends AppObjectUC_1.AppObjectUC {
9
10
  constructor() {
10
11
  super(...arguments);
@@ -32,6 +33,9 @@ class SerializeStoredViewImp extends SerializeStoredView {
32
33
  get storedView() {
33
34
  return this.getCachedSingleton(StoredView_1.StoredView.type);
34
35
  }
36
+ get restoreStoredViewUC() {
37
+ return this.getCachedSingleton(RestoreStoredViewUC_1.RestoreStoredViewUC.type);
38
+ }
35
39
  getSystemState() {
36
40
  if (!this.storedView) {
37
41
  console.warn("[SerializeStoredView] No stored view entity");
@@ -72,6 +76,7 @@ class SerializeStoredViewImp extends SerializeStoredView {
72
76
  this.storedView.hasStoredView = false;
73
77
  }
74
78
  applyV1Data(data) {
79
+ var _a;
75
80
  if (!this.storedView) {
76
81
  console.warn("[SerializeStoredView] No stored view entity");
77
82
  return;
@@ -82,5 +87,8 @@ class SerializeStoredViewImp extends SerializeStoredView {
82
87
  this.storedView.rotation = rot;
83
88
  this.storedView.scale = data.scale;
84
89
  this.storedView.hasStoredView = data.hasStoredView;
90
+ if (data.hasStoredView) {
91
+ (_a = this.restoreStoredViewUC) === null || _a === void 0 ? void 0 : _a.restoreStoredView();
92
+ }
85
93
  }
86
94
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "4.34.8",
3
+ "version": "4.34.10",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",