@vived/app 2.19.0 → 2.20.1

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.
Files changed (128) hide show
  1. package/lib/Entities/FocusCamera.js +1 -1
  2. package/lib/Entities/KeyboardInput.js +0 -2
  3. package/lib/Entities/MouseInput.js +0 -5
  4. package/lib/PresentationManagers/FocusCameraPosRotPM.d.ts +13 -0
  5. package/lib/PresentationManagers/FocusCameraPosRotPM.js +28 -0
  6. package/lib/PresentationManagers/index.d.ts +1 -0
  7. package/lib/PresentationManagers/index.js +1 -0
  8. package/package.json +1 -1
  9. package/lib/Core/BaseApp/Boundary.d.ts +0 -49
  10. package/lib/Core/BaseApp/Boundary.js +0 -2
  11. package/lib/Core/BaseApp/Entity.d.ts +0 -11
  12. package/lib/Core/BaseApp/Entity.js +0 -2
  13. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.d.ts +0 -3
  14. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.js +0 -12
  15. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.d.ts +0 -3
  16. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.js +0 -10
  17. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.d.ts +0 -3
  18. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.js +0 -10
  19. package/lib/Core/BaseApp/Errors/index.d.ts +0 -3
  20. package/lib/Core/BaseApp/Errors/index.js +0 -15
  21. package/lib/Core/BaseApp/UseCase.d.ts +0 -43
  22. package/lib/Core/BaseApp/UseCase.js +0 -250
  23. package/lib/Core/BaseAppState/Boundary.d.ts +0 -14
  24. package/lib/Core/BaseAppState/Boundary.js +0 -2
  25. package/lib/Core/BaseAppState/Entity.d.ts +0 -5
  26. package/lib/Core/BaseAppState/Entity.js +0 -2
  27. package/lib/Core/BaseAppState/UseCase.d.ts +0 -16
  28. package/lib/Core/BaseAppState/UseCase.js +0 -54
  29. package/lib/Core/BaseAppState/UseCase_Imp.d.ts +0 -16
  30. package/lib/Core/BaseAppState/UseCase_Imp.js +0 -54
  31. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.d.ts +0 -16
  32. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.js +0 -56
  33. package/lib/Core/DevicePreview/boundary.d.ts +0 -14
  34. package/lib/Core/DevicePreview/boundary.js +0 -2
  35. package/lib/Core/DevicePreview/entity.d.ts +0 -5
  36. package/lib/Core/DevicePreview/entity.js +0 -2
  37. package/lib/Core/DispatchToHost/Entity.d.ts +0 -4
  38. package/lib/Core/DispatchToHost/Entity.js +0 -2
  39. package/lib/Core/DispatchToHost/UseCase.d.ts +0 -12
  40. package/lib/Core/DispatchToHost/UseCase.js +0 -70
  41. package/lib/Core/DispatchToHost/boundary.d.ts +0 -9
  42. package/lib/Core/DispatchToHost/boundary.js +0 -2
  43. package/lib/Core/Serilization/Boundary.d.ts +0 -20
  44. package/lib/Core/Serilization/Boundary.js +0 -2
  45. package/lib/Core/Serilization/Entity.d.ts +0 -3
  46. package/lib/Core/Serilization/Entity.js +0 -2
  47. package/lib/Core/Serilization/ErrorDuplicateSystemName.d.ts +0 -3
  48. package/lib/Core/Serilization/ErrorDuplicateSystemName.js +0 -12
  49. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.d.ts +0 -3
  50. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.js +0 -10
  51. package/lib/Core/Serilization/Errors.d.ts +0 -6
  52. package/lib/Core/Serilization/Errors.js +0 -19
  53. package/lib/Core/Serilization/UseCase.d.ts +0 -10
  54. package/lib/Core/Serilization/UseCase.js +0 -52
  55. package/lib/Core/Serilization/UseCase_Imp.d.ts +0 -10
  56. package/lib/Core/Serilization/UseCase_Imp.js +0 -51
  57. package/lib/Core/index.d.ts +0 -3
  58. package/lib/Core/index.js +0 -19
  59. package/lib/Entities/Color.d.ts +0 -20
  60. package/lib/Entities/Color.js +0 -59
  61. package/lib/Entities/LineSegment2D.d.ts +0 -11
  62. package/lib/Entities/LineSegment2D.js +0 -70
  63. package/lib/Entities/MouseSceneInput.d.ts +0 -15
  64. package/lib/Entities/MouseSceneInput.js +0 -109
  65. package/lib/Entities/OrbitCamera.d.ts +0 -76
  66. package/lib/Entities/OrbitCamera.js +0 -243
  67. package/lib/Entities/ParametricLine.d.ts +0 -29
  68. package/lib/Entities/ParametricLine.js +0 -79
  69. package/lib/Entities/ParametricPlane.d.ts +0 -20
  70. package/lib/Entities/ParametricPlane.js +0 -63
  71. package/lib/Entities/Vector2.d.ts +0 -21
  72. package/lib/Entities/Vector2.js +0 -83
  73. package/lib/Entities/Vector3.d.ts +0 -19
  74. package/lib/Entities/Vector3.js +0 -75
  75. package/lib/Interface/Controllers/appHandler.d.ts +0 -12
  76. package/lib/Interface/Controllers/appHandler.js +0 -94
  77. package/lib/Interface/Controllers/defaultAppHanlderFunctions.d.ts +0 -3
  78. package/lib/Interface/Controllers/defaultAppHanlderFunctions.js +0 -31
  79. package/lib/Interface/Controllers/dispatchStateChange.d.ts +0 -2
  80. package/lib/Interface/Controllers/dispatchStateChange.js +0 -10
  81. package/lib/Interface/Controllers/index.d.ts +0 -9
  82. package/lib/Interface/Controllers/index.js +0 -21
  83. package/lib/Interface/Controllers/makeAppHandler.d.ts +0 -12
  84. package/lib/Interface/Controllers/makeAppHandler.js +0 -96
  85. package/lib/Interface/Controllers/setDevicePreview.d.ts +0 -2
  86. package/lib/Interface/Controllers/setDevicePreview.js +0 -14
  87. package/lib/Interface/Controllers/setIsAuthoring.d.ts +0 -2
  88. package/lib/Interface/Controllers/setIsAuthoring.js +0 -14
  89. package/lib/Interface/Controllers/setState.d.ts +0 -2
  90. package/lib/Interface/Controllers/setState.js +0 -21
  91. package/lib/Interface/Controllers/showBabylonInspector.d.ts +0 -2
  92. package/lib/Interface/Controllers/showBabylonInspector.js +0 -9
  93. package/lib/Interface/Controllers/startApp.d.ts +0 -1
  94. package/lib/Interface/Controllers/startApp.js +0 -9
  95. package/lib/Interface/Controllers/stopApp.d.ts +0 -2
  96. package/lib/Interface/Controllers/stopApp.js +0 -10
  97. package/lib/Interface/PresentationManagers/DevicePreviewPM.d.ts +0 -13
  98. package/lib/Interface/PresentationManagers/DevicePreviewPM.js +0 -25
  99. package/lib/Interface/PresentationManagers/IsAuthoringPM.d.ts +0 -10
  100. package/lib/Interface/PresentationManagers/IsAuthoringPM.js +0 -23
  101. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.d.ts +0 -10
  102. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.js +0 -23
  103. package/lib/Interface/PresentationManagers/index.d.ts +0 -3
  104. package/lib/Interface/PresentationManagers/index.js +0 -15
  105. package/lib/Interface/appHandler.d.ts +0 -12
  106. package/lib/Interface/appHandler.js +0 -94
  107. package/lib/Interface/index.d.ts +0 -2
  108. package/lib/Interface/index.js +0 -14
  109. package/lib/PresentationManagers/OrbitCameraPM.d.ts +0 -14
  110. package/lib/PresentationManagers/OrbitCameraPM.js +0 -31
  111. package/lib/UseCases/LerpOrbitCamera.d.ts +0 -36
  112. package/lib/UseCases/LerpOrbitCamera.js +0 -71
  113. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +0 -36
  114. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +0 -71
  115. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +0 -9
  116. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +0 -31
  117. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +0 -10
  118. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +0 -31
  119. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +0 -22
  120. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +0 -81
  121. package/lib/UseCases/OrbitCamera/index.d.ts +0 -4
  122. package/lib/UseCases/OrbitCamera/index.js +0 -16
  123. package/lib/UseCases/SerializeCamera.d.ts +0 -21
  124. package/lib/UseCases/SerializeCamera.js +0 -59
  125. package/lib/UseCases/SerializeOrbitCamera.d.ts +0 -21
  126. package/lib/UseCases/SerializeOrbitCamera.js +0 -59
  127. package/lib/UseCases/SerializedCamDemo.d.ts +0 -0
  128. package/lib/UseCases/SerializedCamDemo.js +0 -1
@@ -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
  }
@@ -23,7 +23,6 @@ class KeyboardInputImp {
23
23
  this._eventElement = undefined;
24
24
  };
25
25
  this.submitKeyDown = (e) => {
26
- e.preventDefault();
27
26
  this.controllers.forEach((c) => {
28
27
  if (c.onKeyDown) {
29
28
  c.onKeyDown(e);
@@ -31,7 +30,6 @@ class KeyboardInputImp {
31
30
  });
32
31
  };
33
32
  this.submitKeyUp = (e) => {
34
- e.preventDefault();
35
33
  this.controllers.forEach((c) => {
36
34
  if (c.onKeyUp) {
37
35
  c.onKeyUp(e);
@@ -42,7 +42,6 @@ class MouseInputImp {
42
42
  }
43
43
  };
44
44
  this.onMouseDown = (e) => {
45
- e.preventDefault();
46
45
  const inputEvt = this.makeMouseInputEvent(e);
47
46
  this.controllers.forEach((c) => {
48
47
  if (c.onDown) {
@@ -53,7 +52,6 @@ class MouseInputImp {
53
52
  this.pressEvent = e;
54
53
  };
55
54
  this.onMouseUp = (e) => {
56
- e.preventDefault();
57
55
  const inputEvt = this.makeMouseInputEvent(e);
58
56
  this.controllers.forEach((c) => {
59
57
  if (c.onUp) {
@@ -76,7 +74,6 @@ class MouseInputImp {
76
74
  this.pressEvent = undefined;
77
75
  };
78
76
  this.onMouseMove = (e) => {
79
- e.preventDefault();
80
77
  const inputEvt = this.makeMouseInputEvent(e);
81
78
  this.controllers.forEach((c) => {
82
79
  if (c.onMove) {
@@ -93,7 +90,6 @@ class MouseInputImp {
93
90
  }
94
91
  };
95
92
  this.onMouseOut = (e) => {
96
- e.preventDefault();
97
93
  if (!this.isPressed)
98
94
  return;
99
95
  const inputEvt = this.makeMouseInputEvent(e);
@@ -106,7 +102,6 @@ class MouseInputImp {
106
102
  this.isPressed = false;
107
103
  };
108
104
  this.onWheel = (e) => {
109
- e.preventDefault();
110
105
  const inputEvt = this.makeMouseInputEvent(e);
111
106
  this.controllers.forEach((c) => {
112
107
  if (c.onWheel) {
@@ -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.19.0",
3
+ "version": "2.20.1",
4
4
  "description": "Public package for the VIVED Learning App system",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,49 +0,0 @@
1
- import { Handler } from "@vived/app-host-boundary";
2
- export interface BaseAppUC {
3
- getIsAuthoring(): boolean;
4
- setIsAuthoring(isAuthoring: boolean): void;
5
- getShowBabylonInspector(): boolean;
6
- setShowBabylonInspector(showInspector: boolean): void;
7
- addObserver(observer: BaseAppStateObserver): void;
8
- removeObserver(observer: BaseAppStateObserver): void;
9
- setVerbose(verbose: boolean): void;
10
- getSerializedState(): SerializedStates;
11
- setSerializedState(state: SerializedStates, transitionTime: number): void;
12
- setDefaultState(transitionTime: number): void;
13
- registerSerializableSystem(serializedSystem: SerializableSystem): void;
14
- getIsTransitioning(): boolean;
15
- abortTransition(): void;
16
- setTransitionEaseFn: (easeFn: (normalizedTime: number) => number) => void;
17
- setHostHandler(handler: Handler): void;
18
- hasHostHandler(): boolean;
19
- dispatchOnStateChange(stateObject: object): void;
20
- dispatchOnStateComplete(): void;
21
- dispatchSubmitResults(results: object): void;
22
- dispatchGetAppAssetsURL(): string;
23
- setDevicePreview(x: number, y: number): void;
24
- clearDevicePreview(): void;
25
- getUseDevicePreview(): boolean;
26
- getDevicePreviewSize(): {
27
- x: number;
28
- y: number;
29
- };
30
- }
31
- export interface BaseAppStateObserver {
32
- onBaseAppChange: () => void;
33
- }
34
- export interface SerializedStates {
35
- version: number;
36
- systems: SystemState[];
37
- }
38
- export interface SystemState {
39
- name: string;
40
- seriliziationVersion: number;
41
- state: object;
42
- }
43
- export interface SerializableSystem {
44
- name: string;
45
- seriliziationVersion: number;
46
- getSerializedObject(): object;
47
- intializeStateForTransition(serializedState: object | null, version: number): void;
48
- applyTransition(percent: number): void;
49
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,11 +0,0 @@
1
- export interface BaseAppState {
2
- isAuthoring: boolean;
3
- showBabyonInspector: boolean;
4
- handler?: unknown;
5
- appAssetsURL?: string;
6
- useDevicePreview: boolean;
7
- x: number;
8
- y: number;
9
- isTransitioning: boolean;
10
- verbose: boolean;
11
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +0,0 @@
1
- export declare class DuplicateSystemNameError extends Error {
2
- constructor(name: string);
3
- }
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DuplicateSystemNameError = void 0;
4
- class DuplicateSystemNameError extends Error {
5
- constructor(name) {
6
- const msg = "Cannot add two serialized systems named " +
7
- name +
8
- ". Every system name must be unique";
9
- super(msg);
10
- }
11
- }
12
- exports.DuplicateSystemNameError = DuplicateSystemNameError;
@@ -1,3 +0,0 @@
1
- export declare class ErrorNoHostHandler extends Error {
2
- constructor();
3
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorNoHostHandler = void 0;
4
- class ErrorNoHostHandler extends Error {
5
- constructor() {
6
- const msg = "Host Handler has not been set";
7
- super(msg);
8
- }
9
- }
10
- exports.ErrorNoHostHandler = ErrorNoHostHandler;
@@ -1,3 +0,0 @@
1
- export declare class UnsupportedVersionNumber extends Error {
2
- constructor(version: number);
3
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnsupportedVersionNumber = void 0;
4
- class UnsupportedVersionNumber extends Error {
5
- constructor(version) {
6
- const msg = "Serialization version " + version + " is not supported";
7
- super(msg);
8
- }
9
- }
10
- exports.UnsupportedVersionNumber = UnsupportedVersionNumber;
@@ -1,3 +0,0 @@
1
- export * from "./ErrorDuplicateSystemName";
2
- export * from "./ErrorUnsupportedVersionNumber";
3
- export * from "./ErrorNoHostHandler";
@@ -1,15 +0,0 @@
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("./ErrorDuplicateSystemName"), exports);
14
- __exportStar(require("./ErrorUnsupportedVersionNumber"), exports);
15
- __exportStar(require("./ErrorNoHostHandler"), exports);
@@ -1,43 +0,0 @@
1
- import { Handler } from "@vived/app-host-boundary";
2
- import { BaseAppStateObserver, BaseAppUC, SerializableSystem, SerializedStates } from "./Boundary";
3
- export declare class BaseAppUCImp implements BaseAppUC {
4
- private appState;
5
- private observers;
6
- private systems;
7
- private serilizationVersion;
8
- private currentInterval?;
9
- private easeFunction;
10
- constructor();
11
- setVerbose(verbose: boolean): void;
12
- abortTransition: () => void;
13
- setTransitionEaseFn: (easeFn: (normalizedTime: number) => number) => void;
14
- getIsTransitioning: () => boolean;
15
- setDevicePreview: (x: number, y: number) => void;
16
- clearDevicePreview: () => void;
17
- getUseDevicePreview: () => boolean;
18
- getDevicePreviewSize: () => {
19
- x: number;
20
- y: number;
21
- };
22
- setHostHandler: (handler: Handler) => void;
23
- hasHostHandler: () => boolean;
24
- dispatchOnStateChange: (stateObject: object) => void;
25
- dispatchOnStateComplete: () => void;
26
- dispatchSubmitResults: (results: object) => void;
27
- dispatchGetAppAssetsURL: () => string;
28
- registerSerializableSystem: (serializedSystem: SerializableSystem) => void;
29
- getSerializedState: () => SerializedStates;
30
- setSerializedState: (state: SerializedStates, duration: number) => void;
31
- setDefaultState: (duration: number) => void;
32
- getShowBabylonInspector: () => boolean;
33
- setShowBabylonInspector: (showInspector: boolean) => void;
34
- getIsAuthoring: () => boolean;
35
- setIsAuthoring: (isAuthoring: boolean) => void;
36
- addObserver: (observer: BaseAppStateObserver) => void;
37
- removeObserver: (observer: BaseAppStateObserver) => void;
38
- private logToConsole;
39
- private startTransition;
40
- private applyTransitionToSystems;
41
- private notify;
42
- private dispatch;
43
- }
@@ -1,250 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseAppUCImp = void 0;
4
- const app_host_boundary_1 = require("@vived/app-host-boundary");
5
- const Errors_1 = require("./Errors");
6
- class BaseAppUCImp {
7
- constructor() {
8
- this.observers = [];
9
- this.systems = new Map();
10
- this.serilizationVersion = 2;
11
- this.easeFunction = (normalizedTime) => {
12
- return normalizedTime; // default to a linear function
13
- };
14
- this.abortTransition = () => {
15
- if (this.currentInterval) {
16
- clearInterval(this.currentInterval);
17
- }
18
- this.appState.isTransitioning = false;
19
- };
20
- this.setTransitionEaseFn = (easeFn) => {
21
- this.easeFunction = easeFn;
22
- };
23
- this.getIsTransitioning = () => {
24
- return this.appState.isTransitioning;
25
- };
26
- this.setDevicePreview = (x, y) => {
27
- if (this.appState.useDevicePreview &&
28
- x === this.appState.x &&
29
- y === this.appState.y) {
30
- return;
31
- }
32
- this.appState.useDevicePreview = true;
33
- this.appState.x = x;
34
- this.appState.y = y;
35
- this.notify();
36
- this.logToConsole(`Device Preview set to ${x}, ${y}`);
37
- };
38
- this.clearDevicePreview = () => {
39
- if (!this.appState.useDevicePreview)
40
- return;
41
- this.appState.useDevicePreview = false;
42
- this.appState.x = -1;
43
- this.appState.y = -1;
44
- this.notify();
45
- this.logToConsole(`Device Preview cleared`);
46
- };
47
- this.getUseDevicePreview = () => {
48
- return this.appState.useDevicePreview;
49
- };
50
- this.getDevicePreviewSize = () => {
51
- const { x, y } = this.appState;
52
- return { x, y };
53
- };
54
- this.setHostHandler = (handler) => {
55
- this.appState.handler = handler;
56
- this.logToConsole("Handler set");
57
- };
58
- this.hasHostHandler = () => {
59
- if (this.appState.handler) {
60
- return true;
61
- }
62
- else {
63
- return false;
64
- }
65
- };
66
- this.dispatchOnStateChange = (stateObject) => {
67
- const request = {
68
- type: app_host_boundary_1.ON_STATE_CHANGE,
69
- version: 1,
70
- payload: {
71
- stateObject,
72
- },
73
- };
74
- this.dispatch(request);
75
- };
76
- this.dispatchOnStateComplete = () => {
77
- const request = {
78
- type: app_host_boundary_1.ON_STATE_COMPLETED,
79
- version: 1,
80
- };
81
- this.dispatch(request);
82
- };
83
- this.dispatchSubmitResults = (results) => {
84
- const request = {
85
- type: app_host_boundary_1.SUBMIT_RESULTS,
86
- version: 1,
87
- payload: {
88
- results,
89
- },
90
- };
91
- this.dispatch(request);
92
- };
93
- this.dispatchGetAppAssetsURL = () => {
94
- var _a;
95
- const callback = (url) => {
96
- this.appState.appAssetsURL = url;
97
- };
98
- const request = {
99
- type: app_host_boundary_1.GET_APP_ASSET_URL,
100
- version: 1,
101
- payload: {
102
- callback,
103
- },
104
- };
105
- this.dispatch(request);
106
- return (_a = this.appState.appAssetsURL) !== null && _a !== void 0 ? _a : "";
107
- };
108
- this.registerSerializableSystem = (serializedSystem) => {
109
- if (this.systems.has(serializedSystem.name)) {
110
- throw new Errors_1.DuplicateSystemNameError(serializedSystem.name);
111
- }
112
- this.systems.set(serializedSystem.name, serializedSystem);
113
- };
114
- this.getSerializedState = () => {
115
- const systems = Array.from(this.systems.values());
116
- const serializedStates = systems.map((system) => {
117
- const state = system.getSerializedObject();
118
- return {
119
- seriliziationVersion: system.seriliziationVersion,
120
- name: system.name,
121
- state,
122
- };
123
- });
124
- return {
125
- version: this.serilizationVersion,
126
- systems: serializedStates,
127
- };
128
- };
129
- this.setSerializedState = (state, duration) => {
130
- if (state.version === 2) {
131
- state.systems.forEach((systemState) => {
132
- const seriliazableSystem = this.systems.get(systemState.name);
133
- if (seriliazableSystem) {
134
- seriliazableSystem.intializeStateForTransition(systemState.state, systemState.seriliziationVersion);
135
- }
136
- else {
137
- console.warn("Unable to find seriarializedSystem " + systemState.name);
138
- }
139
- });
140
- }
141
- // Here is where we will add support for future versions
142
- else {
143
- throw new Errors_1.UnsupportedVersionNumber(state.version);
144
- }
145
- this.startTransition(duration);
146
- this.logToConsole(`State set to ${JSON.stringify(state)} with a ${duration} second duration`);
147
- };
148
- this.setDefaultState = (duration) => {
149
- this.systems.forEach((system) => {
150
- system.intializeStateForTransition(null, -1);
151
- });
152
- this.startTransition(duration);
153
- this.logToConsole(`State has been set to transition to default over ${duration} seconds`);
154
- };
155
- this.getShowBabylonInspector = () => {
156
- return this.appState.showBabyonInspector;
157
- };
158
- this.setShowBabylonInspector = (showInspector) => {
159
- if (this.appState.showBabyonInspector === showInspector)
160
- return;
161
- this.appState.showBabyonInspector = showInspector;
162
- this.notify();
163
- this.logToConsole(`Show Babylon Inspector set to ${showInspector}`);
164
- };
165
- this.getIsAuthoring = () => {
166
- return this.appState.isAuthoring;
167
- };
168
- this.setIsAuthoring = (isAuthoring) => {
169
- if (isAuthoring === this.appState.isAuthoring)
170
- return;
171
- this.appState.isAuthoring = isAuthoring;
172
- this.notify();
173
- this.logToConsole(`Is Authoring set to ${isAuthoring}`);
174
- };
175
- this.addObserver = (observer) => {
176
- this.observers.push(observer);
177
- };
178
- this.removeObserver = (observer) => {
179
- const index = this.observers.indexOf(observer);
180
- if (index >= 0) {
181
- this.observers.splice(index, 1);
182
- }
183
- };
184
- this.appState = {
185
- isAuthoring: false,
186
- showBabyonInspector: false,
187
- useDevicePreview: false,
188
- x: -1,
189
- y: -1,
190
- isTransitioning: false,
191
- verbose: false,
192
- };
193
- }
194
- setVerbose(verbose) {
195
- this.appState.verbose = verbose;
196
- }
197
- logToConsole(message) {
198
- if (!this.appState.verbose)
199
- return;
200
- console.log("[Base App UC] " + message);
201
- }
202
- startTransition(duration) {
203
- if (duration === 0) {
204
- if (this.currentInterval) {
205
- clearInterval(this.currentInterval);
206
- this.appState.isTransitioning = false;
207
- }
208
- this.applyTransitionToSystems(1);
209
- }
210
- else {
211
- if (this.currentInterval) {
212
- clearInterval(this.currentInterval);
213
- }
214
- this.appState.isTransitioning = true;
215
- const durationInMS = duration * 1000;
216
- let chrono = 0;
217
- const transitionDelta = 10;
218
- this.currentInterval = setInterval(() => {
219
- chrono = chrono + transitionDelta;
220
- let normalizedTime = chrono / durationInMS;
221
- if (normalizedTime > 1) {
222
- normalizedTime = 1;
223
- }
224
- const percent = this.easeFunction(normalizedTime);
225
- this.applyTransitionToSystems(percent);
226
- if (normalizedTime >= 1 && this.currentInterval) {
227
- clearInterval(this.currentInterval);
228
- this.appState.isTransitioning = false;
229
- }
230
- }, transitionDelta);
231
- }
232
- }
233
- applyTransitionToSystems(percent) {
234
- this.systems.forEach((system) => {
235
- system.applyTransition(percent);
236
- });
237
- }
238
- notify() {
239
- this.observers.forEach((observer) => observer.onBaseAppChange());
240
- }
241
- dispatch(request) {
242
- if (!this.appState.handler) {
243
- throw new Errors_1.ErrorNoHostHandler();
244
- }
245
- const handler = this.appState.handler;
246
- handler(request);
247
- this.logToConsole(`Dispatched request: ${JSON.stringify(request)}`);
248
- }
249
- }
250
- exports.BaseAppUCImp = BaseAppUCImp;
@@ -1,14 +0,0 @@
1
- export interface BaseAppStateUC {
2
- getIsAuthoring(): boolean;
3
- setIsAuthoring(isAuthoring: boolean): void;
4
- getShowBabylonInspector(): boolean;
5
- setShowBabylonInspector(showInspector: boolean): void;
6
- getAppContainer(): HTMLElement | undefined;
7
- setAppContainer(container: HTMLElement): void;
8
- clearAppContainer(): void;
9
- addObserver(observer: BaseAppStateObserver): void;
10
- removeObserver(observer: BaseAppStateObserver): void;
11
- }
12
- export interface BaseAppStateObserver {
13
- onAppStateChange: () => void;
14
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +0,0 @@
1
- export interface BaseAppState {
2
- isAuthoring: boolean;
3
- showBabyonInspector: boolean;
4
- appContainer?: HTMLElement;
5
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +0,0 @@
1
- import { BaseAppStateObserver, BaseAppStateUC } from "./Boundary";
2
- export declare class BaseAppStateUCImp implements BaseAppStateUC {
3
- private appState;
4
- private observers;
5
- constructor();
6
- getAppContainer(): HTMLElement | undefined;
7
- setAppContainer(container: HTMLElement): void;
8
- clearAppContainer(): void;
9
- getShowBabylonInspector(): boolean;
10
- setShowBabylonInspector(showInspector: boolean): void;
11
- getIsAuthoring(): boolean;
12
- setIsAuthoring(isAuthoring: boolean): void;
13
- addObserver(observer: BaseAppStateObserver): void;
14
- removeObserver(observer: BaseAppStateObserver): void;
15
- private notify;
16
- }
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseAppStateUCImp = void 0;
4
- class BaseAppStateUCImp {
5
- constructor() {
6
- this.observers = [];
7
- this.appState = {
8
- isAuthoring: false,
9
- showBabyonInspector: false,
10
- };
11
- }
12
- getAppContainer() {
13
- return this.appState.appContainer;
14
- }
15
- setAppContainer(container) {
16
- this.appState.appContainer = container;
17
- this.notify();
18
- }
19
- clearAppContainer() {
20
- this.appState.appContainer = undefined;
21
- this.notify();
22
- }
23
- getShowBabylonInspector() {
24
- return this.appState.showBabyonInspector;
25
- }
26
- setShowBabylonInspector(showInspector) {
27
- if (this.appState.showBabyonInspector === showInspector)
28
- return;
29
- this.appState.showBabyonInspector = showInspector;
30
- this.notify();
31
- }
32
- getIsAuthoring() {
33
- return this.appState.isAuthoring;
34
- }
35
- setIsAuthoring(isAuthoring) {
36
- if (isAuthoring === this.appState.isAuthoring)
37
- return;
38
- this.appState.isAuthoring = isAuthoring;
39
- this.notify();
40
- }
41
- addObserver(observer) {
42
- this.observers.push(observer);
43
- }
44
- removeObserver(observer) {
45
- const index = this.observers.indexOf(observer);
46
- if (index >= 0) {
47
- this.observers.splice(index, 1);
48
- }
49
- }
50
- notify() {
51
- this.observers.forEach((observer) => observer.onAppStateChange());
52
- }
53
- }
54
- exports.BaseAppStateUCImp = BaseAppStateUCImp;