@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.
Files changed (169) hide show
  1. package/editor/Editor.js +793 -0
  2. package/editor/SelectionVisualizer.js +148 -0
  3. package/editor/actions/concrete/ActionUpdateTexture.js +21 -0
  4. package/editor/actions/concrete/ArrayCopyAction.js +39 -0
  5. package/editor/actions/concrete/ComponentAddAction.js +47 -0
  6. package/editor/actions/concrete/ComponentRemoveAction.js +38 -0
  7. package/editor/actions/concrete/EntityCreateAction.js +47 -0
  8. package/editor/actions/concrete/EntityRemoveAction.js +51 -0
  9. package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
  10. package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
  11. package/editor/actions/concrete/ModifyPatchTextureArray2DAction.js +182 -0
  12. package/editor/actions/concrete/PaintTerrainOverlayAction.js +45 -0
  13. package/editor/actions/concrete/PatchTerrainHeightAction.js +67 -0
  14. package/editor/actions/concrete/PatchTerrainTextureAction.js +152 -0
  15. package/editor/actions/concrete/SelectionAddAction.js +36 -0
  16. package/editor/actions/concrete/SelectionClearAction.js +22 -0
  17. package/editor/actions/concrete/SelectionRemoveAction.js +30 -0
  18. package/editor/actions/concrete/TransformModifyAction.js +46 -0
  19. package/editor/actions/concrete/WriteGridValueAction.js +46 -0
  20. package/editor/ecs/EditorEntity.js +12 -0
  21. package/editor/ecs/EditorEntitySystem.js +14 -0
  22. package/editor/ecs/component/FieldDescriptor.js +34 -0
  23. package/editor/ecs/component/FieldValueAdapter.js +20 -0
  24. package/editor/ecs/component/TypeEditor.js +33 -0
  25. package/editor/ecs/component/TypeSchema.d.ts +38 -0
  26. package/editor/ecs/component/createFieldEditor.js +92 -0
  27. package/editor/ecs/component/createObjectEditor.js +361 -0
  28. package/editor/ecs/component/editors/ColorEditor.js +39 -0
  29. package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
  30. package/editor/ecs/component/editors/ImagePathEditor.js +82 -0
  31. package/editor/ecs/component/editors/LargeStrongEditor.js +107 -0
  32. package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
  33. package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
  34. package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
  35. package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
  36. package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
  37. package/editor/ecs/component/editors/Sampler2DEditor.js +221 -0
  38. package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
  39. package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
  40. package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
  41. package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
  42. package/editor/ecs/component/editors/common/noEditor.js +9 -0
  43. package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
  44. package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
  45. package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +225 -0
  46. package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
  47. package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.js +18 -0
  48. package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
  49. package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +58 -0
  50. package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
  51. package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
  52. package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
  53. package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
  54. package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +95 -0
  55. package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
  56. package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
  57. package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
  58. package/editor/ecs/component/editors/geom/QuaternionEditor.js +63 -0
  59. package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
  60. package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
  61. package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
  62. package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
  63. package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
  64. package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
  65. package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
  66. package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
  67. package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
  68. package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
  69. package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
  70. package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
  71. package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
  72. package/editor/ecs/component/editors/three/TextureEditor.js +112 -0
  73. package/editor/ecs/component/findNearestRegisteredType.js +59 -0
  74. package/editor/ecs/component/prototypeObjectEditor.js +379 -0
  75. package/editor/enableEditor.js +85 -0
  76. package/editor/library/MeshLibrary.js +33 -0
  77. package/editor/process/DisableGameUIProcess.js +43 -0
  78. package/editor/process/EditorProcess.js +35 -0
  79. package/editor/process/ObstacleGridDisplayProcess.js +120 -0
  80. package/editor/process/ProcessEngine.js +123 -0
  81. package/editor/process/SymbolicDisplayProcess.js +132 -0
  82. package/editor/process/symbolic/ComponentSymbolicDisplay.js +34 -0
  83. package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +159 -0
  84. package/editor/process/symbolic/buildThreeJSHelperEntity.js +36 -0
  85. package/editor/process/symbolic/make3DSymbolicDisplay.js +91 -0
  86. package/editor/process/symbolic/makeCameraSymbolicDisplay.js +32 -0
  87. package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +176 -0
  88. package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
  89. package/editor/process/symbolic/makeHelperSphereGeometry.js +73 -0
  90. package/editor/process/symbolic/makeLightSymbolicDisplay.js +77 -0
  91. package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +146 -0
  92. package/editor/process/symbolic/makePathSymbolicDisplay.js +105 -0
  93. package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +74 -0
  94. package/editor/process/symbolic/makeSocketsSymbolicDisplay.js +153 -0
  95. package/editor/process/symbolic/makeSolidArrowGeometry.js +391 -0
  96. package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +89 -0
  97. package/editor/process/symbolic/makeStoryTriggerSetAreaDisplay.js +114 -0
  98. package/editor/process/symbolic/synchronizeTransform.js +50 -0
  99. package/editor/tools/FoliagePaintTool.js +168 -0
  100. package/editor/tools/GridPaintTool.js +247 -0
  101. package/editor/tools/SelectionTool.js +407 -0
  102. package/editor/tools/TopDownCameraControlTool.js +59 -0
  103. package/editor/tools/TransformTool.js +370 -0
  104. package/editor/tools/engine/Tool.js +121 -0
  105. package/editor/tools/engine/ToolEngine.js +193 -0
  106. package/editor/tools/engine/ToolState.js +9 -0
  107. package/editor/tools/engine/ToolStateMachine.js +53 -0
  108. package/editor/tools/paint/TerrainHeightPaintTool.js +297 -0
  109. package/editor/tools/paint/TerrainPaintTool.js +211 -0
  110. package/editor/tools/paint/TerrainTexturePaintTool.js +193 -0
  111. package/editor/tools/paint/prototypeTerrainEditor.js +135 -0
  112. package/editor/tools/v2/BlenderCameraOrientationGizmo.d.ts +50 -0
  113. package/editor/tools/v2/BlenderCameraOrientationGizmo.js +500 -0
  114. package/editor/tools/v2/TransformControls.d.ts +20 -0
  115. package/editor/tools/v2/TransformControls.js +1782 -0
  116. package/editor/tools/v2/prototypeTransformControls.js +92 -0
  117. package/editor/view/EditorView.js +462 -0
  118. package/editor/view/GridPickCoordinateView.js +88 -0
  119. package/editor/view/ecs/ComponentControlFactory.js +48 -0
  120. package/editor/view/ecs/ComponentControlView.js +214 -0
  121. package/editor/view/ecs/EntityEditor.js +258 -0
  122. package/editor/view/ecs/EntityList.js +258 -0
  123. package/editor/view/ecs/components/BlackboardController.js +50 -0
  124. package/editor/view/ecs/components/DatGuiController.js +216 -0
  125. package/editor/view/ecs/components/FogOfWarController.js +78 -0
  126. package/editor/view/ecs/components/FogOfWarRevealerController.js +44 -0
  127. package/editor/view/ecs/components/GeneratedArmyController.js +42 -0
  128. package/editor/view/ecs/components/GridObstacleController.js +72 -0
  129. package/editor/view/ecs/components/GridPositionController.js +40 -0
  130. package/editor/view/ecs/components/HeadsUpDisplayController.js +30 -0
  131. package/editor/view/ecs/components/HighlightController.js +47 -0
  132. package/editor/view/ecs/components/MeshController.js +125 -0
  133. package/editor/view/ecs/components/PathFollowerController.js +87 -0
  134. package/editor/view/ecs/components/TagController.js +80 -0
  135. package/editor/view/ecs/components/TerrainController.js +225 -0
  136. package/editor/view/ecs/components/TransformController.js +103 -0
  137. package/editor/view/ecs/components/UnitShopController.js +112 -0
  138. package/editor/view/ecs/components/army/ArmyController.js +130 -0
  139. package/editor/view/ecs/components/color/GaugeView.js +107 -0
  140. package/editor/view/ecs/components/common/AutoCanvasView.js +53 -0
  141. package/editor/view/ecs/components/common/LineView.js +17 -0
  142. package/editor/view/ecs/components/common/NumberController.js +112 -0
  143. package/editor/view/ecs/components/common/NumericIntervalController.js +64 -0
  144. package/editor/view/ecs/components/gui/GUIElementController.js +117 -0
  145. package/editor/view/ecs/components/items/ItemContainerController.js +132 -0
  146. package/editor/view/ecs/components/items/ItemContainerController.stories.js +50 -0
  147. package/editor/view/ecs/components/items/ItemController.js +52 -0
  148. package/editor/view/ecs/components/particles/ColorParameterLUTController.js +444 -0
  149. package/editor/view/ecs/components/particles/ParameterTrackController.js +51 -0
  150. package/editor/view/ecs/components/particles/ParticleEmitterController.js +213 -0
  151. package/editor/view/ecs/components/particles/ParticleLayerController.js +213 -0
  152. package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +401 -0
  153. package/editor/view/ecs/components/sockets/AttachmentSocketsController.js +51 -0
  154. package/editor/view/ecs/components/sound/SoundEmitterController.js +137 -0
  155. package/editor/view/ecs/components/story/StoryTriggerSetController.js +214 -0
  156. package/editor/view/ecs/components/unit/AuraController.js +45 -0
  157. package/editor/view/library/MeshLibraryView.js +164 -0
  158. package/editor/view/node-graph/NodeGraphEditorView.js +170 -0
  159. package/editor/view/node-graph/NodeGraphView.js +453 -0
  160. package/editor/view/node-graph/NodeView.js +135 -0
  161. package/editor/view/node-graph/PortView.js +69 -0
  162. package/editor/view/process/ProcessView.js +63 -0
  163. package/editor/view/tools/ToolSettingsView.js +143 -0
  164. package/editor/view/tools/ToolView.js +58 -0
  165. package/package.json +2 -1
  166. package/src/engine/intelligence/behavior/composite/CompositeBehavior.js +18 -2
  167. package/src/engine/intelligence/behavior/composite/ParallelBehavior.js +21 -9
  168. package/src/engine/intelligence/behavior/composite/SequenceBehavior.js +5 -1
  169. package/src/engine/intelligence/behavior/util/DelayBehavior.js +8 -3
@@ -0,0 +1,80 @@
1
+ import { TypeEditor } from "../../TypeEditor.js";
2
+ import { assert } from "../../../../../src/core/assert.js";
3
+ import EmptyView from "../../../../../src/view/elements/EmptyView.js";
4
+ import { CheckboxView } from "../../../../../src/view/elements/CheckboxView.js";
5
+ import ObservedBoolean from "../../../../../src/core/model/ObservedBoolean.js";
6
+
7
+
8
+ /**
9
+ *
10
+ * @param {Object} parent
11
+ * @param {FieldDescriptor} field
12
+ * @param {string} key
13
+ * @param {Object<number>} definition
14
+ */
15
+ function make_flag_editor(parent, field, key, definition) {
16
+ const mask = definition[key];
17
+
18
+ function get_field_value() {
19
+ return field.adapter.read(parent, field.name);
20
+ }
21
+
22
+ function read() {
23
+ const flags = get_field_value();
24
+
25
+ return (flags & mask) !== 0;
26
+ }
27
+
28
+ const flag = new ObservedBoolean(read());
29
+
30
+ const r = new CheckboxView({ value: flag });
31
+
32
+ r.attr({
33
+ // Tooltip
34
+ title: key
35
+ })
36
+
37
+ flag.onChanged.add((v) => {
38
+ const flags = get_field_value();
39
+
40
+ let new_flags;
41
+
42
+ if (v) {
43
+ new_flags = flags | mask;
44
+ } else {
45
+ new_flags = flags & ~(mask);
46
+ }
47
+
48
+ field.adapter.write(parent, field.name, new_flags);
49
+ });
50
+
51
+ return r;
52
+ }
53
+
54
+ export class BitFlagsEditor extends TypeEditor {
55
+ /**
56
+ *
57
+ * @param {Object<number>} definition
58
+ */
59
+ constructor(definition) {
60
+ super();
61
+
62
+ assert.defined(definition, 'definition');
63
+
64
+ this.definition = definition;
65
+ }
66
+
67
+ build(parent, field, registry) {
68
+ const flag_names = Object.keys(this.definition);
69
+
70
+ const r = new EmptyView();
71
+
72
+ for (let i = 0; i < flag_names.length; i++) {
73
+ const flag_key = flag_names[i];
74
+
75
+ r.addChild(make_flag_editor(parent, field, flag_key, this.definition));
76
+ }
77
+
78
+ return r;
79
+ }
80
+ }
@@ -0,0 +1,41 @@
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 EnumEditor extends TypeEditor {
7
+ constructor(type) {
8
+ super();
9
+
10
+ this.type = type;
11
+ }
12
+
13
+ build(parent, field, registry) {
14
+
15
+ const valueSet = this.type;
16
+
17
+ function read() {
18
+ return field.adapter.read(parent, field.name);
19
+ }
20
+
21
+ function write(v) {
22
+ field.adapter.write(parent, field.name, v);
23
+ }
24
+
25
+ const ctrl = new DropDownSelectionView(
26
+ new List(Object.keys(valueSet)), {
27
+ changeListener(key) {
28
+ const v = valueSet[key];
29
+
30
+ write(v);
31
+ }
32
+ }
33
+ );
34
+
35
+ ctrl.on.linked.add(() => {
36
+ ctrl.setSelectedValue(objectKeyByValue(valueSet, read()));
37
+ })
38
+
39
+ return ctrl;
40
+ }
41
+ }
@@ -0,0 +1,85 @@
1
+ import EmptyView from "../../../../../src/view/elements/EmptyView.js";
2
+ import { NumberController } from "../../../../view/ecs/components/common/NumberController.js";
3
+ import LabelView from "../../../../../src/view/common/LabelView.js";
4
+
5
+ /**
6
+ *
7
+ * @param {string[]} props
8
+ * @param {} value
9
+ * @param {Signal} change_signal
10
+ */
11
+ export function make_row_editor(props, value, change_signal = value.onChanged) {
12
+
13
+ const r = new EmptyView({
14
+ classList: ['inline-field-row-editor']
15
+ });
16
+
17
+ const ctrls = [];
18
+
19
+ for (let i = 0; i < props.length; i++) {
20
+ const prop_name = props[i];
21
+
22
+ const ctrl = new NumberController({
23
+ value: value[prop_name]
24
+ });
25
+
26
+ r.addChild(new LabelView(prop_name));
27
+ r.addChild(ctrl);
28
+
29
+ ctrls[i] = ctrl;
30
+ }
31
+
32
+ let lock = false;
33
+
34
+ const sync_up = () => {
35
+ if (lock) {
36
+ return;
37
+ }
38
+
39
+ lock = true;
40
+
41
+ for (let i = 0; i < props.length; i++) {
42
+ const prop_name = props[i];
43
+
44
+ ctrls[i].value.set(value[prop_name]);
45
+ }
46
+
47
+
48
+ lock = false;
49
+ };
50
+
51
+ const sync_down = () => {
52
+
53
+ if (lock) {
54
+ return;
55
+ }
56
+
57
+ lock = true;
58
+
59
+ const params = ctrls.map(c => c.value.getValue());
60
+
61
+ value.set.apply(value, params);
62
+
63
+ lock = false;
64
+ };
65
+
66
+ r.on.linked.add(sync_up);
67
+
68
+ r.bindSignal(change_signal, sync_up);
69
+
70
+ for (let i = 0; i < props.length; i++) {
71
+
72
+ ctrls[i].value.onChanged.add(sync_down);
73
+ }
74
+
75
+ return r;
76
+ }
77
+
78
+ /**
79
+ *
80
+ * @param {Vector3} v3
81
+ * @returns {EmptyView}
82
+ */
83
+ export function makeV3_editor(v3) {
84
+ return make_row_editor(['x', 'y', 'z'], v3);
85
+ }
@@ -0,0 +1,9 @@
1
+ import { TypeEditor } from "../../TypeEditor.js";
2
+
3
+ export function noEditor() {
4
+ const editor = new TypeEditor();
5
+
6
+ Object.defineProperty(editor, "hidden", { value: true });
7
+
8
+ return editor;
9
+ }
@@ -0,0 +1,17 @@
1
+ import { TypeEditor } from "../../TypeEditor.js";
2
+ import { CanvasView } from "../../../../../src/view/elements/CanvasView.js";
3
+ import { buildGridObstaclePreview } from "../../../../view/ecs/components/GridObstacleController.js";
4
+
5
+ export class GridObstacleEditor extends TypeEditor {
6
+ inline = false
7
+
8
+ build(parent, field, registry) {
9
+ const v = new CanvasView();
10
+
11
+ v.size.set(100, 100);
12
+
13
+ buildGridObstaclePreview(field.adapter.read(parent, field.name), v.el);
14
+
15
+ return v;
16
+ }
17
+ }
@@ -0,0 +1,16 @@
1
+ import { ObjectEditor } from "../primitive/ObjectEditor.js";
2
+ import ObservedString from "../../../../../src/core/model/ObservedString.js";
3
+ import { ImagePathEditor } from "../ImagePathEditor.js";
4
+
5
+ export class MinimapMarkerEditor extends ObjectEditor {
6
+ get schema() {
7
+ return {
8
+ properties: {
9
+ iconURL: {
10
+ type: ObservedString,
11
+ editor: new ImagePathEditor()
12
+ }
13
+ }
14
+ };
15
+ }
16
+ }
@@ -0,0 +1,225 @@
1
+ import { TypeEditor } from "../../TypeEditor.js";
2
+ import { CanvasView } from "../../../../../src/view/elements/CanvasView.js";
3
+ import { plot_data } from "../../../../../src/engine/animation/curve/draw/plot_data.js";
4
+ import Vector2 from "../../../../../src/core/geom/Vector2.js";
5
+ import EmptyView from "../../../../../src/view/elements/EmptyView.js";
6
+ import { MouseEvents } from "../../../../../src/engine/input/devices/events/MouseEvents.js";
7
+
8
+ export class ParameterLookupTableEditor extends TypeEditor {
9
+ get schema() {
10
+ return {
11
+ properties: {
12
+ on: {
13
+ transient: true
14
+ }
15
+ }
16
+ };
17
+ }
18
+
19
+ build(parent, field,registry) {
20
+
21
+ /**
22
+ * @type {ParameterLookupTable}
23
+ */
24
+ const lut = field.adapter.read(parent, field.name);
25
+ const trackName = field.adapter.read(parent, "name");
26
+
27
+ // if it is a track scale
28
+ if (trackName === "scale"){
29
+ const canvasView = new CanvasView();
30
+ canvasView.size.set(200, 100);
31
+ const ctx = canvasView.context2d;
32
+
33
+ const data = [];
34
+
35
+ const sample = [];
36
+ for (let i = 0; i < canvasView.size.x; i++) {
37
+ const f = i / (canvasView.size.x - 1);
38
+
39
+ lut.sample(f, sample);
40
+
41
+ data[i] = sample[0];
42
+ }
43
+
44
+ plot_data({ ctx, data, width: canvasView.size.x, height: canvasView.size.y, margin: new Vector2(4, 4) });
45
+
46
+ return canvasView;
47
+ } else if (trackName === "color"){
48
+ // if it is color track
49
+ const resultView = new EmptyView();
50
+ const canvasView = new CanvasView();
51
+ canvasView.css({borderColor: 'white', borderStyle: 'solid', borderWidth: '1px',});
52
+ canvasView.size.set(200, 70);
53
+
54
+ const ctx = canvasView.context2d;
55
+
56
+ const colorView = new EmptyView({tag: "input", attr: {type: "color"}, css: {padding: "0px", border: "0px"}});
57
+
58
+ resultView.addChild(canvasView);
59
+ resultView.addChild(colorView);
60
+
61
+ //canvas internal configuration, such as background
62
+ let config = {
63
+ tileSize: new Vector2(10, 10),
64
+ tileColor1: "rgb(255, 255, 255)",
65
+ tileColor2: "rgb(119,119,119)",
66
+ gradientBoxYRange: new Vector2(30, canvasView.size.y),
67
+ };
68
+
69
+ this.DrawBackground(canvasView, ctx, config);
70
+ this.DrawGradient(canvasView, lut, ctx, config);
71
+ let stops = this.DrawStops(canvasView, lut, ctx, colorView, config, 0);
72
+
73
+ canvasView.el.addEventListener(MouseEvents.Click, (e) => {
74
+ const rect = canvasView.el.getBoundingClientRect();
75
+ let x = e.clientX - rect.left,
76
+ y = e.clientY - rect.top;
77
+ for (let i = 0; i < stops.length; i++) {
78
+ if (stops[i].x <= x && stops[i].x + stops[i].width >= x &&
79
+ stops[i].y <= y && stops[i].y + stops[i].height >= y){
80
+ let s = [];
81
+ lut.sample(lut.positions[i], s);
82
+
83
+ this.convertRGB(s);
84
+
85
+ colorView.el.value = this.RGBToHex(s[0], s[1], s[2]);
86
+ canvasView.clear();
87
+
88
+ this.DrawBackground(canvasView, ctx, config);
89
+ this.DrawGradient(canvasView, lut, ctx, config);
90
+ stops = this.DrawStops(canvasView, lut, ctx, colorView, config, i);
91
+
92
+ break;
93
+ }
94
+ }
95
+ });
96
+
97
+ return resultView;
98
+ }
99
+ }
100
+ /**
101
+ * converts rgb to hex string
102
+ * @param {Float} r
103
+ * @param {Float} g
104
+ * @param {Float} b
105
+ */
106
+ RGBToHex(r,g,b) {
107
+ r = r.toString(16);
108
+ g = g.toString(16);
109
+ b = b.toString(16);
110
+
111
+ if (r.length == 1)
112
+ r = "0" + r;
113
+ if (g.length == 1)
114
+ g = "0" + g;
115
+ if (b.length == 1)
116
+ b = "0" + b;
117
+
118
+ return "#" + r + g + b;
119
+ }
120
+
121
+ /**
122
+ * converts lut color sample to RGB
123
+ * @param {[]} sample
124
+ */
125
+ convertRGB(sample){
126
+ sample[0] = Math.floor(sample[0] * 255);
127
+ sample[1] = Math.floor(sample[1] * 255);
128
+ sample[2] = Math.floor(sample[2] * 255);
129
+ }
130
+ /**
131
+ * draws tiled background
132
+ * @param {CanvasView} canvasView
133
+ * @param {CanvasRenderingContext2D} ctx
134
+ * @param {{}} config
135
+ */
136
+ DrawBackground(canvasView, ctx, config){
137
+ for (let i = 0; i < canvasView.size.x; i += config.tileSize.x) {
138
+ for (let j = config.gradientBoxYRange.x; j < config.gradientBoxYRange.y; j += config.tileSize.y){
139
+ ctx.fillStyle = (((i / config.tileSize.x) + (j / config.tileSize.y)) % 2 === 0 ? config.tileColor1 : config.tileColor2);
140
+ ctx.fillRect(i, j, config.tileSize.x, config.tileSize.y);
141
+ }
142
+ }
143
+ }
144
+
145
+ /**
146
+ * draws gradient
147
+ * @param {CanvasView} canvasView
148
+ * @param {ParameterLookupTable} lut
149
+ * @param {CanvasRenderingContext2D} ctx
150
+ * @param {{}} config
151
+ */
152
+ DrawGradient(canvasView, lut, ctx, config){
153
+ const sample = [];
154
+ for (let i = 0; i < canvasView.size.x; i++) {
155
+ const f = i / (canvasView.size.x - 1);
156
+ lut.sample(f, sample);
157
+
158
+ this.convertRGB(sample);
159
+
160
+ ctx.fillStyle = `rgba(${sample[0]},${sample[1]},${sample[2]}, ${sample[3]})`;
161
+ ctx.fillRect(i, config.gradientBoxYRange.x, 1, config.gradientBoxYRange.y - config.gradientBoxYRange.x);
162
+ }
163
+ }
164
+
165
+ /**
166
+ * draws gradient stops
167
+ * @param {CanvasView} canvasView
168
+ * @param {ParameterLookupTable} lut
169
+ * @param {CanvasRenderingContext2D} ctx
170
+ * @param {EmptyView} colorView
171
+ * @param {{}} config
172
+ * @param {Integer} selectedInd
173
+ * @returns {*[]}
174
+ */
175
+ DrawStops(canvasView, lut, ctx, colorView, config, selectedInd){
176
+ const sample = [];
177
+
178
+ let stops = [];
179
+ for (let i = 0; i < lut.positions.length; i++){
180
+ const posX = lut.positions[i] * canvasView.size.x;
181
+ if (i === selectedInd){
182
+ lut.sample(lut.positions[i], sample);
183
+
184
+ this.convertRGB(sample);
185
+
186
+ colorView.el.value = this.RGBToHex(sample[0], sample[1], sample[2]);
187
+ }
188
+ stops.push(this.DrawStop(ctx, config, posX, i=== selectedInd));
189
+ }
190
+ return stops;
191
+ }
192
+ /**
193
+ * draws gradient stop
194
+ * @param {CanvasRenderingContext2D} ctx
195
+ * @param {Object} config
196
+ * @param {Integer} posX
197
+ * @param {Boolean} isSelected
198
+ */
199
+ DrawStop(ctx, config, posX, isSelected){
200
+ ctx.beginPath();
201
+ ctx.moveTo(posX, config.gradientBoxYRange.x + 7);
202
+ ctx.lineTo(posX - 5, config.gradientBoxYRange.x);
203
+ ctx.lineTo(posX - 5, config.gradientBoxYRange.x - 12);
204
+ ctx.lineTo(posX + 5, config.gradientBoxYRange.x - 12);
205
+ ctx.lineTo(posX + 5, config.gradientBoxYRange.x);
206
+ ctx.closePath();
207
+
208
+ ctx.lineWidth = (isSelected ? 4 : 2);
209
+ if (!isSelected)
210
+ ctx.strokeStyle = "rgb(114,114,114)";
211
+ else
212
+ ctx.strokeStyle = "rgb(0,23,255)";
213
+ ctx.stroke();
214
+ ctx.fillStyle = "rgb(255, 255, 255)";
215
+ ctx.fill();
216
+
217
+ return {
218
+ x: posX - 5,
219
+ y: config.gradientBoxYRange.x - 12,
220
+ width: 10,
221
+ height: 12,
222
+ posX: posX,
223
+ };
224
+ }
225
+ }
@@ -0,0 +1,17 @@
1
+ import { ObjectEditor } from "../primitive/ObjectEditor.js";
2
+ import { EnumEditor } from "../common/EnumEditor.js";
3
+
4
+ export class ParameterTrackEditor extends ObjectEditor {
5
+ get schema() {
6
+ return {
7
+ properties: {
8
+ name: {
9
+ editor: new EnumEditor({
10
+ Color: "color",
11
+ Scale: "scale"
12
+ })
13
+ }
14
+ }
15
+ };
16
+ }
17
+ }
@@ -0,0 +1,18 @@
1
+ import List from "../../../../../src/core/collection/list/List.js";
2
+ import { ObjectEditor } from "../primitive/ObjectEditor.js";
3
+ import {
4
+ ParameterTrack
5
+ } from "../../../../../src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js";
6
+
7
+ export class ParameterTrackSetEditor extends ObjectEditor {
8
+ get schema() {
9
+ return {
10
+ properties: {
11
+ tracks: {
12
+ type: List,
13
+ type_parameters: [ParameterTrack],
14
+ },
15
+ }
16
+ };
17
+ }
18
+ }
@@ -0,0 +1,58 @@
1
+ import List from "../../../../../src/core/collection/list/List.js";
2
+ import { ParticleLayer } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js";
3
+ import { BitFlagsEditor } from "../common/BitFlagsEditor.js";
4
+ import {
5
+ ParticleEmitterFlag
6
+ } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitterFlag.js";
7
+ import { ObjectEditor } from "../primitive/ObjectEditor.js";
8
+ import { EnumEditor } from "../common/EnumEditor.js";
9
+ import { BlendingType } from "../../../../../src/engine/graphics/texture/sampler/BlendingType.js";
10
+
11
+ export class ParticleEmitterEditor extends ObjectEditor {
12
+ get schema() {
13
+ return {
14
+ properties: {
15
+ parameters: {
16
+ transient: true
17
+ },
18
+ layers: {
19
+ type: List,
20
+ type_parameters: [ParticleLayer]
21
+ },
22
+ particles: {
23
+ transient: true
24
+ },
25
+ mesh: {
26
+ transient: true
27
+ },
28
+ bvhLeaf: {
29
+ transient: true
30
+ },
31
+ particleBounds: {
32
+ transient: true
33
+ },
34
+ emisionBounds: {
35
+ transient: true
36
+ },
37
+ flags: {
38
+ editor: new BitFlagsEditor(ParticleEmitterFlag)
39
+ },
40
+ blendingMode: {
41
+ editor: new EnumEditor(BlendingType)
42
+ },
43
+ sleepTime: {
44
+ transient: true,
45
+ },
46
+ position: {
47
+ transient: true
48
+ },
49
+ rotation: {
50
+ transient: true
51
+ },
52
+ scale: {
53
+ transient: true
54
+ }
55
+ }
56
+ };
57
+ }
58
+ }
@@ -0,0 +1,58 @@
1
+ import List from "../../../../../src/core/collection/list/List.js";
2
+ import {
3
+ SimulationStepDefinition
4
+ } from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepDefinition.js";
5
+ import { ObjectEditor } from "../primitive/ObjectEditor.js";
6
+ import { ImagePathEditor } from "../ImagePathEditor.js";
7
+ import { EnumEditor } from "../common/EnumEditor.js";
8
+ import {
9
+ EmissionShapeType
10
+ } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/EmissionShapeType.js";
11
+ import {
12
+ EmissionFromType
13
+ } from "../../../../../src/engine/graphics/particles/particular/engine/emitter/EmissionFromType.js";
14
+ import { DataType } from "../../../../../src/core/collection/table/DataType.js";
15
+ import { ParameterTrackSetEditor } from "./ParameterTrackSetEditor.js";
16
+
17
+ export class ParticleEmitterLayerEditor extends ObjectEditor {
18
+ get schema() {
19
+ return {
20
+ properties: {
21
+ imageURL: {
22
+ type: String,
23
+ editor: new ImagePathEditor()
24
+ },
25
+ emissionShape: {
26
+ editor: new EnumEditor(EmissionShapeType)
27
+ },
28
+ emissionFrom: {
29
+ editor: new EnumEditor(EmissionFromType)
30
+ },
31
+ emissionRate: {
32
+ type: Number,
33
+ numeric_type: DataType.Uint32
34
+ },
35
+ emissionImmediate: {
36
+ type: Number,
37
+ numeric_type: DataType.Uint32
38
+ },
39
+ parameterTracks: {
40
+ editor: new ParameterTrackSetEditor()
41
+ },
42
+ scaledSpriteHalfSize: {
43
+ transient: true
44
+ },
45
+ baseBoundingBox: {
46
+ transient: true
47
+ },
48
+ steps: {
49
+ type: List,
50
+ type_parameters: [SimulationStepDefinition]
51
+ },
52
+ timeSinceLastEmission: {
53
+ transient: true
54
+ }
55
+ }
56
+ };
57
+ }
58
+ }
@@ -0,0 +1,21 @@
1
+ import { ObjectEditor } from "../primitive/ObjectEditor.js";
2
+ import { EnumEditor } from "../common/EnumEditor.js";
3
+ import {
4
+ SimulationStepType
5
+ } from "../../../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepType.js";
6
+
7
+ export class SimulationStepDefinitionEditor extends ObjectEditor {
8
+ get schema() {
9
+ return {
10
+ properties: {
11
+ type: {
12
+ editor: new EnumEditor(SimulationStepType)
13
+ },
14
+ parameters: {
15
+ type: Array,
16
+ type_parameters: [Number]
17
+ }
18
+ }
19
+ };
20
+ }
21
+ }
@@ -0,0 +1,33 @@
1
+ import { BitFlagsEditor } from "../common/BitFlagsEditor.js";
2
+ import { Trail2DFlags } from "../../../../../src/engine/graphics/ecs/trail2d/Trail2D.js";
3
+ import { ObjectEditor } from "../primitive/ObjectEditor.js";
4
+
5
+ export class Trail2DEditor extends ObjectEditor {
6
+ get schema() {
7
+ return {
8
+ properties: {
9
+ maxAge: {
10
+ description: "How long does the trail persist in time"
11
+ },
12
+ time: {
13
+ transient: true
14
+ },
15
+ trailingIndex: {
16
+ transient: true
17
+ },
18
+ timeSinceLastUpdate: {
19
+ transient: true
20
+ },
21
+ ribbon: {
22
+ transient: true
23
+ },
24
+ bvhLeaf: {
25
+ transient: true
26
+ },
27
+ flags: {
28
+ editor: new BitFlagsEditor(Trail2DFlags)
29
+ }
30
+ }
31
+ };
32
+ }
33
+ }