wgge 0.0.1

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 (107) hide show
  1. package/core/ActivatedTreeNode.js +187 -0
  2. package/core/Collection.js +156 -0
  3. package/core/Dictionary.js +83 -0
  4. package/core/animation/3d/AnimatedVector3.js +35 -0
  5. package/core/animation/3d/AnimationHelper.js +103 -0
  6. package/core/animation/3d/ProgressVector3.js +26 -0
  7. package/core/animation/AnimatedRotation.js +44 -0
  8. package/core/animation/AnimatedValue.js +33 -0
  9. package/core/animation/AnimatedVector2.js +35 -0
  10. package/core/animation/ProgressRotation.js +40 -0
  11. package/core/animation/ProgressValue.js +27 -0
  12. package/core/animation/ProgressVector2.js +23 -0
  13. package/core/audio/AudioModel.js +36 -0
  14. package/core/audio/AudioRenderer.js +120 -0
  15. package/core/audio/global/GlobalAudioModel.js +88 -0
  16. package/core/audio/global/GlobalAudioRenderer.js +108 -0
  17. package/core/controller/AnimationController.js +37 -0
  18. package/core/controller/AnimationFloatController.js +39 -0
  19. package/core/controller/AnimationVector2Controller.js +39 -0
  20. package/core/controller/CollectionController.js +47 -0
  21. package/core/controller/ConditionalNodeController.js +51 -0
  22. package/core/controller/ControllerBase.js +64 -0
  23. package/core/controller/ControllerWithSaveGame.js +27 -0
  24. package/core/controller/ControllerWithTimeout.js +10 -0
  25. package/core/controller/NullableNodeController.js +35 -0
  26. package/core/controller/TimeoutController.js +26 -0
  27. package/core/helper/ArrayHelper.js +19 -0
  28. package/core/helper/DOMHelper.js +167 -0
  29. package/core/helper/GUIHelper.js +53 -0
  30. package/core/helper/HttpHelper.js +33 -0
  31. package/core/helper/ImageHelper.js +36 -0
  32. package/core/helper/NumberHelper.js +28 -0
  33. package/core/helper/ObjectHelper.js +10 -0
  34. package/core/helper/StringHelper.js +59 -0
  35. package/core/model/ModelBase.js +91 -0
  36. package/core/model/ObjectModel.js +97 -0
  37. package/core/model/collection/ModelNodeCollection.js +232 -0
  38. package/core/model/collection/table/IdentifiedModelNode.js +24 -0
  39. package/core/model/collection/table/ModelNodeTable.js +53 -0
  40. package/core/model/event/ChangeEvent.js +24 -0
  41. package/core/model/event/EventManager.js +44 -0
  42. package/core/model/event/NodeWithEvents.js +32 -0
  43. package/core/model/template/TemplateNode.js +45 -0
  44. package/core/model/value/BoolValue.js +17 -0
  45. package/core/model/value/CapacityValue.js +49 -0
  46. package/core/model/value/DirtyValue.js +66 -0
  47. package/core/model/value/FloatValue.js +8 -0
  48. package/core/model/value/IntValue.js +20 -0
  49. package/core/model/value/NullableNode.js +66 -0
  50. package/core/model/value/StringValue.js +21 -0
  51. package/core/model/vector/Quaternion.js +82 -0
  52. package/core/model/vector/Rotation.js +61 -0
  53. package/core/model/vector/Vector2.js +177 -0
  54. package/core/model/vector/Vector3.js +98 -0
  55. package/core/renderer/RendererBase.js +46 -0
  56. package/core/renderer/canvas/CanvasRenderer.js +60 -0
  57. package/core/renderer/canvas/ImageToCanvasRenderer.js +94 -0
  58. package/core/renderer/dom/DirtyValueRenderer.js +36 -0
  59. package/core/renderer/dom/DomRenderer.js +32 -0
  60. package/core/renderer/dom/ImageRenderer.js +41 -0
  61. package/core/renderer/dom/Vector2Renderer.js +37 -0
  62. package/core/renderer/generic/CollectionRenderer.js +50 -0
  63. package/core/renderer/generic/ConditionalNodeRenderer.js +57 -0
  64. package/core/renderer/generic/NullableNodeRenderer.js +43 -0
  65. package/core/renderer/svg/SvgRenderer.js +130 -0
  66. package/editor/EditorController.js +135 -0
  67. package/editor/EditorModel.js +38 -0
  68. package/editor/EditorRenderer.js +116 -0
  69. package/editor/form/NodeFormRenderer.js +180 -0
  70. package/editor/material/MaterialPreviewRenderer.js +136 -0
  71. package/editor/table/TableRenderer.js +123 -0
  72. package/editor/table/lookup/TableLookupRenderer.js +120 -0
  73. package/editor/table/row/TableRowRenderer.js +97 -0
  74. package/game/GameController.js +144 -0
  75. package/game/GameModel.js +73 -0
  76. package/game/GameRenderer.js +108 -0
  77. package/game/controls/ControlsController.js +104 -0
  78. package/game/controls/ControlsModel.js +60 -0
  79. package/game/menu/MenuModel.js +25 -0
  80. package/game/menu/MenuRenderer.js +37 -0
  81. package/game/menu/item/MenuItemModel.js +31 -0
  82. package/game/menu/item/MenuItemRenderer.js +40 -0
  83. package/game/resources/3d/3DModel.js +30 -0
  84. package/game/resources/ResourcesModel.js +26 -0
  85. package/game/resources/assets/AssetCache.js +193 -0
  86. package/game/resources/assets/loader/AssetLoader.js +56 -0
  87. package/game/resources/assets/loader/AudioLoader.js +15 -0
  88. package/game/resources/assets/loader/GlbLoader.js +16 -0
  89. package/game/resources/assets/loader/ImageLoader.js +15 -0
  90. package/game/resources/assets/loader/MaterialLoader.js +49 -0
  91. package/game/resources/assets/loader/Model3dLoader.js +21 -0
  92. package/game/resources/assets/loader/SpriteLoader.js +40 -0
  93. package/game/resources/image/DualImageModel.js +34 -0
  94. package/game/resources/image/ImageModel.js +43 -0
  95. package/game/resources/material/MaterialModel.js +69 -0
  96. package/game/save/SaveGameController.js +21 -0
  97. package/game/save/SaveGameModel.js +5 -0
  98. package/game/save/SaveGameRenderer.js +17 -0
  99. package/game/save/editor/SaveGameEditorRenderer.js +17 -0
  100. package/index.html +42 -0
  101. package/index.js +73 -0
  102. package/package.json +35 -0
  103. package/style/basic/editor.less +290 -0
  104. package/style/basic/game.less +149 -0
  105. package/style/basic/utilities.less +215 -0
  106. package/style/style.less +3 -0
  107. package/webpack.config.js +29 -0
@@ -0,0 +1,40 @@
1
+ import DomRenderer from "../../../core/renderer/dom/DomRenderer";
2
+ import DirtyValueRenderer from "../../../core/renderer/dom/DirtyValueRenderer";
3
+
4
+ export default class MenuItemRenderer extends DomRenderer {
5
+
6
+ /**
7
+ * @type MenuItemModel
8
+ */
9
+ model;
10
+
11
+ constructor(game, model, dom) {
12
+ super(game, model, dom);
13
+
14
+ this.model = model;
15
+ }
16
+
17
+ activateInternal() {
18
+ this.container = this.addElement('h2', 'item');
19
+ this.container.addEventListener(
20
+ 'click',
21
+ (e) => {
22
+ e.preventDefault();
23
+ this.model.triggerEvent('click');
24
+ }
25
+ );
26
+ this.addChild(
27
+ new DirtyValueRenderer(
28
+ this.game,
29
+ this.model.text,
30
+ this.container
31
+ )
32
+ );
33
+ }
34
+
35
+ deactivateInternal() {
36
+ this.resetChildren();
37
+ this.removeElement(this.container);
38
+ }
39
+
40
+ }
@@ -0,0 +1,30 @@
1
+ import DirtyValue from "../../../core/model/value/DirtyValue";
2
+ import IdentifiedModelNode from "../../../core/model/collection/table/IdentifiedModelNode";
3
+ import Vector3 from "../../../core/model/vector/Vector3";
4
+
5
+ export default class Model3dModel extends IdentifiedModelNode {
6
+
7
+ /**
8
+ * @type DirtyValue
9
+ */
10
+ name;
11
+
12
+ /**
13
+ * @type DirtyValue
14
+ */
15
+ uri;
16
+
17
+ /**
18
+ * @type Vector3
19
+ */
20
+ scale;
21
+
22
+ constructor(id) {
23
+ super(id);
24
+
25
+ this.name = this.addProperty('name', new DirtyValue(`3D Model ${id}`));
26
+ this.uri = this.addProperty('uri', new DirtyValue('glb/races/male.glb'));
27
+ this.scale = this.addProperty('scale', new Vector3(1, 1, 1));
28
+ }
29
+
30
+ }
@@ -0,0 +1,26 @@
1
+ import ModelNodeTable from "../../core/model/collection/table/ModelNodeTable";
2
+ import MaterialModel from "./material/MaterialModel";
3
+ import ObjectModel from "../../core/model/ObjectModel";
4
+ import Model3dModel from "./3d/3DModel";
5
+
6
+ export default class ResourcesModel extends ObjectModel {
7
+
8
+ /**
9
+ * @type ModelNodeTable
10
+ */
11
+ materials;
12
+
13
+ /**
14
+ * @type ModelNodeTable<Model3dModel>
15
+ */
16
+ models3d;
17
+
18
+ constructor() {
19
+ super();
20
+
21
+ this.materials = this.addProperty('materials', new ModelNodeTable((id) => new MaterialModel(id)));
22
+ this.models3d = this.addProperty('models3d', new ModelNodeTable((id) => new Model3dModel(id)));
23
+
24
+ }
25
+
26
+ }
@@ -0,0 +1,193 @@
1
+ import Dictionary from "../../../core/Dictionary";
2
+ import Collection from "../../../core/Collection";
3
+ import NumberHelper from "../../../core/helper/NumberHelper";
4
+ import ImageLoader from "./loader/ImageLoader";
5
+ import GlbLoader from "./loader/GlbLoader";
6
+ import AudioLoader from "./loader/AudioLoader";
7
+ import MaterialLoader from "./loader/MaterialLoader";
8
+ import Model3dLoader from "./loader/Model3dLoader";
9
+ import SpriteLoader from "./loader/SpriteLoader";
10
+ import NodeWithEvents from "../../../core/model/event/NodeWithEvents";
11
+
12
+ const ASSET_TYPE_LOADERS = {
13
+ 'aud': AudioLoader,
14
+ 'img': ImageLoader,
15
+ 'glb': GlbLoader,
16
+ 'mat': MaterialLoader,
17
+ 'm3d': Model3dLoader,
18
+ 'spr': SpriteLoader
19
+ }
20
+
21
+ /**
22
+ * Keeps cached raw resources like images, sounds and 3D models
23
+ */
24
+ export default class AssetCache extends NodeWithEvents {
25
+
26
+ /**
27
+ * @type ResourcesModel
28
+ */
29
+ resources;
30
+
31
+ /**
32
+ * @type Dictionary
33
+ */
34
+ cache;
35
+
36
+ /**
37
+ * @type Collection
38
+ */
39
+ loaders;
40
+
41
+ /**
42
+ * @type int
43
+ */
44
+ totalLoaders = 0;
45
+
46
+ /**
47
+ * @type int
48
+ */
49
+ blockingLoaders = 0;
50
+
51
+ /**
52
+ * @type int
53
+ */
54
+ sessionTotalLoaders = 0;
55
+
56
+ /**
57
+ * @type int
58
+ */
59
+ sessionFinishedLoaders = 0;
60
+
61
+ constructor(resources) {
62
+ super();
63
+ this.resources = resources;
64
+ this.cache = new Dictionary();
65
+ this.loaders = new Collection();
66
+ this.loaders.addOnAddListener((loader) => this.loaderAdded(loader));
67
+ this.loaders.addOnRemoveListener((loader) => this.loaderRemoved(loader));
68
+
69
+ }
70
+
71
+ loaderAdded(loader) {
72
+ this.updateLoadingState();
73
+ if (!loader.isPreloading) {
74
+ this.sessionTotalLoaders++;
75
+ this.triggerEvent('session-total-loaders-changed', this.sessionTotalLoaders);
76
+ }
77
+
78
+ }
79
+
80
+ loaderRemoved(loader) {
81
+ this.updateLoadingState();
82
+ if (!loader.isPreloading) {
83
+ this.sessionFinishedLoaders++;
84
+ if (this.blockingLoaders === 0) {
85
+ this.sessionFinishedLoaders = 0;
86
+ this.sessionTotalLoaders = 0;
87
+ }
88
+ this.triggerEvent('session-finished-loaders-changed', this.sessionFinishedLoaders);
89
+ }
90
+ }
91
+
92
+ updateLoadingState() {
93
+ const total = this.loaders.count();
94
+ if (this.totalLoaders !== total) {
95
+ this.totalLoaders = total;
96
+ this.triggerEvent('total-loaders-changed', total);
97
+ }
98
+ const blocking = this.loaders.filter((l) => l.isPreloading === false).length;
99
+ if (this.blockingLoaders !== blocking) {
100
+ this.blockingLoaders = blocking;
101
+ this.triggerEvent('blocking-loaders-changed', blocking);
102
+ }
103
+ }
104
+
105
+ resetCache(name = null) {
106
+ if (name) {
107
+ this.cache.remove(name);
108
+ } else {
109
+ this.cache.reset();
110
+ }
111
+ }
112
+
113
+ loaderFailed(loader, msg, onError) {
114
+ console.error(`Loading of asset '${loader.uri}' failed: ${msg}`);
115
+
116
+ if (onError) onError(msg);
117
+
118
+ this.loaders.remove(loader);
119
+ }
120
+
121
+ loaderSucceeded(loader, resource, onLoaded) {
122
+ if (this.cache.exists(loader.uri)) {
123
+ this.cache.set(loader.uri, resource);
124
+ console.warn(`Resource ${loader.uri} was already present then loaded and replaced.`);
125
+ } else {
126
+ this.cache.add(loader.uri, resource);
127
+ }
128
+
129
+ if (onLoaded) onLoaded(resource);
130
+
131
+ this.loaders.remove(loader);
132
+ }
133
+
134
+ getAsset(uri, onLoaded = null, onError = null) {
135
+ if (typeof uri !== 'string') {
136
+ console.log('uri is not a string', uri);
137
+ return;
138
+ }
139
+
140
+ if (this.cache.exists(uri)) {
141
+ if (onLoaded) {
142
+ onLoaded(this.cache.get(uri));
143
+ }
144
+ } else {
145
+ const existingLoader = this.loaders.find((l) => l.uri === uri);
146
+ if (existingLoader) {
147
+ if (onLoaded || onError) {
148
+ existingLoader.addLoaderEventsListeners(onLoaded, onError);
149
+ }
150
+ return;
151
+ }
152
+
153
+ const assetType = NumberHelper.extractId(uri, 0);
154
+ if (ASSET_TYPE_LOADERS[assetType] === undefined) {
155
+ console.error(`Valid resource type could not be inferred from URI '${uri}'!`);
156
+ }
157
+
158
+ const loaderType = ASSET_TYPE_LOADERS[assetType];
159
+ const loader = new loaderType(this, uri, onLoaded === null);
160
+ this.loaders.add(loader);
161
+ loader.load(
162
+ (resource) => this.loaderSucceeded(loader, resource, onLoaded),
163
+ (msg) => this.loaderFailed(loader, msg, onError)
164
+ );
165
+ }
166
+ }
167
+
168
+ loadMaterial(materialId, onLoaded) {
169
+ this.getAsset(`mat/${materialId}`, onLoaded);
170
+ }
171
+
172
+ resetMaterial(materialId) {
173
+ this.resetCache(`mat/${materialId}`);
174
+ }
175
+
176
+ loadModel3d(modelId, onLoaded) {
177
+ this.getAsset(`m3d/${modelId}`, onLoaded);
178
+ }
179
+
180
+ loadSprite(spriteId, onLoaded) {
181
+ this.getAsset(`spr/${spriteId}`, onLoaded);
182
+ }
183
+
184
+ preload(resources) {
185
+ console.log('Preloading:', resources);
186
+ resources.forEach((r) => this.getAsset(r));
187
+ }
188
+
189
+ load(resources) {
190
+ console.log('Loading:', resources);
191
+ resources.forEach((r) => this.getAsset(r, () => undefined));
192
+ }
193
+ }
@@ -0,0 +1,56 @@
1
+ import NodeWithEvents from "../../../../core/model/event/NodeWithEvents";
2
+
3
+ /**
4
+ * Loads a single raw resource.
5
+ */
6
+ export default class AssetLoader extends NodeWithEvents {
7
+
8
+ uri;
9
+
10
+ /**
11
+ * @type AssetCache
12
+ */
13
+ assets;
14
+
15
+ constructor(assets, uri, preload = false) {
16
+ super();
17
+ this.assets = assets;
18
+ this.uri = uri;
19
+ this.isPreloading = preload;
20
+ }
21
+
22
+ load(onLoaded, onError = null) {
23
+ this.addLoaderEventsListeners(onLoaded, onError);
24
+ this.loadInternal();
25
+ }
26
+
27
+ /**
28
+ * Override this and then call this.finish(result) or this.fail(msg)
29
+ */
30
+ loadInternal() {
31
+ // do something
32
+ this.fail('No loadInternal method override!');
33
+ }
34
+
35
+ finish(result) {
36
+ this.triggerEvent('load', result);
37
+ }
38
+
39
+ fail(msg) {
40
+ this.triggerEvent('error', msg);
41
+ }
42
+
43
+ addLoaderEventsListeners(onLoaded = null, onError = null) {
44
+ if (onLoaded) this.addEventListener('load', onLoaded);
45
+ if (onError) this.addEventListener('error', onError);
46
+ }
47
+
48
+ url() {
49
+ return AssetLoader.urlFromUri(this.uri);
50
+ }
51
+
52
+ static urlFromUri(uri) {
53
+ return 'assets/' + uri;
54
+ }
55
+
56
+ }
@@ -0,0 +1,15 @@
1
+ import AssetLoader from "./AssetLoader";
2
+
3
+ /**
4
+ * Loads a single audio file (Audio object)
5
+ */
6
+ export default class AudioLoader extends AssetLoader {
7
+
8
+ loadInternal() {
9
+ const audio = new Audio();
10
+ audio.addEventListener('canplaythrough', () => this.finish(audio));
11
+ audio.onerror = (msg) => this.fail(msg);
12
+ audio.src = this.url();
13
+ }
14
+
15
+ }
@@ -0,0 +1,16 @@
1
+ import AssetLoader from "./AssetLoader";
2
+ import {GLTFLoader} from "three/examples/jsm/loaders/GLTFLoader";
3
+
4
+ export default class GlbLoader extends AssetLoader {
5
+
6
+ loadInternal() {
7
+ const loader = new GLTFLoader();
8
+ loader.load(
9
+ this.url(),
10
+ (gltf) => this.finish(gltf),
11
+ null,
12
+ (err) => this.fail(`Glb '${this.url()}' not loaded: ${err}`)
13
+ );
14
+ }
15
+
16
+ }
@@ -0,0 +1,15 @@
1
+ import AssetLoader from "./AssetLoader";
2
+
3
+ /**
4
+ * Loads a single Image
5
+ */
6
+ export default class ImageLoader extends AssetLoader {
7
+
8
+ loadInternal() {
9
+ const image = new Image();
10
+ image.onload = () => this.finish(image);
11
+ image.onerror = (msg) => this.fail(msg);
12
+ image.src = this.url();
13
+ }
14
+
15
+ }
@@ -0,0 +1,49 @@
1
+ import * as THREE from "three";
2
+ import AssetLoader from "./AssetLoader";
3
+ import NumberHelper from "../../../../core/helper/NumberHelper";
4
+
5
+ /**
6
+ * Loads a single THREE material.
7
+ */
8
+ export default class MaterialLoader extends AssetLoader {
9
+
10
+ loadInternal() {
11
+
12
+ const id = NumberHelper.extractId(this.uri);
13
+ const definition = this.assets.resources.materials.getById(id);
14
+ if (!definition) {
15
+ this.fail(`material ID ${this.uri} not found`);
16
+ return;
17
+ }
18
+
19
+ const params = {
20
+ color: definition.color.get()
21
+ };
22
+
23
+ if (definition.useTexture.get()) {
24
+ this.assets.getAsset(
25
+ definition.uri.get(),
26
+ (img) => {
27
+ const texture = new THREE.Texture();
28
+ texture.image = img;
29
+ texture.needsUpdate = true;
30
+ texture.wrapS = definition.wrapS.get();
31
+ texture.wrapT = definition.wrapT.get();
32
+ texture.repeat.set(
33
+ definition.repeatX.get(),
34
+ definition.repeatY.get()
35
+ );
36
+ params.map = texture;
37
+ this.finish(this.createMaterial(definition.threeType.get(), params));
38
+ }
39
+ );
40
+ } else {
41
+ this.finish(this.createMaterial(definition.threeType.get(), params));
42
+ }
43
+ }
44
+
45
+ createMaterial(threeType, params) {
46
+ return new THREE[threeType](params);
47
+ }
48
+
49
+ }
@@ -0,0 +1,21 @@
1
+ import AssetLoader from "./AssetLoader";
2
+ import NumberHelper from "../../../../core/helper/NumberHelper";
3
+
4
+ /**
5
+ * Loads a 3d model
6
+ */
7
+ export default class Model3dLoader extends AssetLoader {
8
+
9
+ loadInternal() {
10
+
11
+ const id = NumberHelper.extractId(this.uri);
12
+ const model = this.assets.resources.models3d.getById(id);
13
+
14
+ this.assets.getAsset(model.uri.get(), (gltf) => {
15
+ const mesh = gltf.scene.clone();
16
+ mesh.scale.set(model.scale.x, model.scale.y, model.scale.z);
17
+ this.finish(mesh);
18
+ });
19
+ }
20
+
21
+ }
@@ -0,0 +1,40 @@
1
+ import * as THREE from "three";
2
+ import AssetLoader from "./AssetLoader";
3
+ import NumberHelper from "../../../../core/helper/NumberHelper";
4
+
5
+ /**
6
+ * Loads a single Sprite
7
+ */
8
+ export default class SpriteLoader extends AssetLoader {
9
+
10
+ loadInternal() {
11
+
12
+ const spriteId = NumberHelper.extractId(this.uri);
13
+ const sprite = this.assets.resources.sprites.getById(spriteId);
14
+
15
+ if (!sprite) {
16
+ this.fail(`Sprite ${spriteId} not found!`);
17
+ return;
18
+ }
19
+
20
+ this.assets.getAsset(sprite.uri.get(), (img) => {
21
+ const texture = new THREE.Texture();
22
+ texture.image = img;
23
+ texture.needsUpdate = true;
24
+ texture.wrapS = THREE.RepeatWrapping;
25
+ texture.wrapT = THREE.RepeatWrapping;
26
+ texture.repeat.set(1, 1);
27
+ const mesh = new THREE.Mesh(new THREE.PlaneGeometry(sprite.size.x, sprite.size.y), new THREE.MeshBasicMaterial({
28
+ transparent: true,
29
+ map: texture
30
+ }));
31
+ //const mesh = new THREE.Sprite(new THREE.SpriteMaterial({map: texture}));
32
+ mesh.position.set(sprite.coordinates.x, sprite.coordinates.y, sprite.coordinates.z);
33
+ const target = mesh.position.clone().add(new THREE.Vector3(-1, 1, -1));
34
+ mesh.lookAt(target.x, target.y, target.z);
35
+ this.finish(mesh);
36
+ });
37
+
38
+ }
39
+
40
+ }
@@ -0,0 +1,34 @@
1
+ import ModelNodeCollection from "../../../core/model/collection/ModelNodeCollection";
2
+ import ImageModel from "./ImageModel";
3
+ import Vector2 from "../../../core/model/vector/Vector2";
4
+
5
+ export default class DualImageModel extends ModelNodeCollection {
6
+
7
+ /**
8
+ * @type ImageModel
9
+ */
10
+ imageA;
11
+
12
+ /**
13
+ * @type ImageModel
14
+ */
15
+ imageB;
16
+
17
+ /**
18
+ * @type Vector2
19
+ */
20
+ size;
21
+
22
+ constructor(persistent) {
23
+ super(null, persistent);
24
+
25
+ this.imageA = this.addProperty('imageA', new ImageModel());
26
+ this.imageB = this.addProperty('imageB', new ImageModel());
27
+ this.size = this.addProperty('size', new Vector2());
28
+
29
+ this.add(this.imageA);
30
+ this.add(this.imageB);
31
+
32
+ }
33
+
34
+ }
@@ -0,0 +1,43 @@
1
+ import ObjectModel from "../../../core/model/ObjectModel";
2
+ import StringValue from "../../../core/model/value/StringValue";
3
+ import FloatValue from "../../../core/model/value/FloatValue";
4
+ import Vector2 from "../../../core/model/vector/Vector2";
5
+
6
+ export default class ImageModel extends ObjectModel {
7
+
8
+ /**
9
+ * @type StringValue
10
+ */
11
+ uri;
12
+
13
+ /**
14
+ * @type FloatValue
15
+ */
16
+ opacity;
17
+
18
+ /**
19
+ * @type Vector2
20
+ */
21
+ coordinates;
22
+
23
+ /**
24
+ * @type FloatValue
25
+ */
26
+ zoom;
27
+
28
+ /**
29
+ * @type Vector2
30
+ */
31
+ size;
32
+
33
+ constructor(persistent = true) {
34
+ super(persistent);
35
+
36
+ this.uri = this.addProperty('uri', new StringValue());
37
+ this.opacity = this.addProperty('opacity', new FloatValue());
38
+ this.coordinates = this.addProperty('coordinates', new Vector2());
39
+ this.size = this.addProperty('size', new Vector2());
40
+ this.zoom = this.addProperty('startZoom', new FloatValue(1));
41
+ }
42
+
43
+ }
@@ -0,0 +1,69 @@
1
+ import DirtyValue from "../../../core/model/value/DirtyValue";
2
+ import IdentifiedModelNode from "../../../core/model/collection/table/IdentifiedModelNode";
3
+ import * as THREE from "three";
4
+ import BoolValue from "../../../core/model/value/BoolValue";
5
+ import IntValue from "../../../core/model/value/IntValue";
6
+
7
+ export default class MaterialModel extends IdentifiedModelNode {
8
+
9
+ /**
10
+ * @type DirtyValue
11
+ */
12
+ name;
13
+
14
+ /**
15
+ * @type DirtyValue
16
+ */
17
+ threeType;
18
+
19
+ /**
20
+ * @type DirtyValue
21
+ */
22
+ color;
23
+
24
+ /**
25
+ * @type BoolValue
26
+ */
27
+ useTexture;
28
+
29
+ /**
30
+ * @type DirtyValue
31
+ */
32
+ uri;
33
+
34
+ /**
35
+ * @type IntValue
36
+ */
37
+ wrapS;
38
+
39
+ /**
40
+ * @type IntValue
41
+ */
42
+ wrapT;
43
+
44
+ /**
45
+ * @type IntValue
46
+ */
47
+ repeatX;
48
+
49
+ /**
50
+ * @type IntValue
51
+ */
52
+ repeatY;
53
+
54
+ constructor(id) {
55
+ super(id);
56
+
57
+ this.name = this.addProperty('name', new DirtyValue(`Material ${id}`));
58
+ this.threeType = this.addProperty('threeType', new DirtyValue('MeshBasicMaterial'));
59
+ this.color = this.addProperty('color', new DirtyValue('#700000'));
60
+
61
+ this.useTexture = this.addProperty('useTexture', new BoolValue(true));
62
+ this.uri = this.addProperty('uri', new DirtyValue('img/texture/dirt.png'));
63
+ this.wrapS = this.addProperty('wrapS', new IntValue(THREE.RepeatWrapping));
64
+ this.wrapT = this.addProperty('wrapT', new IntValue(THREE.RepeatWrapping));
65
+ this.repeatX = this.addProperty('repeatX', new IntValue(2));
66
+ this.repeatY = this.addProperty('repeatY', new IntValue(2));
67
+ }
68
+
69
+ }
@@ -0,0 +1,21 @@
1
+ import ControllerBase from "../../core/controller/ControllerBase";
2
+
3
+ export default class SaveGameController extends ControllerBase {
4
+
5
+ /**
6
+ * @type SaveGameModel
7
+ */
8
+ model;
9
+
10
+ constructor(game, model) {
11
+ super(game, model);
12
+
13
+ this.model = model;
14
+ }
15
+
16
+ update(delta) {
17
+ if (this.game.menu.isSet()) return;
18
+ super.update(delta);
19
+ }
20
+
21
+ }
@@ -0,0 +1,5 @@
1
+ import ObjectModel from "../../core/model/ObjectModel";
2
+
3
+ export default class SaveGameModel extends ObjectModel {
4
+
5
+ }