@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
@@ -1,34 +1,34 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ParametricPlane = void 0;
4
- const Vector3_1 = require("./Vector3");
4
+ const Vector3_1 = require("../ValueObjects/Vector3");
5
5
  class ParametricPlane {
6
6
  constructor(point, normal) {
7
- this.point = point.copy();
8
- this.normal = normal.copy();
7
+ this.point = point;
8
+ this.normal = normal;
9
9
  }
10
10
  static FromPointNormal(point, normal) {
11
11
  return new ParametricPlane(point, normal);
12
12
  }
13
13
  static FromThreePoints(A, B, C) {
14
14
  const point = A;
15
- const AB = B.subtract(A);
16
- const AC = C.subtract(A);
17
- const normal = AB.cross(AC);
15
+ const AB = Vector3_1.Vector3.subtract(B, A);
16
+ const AC = Vector3_1.Vector3.subtract(C, A);
17
+ const normal = Vector3_1.Vector3.cross(AB, AC);
18
18
  return new ParametricPlane(point, normal);
19
19
  }
20
20
  static XY() {
21
- const p = Vector3_1.Vector3.Zero();
21
+ const p = Vector3_1.Vector3.zero();
22
22
  const n = new Vector3_1.Vector3(0, 0, 1);
23
23
  return new ParametricPlane(p, n);
24
24
  }
25
25
  static ZX() {
26
- const p = Vector3_1.Vector3.Zero();
26
+ const p = Vector3_1.Vector3.zero();
27
27
  const n = new Vector3_1.Vector3(0, 1, 0);
28
28
  return new ParametricPlane(p, n);
29
29
  }
30
30
  static YZ() {
31
- const p = Vector3_1.Vector3.Zero();
31
+ const p = Vector3_1.Vector3.zero();
32
32
  const n = new Vector3_1.Vector3(1, 0, 0);
33
33
  return new ParametricPlane(p, n);
34
34
  }
@@ -36,7 +36,7 @@ class ParametricPlane {
36
36
  const a = this.normal.x;
37
37
  const b = this.normal.y;
38
38
  const c = this.normal.z;
39
- let d = this.point.dot(this.normal);
39
+ let d = Vector3_1.Vector3.dot(this.point, this.normal);
40
40
  if (d !== 0) {
41
41
  d *= -1;
42
42
  }
@@ -0,0 +1,21 @@
1
+ import { QuestionChallengeAnswer } from "./QuestionChallengeAnswer";
2
+ export declare type OnQuestionChallengeChange = () => void;
3
+ export interface QuestionChallenge {
4
+ gotItRight: boolean;
5
+ tries: number;
6
+ text: string;
7
+ addAnswer: (answer: QuestionChallengeAnswer) => void;
8
+ removeAnswer: (id: string) => void;
9
+ getAnswer: (id: string) => QuestionChallengeAnswer | undefined;
10
+ getAllAnswers: () => QuestionChallengeAnswer[];
11
+ hasAnswer: (id: string) => boolean;
12
+ createAnswer: (text: string) => QuestionChallengeAnswer;
13
+ removeAllAnswers: () => void;
14
+ setDefaultState: () => void;
15
+ reset: () => void;
16
+ submitAnswer: (id: string) => void;
17
+ setIDGenerator: (generator: () => string) => void;
18
+ addObserver: (observer: OnQuestionChallengeChange) => void;
19
+ removeObserver: (observer: OnQuestionChallengeChange) => void;
20
+ }
21
+ export declare function makeQuestionChallenge(): QuestionChallenge;
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeQuestionChallenge = void 0;
4
+ const _1 = require(".");
5
+ const QuestionChallengeAnswer_1 = require("./QuestionChallengeAnswer");
6
+ function makeQuestionChallenge() {
7
+ return new QuestionChallengeImp();
8
+ }
9
+ exports.makeQuestionChallenge = makeQuestionChallenge;
10
+ class QuestionChallengeImp {
11
+ constructor() {
12
+ this.answerLookup = new Map();
13
+ this.observers = new _1.ObserverList();
14
+ this._tries = 0;
15
+ this._gotItRight = false;
16
+ this.memoizedText = new _1.MemoizedString("", this.observers.notify);
17
+ this.generateID = () => {
18
+ const randomNumber = Math.random() * Date.now();
19
+ return `${randomNumber}`;
20
+ };
21
+ this.setIDGenerator = (generator) => {
22
+ this.generateID = generator;
23
+ };
24
+ this.getAllAnswers = () => {
25
+ return Array.from(this.answerLookup.values());
26
+ };
27
+ this.addAnswer = (answer) => {
28
+ if (this.answerLookup.has(answer.id)) {
29
+ throw new Error(`Answer with ID ${answer.id} already exists`);
30
+ }
31
+ this.answerLookup.set(answer.id, answer);
32
+ this.reset();
33
+ };
34
+ this.removeAnswer = (id) => {
35
+ const answer = this.answerLookup.get(id);
36
+ if (!answer)
37
+ return;
38
+ this.answerLookup.delete(id);
39
+ this.reset();
40
+ };
41
+ this.getAnswer = (id) => {
42
+ return this.answerLookup.get(id);
43
+ };
44
+ this.hasAnswer = (id) => {
45
+ return this.answerLookup.has(id);
46
+ };
47
+ this.reset = () => {
48
+ this._gotItRight = false;
49
+ this._tries = 0;
50
+ this.answerLookup.forEach((ans) => (ans.showFeedback = false));
51
+ this.observers.notify();
52
+ };
53
+ this.submitAnswer = (id) => {
54
+ const ans = this.getAnswer(id);
55
+ if (!ans) {
56
+ console.warn(`[Question Challenge] Unable to find answer by ID: ${id}`);
57
+ return;
58
+ }
59
+ this._tries++;
60
+ ans.showFeedback = true;
61
+ this._gotItRight = ans.isCorrect;
62
+ this.observers.notify();
63
+ };
64
+ this.createAnswer = (text) => {
65
+ const id = this.generateID();
66
+ const answer = QuestionChallengeAnswer_1.makeQuestionChallengeAnswer(id);
67
+ answer.text = text;
68
+ this.addAnswer(answer);
69
+ return answer;
70
+ };
71
+ this.removeAllAnswers = () => {
72
+ const allAnswers = Array.from(this.answerLookup.keys());
73
+ allAnswers.forEach((id) => this.removeAnswer(id));
74
+ this.reset();
75
+ };
76
+ this.setDefaultState = () => {
77
+ this.removeAllAnswers();
78
+ const trueAnswer = this.createAnswer("True");
79
+ trueAnswer.isCorrect = true;
80
+ this.createAnswer("False");
81
+ this.memoizedText.setValQuietly("True / False question text");
82
+ this.reset();
83
+ };
84
+ this.addObserver = (observer) => {
85
+ this.observers.add(observer);
86
+ };
87
+ this.removeObserver = (observer) => {
88
+ this.observers.remove(observer);
89
+ };
90
+ }
91
+ get tries() {
92
+ return this._tries;
93
+ }
94
+ get gotItRight() {
95
+ return this._gotItRight;
96
+ }
97
+ get text() {
98
+ return this.memoizedText.val;
99
+ }
100
+ set text(val) {
101
+ this.memoizedText.val = val;
102
+ }
103
+ }
@@ -0,0 +1,32 @@
1
+ export declare type OnQuestionAnswerChange = () => void;
2
+ export interface QuestionChallengeAnswer {
3
+ id: string;
4
+ text: string;
5
+ isCorrect: boolean;
6
+ feedbackText: string;
7
+ showFeedback: boolean;
8
+ addObserver(observer: OnQuestionAnswerChange): void;
9
+ removeObserver(observer: OnQuestionAnswerChange): void;
10
+ }
11
+ export declare function makeQuestionChallengeAnswer(id: string): QuestionChallengeAnswerImp;
12
+ declare class QuestionChallengeAnswerImp implements QuestionChallengeAnswer {
13
+ private observers;
14
+ private _id;
15
+ get id(): string;
16
+ private memoizedText;
17
+ get text(): string;
18
+ set text(val: string);
19
+ private memoizedFeedback;
20
+ get feedbackText(): string;
21
+ set feedbackText(val: string);
22
+ private memoizedIsCorrect;
23
+ get isCorrect(): boolean;
24
+ set isCorrect(val: boolean);
25
+ private memoizedShowFeedback;
26
+ get showFeedback(): boolean;
27
+ set showFeedback(val: boolean);
28
+ addObserver(observer: OnQuestionAnswerChange): void;
29
+ removeObserver(observer: OnQuestionAnswerChange): void;
30
+ constructor(id: string);
31
+ }
32
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.makeQuestionChallengeAnswer = void 0;
4
+ const _1 = require(".");
5
+ function makeQuestionChallengeAnswer(id) {
6
+ return new QuestionChallengeAnswerImp(id);
7
+ }
8
+ exports.makeQuestionChallengeAnswer = makeQuestionChallengeAnswer;
9
+ class QuestionChallengeAnswerImp {
10
+ constructor(id) {
11
+ this.observers = new _1.ObserverList();
12
+ this.memoizedText = new _1.MemoizedString("Answer", this.observers.notify);
13
+ this.memoizedFeedback = new _1.MemoizedString("", this.observers.notify);
14
+ this.memoizedIsCorrect = new _1.MemoizedBoolean(false, this.observers.notify);
15
+ this.memoizedShowFeedback = new _1.MemoizedBoolean(false, this.observers.notify);
16
+ this._id = id;
17
+ }
18
+ get id() {
19
+ return this._id;
20
+ }
21
+ get text() {
22
+ return this.memoizedText.val;
23
+ }
24
+ set text(val) {
25
+ this.memoizedText.val = val;
26
+ }
27
+ get feedbackText() {
28
+ return this.memoizedFeedback.val;
29
+ }
30
+ set feedbackText(val) {
31
+ this.memoizedFeedback.val = val;
32
+ }
33
+ get isCorrect() {
34
+ return this.memoizedIsCorrect.val;
35
+ }
36
+ set isCorrect(val) {
37
+ this.memoizedIsCorrect.val = val;
38
+ }
39
+ get showFeedback() {
40
+ return this.memoizedShowFeedback.val;
41
+ }
42
+ set showFeedback(val) {
43
+ this.memoizedShowFeedback.val = val;
44
+ }
45
+ addObserver(observer) {
46
+ this.observers.add(observer);
47
+ }
48
+ removeObserver(observer) {
49
+ this.observers.remove(observer);
50
+ }
51
+ }
@@ -1,9 +1,20 @@
1
- import { Vector2 } from ".";
1
+ import { Vector2 } from "../ValueObjects";
2
+ export interface TouchInputEvent {
3
+ touchCount: number;
4
+ touchCenter: Vector2;
5
+ touches: TouchData[];
6
+ event: TouchEvent;
7
+ }
8
+ export interface TouchData {
9
+ id: number;
10
+ position: Vector2;
11
+ touch?: Touch;
12
+ }
2
13
  export interface TouchController {
3
- onTouchStart?: (e: TouchEvent) => void;
4
- onTouchMove?: (e: TouchEvent) => void;
5
- onTouchEnd?: (e: TouchEvent) => void;
6
- onTouchCancel?: (e: TouchEvent) => void;
14
+ onTouchStart?: (e: TouchInputEvent) => void;
15
+ onTouchMove?: (e: TouchInputEvent) => void;
16
+ onTouchEnd?: (e: TouchInputEvent) => void;
17
+ onTouchCancel?: (e: TouchInputEvent) => void;
7
18
  }
8
19
  export interface TouchInput {
9
20
  eventElement: HTMLElement | undefined;
@@ -11,9 +22,6 @@ export interface TouchInput {
11
22
  setEventElement: (eventElement: HTMLElement) => void;
12
23
  clearInputElement: () => void;
13
24
  updateInputElementBounds: () => void;
14
- getTouchOffsetPosition: (touch: Touch) => Vector2;
15
- getDistatnceBetweenTouches: (touch1: Touch, touch2: Touch) => number;
16
- getTouchsCenter: (touches: TouchList) => Vector2;
17
25
  registerController: (controller: TouchController) => void;
18
26
  removeController: (controller: TouchController) => void;
19
27
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeTouchInput = void 0;
4
- const _1 = require(".");
4
+ const ValueObjects_1 = require("../ValueObjects");
5
5
  function makeTouchInput() {
6
6
  return new TouchInputImp();
7
7
  }
@@ -18,31 +18,11 @@ class TouchInputImp {
18
18
  this.getTouchOffsetPosition = (touch) => {
19
19
  if (!this.eventElementBounds) {
20
20
  console.warn("No target bounds");
21
- return _1.Vector2.Zero();
21
+ return ValueObjects_1.Vector2.zero();
22
22
  }
23
23
  const x = touch.clientX - this.eventElementBounds.x;
24
24
  const y = touch.clientY - this.eventElementBounds.y;
25
- return new _1.Vector2(x, y);
26
- };
27
- this.getDistatnceBetweenTouches = (touch1, touch2) => {
28
- const t1 = this.getTouchOffsetPosition(touch1);
29
- const t2 = this.getTouchOffsetPosition(touch2);
30
- const delta = t2.subtract(t1);
31
- return delta.magnitued;
32
- };
33
- this.getTouchsCenter = (touches) => {
34
- const touchCount = touches.length;
35
- if (touchCount === 0)
36
- return _1.Vector2.Zero();
37
- let sumX = 0;
38
- let sumY = 0;
39
- for (let i = 0; i < touchCount; i++) {
40
- const touch = touches[i];
41
- const touchPos = this.getTouchOffsetPosition(touch);
42
- sumX += touchPos.x;
43
- sumY += touchPos.y;
44
- }
45
- return new _1.Vector2(sumX / touches.length, sumY / touches.length);
25
+ return new ValueObjects_1.Vector2(x, y);
46
26
  };
47
27
  this.setEventElement = (eventElement) => {
48
28
  if (this._eventElement)
@@ -56,33 +36,37 @@ class TouchInputImp {
56
36
  };
57
37
  this.onTouchStart = (e) => {
58
38
  e.preventDefault();
39
+ const touchInput = this.createTouchInputEvent(e);
59
40
  this.controllers.forEach((c) => {
60
41
  if (c.onTouchStart) {
61
- c.onTouchStart(e);
42
+ c.onTouchStart(touchInput);
62
43
  }
63
44
  });
64
45
  };
65
46
  this.onTouchMove = (e) => {
66
47
  e.preventDefault();
48
+ const touchInput = this.createTouchInputEvent(e);
67
49
  this.controllers.forEach((c) => {
68
50
  if (c.onTouchMove) {
69
- c.onTouchMove(e);
51
+ c.onTouchMove(touchInput);
70
52
  }
71
53
  });
72
54
  };
73
55
  this.onTouchEnd = (e) => {
74
56
  e.preventDefault();
57
+ const touchInput = this.createTouchInputEvent(e);
75
58
  this.controllers.forEach((c) => {
76
59
  if (c.onTouchEnd) {
77
- c.onTouchEnd(e);
60
+ c.onTouchEnd(touchInput);
78
61
  }
79
62
  });
80
63
  };
81
64
  this.onTouchCancel = (e) => {
82
65
  e.preventDefault();
66
+ const touchInput = this.createTouchInputEvent(e);
83
67
  this.controllers.forEach((c) => {
84
68
  if (c.onTouchCancel) {
85
- c.onTouchCancel(e);
69
+ c.onTouchCancel(touchInput);
86
70
  }
87
71
  });
88
72
  };
@@ -108,4 +92,49 @@ class TouchInputImp {
108
92
  get eventElement() {
109
93
  return this._eventElement;
110
94
  }
95
+ createTouchInputEvent(event) {
96
+ const touches = [];
97
+ const touchCount = event.touches.length;
98
+ let minX = 0;
99
+ let maxX = 0;
100
+ let minY = 0;
101
+ let maxY = 0;
102
+ for (let i = 0; i < touchCount; i++) {
103
+ const touch = event.touches[i];
104
+ const position = this.getTouchOffsetPosition(touch);
105
+ touches.push({
106
+ id: touch.identifier,
107
+ touch,
108
+ position,
109
+ });
110
+ if (i === 0) {
111
+ minX = position.x;
112
+ maxX = position.x;
113
+ minY = position.y;
114
+ maxY = position.y;
115
+ }
116
+ else {
117
+ minX = Math.min(minX, position.x);
118
+ maxX = Math.max(maxX, position.x);
119
+ minY = Math.min(minY, position.y);
120
+ maxY = Math.max(maxY, position.y);
121
+ }
122
+ }
123
+ let cntX = 0;
124
+ let cntY = 0;
125
+ if (touchCount === 1) {
126
+ cntX = maxX;
127
+ cntY = maxY;
128
+ }
129
+ else {
130
+ cntX = minX + (maxX - minX) / 2;
131
+ cntY = minY + (maxY - minY) / 2;
132
+ }
133
+ return {
134
+ touchCenter: new ValueObjects_1.Vector2(cntX, cntY),
135
+ touchCount,
136
+ touches,
137
+ event,
138
+ };
139
+ }
111
140
  }
@@ -1,9 +1,7 @@
1
1
  export * from "./Babylon";
2
2
  export * from "./BaseApp";
3
- export * from "./Color";
4
3
  export * from "./DevicePreview";
5
4
  export * from "./KeyboardInput";
6
- export * from "./LineSegment2D";
7
5
  export * from "./MemoizedBoolean";
8
6
  export * from "./MemoizedNumber";
9
7
  export * from "./MemoizedString";
@@ -11,11 +9,9 @@ export * from "./MemoizedVector2";
11
9
  export * from "./MemoizedVector3";
12
10
  export * from "./ObserverList";
13
11
  export * from "./FocusCamera";
14
- export * from "./ParametricLine";
15
- export * from "./ParametricPlane";
16
12
  export * from "./StateMachine";
17
13
  export * from "./UndoRedo";
18
- export * from "./Vector2";
19
- export * from "./Vector3";
20
14
  export * from "./MouseInput";
21
15
  export * from "./TouchInput";
16
+ export * from "./QuestionChallengeAnswer";
17
+ export * from "./QuestionChallenge";
@@ -12,10 +12,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./Babylon"), exports);
14
14
  __exportStar(require("./BaseApp"), exports);
15
- __exportStar(require("./Color"), exports);
16
15
  __exportStar(require("./DevicePreview"), exports);
17
16
  __exportStar(require("./KeyboardInput"), exports);
18
- __exportStar(require("./LineSegment2D"), exports);
19
17
  __exportStar(require("./MemoizedBoolean"), exports);
20
18
  __exportStar(require("./MemoizedNumber"), exports);
21
19
  __exportStar(require("./MemoizedString"), exports);
@@ -23,11 +21,9 @@ __exportStar(require("./MemoizedVector2"), exports);
23
21
  __exportStar(require("./MemoizedVector3"), exports);
24
22
  __exportStar(require("./ObserverList"), exports);
25
23
  __exportStar(require("./FocusCamera"), exports);
26
- __exportStar(require("./ParametricLine"), exports);
27
- __exportStar(require("./ParametricPlane"), exports);
28
24
  __exportStar(require("./StateMachine"), exports);
29
25
  __exportStar(require("./UndoRedo"), exports);
30
- __exportStar(require("./Vector2"), exports);
31
- __exportStar(require("./Vector3"), exports);
32
26
  __exportStar(require("./MouseInput"), exports);
33
27
  __exportStar(require("./TouchInput"), exports);
28
+ __exportStar(require("./QuestionChallengeAnswer"), exports);
29
+ __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 interface FocusCameraVM {
3
4
  alphaEuler: Vector3;
4
5
  betaEuler: Vector3;
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FocusCameraPM = void 0;
4
- const Entities_1 = require("../Entities");
5
4
  const Utilities_1 = require("../Utilities");
5
+ const ValueObjects_1 = require("../ValueObjects");
6
6
  class FocusCameraPM {
7
7
  constructor(orbitCamera, view) {
8
8
  this.doUpdateView = () => {
9
9
  const { alpha, beta, radius, target } = this.orbitCam;
10
10
  const alphaRadians = Utilities_1.degreesToRadians(alpha);
11
- const alphaEuler = new Entities_1.Vector3(0, alphaRadians, 0);
11
+ const alphaEuler = new ValueObjects_1.Vector3(0, alphaRadians, 0);
12
12
  const betaRadians = Utilities_1.degreesToRadians(beta);
13
- const betaEuler = new Entities_1.Vector3(betaRadians, 0, 0);
14
- const cameraLocalPosition = new Entities_1.Vector3(0, 0, -radius);
13
+ const betaEuler = new ValueObjects_1.Vector3(betaRadians, 0, 0);
14
+ const cameraLocalPosition = new ValueObjects_1.Vector3(0, 0, -radius);
15
15
  this.view({
16
16
  alphaEuler,
17
17
  betaEuler,
@@ -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;