@woosh/meep-engine 2.46.29 → 2.46.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/Editor.js +793 -0
- package/editor/SelectionVisualizer.js +148 -0
- package/editor/actions/concrete/ActionUpdateTexture.js +21 -0
- package/editor/actions/concrete/ArrayCopyAction.js +39 -0
- package/editor/actions/concrete/ComponentAddAction.js +47 -0
- package/editor/actions/concrete/ComponentRemoveAction.js +38 -0
- package/editor/actions/concrete/EntityCreateAction.js +47 -0
- package/editor/actions/concrete/EntityRemoveAction.js +51 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
- package/editor/actions/concrete/ModifyPatchTextureArray2DAction.js +182 -0
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +45 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.js +67 -0
- package/editor/actions/concrete/PatchTerrainTextureAction.js +152 -0
- package/editor/actions/concrete/SelectionAddAction.js +36 -0
- package/editor/actions/concrete/SelectionClearAction.js +22 -0
- package/editor/actions/concrete/SelectionRemoveAction.js +30 -0
- package/editor/actions/concrete/TransformModifyAction.js +46 -0
- package/editor/actions/concrete/WriteGridValueAction.js +46 -0
- package/editor/ecs/EditorEntity.js +12 -0
- package/editor/ecs/EditorEntitySystem.js +14 -0
- package/editor/ecs/component/FieldDescriptor.js +34 -0
- package/editor/ecs/component/FieldValueAdapter.js +20 -0
- package/editor/ecs/component/TypeEditor.js +33 -0
- package/editor/ecs/component/TypeSchema.d.ts +38 -0
- package/editor/ecs/component/createFieldEditor.js +92 -0
- package/editor/ecs/component/createObjectEditor.js +361 -0
- package/editor/ecs/component/editors/ColorEditor.js +39 -0
- package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
- package/editor/ecs/component/editors/ImagePathEditor.js +82 -0
- package/editor/ecs/component/editors/LargeStrongEditor.js +107 -0
- package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
- package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
- package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
- package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
- package/editor/ecs/component/editors/Sampler2DEditor.js +221 -0
- package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
- package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
- package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
- package/editor/ecs/component/editors/common/noEditor.js +9 -0
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +225 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
- package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
- package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +95 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +63 -0
- package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
- package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
- package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
- package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
- package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
- package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
- package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
- package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
- package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
- package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
- package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
- package/editor/ecs/component/editors/three/TextureEditor.js +112 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/enableEditor.js +85 -0
- package/editor/library/MeshLibrary.js +33 -0
- package/editor/process/DisableGameUIProcess.js +43 -0
- package/editor/process/EditorProcess.js +35 -0
- package/editor/process/ObstacleGridDisplayProcess.js +120 -0
- package/editor/process/ProcessEngine.js +123 -0
- package/editor/process/SymbolicDisplayProcess.js +132 -0
- package/editor/process/symbolic/ComponentSymbolicDisplay.js +34 -0
- package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +159 -0
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +36 -0
- package/editor/process/symbolic/make3DSymbolicDisplay.js +91 -0
- package/editor/process/symbolic/makeCameraSymbolicDisplay.js +32 -0
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +176 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/process/symbolic/makeHelperSphereGeometry.js +73 -0
- package/editor/process/symbolic/makeLightSymbolicDisplay.js +77 -0
- package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +146 -0
- package/editor/process/symbolic/makePathSymbolicDisplay.js +105 -0
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +74 -0
- package/editor/process/symbolic/makeSocketsSymbolicDisplay.js +153 -0
- package/editor/process/symbolic/makeSolidArrowGeometry.js +391 -0
- package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +89 -0
- package/editor/process/symbolic/makeStoryTriggerSetAreaDisplay.js +114 -0
- package/editor/process/symbolic/synchronizeTransform.js +50 -0
- package/editor/tools/FoliagePaintTool.js +168 -0
- package/editor/tools/GridPaintTool.js +247 -0
- package/editor/tools/SelectionTool.js +407 -0
- package/editor/tools/TopDownCameraControlTool.js +59 -0
- package/editor/tools/TransformTool.js +370 -0
- package/editor/tools/engine/Tool.js +121 -0
- package/editor/tools/engine/ToolEngine.js +193 -0
- package/editor/tools/engine/ToolState.js +9 -0
- package/editor/tools/engine/ToolStateMachine.js +53 -0
- package/editor/tools/paint/TerrainHeightPaintTool.js +297 -0
- package/editor/tools/paint/TerrainPaintTool.js +211 -0
- package/editor/tools/paint/TerrainTexturePaintTool.js +193 -0
- package/editor/tools/paint/prototypeTerrainEditor.js +135 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.d.ts +50 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +500 -0
- package/editor/tools/v2/TransformControls.d.ts +20 -0
- package/editor/tools/v2/TransformControls.js +1782 -0
- package/editor/tools/v2/prototypeTransformControls.js +92 -0
- package/editor/view/EditorView.js +462 -0
- package/editor/view/GridPickCoordinateView.js +88 -0
- package/editor/view/ecs/ComponentControlFactory.js +48 -0
- package/editor/view/ecs/ComponentControlView.js +214 -0
- package/editor/view/ecs/EntityEditor.js +258 -0
- package/editor/view/ecs/EntityList.js +258 -0
- package/editor/view/ecs/components/BlackboardController.js +50 -0
- package/editor/view/ecs/components/DatGuiController.js +216 -0
- package/editor/view/ecs/components/FogOfWarController.js +78 -0
- package/editor/view/ecs/components/FogOfWarRevealerController.js +44 -0
- package/editor/view/ecs/components/GeneratedArmyController.js +42 -0
- package/editor/view/ecs/components/GridObstacleController.js +72 -0
- package/editor/view/ecs/components/GridPositionController.js +40 -0
- package/editor/view/ecs/components/HeadsUpDisplayController.js +30 -0
- package/editor/view/ecs/components/HighlightController.js +47 -0
- package/editor/view/ecs/components/MeshController.js +125 -0
- package/editor/view/ecs/components/PathFollowerController.js +87 -0
- package/editor/view/ecs/components/TagController.js +80 -0
- package/editor/view/ecs/components/TerrainController.js +225 -0
- package/editor/view/ecs/components/TransformController.js +103 -0
- package/editor/view/ecs/components/UnitShopController.js +112 -0
- package/editor/view/ecs/components/army/ArmyController.js +130 -0
- package/editor/view/ecs/components/color/GaugeView.js +107 -0
- package/editor/view/ecs/components/common/AutoCanvasView.js +53 -0
- package/editor/view/ecs/components/common/LineView.js +17 -0
- package/editor/view/ecs/components/common/NumberController.js +112 -0
- package/editor/view/ecs/components/common/NumericIntervalController.js +64 -0
- package/editor/view/ecs/components/gui/GUIElementController.js +117 -0
- package/editor/view/ecs/components/items/ItemContainerController.js +132 -0
- package/editor/view/ecs/components/items/ItemContainerController.stories.js +50 -0
- package/editor/view/ecs/components/items/ItemController.js +52 -0
- package/editor/view/ecs/components/particles/ColorParameterLUTController.js +444 -0
- package/editor/view/ecs/components/particles/ParameterTrackController.js +51 -0
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +213 -0
- package/editor/view/ecs/components/particles/ParticleLayerController.js +213 -0
- package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +401 -0
- package/editor/view/ecs/components/sockets/AttachmentSocketsController.js +51 -0
- package/editor/view/ecs/components/sound/SoundEmitterController.js +137 -0
- package/editor/view/ecs/components/story/StoryTriggerSetController.js +214 -0
- package/editor/view/ecs/components/unit/AuraController.js +45 -0
- package/editor/view/library/MeshLibraryView.js +164 -0
- package/editor/view/node-graph/NodeGraphEditorView.js +170 -0
- package/editor/view/node-graph/NodeGraphView.js +453 -0
- package/editor/view/node-graph/NodeView.js +135 -0
- package/editor/view/node-graph/PortView.js +69 -0
- package/editor/view/process/ProcessView.js +63 -0
- package/editor/view/tools/ToolSettingsView.js +143 -0
- package/editor/view/tools/ToolView.js +58 -0
- package/package.json +2 -1
- package/src/engine/intelligence/behavior/composite/CompositeBehavior.js +18 -2
- package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +21 -9
- package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +5 -1
- package/src/engine/intelligence/behavior/util/DelayBehavior.js +8 -3
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import View from "../../../src/view/View.js";
|
|
2
|
+
import { PortView } from "./PortView.js";
|
|
3
|
+
import EmptyView from "../../../src/view/elements/EmptyView.js";
|
|
4
|
+
import LabelView from "../../../src/view/common/LabelView.js";
|
|
5
|
+
import { DraggableAspect } from "../../../src/engine/ui/DraggableAspect.js";
|
|
6
|
+
import Vector2 from "../../../src/core/geom/Vector2.js";
|
|
7
|
+
import { noop } from "../../../src/core/function/Functions.js";
|
|
8
|
+
import { NodeParameterDataType } from "../../../src/core/model/node-graph/node/parameter/NodeParameterDataType.js";
|
|
9
|
+
import DatGuiController from "../ecs/components/DatGuiController.js";
|
|
10
|
+
import { PortDirection } from "../../../src/core/model/node-graph/node/PortDirection.js";
|
|
11
|
+
|
|
12
|
+
export class NodeView extends View {
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {NodeInstance} node
|
|
16
|
+
* @param {NodeVisualData} visual
|
|
17
|
+
* @param {NodeGraphVisualData} visualData
|
|
18
|
+
* @param {boolean} enableDrag
|
|
19
|
+
* @param {function(PortView, Port)} portCreationCallback
|
|
20
|
+
*/
|
|
21
|
+
constructor({ node, visual, visualData, enableDrag = true, portCreationCallback = noop }) {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {NodeInstance}
|
|
27
|
+
*/
|
|
28
|
+
this.node = node;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {NodeVisualData}
|
|
32
|
+
*/
|
|
33
|
+
this.visual = visual;
|
|
34
|
+
|
|
35
|
+
this.el = document.createElement('div');
|
|
36
|
+
|
|
37
|
+
this.addClass('ui-node-view');
|
|
38
|
+
|
|
39
|
+
const vPorts = new EmptyView({
|
|
40
|
+
classList: ['ports']
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const nodeDescription = node.description;
|
|
44
|
+
const vName = new LabelView(nodeDescription.name, {
|
|
45
|
+
classList: ['name']
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const v2_prev_position = new Vector2();
|
|
49
|
+
|
|
50
|
+
const self = this;
|
|
51
|
+
|
|
52
|
+
if (enableDrag) {
|
|
53
|
+
const draggableAspect = new DraggableAspect({
|
|
54
|
+
el: this.el,
|
|
55
|
+
dragStart(p) {
|
|
56
|
+
v2_prev_position.copy(p);
|
|
57
|
+
},
|
|
58
|
+
drag(position, origin, delta) {
|
|
59
|
+
const p = delta.clone();
|
|
60
|
+
|
|
61
|
+
const scale = new Vector2(1, 1);
|
|
62
|
+
|
|
63
|
+
self.computeGlobalScale(scale);
|
|
64
|
+
|
|
65
|
+
p.divide(scale);
|
|
66
|
+
|
|
67
|
+
// p.add(v2_origin);
|
|
68
|
+
|
|
69
|
+
visual.dimensions.position.add(p);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
this.on.linked.add(draggableAspect.start, draggableAspect);
|
|
73
|
+
this.on.unlinked.add(draggableAspect.stop, draggableAspect);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//create parameters
|
|
77
|
+
|
|
78
|
+
const vParamContainer = new EmptyView({ classList: ['parameters-container'] });
|
|
79
|
+
|
|
80
|
+
const vParams = new DatGuiController({ classList: ['parameters'] });
|
|
81
|
+
vParamContainer.addChild(vParams);
|
|
82
|
+
|
|
83
|
+
nodeDescription.parameters.forEach(param => {
|
|
84
|
+
const id = param.id;
|
|
85
|
+
|
|
86
|
+
const type = param.type;
|
|
87
|
+
|
|
88
|
+
let controller = null;
|
|
89
|
+
|
|
90
|
+
if (type === NodeParameterDataType.Number) {
|
|
91
|
+
controller = vParams.addControl({ v: node.getParameterValue(id) }, 'v');
|
|
92
|
+
} else if (type === NodeParameterDataType.String) {
|
|
93
|
+
controller = vParams.addControl({ v: node.getParameterValue(id) }, 'v');
|
|
94
|
+
} else if (type === NodeParameterDataType.Boolean) {
|
|
95
|
+
controller = vParams.addControl({ v: node.getParameterValue(id) }, 'v');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
controller.name(param.name);
|
|
99
|
+
controller.onChange((v) => {
|
|
100
|
+
node.setParameterValue(id, v);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
this.addChild(vParamContainer);
|
|
106
|
+
|
|
107
|
+
this.addChild(vName);
|
|
108
|
+
|
|
109
|
+
this.addChild(vPorts);
|
|
110
|
+
|
|
111
|
+
nodeDescription.getPorts().forEach(port => {
|
|
112
|
+
|
|
113
|
+
const portVisualData = visual.getPort(port.id);
|
|
114
|
+
|
|
115
|
+
const portView = new PortView({ port, visual: portVisualData, visualData });
|
|
116
|
+
|
|
117
|
+
portCreationCallback(portView, port);
|
|
118
|
+
|
|
119
|
+
vPorts.addChild(portView);
|
|
120
|
+
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
this.setClass('has-inputs', nodeDescription.getPorts().some(p => p.direction === PortDirection.In));
|
|
124
|
+
this.setClass('has-outputs', nodeDescription.getPorts().some(p => p.direction === PortDirection.Out));
|
|
125
|
+
|
|
126
|
+
this.on.linked.add(this.update, this);
|
|
127
|
+
this.bindSignal(visual.dimensions.position.onChanged, this.update, this);
|
|
128
|
+
this.bindSignal(visual.dimensions.size.onChanged, this.update, this);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
update() {
|
|
132
|
+
this.position.copy(this.visual.dimensions.position);
|
|
133
|
+
this.size.copy(this.visual.dimensions.size);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import View from "../../../src/view/View.js";
|
|
2
|
+
import { PortDirection } from "../../../src/core/model/node-graph/node/PortDirection.js";
|
|
3
|
+
import { camelToKebab } from "../../../src/core/primitives/strings/StringUtils.js";
|
|
4
|
+
import LabelView from "../../../src/view/common/LabelView.js";
|
|
5
|
+
import EmptyView from "../../../src/view/elements/EmptyView.js";
|
|
6
|
+
import { Color } from "../../../src/core/color/Color.js";
|
|
7
|
+
import { objectKeyByValue } from "../../../src/core/model/object/objectKeyByValue.js";
|
|
8
|
+
|
|
9
|
+
const DEFAULT_TYPE_COLOR = new Color(1, 1, 1);
|
|
10
|
+
|
|
11
|
+
export class PortView extends View {
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param {Port} port
|
|
15
|
+
* @param {PortVisualData} visual
|
|
16
|
+
* @param {NodeGraphVisualData} visualData
|
|
17
|
+
*/
|
|
18
|
+
constructor({ port, visual, visualData }) {
|
|
19
|
+
super();
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @type {Port}
|
|
24
|
+
*/
|
|
25
|
+
this.port = port;
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @type {PortVisualData}
|
|
29
|
+
*/
|
|
30
|
+
this.visual = visual;
|
|
31
|
+
|
|
32
|
+
this.el = document.createElement('div');
|
|
33
|
+
|
|
34
|
+
this.addClass('ui-port-view');
|
|
35
|
+
|
|
36
|
+
this.addClass(`direction-${objectKeyByValue(PortDirection, port.direction).toLocaleLowerCase()}`);
|
|
37
|
+
|
|
38
|
+
this.addClass(`data-type-${camelToKebab(port.dataType.name)}`);
|
|
39
|
+
|
|
40
|
+
//add port name label
|
|
41
|
+
const vName = new LabelView(port.name, {
|
|
42
|
+
classList: ['name']
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
this.addChild(vName);
|
|
46
|
+
|
|
47
|
+
let color = visualData.getDataColor(port.dataType.id);
|
|
48
|
+
|
|
49
|
+
if (color === undefined) {
|
|
50
|
+
console.warn(`No color for data type ${port.dataType}, using default`);
|
|
51
|
+
|
|
52
|
+
color = DEFAULT_TYPE_COLOR;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
this.addChild(new EmptyView({
|
|
56
|
+
classList: ['marker'],
|
|
57
|
+
css: {
|
|
58
|
+
backgroundColor: `rgb(${color.r * 255}, ${color.g * 255}, ${color.b * 255})`
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
|
|
62
|
+
this.on.linked.add(this.update, this);
|
|
63
|
+
this.bindSignal(visual.position.onChanged, this.update, this);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
update() {
|
|
67
|
+
this.position.copy(this.visual.position);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import View from "../../../src/view/View.js";
|
|
2
|
+
import dom from "../../../src/view/DOM.js";
|
|
3
|
+
|
|
4
|
+
import LabelView from '../../../src/view/common/LabelView.js';
|
|
5
|
+
import { ProcessState } from "../../../src/core/process/ProcessState.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {ProcessState} state
|
|
10
|
+
* @returns {string}
|
|
11
|
+
*/
|
|
12
|
+
function processState2ClassName(state) {
|
|
13
|
+
return `process-state-${state}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
class ProcessView extends View {
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {BaseProcess} process
|
|
20
|
+
* @constructor
|
|
21
|
+
*/
|
|
22
|
+
constructor(process) {
|
|
23
|
+
|
|
24
|
+
super(process);
|
|
25
|
+
|
|
26
|
+
this.model = process;
|
|
27
|
+
|
|
28
|
+
const dRoot = dom('div');
|
|
29
|
+
|
|
30
|
+
dRoot.addClass('process-view');
|
|
31
|
+
|
|
32
|
+
dRoot.addClass(`editor-process-${process.name}`);
|
|
33
|
+
|
|
34
|
+
this.$el = dRoot;
|
|
35
|
+
this.el = dRoot.el;
|
|
36
|
+
|
|
37
|
+
//add process name
|
|
38
|
+
const lName = new LabelView(process.name);
|
|
39
|
+
this.addChild(lName);
|
|
40
|
+
|
|
41
|
+
this.bindSignal(process.getState().onChanged, function (newValue, oldValue) {
|
|
42
|
+
dRoot.removeClass(processState2ClassName(oldValue));
|
|
43
|
+
dRoot.addClass(processState2ClassName(newValue));
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
link() {
|
|
48
|
+
const $el = this.$el;
|
|
49
|
+
|
|
50
|
+
//clear status classes
|
|
51
|
+
Object.values(ProcessState).map(processState2ClassName).forEach(function (state) {
|
|
52
|
+
$el.removeClass(state);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
//set active status class
|
|
56
|
+
$el.addClass(processState2ClassName(this.model.getState().getValue()));
|
|
57
|
+
|
|
58
|
+
super.link();
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
export default ProcessView;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import View from "../../../src/view/View.js";
|
|
2
|
+
import { clear } from "../../../src/view/controller/dat/DatGuiUtils.js";
|
|
3
|
+
import dat from 'dat.gui'
|
|
4
|
+
|
|
5
|
+
class ToolSettingsView extends View {
|
|
6
|
+
constructor(tool) {
|
|
7
|
+
super(tool);
|
|
8
|
+
|
|
9
|
+
this.model = tool;
|
|
10
|
+
|
|
11
|
+
const gui = new dat.GUI({
|
|
12
|
+
autoPlace: false,
|
|
13
|
+
closed: false,
|
|
14
|
+
resizable: false
|
|
15
|
+
});
|
|
16
|
+
this.gui = gui;
|
|
17
|
+
|
|
18
|
+
this.el = gui.domElement;
|
|
19
|
+
|
|
20
|
+
this.addClass('editor-tool-settings-view');
|
|
21
|
+
|
|
22
|
+
this.build();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setTool(tool) {
|
|
26
|
+
this.model = tool;
|
|
27
|
+
this.build();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
build() {
|
|
31
|
+
|
|
32
|
+
let rowCount = 0;
|
|
33
|
+
|
|
34
|
+
function isObservedValue(v) {
|
|
35
|
+
return typeof v === "object" && typeof v.onChanged === "object" && typeof v.get === "function";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function isVector1(v) {
|
|
39
|
+
return typeof v === "object" && v.constructor !== undefined && v.constructor.typeName === "Vector1";
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function addProperties(folder, object) {
|
|
43
|
+
for (let propertyName in object) {
|
|
44
|
+
const propertyValue = object[propertyName];
|
|
45
|
+
if (typeof propertyValue === object) {
|
|
46
|
+
//check for observed values
|
|
47
|
+
if (isObservedValue(propertyValue) || isVector1(propertyValue)) {
|
|
48
|
+
makeProperty(folder, object, propertyName);
|
|
49
|
+
} else {
|
|
50
|
+
makeFolder(folder, propertyValue, propertyName);
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
makeProperty(folder, object, propertyName);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function makeFolder(parentFolder, object, name) {
|
|
59
|
+
rowCount++;
|
|
60
|
+
|
|
61
|
+
const folder = parentFolder.addFolder(name);
|
|
62
|
+
|
|
63
|
+
folder.closed = false;
|
|
64
|
+
|
|
65
|
+
addProperties(folder, object);
|
|
66
|
+
|
|
67
|
+
return folder;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function wrapObservedValue(value) {
|
|
71
|
+
const op = {
|
|
72
|
+
v: null
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
Object.defineProperty(op, "v", {
|
|
76
|
+
get: function () {
|
|
77
|
+
return value.get();
|
|
78
|
+
},
|
|
79
|
+
set: function (v) {
|
|
80
|
+
return value.set(v);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return op;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function wrapVector1(value) {
|
|
88
|
+
const op = {
|
|
89
|
+
v: null
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
Object.defineProperty(op, "v", {
|
|
93
|
+
get: function () {
|
|
94
|
+
return value.getValue();
|
|
95
|
+
},
|
|
96
|
+
set: function (v) {
|
|
97
|
+
return value.set(v);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return op;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function makeProperty(parentFolder, owner, name) {
|
|
105
|
+
rowCount++;
|
|
106
|
+
|
|
107
|
+
let control;
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
const propertyValue = owner[name];
|
|
111
|
+
if (isObservedValue(propertyValue)) {
|
|
112
|
+
control = parentFolder.add(wrapObservedValue(propertyValue), "v");
|
|
113
|
+
control.name(name);
|
|
114
|
+
} else if (isVector1(propertyValue)) {
|
|
115
|
+
control = parentFolder.add(wrapVector1(propertyValue), "v");
|
|
116
|
+
control.name(name);
|
|
117
|
+
} else {
|
|
118
|
+
control = parentFolder.add(owner, name);
|
|
119
|
+
}
|
|
120
|
+
} catch (e) {
|
|
121
|
+
console.error("Failed to add option controller", name, e);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return control;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const gui = this.gui;
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
clear(gui);
|
|
131
|
+
|
|
132
|
+
const tool = this.model;
|
|
133
|
+
|
|
134
|
+
if (tool !== undefined && typeof tool.settings === "object") {
|
|
135
|
+
addProperties(gui, tool.settings);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.size.set(gui.width, rowCount * 30 + 20);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
export default ToolSettingsView;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by Alex on 16/01/2017.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
import View from "../../../src/view/View.js";
|
|
7
|
+
import dom from "../../../src/view/DOM.js";
|
|
8
|
+
|
|
9
|
+
import LabelView from '../../../src/view/common/LabelView.js';
|
|
10
|
+
import ImageView from "../../../src/view/elements/image/ImageView.js";
|
|
11
|
+
|
|
12
|
+
class ToolView extends View {
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param {Tool} tool
|
|
16
|
+
* @param {Editor} editor
|
|
17
|
+
* @constructor
|
|
18
|
+
*/
|
|
19
|
+
constructor({ tool, editor }) {
|
|
20
|
+
|
|
21
|
+
super(tool);
|
|
22
|
+
|
|
23
|
+
const dRoot = dom('div');
|
|
24
|
+
|
|
25
|
+
dRoot.addClass('tool-view');
|
|
26
|
+
|
|
27
|
+
dRoot.addClass(`editor-tool-${tool.name}`);
|
|
28
|
+
|
|
29
|
+
this.el = dRoot.el;
|
|
30
|
+
|
|
31
|
+
//add tool name
|
|
32
|
+
const lName = new LabelView(tool.name);
|
|
33
|
+
|
|
34
|
+
const icon = new ImageView(tool.icon, { classList: ['icon'] });
|
|
35
|
+
|
|
36
|
+
icon.size.set(32, 32);
|
|
37
|
+
icon.position.set(2, 2);
|
|
38
|
+
|
|
39
|
+
this.addChild(icon);
|
|
40
|
+
|
|
41
|
+
this.addChild(lName);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
this.on.linked.add(() => {
|
|
45
|
+
tool.updateIcon(editor);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function updateIconVisibility() {
|
|
49
|
+
icon.visible = (tool.icon.getValue() !== "");
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
tool.icon.onChanged.add(updateIconVisibility);
|
|
53
|
+
this.on.linked.add(updateIconVisibility);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export default ToolView;
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Fully featured ECS game engine written in JavaScript",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.46.
|
|
8
|
+
"version": "2.46.31",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"files": [
|
|
28
28
|
"build",
|
|
29
29
|
"src",
|
|
30
|
+
"editor",
|
|
30
31
|
"samples",
|
|
31
32
|
"package.json",
|
|
32
33
|
"README.md"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Behavior } from "../Behavior.js";
|
|
2
2
|
import { assert } from "../../../../core/assert.js";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Abstract class
|
|
6
|
+
*/
|
|
4
7
|
export class CompositeBehavior extends Behavior {
|
|
5
8
|
constructor() {
|
|
6
9
|
super();
|
|
@@ -18,12 +21,25 @@ export class CompositeBehavior extends Behavior {
|
|
|
18
21
|
* @param {Behavior} child
|
|
19
22
|
*/
|
|
20
23
|
addChild(child) {
|
|
21
|
-
assert.defined(child);
|
|
22
|
-
assert.
|
|
24
|
+
assert.defined(child, 'child');
|
|
25
|
+
assert.notNull(child, 'child');
|
|
26
|
+
assert.equal(child.isBehavior, true, 'child is not a Behavior');
|
|
23
27
|
|
|
24
28
|
this.__children.push(child);
|
|
25
29
|
}
|
|
26
30
|
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {Behavior[]} many
|
|
34
|
+
*/
|
|
35
|
+
addChildren(many) {
|
|
36
|
+
const n = many.length;
|
|
37
|
+
for (let i = 0; i < n; i++) {
|
|
38
|
+
const e = many[i];
|
|
39
|
+
r.addChild(e);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
27
43
|
/**
|
|
28
44
|
* NOTE: do not modify obtained value
|
|
29
45
|
* @return {Behavior[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CompositeBehavior } from "./CompositeBehavior.js";
|
|
2
2
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
3
3
|
import { BitSet } from "../../../../core/binary/BitSet.js";
|
|
4
|
+
import { assert } from "../../../../core/assert.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
*
|
|
@@ -11,6 +12,9 @@ export const ParallelBehaviorPolicy = {
|
|
|
11
12
|
RequireAll: 1
|
|
12
13
|
};
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Executes all contained behaviors in parallel
|
|
17
|
+
*/
|
|
14
18
|
export class ParallelBehavior extends CompositeBehavior {
|
|
15
19
|
/**
|
|
16
20
|
*
|
|
@@ -20,6 +24,9 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
20
24
|
constructor(successPolicy, failurePolicy) {
|
|
21
25
|
super();
|
|
22
26
|
|
|
27
|
+
assert.enum(successPolicy, ParallelBehaviorPolicy, 'successPolicy');
|
|
28
|
+
assert.enum(failurePolicy, ParallelBehaviorPolicy, 'failurePolicy');
|
|
29
|
+
|
|
23
30
|
/**
|
|
24
31
|
* @private
|
|
25
32
|
* @type {ParallelBehaviorPolicy}
|
|
@@ -33,6 +40,7 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
33
40
|
this.failurePolicy = failurePolicy;
|
|
34
41
|
|
|
35
42
|
/**
|
|
43
|
+
* @readonly
|
|
36
44
|
* @private
|
|
37
45
|
* @type {BitSet}
|
|
38
46
|
*/
|
|
@@ -60,10 +68,11 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
60
68
|
|
|
61
69
|
/**
|
|
62
70
|
*
|
|
63
|
-
* @param {ParallelBehaviorPolicy|number}
|
|
71
|
+
* @param {ParallelBehaviorPolicy|number} policy
|
|
64
72
|
*/
|
|
65
|
-
setSuccessPolicy(
|
|
66
|
-
|
|
73
|
+
setSuccessPolicy(policy) {
|
|
74
|
+
assert.enum(policy, ParallelBehaviorPolicy, 'policy');
|
|
75
|
+
this.successPolicy = policy;
|
|
67
76
|
}
|
|
68
77
|
|
|
69
78
|
/**
|
|
@@ -76,10 +85,11 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
76
85
|
|
|
77
86
|
/**
|
|
78
87
|
*
|
|
79
|
-
* @param {ParallelBehaviorPolicy|number}
|
|
88
|
+
* @param {ParallelBehaviorPolicy|number} policy
|
|
80
89
|
*/
|
|
81
|
-
setFailurePolicy(
|
|
82
|
-
|
|
90
|
+
setFailurePolicy(policy) {
|
|
91
|
+
assert.enum(policy, ParallelBehaviorPolicy, 'policy');
|
|
92
|
+
this.failurePolicy = policy;
|
|
83
93
|
}
|
|
84
94
|
|
|
85
95
|
/**
|
|
@@ -213,14 +223,16 @@ export class ParallelBehavior extends CompositeBehavior {
|
|
|
213
223
|
/**
|
|
214
224
|
*
|
|
215
225
|
* @param {Behavior[]} elements
|
|
216
|
-
* @param {ParallelBehaviorPolicy} success
|
|
217
|
-
* @param {ParallelBehaviorPolicy} failure
|
|
226
|
+
* @param {ParallelBehaviorPolicy} success how should successful completion be determined?
|
|
227
|
+
* @param {ParallelBehaviorPolicy} failure how should failing completion be determined
|
|
218
228
|
* @returns {ParallelBehavior}
|
|
219
229
|
*/
|
|
220
230
|
static from(elements, success = ParallelBehaviorPolicy.RequireAll, failure = ParallelBehaviorPolicy.RequireOne) {
|
|
231
|
+
assert.isArray(elements, 'elements');
|
|
232
|
+
|
|
221
233
|
const r = new ParallelBehavior(success, failure);
|
|
222
234
|
|
|
223
|
-
|
|
235
|
+
r.addChildren(elements);
|
|
224
236
|
|
|
225
237
|
return r;
|
|
226
238
|
}
|
|
@@ -3,6 +3,10 @@ import { CompositeBehavior } from "./CompositeBehavior.js";
|
|
|
3
3
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
4
4
|
import { assert } from "../../../../core/assert.js";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Executes all contained behaviors one after another in a sequence, next behaviour in the sequence will not be started until the previous one signal success
|
|
8
|
+
* If any of the contained behaviours fail - the whole sequence fails
|
|
9
|
+
*/
|
|
6
10
|
export class SequenceBehavior extends CompositeBehavior {
|
|
7
11
|
constructor() {
|
|
8
12
|
super();
|
|
@@ -106,7 +110,7 @@ export class SequenceBehavior extends CompositeBehavior {
|
|
|
106
110
|
static from(list) {
|
|
107
111
|
const r = new SequenceBehavior();
|
|
108
112
|
|
|
109
|
-
|
|
113
|
+
r.addChildren(list);
|
|
110
114
|
|
|
111
115
|
return r;
|
|
112
116
|
}
|
|
@@ -2,12 +2,15 @@ import { Behavior } from "../Behavior.js";
|
|
|
2
2
|
import { BehaviorStatus } from "../BehaviorStatus.js";
|
|
3
3
|
import { assert } from "../../../../core/assert.js";
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Wait for a certain amount of time
|
|
7
|
+
*/
|
|
5
8
|
export class DelayBehavior extends Behavior {
|
|
6
9
|
constructor() {
|
|
7
10
|
super();
|
|
8
11
|
|
|
9
12
|
/**
|
|
10
|
-
* Delay value
|
|
13
|
+
* Delay value in seconds
|
|
11
14
|
* @type {number}
|
|
12
15
|
*/
|
|
13
16
|
this.value = 0;
|
|
@@ -38,11 +41,13 @@ export class DelayBehavior extends Behavior {
|
|
|
38
41
|
|
|
39
42
|
/**
|
|
40
43
|
*
|
|
41
|
-
* @param {number} value
|
|
44
|
+
* @param {number} value in seconds
|
|
42
45
|
* @return {DelayBehavior}
|
|
43
46
|
*/
|
|
44
47
|
static from(value) {
|
|
45
|
-
assert.
|
|
48
|
+
assert.isNumber(value, 'value');
|
|
49
|
+
assert.notNaN(value,'value');
|
|
50
|
+
assert.isFiniteNumber(value,'value');
|
|
46
51
|
|
|
47
52
|
const r = new DelayBehavior();
|
|
48
53
|
|