@woosh/meep-engine 2.50.1 → 2.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -0
- package/editor/Editor.js +5 -1
- package/editor/SelectionVisualizer.js +9 -3
- package/editor/tools/paint/TerrainTexturePaintTool.js +6 -1
- package/editor/view/EditorView.js +5 -1
- package/editor/view/ecs/EntityList.js +48 -37
- package/editor/view/makeEntityDecorators.js +125 -0
- package/package.json +7 -3
- package/samples/generation/README.md +6 -0
- package/{src/generation/example → samples/generation}/SampleGenerator0.js +60 -46
- package/{src/generation/example → samples/generation}/filters/SampleGroundMoistureFilter.js +14 -12
- package/samples/generation/filters/SampleNoise20_0.js +3 -0
- package/{src/generation/example → samples/generation}/generators/interactive/mir_generator_place_buff_objects.js +29 -23
- package/{src/generation/example → samples/generation}/generators/mir_generator_place_bases.js +33 -25
- package/{src/generation/example → samples/generation}/generators/mir_generator_place_road_decorators.js +16 -14
- package/samples/generation/generators/mir_generator_place_starting_point.js +60 -0
- package/{src/generation/example → samples/generation}/grid/configureMirGrid.js +2 -2
- package/{src/generation/example → samples/generation}/main.js +29 -28
- package/{src/generation/example → samples/generation}/rules/matcher_not_play_area.js +1 -1
- package/samples/generation/rules/matcher_play_area.js +5 -0
- package/{src/generation/example → samples/generation}/rules/matcher_tag_not_traversable.js +1 -1
- package/samples/generation/rules/matcher_tag_occupied.js +5 -0
- package/samples/generation/rules/matcher_tag_traversable.js +5 -0
- package/{src/generation/example → samples/generation}/rules/matcher_tag_traversable_unoccupied.js +1 -1
- package/{src/generation/example → samples/generation}/rules/matcher_tag_unoccupied.js +1 -1
- package/{src/generation/example → samples/generation}/rules/mir_matcher_attack_corridor.js +3 -3
- package/{src/generation/example → samples/generation}/themes/SampleTheme0.js +57 -47
- package/{src/generation/example → samples/generation}/themes/SampleTheme1.js +4 -4
- package/{src/generation/example → samples/generation}/themes/SampleTheme2.js +4 -4
- package/src/engine/ecs/{Blueprint.js → storage/json/Blueprint.js} +1 -1
- package/src/engine/ecs/{EntityFactory.js → storage/json/EntityFactory.js} +1 -1
- package/src/engine/ecs/storage/{JSONDeSerializer.js → json/JSONDeSerializer.js} +4 -4
- package/src/engine/ecs/storage/json/README.md +5 -0
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.spec.js +5 -0
- package/src/engine/intelligence/behavior/Behavior.d.ts +5 -0
- package/src/engine/intelligence/behavior/Behavior.js +19 -0
- package/src/engine/intelligence/behavior/SelectorBehavior.js +4 -2
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +2 -0
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +3 -1
- package/src/engine/intelligence/behavior/decorator/AbstractDecoratorBehavior.js +2 -3
- package/src/engine/intelligence/behavior/decorator/RepeatBehavior.js +2 -2
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +2 -2
- package/src/view/common/VirtualListView.js +2 -0
- package/src/generation/example/filters/SampleNoise20_0.js +0 -3
- package/src/generation/example/generators/mir_generator_place_starting_point.js +0 -52
- package/src/generation/example/rules/matcher_play_area.js +0 -5
- package/src/generation/example/rules/matcher_tag_occupied.js +0 -5
- package/src/generation/example/rules/matcher_tag_traversable.js +0 -5
- /package/{src/generation/example → samples/generation}/grid/MirGridLayers.js +0 -0
- /package/src/engine/ecs/storage/{JSONSerializer.js → json/JSONSerializer.js} +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Meep Engine
|
|
2
|
+
|
|
3
|
+
## Template Project
|
|
4
|
+
|
|
5
|
+
Minimal project with no bells or whistles, just enough to run the engine and get you starter. If you're starting from scratch this is likely the best option.
|
|
6
|
+
|
|
7
|
+
[GitLab Repository](http://gitlab.company-named.com/travnik/dream-engine-template)
|
|
8
|
+
|
|
9
|
+
## Samples
|
|
10
|
+
To help get you started, various samples are provided under `/samples` folder. Feel free to use them as a point of reference.
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
[Engine Documentation](http://meep-engine.company-named.com:8080/docs/api/)
|
|
15
|
+
|
|
16
|
+
## Features, for more information, please refer to the documentation
|
|
17
|
+
* Automatic instancing. This will minimize the number of draw calls and improve performance.
|
|
18
|
+
* Decals. Decals in meep are done on the GPU, and as a result you can have a lot of them in your scene. The most I tested in a single scene is 1,000,000 which works quite well. Decals are useful for bullet holes, blood splatter and various scene decorations such as signs and scuff marks.
|
|
19
|
+
* Deferred lights. Meep implements clustered lighting technique which allows you to have a pretty much an unlimited number of point lights in your scene. All the other light types are supported as well, but only point lights are clustered for now. Point lights are useful for various effects, like muzzle flashes, grenade explosions, torches, etc.
|
|
20
|
+
* Particle engine. Meep's particle engine ("Particular") is optimized for game development needs, this means supporting complex effects and being able to spawn/destroy many particle systems every frame. There are a lot of particle engines out there, but they tend to have costly spawning routines, take up a lot of draw calls and not manage memory well, which leads to pretty poor performance in games. My particle engine supports full particle lighting as well, and soft particles. On top of that - all particles are automatically atlassed in the background and are compiled with just 4 shaders. This means that no matter how many particle effects you have - there will be no shader switching and no texture switching, and there will be no delays associated with shader compilation. Particles are culled, so particle systems that are off-screen are not rendered and simulation for them can be paused to save CPU resources (this is automatic behavior)
|
|
21
|
+
* Sound engine. Meep has a custom sound engine which is culled and has custom attenuation, this allows scenes to have 1000s of positional audio sources without any extra cost in terms of performance
|
|
22
|
+
* Asset streaming. Meep in general is a web-first engine, all assets are streamed, meaning that the engine is up and running even before any models/texture are loaded, and you're free to decide when to let the player see your level, wait until everything is loaded or drop them in as soon as you can. There is a pre-loader module in case you want to load some assets in bulk before starting the game.
|
|
23
|
+
* Terrain engine. The terrain engine is chunk-based, which means that terrain is split into rectangular pieces internally, and they are built on-the-fly inside a web-worker based on camera position. Terrain is automatically culled based on camera position, so you're only drawing the chunks that are in view. Terrain supports layers just like Unity, but unlike Unity - Meep supports up to 256 layers of terrain instead of 4.
|
|
24
|
+
* AI tools, including
|
|
25
|
+
* full-fledged Behavior trees
|
|
26
|
+
* Blackboard (took for recording information useful for AI to read/write relevant world state, very commonly used with Behavior Trees)
|
|
27
|
+
* monte-carlo tree search (same as Google's AlphaGo, useful for decision-making)
|
|
28
|
+
* state optimization (useful for decision-making)
|
|
29
|
+
* grid-based path finding (optimized for 10,000s of queries per second)
|
|
30
|
+
* resource allocation solver (useful for planning, given certain resources such as bullets/grenades/money/health - plan what actions to take to optimize your chances of winning)
|
|
31
|
+
* and a number of other useful tools to complement AI development.
|
|
32
|
+
* Inverse kinematics. Meep has 2 very useful IK solvers to fix foot position for characters on uneven terrain or stairs, aligning both the position and orientation of character feet. This works for hands as well if you want and is not limited to bipeds, the system works just as well for, say, spiders.
|
|
33
|
+
* Extremely compact serialization system. You can save/load your scenes from files. This serialization system supports format changes, so as you develop your game - old saves will be supported and the system will automatically upgrade them to the most recent version, so the player doesn't have to lose any data.
|
|
34
|
+
* Achievements. Achievements work with Blackboard components and are very easy to define. There is an abstraction system that helps connect your achievements to various platforms such as Steam or XBox (you'd have to implement that binding yourself though), by default it comes with a browser backend, storing data in IndexedDB. I also have bindings for Steam and NewGrounds that I can share.
|
|
35
|
+
* UI system. You're free to use it or not, the engine works just fine without it. The system is written for speed, and it offers a few commonly used tools, such as popup windows, notifications and pages. The UI system is optimized for speed, so it generates no garbage, but again - if you want to use, say React - you can ignore this system or integrate it with the system.
|
|
36
|
+
* Trails. Meep implements a fairly complex trail system, where a trail can be attached to an entity, and it will create a trail behind.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
Copyright © 2023 Company Named Limited, All Rights Reserved
|
package/editor/Editor.js
CHANGED
|
@@ -696,7 +696,11 @@ Editor.prototype.attach = async function (engine) {
|
|
|
696
696
|
|
|
697
697
|
this.processEngine.startup();
|
|
698
698
|
|
|
699
|
-
|
|
699
|
+
try {
|
|
700
|
+
this.selectionVistualizer.startup();
|
|
701
|
+
} catch (e) {
|
|
702
|
+
console.error("Failed to start selection visualizer:", e);
|
|
703
|
+
}
|
|
700
704
|
|
|
701
705
|
//attach view
|
|
702
706
|
engine.viewStack.push(this.view, "Editor");
|
|
@@ -2,6 +2,7 @@ import { BoxHelper, Group } from 'three';
|
|
|
2
2
|
import Mesh from "../src/engine/graphics/ecs/mesh/Mesh.js";
|
|
3
3
|
import { SignalBinding } from "../src/core/events/signal/SignalBinding.js";
|
|
4
4
|
import { MeshEvents } from "../src/engine/graphics/ecs/mesh/MeshEvents.js";
|
|
5
|
+
import { assert } from "../src/core/assert.js";
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -11,6 +12,9 @@ import { MeshEvents } from "../src/engine/graphics/ecs/mesh/MeshEvents.js";
|
|
|
11
12
|
* @constructor
|
|
12
13
|
*/
|
|
13
14
|
function SelectionContainer(entity, entityManager) {
|
|
15
|
+
assert.defined(entityManager, 'entityManager');
|
|
16
|
+
assert.isNonNegativeInteger(entity, 'entity');
|
|
17
|
+
|
|
14
18
|
this.entity = entity;
|
|
15
19
|
this.entityManager = entityManager;
|
|
16
20
|
|
|
@@ -25,7 +29,7 @@ function SelectionContainer(entity, entityManager) {
|
|
|
25
29
|
const self = this;
|
|
26
30
|
|
|
27
31
|
function updateMesh() {
|
|
28
|
-
const mesh = entityManager.getComponent(entity, Mesh);
|
|
32
|
+
const mesh = entityManager.dataset.getComponent(entity, Mesh);
|
|
29
33
|
|
|
30
34
|
if (mesh !== null && mesh !== undefined && mesh.hasMesh()) {
|
|
31
35
|
boxHelper.setFromObject(mesh.mesh);
|
|
@@ -59,13 +63,15 @@ SelectionContainer.prototype.link = function () {
|
|
|
59
63
|
this.isLinked = true;
|
|
60
64
|
this.handlers.animationLoop();
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
const ecd = this.entityManager.dataset;
|
|
67
|
+
ecd.addEntityEventListener(this.entity, MeshEvents.DataSet, this.handlers.updateMesh);
|
|
63
68
|
};
|
|
64
69
|
|
|
65
70
|
SelectionContainer.prototype.unlink = function () {
|
|
66
71
|
this.isLinked = false;
|
|
67
72
|
|
|
68
|
-
|
|
73
|
+
const ecd = this.entityManager.dataset;
|
|
74
|
+
ecd.removeEntityEventListener(this.entity, MeshEvents.DataSet, this.handlers.updateMesh);
|
|
69
75
|
};
|
|
70
76
|
|
|
71
77
|
/**
|
|
@@ -72,7 +72,12 @@ export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
75
|
+
let url = layer.textureDiffuseURL;
|
|
76
|
+
|
|
77
|
+
if (url === null) {
|
|
78
|
+
// no URL, try to sample texture directly
|
|
79
|
+
url = convertSampler2D2DataURL(layer.diffuse);
|
|
80
|
+
}
|
|
76
81
|
|
|
77
82
|
this.icon.set(url);
|
|
78
83
|
}
|
|
@@ -34,6 +34,8 @@ import { MeshEvents } from "../../src/engine/graphics/ecs/mesh/MeshEvents.js";
|
|
|
34
34
|
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
35
35
|
import { SurfacePoint3 } from "../../src/core/geom/3d/SurfacePoint3.js";
|
|
36
36
|
import { make_ray_from_viewport_position } from "../../src/engine/graphics/make_ray_from_viewport_position.js";
|
|
37
|
+
import { makeEntityDecorators } from "./makeEntityDecorators.js";
|
|
38
|
+
|
|
37
39
|
|
|
38
40
|
class ViewManager extends View {
|
|
39
41
|
constructor() {
|
|
@@ -306,8 +308,10 @@ class EditorView extends View {
|
|
|
306
308
|
*/
|
|
307
309
|
this.gameView = null;
|
|
308
310
|
|
|
311
|
+
const decorators = makeEntityDecorators();
|
|
312
|
+
|
|
309
313
|
|
|
310
|
-
const entityListView = new EntityListView(editor);
|
|
314
|
+
const entityListView = new EntityListView({ editor, decorators });
|
|
311
315
|
this.entityListView = entityListView;
|
|
312
316
|
|
|
313
317
|
//entity editor
|
|
@@ -11,13 +11,12 @@ import ButtonView from '../../../src/view/elements/button/ButtonView.js';
|
|
|
11
11
|
import ObservedValue from '../../../src/core/model/ObservedValue.js';
|
|
12
12
|
import Signal from '../../../src/core/events/signal/Signal.js';
|
|
13
13
|
import List from '../../../src/core/collection/list/List.js';
|
|
14
|
-
import Tag from '../../../src/engine/ecs/components/Tag.js';
|
|
15
14
|
|
|
16
15
|
import SelectionAddAction from '../../actions/concrete/SelectionAddAction.js';
|
|
17
16
|
import SelectionRemoveAction from '../../actions/concrete/SelectionRemoveAction.js';
|
|
18
17
|
import EmptyView from "../../../src/view/elements/EmptyView.js";
|
|
19
18
|
|
|
20
|
-
class EntityView extends
|
|
19
|
+
class EntityView extends EmptyView {
|
|
21
20
|
/**
|
|
22
21
|
*
|
|
23
22
|
* @param entity
|
|
@@ -25,14 +24,12 @@ class EntityView extends View {
|
|
|
25
24
|
* @constructor
|
|
26
25
|
*/
|
|
27
26
|
constructor(entity, entityDataset) {
|
|
28
|
-
super(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
super({
|
|
28
|
+
classList: [
|
|
29
|
+
'entity-view'
|
|
30
|
+
]
|
|
31
|
+
});
|
|
33
32
|
|
|
34
|
-
this.el = dRoot.el;
|
|
35
|
-
const self = this;
|
|
36
33
|
|
|
37
34
|
this.model = entity;
|
|
38
35
|
|
|
@@ -58,38 +55,28 @@ class EntityView extends View {
|
|
|
58
55
|
signals.selected = new Signal();
|
|
59
56
|
|
|
60
57
|
dCheckBox.on('click', function () {
|
|
61
|
-
signals.selected.
|
|
58
|
+
signals.selected.send0();
|
|
62
59
|
});
|
|
63
60
|
|
|
64
|
-
//add tag text
|
|
65
|
-
const tag = entityDataset.getComponent(entity, Tag);
|
|
66
|
-
if (tag !== undefined) {
|
|
67
|
-
const vTags = new EmptyView({ classList: ['tag-container'] });
|
|
68
|
-
|
|
69
|
-
this.addChild(vTags);
|
|
70
|
-
|
|
71
|
-
tag.traverse(n => {
|
|
72
|
-
|
|
73
|
-
const lTag = new LabelView(n, {
|
|
74
|
-
classList: ['tag']
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
vTags.addChild(lTag);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
61
|
this.el.appendChild(dCheckBox.el);
|
|
81
62
|
}
|
|
82
63
|
}
|
|
83
64
|
|
|
84
65
|
|
|
85
66
|
class EntityListView extends View {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
67
|
+
/**
|
|
68
|
+
*
|
|
69
|
+
* @param {Editor} editor
|
|
70
|
+
* @param { (function(entity:number, ecd:EntityComponentDataset, view:View):void)[]} decorators
|
|
71
|
+
*/
|
|
72
|
+
constructor({
|
|
73
|
+
editor,
|
|
74
|
+
decorators = []
|
|
75
|
+
}) {
|
|
76
|
+
super();
|
|
91
77
|
|
|
92
|
-
this.el =
|
|
78
|
+
this.el = document.createElement('div');
|
|
79
|
+
this.addClass('entity-list-view');
|
|
93
80
|
|
|
94
81
|
if (this.on === undefined) {
|
|
95
82
|
this.on = {};
|
|
@@ -107,9 +94,19 @@ class EntityListView extends View {
|
|
|
107
94
|
const entityDataset = entityManager.dataset;
|
|
108
95
|
|
|
109
96
|
const entityView = new EntityView(entity, entityDataset);
|
|
97
|
+
|
|
98
|
+
const decorator_count = decorators.length;
|
|
99
|
+
|
|
100
|
+
for (let i = 0; i < decorator_count; i++) {
|
|
101
|
+
const decorator = decorators[i];
|
|
102
|
+
|
|
103
|
+
decorator(entity, entityDataset, entityView);
|
|
104
|
+
}
|
|
105
|
+
|
|
110
106
|
if (editor.selection.contains(entity)) {
|
|
111
107
|
entityView.isSelected.set(true);
|
|
112
108
|
}
|
|
109
|
+
|
|
113
110
|
entityView.on.selected.add(function () {
|
|
114
111
|
const actions = self.editor.actions;
|
|
115
112
|
actions.mark();
|
|
@@ -141,15 +138,23 @@ class EntityListView extends View {
|
|
|
141
138
|
const actionAdd = {
|
|
142
139
|
name: "Add",
|
|
143
140
|
action: function () {
|
|
144
|
-
engine.entityManager.
|
|
141
|
+
const dataset = editor.engine.entityManager.dataset;
|
|
142
|
+
|
|
143
|
+
if (dataset !== null) {
|
|
144
|
+
dataset.createEntity();
|
|
145
|
+
}
|
|
145
146
|
}
|
|
146
147
|
};
|
|
147
148
|
|
|
149
|
+
const vToolBar = new EmptyView();
|
|
150
|
+
|
|
148
151
|
const vAddButton = new ButtonView(actionAdd);
|
|
149
152
|
vAddButton.size.set(100, 20);
|
|
150
153
|
|
|
154
|
+
vToolBar.addChild(vAddButton);
|
|
155
|
+
|
|
151
156
|
this.addChildAt(list, 0, 0, 0, 0);
|
|
152
|
-
this.addChildAt(
|
|
157
|
+
this.addChildAt(vToolBar, 0, 1, 0, 0);
|
|
153
158
|
|
|
154
159
|
|
|
155
160
|
function addOne(entity) {
|
|
@@ -199,15 +204,21 @@ class EntityListView extends View {
|
|
|
199
204
|
}
|
|
200
205
|
};
|
|
201
206
|
|
|
207
|
+
const layout = () => {
|
|
208
|
+
const size = this.size;
|
|
209
|
+
|
|
210
|
+
list.size.set(size.x, size.y - 20);
|
|
211
|
+
vToolBar.size.set(size.x, 20);
|
|
212
|
+
vToolBar.position.set(0, list.size.y + list.position.y);
|
|
213
|
+
}
|
|
202
214
|
|
|
203
215
|
const handlers = this.handlers;
|
|
204
216
|
|
|
205
217
|
//listen for selection
|
|
206
218
|
this.bindSignal(editor.selection.on.added, handlers.selectOne);
|
|
207
219
|
this.bindSignal(editor.selection.on.removed, handlers.deselectOne);
|
|
208
|
-
this.size.onChanged.add(
|
|
209
|
-
|
|
210
|
-
});
|
|
220
|
+
this.size.onChanged.add(layout);
|
|
221
|
+
this.on.linked.add(layout);
|
|
211
222
|
}
|
|
212
223
|
|
|
213
224
|
layout() {
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Tag } from "../../src/engine/ecs/components/Tag.js";
|
|
2
|
+
import EmptyView from "../../src/view/elements/EmptyView.js";
|
|
3
|
+
import LabelView from "../../src/view/common/LabelView.js";
|
|
4
|
+
import Mesh from "../../src/engine/graphics/ecs/mesh/Mesh.js";
|
|
5
|
+
import { ParticleEmitter } from "../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js";
|
|
6
|
+
import { Light } from "../../src/engine/graphics/ecs/light/Light.js";
|
|
7
|
+
import { Camera } from "../../src/engine/graphics/ecs/camera/Camera.js";
|
|
8
|
+
import ImageView from "../../src/view/elements/image/ImageView.js";
|
|
9
|
+
import { EventType } from "../../src/engine/ecs/EntityManager.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @return {(function(entity:number, ecd:EntityComponentDataset, view:View):void)[]}
|
|
14
|
+
*/
|
|
15
|
+
export function makeEntityDecorators() {
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {number} entity
|
|
20
|
+
* @param {EntityComponentDataset} ecd
|
|
21
|
+
* @param {View} view
|
|
22
|
+
*/
|
|
23
|
+
function decorate_tags(entity, ecd, view) {
|
|
24
|
+
const tag = ecd.getComponent(entity, Tag);
|
|
25
|
+
|
|
26
|
+
if (tag === undefined) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const vTags = new EmptyView({ classList: ['tag-container'] });
|
|
31
|
+
|
|
32
|
+
view.addChild(vTags);
|
|
33
|
+
|
|
34
|
+
tag.traverse(n => {
|
|
35
|
+
|
|
36
|
+
const lTag = new LabelView(n, {
|
|
37
|
+
classList: ['tag']
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
vTags.addChild(lTag);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const component_icons = new Map([
|
|
45
|
+
[Mesh, "data/textures/icons/editor/cube-shaded-v1.png"],
|
|
46
|
+
[ParticleEmitter, "data/textures/icons/editor/particles.png"],
|
|
47
|
+
[Light, "data/textures/icons/editor/light.png"],
|
|
48
|
+
[Camera, "data/textures/icons/editor/camera.png"],
|
|
49
|
+
[Tag, "data/textures/icons/editor/tag-v0.png"],
|
|
50
|
+
]);
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @param {number} entity
|
|
55
|
+
* @param {EntityComponentDataset} ecd
|
|
56
|
+
* @param {View} view
|
|
57
|
+
*/
|
|
58
|
+
function decorate_component_icons(entity, ecd, view) {
|
|
59
|
+
|
|
60
|
+
const vIconContainer = new EmptyView({
|
|
61
|
+
css: {
|
|
62
|
+
pointerEvents: "none",
|
|
63
|
+
display: "flex",
|
|
64
|
+
flexDirection: "row",
|
|
65
|
+
justifyContent: "flex-end",
|
|
66
|
+
filter: "drop-shadow(0 0 2px rgba(0,0,0,0.6))"
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @type {Map<any, View>}
|
|
73
|
+
*/
|
|
74
|
+
const icons = new Map();
|
|
75
|
+
|
|
76
|
+
function update() {
|
|
77
|
+
|
|
78
|
+
for (const [Klass, icon_url] of component_icons) {
|
|
79
|
+
|
|
80
|
+
const has_icon = icons.has(Klass);
|
|
81
|
+
const has_component = ecd.hasComponent(entity, Klass);
|
|
82
|
+
|
|
83
|
+
if (!has_icon && has_component) {
|
|
84
|
+
|
|
85
|
+
const icon = new ImageView(icon_url);
|
|
86
|
+
|
|
87
|
+
icon.size.set(18, 18);
|
|
88
|
+
|
|
89
|
+
vIconContainer.addChild(icon);
|
|
90
|
+
|
|
91
|
+
icons.set(Klass, icon);
|
|
92
|
+
|
|
93
|
+
} else if (has_icon && !has_component) {
|
|
94
|
+
vIconContainer.removeChild(icons.get(Klass));
|
|
95
|
+
|
|
96
|
+
icons.delete(Klass);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function subscribe() {
|
|
103
|
+
ecd.addEntityEventListener(entity, EventType.ComponentAdded, update);
|
|
104
|
+
ecd.addEntityEventListener(entity, EventType.ComponentRemoved, update);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function unsubscribe() {
|
|
108
|
+
ecd.removeEntityEventListener(entity, EventType.ComponentAdded, update);
|
|
109
|
+
ecd.removeEntityEventListener(entity, EventType.ComponentRemoved, update);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
view.on.linked.add(subscribe);
|
|
113
|
+
view.on.linked.add(update);
|
|
114
|
+
view.on.unlinked.add(unsubscribe);
|
|
115
|
+
|
|
116
|
+
view.addChild(vIconContainer);
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return [
|
|
122
|
+
// decorate_tags,
|
|
123
|
+
decorate_component_icons
|
|
124
|
+
];
|
|
125
|
+
}
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Fully featured ECS game engine written in JavaScript",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.50.
|
|
8
|
+
"version": "2.50.2",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"require": "./build/meep.cjs"
|
|
15
15
|
},
|
|
16
16
|
"./src/*": "./src/*",
|
|
17
|
-
"./editor/*": "./editor/*"
|
|
17
|
+
"./editor/*": "./editor/*",
|
|
18
|
+
"./*.md": "./*"
|
|
18
19
|
},
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build-module": "rollup -c rollup.config.js",
|
|
@@ -71,5 +72,8 @@
|
|
|
71
72
|
"entity",
|
|
72
73
|
"component",
|
|
73
74
|
"system"
|
|
74
|
-
]
|
|
75
|
+
],
|
|
76
|
+
"engines": {
|
|
77
|
+
"node": ">=14"
|
|
78
|
+
}
|
|
75
79
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
# Procedural Level Generation samples
|
|
2
|
+
|
|
3
|
+
It is our hope is that you will find the code in these samples useful as a guide.
|
|
4
|
+
|
|
5
|
+
Please note that these samples currently rely on assets from an unpublished game codenamed "mir".
|
|
6
|
+
These assets are not distributed with the engine.
|
|
@@ -1,58 +1,72 @@
|
|
|
1
|
-
import { GridTaskGroup } from "
|
|
2
|
-
import { GridCellPlacementRule } from "
|
|
3
|
-
import { CellMatcherGridPattern } from "
|
|
4
|
-
import { CellMatcherLayerBitMaskTest } from "
|
|
5
|
-
import { GridTags } from "
|
|
6
|
-
import { CellMatcherNot } from "
|
|
7
|
-
import { GridCellActionPlaceMarker } from "
|
|
8
|
-
import { GridTaskCellularAutomata } from "
|
|
9
|
-
import { GridTaskActionRuleSet } from "
|
|
10
|
-
import { GridActionRuleSet } from "
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import {
|
|
1
|
+
import { GridTaskGroup } from "../../src/generation/GridTaskGroup.js";
|
|
2
|
+
import { GridCellPlacementRule } from "../../src/generation/placement/GridCellPlacementRule.js";
|
|
3
|
+
import { CellMatcherGridPattern } from "../../src/generation/rules/cell/CellMatcherGridPattern.js";
|
|
4
|
+
import { CellMatcherLayerBitMaskTest } from "../../src/generation/rules/CellMatcherLayerBitMaskTest.js";
|
|
5
|
+
import { GridTags } from "../../src/generation/GridTags.js";
|
|
6
|
+
import { CellMatcherNot } from "../../src/generation/rules/logic/CellMatcherNot.js";
|
|
7
|
+
import { GridCellActionPlaceMarker } from "../../src/generation/markers/GridCellActionPlaceMarker.js";
|
|
8
|
+
import { GridTaskCellularAutomata } from "../../src/generation/grid/generation/discrete/GridTaskCellularAutomata.js";
|
|
9
|
+
import { GridTaskActionRuleSet } from "../../src/generation/grid/generation/discrete/GridTaskCellActionRuleSet.js";
|
|
10
|
+
import { GridActionRuleSet } from "../../src/generation/markers/GridActionRuleSet.js";
|
|
11
|
+
import {
|
|
12
|
+
GridTaskBuildSourceDistanceMap
|
|
13
|
+
} from "../../src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js";
|
|
14
|
+
import { CellMatcherAnd } from "../../src/generation/rules/logic/CellMatcherAnd.js";
|
|
15
|
+
import { GridCellActionPlaceTags } from "../../src/generation/placement/action/GridCellActionPlaceTags.js";
|
|
16
|
+
import {
|
|
17
|
+
CellMatcherContainsMarkerWithinRadius
|
|
18
|
+
} from "../../src/generation/rules/cell/CellMatcherContainsMarkerWithinRadius.js";
|
|
15
19
|
import { mir_matcher_attack_corridor } from "./rules/mir_matcher_attack_corridor.js";
|
|
16
20
|
import { mir_generator_place_bases } from "./generators/mir_generator_place_bases.js";
|
|
17
21
|
import { matcher_tag_traversable_unoccupied } from "./rules/matcher_tag_traversable_unoccupied.js";
|
|
18
22
|
import { mir_generator_place_starting_point } from "./generators/mir_generator_place_starting_point.js";
|
|
19
|
-
import { GridTaskConnectRooms } from "
|
|
23
|
+
import { GridTaskConnectRooms } from "../../src/generation/grid/generation/discrete/GridTaskConnectRooms.js";
|
|
20
24
|
import { matcher_tag_traversable } from "./rules/matcher_tag_traversable.js";
|
|
21
|
-
import { GridTaskGenerateRoads } from "
|
|
25
|
+
import { GridTaskGenerateRoads } from "../../src/generation/grid/generation/road/GridTaskGenerateRoads.js";
|
|
22
26
|
import { mir_generator_place_road_decorators } from "./generators/mir_generator_place_road_decorators.js";
|
|
23
|
-
import { MarkerNodeMatcherByType } from "
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
27
|
+
import { MarkerNodeMatcherByType } from "../../src/generation/markers/matcher/MarkerNodeMatcherByType.js";
|
|
28
|
+
import {
|
|
29
|
+
GridTaskDensityMarkerDistribution
|
|
30
|
+
} from "../../src/generation/grid/generation/GridTaskDensityMarkerDistribution.js";
|
|
31
|
+
import { CellFilterSimplexNoise } from "../../src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js";
|
|
32
|
+
import { NumericInterval } from "../../src/core/math/interval/NumericInterval.js";
|
|
33
|
+
import { CellFilterMultiply } from "../../src/generation/filtering/numeric/math/algebra/CellFilterMultiply.js";
|
|
34
|
+
import { CellFilterCellMatcher } from "../../src/generation/filtering/CellFilterCellMatcher.js";
|
|
35
|
+
import { CellFilterLiteralFloat } from "../../src/generation/filtering/numeric/CellFilterLiteralFloat.js";
|
|
30
36
|
import { MirGridLayers } from "./grid/MirGridLayers.js";
|
|
31
|
-
import { CellFilterLerp } from "
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
import { CellFilterLerp } from "../../src/generation/filtering/numeric/math/CellFilterLerp.js";
|
|
38
|
+
import {
|
|
39
|
+
GridCellActionWriteFilterToLayer
|
|
40
|
+
} from "../../src/generation/placement/action/GridCellActionWriteFilterToLayer.js";
|
|
41
|
+
import { CellMatcherAny } from "../../src/generation/rules/CellMatcherAny.js";
|
|
42
|
+
import { CellFilterGaussianBlur } from "../../src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js";
|
|
43
|
+
import { GridCellActionSequence } from "../../src/generation/placement/action/util/GridCellActionSequence.js";
|
|
44
|
+
import { CellFilterStep } from "../../src/generation/filtering/numeric/math/CellFilterStep.js";
|
|
45
|
+
import {
|
|
46
|
+
CellFilterSampleLayerLinear
|
|
47
|
+
} from "../../src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js";
|
|
48
|
+
import { CellFilterAngleToNormal } from "../../src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js";
|
|
49
|
+
import Vector3 from "../../src/core/geom/Vector3js";
|
|
50
|
+
import { CellFilterOneMinus } from "../../src/generation/filtering/numeric/math/CellFilterOneMinus.js";
|
|
51
|
+
import { CellFilterSmoothStep } from "../../src/generation/filtering/numeric/math/CellFilterSmoothStep.js";
|
|
42
52
|
import { SampleNoise20_0 } from "./filters/SampleNoise20_0.js";
|
|
43
53
|
import { SampleGroundMoistureFilter } from "./filters/SampleGroundMoistureFilter.js";
|
|
44
|
-
import { GridTaskSequence } from "
|
|
45
|
-
import { CellFilterSubtract } from "
|
|
46
|
-
import { CellFilterCache } from "
|
|
47
|
-
import { CellFilterInverseLerp } from "
|
|
48
|
-
import { CellFilterClamp } from "
|
|
49
|
-
import {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
import { GridTaskSequence } from "../../src/generation/grid/generation/GridTaskSequence.js";
|
|
55
|
+
import { CellFilterSubtract } from "../../src/generation/filtering/numeric/math/algebra/CellFilterSubtract.js";
|
|
56
|
+
import { CellFilterCache } from "../../src/generation/filtering/numeric/CellFilterCache.js";
|
|
57
|
+
import { CellFilterInverseLerp } from "../../src/generation/filtering/numeric/math/CellFilterInverseLerp.js";
|
|
58
|
+
import { CellFilterClamp } from "../../src/generation/filtering/numeric/math/CellFilterClamp.js";
|
|
59
|
+
import {
|
|
60
|
+
MarkerNodeTransformerYRotateByFilter
|
|
61
|
+
} from "../../src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.js";
|
|
62
|
+
import { GridPatternMatcherCell } from "../../src/generation/rules/cell/GridPatternMatcherCell.js";
|
|
63
|
+
import {
|
|
64
|
+
MarkerNodeTransformerRecordProperty
|
|
65
|
+
} from "../../src/generation/markers/transform/MarkerNodeTransformerRecordProperty.js";
|
|
66
|
+
import { CellFilterAdd } from "../../src/generation/filtering/numeric/math/algebra/CellFilterAdd.js";
|
|
67
|
+
import { CellFilterDivide } from "../../src/generation/filtering/numeric/math/algebra/CellFilterDivide.js";
|
|
68
|
+
import { CellFilterCubicFunction } from "../../src/generation/filtering/numeric/math/poly/CellFilterCubicFunction.js";
|
|
69
|
+
import { CellFilterMax2 } from "../../src/generation/filtering/numeric/math/CellFilterMax2.js";
|
|
56
70
|
import { matcher_not_play_area } from "./rules/matcher_not_play_area.js";
|
|
57
71
|
|
|
58
72
|
export const SampleGenerator0 = new GridTaskGroup();
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { CellFilterMultiply } from "
|
|
2
|
-
import { CellFilterSimplexNoise } from "
|
|
3
|
-
import { CellFilterLiteralFloat } from "
|
|
4
|
-
import { CellFilterGaussianBlur } from "
|
|
5
|
-
import { CellFilterStep } from "
|
|
6
|
-
import {
|
|
1
|
+
import { CellFilterMultiply } from "../../../src/generation/filtering/numeric/math/algebra/CellFilterMultiply.js";
|
|
2
|
+
import { CellFilterSimplexNoise } from "../../../src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js";
|
|
3
|
+
import { CellFilterLiteralFloat } from "../../../src/generation/filtering/numeric/CellFilterLiteralFloat.js";
|
|
4
|
+
import { CellFilterGaussianBlur } from "../../../src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js";
|
|
5
|
+
import { CellFilterStep } from "../../../src/generation/filtering/numeric/math/CellFilterStep.js";
|
|
6
|
+
import {
|
|
7
|
+
CellFilterSampleLayerLinear
|
|
8
|
+
} from "../../../src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js";
|
|
7
9
|
import { MirGridLayers } from "../grid/MirGridLayers.js";
|
|
8
|
-
import { CellFilterMax2 } from "
|
|
9
|
-
import { CellFilterSmoothStep } from "
|
|
10
|
-
import { MohGridLayers } from "
|
|
11
|
-
import { CellFilterDilate } from "
|
|
12
|
-
import { CellFilterCache } from "
|
|
13
|
-
import { DEG_TO_RAD } from "../../../core/math/DEG_TO_RAD.js";
|
|
10
|
+
import { CellFilterMax2 } from "../../../src/generation/filtering/numeric/math/CellFilterMax2.js";
|
|
11
|
+
import { CellFilterSmoothStep } from "../../../src/generation/filtering/numeric/math/CellFilterSmoothStep.js";
|
|
12
|
+
import { MohGridLayers } from "../../../../../generator/MohGridLayers.js";
|
|
13
|
+
import { CellFilterDilate } from "../../../src/generation/filtering/numeric/complex/CellFilterDilate.js";
|
|
14
|
+
import { CellFilterCache } from "../../../src/generation/filtering/numeric/CellFilterCache.js";
|
|
15
|
+
import { DEG_TO_RAD } from "../../../src/core/math/DEG_TO_RAD.js";
|
|
14
16
|
|
|
15
17
|
const fReadHeight = CellFilterSampleLayerLinear.from(MirGridLayers.Heights);
|
|
16
18
|
|