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,59 +1,59 @@
1
- export default class StringHelper {
2
-
3
- static shorten(text, length = 25, ellipsis = '...') {
4
- if (text === null || text === undefined || typeof text !== 'string') {
5
- return text;
6
- }
7
- if (text.length <= length) {
8
- return text;
9
- }
10
- let short = text.substring(0, length - ellipsis.length);
11
- short += ellipsis;
12
- return short;
13
- }
14
-
15
- static hash(value) {
16
- let hash = 0;
17
- if (value.length === 0) return hash;
18
- for (let i = 0; i < value.length; i++) {
19
- let ch = value.charCodeAt(i);
20
- hash = ((hash << 5) - hash) + ch;
21
- hash = hash & hash;
22
- }
23
- return hash;
24
- }
25
-
26
- static token(value) {
27
- let hash = StringHelper.hash(value);
28
- if (hash === 0) return null;
29
- let token = 'a';
30
- if (hash < 0) {
31
- token = 'b';
32
- hash = -hash;
33
- }
34
- return token + hash;
35
- }
36
-
37
- static paragraphize(text) {
38
- if ((!text) || typeof text !== 'string') return '';
39
- const arr = text.split(/(\<br\>|\<br\/\>|\n)/);
40
- const strings = arr.filter((t) => StringHelper.stripHtmlTags(t.trim()).length > 0);
41
- return strings.reduce((prev, current) => prev.concat(`<p>${current}</p>`), '');
42
- }
43
-
44
- static extractWord(str, pos = 0, sep = ' ') {
45
- const words = str.split(sep);
46
- if (words.length > pos) return words[pos];
47
- return null;
48
- }
49
-
50
- static extractId(str, pos = 1) {
51
- return StringHelper.extractWord(str, pos, '/');
52
- }
53
-
54
- static stripHtmlTags(text) {
55
- if ((!text) || typeof text !== 'string') return '';
56
- return text.replace(/(<([^>]+)>)/gi, '');
57
- }
58
-
59
- }
1
+ export default class StringHelper {
2
+
3
+ static shorten(text, length = 25, ellipsis = '...') {
4
+ if (text === null || text === undefined || typeof text !== 'string') {
5
+ return text;
6
+ }
7
+ if (text.length <= length) {
8
+ return text;
9
+ }
10
+ let short = text.substring(0, length - ellipsis.length);
11
+ short += ellipsis;
12
+ return short;
13
+ }
14
+
15
+ static hash(value) {
16
+ let hash = 0;
17
+ if (value.length === 0) return hash;
18
+ for (let i = 0; i < value.length; i++) {
19
+ let ch = value.charCodeAt(i);
20
+ hash = ((hash << 5) - hash) + ch;
21
+ hash = hash & hash;
22
+ }
23
+ return hash;
24
+ }
25
+
26
+ static token(value) {
27
+ let hash = StringHelper.hash(value);
28
+ if (hash === 0) return null;
29
+ let token = 'a';
30
+ if (hash < 0) {
31
+ token = 'b';
32
+ hash = -hash;
33
+ }
34
+ return token + hash;
35
+ }
36
+
37
+ static paragraphize(text) {
38
+ if ((!text) || typeof text !== 'string') return '';
39
+ const arr = text.split(/(\<br\>|\<br\/\>|\n)/);
40
+ const strings = arr.filter((t) => StringHelper.stripHtmlTags(t.trim()).length > 0);
41
+ return strings.reduce((prev, current) => prev.concat(`<p>${current}</p>`), '');
42
+ }
43
+
44
+ static extractWord(str, pos = 0, sep = ' ') {
45
+ const words = str.split(sep);
46
+ if (words.length > pos) return words[pos];
47
+ return null;
48
+ }
49
+
50
+ static extractId(str, pos = 1) {
51
+ return StringHelper.extractWord(str, pos, '/');
52
+ }
53
+
54
+ static stripHtmlTags(text) {
55
+ if ((!text) || typeof text !== 'string') return '';
56
+ return text.replace(/(<([^>]+)>)/gi, '');
57
+ }
58
+
59
+ }
@@ -1,99 +1,99 @@
1
- import NodeWithEvents from "./event/NodeWithEvents";
2
-
3
- export const EVENT_REMOVE_ME = 'remove-me';
4
-
5
- export const EVENT_DIRTY = 'dirty';
6
-
7
- export default class ModelBase extends NodeWithEvents {
8
-
9
- /**
10
- * @type boolean
11
- */
12
- isDirty;
13
-
14
- /**
15
- * @type boolean
16
- */
17
- isPersistent;
18
-
19
- constructor(persistent = true) {
20
- super();
21
- this.isPersistent = persistent;
22
- this.isDirty = true;
23
-
24
- this.propertyValueDirtyHandler = () => this.makeDirty();
25
- }
26
-
27
- restoreState(state) {
28
- this.restoreStateInternal(state);
29
- }
30
-
31
- /**
32
- * Override with node specific code
33
- * @param {object} state
34
- */
35
- restoreStateInternal(state) {
36
-
37
- }
38
-
39
- getState() {
40
- if (!this.isPersistent) {
41
- return undefined;
42
- }
43
-
44
- return this.getStateInternal();
45
- }
46
-
47
- /**
48
- * Override with node specific state
49
- * @returns {any}
50
- */
51
- getStateInternal() {
52
- return undefined;
53
- }
54
-
55
- makeDirty() {
56
- if (!this.isDirty) {
57
- this.isDirty = true;
58
- this.triggerEvent(EVENT_DIRTY);
59
- }
60
- }
61
-
62
- clean() {
63
- if (!this.isDirty) return false;
64
- this.isDirty = false;
65
- return true;
66
- }
67
-
68
- clone() {
69
- const n = new this.constructor();
70
- n.restoreState(this.getState());
71
- return n;
72
- }
73
-
74
- addOnDirtyListener(handler) {
75
- this.addEventListener(EVENT_DIRTY, handler);
76
- }
77
-
78
- removeOnDirtyListener(handler) {
79
- this.removeEventListener(EVENT_DIRTY, handler);
80
- }
81
-
82
- subscribeToOnDirtyEvent(node) {
83
- node.addOnDirtyListener(this.propertyValueDirtyHandler);
84
- return node;
85
- }
86
-
87
- unsubscribeFromOnDirtyEvent(node) {
88
- node.removeOnDirtyListener(this.propertyValueDirtyHandler);
89
- return node;
90
- }
91
-
92
- removeMyself() {
93
- this.triggerEvent(EVENT_REMOVE_ME, this);
94
- }
95
-
96
- equalsTo(ch) {
97
- return this === ch;
98
- }
99
- }
1
+ import NodeWithEvents from "./event/NodeWithEvents";
2
+
3
+ export const EVENT_REMOVE_ME = 'remove-me';
4
+
5
+ export const EVENT_DIRTY = 'dirty';
6
+
7
+ export default class ModelBase extends NodeWithEvents {
8
+
9
+ /**
10
+ * @type boolean
11
+ */
12
+ isDirty;
13
+
14
+ /**
15
+ * @type boolean
16
+ */
17
+ isPersistent;
18
+
19
+ constructor(persistent = true) {
20
+ super();
21
+ this.isPersistent = persistent;
22
+ this.isDirty = true;
23
+
24
+ this.propertyValueDirtyHandler = () => this.makeDirty();
25
+ }
26
+
27
+ restoreState(state) {
28
+ this.restoreStateInternal(state);
29
+ }
30
+
31
+ /**
32
+ * Override with node specific code
33
+ * @param {object} state
34
+ */
35
+ restoreStateInternal(state) {
36
+
37
+ }
38
+
39
+ getState() {
40
+ if (!this.isPersistent) {
41
+ return undefined;
42
+ }
43
+
44
+ return this.getStateInternal();
45
+ }
46
+
47
+ /**
48
+ * Override with node specific state
49
+ * @returns {any}
50
+ */
51
+ getStateInternal() {
52
+ return undefined;
53
+ }
54
+
55
+ makeDirty() {
56
+ if (!this.isDirty) {
57
+ this.isDirty = true;
58
+ this.triggerEvent(EVENT_DIRTY);
59
+ }
60
+ }
61
+
62
+ clean() {
63
+ if (!this.isDirty) return false;
64
+ this.isDirty = false;
65
+ return true;
66
+ }
67
+
68
+ clone() {
69
+ const n = new this.constructor();
70
+ n.restoreState(this.getState());
71
+ return n;
72
+ }
73
+
74
+ addOnDirtyListener(handler) {
75
+ this.addEventListener(EVENT_DIRTY, handler);
76
+ }
77
+
78
+ removeOnDirtyListener(handler) {
79
+ this.removeEventListener(EVENT_DIRTY, handler);
80
+ }
81
+
82
+ subscribeToOnDirtyEvent(node) {
83
+ node.addOnDirtyListener(this.propertyValueDirtyHandler);
84
+ return node;
85
+ }
86
+
87
+ unsubscribeFromOnDirtyEvent(node) {
88
+ node.removeOnDirtyListener(this.propertyValueDirtyHandler);
89
+ return node;
90
+ }
91
+
92
+ removeMyself() {
93
+ this.triggerEvent(EVENT_REMOVE_ME, this);
94
+ }
95
+
96
+ equalsTo(ch) {
97
+ return this === ch;
98
+ }
99
+ }
@@ -1,100 +1,100 @@
1
- import Dictionary from "../Dictionary";
2
- import ArrayHelper from "../helper/ArrayHelper";
3
- import ModelBase from "./ModelBase";
4
-
5
- export default class ObjectModel extends ModelBase {
6
-
7
- /**
8
- * @type Dictionary<DirtyValue>
9
- */
10
- properties;
11
-
12
- constructor(persistent = true) {
13
- super(persistent);
14
-
15
- this.properties = new Dictionary();
16
- this.properties.addEventListener('add', (e) => this.propertyAdded(e.key, e.value));
17
- this.properties.addEventListener('remove', (e) => this.propertyRemoved(e.key, e.old));
18
- this.properties.addEventListener('set', (e) => this.propertySet(e.key, e.old, e.value));
19
- }
20
-
21
- addProperty(name, property) {
22
- if (this.properties.exists(name)) {
23
- console.warn(`Property ${name} already set! Overriding.`);
24
- }
25
- return this.properties.add(name, property);
26
- }
27
-
28
- propertyAdded(name, property) {
29
- this.makeDirty();
30
- this.subscribeToOnDirtyEvent(property);
31
- }
32
-
33
- propertyRemoved(name, property) {
34
- this.makeDirty();
35
- this.unsubscribeFromOnDirtyEvent(property);
36
- }
37
-
38
- propertySet(name, oldProperty, newProperty) {
39
- this.propertyRemoved(name, oldProperty);
40
- this.propertyAdded(name, newProperty);
41
- }
42
-
43
- clean() {
44
- if (super.clean()) {
45
- this.properties.forEach((name, property) => property.clean());
46
- }
47
- }
48
-
49
- restoreState(state) {
50
- if (state === null || state === undefined || typeof state !== 'object') {
51
- return;
52
- }
53
- if (state.p) {
54
- this.properties.forEach((name, property) => property.restoreState(state.p[name]));
55
- }
56
- if (state.i !== undefined) {
57
- this.restoreStateInternal(state.i);
58
- }
59
- }
60
-
61
- getState() {
62
- if (!this.isPersistent) {
63
- return null;
64
- }
65
-
66
- const state = {};
67
-
68
- if (this.properties.count() > 0) {
69
- const properties = {};
70
- this.properties.forEach((name, propertyNode) =>
71
- properties[name] = propertyNode.getState()
72
- );
73
- state.p = properties;
74
- }
75
-
76
- const internal = this.getStateInternal();
77
- if (internal !== undefined) {
78
- state.i = internal;
79
- }
80
-
81
- return state;
82
- }
83
-
84
- getResourcesForPreload() {
85
- const result = this.getResourcesForPreloadInternal();
86
- this.properties.forEach(
87
- (name, child) => {
88
- if (typeof child.getResourcesForPreload === 'function') {
89
- result.push(...child.getResourcesForPreload());
90
- }
91
- }
92
- );
93
- return ArrayHelper.unique(result).filter((uri) => uri !== null && uri !== '');
94
- }
95
-
96
- getResourcesForPreloadInternal() {
97
- return [];
98
- }
99
-
100
- }
1
+ import Dictionary from "../Dictionary";
2
+ import ArrayHelper from "../helper/ArrayHelper";
3
+ import ModelBase from "./ModelBase";
4
+
5
+ export default class ObjectModel extends ModelBase {
6
+
7
+ /**
8
+ * @type Dictionary<DirtyValue>
9
+ */
10
+ properties;
11
+
12
+ constructor(persistent = true) {
13
+ super(persistent);
14
+
15
+ this.properties = new Dictionary();
16
+ this.properties.addEventListener('add', (e) => this.propertyAdded(e.key, e.value));
17
+ this.properties.addEventListener('remove', (e) => this.propertyRemoved(e.key, e.old));
18
+ this.properties.addEventListener('set', (e) => this.propertySet(e.key, e.old, e.value));
19
+ }
20
+
21
+ addProperty(name, property) {
22
+ if (this.properties.exists(name)) {
23
+ console.warn(`Property ${name} already set! Overriding.`);
24
+ }
25
+ return this.properties.add(name, property);
26
+ }
27
+
28
+ propertyAdded(name, property) {
29
+ this.makeDirty();
30
+ this.subscribeToOnDirtyEvent(property);
31
+ }
32
+
33
+ propertyRemoved(name, property) {
34
+ this.makeDirty();
35
+ this.unsubscribeFromOnDirtyEvent(property);
36
+ }
37
+
38
+ propertySet(name, oldProperty, newProperty) {
39
+ this.propertyRemoved(name, oldProperty);
40
+ this.propertyAdded(name, newProperty);
41
+ }
42
+
43
+ clean() {
44
+ if (super.clean()) {
45
+ this.properties.forEach((name, property) => property.clean());
46
+ }
47
+ }
48
+
49
+ restoreState(state) {
50
+ if (state === null || state === undefined || typeof state !== 'object') {
51
+ return;
52
+ }
53
+ if (state.p) {
54
+ this.properties.forEach((name, property) => property.restoreState(state.p[name]));
55
+ }
56
+ if (state.i !== undefined) {
57
+ this.restoreStateInternal(state.i);
58
+ }
59
+ }
60
+
61
+ getState() {
62
+ if (!this.isPersistent) {
63
+ return null;
64
+ }
65
+
66
+ const state = {};
67
+
68
+ if (this.properties.count() > 0) {
69
+ const properties = {};
70
+ this.properties.forEach((name, propertyNode) =>
71
+ properties[name] = propertyNode.getState()
72
+ );
73
+ state.p = properties;
74
+ }
75
+
76
+ const internal = this.getStateInternal();
77
+ if (internal !== undefined) {
78
+ state.i = internal;
79
+ }
80
+
81
+ return state;
82
+ }
83
+
84
+ getResourcesForPreload() {
85
+ const result = this.getResourcesForPreloadInternal();
86
+ this.properties.forEach(
87
+ (name, child) => {
88
+ if (typeof child.getResourcesForPreload === 'function') {
89
+ result.push(...child.getResourcesForPreload());
90
+ }
91
+ }
92
+ );
93
+ return ArrayHelper.unique(result).filter((uri) => uri !== null && uri !== '');
94
+ }
95
+
96
+ getResourcesForPreloadInternal() {
97
+ return [];
98
+ }
99
+
100
+ }