wgge 0.1.35 → 1.0.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 (121) hide show
  1. package/README.MD +9 -9
  2. package/bin/deploy.cmd +1 -1
  3. package/core/ActivatedTreeNode.js +187 -187
  4. package/core/Collection.js +156 -156
  5. package/core/Dictionary.js +83 -83
  6. package/core/animation/AnimatedRotation.js +44 -44
  7. package/core/animation/AnimatedValue.js +33 -33
  8. package/core/animation/AnimatedVector2.js +35 -35
  9. package/core/animation/ProgressRotation.js +40 -40
  10. package/core/animation/ProgressValue.js +30 -30
  11. package/core/animation/ProgressVector2.js +23 -23
  12. package/core/audio/AudioModel.js +36 -36
  13. package/core/audio/AudioRenderer.js +120 -120
  14. package/core/audio/global/GlobalAudioModel.js +88 -88
  15. package/core/audio/global/GlobalAudioRenderer.js +108 -108
  16. package/core/controller/AnimationController.js +37 -37
  17. package/core/controller/AnimationDelayController.js +56 -56
  18. package/core/controller/AnimationFloatController.js +39 -39
  19. package/core/controller/AnimationRotationVector2Controller.js +45 -45
  20. package/core/controller/AnimationVector2Controller.js +39 -39
  21. package/core/controller/CollectionController.js +47 -47
  22. package/core/controller/ConditionalNodeController.js +51 -51
  23. package/core/controller/ControllerBase.js +64 -64
  24. package/core/controller/ControllerWithSaveGame.js +27 -27
  25. package/core/controller/ControllerWithTimeout.js +10 -10
  26. package/core/controller/NullableNodeController.js +35 -35
  27. package/core/controller/TimeoutController.js +26 -26
  28. package/core/helper/ArrayHelper.js +19 -19
  29. package/core/helper/DOMHelper.js +167 -167
  30. package/core/helper/HttpHelper.js +41 -41
  31. package/core/helper/ImageHelper.js +36 -36
  32. package/core/helper/NumberHelper.js +28 -28
  33. package/core/helper/ObjectHelper.js +10 -10
  34. package/core/helper/StringHelper.js +59 -59
  35. package/core/model/ModelBase.js +99 -99
  36. package/core/model/ObjectModel.js +100 -100
  37. package/core/model/collection/ModelNodeCollection.js +238 -238
  38. package/core/model/collection/table/IdentifiedModelNode.js +24 -24
  39. package/core/model/collection/table/ModelNodeTable.js +53 -53
  40. package/core/model/event/ChangeEvent.js +24 -24
  41. package/core/model/event/NodeWithEvents.js +37 -37
  42. package/core/model/template/TemplateNode.js +45 -45
  43. package/core/model/value/BoolValue.js +17 -17
  44. package/core/model/value/CapacityValue.js +49 -49
  45. package/core/model/value/DirtyValue.js +66 -66
  46. package/core/model/value/FloatValue.js +12 -12
  47. package/core/model/value/IntValue.js +32 -32
  48. package/core/model/value/NullableNode.js +71 -71
  49. package/core/model/vector/Quaternion.js +86 -86
  50. package/core/model/vector/Rotation.js +61 -61
  51. package/core/model/vector/Vector2.js +178 -178
  52. package/core/renderer/RendererBase.js +46 -46
  53. package/core/renderer/canvas/CanvasRenderer.js +132 -132
  54. package/core/renderer/canvas/ImageCanvasRenderer.js +59 -59
  55. package/core/renderer/canvas/ImageViewRenderer.js +42 -42
  56. package/core/renderer/dom/DirtyValueRenderer.js +36 -36
  57. package/core/renderer/dom/DomRenderer.js +32 -32
  58. package/core/renderer/dom/ImageDomRenderer.js +41 -41
  59. package/core/renderer/dom/Vector2Renderer.js +36 -36
  60. package/core/renderer/generic/CollectionRenderer.js +50 -50
  61. package/core/renderer/generic/ConditionalNodeRenderer.js +57 -57
  62. package/core/renderer/generic/NullableNodeRenderer.js +43 -43
  63. package/core/renderer/generic/SwitchController.js +34 -34
  64. package/core/renderer/generic/SwitchRenderer.js +34 -34
  65. package/editor/EditorController.js +134 -134
  66. package/editor/EditorModel.js +38 -38
  67. package/editor/EditorRenderer.js +116 -116
  68. package/editor/form/NodeFormRenderer.js +180 -180
  69. package/editor/material/MaterialPreviewRenderer.js +136 -136
  70. package/editor/table/TableRenderer.js +123 -123
  71. package/editor/table/lookup/TableLookupRenderer.js +120 -120
  72. package/editor/table/row/TableRowRenderer.js +98 -98
  73. package/game/GameController.js +136 -136
  74. package/game/GameModel.js +73 -73
  75. package/game/GameRenderer.js +108 -108
  76. package/game/controls/ControlsController.js +92 -92
  77. package/game/controls/ControlsModel.js +64 -64
  78. package/game/menu/MainMenuRenderer.js +37 -37
  79. package/game/menu/MenuModel.js +25 -25
  80. package/game/menu/MenuRenderer.js +34 -34
  81. package/game/menu/item/MenuItemModel.js +31 -31
  82. package/game/menu/item/MenuItemRenderer.js +48 -48
  83. package/game/resources/ResourcesModel.js +26 -26
  84. package/game/resources/assets/AssetCache.js +203 -203
  85. package/game/resources/assets/loader/AssetLoader.js +56 -56
  86. package/game/resources/assets/loader/AudioLoader.js +15 -15
  87. package/game/resources/assets/loader/GlbLoader.js +16 -16
  88. package/game/resources/assets/loader/ImageLoader.js +15 -15
  89. package/game/resources/assets/loader/MaterialLoader.js +50 -50
  90. package/game/resources/assets/loader/Model3dAnimationLoader.js +28 -28
  91. package/game/resources/assets/loader/Model3dLoader.js +26 -26
  92. package/game/resources/assets/loader/SpriteLoader.js +40 -40
  93. package/game/resources/image/DualImageModel.js +34 -34
  94. package/game/resources/image/ImageModel.js +24 -24
  95. package/game/resources/image/ImageViewModel.js +106 -106
  96. package/game/resources/material/MaterialModel.js +69 -69
  97. package/game/save/SaveGameController.js +21 -21
  98. package/game/save/SaveGameModel.js +5 -5
  99. package/game/save/SaveGameRenderer.js +17 -17
  100. package/game/save/editor/SaveGameEditorRenderer.js +17 -17
  101. package/index.html +42 -42
  102. package/index.js +72 -73
  103. package/package.json +28 -35
  104. package/style/basic/editor.less +290 -290
  105. package/style/basic/game.less +171 -171
  106. package/style/style.less +3 -3
  107. package/webpack.config.js +29 -29
  108. package/core/animation/3d/AnimatedVector3.js +0 -35
  109. package/core/animation/3d/AnimationHelper.js +0 -103
  110. package/core/animation/3d/ProgressVector3.js +0 -26
  111. package/core/helper/GUIHelper.js +0 -53
  112. package/core/model/vector/Vector3.js +0 -107
  113. package/core/particles/ParticleController.js +0 -35
  114. package/core/particles/ParticleModel.js +0 -68
  115. package/core/particles/ParticleRenderer.js +0 -53
  116. package/core/particles/generator/ParticleGeneratorController.js +0 -70
  117. package/core/particles/generator/ParticleGeneratorModel.js +0 -76
  118. package/core/particles/generator/ParticleGeneratorRenderer.js +0 -27
  119. package/core/renderer/svg/SvgRenderer.js +0 -139
  120. package/core/renderer/three/ThreeRenderer.js +0 -17
  121. package/game/resources/3d/3DModel.js +0 -30
@@ -1,35 +1,35 @@
1
- import ProgressVector2 from "./ProgressVector2";
2
- import NumberHelper from "../helper/NumberHelper";
3
- import {EASING_FLAT} from "./ProgressValue";
4
-
5
- export default class AnimatedVector2 {
6
- progressVector;
7
- duration;
8
- elapsed;
9
-
10
- constructor(start, end, duration, easing = EASING_FLAT, elapsed = 0) {
11
- this.progressVector = new ProgressVector2(start, end, easing, elapsed);
12
- this.duration = duration;
13
- this.elapsed = elapsed;
14
- this.updateProgress();
15
- }
16
-
17
- addElapsed(delta) {
18
- this.elapsed += delta;
19
- this.updateProgress();
20
- }
21
-
22
- updateProgress() {
23
- this.progressVector.setProgress(NumberHelper.between(0, 1, this.elapsed / this.duration));
24
- }
25
-
26
- get(delta = null) {
27
- if (delta !== null) this.addElapsed(delta);
28
- return this.progressVector.get();
29
- }
30
-
31
- isFinished() {
32
- return (this.elapsed >= this.duration);
33
- }
34
-
35
- }
1
+ import ProgressVector2 from "./ProgressVector2";
2
+ import NumberHelper from "../helper/NumberHelper";
3
+ import {EASING_FLAT} from "./ProgressValue";
4
+
5
+ export default class AnimatedVector2 {
6
+ progressVector;
7
+ duration;
8
+ elapsed;
9
+
10
+ constructor(start, end, duration, easing = EASING_FLAT, elapsed = 0) {
11
+ this.progressVector = new ProgressVector2(start, end, easing, elapsed);
12
+ this.duration = duration;
13
+ this.elapsed = elapsed;
14
+ this.updateProgress();
15
+ }
16
+
17
+ addElapsed(delta) {
18
+ this.elapsed += delta;
19
+ this.updateProgress();
20
+ }
21
+
22
+ updateProgress() {
23
+ this.progressVector.setProgress(NumberHelper.between(0, 1, this.elapsed / this.duration));
24
+ }
25
+
26
+ get(delta = null) {
27
+ if (delta !== null) this.addElapsed(delta);
28
+ return this.progressVector.get();
29
+ }
30
+
31
+ isFinished() {
32
+ return (this.elapsed >= this.duration);
33
+ }
34
+
35
+ }
@@ -1,40 +1,40 @@
1
- import Rotation from "../model/vector/Rotation";
2
- import {EASING_FLAT} from "./ProgressValue";
3
-
4
- export default class ProgressRotation {
5
-
6
- /**
7
- * @type Number
8
- */
9
- start;
10
-
11
- /**
12
- * @type Number
13
- */
14
- distance;
15
-
16
- /**
17
- * @type Number
18
- */
19
- progress;
20
-
21
- /**
22
- *
23
- * @param {Number} start
24
- * @param {Number} end
25
- * @param {(float) => float} easing
26
- * @param {Number} progress
27
- */
28
- constructor(start, end, easing = EASING_FLAT, progress = 0) {
29
- this.start = Rotation.normalizeValue(start);
30
- this.distance = Rotation.diff(end, start);
31
- this.easing = easing;
32
- this.progress = progress;
33
- }
34
-
35
- get(progress = null) {
36
- if (progress !== null) this.progress = progress;
37
- return Rotation.normalizeValue(this.start + (this.easing(this.progress) * this.distance));
38
- }
39
-
40
- }
1
+ import Rotation from "../model/vector/Rotation";
2
+ import {EASING_FLAT} from "./ProgressValue";
3
+
4
+ export default class ProgressRotation {
5
+
6
+ /**
7
+ * @type Number
8
+ */
9
+ start;
10
+
11
+ /**
12
+ * @type Number
13
+ */
14
+ distance;
15
+
16
+ /**
17
+ * @type Number
18
+ */
19
+ progress;
20
+
21
+ /**
22
+ *
23
+ * @param {Number} start
24
+ * @param {Number} end
25
+ * @param {(float) => float} easing
26
+ * @param {Number} progress
27
+ */
28
+ constructor(start, end, easing = EASING_FLAT, progress = 0) {
29
+ this.start = Rotation.normalizeValue(start);
30
+ this.distance = Rotation.diff(end, start);
31
+ this.easing = easing;
32
+ this.progress = progress;
33
+ }
34
+
35
+ get(progress = null) {
36
+ if (progress !== null) this.progress = progress;
37
+ return Rotation.normalizeValue(this.start + (this.easing(this.progress) * this.distance));
38
+ }
39
+
40
+ }
@@ -1,30 +1,30 @@
1
- export const EASING_FLAT = (x) => x;
2
- export const EASING_EXPONENTIAL_IN = (x, e = 2) => Math.pow(x, e);
3
- export const EASING_EXPONENTIAL_IN_OUT = (x, e = 2) => (x <= 0.5) ? Math.pow(x * 2, e) / 2 : 1 - Math.pow(2 - x * 2, e) / 2;
4
- export const EASING_QUAD_IN = EASING_EXPONENTIAL_IN;
5
- export const EASING_QUAD_IN_OUT = EASING_EXPONENTIAL_IN_OUT;
6
- export const EASING_CUBIC_IN = (x) => EASING_EXPONENTIAL_IN(x, 3);
7
- export const EASING_CUBIC_IN_OUT = (x) => EASING_EXPONENTIAL_IN_OUT(x, 3);
8
- export const EASING_SPHERE_IN = (v) => 1 - Math.sqrt(1 - Math.pow(v, 2));
9
- export const EASING_SPHERE_OUT = (v) => Math.sqrt(1 - Math.pow(1 - v, 2));
10
- export const EASING_SIN_OUT = (x) => Math.sin(x * Math.PI * 0.5)
11
-
12
- export default class ProgressValue {
13
- start;
14
- end;
15
- progress;
16
- easing;
17
-
18
- constructor(start, end, easing = EASING_FLAT, progress = 0) {
19
- this.start = Number(start);
20
- this.diff = Number(end) - this.start;
21
- this.easing = easing;
22
- this.progress = Number(progress);
23
- }
24
-
25
- get(progress = null) {
26
- if (progress !== null) this.progress = Number(progress);
27
- return this.start + (this.easing(this.progress) * this.diff);
28
- }
29
-
30
- }
1
+ export const EASING_FLAT = (x) => x;
2
+ export const EASING_EXPONENTIAL_IN = (x, e = 2) => Math.pow(x, e);
3
+ export const EASING_EXPONENTIAL_IN_OUT = (x, e = 2) => (x <= 0.5) ? Math.pow(x * 2, e) / 2 : 1 - Math.pow(2 - x * 2, e) / 2;
4
+ export const EASING_QUAD_IN = EASING_EXPONENTIAL_IN;
5
+ export const EASING_QUAD_IN_OUT = EASING_EXPONENTIAL_IN_OUT;
6
+ export const EASING_CUBIC_IN = (x) => EASING_EXPONENTIAL_IN(x, 3);
7
+ export const EASING_CUBIC_IN_OUT = (x) => EASING_EXPONENTIAL_IN_OUT(x, 3);
8
+ export const EASING_SPHERE_IN = (v) => 1 - Math.sqrt(1 - Math.pow(v, 2));
9
+ export const EASING_SPHERE_OUT = (v) => Math.sqrt(1 - Math.pow(1 - v, 2));
10
+ export const EASING_SIN_OUT = (x) => Math.sin(x * Math.PI * 0.5)
11
+
12
+ export default class ProgressValue {
13
+ start;
14
+ end;
15
+ progress;
16
+ easing;
17
+
18
+ constructor(start, end, easing = EASING_FLAT, progress = 0) {
19
+ this.start = Number(start);
20
+ this.diff = Number(end) - this.start;
21
+ this.easing = easing;
22
+ this.progress = Number(progress);
23
+ }
24
+
25
+ get(progress = null) {
26
+ if (progress !== null) this.progress = Number(progress);
27
+ return this.start + (this.easing(this.progress) * this.diff);
28
+ }
29
+
30
+ }
@@ -1,23 +1,23 @@
1
- import ProgressValue, {EASING_FLAT} from "./ProgressValue";
2
- import Vector2 from "../model/vector/Vector2";
3
-
4
- export default class ProgressVector2 {
5
- progressX;
6
- progressY;
7
-
8
- constructor(start, end, easing = EASING_FLAT, progress = 0) {
9
- this.progressX = new ProgressValue(start.x, end.x, easing, progress);
10
- this.progressY = new ProgressValue(start.y, end.y, easing, progress);
11
- }
12
-
13
- setProgress(progress) {
14
- this.progressX.progress = progress;
15
- this.progressY.progress = progress;
16
- }
17
-
18
- get(progress = null) {
19
- if (progress !== null) this.setProgress(progress);
20
- return new Vector2(this.progressX.get(), this.progressY.get());
21
- }
22
-
23
- }
1
+ import ProgressValue, {EASING_FLAT} from "./ProgressValue";
2
+ import Vector2 from "../model/vector/Vector2";
3
+
4
+ export default class ProgressVector2 {
5
+ progressX;
6
+ progressY;
7
+
8
+ constructor(start, end, easing = EASING_FLAT, progress = 0) {
9
+ this.progressX = new ProgressValue(start.x, end.x, easing, progress);
10
+ this.progressY = new ProgressValue(start.y, end.y, easing, progress);
11
+ }
12
+
13
+ setProgress(progress) {
14
+ this.progressX.progress = progress;
15
+ this.progressY.progress = progress;
16
+ }
17
+
18
+ get(progress = null) {
19
+ if (progress !== null) this.setProgress(progress);
20
+ return new Vector2(this.progressX.get(), this.progressY.get());
21
+ }
22
+
23
+ }
@@ -1,36 +1,36 @@
1
- import ObjectModel from "../model/ObjectModel";
2
- import StringValue from "../model/value/StringValue";
3
- import FloatValue from "../model/value/FloatValue";
4
- import BoolValue from "../model/value/BoolValue";
5
-
6
- export default class AudioModel extends ObjectModel {
7
-
8
- /**
9
- * @type StringValue
10
- */
11
- url;
12
-
13
- /**
14
- * @type FloatValue
15
- */
16
- volume;
17
-
18
- /**
19
- * @type BoolValue
20
- */
21
- playing;
22
-
23
- /**
24
- * @type BoolValue
25
- */
26
- loop;
27
-
28
- constructor(persistent = true) {
29
- super(persistent);
30
-
31
- this.url = this.addProperty('uri', new StringValue());
32
- this.volume = this.addProperty('volume', new FloatValue(1));
33
- this.playing = this.addProperty('audioOn', new BoolValue(true));
34
- this.loop = this.addProperty('loop', new BoolValue(false));
35
- }
36
- }
1
+ import ObjectModel from "../model/ObjectModel";
2
+ import StringValue from "../model/value/StringValue";
3
+ import FloatValue from "../model/value/FloatValue";
4
+ import BoolValue from "../model/value/BoolValue";
5
+
6
+ export default class AudioModel extends ObjectModel {
7
+
8
+ /**
9
+ * @type StringValue
10
+ */
11
+ url;
12
+
13
+ /**
14
+ * @type FloatValue
15
+ */
16
+ volume;
17
+
18
+ /**
19
+ * @type BoolValue
20
+ */
21
+ playing;
22
+
23
+ /**
24
+ * @type BoolValue
25
+ */
26
+ loop;
27
+
28
+ constructor(persistent = true) {
29
+ super(persistent);
30
+
31
+ this.url = this.addProperty('uri', new StringValue());
32
+ this.volume = this.addProperty('volume', new FloatValue(1));
33
+ this.playing = this.addProperty('audioOn', new BoolValue(true));
34
+ this.loop = this.addProperty('loop', new BoolValue(false));
35
+ }
36
+ }
@@ -1,120 +1,120 @@
1
- import RendererBase from "../renderer/RendererBase";
2
-
3
- const HAVE_ENOUGH_DATA = 4;
4
-
5
- export default class AudioRenderer extends RendererBase {
6
-
7
- /**
8
- * @type AudioModel
9
- */
10
- model;
11
-
12
- audio;
13
- audioContext;
14
- destination;
15
- source;
16
-
17
- constructor(game, model, audioContext, destination) {
18
- super(game, model);
19
-
20
- this.model = model;
21
- this.audioContext = audioContext;
22
- this.destination = destination;
23
-
24
- this.addAutoEvent(
25
- this.game.audio.paused,
26
- 'change',
27
- () => this.updatePlaying()
28
- );
29
- }
30
-
31
- activateInternal() {
32
- this.audio = new Audio();
33
- this.source = this.audioContext.createMediaElementSource(this.audio);
34
- this.source.connect(this.destination);
35
- this.updateAudio();
36
-
37
- this.audio.addEventListener('ended', () => {
38
- if (!this.model.loop.get()) {
39
- this.model.triggerEvent('remove-me', this.model);
40
- }
41
- });
42
-
43
- this.game.assets.getAsset(this.model.url.get(), (audio) => {
44
- if (!this.audio) {
45
- console.log('audio loaded after renderer was deactivated');
46
- return;
47
- }
48
-
49
- this.audio.addEventListener('canplaythrough', () => {
50
- this.updatePlaying();
51
- });
52
-
53
- this.audio.src = audio.src;
54
- });
55
- }
56
-
57
- deactivateInternal() {
58
- this.pause();
59
- this.source.disconnect();
60
- this.source = null;
61
- this.audio = null;
62
- }
63
-
64
- renderInternal() {
65
- if (this.model.loop.isDirty) {
66
- this.updateLoop();
67
- }
68
- if (this.model.volume.isDirty) {
69
- this.updateVolume();
70
- }
71
- if (this.model.playing.isDirty) {
72
- this.updatePlaying();
73
- }
74
- }
75
-
76
- updateAudio() {
77
- this.audio.autoplay = false;
78
- this.audio.muted = false;
79
- this.audio.controls = false;
80
- this.updateLoop();
81
- this.updateVolume();
82
- this.updatePlaying();
83
- }
84
-
85
- updatePlaying() {
86
- if (this.model.playing.get() && !this.game.audio.paused.get()) {
87
- this.play();
88
- } else {
89
- this.pause();
90
- }
91
- }
92
-
93
- updateLoop() {
94
- this.audio.loop = this.model.loop.get();
95
- }
96
-
97
- updateVolume() {
98
- this.audio.volume = this.model.volume.get();
99
- }
100
-
101
- rewind(time = 0) {
102
- this.audio.currentTime = time;
103
- }
104
-
105
- replay() {
106
- this.rewind();
107
- this.play();
108
- }
109
-
110
- play() {
111
- if (this.audio.readyState === HAVE_ENOUGH_DATA) {
112
- this.audio.play();
113
- }
114
- }
115
-
116
- pause() {
117
- this.audio.pause();
118
- }
119
-
120
- }
1
+ import RendererBase from "../renderer/RendererBase";
2
+
3
+ const HAVE_ENOUGH_DATA = 4;
4
+
5
+ export default class AudioRenderer extends RendererBase {
6
+
7
+ /**
8
+ * @type AudioModel
9
+ */
10
+ model;
11
+
12
+ audio;
13
+ audioContext;
14
+ destination;
15
+ source;
16
+
17
+ constructor(game, model, audioContext, destination) {
18
+ super(game, model);
19
+
20
+ this.model = model;
21
+ this.audioContext = audioContext;
22
+ this.destination = destination;
23
+
24
+ this.addAutoEvent(
25
+ this.game.audio.paused,
26
+ 'change',
27
+ () => this.updatePlaying()
28
+ );
29
+ }
30
+
31
+ activateInternal() {
32
+ this.audio = new Audio();
33
+ this.source = this.audioContext.createMediaElementSource(this.audio);
34
+ this.source.connect(this.destination);
35
+ this.updateAudio();
36
+
37
+ this.audio.addEventListener('ended', () => {
38
+ if (!this.model.loop.get()) {
39
+ this.model.triggerEvent('remove-me', this.model);
40
+ }
41
+ });
42
+
43
+ this.game.assets.getAsset(this.model.url.get(), (audio) => {
44
+ if (!this.audio) {
45
+ console.log('audio loaded after renderer was deactivated');
46
+ return;
47
+ }
48
+
49
+ this.audio.addEventListener('canplaythrough', () => {
50
+ this.updatePlaying();
51
+ });
52
+
53
+ this.audio.src = audio.src;
54
+ });
55
+ }
56
+
57
+ deactivateInternal() {
58
+ this.pause();
59
+ this.source.disconnect();
60
+ this.source = null;
61
+ this.audio = null;
62
+ }
63
+
64
+ renderInternal() {
65
+ if (this.model.loop.isDirty) {
66
+ this.updateLoop();
67
+ }
68
+ if (this.model.volume.isDirty) {
69
+ this.updateVolume();
70
+ }
71
+ if (this.model.playing.isDirty) {
72
+ this.updatePlaying();
73
+ }
74
+ }
75
+
76
+ updateAudio() {
77
+ this.audio.autoplay = false;
78
+ this.audio.muted = false;
79
+ this.audio.controls = false;
80
+ this.updateLoop();
81
+ this.updateVolume();
82
+ this.updatePlaying();
83
+ }
84
+
85
+ updatePlaying() {
86
+ if (this.model.playing.get() && !this.game.audio.paused.get()) {
87
+ this.play();
88
+ } else {
89
+ this.pause();
90
+ }
91
+ }
92
+
93
+ updateLoop() {
94
+ this.audio.loop = this.model.loop.get();
95
+ }
96
+
97
+ updateVolume() {
98
+ this.audio.volume = this.model.volume.get();
99
+ }
100
+
101
+ rewind(time = 0) {
102
+ this.audio.currentTime = time;
103
+ }
104
+
105
+ replay() {
106
+ this.rewind();
107
+ this.play();
108
+ }
109
+
110
+ play() {
111
+ if (this.audio.readyState === HAVE_ENOUGH_DATA) {
112
+ this.audio.play();
113
+ }
114
+ }
115
+
116
+ pause() {
117
+ this.audio.pause();
118
+ }
119
+
120
+ }