@vived/app 2.12.0 → 2.15.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.
Files changed (66) hide show
  1. package/lib/Entities/Babylon.js +1 -1
  2. package/lib/Entities/FocusCamera.js +9 -9
  3. package/lib/Entities/MemoizedBoolean.d.ts +1 -0
  4. package/lib/Entities/MemoizedBoolean.js +3 -0
  5. package/lib/Entities/MemoizedNumber.d.ts +1 -0
  6. package/lib/Entities/MemoizedNumber.js +3 -0
  7. package/lib/Entities/MemoizedString.d.ts +1 -0
  8. package/lib/Entities/MemoizedString.js +3 -0
  9. package/lib/Entities/MemoizedVector2.d.ts +1 -0
  10. package/lib/Entities/MemoizedVector2.js +4 -1
  11. package/lib/Entities/MemoizedVector3.d.ts +1 -0
  12. package/lib/Entities/MemoizedVector3.js +4 -1
  13. package/lib/Entities/MouseInput.d.ts +11 -5
  14. package/lib/Entities/MouseInput.js +21 -6
  15. package/lib/Entities/QuestionChallenge.d.ts +21 -0
  16. package/lib/Entities/QuestionChallenge.js +103 -0
  17. package/lib/Entities/QuestionChallengeAnswer.d.ts +32 -0
  18. package/lib/Entities/QuestionChallengeAnswer.js +51 -0
  19. package/lib/Entities/TouchInput.d.ts +15 -7
  20. package/lib/Entities/TouchInput.js +53 -24
  21. package/lib/Entities/index.d.ts +2 -0
  22. package/lib/Entities/index.js +2 -0
  23. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengeAnswerPM.d.ts +24 -0
  24. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengeAnswerPM.js +65 -0
  25. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengePM.d.ts +17 -0
  26. package/lib/PresentationManagers/QuestionChallenge/AuthorQuestionChallengePM.js +46 -0
  27. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengeAnswerPM.d.ts +17 -0
  28. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengeAnswerPM.js +51 -0
  29. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengePM.d.ts +15 -0
  30. package/lib/PresentationManagers/QuestionChallenge/QuestionChallengePM.js +34 -0
  31. package/lib/PresentationManagers/QuestionChallenge/index.d.ts +4 -0
  32. package/lib/PresentationManagers/QuestionChallenge/index.js +16 -0
  33. package/lib/PresentationManagers/index.d.ts +1 -0
  34. package/lib/PresentationManagers/index.js +1 -0
  35. package/lib/UseCases/FocusCamera/BumpDollyFocusCamera.js +3 -3
  36. package/lib/UseCases/FocusCamera/PinchDollyFocusCamera.js +3 -3
  37. package/lib/UseCases/FocusCamera/PixelDollyFocusCamera.js +3 -3
  38. package/lib/UseCases/FocusCamera/PixelOrbitFocusCamera.js +1 -1
  39. package/lib/UseCases/FocusCamera/PixelPlanePanFocusCamera.js +1 -1
  40. package/lib/UseCases/QuestionChallenge/SerializeQuestionChallenge.d.ts +25 -0
  41. package/lib/UseCases/QuestionChallenge/SerializeQuestionChallenge.js +70 -0
  42. package/lib/UseCases/QuestionChallenge/index.d.ts +4 -0
  43. package/lib/UseCases/QuestionChallenge/index.js +16 -0
  44. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback.d.ts +2 -0
  45. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback.js +16 -0
  46. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerText.d.ts +2 -0
  47. package/lib/UseCases/QuestionChallenge/setQuesionChallengeAnswerText.js +16 -0
  48. package/lib/UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect.d.ts +2 -0
  49. package/lib/UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect.js +16 -0
  50. package/lib/UseCases/index.d.ts +1 -0
  51. package/lib/UseCases/index.js +1 -0
  52. package/lib/ValueObjects/Angle.d.ts +2 -2
  53. package/lib/ValueObjects/Angle.js +2 -2
  54. package/lib/ValueObjects/Color.d.ts +4 -8
  55. package/lib/ValueObjects/Color.js +9 -21
  56. package/lib/ValueObjects/LineSegment2D.d.ts +4 -6
  57. package/lib/ValueObjects/LineSegment2D.js +27 -30
  58. package/lib/ValueObjects/ParametricLine.d.ts +1 -1
  59. package/lib/ValueObjects/ParametricLine.js +8 -8
  60. package/lib/ValueObjects/ParametricPlane.d.ts +1 -1
  61. package/lib/ValueObjects/ParametricPlane.js +10 -10
  62. package/lib/ValueObjects/Vector2.d.ts +11 -11
  63. package/lib/ValueObjects/Vector2.js +14 -14
  64. package/lib/ValueObjects/Vector3.d.ts +16 -16
  65. package/lib/ValueObjects/Vector3.js +18 -18
  66. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ import { QuestionChallenge } from "../../Entities";
2
+ export declare const defaultAuthorQuestionChallengeAnswerVM: AuthorQuestionChallengeAnswerVM;
3
+ export interface AuthorQuestionChallengeAnswerVM {
4
+ answerText: string;
5
+ feedbackText: string;
6
+ isCorrect: boolean;
7
+ allowDelete: boolean;
8
+ setAnswerText: (text: string) => void;
9
+ setFeedbackText: (text: string) => void;
10
+ toggleIsCorrect: () => void;
11
+ deleteAnswer: () => void;
12
+ }
13
+ export declare class AuthorQuestionChallengeAnswerPM {
14
+ private answerID;
15
+ private questionChallengeEntity;
16
+ private updateView;
17
+ private answer?;
18
+ setTextUC: (text: string) => void;
19
+ setFeedbackUC: (text: string) => void;
20
+ toggleIsCorrectUC: () => void;
21
+ dispose: () => void;
22
+ private doUpdateView;
23
+ constructor(answerID: string, questionChallengeEntity: QuestionChallenge, updateView: (vm: AuthorQuestionChallengeAnswerVM) => void);
24
+ }
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorQuestionChallengeAnswerPM = exports.defaultAuthorQuestionChallengeAnswerVM = void 0;
4
+ const setQuesionChallengeAnswerFeedback_1 = require("../../UseCases/QuestionChallenge/setQuesionChallengeAnswerFeedback");
5
+ const setQuesionChallengeAnswerText_1 = require("../../UseCases/QuestionChallenge/setQuesionChallengeAnswerText");
6
+ const toggleQuesionChallengeAnswerIsCorrect_1 = require("../../UseCases/QuestionChallenge/toggleQuesionChallengeAnswerIsCorrect");
7
+ exports.defaultAuthorQuestionChallengeAnswerVM = {
8
+ answerText: "",
9
+ feedbackText: "",
10
+ isCorrect: false,
11
+ allowDelete: false,
12
+ setAnswerText: (text) => {
13
+ console.log("Default setAnswerText: " + text);
14
+ },
15
+ setFeedbackText: (text) => {
16
+ console.log("Default setFeedbackText: " + text);
17
+ },
18
+ toggleIsCorrect: () => {
19
+ console.log("Default toggleIsCorrect");
20
+ },
21
+ deleteAnswer: () => {
22
+ console.log("Default deleteAnswer");
23
+ },
24
+ };
25
+ class AuthorQuestionChallengeAnswerPM {
26
+ constructor(answerID, questionChallengeEntity, updateView) {
27
+ this.answerID = answerID;
28
+ this.questionChallengeEntity = questionChallengeEntity;
29
+ this.updateView = updateView;
30
+ this.dispose = () => {
31
+ var _a;
32
+ (_a = this.answer) === null || _a === void 0 ? void 0 : _a.removeObserver(this.doUpdateView);
33
+ this.questionChallengeEntity.removeObserver(this.doUpdateView);
34
+ };
35
+ this.doUpdateView = () => {
36
+ if (this.answer === undefined)
37
+ return;
38
+ const { feedbackText, text, isCorrect } = this.answer;
39
+ const allowDelete = this.questionChallengeEntity.getAllAnswers().length > 2 ? true : false;
40
+ const vm = {
41
+ answerText: text,
42
+ isCorrect,
43
+ feedbackText,
44
+ allowDelete,
45
+ setAnswerText: this.setTextUC,
46
+ setFeedbackText: this.setFeedbackUC,
47
+ toggleIsCorrect: this.toggleIsCorrectUC,
48
+ deleteAnswer: () => {
49
+ this.questionChallengeEntity.removeAnswer(this.answerID);
50
+ },
51
+ };
52
+ this.updateView(vm);
53
+ };
54
+ this.answer = questionChallengeEntity.getAnswer(answerID);
55
+ this.setTextUC = setQuesionChallengeAnswerText_1.makeSetQuestionChallengeAnswerText(answerID, questionChallengeEntity);
56
+ this.setFeedbackUC = setQuesionChallengeAnswerFeedback_1.makeSetQuestionChallengeAnswerFeedback(answerID, questionChallengeEntity);
57
+ this.toggleIsCorrectUC = toggleQuesionChallengeAnswerIsCorrect_1.makeToggleQuesionChallengeAnswerIsCorrect(answerID, questionChallengeEntity);
58
+ if (this.answer) {
59
+ this.doUpdateView();
60
+ this.answer.addObserver(this.doUpdateView);
61
+ this.questionChallengeEntity.addObserver(this.doUpdateView);
62
+ }
63
+ }
64
+ }
65
+ exports.AuthorQuestionChallengeAnswerPM = AuthorQuestionChallengeAnswerPM;
@@ -0,0 +1,17 @@
1
+ import { QuestionChallenge } from "../../Entities";
2
+ export declare const defaultAuthorQuestionChallengeVM: AuthorQuestionChallengeVM;
3
+ export interface AuthorQuestionChallengeVM {
4
+ text: string;
5
+ answers: string[];
6
+ enableResetButton: boolean;
7
+ setQuestionText: (text: string) => void;
8
+ reset: () => void;
9
+ createAnswer: () => void;
10
+ }
11
+ export declare class AuthorQuestionChallengePM {
12
+ private questionChallengeEntity;
13
+ private updateView;
14
+ dispose: () => void;
15
+ private doUpdateView;
16
+ constructor(questionChallengeEntity: QuestionChallenge, updateView: (vm: AuthorQuestionChallengeVM) => void);
17
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AuthorQuestionChallengePM = exports.defaultAuthorQuestionChallengeVM = void 0;
4
+ exports.defaultAuthorQuestionChallengeVM = {
5
+ text: "",
6
+ answers: [],
7
+ enableResetButton: false,
8
+ setQuestionText: (text) => {
9
+ console.log("Default setQuestionText: " + text);
10
+ },
11
+ reset: () => {
12
+ console.log("Default reset");
13
+ },
14
+ createAnswer: () => {
15
+ console.log("Default reset");
16
+ },
17
+ };
18
+ class AuthorQuestionChallengePM {
19
+ constructor(questionChallengeEntity, updateView) {
20
+ this.questionChallengeEntity = questionChallengeEntity;
21
+ this.updateView = updateView;
22
+ this.dispose = () => {
23
+ this.questionChallengeEntity.removeObserver(this.doUpdateView);
24
+ };
25
+ this.doUpdateView = () => {
26
+ const { text, tries } = this.questionChallengeEntity;
27
+ const answers = this.questionChallengeEntity
28
+ .getAllAnswers()
29
+ .map((ans) => ans.id);
30
+ const vm = {
31
+ text,
32
+ answers,
33
+ enableResetButton: tries > 0,
34
+ setQuestionText: (txt) => {
35
+ this.questionChallengeEntity.text = txt;
36
+ },
37
+ reset: () => this.questionChallengeEntity.reset(),
38
+ createAnswer: () => this.questionChallengeEntity.createAnswer(""),
39
+ };
40
+ this.updateView(vm);
41
+ };
42
+ this.doUpdateView();
43
+ this.questionChallengeEntity.addObserver(this.doUpdateView);
44
+ }
45
+ }
46
+ exports.AuthorQuestionChallengePM = AuthorQuestionChallengePM;
@@ -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);
@@ -26,10 +26,10 @@ class BumpDollyFocusCamera {
26
26
  this.focusCamera.radius = this.initialRadius + range * percent;
27
27
  if (this.pickPoint !== undefined) {
28
28
  const percentChange = this.focusCamera.radius / currentRadius;
29
- let pickToTarget = ValueObjects_1.Vector3.subtract(this.focusCamera.target, this.pickPoint);
29
+ let pickToTarget = ValueObjects_1.Vector3.Subtract(this.focusCamera.target, this.pickPoint);
30
30
  const newLength = pickToTarget.magnitued * percentChange;
31
- pickToTarget = ValueObjects_1.Vector3.newVectorOfLength(pickToTarget, newLength);
32
- const newTargetPos = ValueObjects_1.Vector3.add(this.pickPoint, pickToTarget);
31
+ pickToTarget = ValueObjects_1.Vector3.NewVectorOfLength(pickToTarget, newLength);
32
+ const newTargetPos = ValueObjects_1.Vector3.Add(this.pickPoint, pickToTarget);
33
33
  this.focusCamera.target = newTargetPos;
34
34
  }
35
35
  if (nomralizedTime >= 1 && this.interval) {
@@ -14,10 +14,10 @@ class PinchDollyFocusCamera {
14
14
  this.focusCamera.radius = currentRadius - deltaRadius;
15
15
  if (this.pickPoint !== undefined) {
16
16
  const percentChange = this.focusCamera.radius / currentRadius;
17
- let pickToTarget = ValueObjects_1.Vector3.subtract(this.focusCamera.target, this.pickPoint);
17
+ let pickToTarget = ValueObjects_1.Vector3.Subtract(this.focusCamera.target, this.pickPoint);
18
18
  const newLength = pickToTarget.magnitued * percentChange;
19
- pickToTarget = ValueObjects_1.Vector3.newVectorOfLength(pickToTarget, newLength);
20
- const newTargetPos = ValueObjects_1.Vector3.add(this.pickPoint, 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.previousDistanceBetweenTouches = distanceBetweenTouches;
@@ -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
- let pickToTarget = ValueObjects_1.Vector3.subtract(this.focusCamera.target, this.pickPoint);
17
+ let pickToTarget = ValueObjects_1.Vector3.Subtract(this.focusCamera.target, this.pickPoint);
18
18
  const newLength = pickToTarget.magnitued * percentChange;
19
- pickToTarget = ValueObjects_1.Vector3.newVectorOfLength(pickToTarget, newLength);
20
- const newTargetPos = ValueObjects_1.Vector3.add(this.pickPoint, 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;
@@ -10,7 +10,7 @@ class PixelOrbitFocusCamera {
10
10
  if (!this.previousPixelPos) {
11
11
  throw new Error("[PixelOrbitFocusCamera] You must initialize first!");
12
12
  }
13
- const pixelChange = ValueObjects_1.Vector2.subtract(pixelPosition, this.previousPixelPos);
13
+ const pixelChange = ValueObjects_1.Vector2.Subtract(pixelPosition, this.previousPixelPos);
14
14
  this.focusCamera.alpha += pixelChange.x * this.sensitivity;
15
15
  this.focusCamera.beta += pixelChange.y * this.sensitivity;
16
16
  this.previousPixelPos = pixelPosition;
@@ -16,7 +16,7 @@ class PixelPlanePanFocusCamera {
16
16
  const p2 = this.plane.intersectLine(finalRay);
17
17
  if (!p1 || !p2)
18
18
  return;
19
- const delta = ValueObjects_1.Vector3.subtract(p2, p1);
19
+ const delta = ValueObjects_1.Vector3.Subtract(p2, p1);
20
20
  const currentTarget = this.focusCamera.target;
21
21
  const newTarget = new ValueObjects_1.Vector3(currentTarget.x - delta.x, currentTarget.y - delta.y, currentTarget.z - delta.z);
22
22
  this.focusCamera.target = new ValueObjects_1.Vector3(newTarget.x, newTarget.y, newTarget.z);
@@ -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);
@@ -1,6 +1,6 @@
1
1
  export declare class Angle {
2
- static fromDegrees(degrees: number): Angle;
3
- static fromRadians(radians: number): Angle;
2
+ static FromDegrees(degrees: number): Angle;
3
+ static FromRadians(radians: number): Angle;
4
4
  private _degrees;
5
5
  get degrees(): number;
6
6
  get radians(): number;
@@ -6,10 +6,10 @@ class Angle {
6
6
  this._degrees = 0;
7
7
  this._degrees = degrees;
8
8
  }
9
- static fromDegrees(degrees) {
9
+ static FromDegrees(degrees) {
10
10
  return new Angle(degrees);
11
11
  }
12
- static fromRadians(radians) {
12
+ static FromRadians(radians) {
13
13
  return new Angle(radians * 180 / Math.PI);
14
14
  }
15
15
  get degrees() {
@@ -5,14 +5,10 @@ export declare class Color {
5
5
  static Hex(hex: string): Color;
6
6
  static X11(name: string): Color;
7
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;
8
+ readonly r: number;
9
+ readonly g: number;
10
+ readonly b: number;
11
+ readonly a: number;
16
12
  get rPercent(): number;
17
13
  get gPercent(): number;
18
14
  get bPercent(): number;