@vived/app 2.20.1 → 2.21.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.
Files changed (153) hide show
  1. package/lib/Core/BaseApp/Boundary.d.ts +49 -0
  2. package/lib/Core/BaseApp/Boundary.js +2 -0
  3. package/lib/Core/BaseApp/Entity.d.ts +11 -0
  4. package/lib/Core/BaseApp/Entity.js +2 -0
  5. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.d.ts +3 -0
  6. package/lib/Core/BaseApp/Errors/ErrorDuplicateSystemName.js +12 -0
  7. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.d.ts +3 -0
  8. package/lib/Core/BaseApp/Errors/ErrorNoHostHandler.js +10 -0
  9. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.d.ts +3 -0
  10. package/lib/Core/BaseApp/Errors/ErrorUnsupportedVersionNumber.js +10 -0
  11. package/lib/Core/BaseApp/Errors/index.d.ts +3 -0
  12. package/lib/Core/BaseApp/Errors/index.js +15 -0
  13. package/lib/Core/BaseApp/UseCase.d.ts +43 -0
  14. package/lib/Core/BaseApp/UseCase.js +250 -0
  15. package/lib/Core/BaseAppState/Boundary.d.ts +14 -0
  16. package/lib/Core/BaseAppState/Boundary.js +2 -0
  17. package/lib/Core/BaseAppState/Entity.d.ts +5 -0
  18. package/lib/Core/BaseAppState/Entity.js +2 -0
  19. package/lib/Core/BaseAppState/UseCase.d.ts +16 -0
  20. package/lib/Core/BaseAppState/UseCase.js +54 -0
  21. package/lib/Core/BaseAppState/UseCase_Imp.d.ts +16 -0
  22. package/lib/Core/BaseAppState/UseCase_Imp.js +54 -0
  23. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.d.ts +16 -0
  24. package/lib/Core/DevicePreview/DevicePreviewUC_Imp.js +56 -0
  25. package/lib/Core/DevicePreview/boundary.d.ts +14 -0
  26. package/lib/Core/DevicePreview/boundary.js +2 -0
  27. package/lib/Core/DevicePreview/entity.d.ts +5 -0
  28. package/lib/Core/DevicePreview/entity.js +2 -0
  29. package/lib/Core/DispatchToHost/Entity.d.ts +4 -0
  30. package/lib/Core/DispatchToHost/Entity.js +2 -0
  31. package/lib/Core/DispatchToHost/UseCase.d.ts +12 -0
  32. package/lib/Core/DispatchToHost/UseCase.js +70 -0
  33. package/lib/Core/DispatchToHost/boundary.d.ts +9 -0
  34. package/lib/Core/DispatchToHost/boundary.js +2 -0
  35. package/lib/Core/Serilization/Boundary.d.ts +20 -0
  36. package/lib/Core/Serilization/Boundary.js +2 -0
  37. package/lib/Core/Serilization/Entity.d.ts +3 -0
  38. package/lib/Core/Serilization/Entity.js +2 -0
  39. package/lib/Core/Serilization/ErrorDuplicateSystemName.d.ts +3 -0
  40. package/lib/Core/Serilization/ErrorDuplicateSystemName.js +12 -0
  41. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.d.ts +3 -0
  42. package/lib/Core/Serilization/ErrorUnsupportedVersionNumber.js +10 -0
  43. package/lib/Core/Serilization/Errors.d.ts +6 -0
  44. package/lib/Core/Serilization/Errors.js +19 -0
  45. package/lib/Core/Serilization/UseCase.d.ts +10 -0
  46. package/lib/Core/Serilization/UseCase.js +52 -0
  47. package/lib/Core/Serilization/UseCase_Imp.d.ts +10 -0
  48. package/lib/Core/Serilization/UseCase_Imp.js +51 -0
  49. package/lib/Core/index.d.ts +3 -0
  50. package/lib/Core/index.js +19 -0
  51. package/lib/Entities/Color.d.ts +20 -0
  52. package/lib/Entities/Color.js +59 -0
  53. package/lib/Entities/LineSegment2D.d.ts +11 -0
  54. package/lib/Entities/LineSegment2D.js +70 -0
  55. package/lib/Entities/MouseSceneInput.d.ts +15 -0
  56. package/lib/Entities/MouseSceneInput.js +109 -0
  57. package/lib/Entities/OrbitCamera.d.ts +76 -0
  58. package/lib/Entities/OrbitCamera.js +243 -0
  59. package/lib/Entities/ParametricLine.d.ts +29 -0
  60. package/lib/Entities/ParametricLine.js +79 -0
  61. package/lib/Entities/ParametricPlane.d.ts +20 -0
  62. package/lib/Entities/ParametricPlane.js +63 -0
  63. package/lib/Entities/SceneRoot.d.ts +69 -0
  64. package/lib/Entities/SceneRoot.js +77 -0
  65. package/lib/Entities/TransformNode.d.ts +78 -0
  66. package/lib/Entities/TransformNode.js +217 -0
  67. package/lib/Entities/Vector2.d.ts +21 -0
  68. package/lib/Entities/Vector2.js +83 -0
  69. package/lib/Entities/Vector3.d.ts +19 -0
  70. package/lib/Entities/Vector3.js +75 -0
  71. package/lib/Entities/WorkPlane.d.ts +49 -0
  72. package/lib/Entities/WorkPlane.js +122 -0
  73. package/lib/Entities/index.d.ts +3 -0
  74. package/lib/Entities/index.js +3 -0
  75. package/lib/Interface/Controllers/appHandler.d.ts +12 -0
  76. package/lib/Interface/Controllers/appHandler.js +94 -0
  77. package/lib/Interface/Controllers/defaultAppHanlderFunctions.d.ts +3 -0
  78. package/lib/Interface/Controllers/defaultAppHanlderFunctions.js +31 -0
  79. package/lib/Interface/Controllers/dispatchStateChange.d.ts +2 -0
  80. package/lib/Interface/Controllers/dispatchStateChange.js +10 -0
  81. package/lib/Interface/Controllers/index.d.ts +9 -0
  82. package/lib/Interface/Controllers/index.js +21 -0
  83. package/lib/Interface/Controllers/makeAppHandler.d.ts +12 -0
  84. package/lib/Interface/Controllers/makeAppHandler.js +96 -0
  85. package/lib/Interface/Controllers/setDevicePreview.d.ts +2 -0
  86. package/lib/Interface/Controllers/setDevicePreview.js +14 -0
  87. package/lib/Interface/Controllers/setIsAuthoring.d.ts +2 -0
  88. package/lib/Interface/Controllers/setIsAuthoring.js +14 -0
  89. package/lib/Interface/Controllers/setState.d.ts +2 -0
  90. package/lib/Interface/Controllers/setState.js +21 -0
  91. package/lib/Interface/Controllers/showBabylonInspector.d.ts +2 -0
  92. package/lib/Interface/Controllers/showBabylonInspector.js +9 -0
  93. package/lib/Interface/Controllers/startApp.d.ts +1 -0
  94. package/lib/Interface/Controllers/startApp.js +9 -0
  95. package/lib/Interface/Controllers/stopApp.d.ts +2 -0
  96. package/lib/Interface/Controllers/stopApp.js +10 -0
  97. package/lib/Interface/PresentationManagers/DevicePreviewPM.d.ts +13 -0
  98. package/lib/Interface/PresentationManagers/DevicePreviewPM.js +25 -0
  99. package/lib/Interface/PresentationManagers/IsAuthoringPM.d.ts +10 -0
  100. package/lib/Interface/PresentationManagers/IsAuthoringPM.js +23 -0
  101. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.d.ts +10 -0
  102. package/lib/Interface/PresentationManagers/ShowBabylonInspectorPM.js +23 -0
  103. package/lib/Interface/PresentationManagers/index.d.ts +3 -0
  104. package/lib/Interface/PresentationManagers/index.js +15 -0
  105. package/lib/Interface/appHandler.d.ts +12 -0
  106. package/lib/Interface/appHandler.js +94 -0
  107. package/lib/Interface/index.d.ts +2 -0
  108. package/lib/Interface/index.js +14 -0
  109. package/lib/PresentationManagers/OrbitCameraPM.d.ts +14 -0
  110. package/lib/PresentationManagers/OrbitCameraPM.js +31 -0
  111. package/lib/PresentationManagers/TransformNodePM.d.ts +14 -0
  112. package/lib/PresentationManagers/TransformNodePM.js +23 -0
  113. package/lib/PresentationManagers/index.d.ts +1 -0
  114. package/lib/PresentationManagers/index.js +1 -0
  115. package/lib/UseCases/LerpOrbitCamera.d.ts +36 -0
  116. package/lib/UseCases/LerpOrbitCamera.js +71 -0
  117. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.d.ts +36 -0
  118. package/lib/UseCases/OrbitCamera/LerpOrbitCamera.js +71 -0
  119. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.d.ts +9 -0
  120. package/lib/UseCases/OrbitCamera/PixelDolly_OrbitCamera.js +31 -0
  121. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.d.ts +10 -0
  122. package/lib/UseCases/OrbitCamera/PixelPlanePan_OrbitCamera.js +31 -0
  123. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.d.ts +22 -0
  124. package/lib/UseCases/OrbitCamera/SerializeOrbitCamera.js +81 -0
  125. package/lib/UseCases/OrbitCamera/index.d.ts +4 -0
  126. package/lib/UseCases/OrbitCamera/index.js +16 -0
  127. package/lib/UseCases/SceneRoot/SerializeSceneRoot.d.ts +18 -0
  128. package/lib/UseCases/SceneRoot/SerializeSceneRoot.js +48 -0
  129. package/lib/UseCases/SceneRoot/index.d.ts +1 -0
  130. package/lib/UseCases/SceneRoot/index.js +13 -0
  131. package/lib/UseCases/SerializeCamera.d.ts +21 -0
  132. package/lib/UseCases/SerializeCamera.js +59 -0
  133. package/lib/UseCases/SerializeOrbitCamera.d.ts +21 -0
  134. package/lib/UseCases/SerializeOrbitCamera.js +59 -0
  135. package/lib/UseCases/SerializedCamDemo.d.ts +0 -0
  136. package/lib/UseCases/SerializedCamDemo.js +1 -0
  137. package/lib/UseCases/index.d.ts +1 -0
  138. package/lib/UseCases/index.js +1 -0
  139. package/lib/ValueObjects/Angle.d.ts +18 -0
  140. package/lib/ValueObjects/Angle.js +26 -2
  141. package/lib/ValueObjects/Color.d.ts +46 -0
  142. package/lib/ValueObjects/Color.js +46 -0
  143. package/lib/ValueObjects/Matrix.d.ts +120 -0
  144. package/lib/ValueObjects/Matrix.js +423 -0
  145. package/lib/ValueObjects/Quaternion.d.ts +94 -0
  146. package/lib/ValueObjects/Quaternion.js +243 -0
  147. package/lib/ValueObjects/Vector2.d.ts +82 -0
  148. package/lib/ValueObjects/Vector2.js +82 -0
  149. package/lib/ValueObjects/Vector3.d.ts +107 -0
  150. package/lib/ValueObjects/Vector3.js +116 -0
  151. package/lib/ValueObjects/index.d.ts +2 -0
  152. package/lib/ValueObjects/index.js +2 -0
  153. package/package.json +1 -1
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializedOrbitCamera = void 0;
4
+ const _1 = require(".");
5
+ const Entities_1 = require("../../Entities");
6
+ class SerializedOrbitCamera {
7
+ constructor(orbitCamera, stateMachine) {
8
+ this.name = "orbitCamera";
9
+ this.seriliziationVersion = 1;
10
+ this.orbitCamera = orbitCamera;
11
+ this.stateMachine = stateMachine;
12
+ stateMachine.registerSerializedSystem(this);
13
+ }
14
+ getSystemState() {
15
+ const data = {
16
+ alpha: this.orbitCamera.alpha,
17
+ beta: this.orbitCamera.beta,
18
+ radius: this.orbitCamera.radius,
19
+ target_x: this.orbitCamera.target.x,
20
+ target_y: this.orbitCamera.target.y,
21
+ target_z: this.orbitCamera.target.z,
22
+ };
23
+ return data;
24
+ }
25
+ applySystemState(serializedState, version, transitionTime) {
26
+ try {
27
+ if (version === 1) {
28
+ const castState = serializedState;
29
+ this.applyV1Data(castState, transitionTime);
30
+ }
31
+ else {
32
+ console.warn(`[SerializedCamera] Unsupported version number ${version}. Defaulting`);
33
+ this.applyDefaultState(transitionTime);
34
+ }
35
+ }
36
+ catch (e) {
37
+ console.warn(`[SerializedCamera] Caught when deserializing ${e}. Defaulting`);
38
+ this.applyDefaultState(transitionTime);
39
+ }
40
+ }
41
+ applyDefaultState(transitionDuration) {
42
+ const alpha = this.orbitCamera.defaultAlpha;
43
+ const beta = this.orbitCamera.defaultBeta;
44
+ const radius = this.orbitCamera.defaultRadius;
45
+ const target = this.orbitCamera.defaultTarget;
46
+ if (transitionDuration === 0) {
47
+ this.applyImmediate(alpha, beta, radius, target);
48
+ }
49
+ else {
50
+ this.applyLerp(alpha, beta, radius, target, transitionDuration);
51
+ }
52
+ }
53
+ applyV1Data(data, transitionTime) {
54
+ const { alpha, beta, radius, target_x, target_y, target_z } = data;
55
+ const target = new Entities_1.Vector3(target_x, target_y, target_z);
56
+ if (transitionTime === 0) {
57
+ this.applyImmediate(alpha, beta, radius, target);
58
+ }
59
+ else {
60
+ this.applyLerp(alpha, beta, radius, target, transitionTime);
61
+ }
62
+ }
63
+ applyImmediate(alpha, beta, radius, target) {
64
+ this.orbitCamera.cancelLerp();
65
+ this.orbitCamera.alpha = alpha;
66
+ this.orbitCamera.beta = beta;
67
+ this.orbitCamera.radius = radius;
68
+ this.orbitCamera.target = target;
69
+ }
70
+ applyLerp(alpha, beta, radius, target, transitionTime) {
71
+ const lerpParams = {
72
+ duration: transitionTime,
73
+ finalRadius: radius,
74
+ finalBeta: beta,
75
+ finalAlpha: alpha,
76
+ finalTarget: target,
77
+ };
78
+ new _1.LerpOrbitCamera(this.orbitCamera, this.stateMachine.transitionEaseFunction, lerpParams);
79
+ }
80
+ }
81
+ exports.SerializedOrbitCamera = SerializedOrbitCamera;
@@ -0,0 +1,4 @@
1
+ export * from "./PixelPlanePan_OrbitCamera";
2
+ export * from "./LerpOrbitCamera";
3
+ export * from "./SerializeOrbitCamera";
4
+ export * from "./PixelDolly_OrbitCamera";
@@ -0,0 +1,16 @@
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("./PixelPlanePan_OrbitCamera"), exports);
14
+ __exportStar(require("./LerpOrbitCamera"), exports);
15
+ __exportStar(require("./SerializeOrbitCamera"), exports);
16
+ __exportStar(require("./PixelDolly_OrbitCamera"), exports);
@@ -0,0 +1,18 @@
1
+ import { SerializedSystem, StateMachine } from "../../Entities";
2
+ import { SceneRoot } from "../../Entities/SceneRoot";
3
+ export declare class SerializeSceneRoot implements SerializedSystem {
4
+ name: string;
5
+ seriliziationVersion: number;
6
+ private sceneRoot;
7
+ private stateMachine;
8
+ getSystemState(): object;
9
+ applySystemState(serializedState: object, version: number, transitionTime: number): void;
10
+ applyDefaultState(transitionDuration: number): void;
11
+ private applyV1Data;
12
+ constructor(sceneRoot: SceneRoot, stateMachine: StateMachine);
13
+ }
14
+ export interface SceneRootDataV1 {
15
+ position: [number, number, number];
16
+ rotation: [number, number, number, number];
17
+ scale: [number, number, number];
18
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializeSceneRoot = void 0;
4
+ const ValueObjects_1 = require("../../ValueObjects");
5
+ class SerializeSceneRoot {
6
+ constructor(sceneRoot, stateMachine) {
7
+ this.name = "sceneRoot";
8
+ this.seriliziationVersion = 1;
9
+ this.sceneRoot = sceneRoot;
10
+ this.stateMachine = stateMachine;
11
+ stateMachine.registerSerializedSystem(this);
12
+ }
13
+ getSystemState() {
14
+ const rootTransform = this.sceneRoot.transform;
15
+ const data = {
16
+ position: rootTransform.localPosition.array,
17
+ rotation: rootTransform.localRotation.toArray(),
18
+ scale: rootTransform.localScale.array,
19
+ };
20
+ return data;
21
+ }
22
+ applySystemState(serializedState, version, transitionTime) {
23
+ try {
24
+ if (version === 1) {
25
+ const castState = serializedState;
26
+ this.applyV1Data(castState, transitionTime);
27
+ }
28
+ else {
29
+ console.warn(`[SerializeSceneRoot] Unsupported version number ${version}. Defaulting`);
30
+ this.applyDefaultState(transitionTime);
31
+ }
32
+ }
33
+ catch (e) {
34
+ console.warn(`[SerializeSceneRoot] Caught when deserializing ${e}. Defaulting`);
35
+ this.applyDefaultState(transitionTime);
36
+ }
37
+ }
38
+ applyDefaultState(transitionDuration) {
39
+ this.sceneRoot.transform.lerp(transitionDuration * 1000, this.stateMachine.transitionEaseFunction, this.sceneRoot.defaultPosition, this.sceneRoot.defaultRoation, this.sceneRoot.defaultScale);
40
+ }
41
+ applyV1Data(data, transitionTime) {
42
+ const pos = ValueObjects_1.Vector3.FromArray(data.position);
43
+ const rot = ValueObjects_1.Quaternion.FromArray(data.rotation);
44
+ const scale = ValueObjects_1.Vector3.FromArray(data.scale);
45
+ this.sceneRoot.transform.lerp(transitionTime * 1000, this.stateMachine.transitionEaseFunction, pos, rot, scale);
46
+ }
47
+ }
48
+ exports.SerializeSceneRoot = SerializeSceneRoot;
@@ -0,0 +1 @@
1
+ export * from "./SerializeSceneRoot";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./SerializeSceneRoot"), exports);
@@ -0,0 +1,21 @@
1
+ import { OrbitCamera, SerializedSystem, StateMachine } from "../Entities";
2
+ export declare class SerializedCamera implements SerializedSystem {
3
+ name: string;
4
+ seriliziationVersion: number;
5
+ private orbitCamera;
6
+ private stateMachine;
7
+ private defaultState?;
8
+ getSystemState(): object;
9
+ applySystemState(serializedState: object, version: number, transitionTime: number): void;
10
+ applyDefaultState(transitionDuration: number): void;
11
+ private applyV1Data;
12
+ constructor(orbitCamera: OrbitCamera, stateMachine: StateMachine, defaultState?: CameraDataV1);
13
+ }
14
+ export interface CameraDataV1 {
15
+ alpha: number;
16
+ beta: number;
17
+ radius: number;
18
+ target_x: number;
19
+ target_y: number;
20
+ target_z: number;
21
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializedCamera = void 0;
4
+ const _1 = require(".");
5
+ const Entities_1 = require("../Entities");
6
+ class SerializedCamera {
7
+ constructor(orbitCamera, stateMachine, defaultState) {
8
+ this.name = "orbitCamera";
9
+ this.seriliziationVersion = 1;
10
+ this.orbitCamera = orbitCamera;
11
+ this.stateMachine = stateMachine;
12
+ this.defaultState = defaultState;
13
+ stateMachine.registerSerializedSystem(this);
14
+ }
15
+ getSystemState() {
16
+ const data = {
17
+ alpha: this.orbitCamera.alpha,
18
+ beta: this.orbitCamera.beta,
19
+ radius: this.orbitCamera.radius,
20
+ target_x: this.orbitCamera.target.x,
21
+ target_y: this.orbitCamera.target.y,
22
+ target_z: this.orbitCamera.target.z,
23
+ };
24
+ return data;
25
+ }
26
+ applySystemState(serializedState, version, transitionTime) {
27
+ try {
28
+ if (version === 1) {
29
+ const castState = serializedState;
30
+ this.applyV1Data(castState, transitionTime);
31
+ }
32
+ else {
33
+ console.warn(`[SerializedCamera] Unsupported version number ${version}. Defaulting`);
34
+ this.applyDefaultState(transitionTime);
35
+ }
36
+ }
37
+ catch (e) {
38
+ console.warn(`[SerializedCamera] Caught when deserializing ${e}. Defaulting`);
39
+ this.applyDefaultState(transitionTime);
40
+ }
41
+ }
42
+ applyDefaultState(transitionDuration) {
43
+ if (this.defaultState) {
44
+ this.applyV1Data(this.defaultState, transitionDuration);
45
+ }
46
+ }
47
+ applyV1Data(data, transitionTime) {
48
+ const { alpha, beta, radius, target_x, target_y, target_z } = data;
49
+ const lerpParams = {
50
+ duration: transitionTime,
51
+ finalRadius: radius,
52
+ finalBeta: beta,
53
+ finalAlpha: alpha,
54
+ finalTarget: new Entities_1.Vector3(target_x, target_y, target_z),
55
+ };
56
+ new _1.LerpOrbitCamera(this.orbitCamera, this.stateMachine.transitionEaseFunction, lerpParams);
57
+ }
58
+ }
59
+ exports.SerializedCamera = SerializedCamera;
@@ -0,0 +1,21 @@
1
+ import { OrbitCamera, SerializedSystem, StateMachine } from "../Entities";
2
+ export declare class SerializedOrbitCamera implements SerializedSystem {
3
+ name: string;
4
+ seriliziationVersion: number;
5
+ private orbitCamera;
6
+ private stateMachine;
7
+ private defaultState?;
8
+ getSystemState(): object;
9
+ applySystemState(serializedState: object, version: number, transitionTime: number): void;
10
+ applyDefaultState(transitionDuration: number): void;
11
+ private applyV1Data;
12
+ constructor(orbitCamera: OrbitCamera, stateMachine: StateMachine, defaultState?: CameraDataV1);
13
+ }
14
+ export interface CameraDataV1 {
15
+ alpha: number;
16
+ beta: number;
17
+ radius: number;
18
+ target_x: number;
19
+ target_y: number;
20
+ target_z: number;
21
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializedOrbitCamera = void 0;
4
+ const _1 = require(".");
5
+ const Entities_1 = require("../Entities");
6
+ class SerializedOrbitCamera {
7
+ constructor(orbitCamera, stateMachine, defaultState) {
8
+ this.name = "orbitCamera";
9
+ this.seriliziationVersion = 1;
10
+ this.orbitCamera = orbitCamera;
11
+ this.stateMachine = stateMachine;
12
+ this.defaultState = defaultState;
13
+ stateMachine.registerSerializedSystem(this);
14
+ }
15
+ getSystemState() {
16
+ const data = {
17
+ alpha: this.orbitCamera.alpha,
18
+ beta: this.orbitCamera.beta,
19
+ radius: this.orbitCamera.radius,
20
+ target_x: this.orbitCamera.target.x,
21
+ target_y: this.orbitCamera.target.y,
22
+ target_z: this.orbitCamera.target.z,
23
+ };
24
+ return data;
25
+ }
26
+ applySystemState(serializedState, version, transitionTime) {
27
+ try {
28
+ if (version === 1) {
29
+ const castState = serializedState;
30
+ this.applyV1Data(castState, transitionTime);
31
+ }
32
+ else {
33
+ console.warn(`[SerializedCamera] Unsupported version number ${version}. Defaulting`);
34
+ this.applyDefaultState(transitionTime);
35
+ }
36
+ }
37
+ catch (e) {
38
+ console.warn(`[SerializedCamera] Caught when deserializing ${e}. Defaulting`);
39
+ this.applyDefaultState(transitionTime);
40
+ }
41
+ }
42
+ applyDefaultState(transitionDuration) {
43
+ if (this.defaultState) {
44
+ this.applyV1Data(this.defaultState, transitionDuration);
45
+ }
46
+ }
47
+ applyV1Data(data, transitionTime) {
48
+ const { alpha, beta, radius, target_x, target_y, target_z } = data;
49
+ const lerpParams = {
50
+ duration: transitionTime,
51
+ finalRadius: radius,
52
+ finalBeta: beta,
53
+ finalAlpha: alpha,
54
+ finalTarget: new Entities_1.Vector3(target_x, target_y, target_z),
55
+ };
56
+ new _1.LerpOrbitCamera(this.orbitCamera, this.stateMachine.transitionEaseFunction, lerpParams);
57
+ }
58
+ }
59
+ exports.SerializedOrbitCamera = SerializedOrbitCamera;
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
@@ -2,3 +2,4 @@ export * from "./setDevicePreview";
2
2
  export * from "./FocusCamera";
3
3
  export * from "./QuestionChallenge";
4
4
  export * from "./LerpVector3";
5
+ export * from "./SceneRoot";
@@ -14,3 +14,4 @@ __exportStar(require("./setDevicePreview"), exports);
14
14
  __exportStar(require("./FocusCamera"), exports);
15
15
  __exportStar(require("./QuestionChallenge"), exports);
16
16
  __exportStar(require("./LerpVector3"), exports);
17
+ __exportStar(require("./SceneRoot"), exports);
@@ -1,6 +1,24 @@
1
1
  export declare class Angle {
2
+ /**
3
+ * Creates an angle from degrees
4
+ * @param degrees Angle in degrees
5
+ * @returns The angle
6
+ */
2
7
  static FromDegrees(degrees: number): Angle;
8
+ /**
9
+ * Creates an angle from radians
10
+ * @param radians Angle in radians
11
+ * @returns The angle
12
+ */
3
13
  static FromRadians(radians: number): Angle;
14
+ /**
15
+ * Check to see if two angles are close
16
+ * @param a Angle A
17
+ * @param b Angle B
18
+ * @param tolerance Tolerance for "Close" in degrees. Defaults to 0.001;
19
+ * @returns True if the difference between A and B (in degress) is less than the tolerance
20
+ */
21
+ static Close(a: Angle, b: Angle, tolerance?: number): boolean;
4
22
  private _degrees;
5
23
  get degrees(): number;
6
24
  get radians(): number;
@@ -6,17 +6,41 @@ class Angle {
6
6
  this._degrees = 0;
7
7
  this._degrees = degrees;
8
8
  }
9
+ /**
10
+ * Creates an angle from degrees
11
+ * @param degrees Angle in degrees
12
+ * @returns The angle
13
+ */
9
14
  static FromDegrees(degrees) {
10
15
  return new Angle(degrees);
11
16
  }
17
+ /**
18
+ * Creates an angle from radians
19
+ * @param radians Angle in radians
20
+ * @returns The angle
21
+ */
12
22
  static FromRadians(radians) {
13
- return new Angle(radians * 180 / Math.PI);
23
+ return new Angle((radians * 180) / Math.PI);
24
+ }
25
+ /**
26
+ * Check to see if two angles are close
27
+ * @param a Angle A
28
+ * @param b Angle B
29
+ * @param tolerance Tolerance for "Close" in degrees. Defaults to 0.001;
30
+ * @returns True if the difference between A and B (in degress) is less than the tolerance
31
+ */
32
+ static Close(a, b, tolerance = 0.001) {
33
+ let diff = a.degrees - b.degrees;
34
+ if (diff < 0) {
35
+ diff = -diff;
36
+ }
37
+ return diff < tolerance;
14
38
  }
15
39
  get degrees() {
16
40
  return this._degrees;
17
41
  }
18
42
  get radians() {
19
- return this._degrees * Math.PI / 180;
43
+ return (this._degrees * Math.PI) / 180;
20
44
  }
21
45
  }
22
46
  exports.Angle = Angle;
@@ -1,18 +1,64 @@
1
1
  export declare type BasicColor = "";
2
2
  export declare class Color {
3
+ /**
4
+ * Creates a Color from RGBA values
5
+ * @param r Red value, between 0-255
6
+ * @param g Green value, between 0-255
7
+ * @param b Blue value, between 0-255
8
+ * @param a Alpha value, between 0-255
9
+ * @returns The Color
10
+ */
3
11
  static RGBA(r: number, g: number, b: number, a: number): Color;
12
+ /**
13
+ * Creates a Color from RGB values. Alpha is set to 255
14
+ * @param r Red value, between 0-255
15
+ * @param g Green value, between 0-255
16
+ * @param b Blue value, between 0-255
17
+ * @returns The Color
18
+ */
4
19
  static RGB(r: number, g: number, b: number): Color;
20
+ /**
21
+ * Creates a color from a Hex value
22
+ * @param hex The Hex string. Example '808080'
23
+ * @returns The Color
24
+ */
5
25
  static Hex(hex: string): Color;
26
+ /**
27
+ * Creates a color from the X11 standard.
28
+ * @param name X11 name
29
+ * @returns The Color. If the color name is not found, it will return Black.
30
+ */
6
31
  static X11(name: string): Color;
32
+ /**
33
+ * Checks to see if Color A equals Color B
34
+ * @param a Color A
35
+ * @param b Color B
36
+ * @returns True if Color A === Color B
37
+ */
7
38
  static Equal(a: Color, b: Color): boolean;
8
39
  readonly r: number;
9
40
  readonly g: number;
10
41
  readonly b: number;
11
42
  readonly a: number;
43
+ /**
44
+ * Return the r value as a percent
45
+ */
12
46
  get rPercent(): number;
47
+ /**
48
+ * Return the g value as a percent
49
+ */
13
50
  get gPercent(): number;
51
+ /**
52
+ * Return the b value as a percent
53
+ */
14
54
  get bPercent(): number;
55
+ /**
56
+ * Return the a value as a percent
57
+ */
15
58
  get aPercent(): number;
59
+ /**
60
+ * Returns the Color values as an array [r,g,b,a]
61
+ */
16
62
  get array(): [number, number, number, number];
17
63
  private clampVal;
18
64
  private constructor();
@@ -8,12 +8,32 @@ class Color {
8
8
  this.b = this.clampVal(b);
9
9
  this.a = this.clampVal(a);
10
10
  }
11
+ /**
12
+ * Creates a Color from RGBA values
13
+ * @param r Red value, between 0-255
14
+ * @param g Green value, between 0-255
15
+ * @param b Blue value, between 0-255
16
+ * @param a Alpha value, between 0-255
17
+ * @returns The Color
18
+ */
11
19
  static RGBA(r, g, b, a) {
12
20
  return new Color(r, g, b, a);
13
21
  }
22
+ /**
23
+ * Creates a Color from RGB values. Alpha is set to 255
24
+ * @param r Red value, between 0-255
25
+ * @param g Green value, between 0-255
26
+ * @param b Blue value, between 0-255
27
+ * @returns The Color
28
+ */
14
29
  static RGB(r, g, b) {
15
30
  return new Color(r, g, b, 255);
16
31
  }
32
+ /**
33
+ * Creates a color from a Hex value
34
+ * @param hex The Hex string. Example '808080'
35
+ * @returns The Color
36
+ */
17
37
  static Hex(hex) {
18
38
  // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
19
39
  const shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
@@ -35,6 +55,11 @@ class Color {
35
55
  }
36
56
  return Color.RGB(r, g, b);
37
57
  }
58
+ /**
59
+ * Creates a color from the X11 standard.
60
+ * @param name X11 name
61
+ * @returns The Color. If the color name is not found, it will return Black.
62
+ */
38
63
  static X11(name) {
39
64
  for (const c of x11Colors) {
40
65
  if (c.name === name) {
@@ -44,6 +69,12 @@ class Color {
44
69
  console.warn("Unable to find X11 color by name: " + name);
45
70
  return Color.RGB(0, 0, 0);
46
71
  }
72
+ /**
73
+ * Checks to see if Color A equals Color B
74
+ * @param a Color A
75
+ * @param b Color B
76
+ * @returns True if Color A === Color B
77
+ */
47
78
  static Equal(a, b) {
48
79
  if (a.a !== b.a)
49
80
  return false;
@@ -51,18 +82,33 @@ class Color {
51
82
  return false;
52
83
  return true;
53
84
  }
85
+ /**
86
+ * Return the r value as a percent
87
+ */
54
88
  get rPercent() {
55
89
  return this.r / 255;
56
90
  }
91
+ /**
92
+ * Return the g value as a percent
93
+ */
57
94
  get gPercent() {
58
95
  return this.g / 255;
59
96
  }
97
+ /**
98
+ * Return the b value as a percent
99
+ */
60
100
  get bPercent() {
61
101
  return this.b / 255;
62
102
  }
103
+ /**
104
+ * Return the a value as a percent
105
+ */
63
106
  get aPercent() {
64
107
  return this.a / 255;
65
108
  }
109
+ /**
110
+ * Returns the Color values as an array [r,g,b,a]
111
+ */
66
112
  get array() {
67
113
  return [this.r, this.g, this.b, this.a];
68
114
  }