@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,43 @@
|
|
|
1
|
+
import { EditorProcess } from "./EditorProcess.js";
|
|
2
|
+
import GUIElementSystem from "../../src/engine/ecs/gui/GUIElementSystem.js";
|
|
3
|
+
|
|
4
|
+
class DisableGameUIProcess extends EditorProcess {
|
|
5
|
+
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.name = DisableGameUIProcess.Id;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
initialize(editor) {
|
|
13
|
+
super.initialize(editor);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
startup() {
|
|
17
|
+
super.startup();
|
|
18
|
+
|
|
19
|
+
const em = this.editor.engine.entityManager;
|
|
20
|
+
|
|
21
|
+
const guiElementSystem = em.getSystem(GUIElementSystem);
|
|
22
|
+
|
|
23
|
+
if (guiElementSystem !== null) {
|
|
24
|
+
guiElementSystem.view.visible = false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
shutdown() {
|
|
29
|
+
super.shutdown();
|
|
30
|
+
|
|
31
|
+
const em = this.editor.engine.entityManager;
|
|
32
|
+
|
|
33
|
+
const guiElementSystem = em.getSystem(GUIElementSystem);
|
|
34
|
+
|
|
35
|
+
if (guiElementSystem !== null) {
|
|
36
|
+
guiElementSystem.view.visible = true;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
DisableGameUIProcess.Id = 'disable-game-user-interface';
|
|
42
|
+
|
|
43
|
+
export { DisableGameUIProcess };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { BaseProcess } from "../../src/core/process/BaseProcess.js";
|
|
2
|
+
import { assert } from "../../src/core/assert.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class EditorProcess extends BaseProcess {
|
|
6
|
+
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @type {string}
|
|
13
|
+
*/
|
|
14
|
+
this.name = "unnamed";
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @type {Editor|null}
|
|
18
|
+
*/
|
|
19
|
+
this.editor = null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @param {Editor} editor
|
|
25
|
+
*/
|
|
26
|
+
initialize(editor) {
|
|
27
|
+
assert.defined(editor,'editor');
|
|
28
|
+
|
|
29
|
+
this.editor = editor;
|
|
30
|
+
|
|
31
|
+
super.initialize();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { EditorProcess };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { EditorProcess } from "./EditorProcess.js";
|
|
2
|
+
import GridObstacle from "../../src/engine/grid/components/GridObstacle.js";
|
|
3
|
+
import GridPosition from "../../src/engine/grid/components/GridPosition.js";
|
|
4
|
+
import { Sampler2D } from "../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
|
+
import { obtainTerrain } from "../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
6
|
+
|
|
7
|
+
class ObstacleGridDisplayProcess extends EditorProcess {
|
|
8
|
+
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @type {TerrainOverlay|null}
|
|
14
|
+
*/
|
|
15
|
+
this.overlay = null;
|
|
16
|
+
this.name = ObstacleGridDisplayProcess.Id;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
startup() {
|
|
20
|
+
super.startup();
|
|
21
|
+
|
|
22
|
+
const engine = this.editor.engine;
|
|
23
|
+
|
|
24
|
+
const entityManager = engine.entityManager;
|
|
25
|
+
|
|
26
|
+
const terrain = obtainTerrain(entityManager.dataset);
|
|
27
|
+
|
|
28
|
+
if (terrain === null) {
|
|
29
|
+
this.overlay = null;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const overlay = terrain.overlay;
|
|
34
|
+
this.overlay = overlay;
|
|
35
|
+
|
|
36
|
+
overlay.push();
|
|
37
|
+
|
|
38
|
+
overlay.borderWidth.set(0.05);
|
|
39
|
+
|
|
40
|
+
this.draw();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
draw() {
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @type {TerrainOverlay}
|
|
47
|
+
*/
|
|
48
|
+
const overlay = this.overlay;
|
|
49
|
+
if (overlay === null) {
|
|
50
|
+
//no overlay, do nothing
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//
|
|
55
|
+
const drawBuffer = Sampler2D.uint8(4, overlay.size.x, overlay.size.y);
|
|
56
|
+
|
|
57
|
+
overlay.clear();
|
|
58
|
+
|
|
59
|
+
const em = this.editor.engine.entityManager;
|
|
60
|
+
|
|
61
|
+
const color = [];
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
* @param {number} x
|
|
66
|
+
* @param {number} y
|
|
67
|
+
* @param {number} value
|
|
68
|
+
*/
|
|
69
|
+
function paintPoint(x, y, value) {
|
|
70
|
+
drawBuffer.read(x, y, color);
|
|
71
|
+
|
|
72
|
+
if (value === 0) {
|
|
73
|
+
if (color[3] !== 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
color[0] = 2;
|
|
77
|
+
color[1] = 256;
|
|
78
|
+
color[2] = 0;
|
|
79
|
+
color[3] = 13;
|
|
80
|
+
} else {
|
|
81
|
+
if (color[3] !== 0) {
|
|
82
|
+
drawBuffer.set(x, y, [0, 0, 0, 0]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
color[0] = 0;
|
|
86
|
+
color[1] = 0;
|
|
87
|
+
color[2] = 0;
|
|
88
|
+
color[3] = 54;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
drawBuffer.set(x, y, color);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param {GridObstacle} obstacle
|
|
98
|
+
* @param {GridPosition} position
|
|
99
|
+
*/
|
|
100
|
+
function visitObstacle(obstacle, position) {
|
|
101
|
+
obstacle.traverseMask(position.x, position.y, paintPoint);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
em.dataset.traverseEntities([GridObstacle, GridPosition], visitObstacle);
|
|
105
|
+
|
|
106
|
+
overlay.writeData(drawBuffer.data);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
shutdown() {
|
|
110
|
+
super.shutdown();
|
|
111
|
+
|
|
112
|
+
if (this.overlay !== null) {
|
|
113
|
+
this.overlay.pop();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
ObstacleGridDisplayProcess.Id = "obstacle-grid-display";
|
|
119
|
+
|
|
120
|
+
export { ObstacleGridDisplayProcess };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { EditorProcess } from "./EditorProcess.js";
|
|
2
|
+
import List from "../../src/core/collection/list/List.js";
|
|
3
|
+
import { ProcessState } from "../../src/core/process/ProcessState.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {Editor} editor
|
|
8
|
+
* @param {EditorProcess} process
|
|
9
|
+
*/
|
|
10
|
+
function tryInitialize(editor, process) {
|
|
11
|
+
if (process.__state.getValue() !== ProcessState.New) {
|
|
12
|
+
//process already initialized, ignore
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
process.initialize(editor);
|
|
18
|
+
} catch (e) {
|
|
19
|
+
console.error(`Failed to initialize process (name='${process.name}'):`, e);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class ProcessEngine extends EditorProcess {
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
/**
|
|
27
|
+
* @type {List.<EditorProcess>}
|
|
28
|
+
*/
|
|
29
|
+
this.processes = new List();
|
|
30
|
+
|
|
31
|
+
this.__suspendedList = new List();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
startup() {
|
|
35
|
+
super.startup();
|
|
36
|
+
const editor = this.editor;
|
|
37
|
+
|
|
38
|
+
this.processes.forEach(function (proc) {
|
|
39
|
+
tryInitialize(editor, proc);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
//re-start suspended processes
|
|
43
|
+
this.__suspendedList.forEach(function (process) {
|
|
44
|
+
process.startup();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
this.__suspendedList.reset();
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {EditorProcess} process
|
|
53
|
+
*/
|
|
54
|
+
add(process) {
|
|
55
|
+
this.processes.add(process);
|
|
56
|
+
|
|
57
|
+
if (this.__state.getValue() !== ProcessState.New && this.__state.getValue() !== ProcessState.Stopped) {
|
|
58
|
+
tryInitialize(this.editor, process);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
shutdown() {
|
|
63
|
+
const self = this;
|
|
64
|
+
//shutdown any running processes
|
|
65
|
+
this.processes.forEach(function (process) {
|
|
66
|
+
if (process.__state.getValue() === ProcessState.Running) {
|
|
67
|
+
process.shutdown();
|
|
68
|
+
//record process as suspended
|
|
69
|
+
self.__suspendedList.add(process);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
super.shutdown();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @private
|
|
77
|
+
* @param {EditorProcess} process
|
|
78
|
+
*/
|
|
79
|
+
startProcess(process) {
|
|
80
|
+
if (process.__state.getValue() !== ProcessState.Running) {
|
|
81
|
+
if (this.__state.getValue() !== ProcessState.Running) {
|
|
82
|
+
//record as suspended
|
|
83
|
+
this.__suspendedList.add(process);
|
|
84
|
+
} else {
|
|
85
|
+
process.startup();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* @param {string} name
|
|
93
|
+
*/
|
|
94
|
+
startByName(name) {
|
|
95
|
+
const process = this.processes.find(p => p.name === name);
|
|
96
|
+
|
|
97
|
+
if (process === undefined) {
|
|
98
|
+
console.error(`No process found by name '${name}'`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
this.startProcess(process);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
* @param {string} name
|
|
108
|
+
*/
|
|
109
|
+
stopByName(name) {
|
|
110
|
+
const process = this.processes.find(p => p.name === name);
|
|
111
|
+
|
|
112
|
+
if (process === undefined) {
|
|
113
|
+
console.error(`No process found by name '${name}'`);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (process.__state.getValue() === ProcessState.Running) {
|
|
118
|
+
process.shutdown();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export { ProcessEngine };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { EditorProcess } from "./EditorProcess.js";
|
|
2
|
+
import { ParticleEmitter } from "../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js";
|
|
3
|
+
import RenderSystem from "../../src/engine/ecs/systems/RenderSystem.js";
|
|
4
|
+
import { Camera } from "../../src/engine/graphics/ecs/camera/Camera.js";
|
|
5
|
+
import { Light } from "../../src/engine/graphics/ecs/light/Light.js";
|
|
6
|
+
import { ComponentSymbolicDisplay } from "./symbolic/ComponentSymbolicDisplay.js";
|
|
7
|
+
import { makeSocketsSymbolicDisplay } from "./symbolic/makeSocketsSymbolicDisplay.js";
|
|
8
|
+
import { makeParticleEmitterSymbolicDisplay } from "./symbolic/makeParticleEmitterSymbolicDisplay.js";
|
|
9
|
+
import { assert } from "../../src/core/assert.js";
|
|
10
|
+
import { makeSoundEmitterSymbolicDisplay } from "./symbolic/makeSoundEmitterSymbolicDisplay.js";
|
|
11
|
+
import { SoundEmitter } from "../../src/engine/sound/ecs/emitter/SoundEmitter.js";
|
|
12
|
+
import { makeCameraSymbolicDisplay } from "./symbolic/makeCameraSymbolicDisplay.js";
|
|
13
|
+
import { makePathSymbolicDisplay } from "./symbolic/makePathSymbolicDisplay.js";
|
|
14
|
+
import { makePositionedIconDisplaySymbol } from "./symbolic/makePositionedIconDisplaySymbol.js";
|
|
15
|
+
import { makeLightSymbolicDisplay } from "./symbolic/makeLightSymbolicDisplay.js";
|
|
16
|
+
import { makeGridPositionSymbolDisplay } from "./symbolic/makeGridPositionSymbolDisplay.js";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class SymbolicDisplayProcess extends EditorProcess {
|
|
20
|
+
constructor() {
|
|
21
|
+
super();
|
|
22
|
+
|
|
23
|
+
this.name = SymbolicDisplayProcess.Id;
|
|
24
|
+
|
|
25
|
+
const self = this;
|
|
26
|
+
this.requiredSystems = [{
|
|
27
|
+
klass: RenderSystem,
|
|
28
|
+
factory: function () {
|
|
29
|
+
return new RenderSystem(self.editor.engine.graphics);
|
|
30
|
+
}
|
|
31
|
+
}];
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @type {EditorProcess[]}
|
|
36
|
+
*/
|
|
37
|
+
this.displays = [];
|
|
38
|
+
|
|
39
|
+
this.spawnedSystems = [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
initialize(editor) {
|
|
43
|
+
super.initialize(editor);
|
|
44
|
+
|
|
45
|
+
const engine = editor.engine;
|
|
46
|
+
|
|
47
|
+
assert.defined(engine, 'engine');
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @type {ComponentSymbolicDisplay[]}
|
|
52
|
+
*/
|
|
53
|
+
this.displays = [
|
|
54
|
+
makePositionedIconDisplaySymbol(engine, "data/textures/icons/editor/particles.png", ParticleEmitter),
|
|
55
|
+
makePositionedIconDisplaySymbol(engine, "data/textures/icons/editor/camera.png", Camera),
|
|
56
|
+
makePositionedIconDisplaySymbol(engine, "data/textures/icons/editor/light.png", Light),
|
|
57
|
+
makePositionedIconDisplaySymbol(engine, "data/textures/icons/editor/sound.png", SoundEmitter),
|
|
58
|
+
|
|
59
|
+
makeCameraSymbolicDisplay(engine),
|
|
60
|
+
makeLightSymbolicDisplay(engine),
|
|
61
|
+
makeGridPositionSymbolDisplay(engine),
|
|
62
|
+
makePathSymbolicDisplay(engine),
|
|
63
|
+
makeSocketsSymbolicDisplay(engine),
|
|
64
|
+
makeParticleEmitterSymbolicDisplay(engine),
|
|
65
|
+
makeSoundEmitterSymbolicDisplay(engine)
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
this.displays.forEach(d => d.initialize(editor));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
startup() {
|
|
72
|
+
super.startup();
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
const self = this;
|
|
76
|
+
|
|
77
|
+
const entityManager = this.editor.engine.entityManager;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @type {EntityComponentDataset}
|
|
82
|
+
*/
|
|
83
|
+
const ecd = entityManager.dataset;
|
|
84
|
+
|
|
85
|
+
this.requiredSystems.forEach(systemDescriptor => {
|
|
86
|
+
|
|
87
|
+
const foundSystem = entityManager.systems.find(system => system instanceof systemDescriptor.klass);
|
|
88
|
+
|
|
89
|
+
if (foundSystem === undefined) {
|
|
90
|
+
const system = systemDescriptor.factory();
|
|
91
|
+
|
|
92
|
+
self.spawnedSystems.push(system);
|
|
93
|
+
|
|
94
|
+
entityManager.addSystem(system);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
for (let i = 0; i < this.displays.length; i++) {
|
|
99
|
+
const d = this.displays[i];
|
|
100
|
+
|
|
101
|
+
// validate observer
|
|
102
|
+
if (d instanceof ComponentSymbolicDisplay) {
|
|
103
|
+
if (!ecd.areComponentTypesRegistered(d.observer.componentTypes)) {
|
|
104
|
+
// not compatible
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
d.startup();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
shutdown() {
|
|
114
|
+
super.shutdown();
|
|
115
|
+
|
|
116
|
+
const entityManager = this.editor.engine.entityManager;
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
this.displays.forEach(d => d.shutdown());
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
this.spawnedSystems.forEach(s => {
|
|
123
|
+
entityManager.removeSystem(s);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
this.spawnedSystems = [];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
SymbolicDisplayProcess.Id = 'symbolic-display-process';
|
|
131
|
+
|
|
132
|
+
export { SymbolicDisplayProcess };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { EditorProcess } from "../EditorProcess.js";
|
|
2
|
+
import { EntityObserver } from "../../../src/engine/ecs/EntityObserver.js";
|
|
3
|
+
|
|
4
|
+
export class ComponentSymbolicDisplay extends EditorProcess {
|
|
5
|
+
constructor(components, creator, destructor) {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @type {EntityObserver}
|
|
11
|
+
*/
|
|
12
|
+
this.observer = new EntityObserver(components, creator, destructor);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
startup() {
|
|
16
|
+
super.startup();
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {EntityComponentDataset}
|
|
21
|
+
*/
|
|
22
|
+
const dataset = this.editor.engine.entityManager.dataset;
|
|
23
|
+
|
|
24
|
+
dataset.addObserver(this.observer, true);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
shutdown() {
|
|
28
|
+
super.shutdown();
|
|
29
|
+
|
|
30
|
+
const dataset = this.editor.engine.entityManager.dataset;
|
|
31
|
+
|
|
32
|
+
dataset.removeObserver(this.observer, true);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { SignalBinding } from "../../../src/core/events/signal/SignalBinding.js";
|
|
2
|
+
import Signal from "../../../src/core/events/signal/Signal.js";
|
|
3
|
+
import { assert } from "../../../src/core/assert.js";
|
|
4
|
+
import { seededRandom } from "../../../src/core/math/random/seededRandom.js";
|
|
5
|
+
import { ProcessState } from "../../../src/core/process/ProcessState.js";
|
|
6
|
+
import EditorEntity from "../../ecs/EditorEntity.js";
|
|
7
|
+
import List from "../../../src/core/collection/list/List.js";
|
|
8
|
+
|
|
9
|
+
export class SymbolicDisplayInternalAPI {
|
|
10
|
+
constructor() {
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @type {SignalBinding[]}
|
|
14
|
+
*/
|
|
15
|
+
this.bindings = [];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @type {Engine}
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
this.__engine = null;
|
|
23
|
+
|
|
24
|
+
this.__requestUpdate = new Signal();
|
|
25
|
+
|
|
26
|
+
this.random = seededRandom(42);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @type {List<EntityBuilder>}
|
|
31
|
+
* @private
|
|
32
|
+
*/
|
|
33
|
+
this.__managed_entities = new List();
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @type {ProcessState}
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
this.__state = ProcessState.New;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @type {EntityComponentDataset}
|
|
45
|
+
* @private
|
|
46
|
+
*/
|
|
47
|
+
this.__dataset = null;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @type {number}
|
|
52
|
+
* @private
|
|
53
|
+
*/
|
|
54
|
+
this.__source_entity = -1;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param {EntityBuilder} entity
|
|
60
|
+
*/
|
|
61
|
+
emit(entity) {
|
|
62
|
+
assert.defined(entity, 'entity');
|
|
63
|
+
assert.equal(entity.isEntityBuilder, true, 'entity.isEntityBuilder !== true');
|
|
64
|
+
|
|
65
|
+
if (entity.getComponent(EditorEntity) === null) {
|
|
66
|
+
entity.add(new EditorEntity({ referenceEntity: this.__source_entity }));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
this.__managed_entities.add(entity);
|
|
70
|
+
|
|
71
|
+
if (this.__state === ProcessState.Running) {
|
|
72
|
+
entity.build(this.__dataset);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
* @param {number} entity
|
|
79
|
+
* @param {EntityComponentDataset} ecd
|
|
80
|
+
* @param {Engine} engine
|
|
81
|
+
*/
|
|
82
|
+
initialize({
|
|
83
|
+
entity,
|
|
84
|
+
ecd,
|
|
85
|
+
engine
|
|
86
|
+
}) {
|
|
87
|
+
this.__engine = engine;
|
|
88
|
+
this.__dataset = ecd;
|
|
89
|
+
this.__source_entity = entity;
|
|
90
|
+
|
|
91
|
+
this.__state = ProcessState.Running;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
finalize() {
|
|
95
|
+
// remove all managed entities
|
|
96
|
+
this.__managed_entities.forEach(e => e.destroy());
|
|
97
|
+
|
|
98
|
+
// clear all bindings
|
|
99
|
+
this.bindings.forEach(b => b.unlink());
|
|
100
|
+
|
|
101
|
+
// clear dataset
|
|
102
|
+
this.__dataset = null;
|
|
103
|
+
|
|
104
|
+
this.__state = ProcessState.Finalized;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
* @param {Transform} source
|
|
110
|
+
* @param {Transform} target
|
|
111
|
+
*/
|
|
112
|
+
bindTransform(source, target) {
|
|
113
|
+
|
|
114
|
+
// watch source transform
|
|
115
|
+
this.bind(source.position.onChanged, target.position.set, target.position);
|
|
116
|
+
this.bind(source.rotation.onChanged, target.rotation.set, target.rotation);
|
|
117
|
+
this.bind(source.scale.onChanged, target.scale.set, target.scale);
|
|
118
|
+
|
|
119
|
+
// copy source transform
|
|
120
|
+
target.position.copy(source.position);
|
|
121
|
+
target.rotation.copy(source.rotation);
|
|
122
|
+
target.scale.copy(source.scale);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
bind(signal, action, context) {
|
|
126
|
+
const binding = new SignalBinding(signal, action, context);
|
|
127
|
+
this.bindings.push(binding);
|
|
128
|
+
binding.link();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
onFrame(method, thisArg) {
|
|
132
|
+
const engine = this.__engine;
|
|
133
|
+
this.bind(engine.graphics.on.visibilityConstructionEnded, method, thisArg);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
unbind(signal, action, context) {
|
|
137
|
+
const bindings = this.bindings;
|
|
138
|
+
|
|
139
|
+
for (let i = 0; i < bindings.length; i++) {
|
|
140
|
+
|
|
141
|
+
const b = bindings[i];
|
|
142
|
+
|
|
143
|
+
if (b.signal === signal && b.handler === action && b.context === context) {
|
|
144
|
+
b.unlink();
|
|
145
|
+
|
|
146
|
+
bindings.splice(i, 1);
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
update() {
|
|
156
|
+
this.__requestUpdate.send0();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import EntityBuilder from "../../../src/engine/ecs/EntityBuilder.js";
|
|
2
|
+
import Renderable from "../../../src/engine/ecs/components/Renderable.js";
|
|
3
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
4
|
+
import EditorEntity from "../../ecs/EditorEntity.js";
|
|
5
|
+
import Script from "../../../src/engine/ecs/components/Script.js";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {Object3D} helper
|
|
11
|
+
* @param {number} sourceEntity
|
|
12
|
+
* @return {EntityBuilder}
|
|
13
|
+
*/
|
|
14
|
+
export function buildThreeJSHelperEntity(helper, sourceEntity = -1) {
|
|
15
|
+
helper.frustumCulled = false;
|
|
16
|
+
|
|
17
|
+
const entityBuilder = new EntityBuilder();
|
|
18
|
+
|
|
19
|
+
const renderable = new Renderable(helper);
|
|
20
|
+
// renderable.matrixAutoUpdate = false;
|
|
21
|
+
|
|
22
|
+
entityBuilder.add(new Transform());
|
|
23
|
+
entityBuilder.add(new EditorEntity(sourceEntity));
|
|
24
|
+
entityBuilder.add(renderable);
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
if (typeof helper.update === "function") {
|
|
28
|
+
entityBuilder.add(new Script(function () {
|
|
29
|
+
helper.update();
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
renderable.computeBoundsFromObject();
|
|
34
|
+
|
|
35
|
+
return entityBuilder;
|
|
36
|
+
}
|