@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,107 @@
|
|
|
1
|
+
import { TypeEditor } from "../TypeEditor.js";
|
|
2
|
+
import { StringEditor } from "./primitive/StringEditor.js";
|
|
3
|
+
import ObservedString from "../../../../src/core/model/ObservedString.js";
|
|
4
|
+
import { ObservedStringEditor } from "./ObservedStringEditor.js";
|
|
5
|
+
import EmptyView from "../../../../src/view/elements/EmptyView.js";
|
|
6
|
+
import LabelView from "../../../../src/view/common/LabelView.js";
|
|
7
|
+
import { MouseEvents } from "../../../../src/engine/input/devices/events/MouseEvents.js";
|
|
8
|
+
import Signal from "../../../../src/core/events/signal/Signal.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* If path is larger than this - it will be truncated and displayed as non-input
|
|
12
|
+
* @readonly
|
|
13
|
+
* @type {number}
|
|
14
|
+
*/
|
|
15
|
+
const MAX_PATH_LENGTH_EDITABLE = 256;
|
|
16
|
+
/**
|
|
17
|
+
* How long to crop to
|
|
18
|
+
* @readonly
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
const MAX_CROP_LENGTH = 32;
|
|
22
|
+
|
|
23
|
+
export class LargeStrongEditor extends TypeEditor {
|
|
24
|
+
inline = true;
|
|
25
|
+
|
|
26
|
+
build(parent, field, registry) {
|
|
27
|
+
let url_editor;
|
|
28
|
+
|
|
29
|
+
if (field.type === String) {
|
|
30
|
+
|
|
31
|
+
url_editor = new StringEditor();
|
|
32
|
+
|
|
33
|
+
} else if (field.type === ObservedString) {
|
|
34
|
+
|
|
35
|
+
url_editor = new ObservedStringEditor();
|
|
36
|
+
|
|
37
|
+
} else {
|
|
38
|
+
throw new Error(`Unsupported type`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let in_focus = false;
|
|
42
|
+
|
|
43
|
+
const vEditor = url_editor.build(parent, field, registry);
|
|
44
|
+
|
|
45
|
+
const truncated_url = new ObservedString('');
|
|
46
|
+
const vTruncated = new LabelView(truncated_url);
|
|
47
|
+
|
|
48
|
+
vTruncated.el.addEventListener(MouseEvents.Click, () => {
|
|
49
|
+
in_focus = true;
|
|
50
|
+
update();
|
|
51
|
+
vEditor.el.focus();
|
|
52
|
+
});
|
|
53
|
+
vEditor.el.addEventListener('focusin', () => {
|
|
54
|
+
in_focus = true;
|
|
55
|
+
update();
|
|
56
|
+
});
|
|
57
|
+
vEditor.el.addEventListener('blur', () => {
|
|
58
|
+
in_focus = false;
|
|
59
|
+
update();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const r = new EmptyView();
|
|
63
|
+
|
|
64
|
+
function update() {
|
|
65
|
+
const url = field.adapter.read(parent, field.name);
|
|
66
|
+
|
|
67
|
+
if (typeof url === "string" && url.length > MAX_PATH_LENGTH_EDITABLE && !in_focus) {
|
|
68
|
+
r.removeChild(vEditor);
|
|
69
|
+
|
|
70
|
+
truncated_url.set('[...]'+url.slice(0, MAX_CROP_LENGTH));
|
|
71
|
+
|
|
72
|
+
if (!r.hasChild(vTruncated)) {
|
|
73
|
+
r.addChild(vTruncated);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
} else if(!r.hasChild(vEditor)){
|
|
77
|
+
r.removeChild(vTruncated);
|
|
78
|
+
r.addChild(vEditor);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const input_changed = new Signal();
|
|
83
|
+
|
|
84
|
+
vEditor.el.addEventListener('input', () => {
|
|
85
|
+
|
|
86
|
+
const value = vEditor.el.value;
|
|
87
|
+
|
|
88
|
+
input_changed.send1(value);
|
|
89
|
+
|
|
90
|
+
update();
|
|
91
|
+
});
|
|
92
|
+
r.on.linked.add(update);
|
|
93
|
+
|
|
94
|
+
return {
|
|
95
|
+
view: r, signals: {
|
|
96
|
+
input_changed
|
|
97
|
+
},
|
|
98
|
+
methods: {
|
|
99
|
+
set_value(v) {
|
|
100
|
+
field.adapter.write(parent, field.name, v);
|
|
101
|
+
update();
|
|
102
|
+
vEditor.el.value = v;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { TypeEditor } from "../TypeEditor.js";
|
|
2
|
+
import EmptyView from "../../../../src/view/elements/EmptyView.js";
|
|
3
|
+
import { NumberController } from "../../../view/ecs/components/common/NumberController.js";
|
|
4
|
+
import LabelView from "../../../../src/view/common/LabelView.js";
|
|
5
|
+
|
|
6
|
+
export class NumericIntervalEditor extends TypeEditor {
|
|
7
|
+
build(parent, field, registry) {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {NumericInterval}
|
|
11
|
+
*/
|
|
12
|
+
const interval = field.adapter?.read(parent, field.name);
|
|
13
|
+
|
|
14
|
+
const r = new EmptyView({
|
|
15
|
+
classList: ["inline-field-row-editor"]
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const c_0 = new NumberController({ value: interval.min });
|
|
19
|
+
const c_1 = new NumberController({ value: interval.max });
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
r.addChild(new LabelView("min"))
|
|
23
|
+
r.addChild(c_0);
|
|
24
|
+
r.addChild(new LabelView("max"))
|
|
25
|
+
r.addChild(c_1);
|
|
26
|
+
|
|
27
|
+
let lock = false;
|
|
28
|
+
|
|
29
|
+
const sync_up = () => {
|
|
30
|
+
if (lock) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
lock = true;
|
|
35
|
+
|
|
36
|
+
c_0.value.set(interval.min);
|
|
37
|
+
c_1.value.set(interval.max);
|
|
38
|
+
|
|
39
|
+
lock = false;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const sync_down = () => {
|
|
43
|
+
|
|
44
|
+
if (lock) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
lock = true;
|
|
49
|
+
|
|
50
|
+
const v0 = c_0.value.getValue();
|
|
51
|
+
const v1 = c_1.value.getValue();
|
|
52
|
+
|
|
53
|
+
if (v0 <= v1) {
|
|
54
|
+
|
|
55
|
+
interval.set(
|
|
56
|
+
v0,
|
|
57
|
+
v1,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
lock = false;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
r.on.linked.add(sync_up);
|
|
65
|
+
|
|
66
|
+
r.bindSignal(interval.onChanged, sync_up);
|
|
67
|
+
|
|
68
|
+
r.bindSignal(c_0.value.onChanged, sync_down);
|
|
69
|
+
r.bindSignal(c_1.value.onChanged, sync_down);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
const validate = () => {
|
|
73
|
+
// validation
|
|
74
|
+
|
|
75
|
+
if (c_0.value.getValue() > c_1.value.getValue()) {
|
|
76
|
+
// restore
|
|
77
|
+
sync_up();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
c_0.el.addEventListener('blur', validate);
|
|
82
|
+
c_1.el.addEventListener('blur', validate);
|
|
83
|
+
|
|
84
|
+
return r;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TypeEditor } from "../TypeEditor.js";
|
|
2
|
+
import { CheckboxView } from "../../../../src/view/elements/CheckboxView.js";
|
|
3
|
+
|
|
4
|
+
export class ObservedBooleanEditor extends TypeEditor {
|
|
5
|
+
build(parent, field, registry) {
|
|
6
|
+
|
|
7
|
+
const ctrl = new CheckboxView({
|
|
8
|
+
value: field.adapter.read(parent, field.name)
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return ctrl;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TypeEditor } from "../TypeEditor.js";
|
|
2
|
+
import DropDownSelectionView from "../../../../src/view/elements/DropDownSelectionView.js";
|
|
3
|
+
import List from "../../../../src/core/collection/list/List.js";
|
|
4
|
+
import { objectKeyByValue } from "../../../../src/core/model/object/objectKeyByValue.js";
|
|
5
|
+
|
|
6
|
+
export class ObservedEnumEditor extends TypeEditor {
|
|
7
|
+
build(parent, field, registry) {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @type {ObservedEnum}
|
|
11
|
+
*/
|
|
12
|
+
const value = field.adapter.read(parent, field.name);
|
|
13
|
+
|
|
14
|
+
const valueSet = value.getValidValueSet();
|
|
15
|
+
|
|
16
|
+
const ctrl = new DropDownSelectionView(
|
|
17
|
+
new List(Object.keys(valueSet)), {
|
|
18
|
+
changeListener(key) {
|
|
19
|
+
const v = valueSet[key];
|
|
20
|
+
|
|
21
|
+
value.set(v);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
ctrl.on.linked.add(() => {
|
|
27
|
+
ctrl.setSelectedValue(objectKeyByValue(valueSet, value.getValue()));
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
return ctrl;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TypeEditor } from "../TypeEditor.js";
|
|
2
|
+
import { NumberController } from "../../../view/ecs/components/common/NumberController.js";
|
|
3
|
+
|
|
4
|
+
export class ObservedIntegerEditor extends TypeEditor {
|
|
5
|
+
build(parent, field, registry) {
|
|
6
|
+
const instance = field.adapter.read(parent, field.name);
|
|
7
|
+
const ctrl = new NumberController();
|
|
8
|
+
|
|
9
|
+
let lock = false;
|
|
10
|
+
|
|
11
|
+
function sync_down() {
|
|
12
|
+
|
|
13
|
+
if (lock) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
lock = true;
|
|
18
|
+
|
|
19
|
+
instance.set(ctrl.value.getValue());
|
|
20
|
+
|
|
21
|
+
lock = false;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function sync_up() {
|
|
25
|
+
if (lock) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
lock = true;
|
|
30
|
+
|
|
31
|
+
ctrl.value.set(instance.getValue());
|
|
32
|
+
|
|
33
|
+
lock = false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
ctrl.on.linked.add(sync_up);
|
|
37
|
+
|
|
38
|
+
ctrl.value.onChanged.add(sync_down);
|
|
39
|
+
ctrl.bindSignal(instance.onChanged, sync_up);
|
|
40
|
+
|
|
41
|
+
return ctrl;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { TypeEditor } from "../TypeEditor.js";
|
|
2
|
+
import EmptyView from "../../../../src/view/elements/EmptyView.js";
|
|
3
|
+
|
|
4
|
+
export class ObservedStringEditor extends TypeEditor {
|
|
5
|
+
build(parent, field, registry) {
|
|
6
|
+
|
|
7
|
+
const ctrl = new EmptyView({
|
|
8
|
+
tag: 'input'
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
ctrl.attr({
|
|
12
|
+
type: 'text'
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const value = field.adapter.read(parent, field.name);
|
|
16
|
+
|
|
17
|
+
let lock = false;
|
|
18
|
+
|
|
19
|
+
function sync_up() {
|
|
20
|
+
if (lock) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
lock = true;
|
|
25
|
+
|
|
26
|
+
ctrl.el.value = value.getValue();
|
|
27
|
+
|
|
28
|
+
lock = false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function sync_down() {
|
|
32
|
+
if (lock) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
lock = true;
|
|
37
|
+
const str = ctrl.el.value;
|
|
38
|
+
|
|
39
|
+
value.set(str);
|
|
40
|
+
|
|
41
|
+
lock = false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ctrl.on.linked.add(sync_up);
|
|
45
|
+
ctrl.bindSignal(value.onChanged, sync_up);
|
|
46
|
+
ctrl.el.addEventListener('input', sync_down);
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
return ctrl;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { TypeEditor } from "../TypeEditor.js";
|
|
2
|
+
import { CanvasView } from "../../../../src/view/elements/CanvasView.js";
|
|
3
|
+
import sampler2D2Canvas from "../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
4
|
+
import { scaleSampler2D } from "../../../../src/engine/graphics/texture/sampler/scaleSampler2D.js";
|
|
5
|
+
import { Sampler2D } from "../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
|
|
6
|
+
import {
|
|
7
|
+
typedArrayConstructorByInstance
|
|
8
|
+
} from "../../../../src/engine/graphics/texture/sampler/typedArrayConstructorByInstance.js";
|
|
9
|
+
import { FrameRunner } from "../../../../src/engine/graphics/FrameRunner.js";
|
|
10
|
+
import canvas2Sampler2D from "../../../../src/engine/graphics/texture/Canvas2Sampler2D.js";
|
|
11
|
+
import {
|
|
12
|
+
copy_Sampler2D_channel_data
|
|
13
|
+
} from "../../../../src/engine/graphics/texture/sampler/copy_Sampler2D_channel_data.js";
|
|
14
|
+
import { MouseEvents } from "../../../../src/engine/input/devices/events/MouseEvents.js";
|
|
15
|
+
import { downloadSampler2DAsPNG } from "../../../../src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js";
|
|
16
|
+
import {
|
|
17
|
+
sampler2d_compute_texel_value_conversion_scale_to_uint8
|
|
18
|
+
} from "../../../../src/engine/graphics/texture/sampler/sampler2d_compute_texel_value_conversion_scale_to_uint8.js";
|
|
19
|
+
import EmptyView from "../../../../src/view/elements/EmptyView.js";
|
|
20
|
+
|
|
21
|
+
const UPDATE_DELAY = 200;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {Sampler2D} sampler
|
|
26
|
+
* @param {HTMLCanvasElement} domElement
|
|
27
|
+
*/
|
|
28
|
+
function draw_sampler(sampler, domElement) {
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
let TypedArrayConstructor = typedArrayConstructorByInstance(sampler.data);
|
|
32
|
+
|
|
33
|
+
if (TypedArrayConstructor === Uint8Array) {
|
|
34
|
+
// use clamped array to avoid filtering artifacts
|
|
35
|
+
TypedArrayConstructor = Uint8ClampedArray;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const res = 32;
|
|
39
|
+
const result_sampler = new Sampler2D(new TypedArrayConstructor(sampler.itemSize * res * res), sampler.itemSize, res, res);
|
|
40
|
+
|
|
41
|
+
scaleSampler2D(sampler, result_sampler);
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
const { scale, offset } = sampler2d_compute_texel_value_conversion_scale_to_uint8(result_sampler);
|
|
45
|
+
|
|
46
|
+
sampler2D2Canvas(result_sampler, scale, offset, domElement);
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {*} parent
|
|
53
|
+
* @param {HTMLCanvasElement} element
|
|
54
|
+
* @param {FieldDescriptor} field
|
|
55
|
+
*/
|
|
56
|
+
function enable_drop(parent, element, field) {
|
|
57
|
+
/**
|
|
58
|
+
*
|
|
59
|
+
* @param {DragEvent} ev
|
|
60
|
+
*/
|
|
61
|
+
function handleDrop(ev) {
|
|
62
|
+
ev.preventDefault();
|
|
63
|
+
|
|
64
|
+
let processed = false;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {File} file
|
|
69
|
+
*/
|
|
70
|
+
function processFile(file) {
|
|
71
|
+
if (processed) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
var img = new Image();
|
|
76
|
+
// URL @ Mozilla, webkitURL @ Chrome
|
|
77
|
+
img.src = (window.webkitURL ? webkitURL : URL).createObjectURL(file);
|
|
78
|
+
|
|
79
|
+
// call ctx.drawImage when the image got loaded
|
|
80
|
+
img.onload = function () {
|
|
81
|
+
var canvas = document.createElement("canvas");
|
|
82
|
+
var ctx = canvas.getContext("2d");
|
|
83
|
+
|
|
84
|
+
const width = img.width;
|
|
85
|
+
const height = img.height;
|
|
86
|
+
|
|
87
|
+
canvas.style.width = `${width}px`;
|
|
88
|
+
canvas.style.height = `${height}px`;
|
|
89
|
+
|
|
90
|
+
canvas.width = width;
|
|
91
|
+
canvas.height = height;
|
|
92
|
+
|
|
93
|
+
// ctx.drawImage(img, 0, 0);
|
|
94
|
+
ctx.drawImage(img, 0, 0, width, height, 0, 0, width, height); // stretch img to canvas size
|
|
95
|
+
|
|
96
|
+
const file_data_sampler = canvas2Sampler2D(canvas);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @type {Sampler2D}
|
|
100
|
+
*/
|
|
101
|
+
const sampler = field.adapter.read(parent, field.name);
|
|
102
|
+
|
|
103
|
+
sampler.resize(width, height, false);
|
|
104
|
+
|
|
105
|
+
copy_Sampler2D_channel_data(file_data_sampler, sampler);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
processed = true;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (ev.dataTransfer.items) {
|
|
113
|
+
// Use DataTransferItemList interface to access the file(s)
|
|
114
|
+
for (var i = 0; i < ev.dataTransfer.items.length; i++) {
|
|
115
|
+
// If dropped items aren't files, reject them
|
|
116
|
+
if (ev.dataTransfer.items[i].kind === 'file') {
|
|
117
|
+
var file = ev.dataTransfer.items[i].getAsFile();
|
|
118
|
+
|
|
119
|
+
processFile(file);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} else {
|
|
123
|
+
// Use DataTransfer interface to access the file(s)
|
|
124
|
+
for (var i = 0; i < ev.dataTransfer.files.length; i++) {
|
|
125
|
+
const file = ev.dataTransfer.files[i];
|
|
126
|
+
|
|
127
|
+
processFile(file);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function handleDragOver(ev) {
|
|
133
|
+
|
|
134
|
+
// Prevent default behavior (Prevent file from being opened)
|
|
135
|
+
ev.preventDefault();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
element.addEventListener('dragover', handleDragOver);
|
|
139
|
+
element.addEventListener('drop', handleDrop);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export class Sampler2DEditor extends TypeEditor {
|
|
143
|
+
|
|
144
|
+
build(parent, field, context) {
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @type {Sampler2D}
|
|
148
|
+
*/
|
|
149
|
+
const sampler = field.adapter.read(parent, field.name);
|
|
150
|
+
|
|
151
|
+
let last_version = -1;
|
|
152
|
+
let last_update_time = 0;
|
|
153
|
+
let last_update_duration = 0;
|
|
154
|
+
|
|
155
|
+
const view_container = new EmptyView({
|
|
156
|
+
css:{
|
|
157
|
+
width: "min-content",
|
|
158
|
+
height:"min-content"
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
const canvas_view = new CanvasView();
|
|
163
|
+
canvas_view.css({
|
|
164
|
+
background: 'black',
|
|
165
|
+
position: 'relative',
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
function draw() {
|
|
169
|
+
const draw_start_time = performance.now();
|
|
170
|
+
|
|
171
|
+
draw_sampler(sampler, canvas_view.el);
|
|
172
|
+
|
|
173
|
+
last_version = sampler.version;
|
|
174
|
+
|
|
175
|
+
const draw_end_time = performance.now();
|
|
176
|
+
last_update_duration = draw_end_time - draw_start_time;
|
|
177
|
+
|
|
178
|
+
last_update_time = draw_end_time;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
canvas_view.on.linked.add(try_update);
|
|
183
|
+
|
|
184
|
+
function try_update() {
|
|
185
|
+
if (sampler.version !== last_version) {
|
|
186
|
+
|
|
187
|
+
const time_now = performance.now();
|
|
188
|
+
|
|
189
|
+
if ((time_now - last_update_time) >= UPDATE_DELAY) {
|
|
190
|
+
draw();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const frameRunner = new FrameRunner(try_update);
|
|
196
|
+
|
|
197
|
+
canvas_view.on.linked.add(frameRunner.startup, frameRunner);
|
|
198
|
+
canvas_view.on.unlinked.add(frameRunner.shutdown, frameRunner);
|
|
199
|
+
|
|
200
|
+
//drop target
|
|
201
|
+
const allow_drop = true;
|
|
202
|
+
if (allow_drop) {
|
|
203
|
+
|
|
204
|
+
enable_drop(parent, canvas_view.el, field);
|
|
205
|
+
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const allow_download = true;
|
|
209
|
+
if (allow_download) {
|
|
210
|
+
canvas_view.el.addEventListener(MouseEvents.Click, () => {
|
|
211
|
+
downloadSampler2DAsPNG(sampler, field.name);
|
|
212
|
+
});
|
|
213
|
+
// add download marker
|
|
214
|
+
view_container.addClass('downloadable');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
view_container.addChild(canvas_view);
|
|
218
|
+
|
|
219
|
+
return view_container;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { TypeEditor } from "../../TypeEditor.js";
|
|
2
|
+
import { NativeListController } from "../../../../../src/view/controller/controls/NativeListController.js";
|
|
3
|
+
import { buildObjectEditorFromRegistry } from "../../createObjectEditor.js";
|
|
4
|
+
import LabelView from "../../../../../src/view/common/LabelView.js";
|
|
5
|
+
import { FieldDescriptor } from "../../FieldDescriptor.js";
|
|
6
|
+
import { FieldValueAdapter } from "../../FieldValueAdapter.js";
|
|
7
|
+
|
|
8
|
+
export class ListEditor extends TypeEditor {
|
|
9
|
+
inline = false;
|
|
10
|
+
|
|
11
|
+
build(parent, field, registry) {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
const list = field.adapter.read(parent, field.name);
|
|
15
|
+
|
|
16
|
+
if (list.length > 100) {
|
|
17
|
+
return new LabelView(`List is too big (length = ${list.length})`);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let ElementType;
|
|
21
|
+
|
|
22
|
+
const field_schema = field.schema;
|
|
23
|
+
|
|
24
|
+
if (field_schema !== undefined) {
|
|
25
|
+
|
|
26
|
+
const type_parameters = field_schema.type_parameters;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (type_parameters === undefined || type_parameters.length < 1) {
|
|
30
|
+
// no type specified on schema
|
|
31
|
+
|
|
32
|
+
} else {
|
|
33
|
+
|
|
34
|
+
ElementType = type_parameters[0];
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let inferred_type = false;
|
|
40
|
+
|
|
41
|
+
if (ElementType === undefined && list.length > 0) {
|
|
42
|
+
ElementType = list.get(0).constructor;
|
|
43
|
+
inferred_type = true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (ElementType === undefined) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (inferred_type && !registry.has(ElementType)) {
|
|
51
|
+
// only work with known types when type is inferred, too messy otherwise
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return new NativeListController({
|
|
56
|
+
model: list,
|
|
57
|
+
elementFactory() {
|
|
58
|
+
return new ElementType();
|
|
59
|
+
},
|
|
60
|
+
elementViewFactory(el) {
|
|
61
|
+
const fd = new FieldDescriptor();
|
|
62
|
+
|
|
63
|
+
let last_known = el;
|
|
64
|
+
|
|
65
|
+
fd.type = ElementType;
|
|
66
|
+
fd.adapter = new FieldValueAdapter();
|
|
67
|
+
fd.adapter.read = (object, field_name) => {
|
|
68
|
+
return last_known;
|
|
69
|
+
};
|
|
70
|
+
fd.adapter.write = (object, field_name, value) => {
|
|
71
|
+
const i = list.indexOf(last_known);
|
|
72
|
+
|
|
73
|
+
list.set(i, value);
|
|
74
|
+
|
|
75
|
+
last_known = value;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return buildObjectEditorFromRegistry(el, registry, fd);
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
}
|