@woosh/meep-engine 2.46.28 → 2.46.30
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/editor/Editor.js +793 -0
- package/editor/SelectionVisualizer.js +148 -0
- package/editor/actions/concrete/ActionUpdateTexture.js +21 -0
- package/editor/actions/concrete/ArrayCopyAction.js +39 -0
- package/editor/actions/concrete/ComponentAddAction.js +47 -0
- package/editor/actions/concrete/ComponentRemoveAction.js +38 -0
- package/editor/actions/concrete/EntityCreateAction.js +47 -0
- package/editor/actions/concrete/EntityRemoveAction.js +51 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
- package/editor/actions/concrete/ModifyPatchTextureArray2DAction.js +182 -0
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +45 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.js +67 -0
- package/editor/actions/concrete/PatchTerrainTextureAction.js +152 -0
- package/editor/actions/concrete/SelectionAddAction.js +36 -0
- package/editor/actions/concrete/SelectionClearAction.js +22 -0
- package/editor/actions/concrete/SelectionRemoveAction.js +30 -0
- package/editor/actions/concrete/TransformModifyAction.js +46 -0
- package/editor/actions/concrete/WriteGridValueAction.js +46 -0
- package/editor/ecs/EditorEntity.js +12 -0
- package/editor/ecs/EditorEntitySystem.js +14 -0
- package/editor/ecs/component/FieldDescriptor.js +34 -0
- package/editor/ecs/component/FieldValueAdapter.js +20 -0
- package/editor/ecs/component/TypeEditor.js +33 -0
- package/editor/ecs/component/TypeSchema.d.ts +38 -0
- package/editor/ecs/component/createFieldEditor.js +92 -0
- package/editor/ecs/component/createObjectEditor.js +361 -0
- package/editor/ecs/component/editors/ColorEditor.js +39 -0
- package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
- package/editor/ecs/component/editors/ImagePathEditor.js +82 -0
- package/editor/ecs/component/editors/LargeStrongEditor.js +107 -0
- package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
- package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
- package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
- package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
- package/editor/ecs/component/editors/Sampler2DEditor.js +221 -0
- package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
- package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
- package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
- package/editor/ecs/component/editors/common/noEditor.js +9 -0
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +225 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
- package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
- package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +95 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +63 -0
- package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
- package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
- package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
- package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
- package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
- package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
- package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
- package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
- package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
- package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
- package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
- package/editor/ecs/component/editors/three/TextureEditor.js +112 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/enableEditor.js +85 -0
- package/editor/library/MeshLibrary.js +33 -0
- package/editor/process/DisableGameUIProcess.js +43 -0
- package/editor/process/EditorProcess.js +35 -0
- package/editor/process/ObstacleGridDisplayProcess.js +120 -0
- package/editor/process/ProcessEngine.js +123 -0
- package/editor/process/SymbolicDisplayProcess.js +132 -0
- package/editor/process/symbolic/ComponentSymbolicDisplay.js +34 -0
- package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +159 -0
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +36 -0
- package/editor/process/symbolic/make3DSymbolicDisplay.js +91 -0
- package/editor/process/symbolic/makeCameraSymbolicDisplay.js +32 -0
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +176 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/process/symbolic/makeHelperSphereGeometry.js +73 -0
- package/editor/process/symbolic/makeLightSymbolicDisplay.js +77 -0
- package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +146 -0
- package/editor/process/symbolic/makePathSymbolicDisplay.js +105 -0
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +74 -0
- package/editor/process/symbolic/makeSocketsSymbolicDisplay.js +153 -0
- package/editor/process/symbolic/makeSolidArrowGeometry.js +391 -0
- package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +89 -0
- package/editor/process/symbolic/makeStoryTriggerSetAreaDisplay.js +114 -0
- package/editor/process/symbolic/synchronizeTransform.js +50 -0
- package/editor/tools/FoliagePaintTool.js +168 -0
- package/editor/tools/GridPaintTool.js +247 -0
- package/editor/tools/SelectionTool.js +407 -0
- package/editor/tools/TopDownCameraControlTool.js +59 -0
- package/editor/tools/TransformTool.js +370 -0
- package/editor/tools/engine/Tool.js +121 -0
- package/editor/tools/engine/ToolEngine.js +193 -0
- package/editor/tools/engine/ToolState.js +9 -0
- package/editor/tools/engine/ToolStateMachine.js +53 -0
- package/editor/tools/paint/TerrainHeightPaintTool.js +297 -0
- package/editor/tools/paint/TerrainPaintTool.js +211 -0
- package/editor/tools/paint/TerrainTexturePaintTool.js +193 -0
- package/editor/tools/paint/prototypeTerrainEditor.js +135 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.d.ts +50 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +500 -0
- package/editor/tools/v2/TransformControls.d.ts +20 -0
- package/editor/tools/v2/TransformControls.js +1782 -0
- package/editor/tools/v2/prototypeTransformControls.js +92 -0
- package/editor/view/EditorView.js +462 -0
- package/editor/view/GridPickCoordinateView.js +88 -0
- package/editor/view/ecs/ComponentControlFactory.js +48 -0
- package/editor/view/ecs/ComponentControlView.js +214 -0
- package/editor/view/ecs/EntityEditor.js +258 -0
- package/editor/view/ecs/EntityList.js +258 -0
- package/editor/view/ecs/components/BlackboardController.js +50 -0
- package/editor/view/ecs/components/DatGuiController.js +216 -0
- package/editor/view/ecs/components/FogOfWarController.js +78 -0
- package/editor/view/ecs/components/FogOfWarRevealerController.js +44 -0
- package/editor/view/ecs/components/GeneratedArmyController.js +42 -0
- package/editor/view/ecs/components/GridObstacleController.js +72 -0
- package/editor/view/ecs/components/GridPositionController.js +40 -0
- package/editor/view/ecs/components/HeadsUpDisplayController.js +30 -0
- package/editor/view/ecs/components/HighlightController.js +47 -0
- package/editor/view/ecs/components/MeshController.js +125 -0
- package/editor/view/ecs/components/PathFollowerController.js +87 -0
- package/editor/view/ecs/components/TagController.js +80 -0
- package/editor/view/ecs/components/TerrainController.js +225 -0
- package/editor/view/ecs/components/TransformController.js +103 -0
- package/editor/view/ecs/components/UnitShopController.js +112 -0
- package/editor/view/ecs/components/army/ArmyController.js +130 -0
- package/editor/view/ecs/components/color/GaugeView.js +107 -0
- package/editor/view/ecs/components/common/AutoCanvasView.js +53 -0
- package/editor/view/ecs/components/common/LineView.js +17 -0
- package/editor/view/ecs/components/common/NumberController.js +112 -0
- package/editor/view/ecs/components/common/NumericIntervalController.js +64 -0
- package/editor/view/ecs/components/gui/GUIElementController.js +117 -0
- package/editor/view/ecs/components/items/ItemContainerController.js +132 -0
- package/editor/view/ecs/components/items/ItemContainerController.stories.js +50 -0
- package/editor/view/ecs/components/items/ItemController.js +52 -0
- package/editor/view/ecs/components/particles/ColorParameterLUTController.js +444 -0
- package/editor/view/ecs/components/particles/ParameterTrackController.js +51 -0
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +213 -0
- package/editor/view/ecs/components/particles/ParticleLayerController.js +213 -0
- package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +401 -0
- package/editor/view/ecs/components/sockets/AttachmentSocketsController.js +51 -0
- package/editor/view/ecs/components/sound/SoundEmitterController.js +137 -0
- package/editor/view/ecs/components/story/StoryTriggerSetController.js +214 -0
- package/editor/view/ecs/components/unit/AuraController.js +45 -0
- package/editor/view/library/MeshLibraryView.js +164 -0
- package/editor/view/node-graph/NodeGraphEditorView.js +170 -0
- package/editor/view/node-graph/NodeGraphView.js +453 -0
- package/editor/view/node-graph/NodeView.js +135 -0
- package/editor/view/node-graph/PortView.js +69 -0
- package/editor/view/process/ProcessView.js +63 -0
- package/editor/view/tools/ToolSettingsView.js +143 -0
- package/editor/view/tools/ToolView.js +58 -0
- package/package.json +2 -1
- package/src/core/bvh2/bvh3/EBBVHLeafProxy.js +6 -1
- package/src/core/geom/3d/aabb/aabb3_matrix4_project.js +1 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts +9 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +148 -9
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +21 -1
- package/src/engine/graphics/render/forward_plus/LightManager.js +0 -60
- package/src/engine/graphics/render/forward_plus/LightRenderMetadata.js +1 -3
- package/src/engine/graphics/render/forward_plus/model/Decal.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts +0 -3
- package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +0 -11
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Alex on 14/01/2017.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import View from "../../../src/view/View.js";
|
|
7
|
+
import dom from "../../../src/view/DOM.js";
|
|
8
|
+
import LabelView from '../../../src/view/common/LabelView.js';
|
|
9
|
+
import VirtualListView from '../../../src/view/common/VirtualListView.js';
|
|
10
|
+
import ButtonView from '../../../src/view/elements/button/ButtonView.js';
|
|
11
|
+
import ObservedValue from '../../../src/core/model/ObservedValue.js';
|
|
12
|
+
import Signal from '../../../src/core/events/signal/Signal.js';
|
|
13
|
+
import List from '../../../src/core/collection/list/List.js';
|
|
14
|
+
import Tag from '../../../src/engine/ecs/components/Tag.js';
|
|
15
|
+
|
|
16
|
+
import SelectionAddAction from '../../actions/concrete/SelectionAddAction.js';
|
|
17
|
+
import SelectionRemoveAction from '../../actions/concrete/SelectionRemoveAction.js';
|
|
18
|
+
import EmptyView from "../../../src/view/elements/EmptyView.js";
|
|
19
|
+
|
|
20
|
+
class EntityView extends View {
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param entity
|
|
24
|
+
* @param {EntityComponentDataset} entityDataset
|
|
25
|
+
* @constructor
|
|
26
|
+
*/
|
|
27
|
+
constructor(entity, entityDataset) {
|
|
28
|
+
super(entity, entityDataset);
|
|
29
|
+
|
|
30
|
+
const dRoot = dom('div');
|
|
31
|
+
|
|
32
|
+
dRoot.addClass('entity-view');
|
|
33
|
+
|
|
34
|
+
this.el = dRoot.el;
|
|
35
|
+
const self = this;
|
|
36
|
+
|
|
37
|
+
this.model = entity;
|
|
38
|
+
|
|
39
|
+
const lId = new LabelView(entity, { classList: ['id'] });
|
|
40
|
+
lId.position.setX(0);
|
|
41
|
+
this.addChild(lId);
|
|
42
|
+
|
|
43
|
+
this.isSelected = new ObservedValue(false);
|
|
44
|
+
|
|
45
|
+
const dCheckBox = dom('div');
|
|
46
|
+
dCheckBox.addClass('selection');
|
|
47
|
+
|
|
48
|
+
this.isSelected.onChanged.add(function (v) {
|
|
49
|
+
dCheckBox.setClass('selected', v);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (this.on === undefined) {
|
|
53
|
+
this.on = {};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const signals = this.on;
|
|
57
|
+
|
|
58
|
+
signals.selected = new Signal();
|
|
59
|
+
|
|
60
|
+
dCheckBox.on('click', function () {
|
|
61
|
+
signals.selected.dispatch();
|
|
62
|
+
});
|
|
63
|
+
|
|
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
|
+
this.el.appendChild(dCheckBox.el);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class EntityListView extends View {
|
|
86
|
+
constructor(editor) {
|
|
87
|
+
super(editor);
|
|
88
|
+
|
|
89
|
+
const dRoot = dom('div');
|
|
90
|
+
dRoot.addClass('entity-list-view');
|
|
91
|
+
|
|
92
|
+
this.el = dRoot.el;
|
|
93
|
+
|
|
94
|
+
if (this.on === undefined) {
|
|
95
|
+
this.on = {};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
this.on.interaction = new Signal();
|
|
99
|
+
|
|
100
|
+
const hiddenEntities = new List();
|
|
101
|
+
|
|
102
|
+
const self = this;
|
|
103
|
+
this.editor = editor;
|
|
104
|
+
|
|
105
|
+
function makeElement(entity) {
|
|
106
|
+
const entityManager = editor.engine.entityManager;
|
|
107
|
+
const entityDataset = entityManager.dataset;
|
|
108
|
+
|
|
109
|
+
const entityView = new EntityView(entity, entityDataset);
|
|
110
|
+
if (editor.selection.contains(entity)) {
|
|
111
|
+
entityView.isSelected.set(true);
|
|
112
|
+
}
|
|
113
|
+
entityView.on.selected.add(function () {
|
|
114
|
+
const actions = self.editor.actions;
|
|
115
|
+
actions.mark();
|
|
116
|
+
const value = !entityView.isSelected.get();
|
|
117
|
+
if (value) {
|
|
118
|
+
actions.do(new SelectionAddAction([entity]));
|
|
119
|
+
} else {
|
|
120
|
+
actions.do(new SelectionRemoveAction([entity]));
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
entityView.el.addEventListener('click', function () {
|
|
125
|
+
self.on.interaction.dispatch(entity);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return entityView;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const entityList = new List();
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
const list = new VirtualListView(entityList, {
|
|
135
|
+
lineSize: 20,
|
|
136
|
+
elementFactory: makeElement
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
list.size.set(150, 600);
|
|
140
|
+
|
|
141
|
+
const actionAdd = {
|
|
142
|
+
name: "Add",
|
|
143
|
+
action: function () {
|
|
144
|
+
engine.entityManager.createEntity();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const vAddButton = new ButtonView(actionAdd);
|
|
149
|
+
vAddButton.size.set(100, 20);
|
|
150
|
+
|
|
151
|
+
this.addChildAt(list, 0, 0, 0, 0);
|
|
152
|
+
this.addChildAt(vAddButton, 0, 1, 0, 0);
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
function addOne(entity) {
|
|
156
|
+
//exclude editor-owned entities
|
|
157
|
+
if (editor.isEditorEntity(entity)) {
|
|
158
|
+
hiddenEntities.add(entity);
|
|
159
|
+
|
|
160
|
+
} else {
|
|
161
|
+
entityList.add(entity);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
function removeOne(entity) {
|
|
166
|
+
const hiddenIndex = hiddenEntities.indexOf(entity);
|
|
167
|
+
if (hiddenIndex !== -1) {
|
|
168
|
+
hiddenEntities.remove(hiddenIndex);
|
|
169
|
+
} else {
|
|
170
|
+
entityList.removeOneOf(entity);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function selectOne(entity) {
|
|
175
|
+
list.renderedViews.forEach(function (v) {
|
|
176
|
+
if (v.model === entity) {
|
|
177
|
+
v.isSelected.set(true);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function deselectOne(entity) {
|
|
183
|
+
list.renderedViews.forEach(function (v) {
|
|
184
|
+
if (v.model === entity) {
|
|
185
|
+
v.isSelected.set(false);
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
this.handlers = {
|
|
191
|
+
addOne: addOne,
|
|
192
|
+
removeOne: removeOne,
|
|
193
|
+
selectOne: selectOne,
|
|
194
|
+
deselectOne: deselectOne,
|
|
195
|
+
reset: function () {
|
|
196
|
+
//reset all
|
|
197
|
+
entityList.reset();
|
|
198
|
+
hiddenEntities.reset();
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
const handlers = this.handlers;
|
|
204
|
+
|
|
205
|
+
//listen for selection
|
|
206
|
+
this.bindSignal(editor.selection.on.added, handlers.selectOne);
|
|
207
|
+
this.bindSignal(editor.selection.on.removed, handlers.deselectOne);
|
|
208
|
+
this.size.onChanged.add(function (x, y) {
|
|
209
|
+
list.size.set(x, y);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
layout() {
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
link() {
|
|
218
|
+
super.link();
|
|
219
|
+
|
|
220
|
+
const entityManager = this.editor.engine.entityManager;
|
|
221
|
+
|
|
222
|
+
const handlers = this.handlers;
|
|
223
|
+
|
|
224
|
+
//list all active
|
|
225
|
+
const dataset = entityManager.dataset;
|
|
226
|
+
dataset.traverseEntityIndices(function (id) {
|
|
227
|
+
handlers.addOne(id);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
//propagate current selection
|
|
231
|
+
this.editor.selection.forEach(handlers.selectOne);
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
dataset.onEntityCreated.add(handlers.addOne);
|
|
235
|
+
dataset.onEntityRemoved.add(handlers.removeOne);
|
|
236
|
+
entityManager.on.reset.add(handlers.reset);
|
|
237
|
+
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
unlink() {
|
|
241
|
+
super.unlink();
|
|
242
|
+
|
|
243
|
+
const entityManager = this.editor.engine.entityManager;
|
|
244
|
+
const dataset = entityManager.dataset;
|
|
245
|
+
|
|
246
|
+
const handlers = this.handlers;
|
|
247
|
+
|
|
248
|
+
//clear out entity list
|
|
249
|
+
this.handlers.reset();
|
|
250
|
+
|
|
251
|
+
dataset.onEntityCreated.remove(handlers.addOne);
|
|
252
|
+
dataset.onEntityRemoved.remove(handlers.removeOne);
|
|
253
|
+
entityManager.on.reset.remove(handlers.reset);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
export default EntityListView;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import DatGuiController from "./DatGuiController.js";
|
|
2
|
+
import { clear } from "../../../../src/view/controller/dat/DatGuiUtils.js";
|
|
3
|
+
|
|
4
|
+
export class BlackboardController extends DatGuiController {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.addClass('ui-component-controller-blackboard');
|
|
9
|
+
|
|
10
|
+
const self = this;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {Blackboard} model
|
|
15
|
+
*/
|
|
16
|
+
function setModel(model) {
|
|
17
|
+
const gui = self.gui;
|
|
18
|
+
clear(gui);
|
|
19
|
+
|
|
20
|
+
if (model !== null) {
|
|
21
|
+
|
|
22
|
+
const data = model.data;
|
|
23
|
+
|
|
24
|
+
const elements = [];
|
|
25
|
+
|
|
26
|
+
for (let p in data) {
|
|
27
|
+
const datum = data[p];
|
|
28
|
+
|
|
29
|
+
elements.push({
|
|
30
|
+
datum,
|
|
31
|
+
name: p
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
elements.sort((a, b) => a.name.localeCompare(b.name));
|
|
37
|
+
|
|
38
|
+
const n = elements.length;
|
|
39
|
+
for (let i = 0; i < n; i++) {
|
|
40
|
+
const element = elements[i];
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
self.add(element.datum, 'value').name(element.name);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
this.model.onChanged.add(setModel);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import GuiControl from "../../../../src/view/controller/controls/GuiControl.js";
|
|
2
|
+
import dat from "dat.gui";
|
|
3
|
+
|
|
4
|
+
class DatGuiController extends GuiControl {
|
|
5
|
+
constructor({ classList = [] } = {}) {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
const gui = new dat.GUI({
|
|
9
|
+
autoPlace: false,
|
|
10
|
+
closed: false,
|
|
11
|
+
closeOnTop: false, //If true, close/open button shows on top of the GUI
|
|
12
|
+
resizable: false
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
this.gui = gui;
|
|
16
|
+
|
|
17
|
+
const domElement = gui.domElement;
|
|
18
|
+
this.el = domElement;
|
|
19
|
+
this.dRoot.el = domElement;
|
|
20
|
+
|
|
21
|
+
this.dRoot.addClass(GuiControl.CSS_CLASS_NAME);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
classList.forEach(c => this.addClass(c));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param {object} object
|
|
30
|
+
* @param {string} property
|
|
31
|
+
* @param {number} bitIndex
|
|
32
|
+
* @param {string} name
|
|
33
|
+
* @param {*} [extra]
|
|
34
|
+
*/
|
|
35
|
+
addBitFlag(object, property, bitIndex, name, extra) {
|
|
36
|
+
|
|
37
|
+
const proxy = {
|
|
38
|
+
get v() {
|
|
39
|
+
return (object[property] & bitIndex) !== 0;
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
set v(v) {
|
|
43
|
+
if (v) {
|
|
44
|
+
object[property] |= bitIndex;
|
|
45
|
+
} else {
|
|
46
|
+
object[property] &= ~bitIndex;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const c = this.addControl(proxy, 'v');
|
|
52
|
+
|
|
53
|
+
c
|
|
54
|
+
.name(name);
|
|
55
|
+
|
|
56
|
+
return c;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {function} method
|
|
62
|
+
* @param {string} [name]
|
|
63
|
+
* @param {*} [thisArg]
|
|
64
|
+
* @return {Controller}
|
|
65
|
+
*/
|
|
66
|
+
addAction(method, name, thisArg) {
|
|
67
|
+
if (name === undefined) {
|
|
68
|
+
name = method.name;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const proxy = {
|
|
72
|
+
m: () => {
|
|
73
|
+
method.call(thisArg);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
return this.add(proxy, 'm').name(name);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
*
|
|
82
|
+
* @param object
|
|
83
|
+
* @param {string} property
|
|
84
|
+
* @param extra
|
|
85
|
+
* @return {Controller}
|
|
86
|
+
*/
|
|
87
|
+
add(object, property, extra) {
|
|
88
|
+
const prop = object[property];
|
|
89
|
+
|
|
90
|
+
if (prop === undefined) {
|
|
91
|
+
throw new Error(`Property '${property}' is undefined`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (prop === null) {
|
|
95
|
+
throw new Error(`Property '${property}' is null`);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let c;
|
|
99
|
+
|
|
100
|
+
if (prop.isObservedBoolean || prop.isObservedInteger || prop.isVector1 || prop.isObservedString) {
|
|
101
|
+
|
|
102
|
+
const proxy = { v: prop.getValue() };
|
|
103
|
+
|
|
104
|
+
c = this.addControl(proxy, 'v');
|
|
105
|
+
|
|
106
|
+
c
|
|
107
|
+
.name(property)
|
|
108
|
+
.onChange(v => prop.set(v));
|
|
109
|
+
|
|
110
|
+
this.bindSignal(prop.onChanged, v => {
|
|
111
|
+
proxy.v = v;
|
|
112
|
+
c.setValue(v);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
} else if (prop.isVector2 || prop.isVector3) {
|
|
116
|
+
|
|
117
|
+
const proxy = {
|
|
118
|
+
get x() {
|
|
119
|
+
return prop.x;
|
|
120
|
+
},
|
|
121
|
+
set x(v) {
|
|
122
|
+
prop.setX(v);
|
|
123
|
+
},
|
|
124
|
+
get y() {
|
|
125
|
+
return prop.y;
|
|
126
|
+
},
|
|
127
|
+
set y(v) {
|
|
128
|
+
prop.setY(v);
|
|
129
|
+
},
|
|
130
|
+
get z() {
|
|
131
|
+
return prop.z;
|
|
132
|
+
},
|
|
133
|
+
set z(v) {
|
|
134
|
+
prop.setZ(v);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const f = this.addFolder(property);
|
|
139
|
+
|
|
140
|
+
let step = 0.00001;
|
|
141
|
+
|
|
142
|
+
if (extra !== undefined && extra.step !== undefined) {
|
|
143
|
+
step = extra.step;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
f.add(proxy, 'x').step(step);
|
|
148
|
+
f.add(proxy, 'y').step(step);
|
|
149
|
+
|
|
150
|
+
if (prop.isVector3) {
|
|
151
|
+
f.add(proxy, 'z').step(step);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
c = f;
|
|
155
|
+
} else {
|
|
156
|
+
c = this.addControl(object, property, extra);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return c;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
addEnumRaw(object, property, type) {
|
|
163
|
+
|
|
164
|
+
const proxy = { v: object[property] };
|
|
165
|
+
|
|
166
|
+
const c = this.addControl(proxy, "v", type);
|
|
167
|
+
|
|
168
|
+
c.name(property);
|
|
169
|
+
c.onChange(v => {
|
|
170
|
+
for (let typeKey in type) {
|
|
171
|
+
const typeValue = type[typeKey];
|
|
172
|
+
if (typeValue == v) {
|
|
173
|
+
object[property] = typeValue;
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
console.warn(`Value ${v} not found in enum`, v, type);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
return c;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
*
|
|
186
|
+
* @param {Object} object
|
|
187
|
+
* @param {string} property
|
|
188
|
+
* @param {Object|Array} [extra]
|
|
189
|
+
* @returns {Controller}
|
|
190
|
+
*/
|
|
191
|
+
addControl(object, property, extra) {
|
|
192
|
+
if (object[property] === undefined) {
|
|
193
|
+
throw new Error(`Object has no property '${property}'`);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const control = this.gui.add(object, property, extra);
|
|
197
|
+
|
|
198
|
+
return control;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
addFolder(name) {
|
|
202
|
+
const control = this.gui.addFolder(name);
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
return control;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
addColorControl(object, property) {
|
|
209
|
+
const control = this.gui.addColor(object, property);
|
|
210
|
+
|
|
211
|
+
return control;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
export default DatGuiController;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import DatGuiController from "./DatGuiController.js";
|
|
2
|
+
import { clear } from "../../../../src/view/controller/dat/DatGuiUtils.js";
|
|
3
|
+
import ButtonView from "../../../../src/view/elements/button/ButtonView.js";
|
|
4
|
+
import { FogOfWarRevealerSystem } from "../../../../src/engine/ecs/fow/FogOfWarRevealerSystem.js";
|
|
5
|
+
|
|
6
|
+
export class FogOfWarController extends DatGuiController {
|
|
7
|
+
/**
|
|
8
|
+
* @param {EntityManager} em
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
constructor(em) {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
const self = this;
|
|
15
|
+
|
|
16
|
+
this.addChild(new ButtonView({
|
|
17
|
+
action() {
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {FogOfWar}
|
|
21
|
+
*/
|
|
22
|
+
const fow = self.model.getValue();
|
|
23
|
+
|
|
24
|
+
fow.clear();
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @type {FogOfWarRevealerSystem}
|
|
29
|
+
*/
|
|
30
|
+
const revealerSystem = em.getSystem(FogOfWarRevealerSystem);
|
|
31
|
+
|
|
32
|
+
if (revealerSystem !== null) {
|
|
33
|
+
revealerSystem.forceUpdate();
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
name: 'Conceal All'
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
this.addChild(new ButtonView({
|
|
40
|
+
action() {
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @type {FogOfWar}
|
|
44
|
+
*/
|
|
45
|
+
const fow = self.model.getValue();
|
|
46
|
+
|
|
47
|
+
fow.revealAll();
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @type {FogOfWarRevealerSystem}
|
|
52
|
+
*/
|
|
53
|
+
const revealerSystem = em.getSystem(FogOfWarRevealerSystem);
|
|
54
|
+
|
|
55
|
+
if (revealerSystem !== null) {
|
|
56
|
+
revealerSystem.forceUpdate();
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
name: 'Reveal All'
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {FogOfWar} model
|
|
65
|
+
*/
|
|
66
|
+
function setModel(model) {
|
|
67
|
+
const gui = self.gui;
|
|
68
|
+
clear(gui);
|
|
69
|
+
|
|
70
|
+
if (model !== null) {
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.model.onChanged.add(setModel);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { LineView } from "./common/LineView.js";
|
|
2
|
+
import LabelView from "../../../../src/view/common/LabelView.js";
|
|
3
|
+
import View from "../../../../src/view/View.js";
|
|
4
|
+
import ObservedValue from "../../../../src/core/model/ObservedValue.js";
|
|
5
|
+
import Vector1Control from "../../../../src/view/controller/controls/Vector1Control.js";
|
|
6
|
+
|
|
7
|
+
export class FogOfWarRevealerController extends View {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
|
|
15
|
+
this.el = document.createElement('div');
|
|
16
|
+
this.addClass('ui-fow-revealer-controller');
|
|
17
|
+
|
|
18
|
+
this.model = new ObservedValue(null);
|
|
19
|
+
|
|
20
|
+
const cRadius = new Vector1Control();
|
|
21
|
+
|
|
22
|
+
this.addChild(new LineView({
|
|
23
|
+
elements: [
|
|
24
|
+
new LabelView('radius'),
|
|
25
|
+
cRadius
|
|
26
|
+
]
|
|
27
|
+
}));
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param {FogOfWarRevealer} model
|
|
32
|
+
*/
|
|
33
|
+
function setModel(model) {
|
|
34
|
+
|
|
35
|
+
if (model !== null) {
|
|
36
|
+
cRadius.model.set(model.radius);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.model.onChanged.add(setModel);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import DatGuiController from "./DatGuiController.js";
|
|
2
|
+
import { clear } from "../../../../src/view/controller/dat/DatGuiUtils.js";
|
|
3
|
+
import { buildCombatUnitsValidator } from "../../../../../model/game/ecs/component/generator/army/GeneratedArmy.js";
|
|
4
|
+
import { extractFunctionBody } from "../../../../src/core/function/extractFunctionBody.js";
|
|
5
|
+
|
|
6
|
+
export class GeneratedArmyController extends DatGuiController {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
const self = this;
|
|
15
|
+
|
|
16
|
+
const proxy = {
|
|
17
|
+
validator: ''
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @param {GeneratedArmy} model
|
|
24
|
+
*/
|
|
25
|
+
function setModel(model) {
|
|
26
|
+
const gui = self.gui;
|
|
27
|
+
clear(gui);
|
|
28
|
+
|
|
29
|
+
if (model !== null) {
|
|
30
|
+
proxy.validator = extractFunctionBody(model.validator);
|
|
31
|
+
|
|
32
|
+
self.addControl(model, 'value').name('Value');
|
|
33
|
+
|
|
34
|
+
self.addControl(proxy, 'validator').name('Validator').onChange(function () {
|
|
35
|
+
model.validator = buildCombatUnitsValidator(proxy.validator);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.model.onChanged.add(setModel);
|
|
41
|
+
}
|
|
42
|
+
}
|