@vived/app 2.11.1 → 2.15.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 (88) hide show
  1. package/lib/Entities/Babylon.d.ts +1 -2
  2. package/lib/Entities/Babylon.js +6 -7
  3. package/lib/Entities/DevicePreview.d.ts +1 -1
  4. package/lib/Entities/DevicePreview.js +5 -5
  5. package/lib/Entities/FocusCamera.d.ts +1 -1
  6. package/lib/Entities/FocusCamera.js +19 -19
  7. package/lib/Entities/KeyboardInput.js +1 -0
  8. package/lib/Entities/MemoizedBoolean.d.ts +1 -0
  9. package/lib/Entities/MemoizedBoolean.js +3 -0
  10. package/lib/Entities/MemoizedNumber.d.ts +1 -0
  11. package/lib/Entities/MemoizedNumber.js +3 -0
  12. package/lib/Entities/MemoizedString.d.ts +1 -0
  13. package/lib/Entities/MemoizedString.js +3 -0
  14. package/lib/Entities/MemoizedVector2.d.ts +4 -7
  15. package/lib/Entities/MemoizedVector2.js +9 -23
  16. package/lib/Entities/MemoizedVector3.d.ts +4 -9
  17. package/lib/Entities/MemoizedVector3.js +9 -32
  18. package/lib/Entities/MouseInput.d.ts +11 -5
  19. package/lib/Entities/MouseInput.js +24 -9
  20. package/lib/Entities/ParametricLine.d.ts +1 -1
  21. package/lib/Entities/ParametricLine.js +8 -8
  22. package/lib/Entities/ParametricPlane.d.ts +3 -3
  23. package/lib/Entities/ParametricPlane.js +10 -10
  24. package/lib/Entities/QuestionChallenge.d.ts +21 -0
  25. package/lib/Entities/QuestionChallenge.js +103 -0
  26. package/lib/Entities/QuestionChallengeAnswer.d.ts +32 -0
  27. package/lib/Entities/QuestionChallengeAnswer.js +51 -0
  28. package/lib/Entities/TouchInput.d.ts +16 -8
  29. package/lib/Entities/TouchInput.js +56 -27
  30. package/lib/Entities/index.d.ts +2 -6
  31. package/lib/Entities/index.js +2 -6
  32. package/lib/PresentationManagers/FocusCameraPM.d.ts +2 -1
  33. package/lib/PresentationManagers/FocusCameraPM.js +4 -4
  34. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengeAnswerPM.d.ts +24 -0
  35. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengeAnswerPM.js +65 -0
  36. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengePM.d.ts +17 -0
  37. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengePM.js +46 -0
  38. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengeAnswerPM.d.ts +17 -0
  39. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengeAnswerPM.js +51 -0
  40. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengePM.d.ts +15 -0
  41. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengePM.js +34 -0
  42. package/lib/PresentationManagers/QuestionChallenge/index.d.ts +4 -0
  43. package/lib/PresentationManagers/QuestionChallenge/index.js +16 -0
  44. package/lib/PresentationManagers/index.d.ts +1 -0
  45. package/lib/PresentationManagers/index.js +1 -0
  46. package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.d.ts +2 -1
  47. package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +4 -3
  48. package/lib/UseCases/FocusCamera/LerpFocusCamera.js +2 -2
  49. package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.d.ts +2 -1
  50. package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +4 -3
  51. package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.d.ts +2 -1
  52. package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +5 -5
  53. package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.d.ts +2 -1
  54. package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +2 -1
  55. package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.d.ts +2 -1
  56. package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +4 -4
  57. package/lib/UseCases/FocusCamera/SerializeFocusCamera.js +2 -2
  58. package/lib/UseCases/QuestionChallenge/SerializeQuestionChallenge.d.ts +25 -0
  59. package/lib/UseCases/QuestionChallenge/SerializeQuestionChallenge.js +70 -0
  60. package/lib/UseCases/QuestionChallenge/index.d.ts +4 -0
  61. package/lib/UseCases/QuestionChallenge/index.js +16 -0
  62. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback.d.ts +2 -0
  63. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback.js +16 -0
  64. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerText.d.ts +2 -0
  65. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerText.js +16 -0
  66. package/lib/UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect.d.ts +2 -0
  67. package/lib/UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect.js +16 -0
  68. package/lib/UseCases/index.d.ts +1 -0
  69. package/lib/UseCases/index.js +1 -0
  70. package/lib/ValueObjects/Angle.d.ts +8 -0
  71. package/lib/ValueObjects/Angle.js +22 -0
  72. package/lib/ValueObjects/Color.d.ts +23 -0
  73. package/lib/ValueObjects/Color.js +791 -0
  74. package/lib/ValueObjects/LineSegment2D.d.ts +12 -0
  75. package/lib/ValueObjects/LineSegment2D.js +55 -0
  76. package/lib/ValueObjects/ParametricLine.d.ts +27 -0
  77. package/lib/ValueObjects/ParametricLine.js +66 -0
  78. package/lib/ValueObjects/ParametricPlane.d.ts +20 -0
  79. package/lib/ValueObjects/ParametricPlane.js +64 -0
  80. package/lib/ValueObjects/Vector2.d.ts +22 -0
  81. package/lib/ValueObjects/Vector2.js +87 -0
  82. package/lib/ValueObjects/Vector3.d.ts +25 -0
  83. package/lib/ValueObjects/Vector3.js +91 -0
  84. package/lib/ValueObjects/index.d.ts +7 -0
  85. package/lib/ValueObjects/index.js +19 -0
  86. package/lib/index.d.ts +2 -0
  87. package/lib/index.js +3 -1
  88. package/package.json +1 -1
@@ -0,0 +1,17 @@
1
+ import { QuestionChallenge } from "../../Entities";
2
+ export declare const defaultQestionChallengeAnswerVM: QuestionChallengeAnswerVM;
3
+ export interface QuestionChallengeAnswerVM {
4
+ displayText: string;
5
+ isShowingFeedback: boolean;
6
+ isCorrect: boolean;
7
+ submitAnswer: () => void;
8
+ }
9
+ export declare class QuestionChallengeAnswerPM {
10
+ private answerID;
11
+ private questionChallengeEntity;
12
+ private updateView;
13
+ private answer?;
14
+ dispose: () => void;
15
+ private doUpdateView;
16
+ constructor(answerID: string, questionChallengeEntity: QuestionChallenge, updateView: (vm: QuestionChallengeAnswerVM) => void);
17
+ }
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionChallengeAnswerPM = exports.defaultQestionChallengeAnswerVM = void 0;
4
+ exports.defaultQestionChallengeAnswerVM = {
5
+ displayText: "",
6
+ isShowingFeedback: false,
7
+ isCorrect: false,
8
+ submitAnswer: () => {
9
+ console.log("Default submitAnswer");
10
+ },
11
+ };
12
+ class QuestionChallengeAnswerPM {
13
+ constructor(answerID, questionChallengeEntity, updateView) {
14
+ this.answerID = answerID;
15
+ this.questionChallengeEntity = questionChallengeEntity;
16
+ this.updateView = updateView;
17
+ this.dispose = () => {
18
+ var _a;
19
+ (_a = this.answer) === null || _a === void 0 ? void 0 : _a.removeObserver(this.doUpdateView);
20
+ };
21
+ this.doUpdateView = () => {
22
+ if (!this.answer)
23
+ return;
24
+ const { feedbackText, showFeedback, text, isCorrect } = this.answer;
25
+ let displayText = text ? text : `Answer`;
26
+ if (showFeedback) {
27
+ if (feedbackText) {
28
+ displayText = feedbackText;
29
+ }
30
+ else {
31
+ displayText = isCorrect ? "Correct" : "Incorrect";
32
+ }
33
+ }
34
+ const vm = {
35
+ displayText,
36
+ isCorrect,
37
+ isShowingFeedback: showFeedback,
38
+ submitAnswer: () => {
39
+ this.questionChallengeEntity.submitAnswer(this.answerID);
40
+ },
41
+ };
42
+ this.updateView(vm);
43
+ };
44
+ this.answer = questionChallengeEntity.getAnswer(answerID);
45
+ if (this.answer) {
46
+ this.doUpdateView();
47
+ this.answer.addObserver(this.doUpdateView);
48
+ }
49
+ }
50
+ }
51
+ exports.QuestionChallengeAnswerPM = QuestionChallengeAnswerPM;
@@ -0,0 +1,15 @@
1
+ import { QuestionChallenge } from "../../Entities";
2
+ export declare const defaultQuestionChallengeVM: QuestionChallengeVM;
3
+ export interface QuestionChallengeVM {
4
+ text: string;
5
+ tries: number;
6
+ gotItRight: boolean;
7
+ answers: string[];
8
+ }
9
+ export declare class QuestionChallengePM {
10
+ private questionChallengeEntity;
11
+ private updateView;
12
+ dispose: () => void;
13
+ private doUpdateView;
14
+ constructor(questionChallengeEntity: QuestionChallenge, updateView: (vm: QuestionChallengeVM) => void);
15
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QuestionChallengePM = exports.defaultQuestionChallengeVM = void 0;
4
+ exports.defaultQuestionChallengeVM = {
5
+ text: "",
6
+ answers: [],
7
+ gotItRight: false,
8
+ tries: 0,
9
+ };
10
+ class QuestionChallengePM {
11
+ constructor(questionChallengeEntity, updateView) {
12
+ this.questionChallengeEntity = questionChallengeEntity;
13
+ this.updateView = updateView;
14
+ this.dispose = () => {
15
+ this.questionChallengeEntity.removeObserver(this.doUpdateView);
16
+ };
17
+ this.doUpdateView = () => {
18
+ const { tries, text } = this.questionChallengeEntity;
19
+ const answers = this.questionChallengeEntity
20
+ .getAllAnswers()
21
+ .map((ans) => ans.id);
22
+ const vm = {
23
+ text,
24
+ tries,
25
+ gotItRight: this.questionChallengeEntity.gotItRight,
26
+ answers,
27
+ };
28
+ this.updateView(vm);
29
+ };
30
+ this.doUpdateView();
31
+ this.questionChallengeEntity.addObserver(this.doUpdateView);
32
+ }
33
+ }
34
+ exports.QuestionChallengePM = QuestionChallengePM;
@@ -0,0 +1,4 @@
1
+ export * from "./QuestionChallengePM";
2
+ export * from "./QuestionChallengeAnswerPM";
3
+ export * from "./AuthorQuestionChallengeAnswerPM";
4
+ export * from "./AuthorQuestionChallengePM";
@@ -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("./QuestionChallengePM"), exports);
14
+ __exportStar(require("./QuestionChallengeAnswerPM"), exports);
15
+ __exportStar(require("./AuthorQuestionChallengeAnswerPM"), exports);
16
+ __exportStar(require("./AuthorQuestionChallengePM"), exports);
@@ -4,3 +4,4 @@ export * from "./ShowBabylonInspectorPM";
4
4
  export * from "./HasRedoPM";
5
5
  export * from "./HasUndoPM";
6
6
  export * from "./FocusCameraPM";
7
+ export * from "./QuestionChallenge";
@@ -16,3 +16,4 @@ __exportStar(require("./ShowBabylonInspectorPM"), exports);
16
16
  __exportStar(require("./HasRedoPM"), exports);
17
17
  __exportStar(require("./HasUndoPM"), exports);
18
18
  __exportStar(require("./FocusCameraPM"), exports);
19
+ __exportStar(require("./QuestionChallenge"), exports);
@@ -1,4 +1,5 @@
1
- import { FocusCamera, Vector3 } from "../../Entities";
1
+ import { FocusCamera } from "../../Entities";
2
+ import { Vector3 } from "../../ValueObjects";
2
3
  export declare class BumpDollyFocusCamera {
3
4
  private focusCamera;
4
5
  bumpDurationMS: number;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BumpDollyFocusCamera = void 0;
4
+ const ValueObjects_1 = require("../../ValueObjects");
4
5
  class BumpDollyFocusCamera {
5
6
  constructor(focusCamera) {
6
7
  this.focusCamera = focusCamera;
@@ -25,10 +26,10 @@ class BumpDollyFocusCamera {
25
26
  this.focusCamera.radius = this.initialRadius + range * percent;
26
27
  if (this.pickPoint !== undefined) {
27
28
  const percentChange = this.focusCamera.radius / currentRadius;
28
- const pickToTarget = this.focusCamera.target.subtract(this.pickPoint);
29
+ let pickToTarget = ValueObjects_1.Vector3.subtract(this.focusCamera.target, this.pickPoint);
29
30
  const newLength = pickToTarget.magnitued * percentChange;
30
- pickToTarget.setLength(newLength);
31
- const newTargetPos = this.pickPoint.add(pickToTarget);
31
+ pickToTarget = ValueObjects_1.Vector3.newVectorOfLength(pickToTarget, newLength);
32
+ const newTargetPos = ValueObjects_1.Vector3.add(this.pickPoint, pickToTarget);
32
33
  this.focusCamera.target = newTargetPos;
33
34
  }
34
35
  if (nomralizedTime >= 1 && this.interval) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LerpFocusCamera = void 0;
4
- const Entities_1 = require("../../Entities");
4
+ const ValueObjects_1 = require("../../ValueObjects");
5
5
  class LerpFocusCamera {
6
6
  constructor(focusCamera, easeFn, parameters) {
7
7
  var _a, _b, _c;
@@ -30,7 +30,7 @@ class LerpFocusCamera {
30
30
  const x = this.lerpX(percent);
31
31
  const y = this.lerpY(percent);
32
32
  const z = this.lerpZ(percent);
33
- this.focusCamera.target = new Entities_1.Vector3(x, y, z);
33
+ this.focusCamera.target = new ValueObjects_1.Vector3(x, y, z);
34
34
  if (nomralizedTime >= 1) {
35
35
  clearInterval(this.interval);
36
36
  if (this.onComplete) {
@@ -1,4 +1,5 @@
1
- import { FocusCamera, Vector3 } from "../../Entities";
1
+ import { FocusCamera } from "../../Entities";
2
+ import { Vector3 } from "../../ValueObjects";
2
3
  export declare class PinchDollyFocusCamera {
3
4
  private focusCamera;
4
5
  sensitivity: number;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PinchDollyFocusCamera = void 0;
4
+ const ValueObjects_1 = require("../../ValueObjects");
4
5
  class PinchDollyFocusCamera {
5
6
  constructor(focusCamera) {
6
7
  this.focusCamera = focusCamera;
@@ -13,10 +14,10 @@ class PinchDollyFocusCamera {
13
14
  this.focusCamera.radius = currentRadius - deltaRadius;
14
15
  if (this.pickPoint !== undefined) {
15
16
  const percentChange = this.focusCamera.radius / currentRadius;
16
- const pickToTarget = this.focusCamera.target.subtract(this.pickPoint);
17
+ let pickToTarget = ValueObjects_1.Vector3.subtract(this.focusCamera.target, this.pickPoint);
17
18
  const newLength = pickToTarget.magnitued * percentChange;
18
- pickToTarget.setLength(newLength);
19
- const newTargetPos = this.pickPoint.add(pickToTarget);
19
+ pickToTarget = ValueObjects_1.Vector3.newVectorOfLength(pickToTarget, newLength);
20
+ const newTargetPos = ValueObjects_1.Vector3.add(this.pickPoint, pickToTarget);
20
21
  this.focusCamera.target = newTargetPos;
21
22
  }
22
23
  this.previousDistanceBetweenTouches = distanceBetweenTouches;
@@ -1,4 +1,5 @@
1
- import { FocusCamera, Vector2, Vector3 } from "../../Entities";
1
+ import { FocusCamera } from "../../Entities";
2
+ import { Vector2, Vector3 } from "../../ValueObjects";
2
3
  export declare class PixelDollyFocusCamera {
3
4
  private focusCamera;
4
5
  sensitivity: number;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PixelDollyFocusCamera = void 0;
4
- const Entities_1 = require("../../Entities");
4
+ const ValueObjects_1 = require("../../ValueObjects");
5
5
  class PixelDollyFocusCamera {
6
6
  constructor(focusCamera) {
7
7
  this.focusCamera = focusCamera;
8
8
  this.sensitivity = 0.05;
9
- this.previousPixelPosition = Entities_1.Vector2.Zero();
9
+ this.previousPixelPosition = ValueObjects_1.Vector2.zero();
10
10
  this.doDolly = (pixelPosition) => {
11
11
  const pixelDeltaY = pixelPosition.y - this.previousPixelPosition.y;
12
12
  const deltaRadius = pixelDeltaY * this.sensitivity;
@@ -14,10 +14,10 @@ class PixelDollyFocusCamera {
14
14
  this.focusCamera.radius = currentRadius - deltaRadius;
15
15
  if (this.pickPoint !== undefined) {
16
16
  const percentChange = this.focusCamera.radius / currentRadius;
17
- const pickToTarget = this.focusCamera.target.subtract(this.pickPoint);
17
+ let pickToTarget = ValueObjects_1.Vector3.subtract(this.focusCamera.target, this.pickPoint);
18
18
  const newLength = pickToTarget.magnitued * percentChange;
19
- pickToTarget.setLength(newLength);
20
- const newTargetPos = this.pickPoint.add(pickToTarget);
19
+ pickToTarget = ValueObjects_1.Vector3.newVectorOfLength(pickToTarget, newLength);
20
+ const newTargetPos = ValueObjects_1.Vector3.add(this.pickPoint, pickToTarget);
21
21
  this.focusCamera.target = newTargetPos;
22
22
  }
23
23
  this.previousPixelPosition = pixelPosition;
@@ -1,4 +1,5 @@
1
- import { FocusCamera, Vector2, Vector3 } from "../../Entities";
1
+ import { FocusCamera } from "../../Entities";
2
+ import { Vector2, Vector3 } from "../../ValueObjects";
2
3
  export declare class PixelOrbitFocusCamera {
3
4
  private focusCamera;
4
5
  sensitivity: number;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PixelOrbitFocusCamera = void 0;
4
+ const ValueObjects_1 = require("../../ValueObjects");
4
5
  class PixelOrbitFocusCamera {
5
6
  constructor(focusCamera) {
6
7
  this.focusCamera = focusCamera;
@@ -9,7 +10,7 @@ class PixelOrbitFocusCamera {
9
10
  if (!this.previousPixelPos) {
10
11
  throw new Error("[PixelOrbitFocusCamera] You must initialize first!");
11
12
  }
12
- const pixelChange = pixelPosition.subtract(this.previousPixelPos);
13
+ const pixelChange = ValueObjects_1.Vector2.subtract(pixelPosition, this.previousPixelPos);
13
14
  this.focusCamera.alpha += pixelChange.x * this.sensitivity;
14
15
  this.focusCamera.beta += pixelChange.y * this.sensitivity;
15
16
  this.previousPixelPos = pixelPosition;
@@ -1,4 +1,5 @@
1
- import { Babylon, FocusCamera, ParametricPlane, Vector2 } from "../../Entities";
1
+ import { Babylon, FocusCamera } from "../../Entities";
2
+ import { ParametricPlane, Vector2 } from "../../ValueObjects";
2
3
  export declare class PixelPlanePanFocusCamera {
3
4
  private focusCamera;
4
5
  private babylon;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PixelPlanePanFocusCamera = void 0;
4
- const Entities_1 = require("../../Entities");
4
+ const ValueObjects_1 = require("../../ValueObjects");
5
5
  class PixelPlanePanFocusCamera {
6
6
  constructor(focusCamera, babylon) {
7
7
  this.focusCamera = focusCamera;
@@ -16,10 +16,10 @@ class PixelPlanePanFocusCamera {
16
16
  const p2 = this.plane.intersectLine(finalRay);
17
17
  if (!p1 || !p2)
18
18
  return;
19
- const delta = p2.subtract(p1);
19
+ const delta = ValueObjects_1.Vector3.subtract(p2, p1);
20
20
  const currentTarget = this.focusCamera.target;
21
- const newTarget = new Entities_1.Vector3(currentTarget.x - delta.x, currentTarget.y - delta.y, currentTarget.z - delta.z);
22
- this.focusCamera.target = new Entities_1.Vector3(newTarget.x, newTarget.y, newTarget.z);
21
+ const newTarget = new ValueObjects_1.Vector3(currentTarget.x - delta.x, currentTarget.y - delta.y, currentTarget.z - delta.z);
22
+ this.focusCamera.target = new ValueObjects_1.Vector3(newTarget.x, newTarget.y, newTarget.z);
23
23
  this.previousPixelPos = pixelPosition;
24
24
  };
25
25
  this.initializePan = (initialPixelPos, panPlane) => {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SerializeFocusCamera = void 0;
4
4
  const _1 = require(".");
5
- const Entities_1 = require("../../Entities");
5
+ const ValueObjects_1 = require("../../ValueObjects");
6
6
  class SerializeFocusCamera {
7
7
  constructor(focusCamera, stateMachine) {
8
8
  this.name = "focusCamera";
@@ -52,7 +52,7 @@ class SerializeFocusCamera {
52
52
  }
53
53
  applyV1Data(data, transitionTime) {
54
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);
55
+ const target = new ValueObjects_1.Vector3(target_x, target_y, target_z);
56
56
  if (transitionTime === 0) {
57
57
  this.applyImmediate(alpha, beta, radius, target);
58
58
  }
@@ -0,0 +1,25 @@
1
+ import { QuestionChallenge, SerializedSystem, StateMachine } from "../../Entities";
2
+ export declare class SerializeQuestionChallenge implements SerializedSystem {
3
+ private questionChallenge;
4
+ name: string;
5
+ seriliziationVersion: number;
6
+ getSystemState(): object;
7
+ applySystemState(state: object, version: number): void;
8
+ applyDefaultState(): void;
9
+ private applyDataV1;
10
+ private applyDataV2;
11
+ constructor(questionChallenge: QuestionChallenge, stateMachine: StateMachine);
12
+ }
13
+ export interface ChallengeDataV2 {
14
+ questionText: string;
15
+ answers: AnswerDataV1[];
16
+ }
17
+ export interface ChallengeDataV1 {
18
+ answers: AnswerDataV1[];
19
+ }
20
+ export interface AnswerDataV1 {
21
+ id: string;
22
+ text: string;
23
+ feedback: string;
24
+ isCorrect: boolean;
25
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SerializeQuestionChallenge = void 0;
4
+ const Entities_1 = require("../../Entities");
5
+ class SerializeQuestionChallenge {
6
+ constructor(questionChallenge, stateMachine) {
7
+ this.questionChallenge = questionChallenge;
8
+ this.name = "question";
9
+ this.seriliziationVersion = 2;
10
+ stateMachine.registerSerializedSystem(this);
11
+ }
12
+ getSystemState() {
13
+ const answers = this.questionChallenge
14
+ .getAllAnswers()
15
+ .map((answer) => {
16
+ return {
17
+ id: answer.id,
18
+ feedback: answer.feedbackText,
19
+ isCorrect: answer.isCorrect,
20
+ text: answer.text,
21
+ };
22
+ });
23
+ const state = {
24
+ questionText: this.questionChallenge.text,
25
+ answers,
26
+ };
27
+ return state;
28
+ }
29
+ applySystemState(state, version) {
30
+ if (state && version === 1) {
31
+ const castState = state;
32
+ this.applyDataV1(castState);
33
+ }
34
+ else if (state && version === 2) {
35
+ const castState = state;
36
+ this.applyDataV2(castState);
37
+ }
38
+ else {
39
+ // Unsupported version
40
+ console.warn(`Unsupported data version ${version} for serialized system ${this.name}. Reverting to default state`);
41
+ this.applyDefaultState();
42
+ }
43
+ }
44
+ applyDefaultState() {
45
+ this.questionChallenge.setDefaultState();
46
+ }
47
+ applyDataV1(data) {
48
+ this.questionChallenge.removeAllAnswers();
49
+ this.questionChallenge.text = "";
50
+ data.answers.forEach((answerData) => {
51
+ const answer = Entities_1.makeQuestionChallengeAnswer(answerData.id);
52
+ answer.text = answerData.text;
53
+ answer.isCorrect = answerData.isCorrect;
54
+ answer.feedbackText = answerData.feedback;
55
+ this.questionChallenge.addAnswer(answer);
56
+ });
57
+ }
58
+ applyDataV2(data) {
59
+ this.questionChallenge.removeAllAnswers();
60
+ this.questionChallenge.text = data.questionText;
61
+ data.answers.forEach((answerData) => {
62
+ const answer = Entities_1.makeQuestionChallengeAnswer(answerData.id);
63
+ answer.text = answerData.text;
64
+ answer.isCorrect = answerData.isCorrect;
65
+ answer.feedbackText = answerData.feedback;
66
+ this.questionChallenge.addAnswer(answer);
67
+ });
68
+ }
69
+ }
70
+ exports.SerializeQuestionChallenge = SerializeQuestionChallenge;
@@ -0,0 +1,4 @@
1
+ export * from "./SerializeQuestionChallenge";
2
+ export * from "./setQuesionChallengeAnswerFeedback";
3
+ export * from "./setQuesionChallengeAnswerText";
4
+ export * from "./toggleQuesionChallengeAnswerIsCorrect";
@@ -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("./SerializeQuestionChallenge"), exports);
14
+ __exportStar(require("./setQuesionChallengeAnswerFeedback"), exports);
15
+ __exportStar(require("./setQuesionChallengeAnswerText"), exports);
16
+ __exportStar(require("./toggleQuesionChallengeAnswerIsCorrect"), exports);
@@ -0,0 +1,2 @@
1
+ import { QuestionChallenge } from "../../Entities";
2
+ export declare function makeSetQuestionChallengeAnswerFeedback(answerID: string, questionChallenge: QuestionChallenge): (feedback: string) => void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeSetQuestionChallengeAnswerFeedback = void 0;
4
+ function makeSetQuestionChallengeAnswerFeedback(answerID, questionChallenge) {
5
+ return function setQuestionChallengeAnswerFeedback(feedback) {
6
+ const answer = questionChallenge.getAnswer(answerID);
7
+ if (answer) {
8
+ answer.feedbackText = feedback;
9
+ }
10
+ else {
11
+ console.warn("[setQuestionChallengeAnswerFeedback] Unable to find question by id " +
12
+ answerID);
13
+ }
14
+ };
15
+ }
16
+ exports.makeSetQuestionChallengeAnswerFeedback = makeSetQuestionChallengeAnswerFeedback;
@@ -0,0 +1,2 @@
1
+ import { QuestionChallenge } from "../../Entities";
2
+ export declare function makeSetQuestionChallengeAnswerText(answerID: string, questionChallenge: QuestionChallenge): (text: string) => void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeSetQuestionChallengeAnswerText = void 0;
4
+ function makeSetQuestionChallengeAnswerText(answerID, questionChallenge) {
5
+ return function setQuestionChallengeAnswerText(text) {
6
+ const answer = questionChallenge.getAnswer(answerID);
7
+ if (answer) {
8
+ answer.text = text;
9
+ }
10
+ else {
11
+ console.warn("[setQuestionChallengeAnswerText] Unable to find question by id " +
12
+ answerID);
13
+ }
14
+ };
15
+ }
16
+ exports.makeSetQuestionChallengeAnswerText = makeSetQuestionChallengeAnswerText;
@@ -0,0 +1,2 @@
1
+ import { QuestionChallenge } from "../../Entities";
2
+ export declare function makeToggleQuesionChallengeAnswerIsCorrect(answerID: string, questionChallenge: QuestionChallenge): () => void;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeToggleQuesionChallengeAnswerIsCorrect = void 0;
4
+ function makeToggleQuesionChallengeAnswerIsCorrect(answerID, questionChallenge) {
5
+ return function toggleQuesionChallengeAnswerIsCorrect() {
6
+ const answer = questionChallenge.getAnswer(answerID);
7
+ if (answer) {
8
+ answer.isCorrect = !answer.isCorrect;
9
+ }
10
+ else {
11
+ console.warn("[toggleQuesionChallengeAnswerIsCorrect] Unable to find question by id " +
12
+ answerID);
13
+ }
14
+ };
15
+ }
16
+ exports.makeToggleQuesionChallengeAnswerIsCorrect = makeToggleQuesionChallengeAnswerIsCorrect;
@@ -1,2 +1,3 @@
1
1
  export * from "./setDevicePreview";
2
2
  export * from "./FocusCamera";
3
+ export * from "./QuestionChallenge";
@@ -12,3 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./setDevicePreview"), exports);
14
14
  __exportStar(require("./FocusCamera"), exports);
15
+ __exportStar(require("./QuestionChallenge"), exports);
@@ -0,0 +1,8 @@
1
+ export declare class Angle {
2
+ static fromDegrees(degrees: number): Angle;
3
+ static fromRadians(radians: number): Angle;
4
+ private _degrees;
5
+ get degrees(): number;
6
+ get radians(): number;
7
+ private constructor();
8
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Angle = void 0;
4
+ class Angle {
5
+ constructor(degrees) {
6
+ this._degrees = 0;
7
+ this._degrees = degrees;
8
+ }
9
+ static fromDegrees(degrees) {
10
+ return new Angle(degrees);
11
+ }
12
+ static fromRadians(radians) {
13
+ return new Angle(radians * 180 / Math.PI);
14
+ }
15
+ get degrees() {
16
+ return this._degrees;
17
+ }
18
+ get radians() {
19
+ return this._degrees * Math.PI / 180;
20
+ }
21
+ }
22
+ exports.Angle = Angle;
@@ -0,0 +1,23 @@
1
+ export declare type BasicColor = "";
2
+ export declare class Color {
3
+ static RGBA(r: number, g: number, b: number, a: number): Color;
4
+ static RGB(r: number, g: number, b: number): Color;
5
+ static Hex(hex: string): Color;
6
+ static X11(name: string): Color;
7
+ static Equal(a: Color, b: Color): boolean;
8
+ private _r;
9
+ private _g;
10
+ private _b;
11
+ private _a;
12
+ get r(): number;
13
+ get g(): number;
14
+ get b(): number;
15
+ get a(): number;
16
+ get rPercent(): number;
17
+ get gPercent(): number;
18
+ get bPercent(): number;
19
+ get aPercent(): number;
20
+ get array(): [number, number, number, number];
21
+ private clampVal;
22
+ private constructor();
23
+ }