@woosh/meep-engine 2.46.29 → 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
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
2
|
+
import { assert } from "../../../src/core/assert.js";
|
|
3
|
+
import { texture_array_2d_copy } from "../../../src/engine/graphics/texture/texture_array_2d_copy.js";
|
|
4
|
+
import { clamp } from "../../../src/core/math/clamp.js";
|
|
5
|
+
|
|
6
|
+
export class ModifyPatchTextureArray2DAction extends Action {
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {number[]|Uint8Array|Uint32Array|Float32Array} data
|
|
10
|
+
* @param {number[]} data_resolution
|
|
11
|
+
* @param {number[]} bounds
|
|
12
|
+
*/
|
|
13
|
+
constructor(data, data_resolution, bounds) {
|
|
14
|
+
super();
|
|
15
|
+
|
|
16
|
+
assert.isArrayLike(data, 'data');
|
|
17
|
+
|
|
18
|
+
this.__data = data;
|
|
19
|
+
this.__data_resolution = data_resolution;
|
|
20
|
+
this.__bounds = bounds;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const width = this.__bounds[2] - this.__bounds[0];
|
|
24
|
+
const height = this.__bounds[3] - this.__bounds[1];
|
|
25
|
+
|
|
26
|
+
const depth = data_resolution[2];
|
|
27
|
+
|
|
28
|
+
const CTOR = Object.getPrototypeOf(data).constructor;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @type {ArrayLike<number>}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
this.__patch_new = new CTOR(height * width * depth);
|
|
35
|
+
/**
|
|
36
|
+
* @type {ArrayLike<number>}
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
this.__patch_old = new CTOR(height * width * depth);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @param {number} center_x
|
|
45
|
+
* @param {number} center_y
|
|
46
|
+
* @param {Sampler2D} stamp
|
|
47
|
+
* @param {number} layer_index
|
|
48
|
+
* @param {number} weight
|
|
49
|
+
* @param {number} clamp_min
|
|
50
|
+
* @param {number} clamp_max
|
|
51
|
+
*/
|
|
52
|
+
applyWeightStampToLayer(
|
|
53
|
+
center_x, center_y,
|
|
54
|
+
stamp, layer_index, weight,
|
|
55
|
+
clamp_min = Number.NEGATIVE_INFINITY, clamp_max = Number.POSITIVE_INFINITY
|
|
56
|
+
) {
|
|
57
|
+
|
|
58
|
+
const bounds_x0 = this.__bounds[0];
|
|
59
|
+
const bounds_y0 = this.__bounds[1];
|
|
60
|
+
|
|
61
|
+
const bounds_x1 = this.__bounds[2];
|
|
62
|
+
const bounds_y1 = this.__bounds[3];
|
|
63
|
+
|
|
64
|
+
const width = bounds_x1 - bounds_x0;
|
|
65
|
+
const height = bounds_y1 - bounds_y0;
|
|
66
|
+
|
|
67
|
+
const center_offset_x = (bounds_x0 + bounds_x1) * 0.5 - center_x;
|
|
68
|
+
const center_offset_y = (bounds_y0 + bounds_y1) * 0.5 - center_y;
|
|
69
|
+
|
|
70
|
+
const source_data = this.__data;
|
|
71
|
+
|
|
72
|
+
const source_width = this.__data_resolution[0];
|
|
73
|
+
const source_height = this.__data_resolution[1];
|
|
74
|
+
const depth = this.__data_resolution[2];
|
|
75
|
+
|
|
76
|
+
for (let y = 0; y < height; y++) {
|
|
77
|
+
const marker_v = (y + center_offset_y) / (height - 1);
|
|
78
|
+
|
|
79
|
+
for (let x = 0; x < width; x++) {
|
|
80
|
+
const marker_u = (x + center_offset_x) / (width - 1);
|
|
81
|
+
|
|
82
|
+
const stamp_value = stamp.sampleChannelBilinearUV(marker_u, marker_v, 3);
|
|
83
|
+
|
|
84
|
+
if (Number.isNaN(stamp_value)) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const weighed_stamp_value = stamp_value * weight;
|
|
89
|
+
|
|
90
|
+
const source_x = (x + bounds_x0);
|
|
91
|
+
const source_y = (y + bounds_y0);
|
|
92
|
+
|
|
93
|
+
const weight_reciprocal = weighed_stamp_value / (depth - 1);
|
|
94
|
+
|
|
95
|
+
for (let i = 0; i < depth; i++) {
|
|
96
|
+
const source_layer_address = source_width * source_height * i;
|
|
97
|
+
const source_texel_address = source_layer_address + source_y * source_width + source_x;
|
|
98
|
+
|
|
99
|
+
const destination_texel_address = width * height * i + y * width + x;
|
|
100
|
+
|
|
101
|
+
const source_value = source_data[source_texel_address];
|
|
102
|
+
|
|
103
|
+
let destination_value;
|
|
104
|
+
if (i === layer_index) {
|
|
105
|
+
// the channel that we are stamping
|
|
106
|
+
destination_value = source_value + weighed_stamp_value;
|
|
107
|
+
} else {
|
|
108
|
+
destination_value = source_value - weight_reciprocal;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
this.__patch_new[destination_texel_address] = clamp(destination_value, clamp_min, clamp_max);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
get patch_data() {
|
|
118
|
+
return this.__patch_new;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
computeByteSize() {
|
|
122
|
+
// TODO take size of array elements into account
|
|
123
|
+
return this.__patch_new.length + this.__patch_old.length + 280;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
async apply(context) {
|
|
127
|
+
const data = this.__data;
|
|
128
|
+
|
|
129
|
+
const depth = this.__data_resolution[2];
|
|
130
|
+
|
|
131
|
+
const bounds_x0 = this.__bounds[0];
|
|
132
|
+
const bounds_y0 = this.__bounds[1];
|
|
133
|
+
|
|
134
|
+
const bounds_x1 = this.__bounds[2];
|
|
135
|
+
const bounds_y1 = this.__bounds[3];
|
|
136
|
+
|
|
137
|
+
const width = bounds_x1 - bounds_x0;
|
|
138
|
+
const height = bounds_y1 - bounds_y0;
|
|
139
|
+
|
|
140
|
+
const source_resolution_x = this.__data_resolution[0];
|
|
141
|
+
const source_resolution_y = this.__data_resolution[1];
|
|
142
|
+
|
|
143
|
+
// store old data
|
|
144
|
+
texture_array_2d_copy(
|
|
145
|
+
data, bounds_x0, bounds_y0, source_resolution_x, source_resolution_y,
|
|
146
|
+
this.__patch_old, 0, 0, width, height,
|
|
147
|
+
width, height, depth
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
texture_array_2d_copy(
|
|
151
|
+
this.__patch_new, 0, 0, width, height,
|
|
152
|
+
data, bounds_x0, bounds_y0, source_resolution_x, source_resolution_y,
|
|
153
|
+
width, height, depth
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async revert(context) {
|
|
159
|
+
|
|
160
|
+
const data = this.__data;
|
|
161
|
+
|
|
162
|
+
const depth = this.__data_resolution[2];
|
|
163
|
+
|
|
164
|
+
const bounds_x0 = this.__bounds[0];
|
|
165
|
+
const bounds_y0 = this.__bounds[1];
|
|
166
|
+
|
|
167
|
+
const bounds_x1 = this.__bounds[2];
|
|
168
|
+
const bounds_y1 = this.__bounds[3];
|
|
169
|
+
|
|
170
|
+
const width = bounds_x1 - bounds_x0;
|
|
171
|
+
const height = bounds_y1 - bounds_y0;
|
|
172
|
+
|
|
173
|
+
const source_resolution_x = this.__data_resolution[0];
|
|
174
|
+
const source_resolution_y = this.__data_resolution[1];
|
|
175
|
+
|
|
176
|
+
texture_array_2d_copy(
|
|
177
|
+
this.__patch_old, 0, 0, width, height,
|
|
178
|
+
data, bounds_x0, bounds_y0, source_resolution_x, source_resolution_y,
|
|
179
|
+
width, height, depth
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Vector4 from "../../../src/core/geom/Vector4.js";
|
|
2
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
3
|
+
import { obtainTerrain } from "../../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
4
|
+
|
|
5
|
+
class PaintTerrainOverlayAction extends Action {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {number} entity
|
|
9
|
+
* @param {number} x
|
|
10
|
+
* @param {number} y
|
|
11
|
+
* @param {Vector4} color
|
|
12
|
+
* @constructor
|
|
13
|
+
*/
|
|
14
|
+
constructor(entity, x, y, color) {
|
|
15
|
+
super();
|
|
16
|
+
this.entity = entity;
|
|
17
|
+
this.x = x;
|
|
18
|
+
this.y = y;
|
|
19
|
+
this.color = color;
|
|
20
|
+
|
|
21
|
+
this.overlay = null;
|
|
22
|
+
this.oldColor = new Vector4();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async apply(editor) {
|
|
26
|
+
const terrain = obtainTerrain(editor.engine.entityManager.dataset);
|
|
27
|
+
const overlay = this.overlay = terrain.overlay;
|
|
28
|
+
|
|
29
|
+
//remember old color
|
|
30
|
+
overlay.readPoint(this.x, this.y, this.oldColor);
|
|
31
|
+
|
|
32
|
+
overlay.clearPoint(this.x, this.y);
|
|
33
|
+
overlay.paintPoint(this.x, this.y, this.color);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async revert(editor) {
|
|
37
|
+
const overlay = this.overlay;
|
|
38
|
+
|
|
39
|
+
overlay.clearPoint(this.x, this.y);
|
|
40
|
+
overlay.paintPoint(this.x, this.y, this.oldColor);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
export default PaintTerrainOverlayAction;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ModifyPatchSampler2DAction } from "./ModifyPatchSampler2DAction.js";
|
|
2
|
+
|
|
3
|
+
export class PatchTerrainHeightAction extends ModifyPatchSampler2DAction {
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Terrain} terrain
|
|
7
|
+
* @param {number} x
|
|
8
|
+
* @param {number} y
|
|
9
|
+
* @param {number} width
|
|
10
|
+
* @param {number} height
|
|
11
|
+
*/
|
|
12
|
+
constructor(terrain, x, y, width, height) {
|
|
13
|
+
super(terrain.samplerHeight, [x, y, x + width, y + height]);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @type {Terrain}
|
|
18
|
+
*/
|
|
19
|
+
this.terrain = terrain;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async updateTerrain() {
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @type {Terrain}
|
|
26
|
+
*/
|
|
27
|
+
const terrain = this.terrain;
|
|
28
|
+
|
|
29
|
+
terrain.updateHeightTexture();
|
|
30
|
+
terrain.updateWorkerHeights();
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @type {Sampler2D}
|
|
35
|
+
*/
|
|
36
|
+
const heightMap = terrain.samplerHeight;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @type {TerrainTileManager}
|
|
41
|
+
*/
|
|
42
|
+
const tiles = terrain.__tiles;
|
|
43
|
+
|
|
44
|
+
const x = this.x;
|
|
45
|
+
const y = this.y;
|
|
46
|
+
|
|
47
|
+
const u0 = x / heightMap.width;
|
|
48
|
+
const u1 = (x + this.patch.width) / heightMap.height;
|
|
49
|
+
|
|
50
|
+
const v0 = y / heightMap.height;
|
|
51
|
+
const v1 = (y + this.patch.height) / heightMap.height;
|
|
52
|
+
|
|
53
|
+
tiles.rebuildTilesByUV(u0, v0, u1, v1);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
async apply(context) {
|
|
57
|
+
await super.apply(context);
|
|
58
|
+
|
|
59
|
+
await this.updateTerrain();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async revert(context) {
|
|
63
|
+
await super.revert(context);
|
|
64
|
+
|
|
65
|
+
await this.updateTerrain();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { max2 } from "../../../src/core/math/max2.js";
|
|
2
|
+
import { min2 } from "../../../src/core/math/min2.js";
|
|
3
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
4
|
+
import { Sampler2D } from "../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
|
+
|
|
6
|
+
export class PatchTerrainTextureAction extends Action {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {Terrain} terrain
|
|
11
|
+
* @param {number} x
|
|
12
|
+
* @param {number} y
|
|
13
|
+
* @param {number} width
|
|
14
|
+
* @param {number} height
|
|
15
|
+
*/
|
|
16
|
+
constructor(terrain, x, y, width, height) {
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @type {Terrain}
|
|
22
|
+
*/
|
|
23
|
+
this.terrain = terrain;
|
|
24
|
+
|
|
25
|
+
const depth = terrain.splat.depth;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @type {Uint8Array}
|
|
30
|
+
*/
|
|
31
|
+
this.patchWeight = new Uint8Array(width * height * depth);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @type {Sampler2D}
|
|
36
|
+
*/
|
|
37
|
+
this.patchMaterial = Sampler2D.uint8(4, width, height);
|
|
38
|
+
|
|
39
|
+
this.x = x;
|
|
40
|
+
this.y = y;
|
|
41
|
+
|
|
42
|
+
this.width = width;
|
|
43
|
+
this.height = height;
|
|
44
|
+
|
|
45
|
+
this.__oldPatchWeight = new Uint8Array(width * height * depth);
|
|
46
|
+
this.__oldPatchMaterial = Sampler2D.uint8(4, width, height);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {number[]|Uint8Array|Float32Array} source
|
|
52
|
+
* @param {number} sourceWidth
|
|
53
|
+
* @param {number} sourceHeight
|
|
54
|
+
*/
|
|
55
|
+
readWeights(source, sourceWidth, sourceHeight) {
|
|
56
|
+
const depth = this.terrain.splat.depth;
|
|
57
|
+
|
|
58
|
+
const destinationWidth = this.width;
|
|
59
|
+
const destinationHeight = this.height;
|
|
60
|
+
|
|
61
|
+
const sourceX = this.x;
|
|
62
|
+
const sourceY = this.y;
|
|
63
|
+
|
|
64
|
+
const sourceLayerSize = sourceWidth * sourceHeight;
|
|
65
|
+
const destinationLayerSize = destinationWidth * destinationHeight;
|
|
66
|
+
|
|
67
|
+
const _w = max2(0, min2(destinationWidth, sourceWidth - sourceX));
|
|
68
|
+
const _h = max2(0, min2(destinationHeight, sourceHeight - sourceY));
|
|
69
|
+
|
|
70
|
+
const destination = this.patchWeight;
|
|
71
|
+
|
|
72
|
+
for (let i = 0; i < depth; i++) {
|
|
73
|
+
|
|
74
|
+
const dLayerAddress = destinationLayerSize * i;
|
|
75
|
+
const sLayerAddress = sourceLayerSize * i;
|
|
76
|
+
|
|
77
|
+
for (let y = 0; y < _h; y++) {
|
|
78
|
+
const dRowAddress = y * destinationWidth + dLayerAddress;
|
|
79
|
+
|
|
80
|
+
const sRowAddress = (y + sourceY) * sourceWidth + sLayerAddress;
|
|
81
|
+
|
|
82
|
+
for (let x = 0; x < _w; x++) {
|
|
83
|
+
const dAddress = dRowAddress + x;
|
|
84
|
+
|
|
85
|
+
const sAddress = sRowAddress + x + sourceX;
|
|
86
|
+
|
|
87
|
+
destination[dAddress] = source[sAddress];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
updateTerrain() {
|
|
95
|
+
|
|
96
|
+
this.terrain.splat.materialTexture.needsUpdate = true;
|
|
97
|
+
this.terrain.splat.weightTexture.needsUpdate = true;
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async apply(context) {
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
* @type {Terrain}
|
|
106
|
+
*/
|
|
107
|
+
const terrain = this.terrain;
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
const splat = terrain.splat;
|
|
111
|
+
|
|
112
|
+
const samplerMaterials = splat.materialSampler;
|
|
113
|
+
|
|
114
|
+
//store old data from the patch
|
|
115
|
+
splat.readWeightData(this.__oldPatchWeight, this.x, this.y, this.width, this.height);
|
|
116
|
+
|
|
117
|
+
const oldPatchMaterial = this.__oldPatchMaterial;
|
|
118
|
+
oldPatchMaterial.copy_sameItemSize(samplerMaterials, this.x, this.y, 0, 0, oldPatchMaterial.width, oldPatchMaterial.height);
|
|
119
|
+
|
|
120
|
+
//apply the patch
|
|
121
|
+
splat.writeWeightData(this.patchWeight, this.x, this.y, this.width, this.height);
|
|
122
|
+
|
|
123
|
+
const patchMaterial = this.patchMaterial;
|
|
124
|
+
samplerMaterials.copy_sameItemSize(patchMaterial, 0, 0, this.x, this.y, patchMaterial.width, patchMaterial.height);
|
|
125
|
+
|
|
126
|
+
this.updateTerrain();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
async revert(context) {
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
* @type {Terrain}
|
|
133
|
+
*/
|
|
134
|
+
const terrain = this.terrain;
|
|
135
|
+
|
|
136
|
+
const splat = terrain.splat;
|
|
137
|
+
|
|
138
|
+
const samplerMaterials = new Sampler2D(splat.materialData, 4, splat.size.x, splat.size.y);
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
//apply the patch
|
|
142
|
+
splat.writeWeightData(this.__oldPatchWeight, this.x, this.y, this.width, this.height);
|
|
143
|
+
|
|
144
|
+
const patchMaterial = this.__oldPatchMaterial;
|
|
145
|
+
samplerMaterials.copy_sameItemSize(patchMaterial, 0, 0, this.x, this.y, patchMaterial.width, patchMaterial.height);
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
this.updateTerrain();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Alex on 16/01/2017.
|
|
3
|
+
*/
|
|
4
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class SelectionAddAction extends Action {
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {int[]} entities
|
|
11
|
+
* @constructor
|
|
12
|
+
*/
|
|
13
|
+
constructor(entities) {
|
|
14
|
+
super();
|
|
15
|
+
this.oldState = null;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @type {int[]}
|
|
19
|
+
*/
|
|
20
|
+
this.entities = entities;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async apply(editor) {
|
|
24
|
+
this.oldState = editor.selection.clone();
|
|
25
|
+
|
|
26
|
+
const selection = editor.selection;
|
|
27
|
+
|
|
28
|
+
selection.addAllUnique(this.entities);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
async revert(editor) {
|
|
32
|
+
editor.selection.copy(this.oldState);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default SelectionAddAction;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
2
|
+
|
|
3
|
+
class SelectionClearAction extends Action {
|
|
4
|
+
/**
|
|
5
|
+
* Created by Alex on 16/01/2017.
|
|
6
|
+
*/
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
this.oldState = null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async apply(editor) {
|
|
13
|
+
this.oldState = editor.selection.clone();
|
|
14
|
+
editor.selection.reset();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async revert(editor) {
|
|
18
|
+
editor.selection.copy(this.oldState);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default SelectionClearAction;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
2
|
+
|
|
3
|
+
class SelectionRemoveAction extends Action {
|
|
4
|
+
/**
|
|
5
|
+
* Created by Alex on 16/01/2017.
|
|
6
|
+
*/
|
|
7
|
+
constructor(entities) {
|
|
8
|
+
super();
|
|
9
|
+
this.oldState = null;
|
|
10
|
+
this.entities = entities;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
async apply(editor) {
|
|
14
|
+
const selection = editor.selection;
|
|
15
|
+
this.oldState = selection.clone();
|
|
16
|
+
for (let i = 0; i < this.entities.length; i++) {
|
|
17
|
+
const entity = this.entities[i];
|
|
18
|
+
const index = selection.indexOf(entity);
|
|
19
|
+
if (index !== -1) {
|
|
20
|
+
selection.remove(index);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async revert(editor) {
|
|
26
|
+
editor.selection.copy(this.oldState);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default SelectionRemoveAction;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
2
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
3
|
+
|
|
4
|
+
class TransformModifyAction extends Action {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param entity
|
|
8
|
+
* @param {Transform} modified
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
constructor(entity, modified) {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.oldState = null;
|
|
15
|
+
this.modified = modified;
|
|
16
|
+
this.entity = entity;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
computeByteSize() {
|
|
20
|
+
return 280;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {Editor} editor
|
|
26
|
+
*/
|
|
27
|
+
async apply(editor) {
|
|
28
|
+
const entityManager = editor.engine.entityManager;
|
|
29
|
+
|
|
30
|
+
const component = entityManager.getComponent(this.entity, Transform);
|
|
31
|
+
|
|
32
|
+
this.oldState = component.clone();
|
|
33
|
+
|
|
34
|
+
component.copy(this.modified);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async revert(editor) {
|
|
38
|
+
const entityManager = editor.engine.entityManager;
|
|
39
|
+
|
|
40
|
+
const component = entityManager.getComponent(this.entity, Transform);
|
|
41
|
+
|
|
42
|
+
component.copy(this.oldState);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default TransformModifyAction;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import GridField from "../../../src/engine/navigation/grid/GridField.js";
|
|
2
|
+
import GridObstacle from "../../../src/engine/grid/components/GridObstacle.js";
|
|
3
|
+
import { Action } from "../../../src/core/process/undo/Action.js";
|
|
4
|
+
|
|
5
|
+
class WriteGridValueAction extends Action {
|
|
6
|
+
constructor(entity, x, y, value) {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.entity = entity;
|
|
10
|
+
this.x = x;
|
|
11
|
+
this.y = y;
|
|
12
|
+
this.value = value;
|
|
13
|
+
|
|
14
|
+
this.obstacle = null;
|
|
15
|
+
this.oldValue = null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async apply(editor) {
|
|
19
|
+
const obstacle = editor.engine.entityManager.getComponent(this.entity, GridObstacle);
|
|
20
|
+
this.obstacle = obstacle;
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
const gridField = obstacle2grid(obstacle);
|
|
24
|
+
|
|
25
|
+
this.oldValue = gridField.read(this.x, this.y);
|
|
26
|
+
gridField.pointSet(this.x, this.y, this.value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async revert(editor) {
|
|
30
|
+
const gridField = obstacle2grid(this.obstacle);
|
|
31
|
+
|
|
32
|
+
gridField.pointSet(this.x, this.y, this.oldValue);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function obstacle2grid(obstacle) {
|
|
37
|
+
const gridField = new GridField();
|
|
38
|
+
|
|
39
|
+
gridField.width = obstacle.size.x;
|
|
40
|
+
gridField.height = obstacle.size.y;
|
|
41
|
+
gridField.data = obstacle.data;
|
|
42
|
+
|
|
43
|
+
return gridField;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default WriteGridValueAction;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marker component to distinguish editor-owned entities
|
|
3
|
+
* @constructor
|
|
4
|
+
*/
|
|
5
|
+
function EditorEntity({ referenceEntity = -1 } = {}) {
|
|
6
|
+
this.referenceEntity = referenceEntity;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
EditorEntity.typeName = "EditorEntity";
|
|
10
|
+
EditorEntity.serializable = false;
|
|
11
|
+
|
|
12
|
+
export default EditorEntity;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { System } from "../../src/engine/ecs/System.js";
|
|
2
|
+
import EditorEntity from "./EditorEntity.js";
|
|
3
|
+
|
|
4
|
+
class EditorEntitySystem extends System {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.dependencies = [EditorEntity];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
export default EditorEntitySystem;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
*/
|
|
4
|
+
export class FieldDescriptor {
|
|
5
|
+
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
this.name = "";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* typeof field
|
|
14
|
+
* @type {Class<T>}
|
|
15
|
+
*/
|
|
16
|
+
this.type = null;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {FieldValueAdapter|null}
|
|
21
|
+
*/
|
|
22
|
+
this.adapter = null;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {{}|undefined}
|
|
27
|
+
*/
|
|
28
|
+
this.schema = undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
toString() {
|
|
32
|
+
return `FieldDescriptor[name='${this.name}']`;
|
|
33
|
+
}
|
|
34
|
+
}
|