@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,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DevicePreviewUCImp = void 0;
|
|
4
|
+
class DevicePreviewUCImp {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.observers = [];
|
|
7
|
+
this.entity = {
|
|
8
|
+
useDevicePreview: false,
|
|
9
|
+
x: -1,
|
|
10
|
+
y: -1,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
setDevicePreview(x, y) {
|
|
14
|
+
if (this.entity.useDevicePreview &&
|
|
15
|
+
x === this.entity.x &&
|
|
16
|
+
y === this.entity.y) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
this.entity = {
|
|
20
|
+
useDevicePreview: true,
|
|
21
|
+
x,
|
|
22
|
+
y,
|
|
23
|
+
};
|
|
24
|
+
this.notify();
|
|
25
|
+
}
|
|
26
|
+
clearDevicePreview() {
|
|
27
|
+
if (this.entity.useDevicePreview) {
|
|
28
|
+
this.entity = {
|
|
29
|
+
useDevicePreview: false,
|
|
30
|
+
x: -1,
|
|
31
|
+
y: -1,
|
|
32
|
+
};
|
|
33
|
+
this.notify();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
getUseDevicePreview() {
|
|
37
|
+
return this.entity.useDevicePreview;
|
|
38
|
+
}
|
|
39
|
+
getDevicePreviewSize() {
|
|
40
|
+
const { x, y } = this.entity;
|
|
41
|
+
return { x, y };
|
|
42
|
+
}
|
|
43
|
+
addObserver(observer) {
|
|
44
|
+
this.observers.push(observer);
|
|
45
|
+
}
|
|
46
|
+
removeObserver(observer) {
|
|
47
|
+
const index = this.observers.indexOf(observer);
|
|
48
|
+
if (index >= 0) {
|
|
49
|
+
this.observers.splice(index, 1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
notify() {
|
|
53
|
+
this.observers.forEach((obs) => obs.onDevicePreviewChange());
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.DevicePreviewUCImp = DevicePreviewUCImp;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface OnDevicePreviewChange {
|
|
2
|
+
onDevicePreviewChange: () => void;
|
|
3
|
+
}
|
|
4
|
+
export interface DevicePreviewUC {
|
|
5
|
+
setDevicePreview(x: number, y: number): void;
|
|
6
|
+
clearDevicePreview(): void;
|
|
7
|
+
getUseDevicePreview(): boolean;
|
|
8
|
+
getDevicePreviewSize(): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
addObserver(observer: OnDevicePreviewChange): void;
|
|
13
|
+
removeObserver(observer: OnDevicePreviewChange): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Handler } from "@vived/app-host-boundary";
|
|
2
|
+
import { DispatchToHostUC } from "./boundary";
|
|
3
|
+
export declare class DispatchToHostUCImp implements DispatchToHostUC {
|
|
4
|
+
private entity;
|
|
5
|
+
setHostHandler(handler: Handler): void;
|
|
6
|
+
hasHostHandler(): boolean;
|
|
7
|
+
onStateChange(stateObject: object): void;
|
|
8
|
+
onStateComplete(): void;
|
|
9
|
+
submitResults(results: object): void;
|
|
10
|
+
getAssetURL(): string;
|
|
11
|
+
private dispatch;
|
|
12
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DispatchToHostUCImp = void 0;
|
|
4
|
+
const app_host_boundary_1 = require("@vived/app-host-boundary");
|
|
5
|
+
class DispatchToHostUCImp {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.entity = {};
|
|
8
|
+
}
|
|
9
|
+
setHostHandler(handler) {
|
|
10
|
+
this.entity.handler = handler;
|
|
11
|
+
}
|
|
12
|
+
hasHostHandler() {
|
|
13
|
+
if (this.entity.handler) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
onStateChange(stateObject) {
|
|
21
|
+
const request = {
|
|
22
|
+
type: app_host_boundary_1.ON_STATE_CHANGE,
|
|
23
|
+
version: 1,
|
|
24
|
+
payload: {
|
|
25
|
+
stateObject,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
this.dispatch(request);
|
|
29
|
+
}
|
|
30
|
+
onStateComplete() {
|
|
31
|
+
const request = {
|
|
32
|
+
type: app_host_boundary_1.ON_STATE_COMPLETED,
|
|
33
|
+
version: 1,
|
|
34
|
+
};
|
|
35
|
+
this.dispatch(request);
|
|
36
|
+
}
|
|
37
|
+
submitResults(results) {
|
|
38
|
+
const request = {
|
|
39
|
+
type: app_host_boundary_1.SUBMIT_RESULTS,
|
|
40
|
+
version: 1,
|
|
41
|
+
payload: {
|
|
42
|
+
results,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
this.dispatch(request);
|
|
46
|
+
}
|
|
47
|
+
getAssetURL() {
|
|
48
|
+
var _a;
|
|
49
|
+
const callback = (url) => {
|
|
50
|
+
this.entity.appAssetsURL = url;
|
|
51
|
+
};
|
|
52
|
+
const request = {
|
|
53
|
+
type: app_host_boundary_1.GET_APP_ASSET_URL,
|
|
54
|
+
version: 1,
|
|
55
|
+
payload: {
|
|
56
|
+
callback,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
this.dispatch(request);
|
|
60
|
+
return (_a = this.entity.appAssetsURL) !== null && _a !== void 0 ? _a : "";
|
|
61
|
+
}
|
|
62
|
+
dispatch(request) {
|
|
63
|
+
if (!this.entity.handler) {
|
|
64
|
+
throw new Error("No host handler has been set");
|
|
65
|
+
}
|
|
66
|
+
const handler = this.entity.handler;
|
|
67
|
+
handler(request);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.DispatchToHostUCImp = DispatchToHostUCImp;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Handler } from "@vived/app-host-boundary";
|
|
2
|
+
export interface DispatchToHostUC {
|
|
3
|
+
setHostHandler(handler: Handler): void;
|
|
4
|
+
hasHostHandler(): boolean;
|
|
5
|
+
onStateChange(stateObject: object): void;
|
|
6
|
+
onStateComplete(): void;
|
|
7
|
+
submitResults(results: object): void;
|
|
8
|
+
getAssetURL(): string;
|
|
9
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface SerilizationUC {
|
|
2
|
+
getSerializedState(): SerializedStates;
|
|
3
|
+
setSerializedState(state: SerializedStates): void;
|
|
4
|
+
registerSerializableSystem(serializedSystem: SerializableSystem): void;
|
|
5
|
+
}
|
|
6
|
+
export interface SerializedStates {
|
|
7
|
+
version: number;
|
|
8
|
+
systems: SystemState[];
|
|
9
|
+
}
|
|
10
|
+
export interface SystemState {
|
|
11
|
+
name: string;
|
|
12
|
+
seriliziationVersion: number;
|
|
13
|
+
state: object;
|
|
14
|
+
}
|
|
15
|
+
export interface SerializableSystem {
|
|
16
|
+
name: string;
|
|
17
|
+
seriliziationVersion: number;
|
|
18
|
+
getSerializedObject(): object;
|
|
19
|
+
applySerailizedObject(state: object, version: number): void;
|
|
20
|
+
}
|
|
@@ -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.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,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnsupportedVersionNumber = 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;
|
|
13
|
+
class UnsupportedVersionNumber extends Error {
|
|
14
|
+
constructor(version) {
|
|
15
|
+
const msg = "Serialization version " + version + " is not supported";
|
|
16
|
+
super(msg);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.UnsupportedVersionNumber = UnsupportedVersionNumber;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SerializedStates, SerializableSystem, SerilizationUC } from "./Boundary";
|
|
2
|
+
import * as Entity from "./Entity";
|
|
3
|
+
export declare class SerilizationUCImp implements SerilizationUC {
|
|
4
|
+
serilizationEntity: Entity.Serilization;
|
|
5
|
+
private systems;
|
|
6
|
+
constructor();
|
|
7
|
+
registerSerializableSystem(serializedSystem: SerializableSystem): void;
|
|
8
|
+
getSerializedState(): SerializedStates;
|
|
9
|
+
setSerializedState(state: SerializedStates): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerilizationUCImp = void 0;
|
|
4
|
+
const ErrorDuplicateSystemName_1 = require("./ErrorDuplicateSystemName");
|
|
5
|
+
const ErrorUnsupportedVersionNumber_1 = require("./ErrorUnsupportedVersionNumber");
|
|
6
|
+
class SerilizationUCImp {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.systems = new Map();
|
|
9
|
+
this.serilizationEntity = {
|
|
10
|
+
version: 2,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
registerSerializableSystem(serializedSystem) {
|
|
14
|
+
if (this.systems.has(serializedSystem.name)) {
|
|
15
|
+
throw new ErrorDuplicateSystemName_1.DuplicateSystemNameError(serializedSystem.name);
|
|
16
|
+
}
|
|
17
|
+
this.systems.set(serializedSystem.name, serializedSystem);
|
|
18
|
+
}
|
|
19
|
+
getSerializedState() {
|
|
20
|
+
const systems = Array.from(this.systems.values());
|
|
21
|
+
const serializedStates = systems.map((system) => {
|
|
22
|
+
const state = system.getSerializedObject();
|
|
23
|
+
return {
|
|
24
|
+
seriliziationVersion: system.seriliziationVersion,
|
|
25
|
+
name: system.name,
|
|
26
|
+
state,
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
version: this.serilizationEntity.version,
|
|
31
|
+
systems: serializedStates,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
setSerializedState(state) {
|
|
35
|
+
if (state.version === 2) {
|
|
36
|
+
state.systems.forEach((systemState) => {
|
|
37
|
+
const seriliazableSystem = this.systems.get(systemState.name);
|
|
38
|
+
if (seriliazableSystem) {
|
|
39
|
+
seriliazableSystem.applySerailizedObject(systemState.state, systemState.seriliziationVersion);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.warn("Unable to find seriarializedSystem " + systemState.name);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Here is where we will add support for future versions
|
|
47
|
+
else {
|
|
48
|
+
throw new ErrorUnsupportedVersionNumber_1.UnsupportedVersionNumber(state.version);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.SerilizationUCImp = SerilizationUCImp;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SerializedStates, SerializableSystem, SerilizationUC } from "./Boundary";
|
|
2
|
+
import * as Entity from "./Entity";
|
|
3
|
+
export declare class SerilizationUC_Imp implements SerilizationUC {
|
|
4
|
+
serilizationEntity: Entity.Serilization;
|
|
5
|
+
private systems;
|
|
6
|
+
constructor();
|
|
7
|
+
registerSerializableSystem(serializedSystem: SerializableSystem): void;
|
|
8
|
+
getSerializedState(): SerializedStates;
|
|
9
|
+
setSerializedState(state: SerializedStates): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SerilizationUC_Imp = void 0;
|
|
4
|
+
const Errors_1 = require("./Errors");
|
|
5
|
+
class SerilizationUC_Imp {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.systems = new Map();
|
|
8
|
+
this.serilizationEntity = {
|
|
9
|
+
version: 2,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
registerSerializableSystem(serializedSystem) {
|
|
13
|
+
if (this.systems.has(serializedSystem.name)) {
|
|
14
|
+
throw new Errors_1.DuplicateSystemNameError(serializedSystem.name);
|
|
15
|
+
}
|
|
16
|
+
this.systems.set(serializedSystem.name, serializedSystem);
|
|
17
|
+
}
|
|
18
|
+
getSerializedState() {
|
|
19
|
+
const systems = Array.from(this.systems.values());
|
|
20
|
+
const serializedStates = systems.map((system) => {
|
|
21
|
+
const state = system.getSerializedObject();
|
|
22
|
+
return {
|
|
23
|
+
seriliziationVersion: system.seriliziationVersion,
|
|
24
|
+
name: system.name,
|
|
25
|
+
state,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
version: this.serilizationEntity.version,
|
|
30
|
+
systems: serializedStates,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
setSerializedState(state) {
|
|
34
|
+
if (state.version === 2) {
|
|
35
|
+
state.systems.forEach((systemState) => {
|
|
36
|
+
const seriliazableSystem = this.systems.get(systemState.name);
|
|
37
|
+
if (seriliazableSystem) {
|
|
38
|
+
seriliazableSystem.applySerailizedObject(systemState.state, systemState.seriliziationVersion);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
console.warn("Unable to find seriarializedSystem " + systemState.name);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
// Here is where we will add support for future versions
|
|
46
|
+
else {
|
|
47
|
+
throw new Errors_1.UnsupportedVersionNumber(state.version);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.SerilizationUC_Imp = SerilizationUC_Imp;
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
exports.makeBaseAppUC = void 0;
|
|
14
|
+
const UseCase_1 = require("./BaseApp/UseCase");
|
|
15
|
+
__exportStar(require("./BaseApp/Boundary"), exports);
|
|
16
|
+
function makeBaseAppUC() {
|
|
17
|
+
return new UseCase_1.BaseAppUCImp();
|
|
18
|
+
}
|
|
19
|
+
exports.makeBaseAppUC = makeBaseAppUC;
|
package/lib/Entities/Babylon.js
CHANGED
|
@@ -29,11 +29,16 @@ class BabylonImp {
|
|
|
29
29
|
return;
|
|
30
30
|
if (!this._renderCanvas)
|
|
31
31
|
return;
|
|
32
|
+
if (this.workingCanvas.height === this._renderCanvas.height &&
|
|
33
|
+
this.workingCanvas.width === this._renderCanvas.width) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
32
36
|
if (this.resizeEngine) {
|
|
33
37
|
this.resizeEngine();
|
|
34
38
|
}
|
|
35
39
|
this.workingCanvas.height = this._renderCanvas.height;
|
|
36
40
|
this.workingCanvas.width = this._renderCanvas.width;
|
|
41
|
+
this.observers.notify();
|
|
37
42
|
};
|
|
38
43
|
this.submitRenderCanvas = (canvas) => {
|
|
39
44
|
if (canvas === this._renderCanvas)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare class Color {
|
|
2
|
+
static White(): Color;
|
|
3
|
+
static Black(): Color;
|
|
4
|
+
static Red(): Color;
|
|
5
|
+
static Green(): Color;
|
|
6
|
+
static Blue(): Color;
|
|
7
|
+
static Yellow(): Color;
|
|
8
|
+
static Gray(): Color;
|
|
9
|
+
r: number;
|
|
10
|
+
g: number;
|
|
11
|
+
b: number;
|
|
12
|
+
a: number;
|
|
13
|
+
get rPercent(): number;
|
|
14
|
+
get gPercent(): number;
|
|
15
|
+
get bPercent(): number;
|
|
16
|
+
get aPercent(): number;
|
|
17
|
+
equal: (otherColor: Color) => boolean;
|
|
18
|
+
copy: () => Color;
|
|
19
|
+
constructor(r: number, g: number, b: number, a?: number);
|
|
20
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Color = void 0;
|
|
4
|
+
class Color {
|
|
5
|
+
constructor(r, g, b, a = 255) {
|
|
6
|
+
this.equal = (otherColor) => {
|
|
7
|
+
if (otherColor.r === this.r &&
|
|
8
|
+
otherColor.g === this.g &&
|
|
9
|
+
otherColor.b === this.b &&
|
|
10
|
+
otherColor.a === this.a) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
this.copy = () => {
|
|
18
|
+
return new Color(this.r, this.g, this.b, this.a);
|
|
19
|
+
};
|
|
20
|
+
this.r = r;
|
|
21
|
+
this.g = g;
|
|
22
|
+
this.b = b;
|
|
23
|
+
this.a = a;
|
|
24
|
+
}
|
|
25
|
+
static White() {
|
|
26
|
+
return new Color(255, 255, 255, 255);
|
|
27
|
+
}
|
|
28
|
+
static Black() {
|
|
29
|
+
return new Color(0, 0, 0, 255);
|
|
30
|
+
}
|
|
31
|
+
static Red() {
|
|
32
|
+
return new Color(255, 0, 0, 255);
|
|
33
|
+
}
|
|
34
|
+
static Green() {
|
|
35
|
+
return new Color(0, 255, 0, 255);
|
|
36
|
+
}
|
|
37
|
+
static Blue() {
|
|
38
|
+
return new Color(0, 0, 255, 255);
|
|
39
|
+
}
|
|
40
|
+
static Yellow() {
|
|
41
|
+
return new Color(255, 0, 255, 255);
|
|
42
|
+
}
|
|
43
|
+
static Gray() {
|
|
44
|
+
return new Color(192, 192, 192, 255);
|
|
45
|
+
}
|
|
46
|
+
get rPercent() {
|
|
47
|
+
return this.r / 255;
|
|
48
|
+
}
|
|
49
|
+
get gPercent() {
|
|
50
|
+
return this.g / 255;
|
|
51
|
+
}
|
|
52
|
+
get bPercent() {
|
|
53
|
+
return this.b / 255;
|
|
54
|
+
}
|
|
55
|
+
get aPercent() {
|
|
56
|
+
return this.a / 255;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.Color = Color;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Vector2 } from "./Vector2";
|
|
2
|
+
export declare class LineSegment2D {
|
|
3
|
+
start: Vector2;
|
|
4
|
+
end: Vector2;
|
|
5
|
+
get length(): number;
|
|
6
|
+
get direction(): Vector2;
|
|
7
|
+
getPositionAtPercent(percent: number): Vector2;
|
|
8
|
+
closestPointOnLine(point: Vector2): Vector2;
|
|
9
|
+
intersect(otherLine: LineSegment2D, tolerance?: number): Vector2 | undefined;
|
|
10
|
+
constructor(start: Vector2, end: Vector2);
|
|
11
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LineSegment2D = void 0;
|
|
4
|
+
const Vector2_1 = require("./Vector2");
|
|
5
|
+
class LineSegment2D {
|
|
6
|
+
constructor(start, end) {
|
|
7
|
+
this.start = start;
|
|
8
|
+
this.end = end;
|
|
9
|
+
}
|
|
10
|
+
get length() {
|
|
11
|
+
return this.end.subtract(this.start).magnitued;
|
|
12
|
+
}
|
|
13
|
+
get direction() {
|
|
14
|
+
return this.end.subtract(this.start).unit;
|
|
15
|
+
}
|
|
16
|
+
getPositionAtPercent(percent) {
|
|
17
|
+
const dir = this.direction;
|
|
18
|
+
const length = percent * this.length;
|
|
19
|
+
dir.setLength(length);
|
|
20
|
+
return this.start.add(dir);
|
|
21
|
+
}
|
|
22
|
+
closestPointOnLine(point) {
|
|
23
|
+
// see https://monkeyproofsolutions.nl/wordpress/how-to-calculate-the-shortest-distance-between-a-point-and-a-line/
|
|
24
|
+
const direction = this.end.subtract(this.start);
|
|
25
|
+
const tNumerator = direction.dot(point.subtract(this.start));
|
|
26
|
+
const tDenominator = direction.dot(direction);
|
|
27
|
+
const t = tNumerator / tDenominator;
|
|
28
|
+
if (t < 0) {
|
|
29
|
+
return this.start.copy();
|
|
30
|
+
}
|
|
31
|
+
else if (t > 1) {
|
|
32
|
+
return this.end.copy();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
const length = t * direction.magnitued;
|
|
36
|
+
direction.setLength(length);
|
|
37
|
+
return this.start.add(direction);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
intersect(otherLine, tolerance = 0) {
|
|
41
|
+
// See https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
|
|
42
|
+
const x1 = this.start.x;
|
|
43
|
+
const y1 = this.start.y;
|
|
44
|
+
const x2 = this.end.x;
|
|
45
|
+
const y2 = this.end.y;
|
|
46
|
+
const x3 = otherLine.start.x;
|
|
47
|
+
const y3 = otherLine.start.y;
|
|
48
|
+
const x4 = otherLine.end.x;
|
|
49
|
+
const y4 = otherLine.end.y;
|
|
50
|
+
const denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
|
|
51
|
+
if (denominator === 0) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
const tNumerator = (x1 - x3) * (y3 - y4) - (y1 - y3) * (x3 - x4);
|
|
55
|
+
const t = tNumerator / denominator;
|
|
56
|
+
const tTolearnce = tolerance / this.length;
|
|
57
|
+
if (t < -tTolearnce || t > 1 + tTolearnce) {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
const uNumerator = (x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3);
|
|
61
|
+
const u = uNumerator / denominator;
|
|
62
|
+
const uTolearnce = tolerance / otherLine.length;
|
|
63
|
+
if (u < -uTolearnce || u > 1 + uTolearnce)
|
|
64
|
+
return undefined;
|
|
65
|
+
const px = x1 + t * (x2 - x1);
|
|
66
|
+
const py = y1 + t * (y2 - y1);
|
|
67
|
+
return new Vector2_1.Vector2(px, py);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.LineSegment2D = LineSegment2D;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface MouseController {
|
|
2
|
+
onClick?: (e: MouseEvent) => void;
|
|
3
|
+
onDown?: (e: MouseEvent) => void;
|
|
4
|
+
onUp?: (e: MouseEvent) => void;
|
|
5
|
+
onMove?: (e: MouseEvent) => void;
|
|
6
|
+
onWheel?: (e: WheelEvent) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface MouseSceneInput {
|
|
9
|
+
eventElement: HTMLElement | undefined;
|
|
10
|
+
setEventElement: (eventElement: HTMLElement) => void;
|
|
11
|
+
clearInputElement: () => void;
|
|
12
|
+
registerController: (controller: MouseController) => void;
|
|
13
|
+
removeController: (controller: MouseController) => void;
|
|
14
|
+
}
|
|
15
|
+
export declare function makeMouseSceneInput(): MouseSceneInput;
|