@woosh/meep-engine 2.37.16 → 2.37.19
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/core/assert.js +16 -2
- package/core/collection/array/typed/isTypedArray.js +20 -0
- package/core/collection/array/typedArrayToDataType.js +2 -1
- package/core/collection/table/RowFirstTable.js +34 -0
- package/core/collection/table/RowFirstTable.spec.js +59 -1
- package/core/color/Color.js +14 -0
- package/core/color/rgb2hex.js +1 -1
- package/core/events/signal/Signal.js +8 -8
- package/core/events/signal/Signal.spec.js +16 -0
- package/core/geom/Quaternion.d.ts +5 -0
- package/core/geom/Quaternion.js +152 -137
- package/core/geom/Quaternion.spec.js +47 -2
- package/core/geom/Vector3.schema.json +16 -0
- package/core/json/JsonUtils.js +2 -20
- package/core/model/ObservedEnum.js +8 -0
- package/editor/Editor.js +97 -1
- package/editor/actions/concrete/PatchTerrainHeightAction.js +1 -1
- 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 +90 -0
- package/editor/ecs/component/createObjectEditor.js +242 -60
- 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 +50 -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 +60 -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 +44 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +54 -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 +42 -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 +56 -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 +25 -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 +32 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/view/EditorView.js +1 -1
- package/editor/view/ecs/ComponentControlView.js +2 -30
- package/editor/view/ecs/EntityEditor.js +61 -139
- package/editor/view/ecs/components/GridObstacleController.js +4 -4
- package/editor/view/ecs/components/TerrainController.js +1 -1
- package/editor/view/ecs/components/common/NumberController.js +19 -7
- package/engine/animation/keyed2/AnimationTrack.js +1 -1
- package/engine/asset/AssetManager.js +1 -1
- package/engine/ecs/EntityBlueprint.js +1 -1
- package/engine/ecs/EntityBuilder.js +2 -2
- package/engine/ecs/EntityManager.js +1 -1
- package/engine/ecs/components/TagEditor.js +15 -0
- package/engine/ecs/parent/EntityNode.js +3 -0
- package/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter.js +1 -1
- package/engine/ecs/terrain/ecs/Terrain.js +23 -42
- package/engine/ecs/terrain/ecs/TerrainSystem.js +2 -2
- package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +1 -1
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +1 -1
- package/engine/ecs/transform/Transform.editor.schema.json +16 -0
- package/engine/ecs/transform/Transform.js +3 -0
- package/engine/ecs/util/hideEntityGracefully.js +4 -2
- package/engine/graphics/ecs/highlight/HighlightEditor.js +17 -0
- package/engine/graphics/ecs/mesh/MeshEditor.js +28 -0
- package/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +3 -3
- package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +15 -15
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +5 -0
- package/engine/graphics/texture/sampler/Sampler2D.js +16 -0
- package/engine/graphics/util/ScaleObject3ToBox.js +14 -1
- package/engine/graphics/util/makeMeshPreviewScene.js +2 -1
- package/engine/grid/components/GridObstacle.js +0 -44
- package/engine/grid/components/GridObstacleSerializationAdapter.js +46 -0
- package/engine/knowledge/database/StaticKnowledgeDatabase.js +1 -1
- package/engine/navigation/ecs/components/Path.d.ts +2 -0
- package/engine/navigation/ecs/components/Path.js +6 -1
- package/engine/sound/material/concrete/json/serializeSoundMaterialToJSON.js +1 -1
- package/generation/example/SampleGenerator0.js +33 -29
- package/generation/example/generators/interactive/mir_generator_place_buff_objects.js +7 -6
- package/generation/example/generators/mir_generator_place_bases.js +7 -3
- package/generation/example/generators/mir_generator_place_road_decorators.js +3 -3
- package/generation/example/generators/mir_generator_place_starting_point.js +3 -2
- package/generation/markers/GridCellActionPlaceMarker.js +9 -3
- package/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -1
- package/generation/placement/GridCellPlacementRule.js +22 -23
- package/generation/theme/ThemeEngine.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/main.js +1 -1
- package/view/View.js +23 -1
- package/view/common/LabelView.js +1 -1
- package/view/compose3x3transform.js +32 -8
- package/view/controller/dat/DatGuiUtils.js +1 -1
- package/view/elements/DropDownSelectionView.js +11 -3
- package/view/elements/image/ImageView.js +3 -1
- package/core/model/ObservedReal.js +0 -55
- package/editor/ecs/component/ObjectEditor.js +0 -0
|
@@ -9,89 +9,14 @@ import ObservedValue from '../../../core/model/ObservedValue.js';
|
|
|
9
9
|
import LabelView from '../../../view/common/LabelView.js';
|
|
10
10
|
import ButtonView from '../../../view/elements/button/ButtonView.js';
|
|
11
11
|
import DropDownSelectionView from '../../../view/elements/DropDownSelectionView.js';
|
|
12
|
-
|
|
13
|
-
import TransformController from './components/TransformController.js';
|
|
14
|
-
import MeshController from './components/MeshController.js';
|
|
15
|
-
import { datify } from "../../../view/controller/dat/DatGuiUtils.js";
|
|
16
12
|
import EmptyView from "../../../view/elements/EmptyView.js";
|
|
17
13
|
import { EntityManager, EventType } from "../../../engine/ecs/EntityManager.js";
|
|
18
|
-
import HighlightController from "./components/HighlightController.js";
|
|
19
|
-
import { GridPositionController } from "./components/GridPositionController.js";
|
|
20
|
-
import { ParticleEmitterController } from "./components/particles/ParticleEmitterController.js";
|
|
21
|
-
import { TerrainController } from "./components/TerrainController.js";
|
|
22
|
-
import { TagController } from "./components/TagController.js";
|
|
23
|
-
import { ItemContainerController } from "./components/items/ItemContainerController.js";
|
|
24
|
-
import { FogOfWarRevealerController } from "./components/FogOfWarRevealerController.js";
|
|
25
|
-
import { FogOfWarController } from "./components/FogOfWarController.js";
|
|
26
|
-
import { GeneratedArmyController } from "./components/GeneratedArmyController.js";
|
|
27
|
-
import { ArmyController } from "./components/army/ArmyController.js";
|
|
28
|
-
import { PathFollowerController } from "./components/PathFollowerController.js";
|
|
29
14
|
import ComponentRemoveAction from "../../actions/concrete/ComponentRemoveAction.js";
|
|
30
15
|
import ComponentAddAction from "../../actions/concrete/ComponentAddAction.js";
|
|
31
|
-
import { StoryTriggerSetController } from "./components/story/StoryTriggerSetController.js";
|
|
32
|
-
import { UnitShopController } from "./components/UnitShopController.js";
|
|
33
|
-
import { SoundEmitterController } from "./components/sound/SoundEmitterController.js";
|
|
34
|
-
import { GUIElementController } from "./components/gui/GUIElementController.js";
|
|
35
16
|
import { LineView } from "./components/common/LineView.js";
|
|
36
17
|
import { ComponentControlView } from "./ComponentControlView.js";
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import { GridObstacleController } from "./components/GridObstacleController.js";
|
|
40
|
-
import { AttachmentSocketsController } from "./components/sockets/AttachmentSocketsController.js";
|
|
41
|
-
import { ParticleEmitterSystem } from "../../../engine/graphics/particles/ecs/ParticleEmitterSystem.js";
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
*
|
|
45
|
-
* @param {ComponentControlFactory} factory
|
|
46
|
-
* @param {Editor} editor
|
|
47
|
-
*/
|
|
48
|
-
function prepareComponentFactory(factory, editor) {
|
|
49
|
-
factory
|
|
50
|
-
.register('Transform', () => new TransformController())
|
|
51
|
-
.register('Mesh', () => new MeshController(editor.engine.assetManager))
|
|
52
|
-
.register('GridPosition', () => new GridPositionController())
|
|
53
|
-
.register('Name', datify)
|
|
54
|
-
.register('Tag', () => new TagController())
|
|
55
|
-
.register('Team', datify)
|
|
56
|
-
.register('HeadsUpDisplay', () => new HeadsUpDisplayController())
|
|
57
|
-
.register('GeneratedArmy', () => new GeneratedArmyController())
|
|
58
|
-
.register('Army', () => new ArmyController({
|
|
59
|
-
localization: editor.engine.localization,
|
|
60
|
-
afflictionDatabase: editor.engine.staticKnowledge.afflictions
|
|
61
|
-
}))
|
|
62
|
-
.register('ClingToTerrain', datify)
|
|
63
|
-
.register('Commander', datify)
|
|
64
|
-
.register('MinimapMarker', datify)
|
|
65
|
-
.register('Camera', datify)
|
|
66
|
-
.register('FacingDirection', datify)
|
|
67
|
-
.register('GridObstacle', () => new GridObstacleController())
|
|
68
|
-
.register('Terrain', () => new TerrainController(editor.engine.assetManager))
|
|
69
|
-
.register('TopDownCameraController', datify)
|
|
70
|
-
.register('Light', datify)
|
|
71
|
-
.register('FogOfWar', () => new FogOfWarController(editor.engine.entityManager))
|
|
72
|
-
.register('FogOfWarRevealer', () => new FogOfWarRevealerController())
|
|
73
|
-
.register('PathFollower', () => new PathFollowerController())
|
|
74
|
-
.register('Highlight', () => new HighlightController())
|
|
75
|
-
.register('Blackboard', () => new BlackboardController())
|
|
76
|
-
.register('StoryTriggerSet', () => new StoryTriggerSetController())
|
|
77
|
-
.register('UnitShop', () => new UnitShopController())
|
|
78
|
-
.register('ItemContainer', () => new ItemContainerController({
|
|
79
|
-
localization: editor.engine.localization,
|
|
80
|
-
itemDatabase: editor.engine.staticKnowledge.items
|
|
81
|
-
}))
|
|
82
|
-
.register('ParticleEmitter', () => {
|
|
83
|
-
const em = editor.engine.entityManager;
|
|
84
|
-
|
|
85
|
-
const particleEmitterSystem = em.getSystem(ParticleEmitterSystem);
|
|
86
|
-
|
|
87
|
-
return new ParticleEmitterController(particleEmitterSystem);
|
|
88
|
-
})
|
|
89
|
-
.register('SoundEmitter', () => new SoundEmitterController(editor.engine))
|
|
90
|
-
.register('GUIElement', () => new GUIElementController())
|
|
91
|
-
.register('ViewportPosition', datify)
|
|
92
|
-
.register('AttachmentSockets', () => new AttachmentSocketsController())
|
|
93
|
-
;
|
|
94
|
-
}
|
|
18
|
+
import { buildObjectEditorFromRegistry } from "../../ecs/component/createObjectEditor.js";
|
|
19
|
+
import { isDefined } from "../../../core/process/matcher/Matchers.js";
|
|
95
20
|
|
|
96
21
|
|
|
97
22
|
class EntityEditor extends View {
|
|
@@ -122,7 +47,11 @@ class EntityEditor extends View {
|
|
|
122
47
|
|
|
123
48
|
const vComponentList = new EmptyView({ classList: ['component-list'] });
|
|
124
49
|
|
|
125
|
-
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @type {Map<any, TypeEditor>}
|
|
53
|
+
*/
|
|
54
|
+
const registry = editor.type_editor_registry;
|
|
126
55
|
|
|
127
56
|
/**
|
|
128
57
|
*
|
|
@@ -130,6 +59,14 @@ class EntityEditor extends View {
|
|
|
130
59
|
*/
|
|
131
60
|
this.componentControllers = new Map();
|
|
132
61
|
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @returns {EntityComponentDataset}
|
|
65
|
+
*/
|
|
66
|
+
function get_dataset() {
|
|
67
|
+
return self.entityManager.get().dataset;
|
|
68
|
+
}
|
|
69
|
+
|
|
133
70
|
function addComponent(event) {
|
|
134
71
|
if (event.instance === undefined) {
|
|
135
72
|
return;
|
|
@@ -153,13 +90,8 @@ class EntityEditor extends View {
|
|
|
153
90
|
}
|
|
154
91
|
|
|
155
92
|
function watchEntity(entity) {
|
|
156
|
-
/**
|
|
157
|
-
*
|
|
158
|
-
* @type {EntityManager}
|
|
159
|
-
*/
|
|
160
|
-
const entityManager = self.entityManager.get();
|
|
161
93
|
|
|
162
|
-
const dataset =
|
|
94
|
+
const dataset = get_dataset();
|
|
163
95
|
|
|
164
96
|
if (!dataset.entityExists(entity)) {
|
|
165
97
|
//doesn't exist, nothing to do
|
|
@@ -172,13 +104,8 @@ class EntityEditor extends View {
|
|
|
172
104
|
}
|
|
173
105
|
|
|
174
106
|
function unwatchEntity(entity) {
|
|
175
|
-
/**
|
|
176
|
-
*
|
|
177
|
-
* @type {EntityManager}
|
|
178
|
-
*/
|
|
179
|
-
const entityManager = self.entityManager.get();
|
|
180
107
|
|
|
181
|
-
const dataset =
|
|
108
|
+
const dataset = get_dataset();
|
|
182
109
|
|
|
183
110
|
if (!dataset.entityExists(entity)) {
|
|
184
111
|
//doesn't exist, nothing to do
|
|
@@ -198,13 +125,15 @@ class EntityEditor extends View {
|
|
|
198
125
|
|
|
199
126
|
self.components.reset();
|
|
200
127
|
|
|
201
|
-
const entityManager = self.entityManager.get();
|
|
202
128
|
|
|
203
129
|
/**
|
|
204
130
|
*
|
|
205
131
|
* @type {EntityComponentDataset}
|
|
206
132
|
*/
|
|
207
|
-
const dataset =
|
|
133
|
+
const dataset = get_dataset();
|
|
134
|
+
|
|
135
|
+
unattachedTypes.reset();
|
|
136
|
+
unattachedTypes.addAll(dataset.getComponentTypeMap().map(a => a.typeName).filter(isDefined));
|
|
208
137
|
|
|
209
138
|
const components = dataset.getAllComponents(entity);
|
|
210
139
|
components.forEach(function (c) {
|
|
@@ -221,74 +150,67 @@ class EntityEditor extends View {
|
|
|
221
150
|
|
|
222
151
|
const unattachedTypes = new List();
|
|
223
152
|
|
|
224
|
-
|
|
153
|
+
/**
|
|
154
|
+
* @template T
|
|
155
|
+
* @param {T} component
|
|
156
|
+
*/
|
|
157
|
+
function handleComponentAdded(component) {
|
|
158
|
+
let view;
|
|
159
|
+
|
|
160
|
+
try {
|
|
161
|
+
view = buildObjectEditorFromRegistry(component, registry);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
view = new LabelView(`ERROR: ${e.message}\n${e.stack}`);
|
|
164
|
+
|
|
165
|
+
console.warn('Failed to build editor', e);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (!view) {
|
|
169
|
+
view = new LabelView('EMPTY');
|
|
170
|
+
}
|
|
171
|
+
|
|
225
172
|
/**
|
|
226
173
|
*
|
|
227
174
|
* @type {EntityManager}
|
|
228
175
|
*/
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
//all systems
|
|
232
|
-
const allTypeNames = em.getComponentTypeMap()
|
|
233
|
-
.map(c => c.typeName)
|
|
234
|
-
.filter(typeName => typeof typeName === "string")
|
|
235
|
-
.sort();
|
|
236
|
-
|
|
237
|
-
function has(typeName) {
|
|
238
|
-
let result = false;
|
|
239
|
-
|
|
240
|
-
self.components.visitFirstMatch(c => c.constructor.typeName === typeName, () => result = true);
|
|
176
|
+
const entityManager = self.entityManager.getValue();
|
|
241
177
|
|
|
242
|
-
|
|
243
|
-
}
|
|
178
|
+
const entityId = self.model.getValue();
|
|
244
179
|
|
|
245
|
-
|
|
246
|
-
|
|
180
|
+
const vBody = new EmptyView({
|
|
181
|
+
classList: ['body']
|
|
182
|
+
});
|
|
183
|
+
vBody.addChild(view);
|
|
247
184
|
|
|
248
|
-
|
|
249
|
-
unattachedTypes.addAll(unattachedTypeNames);
|
|
250
|
-
}
|
|
185
|
+
const controlView = new ComponentControlView(entityId, component, entityManager, vBody);
|
|
251
186
|
|
|
252
|
-
/**
|
|
253
|
-
* @template T
|
|
254
|
-
* @param {T} component
|
|
255
|
-
*/
|
|
256
|
-
function handleComponentAdded(component) {
|
|
257
|
-
// console.log("handleComponentAdded",c);
|
|
258
187
|
const Klass = component.constructor;
|
|
259
|
-
if (!self.componentControllers.has(Klass)) {
|
|
260
|
-
/**
|
|
261
|
-
*
|
|
262
|
-
* @type {EntityManager}
|
|
263
|
-
*/
|
|
264
|
-
const entityManager = self.entityManager.getValue();
|
|
265
188
|
|
|
266
|
-
|
|
189
|
+
controlView.signal.remove.add(function () {
|
|
267
190
|
|
|
268
|
-
|
|
191
|
+
editor.actions.mark('Remove Component');
|
|
192
|
+
editor.actions.do(new ComponentRemoveAction(entityId, Klass));
|
|
193
|
+
});
|
|
269
194
|
|
|
270
|
-
controlView.signal.remove.add(function () {
|
|
271
195
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
});
|
|
196
|
+
vComponentList.addChild(controlView);
|
|
197
|
+
self.componentControllers.set(component, controlView);
|
|
275
198
|
|
|
199
|
+
unattachedTypes.removeOneOf(Klass.typeName);
|
|
276
200
|
|
|
277
|
-
self.componentControllers.set(Klass, controlView);
|
|
278
|
-
vComponentList.addChild(controlView);
|
|
279
|
-
}
|
|
280
|
-
updateList();
|
|
281
201
|
}
|
|
282
202
|
|
|
283
203
|
function handleComponentRemoved(c) {
|
|
284
204
|
// console.log("handleComponentRemoved",c);
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
self.componentControllers.delete(key);
|
|
205
|
+
if (self.componentControllers.has(c)) {
|
|
206
|
+
const controlView = self.componentControllers.get(c);
|
|
207
|
+
self.componentControllers.delete(c);
|
|
289
208
|
vComponentList.removeChild(controlView);
|
|
209
|
+
|
|
210
|
+
const Klass = c.constructor;
|
|
211
|
+
|
|
212
|
+
unattachedTypes.add(Klass.typeName);
|
|
290
213
|
}
|
|
291
|
-
updateList();
|
|
292
214
|
}
|
|
293
215
|
|
|
294
216
|
this.components.on.added.add(handleComponentAdded);
|
|
@@ -12,7 +12,7 @@ import Vector2 from "../../../../core/geom/Vector2.js";
|
|
|
12
12
|
* @param {GridObstacle} grid
|
|
13
13
|
* @param {HTMLCanvasElement} canvas
|
|
14
14
|
*/
|
|
15
|
-
function
|
|
15
|
+
export function buildGridObstaclePreview(grid, canvas) {
|
|
16
16
|
const source = new Sampler2D(grid.data, 1, grid.size.x, grid.size.y);
|
|
17
17
|
|
|
18
18
|
const target = Sampler2D.uint8(1, canvas.width, canvas.height);
|
|
@@ -43,7 +43,7 @@ export class GridObstacleController extends View {
|
|
|
43
43
|
|
|
44
44
|
vPreview.size.set(200, 200);
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
buildGridObstaclePreview(model, vPreview.el);
|
|
47
47
|
|
|
48
48
|
self.addChild(vPreview);
|
|
49
49
|
|
|
@@ -57,13 +57,13 @@ export class GridObstacleController extends View {
|
|
|
57
57
|
|
|
58
58
|
controller.add(proxy, 'size');
|
|
59
59
|
controller.addAction(() => {
|
|
60
|
-
|
|
60
|
+
buildGridObstaclePreview(model, vPreview.el);
|
|
61
61
|
}, 'update preview');
|
|
62
62
|
|
|
63
63
|
proxy.size.onChanged.add((x, y) => {
|
|
64
64
|
model.resize(x, y);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
buildGridObstaclePreview(model, vPreview.el);
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -5,17 +5,19 @@ export class NumberController extends View {
|
|
|
5
5
|
/**
|
|
6
6
|
*
|
|
7
7
|
* @param {string[]} [classList]
|
|
8
|
+
* @param {number} [value]
|
|
9
|
+
* @param figures
|
|
8
10
|
*/
|
|
9
|
-
constructor({ classList = [] } = {}) {
|
|
11
|
+
constructor({ classList = [], value = 0, figures = 6 } = {}) {
|
|
10
12
|
super();
|
|
11
13
|
|
|
12
|
-
const
|
|
14
|
+
const _value = new Vector1(value);
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
*
|
|
16
18
|
* @type {Vector1}
|
|
17
19
|
*/
|
|
18
|
-
this.value =
|
|
20
|
+
this.value = _value;
|
|
19
21
|
|
|
20
22
|
const el = document.createElement('input');
|
|
21
23
|
this.el = el;
|
|
@@ -23,6 +25,8 @@ export class NumberController extends View {
|
|
|
23
25
|
classList.forEach(c => this.addClass(c));
|
|
24
26
|
|
|
25
27
|
el.setAttribute('type', 'text');
|
|
28
|
+
el.setAttribute('spellcheck', false);
|
|
29
|
+
el.setAttribute('size', 2);
|
|
26
30
|
|
|
27
31
|
el.classList.add('ui-number-controller');
|
|
28
32
|
|
|
@@ -30,23 +34,31 @@ export class NumberController extends View {
|
|
|
30
34
|
|
|
31
35
|
function data2view() {
|
|
32
36
|
|
|
33
|
-
if(lockForward){
|
|
37
|
+
if (lockForward) {
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
|
|
41
|
+
const num_value = _value.getValue();
|
|
42
|
+
|
|
43
|
+
let str = num_value;
|
|
44
|
+
|
|
45
|
+
if (Math.abs(num_value) > 0 && Math.abs(num_value % 1).toString().length > (figures + 2)) {
|
|
46
|
+
str = num_value.toFixed(figures);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
el.value = str;
|
|
38
50
|
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
function view2data() {
|
|
42
54
|
lockForward = true;
|
|
43
55
|
|
|
44
|
-
|
|
56
|
+
_value.set(parseFloat(el.value));
|
|
45
57
|
|
|
46
58
|
lockForward = false;
|
|
47
59
|
}
|
|
48
60
|
|
|
49
|
-
|
|
61
|
+
_value.process(data2view);
|
|
50
62
|
|
|
51
63
|
el.addEventListener('input', view2data);
|
|
52
64
|
}
|
|
@@ -409,7 +409,7 @@ AssetManager.prototype.registerLoader = async function (type, loader) {
|
|
|
409
409
|
if (existing_loader === loader) {
|
|
410
410
|
// all is well, already registered
|
|
411
411
|
return existing_loader;
|
|
412
|
-
} else if (existing_loader
|
|
412
|
+
} else if (Object.getPrototypeOf(existing_loader) === Object.getPrototypeOf(loader)) {
|
|
413
413
|
console.warn(`Another instance of this loader is already registered for type '${type}'. Ignoring.`);
|
|
414
414
|
return existing_loader;
|
|
415
415
|
} else {
|
|
@@ -87,7 +87,7 @@ export class EntityBlueprint {
|
|
|
87
87
|
* @param {Object} component
|
|
88
88
|
*/
|
|
89
89
|
add(component) {
|
|
90
|
-
const constructor = component.
|
|
90
|
+
const constructor = Object.getPrototypeOf(component).constructor;
|
|
91
91
|
|
|
92
92
|
this.addJSON(constructor, component.toJSON());
|
|
93
93
|
}
|
|
@@ -118,7 +118,7 @@ class EntityBuilder {
|
|
|
118
118
|
for (let i = n - 1; i >= 0; i--) {
|
|
119
119
|
const component = elements[i];
|
|
120
120
|
|
|
121
|
-
this.removeComponent(component.
|
|
121
|
+
this.removeComponent(Object.getPrototypeOf(component).constructor);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -132,7 +132,7 @@ class EntityBuilder {
|
|
|
132
132
|
throw new Error("Can not add " + componentInstance + " to EntityBuilder");
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
assert.notOk(this.getComponent(componentInstance.
|
|
135
|
+
assert.notOk(this.getComponent(Object.getPrototypeOf(componentInstance).constructor) !== null, 'Component of this type already exists');
|
|
136
136
|
|
|
137
137
|
this.element.push(componentInstance);
|
|
138
138
|
|
|
@@ -478,7 +478,7 @@ EntityManager.prototype.addSystem = async function (system) {
|
|
|
478
478
|
assert.defined(system, "system");
|
|
479
479
|
assert.isInstanceOf(system, System, 'system', 'System');
|
|
480
480
|
|
|
481
|
-
const existing = this.getSystem(system.
|
|
481
|
+
const existing = this.getSystem(Object.getPrototypeOf(system).constructor);
|
|
482
482
|
|
|
483
483
|
if (existing !== null) {
|
|
484
484
|
if (existing === system) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ObjectEditor } from "../../../editor/ecs/component/editors/primitive/ObjectEditor.js";
|
|
2
|
+
|
|
3
|
+
export class TagEditor extends ObjectEditor {
|
|
4
|
+
get schema() {
|
|
5
|
+
return {
|
|
6
|
+
additionalProperties: false,
|
|
7
|
+
properties: {
|
|
8
|
+
values: {
|
|
9
|
+
type: Array,
|
|
10
|
+
type_parameters: [String]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -253,6 +253,7 @@ export class EntityNode {
|
|
|
253
253
|
* @param {EntityComponentDataset} ecd
|
|
254
254
|
*/
|
|
255
255
|
build(ecd) {
|
|
256
|
+
assert.notOk(this.__entity.isBuilt, 'Already built');
|
|
256
257
|
|
|
257
258
|
// assume that parent is built
|
|
258
259
|
const parent = this.__parent;
|
|
@@ -305,6 +306,8 @@ export class EntityNode {
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
destroy() {
|
|
309
|
+
assert.ok(this.__entity.isBuilt, 'Not built');
|
|
310
|
+
|
|
308
311
|
// remove listeners
|
|
309
312
|
this.__transform.position.onChanged.remove(this.__transform_sync_down, this);
|
|
310
313
|
this.__transform.scale.onChanged.remove(this.__transform_sync_down, this);
|
|
@@ -56,7 +56,7 @@ export class BinaryObjectSerializationAdapter {
|
|
|
56
56
|
if (className === undefined) {
|
|
57
57
|
//class name is not specified, try to infer it
|
|
58
58
|
|
|
59
|
-
const Klass = object.
|
|
59
|
+
const Klass = Object.getPrototypeOf(object).constructor;
|
|
60
60
|
|
|
61
61
|
const typeName = Klass.typeName;
|
|
62
62
|
|
|
@@ -173,16 +173,16 @@ class Terrain {
|
|
|
173
173
|
*
|
|
174
174
|
* @type {WorkerProxy}
|
|
175
175
|
*/
|
|
176
|
-
this.
|
|
176
|
+
this.__buildWorker = makeTerrainWorkerProxy();
|
|
177
177
|
|
|
178
|
-
this.
|
|
178
|
+
this.__tiles = new TerrainTileManager({
|
|
179
179
|
material: this.material,
|
|
180
|
-
buildWorker: this.
|
|
180
|
+
buildWorker: this.__buildWorker
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
this.
|
|
183
|
+
this.__tiles.tileSize.set(TILE_SIZE, TILE_SIZE);
|
|
184
184
|
|
|
185
|
-
this.
|
|
185
|
+
this.__tiles.material.set(this.material);
|
|
186
186
|
|
|
187
187
|
/**
|
|
188
188
|
*
|
|
@@ -285,7 +285,7 @@ class Terrain {
|
|
|
285
285
|
const material = material_handle.getValue();
|
|
286
286
|
this.clouds.addMaterial(material);
|
|
287
287
|
|
|
288
|
-
this.
|
|
288
|
+
this.__tiles.material.set(material);
|
|
289
289
|
|
|
290
290
|
this.updateMaterial();
|
|
291
291
|
|
|
@@ -314,7 +314,7 @@ class Terrain {
|
|
|
314
314
|
// release material handle
|
|
315
315
|
this.__material_reference.release();
|
|
316
316
|
|
|
317
|
-
this.
|
|
317
|
+
this.__tiles.dispose();
|
|
318
318
|
this.splat.dispose();
|
|
319
319
|
this.layers.dispose();
|
|
320
320
|
|
|
@@ -428,11 +428,11 @@ class Terrain {
|
|
|
428
428
|
* @returns {boolean}
|
|
429
429
|
*/
|
|
430
430
|
raycastFirstSync(result, originX, originY, originZ, directionX, directionY, directionZ) {
|
|
431
|
-
if (this.
|
|
431
|
+
if (this.__tiles === undefined) {
|
|
432
432
|
return false;
|
|
433
433
|
}
|
|
434
434
|
|
|
435
|
-
return this.
|
|
435
|
+
return this.__tiles.raycastFirstSync(result, originX, originY, originZ, directionX, directionY, directionZ);
|
|
436
436
|
}
|
|
437
437
|
|
|
438
438
|
/**
|
|
@@ -443,7 +443,7 @@ class Terrain {
|
|
|
443
443
|
* @param {function} missCallback
|
|
444
444
|
*/
|
|
445
445
|
raycast(origin, direction, callback, missCallback) {
|
|
446
|
-
this.
|
|
446
|
+
this.__tiles.raycast(origin, direction, callback, missCallback);
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
/**
|
|
@@ -459,7 +459,7 @@ class Terrain {
|
|
|
459
459
|
assert.typeOf(missCallback, 'function', 'missCallback');
|
|
460
460
|
assert.typeOf(errorCallback, 'function', 'errorCallback');
|
|
461
461
|
|
|
462
|
-
this.
|
|
462
|
+
this.__tiles.raycastVertical(x, y, callback, missCallback);
|
|
463
463
|
}
|
|
464
464
|
|
|
465
465
|
/**
|
|
@@ -470,12 +470,12 @@ class Terrain {
|
|
|
470
470
|
* @return {boolean}
|
|
471
471
|
*/
|
|
472
472
|
raycastVerticalFirstSync(contact, x, y) {
|
|
473
|
-
if (this.
|
|
473
|
+
if (this.__tiles === undefined) {
|
|
474
474
|
//tiles don't exist
|
|
475
475
|
return false;
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
return this.
|
|
478
|
+
return this.__tiles.raycastVerticalFirstSync(contact, x, y);
|
|
479
479
|
}
|
|
480
480
|
|
|
481
481
|
/**
|
|
@@ -643,7 +643,7 @@ class Terrain {
|
|
|
643
643
|
*
|
|
644
644
|
* @type {TerrainTileManager}
|
|
645
645
|
*/
|
|
646
|
-
const tiles = this.
|
|
646
|
+
const tiles = this.__tiles;
|
|
647
647
|
|
|
648
648
|
const promisedTiles = [];
|
|
649
649
|
|
|
@@ -660,25 +660,6 @@ class Terrain {
|
|
|
660
660
|
return Promise.all(promisedTiles);
|
|
661
661
|
}
|
|
662
662
|
|
|
663
|
-
/**
|
|
664
|
-
* @deprecated use {@link #samplerHeight} instead
|
|
665
|
-
* @param {Sampler2D} v
|
|
666
|
-
*/
|
|
667
|
-
set heightMap(v) {
|
|
668
|
-
this.samplerHeight = v;
|
|
669
|
-
this.updateHeightTexture();
|
|
670
|
-
|
|
671
|
-
console.warn('Deprecated');
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
/**
|
|
675
|
-
* @deprecated use {@link #samplerHeight} instead
|
|
676
|
-
* @return {Sampler2D}
|
|
677
|
-
*/
|
|
678
|
-
get heightMap() {
|
|
679
|
-
return this.samplerHeight;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
663
|
updateMaterial() {
|
|
683
664
|
let m = this.material;
|
|
684
665
|
|
|
@@ -753,24 +734,24 @@ class Terrain {
|
|
|
753
734
|
}
|
|
754
735
|
|
|
755
736
|
startBuildService() {
|
|
756
|
-
this.
|
|
737
|
+
this.__buildWorker.start();
|
|
757
738
|
this.updateWorkerHeights();
|
|
758
739
|
}
|
|
759
740
|
|
|
760
741
|
async updateWorkerHeights() {
|
|
761
742
|
const s = this.samplerHeight;
|
|
762
|
-
const worker = this.
|
|
743
|
+
const worker = this.__buildWorker;
|
|
763
744
|
|
|
764
745
|
await worker.setHeightSampler(s.data, s.itemSize, s.width, s.height);
|
|
765
746
|
|
|
766
747
|
return await worker.computeHeightRange()
|
|
767
748
|
.then(({ min, max }) => {
|
|
768
|
-
this.
|
|
749
|
+
this.__tiles.setHeightRange(min, max);
|
|
769
750
|
});
|
|
770
751
|
}
|
|
771
752
|
|
|
772
753
|
stopBuildService() {
|
|
773
|
-
this.
|
|
754
|
+
this.__buildWorker.stop();
|
|
774
755
|
}
|
|
775
756
|
|
|
776
757
|
buildGridTransform() {
|
|
@@ -816,9 +797,9 @@ class Terrain {
|
|
|
816
797
|
|
|
817
798
|
this.overlay.tileImage.set(MeepSettings.ecs.Terrain['tile-decal']);
|
|
818
799
|
|
|
819
|
-
this.
|
|
820
|
-
this.
|
|
821
|
-
this.
|
|
800
|
+
this.__tiles.totalSize.copy(this.size);
|
|
801
|
+
this.__tiles.scale.set(this.gridScale, this.gridScale);
|
|
802
|
+
this.__tiles.resolution.set(this.resolution);
|
|
822
803
|
|
|
823
804
|
if (this.__legacyMaterialSpec !== null) {
|
|
824
805
|
this.buildFromLegacy(assetManager);
|
|
@@ -855,9 +836,9 @@ class Terrain {
|
|
|
855
836
|
* @type {Promise<TerrainTileManager>}
|
|
856
837
|
* @deprecated
|
|
857
838
|
*/
|
|
858
|
-
this.pTiles = Promise.resolve(this.
|
|
839
|
+
this.pTiles = Promise.resolve(this.__tiles);
|
|
859
840
|
|
|
860
|
-
this.
|
|
841
|
+
this.__tiles.initialize();
|
|
861
842
|
|
|
862
843
|
this.updateMaterial();
|
|
863
844
|
|