@vived/app 4.34.9 → 4.34.11

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
  }
@@ -0,0 +1 @@
1
+ export * from "./setupLabel";
@@ -0,0 +1,13 @@
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("./setupLabel"), exports);
@@ -0,0 +1,2 @@
1
+ import { AppObject, AppObjectRepo } from "../../../AppObject";
2
+ export declare function setupLabel(appObjects: AppObjectRepo): AppObject;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setupLabel = void 0;
4
+ const UC_1 = require("../UC");
5
+ function setupLabel(appObjects) {
6
+ const ao = appObjects.getOrCreate("Label");
7
+ // UCs
8
+ UC_1.makeSerializeCustomLabels(ao);
9
+ return ao;
10
+ }
11
+ exports.setupLabel = setupLabel;
@@ -0,0 +1,26 @@
1
+ import { AppObject, AppObjectUC } from "../../../AppObject";
2
+ import { SerializedSystem } from "../../StateMachine";
3
+ export declare abstract class SerializeCustomLabels extends AppObjectUC implements SerializedSystem {
4
+ static readonly type = "SerializeCustomLabels";
5
+ name: string;
6
+ abstract seriliziationVersion: number;
7
+ abstract getSystemState(): object;
8
+ abstract applySystemState(state: object, version: number, transitionDuration: number): void;
9
+ abstract applyDefaultState(transitionDuration: number): void;
10
+ }
11
+ export declare function makeSerializeCustomLabels(appObject: AppObject): SerializeCustomLabels;
12
+ export declare class SerializeCustomLabelsImp extends SerializeCustomLabels {
13
+ seriliziationVersion: number;
14
+ getSystemState(): object;
15
+ applySystemState(state: object, version: number, durationS: number): Promise<void> | void;
16
+ private applyStateV1;
17
+ applyDefaultState(): void;
18
+ constructor(appObj: AppObject);
19
+ }
20
+ export interface SerializedCustomLabelsV1 {
21
+ customLabels: SerializedCustomLabelV1[];
22
+ }
23
+ export interface SerializedCustomLabelV1 {
24
+ objectId: string;
25
+ customLabel: string;
26
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializeCustomLabelsImp = exports.makeSerializeCustomLabels = exports.SerializeCustomLabels = void 0;
4
+ const AppObject_1 = require("../../../AppObject");
5
+ const StateMachine_1 = require("../../StateMachine");
6
+ const Entities_1 = require("../Entities");
7
+ class SerializeCustomLabels extends AppObject_1.AppObjectUC {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.name = "serialize-custom-labels";
11
+ }
12
+ }
13
+ exports.SerializeCustomLabels = SerializeCustomLabels;
14
+ SerializeCustomLabels.type = "SerializeCustomLabels";
15
+ function makeSerializeCustomLabels(appObject) {
16
+ return new SerializeCustomLabelsImp(appObject);
17
+ }
18
+ exports.makeSerializeCustomLabels = makeSerializeCustomLabels;
19
+ class SerializeCustomLabelsImp extends SerializeCustomLabels {
20
+ constructor(appObj) {
21
+ super(appObj, SerializeCustomLabels.type);
22
+ this.seriliziationVersion = 1;
23
+ const stateMachine = this.appObjects.getSingleton(StateMachine_1.StateMachineEntity.type);
24
+ if (stateMachine) {
25
+ stateMachine.registerSerializedSystem(this);
26
+ }
27
+ else {
28
+ this.warn("Unable to find StateMachineEntity");
29
+ }
30
+ }
31
+ getSystemState() {
32
+ const customLabels = [];
33
+ const allLabels = this.appObjects.getAllComponents(Entities_1.LabelEntity.type);
34
+ allLabels.forEach((label) => {
35
+ if (label.hasCustomLabel)
36
+ customLabels.push({
37
+ objectId: label.appObject.id,
38
+ customLabel: label.custom,
39
+ });
40
+ });
41
+ const state = {
42
+ customLabels,
43
+ };
44
+ return state;
45
+ }
46
+ applySystemState(state, version, durationS) {
47
+ if (version === 1) {
48
+ return this.applyStateV1(state, durationS);
49
+ }
50
+ else {
51
+ this.applyDefaultState();
52
+ }
53
+ }
54
+ applyStateV1(state, durationS) {
55
+ const { customLabels } = state;
56
+ if (!customLabels || customLabels.length === 0) {
57
+ this.applyDefaultState();
58
+ return;
59
+ }
60
+ // Create a Map for faster lookups
61
+ const customLabelsLookup = new Map();
62
+ customLabels.forEach((customLabel) => {
63
+ customLabelsLookup.set(customLabel.objectId, customLabel.customLabel);
64
+ });
65
+ const allLabels = this.appObjects.getAllComponents(Entities_1.LabelEntity.type);
66
+ allLabels.forEach((label) => {
67
+ var _a;
68
+ const appObjectId = label.appObject.id;
69
+ label.custom = (_a = customLabelsLookup.get(appObjectId)) !== null && _a !== void 0 ? _a : "";
70
+ });
71
+ customLabelsLookup.forEach((customLabel, objectId) => {
72
+ const appObject = this.appObjects.getOrCreate(objectId);
73
+ if (appObject) {
74
+ const label = Entities_1.LabelEntity.addIfMissing(appObject);
75
+ label.custom = customLabel;
76
+ }
77
+ });
78
+ }
79
+ applyDefaultState() {
80
+ const allLabels = this.appObjects.getAllComponents(Entities_1.LabelEntity.type);
81
+ allLabels.forEach((label) => {
82
+ label.custom = "";
83
+ });
84
+ }
85
+ }
86
+ exports.SerializeCustomLabelsImp = SerializeCustomLabelsImp;
@@ -1,2 +1,3 @@
1
1
  export * from "./ClearCustomLabelUC";
2
2
  export * from "./SetCustomLabelUC";
3
+ export * from "./SerializeCustomLabels";
@@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./ClearCustomLabelUC"), exports);
14
14
  __exportStar(require("./SetCustomLabelUC"), exports);
15
+ __exportStar(require("./SerializeCustomLabels"), exports);
@@ -1,6 +1,7 @@
1
1
  export * from "./Adapters";
2
2
  export * from "./Controller";
3
3
  export * from "./Entities";
4
+ export * from "./Factories";
4
5
  export * from "./Mocks";
5
6
  export * from "./PM";
6
7
  export * from "./UC";
@@ -13,6 +13,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./Adapters"), exports);
14
14
  __exportStar(require("./Controller"), exports);
15
15
  __exportStar(require("./Entities"), exports);
16
+ __exportStar(require("./Factories"), exports);
16
17
  __exportStar(require("./Mocks"), exports);
17
18
  __exportStar(require("./PM"), exports);
18
19
  __exportStar(require("./UC"), exports);
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "4.34.9",
3
+ "version": "4.34.11",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",