@vived/app 2.18.2 → 2.20.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.
@@ -245,7 +245,7 @@ class FocusCameraImp {
245
245
  const yLength = -Math.sin(this.degToRad(this.beta));
246
246
  const horizontalLenght = Math.cos(this.degToRad(this.beta));
247
247
  const alphaRadians = this.degToRad(this.alpha);
248
- const xLength = -horizontalLenght * Math.sin(alphaRadians);
248
+ const xLength = horizontalLenght * Math.sin(alphaRadians);
249
249
  const zLength = horizontalLenght * Math.cos(alphaRadians);
250
250
  return new ValueObjects_1.Vector3(xLength, yLength, zLength);
251
251
  }
@@ -1,4 +1,5 @@
1
1
  import { Result } from "../ValueObjects";
2
+ export declare type OnStateHasBeenApplied = () => void;
2
3
  export interface SerializedStates {
3
4
  version: number;
4
5
  systems: SystemState[];
@@ -22,5 +23,7 @@ export interface StateMachine {
22
23
  applySerializedStatesString: (state: string, duration?: number) => void;
23
24
  setDefaultState(transitionTime: number): void;
24
25
  registerSerializedSystem(serializedSystem: SerializedSystem): Result<null, Error>;
26
+ addStateHasBeenAppliedObserver: (observer: OnStateHasBeenApplied) => void;
27
+ removeStateHasBeenAppliedObserver: (observer: OnStateHasBeenApplied) => void;
25
28
  }
26
29
  export declare function makeStateMachine(): StateMachine;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeStateMachine = void 0;
4
4
  const ValueObjects_1 = require("../ValueObjects");
5
+ const ObserverList_1 = require("./ObserverList");
5
6
  function makeStateMachine() {
6
7
  return new StateMachineImp();
7
8
  }
@@ -10,6 +11,7 @@ class StateMachineImp {
10
11
  constructor() {
11
12
  this.serializedSystems = new Map();
12
13
  this.serilizationVersion = 2;
14
+ this.stateAppliedObservers = new ObserverList_1.ObserverList();
13
15
  this.transitionEaseFunction = (normalizedTime) => {
14
16
  return normalizedTime; // default to a linear function
15
17
  };
@@ -70,6 +72,7 @@ class StateMachineImp {
70
72
  system.applyDefaultState(duration);
71
73
  }
72
74
  });
75
+ this.stateAppliedObservers.notify();
73
76
  return ValueObjects_1.resolve(null);
74
77
  }
75
78
  // Here is where we will add support for future versions
@@ -83,6 +86,13 @@ class StateMachineImp {
83
86
  this.serializedSystems.forEach((system) => {
84
87
  system.applyDefaultState(duration);
85
88
  });
89
+ this.stateAppliedObservers.notify();
90
+ };
91
+ this.addStateHasBeenAppliedObserver = (observer) => {
92
+ this.stateAppliedObservers.add(observer);
93
+ };
94
+ this.removeStateHasBeenAppliedObserver = (observer) => {
95
+ this.stateAppliedObservers.remove(observer);
86
96
  };
87
97
  }
88
98
  }
@@ -0,0 +1,13 @@
1
+ import { FocusCamera } from "../Entities";
2
+ import { Vector3 } from "../ValueObjects";
3
+ export interface FocusCameraPosRotVM {
4
+ position: Vector3;
5
+ rotation: Vector3;
6
+ }
7
+ export declare class FocusCameraPosRotPM {
8
+ private focusCam;
9
+ private view;
10
+ dispose(): void;
11
+ private doUpdateView;
12
+ constructor(orbitCamera: FocusCamera, view: (vm: FocusCameraPosRotVM) => void);
13
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FocusCameraPosRotPM = void 0;
4
+ const Utilities_1 = require("../Utilities");
5
+ const ValueObjects_1 = require("../ValueObjects");
6
+ class FocusCameraPosRotPM {
7
+ constructor(orbitCamera, view) {
8
+ this.doUpdateView = () => {
9
+ const { alpha, beta } = this.focusCam;
10
+ const alphaRadians = Utilities_1.degreesToRadians(alpha);
11
+ const betaRadians = Utilities_1.degreesToRadians(beta);
12
+ const position = this.focusCam.cameraPosition;
13
+ const rotation = new ValueObjects_1.Vector3(betaRadians, alphaRadians, 0);
14
+ this.view({
15
+ position,
16
+ rotation,
17
+ });
18
+ };
19
+ this.focusCam = orbitCamera;
20
+ this.view = view;
21
+ this.doUpdateView();
22
+ this.focusCam.addObserver(this.doUpdateView);
23
+ }
24
+ dispose() {
25
+ this.focusCam.removeObserver(this.doUpdateView);
26
+ }
27
+ }
28
+ exports.FocusCameraPosRotPM = FocusCameraPosRotPM;
@@ -5,3 +5,4 @@ export * from "./HasRedoPM";
5
5
  export * from "./HasUndoPM";
6
6
  export * from "./FocusCameraPM";
7
7
  export * from "./QuestionChallenge";
8
+ export * from "./FocusCameraPosRotPM";
@@ -17,3 +17,4 @@ __exportStar(require("./HasRedoPM"), exports);
17
17
  __exportStar(require("./HasUndoPM"), exports);
18
18
  __exportStar(require("./FocusCameraPM"), exports);
19
19
  __exportStar(require("./QuestionChallenge"), exports);
20
+ __exportStar(require("./FocusCameraPosRotPM"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vived/app",
3
- "version": "2.18.2",
3
+ "version": "2.20.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",