@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,225 @@
|
|
|
1
|
+
import DatGuiController from "./DatGuiController.js";
|
|
2
|
+
import Vector2 from "../../../../src/core/geom/Vector2.js";
|
|
3
|
+
import View from "../../../../src/view/View.js";
|
|
4
|
+
import { NativeListController } from "../../../../src/view/controller/controls/NativeListController.js";
|
|
5
|
+
import { TerrainLayer } from "../../../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
6
|
+
import CheckersTextureURI from "../../../../src/engine/graphics/texture/CheckersTextureURI.js";
|
|
7
|
+
import EmptyView from "../../../../src/view/elements/EmptyView.js";
|
|
8
|
+
import convertSampler2D2Canvas from "../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
9
|
+
import { CanvasView } from "../../../../src/view/elements/CanvasView.js";
|
|
10
|
+
import { scaleSampler2D } from "../../../../src/engine/graphics/texture/sampler/scaleSampler2D.js";
|
|
11
|
+
import { Sampler2D } from "../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
12
|
+
import Signal from "../../../../src/core/events/signal/Signal.js";
|
|
13
|
+
import Vector2Control from "../../../../src/view/controller/controls/Vector2Control.js";
|
|
14
|
+
import GroupView from "../../../../src/view/elements/Group.js";
|
|
15
|
+
import LabelView from "../../../../src/view/common/LabelView.js";
|
|
16
|
+
import ObservedValue from "../../../../src/core/model/ObservedValue.js";
|
|
17
|
+
import { SplatMapOptimizer } from "../../../../src/engine/ecs/terrain/ecs/splat/SplatMapOptimizer.js";
|
|
18
|
+
|
|
19
|
+
class LayersController extends View {
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param {Terrain} terrain
|
|
23
|
+
* @param {TerrainLayers} layers
|
|
24
|
+
* @param {AssetManager} assetManager
|
|
25
|
+
*/
|
|
26
|
+
constructor({ terrain, layers, assetManager }) {
|
|
27
|
+
super();
|
|
28
|
+
|
|
29
|
+
this.el = document.createElement('div');
|
|
30
|
+
this.addClass('ui-terrain-layers-controller-view');
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function updateLayers() {
|
|
34
|
+
|
|
35
|
+
terrain.layers.buildTexture();
|
|
36
|
+
terrain.layers.writeAllLayersDataIntoTexture();
|
|
37
|
+
|
|
38
|
+
terrain.updateMaterial();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const updateBus = new Signal();
|
|
42
|
+
|
|
43
|
+
this.bindSignal(layers.layers.on.added, () => {
|
|
44
|
+
terrain.splat.addWeightLayer();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.bindSignal(layers.layers.on.removed, (layer, index) => {
|
|
48
|
+
terrain.splat.removeWeightLayer(index);
|
|
49
|
+
updateLayers();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.addChild(
|
|
53
|
+
new NativeListController({
|
|
54
|
+
model: layers.layers,
|
|
55
|
+
elementFactory() {
|
|
56
|
+
const layer = new TerrainLayer();
|
|
57
|
+
|
|
58
|
+
layer.textureDiffuseURL = CheckersTextureURI;
|
|
59
|
+
layer.size.set(1, 1);
|
|
60
|
+
|
|
61
|
+
layer.loadTextureData(assetManager)
|
|
62
|
+
.then(() => {
|
|
63
|
+
|
|
64
|
+
updateLayers();
|
|
65
|
+
|
|
66
|
+
updateBus.send1(layer);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
return layer;
|
|
70
|
+
},
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param {TerrainLayer} layer
|
|
74
|
+
* @return {View}
|
|
75
|
+
*/
|
|
76
|
+
elementViewFactory(layer) {
|
|
77
|
+
const v = new EmptyView();
|
|
78
|
+
|
|
79
|
+
v.bindSignal(updateBus, (l) => {
|
|
80
|
+
if (l === layer) {
|
|
81
|
+
update();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
v.addClass('ui-terrain-layer-controller-view');
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
const vCanvas = new CanvasView();
|
|
89
|
+
vCanvas.size.set(64, 64);
|
|
90
|
+
|
|
91
|
+
const t = Sampler2D.uint8(layer.diffuse.itemSize, 64, 64);
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
function update() {
|
|
95
|
+
|
|
96
|
+
scaleSampler2D(layer.diffuse, t);
|
|
97
|
+
|
|
98
|
+
convertSampler2D2Canvas(t, 1, 0, vCanvas.el);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
update();
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
v.addChild(vCanvas);
|
|
105
|
+
|
|
106
|
+
const vURL = new EmptyView({ classList: ['url'], tag: 'input' });
|
|
107
|
+
const elValue = vURL.el;
|
|
108
|
+
|
|
109
|
+
elValue.setAttribute('type', 'text');
|
|
110
|
+
elValue.value = layer.textureDiffuseURL;
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
elValue.addEventListener('input', () => {
|
|
114
|
+
const v = elValue.value;
|
|
115
|
+
|
|
116
|
+
layer.textureDiffuseURL = v;
|
|
117
|
+
|
|
118
|
+
layer.loadTextureData(assetManager).then(() => {
|
|
119
|
+
update();
|
|
120
|
+
|
|
121
|
+
const index = layers.layers.indexOf(layer);
|
|
122
|
+
|
|
123
|
+
layers.writeLayerDataIntoTexture(index);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const vSize = new Vector2Control();
|
|
128
|
+
vSize.model.set(layer.size);
|
|
129
|
+
|
|
130
|
+
v.bindSignal(layer.size.onChanged, terrain.updateMaterial, terrain);
|
|
131
|
+
|
|
132
|
+
const groupView = new GroupView();
|
|
133
|
+
groupView.add(new LabelView('size'));
|
|
134
|
+
groupView.add(vSize);
|
|
135
|
+
|
|
136
|
+
v.addChild(groupView);
|
|
137
|
+
|
|
138
|
+
v.addChild(vURL);
|
|
139
|
+
|
|
140
|
+
return v;
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export class TerrainController extends View {
|
|
148
|
+
/**
|
|
149
|
+
*
|
|
150
|
+
* @param {AssetManager} assetManager
|
|
151
|
+
*/
|
|
152
|
+
constructor(assetManager) {
|
|
153
|
+
super();
|
|
154
|
+
|
|
155
|
+
this.el = document.createElement('div');
|
|
156
|
+
|
|
157
|
+
this.model = new ObservedValue(null);
|
|
158
|
+
|
|
159
|
+
const self = this;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
*
|
|
163
|
+
* @param {Terrain} model
|
|
164
|
+
*/
|
|
165
|
+
function setModel(model) {
|
|
166
|
+
|
|
167
|
+
self.removeAllChildren();
|
|
168
|
+
const controller = new DatGuiController();
|
|
169
|
+
self.addChild(controller);
|
|
170
|
+
|
|
171
|
+
if (model !== null) {
|
|
172
|
+
controller.addAction(() => {
|
|
173
|
+
model.__tiles.rebuild();
|
|
174
|
+
}, 'Rebuild');
|
|
175
|
+
|
|
176
|
+
controller.addAction(() => {
|
|
177
|
+
|
|
178
|
+
SplatMapOptimizer.optimizeSynchronous(model.splat)
|
|
179
|
+
|
|
180
|
+
}, 'Optimize Textures');
|
|
181
|
+
|
|
182
|
+
controller.add(model, 'size', { step: 1 });
|
|
183
|
+
controller.add(model, 'resolution').step(1);
|
|
184
|
+
controller.add(model, 'gridScale').step(1).name('Gird Size');
|
|
185
|
+
|
|
186
|
+
const proxy = {
|
|
187
|
+
heightResolution: new Vector2(model.samplerHeight.width, model.samplerHeight.height),
|
|
188
|
+
weightResolution: new Vector2(model.splat.size.x, model.splat.size.y),
|
|
189
|
+
layerResolution: new Vector2(model.layers.resolution.x, model.layers.resolution.y),
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
proxy.heightResolution.onChanged.add((x, y) => {
|
|
193
|
+
model.samplerHeight.resize(x, y);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
proxy.weightResolution.onChanged.add((x, y) => {
|
|
197
|
+
model.splat.resize(x, y, model.splat.depth);
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
proxy.layerResolution.onChanged.add((x, y) => {
|
|
201
|
+
model.layers.resolution.set(x, y);
|
|
202
|
+
|
|
203
|
+
model.layers.buildTexture();
|
|
204
|
+
model.layers.writeAllLayersDataIntoTexture();
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
controller.add(proxy, 'heightResolution', { step: 1 });
|
|
208
|
+
controller.add(proxy, 'weightResolution', { step: 1 });
|
|
209
|
+
controller.add(proxy, 'layerResolution', { step: 1 });
|
|
210
|
+
|
|
211
|
+
if (model.preview.url === null) {
|
|
212
|
+
model.preview.url = '';
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
controller.add(model.preview, 'url').name('preview url');
|
|
216
|
+
controller.add(model.preview, 'offset');
|
|
217
|
+
controller.add(model.preview, 'scale');
|
|
218
|
+
|
|
219
|
+
self.addChild(new LayersController({ terrain: model, layers: model.layers, assetManager }));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.model.onChanged.add(setModel);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Alex on 14/01/2017.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import GuiControl from '../../../../src/view/controller/controls/GuiControl.js';
|
|
7
|
+
import Vector3Control from '../../../../src/view/controller/controls/Vector3Control.js';
|
|
8
|
+
import Vector3 from '../../../../src/core/geom/Vector3.js';
|
|
9
|
+
|
|
10
|
+
import LabelView from '../../../../src/view/common/LabelView.js';
|
|
11
|
+
|
|
12
|
+
import { Euler as ThreeEuler } from 'three';
|
|
13
|
+
|
|
14
|
+
class TransformController extends GuiControl {
|
|
15
|
+
constructor() {
|
|
16
|
+
super();
|
|
17
|
+
|
|
18
|
+
this.cPosition = new Vector3Control();
|
|
19
|
+
this.cScale = new Vector3Control();
|
|
20
|
+
this.cRotation = new Vector3Control();
|
|
21
|
+
|
|
22
|
+
this.rotationProxy = new Vector3(0, 0, 0);
|
|
23
|
+
|
|
24
|
+
this.cRotation.model.set(this.rotationProxy);
|
|
25
|
+
|
|
26
|
+
const lPosition = new LabelView('Position');
|
|
27
|
+
const lScale = new LabelView('Scale');
|
|
28
|
+
const lRotation = new LabelView('Rotation');
|
|
29
|
+
|
|
30
|
+
this.addChild(lPosition);
|
|
31
|
+
this.addChild(this.cPosition);
|
|
32
|
+
|
|
33
|
+
this.addChild(lScale);
|
|
34
|
+
this.addChild(this.cScale);
|
|
35
|
+
|
|
36
|
+
this.addChild(lRotation);
|
|
37
|
+
this.addChild(this.cRotation);
|
|
38
|
+
|
|
39
|
+
const self = this;
|
|
40
|
+
|
|
41
|
+
this.handlers = {
|
|
42
|
+
updateRotationFromModel: function () {
|
|
43
|
+
if (self.isLinked) {
|
|
44
|
+
requestAnimationFrame(self.handlers.updateRotationFromModel);
|
|
45
|
+
} else {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const transform = self.model.get();
|
|
50
|
+
if (transform !== null) {
|
|
51
|
+
const euler = new ThreeEuler();
|
|
52
|
+
euler.setFromQuaternion(transform.rotation);
|
|
53
|
+
|
|
54
|
+
//suppress double updates
|
|
55
|
+
self.rotationProxy.onChanged.remove(self.handlers.updateRotationToModel);
|
|
56
|
+
|
|
57
|
+
if (!Number.isNaN(euler.x) && !Number.isNaN(euler.y) && !Number.isNaN(euler.z)) {
|
|
58
|
+
self.rotationProxy.copy(euler);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//reactivate updates
|
|
62
|
+
self.rotationProxy.onChanged.add(self.handlers.updateRotationToModel);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
updateRotationToModel: function () {
|
|
66
|
+
const transform = self.model.get();
|
|
67
|
+
if (transform !== null) {
|
|
68
|
+
transform.rotation.__setFromEuler(self.rotationProxy.x, self.rotationProxy.y, self.rotationProxy.z, 'XYZ');
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
modelChanged: function (newModel, oldModel) {
|
|
72
|
+
if (newModel !== null) {
|
|
73
|
+
self.cPosition.model.set(newModel.position);
|
|
74
|
+
self.cScale.model.set(newModel.scale);
|
|
75
|
+
self.handlers.updateRotationFromModel();
|
|
76
|
+
}
|
|
77
|
+
if (oldModel !== null) {
|
|
78
|
+
//do nothing really
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
this.bindSignal(this.model.onChanged, this.handlers.modelChanged);
|
|
85
|
+
this.bindSignal(this.rotationProxy.onChanged, this.handlers.updateRotationToModel);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
link() {
|
|
89
|
+
super.link();
|
|
90
|
+
|
|
91
|
+
if (this.model.getValue() !== null) {
|
|
92
|
+
this.handlers.modelChanged(this.model.getValue(), null);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
unlink() {
|
|
97
|
+
super.unlink();
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
export default TransformController;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import View from "../../../../src/view/View.js";
|
|
2
|
+
import ObservedValue from "../../../../src/core/model/ObservedValue.js";
|
|
3
|
+
import ListView from "../../../../src/view/common/ListView.js";
|
|
4
|
+
import DatGuiController from "./DatGuiController.js";
|
|
5
|
+
import { ShopGoodType, UnitShopElement } from "../../../../../model/game/ecs/component/shop/UnitShop.js";
|
|
6
|
+
import ObservedString from "../../../../src/core/model/ObservedString.js";
|
|
7
|
+
|
|
8
|
+
export class UnitShopController extends View {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this.el = document.createElement('div');
|
|
13
|
+
this.addClass('unit-shop-controller');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @type {ObservedValue<UnitShop>}
|
|
18
|
+
*/
|
|
19
|
+
this.model = new ObservedValue(null);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
this.model.onChanged.add(shop => {
|
|
23
|
+
|
|
24
|
+
this.removeAllChildren();
|
|
25
|
+
|
|
26
|
+
let lock = false;
|
|
27
|
+
const json = new ObservedString(makeJSON());
|
|
28
|
+
|
|
29
|
+
json.onChanged.add(v => {
|
|
30
|
+
if (lock) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
lock = true;
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
const j = JSON.parse(v);
|
|
37
|
+
shop.fromJSON(j);
|
|
38
|
+
} catch (e) {
|
|
39
|
+
console.error(e);
|
|
40
|
+
} finally {
|
|
41
|
+
lock = false;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
const list = new ListView(shop.elements, {
|
|
46
|
+
classList: ['elements'],
|
|
47
|
+
elementFactory(el) {
|
|
48
|
+
const view = new DatGuiController();
|
|
49
|
+
|
|
50
|
+
function update() {
|
|
51
|
+
updateJSON();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
view.addEnumRaw(el, 'goodType', ShopGoodType).onChange(update);
|
|
55
|
+
view.addControl(el, 'good').onChange(update);
|
|
56
|
+
|
|
57
|
+
view.add(el, 'supply').onChange(update);
|
|
58
|
+
view.add(el, 'supplyLimit').onChange(update);
|
|
59
|
+
view.add(el, 'cooldown').onChange(update);
|
|
60
|
+
view.add(el, 'cooldownCounter').onChange(update);
|
|
61
|
+
|
|
62
|
+
view.addControl({
|
|
63
|
+
remove() {
|
|
64
|
+
shop.elements.removeOneOf(el);
|
|
65
|
+
}
|
|
66
|
+
}, 'remove');
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
return view;
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
function makeJSON() {
|
|
74
|
+
return JSON.stringify(shop.toJSON(), 3, 3);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function updateJSON() {
|
|
78
|
+
lock = true;
|
|
79
|
+
try {
|
|
80
|
+
const str = makeJSON();
|
|
81
|
+
json.set(str);
|
|
82
|
+
} catch (e) {
|
|
83
|
+
console.error(e);
|
|
84
|
+
} finally {
|
|
85
|
+
lock = false;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
list.bindSignal(shop.elements.on.added, updateJSON);
|
|
90
|
+
list.bindSignal(shop.elements.on.removed, updateJSON);
|
|
91
|
+
|
|
92
|
+
this.addChild(list);
|
|
93
|
+
|
|
94
|
+
const dat = new DatGuiController();
|
|
95
|
+
|
|
96
|
+
dat.addControl({
|
|
97
|
+
add() {
|
|
98
|
+
const el = new UnitShopElement();
|
|
99
|
+
|
|
100
|
+
shop.elements.add(el);
|
|
101
|
+
}
|
|
102
|
+
}, "add").name("+new");
|
|
103
|
+
|
|
104
|
+
dat.add({
|
|
105
|
+
json
|
|
106
|
+
}, 'json');
|
|
107
|
+
|
|
108
|
+
this.addChild(dat);
|
|
109
|
+
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import View from "../../../../../src/view/View.js";
|
|
2
|
+
import EmptyView from "../../../../../src/view/elements/EmptyView.js";
|
|
3
|
+
import { LineView } from "../common/LineView.js";
|
|
4
|
+
import ButtonView from "../../../../../src/view/elements/button/ButtonView.js";
|
|
5
|
+
import Aura from "../../../../../../model/game/unit/aura/Aura.js";
|
|
6
|
+
import ObservedValue from "../../../../../src/core/model/ObservedValue.js";
|
|
7
|
+
import LabelView from "../../../../../src/view/common/LabelView.js";
|
|
8
|
+
import ListView from "../../../../../src/view/common/ListView.js";
|
|
9
|
+
import { AuraController } from "../unit/AuraController.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {Army} army
|
|
14
|
+
* @param {AfflictionDescriptionDatabase} afflictions
|
|
15
|
+
* @return {View}
|
|
16
|
+
*/
|
|
17
|
+
function makeAuraAdder(army, afflictions) {
|
|
18
|
+
|
|
19
|
+
const vInput = new EmptyView({ classList: ['id'], tag: 'input' });
|
|
20
|
+
|
|
21
|
+
//item adder
|
|
22
|
+
return new LineView({
|
|
23
|
+
classList: [
|
|
24
|
+
'aura-adder'
|
|
25
|
+
],
|
|
26
|
+
elements: [
|
|
27
|
+
vInput,
|
|
28
|
+
new ButtonView({
|
|
29
|
+
action() {
|
|
30
|
+
const id = vInput.el.value;
|
|
31
|
+
const description = afflictions.get(id);
|
|
32
|
+
|
|
33
|
+
if (description === null) {
|
|
34
|
+
|
|
35
|
+
console.error(`affliction '${id}' not found`);
|
|
36
|
+
|
|
37
|
+
return;
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const aura = new Aura();
|
|
42
|
+
|
|
43
|
+
aura.affliction = description;
|
|
44
|
+
|
|
45
|
+
if (army.auras.find(a => a.equals(aura))) {
|
|
46
|
+
//aura already exists, prevent duplicates
|
|
47
|
+
console.warn(`Army already has aura '${description.id}', preventing duplication`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
army.auras.add(aura);
|
|
52
|
+
},
|
|
53
|
+
name: 'Add',
|
|
54
|
+
classList: ['add']
|
|
55
|
+
})
|
|
56
|
+
]
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export class CombatUnitController extends View {
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {CombatUnit} unit
|
|
65
|
+
* @param {function} remove
|
|
66
|
+
* @param {StaticKnowledgeDatabase} database
|
|
67
|
+
*/
|
|
68
|
+
constructor({ unit, remove, database }) {
|
|
69
|
+
super();
|
|
70
|
+
|
|
71
|
+
this.el = document.createElement('div');
|
|
72
|
+
this.addClass('el-combat-unit-controller');
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export class ArmyController extends View {
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {Localization} localization
|
|
82
|
+
* @param {AfflictionDescriptionDatabase} afflictionDatabase
|
|
83
|
+
*/
|
|
84
|
+
constructor({ localization, afflictionDatabase }) {
|
|
85
|
+
super();
|
|
86
|
+
|
|
87
|
+
this.el = document.createElement('div');
|
|
88
|
+
this.addClass('ui-army-controller');
|
|
89
|
+
|
|
90
|
+
this.model = new ObservedValue(null);
|
|
91
|
+
|
|
92
|
+
const self = this;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @param {Army} model
|
|
97
|
+
*/
|
|
98
|
+
function setModel(model) {
|
|
99
|
+
self.removeAllChildren();
|
|
100
|
+
|
|
101
|
+
if (model === null) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
self.addChild(new LabelView('Auras:'));
|
|
106
|
+
|
|
107
|
+
const vList = new ListView(model.auras, {
|
|
108
|
+
classList: ['auras'],
|
|
109
|
+
elementFactory(aura) {
|
|
110
|
+
|
|
111
|
+
const elementController = new AuraController({
|
|
112
|
+
aura,
|
|
113
|
+
localization,
|
|
114
|
+
requestRemoval() {
|
|
115
|
+
model.auras.removeOneOf(aura);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
return elementController;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
self.addChild(vList);
|
|
124
|
+
|
|
125
|
+
self.addChild(makeAuraAdder(model, afflictionDatabase));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this.model.onChanged.add(setModel);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import GuiControl from "../../../../../src/view/controller/controls/GuiControl.js";
|
|
2
|
+
import EmptyView from "../../../../../src/view/elements/EmptyView.js";
|
|
3
|
+
import LabelView from "../../../../../src/view/common/LabelView.js";
|
|
4
|
+
import { PointerDevice } from "../../../../../src/engine/input/devices/PointerDevice.js";
|
|
5
|
+
import { AutoCanvasView } from "../common/AutoCanvasView.js";
|
|
6
|
+
import { clamp01 } from "../../../../../src/core/math/clamp01.js";
|
|
7
|
+
|
|
8
|
+
export class GaugeView extends GuiControl {
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {string} name
|
|
12
|
+
* @param {function} draw
|
|
13
|
+
* @param {string[]} classList
|
|
14
|
+
* @constructor
|
|
15
|
+
*/
|
|
16
|
+
constructor({ name, draw, classList = [] }) {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
this.el.classList.add('gauge-view');
|
|
20
|
+
classList.forEach(c => this.addClass(c));
|
|
21
|
+
|
|
22
|
+
const self = this;
|
|
23
|
+
|
|
24
|
+
const vMark = new EmptyView();
|
|
25
|
+
vMark.el.classList.add('mark-view');
|
|
26
|
+
|
|
27
|
+
const c = new AutoCanvasView();
|
|
28
|
+
|
|
29
|
+
c.draw = function (ctx, width, height) {
|
|
30
|
+
|
|
31
|
+
const model = self.model.getValue();
|
|
32
|
+
|
|
33
|
+
const value = model !== null ? model.x : 0;
|
|
34
|
+
|
|
35
|
+
draw(ctx, value, self, width, height);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const vGauge = new EmptyView({ classList: ['gauge'] });
|
|
39
|
+
vGauge.addChild(c);
|
|
40
|
+
vGauge.addChild(vMark);
|
|
41
|
+
|
|
42
|
+
const vName = new LabelView(name);
|
|
43
|
+
this.addChild(vName);
|
|
44
|
+
this.addChild(vGauge);
|
|
45
|
+
|
|
46
|
+
function updateMark() {
|
|
47
|
+
const model = self.model.getValue();
|
|
48
|
+
|
|
49
|
+
const value = model !== null ? model.x : 0;
|
|
50
|
+
|
|
51
|
+
vMark.el.style.left = `${value * 100}%`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function update() {
|
|
55
|
+
c.render();
|
|
56
|
+
|
|
57
|
+
updateMark();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.render = update;
|
|
61
|
+
|
|
62
|
+
this.model.onChanged.add(function (color, oldColor) {
|
|
63
|
+
update();
|
|
64
|
+
|
|
65
|
+
if (color !== null) {
|
|
66
|
+
color.onChanged.add(update);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (oldColor !== null) {
|
|
70
|
+
oldColor.onChanged.remove(update);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
function setValue(v) {
|
|
77
|
+
const model = self.model.getValue();
|
|
78
|
+
|
|
79
|
+
if (model === null) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
model.set(clamp01(v));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function setValueFromMouseEvent(event) {
|
|
87
|
+
|
|
88
|
+
const offsetX = event.offsetX;
|
|
89
|
+
|
|
90
|
+
setValue(offsetX / c.el.width);
|
|
91
|
+
|
|
92
|
+
update();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const pD = new PointerDevice(c.el);
|
|
96
|
+
|
|
97
|
+
pD.start();
|
|
98
|
+
|
|
99
|
+
pD.on.down.add(function (position, event) {
|
|
100
|
+
setValueFromMouseEvent(event);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
pD.on.drag.add(function (position, origin, previousPosition, mouseEvent) {
|
|
104
|
+
setValueFromMouseEvent(mouseEvent);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|