@vived/app 2.18.1 → 2.18.2
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.
- package/lib/Core/BaseApp/Boundary.d.ts +49 -0
- package/lib/Core/BaseApp/Boundary.js +2 -0
- package/lib/Core/BaseApp/Entity.d.ts +11 -0
- package/lib/Core/BaseApp/Entity.js +2 -0
- package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.js +12 -0
- package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.js +10 -0
- package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.js +10 -0
- package/lib/Core/BaseApp/Errors/index.d.ts +3 -0
- package/lib/Core/BaseApp/Errors/index.js +15 -0
- package/lib/Core/BaseApp/UseCase.d.ts +43 -0
- package/lib/Core/BaseApp/UseCase.js +250 -0
- package/lib/Core/BaseAppState/Boundary.d.ts +14 -0
- package/lib/Core/BaseAppState/Boundary.js +2 -0
- package/lib/Core/BaseAppState/Entity.d.ts +5 -0
- package/lib/Core/BaseAppState/Entity.js +2 -0
- package/lib/Core/BaseAppState/UseCase.d.ts +16 -0
- package/lib/Core/BaseAppState/UseCase.js +54 -0
- package/lib/Core/BaseAppState/UseCase_Imp.d.ts +16 -0
- package/lib/Core/BaseAppState/UseCase_Imp.js +54 -0
- package/lib/Core/DevicePreview/DevicePreviewUC_Imp.d.ts +16 -0
- package/lib/Core/DevicePreview/DevicePreviewUC_Imp.js +56 -0
- package/lib/Core/DevicePreview/boundary.d.ts +14 -0
- package/lib/Core/DevicePreview/boundary.js +2 -0
- package/lib/Core/DevicePreview/entity.d.ts +5 -0
- package/lib/Core/DevicePreview/entity.js +2 -0
- package/lib/Core/DispatchToHost/Entity.d.ts +4 -0
- package/lib/Core/DispatchToHost/Entity.js +2 -0
- package/lib/Core/DispatchToHost/UseCase.d.ts +12 -0
- package/lib/Core/DispatchToHost/UseCase.js +70 -0
- package/lib/Core/DispatchToHost/boundary.d.ts +9 -0
- package/lib/Core/DispatchToHost/boundary.js +2 -0
- package/lib/Core/Serilization/Boundary.d.ts +20 -0
- package/lib/Core/Serilization/Boundary.js +2 -0
- package/lib/Core/Serilization/Entity.d.ts +3 -0
- package/lib/Core/Serilization/Entity.js +2 -0
- package/lib/Core/Serilization/ErrorDuplicateSystemName.d.ts +3 -0
- package/lib/Core/Serilization/ErrorDuplicateSystemName.js +12 -0
- package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.d.ts +3 -0
- package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.js +10 -0
- package/lib/Core/Serilization/Errors.d.ts +6 -0
- package/lib/Core/Serilization/Errors.js +19 -0
- package/lib/Core/Serilization/UseCase.d.ts +10 -0
- package/lib/Core/Serilization/UseCase.js +52 -0
- package/lib/Core/Serilization/UseCase_Imp.d.ts +10 -0
- package/lib/Core/Serilization/UseCase_Imp.js +51 -0
- package/lib/Core/index.d.ts +3 -0
- package/lib/Core/index.js +19 -0
- package/lib/Entities/Babylon.js +5 -0
- package/lib/Entities/Color.d.ts +20 -0
- package/lib/Entities/Color.js +59 -0
- package/lib/Entities/LineSegment2D.d.ts +11 -0
- package/lib/Entities/LineSegment2D.js +70 -0
- package/lib/Entities/MouseSceneInput.d.ts +15 -0
- package/lib/Entities/MouseSceneInput.js +109 -0
- package/lib/Entities/OrbitCamera.d.ts +76 -0
- package/lib/Entities/OrbitCamera.js +243 -0
- package/lib/Entities/ParametricLine.d.ts +29 -0
- package/lib/Entities/ParametricLine.js +79 -0
- package/lib/Entities/ParametricPlane.d.ts +20 -0
- package/lib/Entities/ParametricPlane.js +63 -0
- package/lib/Entities/Vector2.d.ts +21 -0
- package/lib/Entities/Vector2.js +83 -0
- package/lib/Entities/Vector3.d.ts +19 -0
- package/lib/Entities/Vector3.js +75 -0
- package/lib/Interface/Controllers/appHandler.d.ts +12 -0
- package/lib/Interface/Controllers/appHandler.js +94 -0
- package/lib/Interface/Controllers/defaultAppHanlderFunctions.d.ts +3 -0
- package/lib/Interface/Controllers/defaultAppHanlderFunctions.js +31 -0
- package/lib/Interface/Controllers/dispatchStateChange.d.ts +2 -0
- package/lib/Interface/Controllers/dispatchStateChange.js +10 -0
- package/lib/Interface/Controllers/index.d.ts +9 -0
- package/lib/Interface/Controllers/index.js +21 -0
- package/lib/Interface/Controllers/makeAppHandler.d.ts +12 -0
- package/lib/Interface/Controllers/makeAppHandler.js +96 -0
- package/lib/Interface/Controllers/setDevicePreview.d.ts +2 -0
- package/lib/Interface/Controllers/setDevicePreview.js +14 -0
- package/lib/Interface/Controllers/setIsAuthoring.d.ts +2 -0
- package/lib/Interface/Controllers/setIsAuthoring.js +14 -0
- package/lib/Interface/Controllers/setState.d.ts +2 -0
- package/lib/Interface/Controllers/setState.js +21 -0
- package/lib/Interface/Controllers/showBabylonInspector.d.ts +2 -0
- package/lib/Interface/Controllers/showBabylonInspector.js +9 -0
- package/lib/Interface/Controllers/startApp.d.ts +1 -0
- package/lib/Interface/Controllers/startApp.js +9 -0
- package/lib/Interface/Controllers/stopApp.d.ts +2 -0
- package/lib/Interface/Controllers/stopApp.js +10 -0
- package/lib/Interface/PresentationManagers/DevicePreviewPM.d.ts +13 -0
- package/lib/Interface/PresentationManagers/DevicePreviewPM.js +25 -0
- package/lib/Interface/PresentationManagers/IsAuthoringPM.d.ts +10 -0
- package/lib/Interface/PresentationManagers/IsAuthoringPM.js +23 -0
- package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.d.ts +10 -0
- package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.js +23 -0
- package/lib/Interface/PresentationManagers/index.d.ts +3 -0
- package/lib/Interface/PresentationManagers/index.js +15 -0
- package/lib/Interface/appHandler.d.ts +12 -0
- package/lib/Interface/appHandler.js +94 -0
- package/lib/Interface/index.d.ts +2 -0
- package/lib/Interface/index.js +14 -0
- package/lib/PresentationManagers/OrbitCameraPM.d.ts +14 -0
- package/lib/PresentationManagers/OrbitCameraPM.js +31 -0
- package/lib/UseCases/LerpOrbitCamera.d.ts +36 -0
- package/lib/UseCases/LerpOrbitCamera.js +71 -0
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +36 -0
- package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +71 -0
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +9 -0
- package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +31 -0
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +10 -0
- package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +31 -0
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +22 -0
- package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +81 -0
- package/lib/UseCases/OrbitCamera/index.d.ts +4 -0
- package/lib/UseCases/OrbitCamera/index.js +16 -0
- package/lib/UseCases/SerializeCamera.d.ts +21 -0
- package/lib/UseCases/SerializeCamera.js +59 -0
- package/lib/UseCases/SerializeOrbitCamera.d.ts +21 -0
- package/lib/UseCases/SerializeOrbitCamera.js +59 -0
- package/lib/UseCases/SerializedCamDemo.d.ts +0 -0
- package/lib/UseCases/SerializedCamDemo.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,10 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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);
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,250 @@
|
|
|
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;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseAppStateObserver, BaseAppStateUC } from "./Boundary";
|
|
2
|
+
export declare class BaseAppStateUC_Imp 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
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseAppStateUC_Imp = void 0;
|
|
4
|
+
class BaseAppStateUC_Imp {
|
|
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.BaseAppStateUC_Imp = BaseAppStateUC_Imp;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DevicePreviewUC, OnDevicePreviewChange } from "./boundary";
|
|
2
|
+
export declare class DevicePreviewUCImp implements DevicePreviewUC {
|
|
3
|
+
private observers;
|
|
4
|
+
private entity;
|
|
5
|
+
constructor();
|
|
6
|
+
setDevicePreview(x: number, y: number): void;
|
|
7
|
+
clearDevicePreview(): void;
|
|
8
|
+
getUseDevicePreview(): boolean;
|
|
9
|
+
getDevicePreviewSize(): {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
addObserver(observer: OnDevicePreviewChange): void;
|
|
14
|
+
removeObserver(observer: OnDevicePreviewChange): void;
|
|
15
|
+
private notify;
|
|
16
|
+
}
|