@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,112 @@
1
+ import { TypeEditor } from "../../TypeEditor.js";
2
+ import {
3
+ convertTexture2Sampler2D
4
+ } from "../../../../../src/engine/graphics/texture/sampler/convertTexture2Sampler2D.js";
5
+ import { Sampler2D } from "../../../../../src/engine/graphics/texture/sampler/Sampler2D.js";
6
+ import { CanvasView } from "../../../../../src/view/elements/CanvasView.js";
7
+ import sampler2D2Canvas from "../../../../../src/engine/graphics/texture/sampler/Sampler2D2Canvas.js";
8
+ import { MouseEvents } from "../../../../../src/engine/input/devices/events/MouseEvents.js";
9
+ import { downloadSampler2DAsPNG } from "../../../../../src/engine/graphics/texture/sampler/downloadSamplerAsPNG.js";
10
+ import EmptyView from "../../../../../src/view/elements/EmptyView.js";
11
+ import { FrameRunner } from "../../../../../src/engine/graphics/FrameRunner.js";
12
+
13
+ const UPDATE_DELAY = 200;
14
+
15
+ export class TextureEditor extends TypeEditor {
16
+ inline = true;
17
+
18
+ build(parent, field, registry) {
19
+ const size = 32;
20
+
21
+ let texture = field.adapter.read(parent, field.name);
22
+ let sampler;
23
+ if (texture) {
24
+
25
+ sampler = convertTexture2Sampler2D(texture, size, size)
26
+
27
+ } else {
28
+ sampler = Sampler2D.uint8(4, size, size);
29
+ sampler.fill_channel(3, 255);
30
+ }
31
+
32
+ const vContainer = new EmptyView({
33
+ css: {
34
+ width: "min-content",
35
+ height: "min-content"
36
+ }
37
+ });
38
+
39
+ const canvasView = new CanvasView();
40
+ canvasView.css({
41
+ position: "relative",
42
+ background: 'black'
43
+ });
44
+ vContainer.addChild(canvasView);
45
+
46
+ canvasView.size.set(sampler.width, sampler.height);
47
+
48
+
49
+ let last_version = -1;
50
+ let last_update_time = 0;
51
+ let last_update_duration = 0;
52
+
53
+ function draw() {
54
+ const draw_start_time = performance.now();
55
+
56
+ sampler = convertTexture2Sampler2D(texture, size, size);
57
+ sampler2D2Canvas(sampler, 1, 0, canvasView.el);
58
+
59
+ last_version = texture.version;
60
+
61
+ const draw_end_time = performance.now();
62
+ last_update_duration = draw_end_time - draw_start_time;
63
+
64
+ last_update_time = draw_end_time;
65
+ }
66
+
67
+
68
+ function try_update() {
69
+ const time_now = performance.now();
70
+
71
+ if ((time_now - last_update_time) < UPDATE_DELAY) {
72
+ return;
73
+ }
74
+
75
+ texture = field.adapter.read(parent, field.name);
76
+
77
+ if (texture === undefined || texture === null) {
78
+ sampler.fill(0);
79
+ return;
80
+ }
81
+
82
+ if (texture.version !== last_version) {
83
+ draw();
84
+ }
85
+ }
86
+
87
+ const frameRunner = new FrameRunner(try_update);
88
+
89
+ canvasView.on.linked.add(frameRunner.startup, frameRunner);
90
+ canvasView.on.unlinked.add(frameRunner.shutdown, frameRunner);
91
+
92
+
93
+ const allow_download = true;
94
+ if (allow_download) {
95
+ vContainer.el.addEventListener(MouseEvents.Click, () => {
96
+ const texture = field.adapter.read(parent, field.name);
97
+ if (texture === undefined || texture == null) {
98
+ return;
99
+ }
100
+
101
+ const sampler = convertTexture2Sampler2D(texture);
102
+
103
+ downloadSampler2DAsPNG(sampler, field.name);
104
+ });
105
+ // add download marker
106
+ vContainer.addClass('downloadable');
107
+ }
108
+
109
+
110
+ return vContainer;
111
+ }
112
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ *
3
+ * @param {Map<*, TypeEditor>} registry
4
+ * @param {*} value
5
+ * @returns {TypeEditor|void}
6
+ */
7
+ export function findNearestRegisteredType(registry, value) {
8
+ const path = [];
9
+
10
+ let editor;
11
+ let t = value;
12
+ do {
13
+
14
+ if (t === undefined || t === null) {
15
+ return;
16
+ }
17
+
18
+
19
+ editor = registry.get(t);
20
+
21
+ if (editor !== undefined) {
22
+ return editor;
23
+ }
24
+
25
+ if (typeof t === "function" && t !== Function) {
26
+ // t is a class, classes have Function prototype, this is confusing, but we want to skip going to function class in this case
27
+ t = t.prototype;
28
+ continue;
29
+ }
30
+
31
+ if (t.constructor !== undefined) {
32
+
33
+ editor = registry.get(t.constructor);
34
+
35
+ if (editor !== undefined) {
36
+ return editor;
37
+ }
38
+ }
39
+
40
+ const proto = Object.getPrototypeOf(t);
41
+
42
+ if (proto === undefined || proto === null) {
43
+ return;
44
+ }
45
+
46
+
47
+ const ctor = proto;
48
+
49
+ t = ctor;
50
+
51
+ if (path.includes(t)) {
52
+ // circular dependency detected
53
+ return;
54
+ }
55
+
56
+ path.push(t);
57
+
58
+ } while (true);
59
+ }
@@ -0,0 +1,379 @@
1
+ import { buildObjectEditorFromRegistry } from "./createObjectEditor.js";
2
+ import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
3
+ import Vector3 from "../../../src/core/geom/Vector3.js";
4
+ import Signal from "../../../src/core/events/signal/Signal.js";
5
+ import Quaternion from "../../../src/core/geom/Quaternion.js";
6
+ import { seededRandom } from "../../../src/core/math/random/seededRandom.js";
7
+ import Clock from "../../../src/engine/Clock.js";
8
+ import { TypeEditor } from "./TypeEditor.js";
9
+ import { Vector3Editor } from "./editors/geom/Vector3Editor.js";
10
+ import { QuaternionEditor } from "./editors/geom/QuaternionEditor.js";
11
+ import { noEditor } from "./editors/common/noEditor.js";
12
+ import { TransformEditor } from "./editors/ecs/TransformEditor.js";
13
+ import { Sampler2D } from "../../../src/engine/graphics/texture/sampler/Sampler2D.js";
14
+ import { Light } from "../../../src/engine/graphics/ecs/light/Light.js";
15
+ import { Sampler2DEditor } from "./editors/Sampler2DEditor.js";
16
+ import Vector1 from "../../../src/core/geom/Vector1.js";
17
+ import { Color } from "../../../src/core/color/Color.js";
18
+ import { ColorEditor } from "./editors/ColorEditor.js";
19
+ import { Vector1Editor } from "./editors/geom/Vector1Editor.js";
20
+ import ObservedBoolean from "../../../src/core/model/ObservedBoolean.js";
21
+ import ObservedEnum from "../../../src/core/model/ObservedEnum.js";
22
+ import { LightType } from "../../../src/engine/graphics/ecs/light/LightType.js";
23
+ import { ShadedGeometry } from "../../../src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js";
24
+ import { BoxBufferGeometry, BufferGeometry, Material, MeshStandardMaterial, Texture } from "three";
25
+ import { SGMesh } from "../../../src/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js";
26
+ import { ParticleEmitter } from "../../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js";
27
+ import { BufferGeometryEditor } from "./editors/three/BufferGeometryEditor.js";
28
+ import { MaterialEditor } from "./editors/three/MaterialEditor.js";
29
+ import { ObservedEnumEditor } from "./editors/ObservedEnumEditor.js";
30
+ import { ObservedBooleanEditor } from "./editors/ObservedBooleanEditor.js";
31
+ import { StringEditor } from "./editors/primitive/StringEditor.js";
32
+ import { BooleanEditor } from "./editors/primitive/BooleanEditor.js";
33
+ import { NumberEditor } from "./editors/primitive/NumberEditor.js";
34
+ import {
35
+ ParameterLookupTable
36
+ } from "../../../src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js";
37
+ import { ParameterLookupTableEditor } from "./editors/ecs/ParameterLookupTableEditor.js";
38
+ import List from "../../../src/core/collection/list/List.js";
39
+ import { ParticleLayer } from "../../../src/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js";
40
+ import { NumericInterval } from "../../../src/core/math/interval/NumericInterval.js";
41
+ import { NumericIntervalEditor } from "./editors/NumericIntervalEditor.js";
42
+ import { ObjectEditor } from "./editors/primitive/ObjectEditor.js";
43
+ import { ListEditor } from "./editors/collection/ListEditor.js";
44
+ import Trail2D from "../../../src/engine/graphics/ecs/trail2d/Trail2D.js";
45
+ import { ParticleEmitterLayerEditor } from "./editors/ecs/ParticleEmitterLayerEditor.js";
46
+ import { ParticleEmitterEditor } from "./editors/ecs/ParticleEmitterEditor.js";
47
+ import Vector4 from "../../../src/core/geom/Vector4.js";
48
+ import { Vector4Editor } from "./editors/geom/Vector4Editor.js";
49
+ import { Trail2DEditor } from "./editors/ecs/Trail2DEditor.js";
50
+ import GridObstacle from "../../../src/engine/grid/components/GridObstacle.js";
51
+ import { Vector2Editor } from "./editors/geom/Vector2Editor.js";
52
+ import Vector2 from "../../../src/core/geom/Vector2.js";
53
+ import { randomIntegerBetween } from "../../../src/core/math/random/randomIntegerBetween.js";
54
+ import { GridObstacleEditor } from "./editors/ecs/GridObstacleEditor.js";
55
+ import { EngineHarness } from "../../../src/engine/EngineHarness.js";
56
+ import Terrain from "../../../src/engine/ecs/terrain/ecs/Terrain.js";
57
+ import WorkerProxy from "../../../src/core/process/worker/WorkerProxy.js";
58
+ import { TextureEditor } from "./editors/three/TextureEditor.js";
59
+ import { HTMLElementEditor } from "./editors/HTMLElementEditor.js";
60
+ import { TerrainLayerEditor } from "./editors/ecs/terrain/TerrainLayerEditor.js";
61
+ import { TerrainLayer } from "../../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js";
62
+ import ObservedString from "../../../src/core/model/ObservedString.js";
63
+ import { ObservedStringEditor } from "./editors/ObservedStringEditor.js";
64
+ import { TerrainOverlay } from "../../../src/engine/ecs/terrain/overlay/TerrainOverlay.js";
65
+ import { TerrainOverlayEditor } from "./editors/ecs/terrain/TerrainOverlayEditor.js";
66
+ import { TerrainEditor } from "./editors/ecs/terrain/TerrainEditor.js";
67
+ import { SplatMapping } from "../../../src/engine/ecs/terrain/ecs/splat/SplatMapping.js";
68
+ import { SplatMappingEditor } from "./editors/ecs/terrain/SplatMappingEditor.js";
69
+ import { TerrainLayersEditor } from "./editors/ecs/terrain/TerrainLayersEditor.js";
70
+ import { TerrainLayers } from "../../../src/engine/ecs/terrain/ecs/layers/TerrainLayers.js";
71
+ import {
72
+ SimulationStepDefinition
73
+ } from "../../../src/engine/graphics/particles/particular/engine/simulator/SimulationStepDefinition.js";
74
+ import { SimulationStepDefinitionEditor } from "./editors/ecs/SimulationStepDefinitionEditor.js";
75
+ import { ArrayEditor } from "./editors/primitive/ArrayEditor.js";
76
+ import { ParameterTrackEditor } from "./editors/ecs/ParameterTrackEditor.js";
77
+ import { ParameterTrack } from "../../../src/engine/graphics/particles/particular/engine/parameter/ParameterTrack.js";
78
+
79
+ /**
80
+ *
81
+ * @type {Map<any, TypeEditor>}
82
+ */
83
+ const registry = new Map();
84
+
85
+ registry.set(Terrain, new TerrainEditor());
86
+ registry.set(TerrainLayer, new TerrainLayerEditor());
87
+ registry.set(SplatMapping, new SplatMappingEditor());
88
+ registry.set(TerrainOverlay, new TerrainOverlayEditor());
89
+ registry.set(TerrainLayers, new TerrainLayersEditor());
90
+
91
+ registry.set(GridObstacle, new GridObstacleEditor());
92
+
93
+ registry.set(ParticleLayer, new ParticleEmitterLayerEditor());
94
+ registry.set(ParticleEmitter, new ParticleEmitterEditor());
95
+ registry.set(ParameterTrack, new ParameterTrackEditor());
96
+ registry.set(SimulationStepDefinition, new SimulationStepDefinitionEditor());
97
+
98
+ registry.set(Trail2D, new Trail2DEditor());
99
+
100
+ registry.set(Number, new NumberEditor());
101
+ registry.set(Boolean, new BooleanEditor());
102
+ registry.set(String, new StringEditor());
103
+ registry.set(Array, new ArrayEditor());
104
+ registry.set(Object, new ObjectEditor());
105
+
106
+ registry.set(NumericInterval, new NumericIntervalEditor());
107
+ registry.set(List, new ListEditor());
108
+ registry.set(ObservedBoolean, new ObservedBooleanEditor());
109
+ registry.set(ObservedEnum, new ObservedEnumEditor());
110
+ registry.set(Material, new MaterialEditor());
111
+ registry.set(BufferGeometry, new BufferGeometryEditor());
112
+ registry.set(Texture, new TextureEditor());
113
+ registry.set(Color, new ColorEditor());
114
+ registry.set(Vector4, new Vector4Editor());
115
+ registry.set(Vector3, new Vector3Editor());
116
+ registry.set(Vector2, new Vector2Editor());
117
+ registry.set(Vector1, new Vector1Editor());
118
+ registry.set(ObservedString, new ObservedStringEditor());
119
+
120
+ registry.set(Quaternion, new QuaternionEditor());
121
+ registry.set(Transform, new TransformEditor());
122
+ registry.set(ParameterLookupTable, new ParameterLookupTableEditor());
123
+ registry.set(Sampler2D, new Sampler2DEditor());
124
+
125
+ registry.set(HTMLElement, new HTMLElementEditor());
126
+ registry.set(HTMLCanvasElement, new HTMLElementEditor());
127
+
128
+ registry.set(WorkerProxy, noEditor());
129
+ registry.set(Signal, noEditor());
130
+
131
+ registry.set(Uint8Array, noEditor());
132
+ registry.set(Uint16Array, noEditor());
133
+ registry.set(Uint32Array, noEditor());
134
+
135
+ registry.set(Int8Array, noEditor());
136
+ registry.set(Int16Array, noEditor());
137
+ registry.set(Int32Array, noEditor());
138
+
139
+ registry.set(Float32Array, noEditor());
140
+ registry.set(Float64Array, noEditor());
141
+
142
+ registry.set(CanvasRenderingContext2D, noEditor());
143
+
144
+
145
+ const random = seededRandom(7);
146
+
147
+ const transform = new Transform();
148
+
149
+ const light = new Light();
150
+ light.type.set(LightType.SPOT);
151
+ light.color.parse('rgb(255,145,0)');
152
+
153
+ const sg = ShadedGeometry.from(new BoxBufferGeometry(), new MeshStandardMaterial({
154
+ color: 0xFFFF00
155
+ }));
156
+ const sgMesh = SGMesh.fromURL('bla-bla');
157
+ const particleEmitter = ParticleEmitter.fromJSON({
158
+ "position": {
159
+ "x": 22,
160
+ "y": 0,
161
+ "z": 18
162
+ },
163
+ "scale": {
164
+ "x": 0.25,
165
+ "y": 0.25,
166
+ "z": 0.25
167
+ },
168
+ "rotation": {
169
+ "x": 0,
170
+ "y": -0.4073445409440101,
171
+ "z": 0,
172
+ "w": 0.9132745616533474
173
+ },
174
+ "parameters": [
175
+ {
176
+ "name": "scale",
177
+ "itemSize": 1,
178
+ "defaultTrackValue": {
179
+ "itemSize": 1,
180
+ "data": [
181
+ 1
182
+ ],
183
+ "positions": [
184
+ 0
185
+ ]
186
+ }
187
+ },
188
+ {
189
+ "name": "color",
190
+ "itemSize": 4,
191
+ "defaultTrackValue": {
192
+ "itemSize": 4,
193
+ "data": [
194
+ 1,
195
+ 1,
196
+ 1,
197
+ 1
198
+ ],
199
+ "positions": [
200
+ 0
201
+ ]
202
+ }
203
+ }
204
+ ],
205
+ "preWarm": true,
206
+ "readDepth": true,
207
+ "softDepth": true,
208
+ "velocityAlign": false,
209
+ "receiveLight": true,
210
+ "blendingMode": 0,
211
+ "layers": [
212
+ {
213
+ "imageURL": "data/textures/particle/UETools/x64/Smoke_14.png",
214
+ "particleLife": {
215
+ "min": 6,
216
+ "max": 8
217
+ },
218
+ "particleSize": {
219
+ "min": 0.4,
220
+ "max": 0.4
221
+ },
222
+ "particleRotation": {
223
+ "min": 0,
224
+ "max": 0
225
+ },
226
+ "particleRotationSpeed": {
227
+ "min": 0,
228
+ "max": 0
229
+ },
230
+ "emissionShape": 3,
231
+ "emissionFrom": 1,
232
+ "emissionRate": 2,
233
+ "emissionImmediate": 0,
234
+ "parameterTracks": [
235
+ {
236
+ "name": "color",
237
+ "track": {
238
+ "itemSize": 4,
239
+ "data": [
240
+ 0.45,
241
+ 0.45,
242
+ 0.45,
243
+ 0,
244
+
245
+ 0.6,
246
+ 0.6,
247
+ 0.6,
248
+ 0.3,
249
+
250
+ 0.6,
251
+ 0.6,
252
+ 0.6,
253
+ 0.2,
254
+
255
+ 0.6,
256
+ 0.6,
257
+ 0.6,
258
+ 0
259
+ ],
260
+ "positions": [
261
+ 0,
262
+ 0.2,
263
+ 0.7,
264
+ 1
265
+ ]
266
+ }
267
+ },
268
+ {
269
+ "name": "scale",
270
+ "track": {
271
+ "itemSize": 1,
272
+ "data": [
273
+ 0.2493331876981993,
274
+ 0.6134230340328317,
275
+ 1.0759788492641973,
276
+ 1.261059004570864
277
+ ],
278
+ "positions": [
279
+ 0,
280
+ 0.4176470588235294,
281
+ 0.7588235294117648,
282
+ 1
283
+ ]
284
+ }
285
+ }
286
+ ],
287
+ "position": {
288
+ "x": 2.7,
289
+ "y": 2.3,
290
+ "z": 1.5
291
+ },
292
+ "scale": {
293
+ "x": 1,
294
+ "y": 1,
295
+ "z": 1
296
+ },
297
+ "particleVelocityDirection": {
298
+ "direction": {
299
+ "x": 0,
300
+ "y": 1,
301
+ "z": 0
302
+ },
303
+ "angle": 0.1
304
+ },
305
+ "particleSpeed": {
306
+ "min": 0.2,
307
+ "max": 0.22
308
+ },
309
+ "steps": [
310
+ {
311
+ "type": "FixedPhysics",
312
+ "parameters": []
313
+ }
314
+ ]
315
+ },
316
+
317
+ ]
318
+ });
319
+
320
+ const trail2D = new Trail2D();
321
+
322
+ const gridObstacle = new GridObstacle();
323
+ gridObstacle.resize(10, 10);
324
+ gridObstacle.traverseMask(0, 0, (x, y) => {
325
+ gridObstacle.writePoint(x, y, randomIntegerBetween(random, 0, 1))
326
+ });
327
+
328
+
329
+ async function makeTerrain() {
330
+ const harness = new EngineHarness();
331
+
332
+ await harness.initialize()
333
+
334
+ const engine = harness.engine;
335
+
336
+ engine.viewStack.el.parentElement.removeChild(engine.viewStack.el);
337
+
338
+ return await EngineHarness.buildTerrain({ engine: engine })
339
+ }
340
+
341
+ async function exec() {
342
+
343
+ // const terrain = await makeTerrain();
344
+
345
+ const object = particleEmitter;
346
+
347
+
348
+ // transform.rotation.random(random);
349
+
350
+ const view = buildObjectEditorFromRegistry(object, registry);
351
+
352
+ console.warn(object);
353
+
354
+ document.body.append(view.el);
355
+
356
+ document.body.style.background = 'rgb(37,73,0)';
357
+
358
+ view.link();
359
+
360
+ view.css({
361
+ background: 'grey'
362
+ });
363
+ }
364
+
365
+ exec();
366
+
367
+ const clock = new Clock();
368
+ clock.start();
369
+
370
+ function animate() {
371
+ requestAnimationFrame(animate);
372
+
373
+ const delta = clock.getDelta();
374
+ const time = clock.getElapsedTime();
375
+
376
+ // transform.rotation.lookAt(Vector3.zero, new Vector3(Math.cos(time), Math.sin(time), time % 10))
377
+ }
378
+
379
+ animate();
@@ -0,0 +1,85 @@
1
+ import Editor from "./Editor.js";
2
+ import { noop } from "../src/core/function/Functions.js";
3
+
4
+ /**
5
+ *
6
+ * @param {Engine} engine
7
+ * @param {function(Editor):*} [initialization]
8
+ * @returns {{enable:function, disable: function, toggle: function, editor: Editor}}
9
+ */
10
+ export function enableEditor(engine, initialization = noop) {
11
+ let editor = null;
12
+
13
+ let enabled = false;
14
+
15
+ function ensureEditor() {
16
+ if (editor === null) {
17
+ editor = new Editor();
18
+ editor.engine = engine;
19
+
20
+ editor.initialize();
21
+
22
+ initialization(editor);
23
+ }
24
+
25
+ return editor;
26
+ }
27
+
28
+ function attachEditor() {
29
+ if (enabled) {
30
+ return;
31
+ }
32
+
33
+ console.log('Enabling editor');
34
+
35
+ ensureEditor();
36
+
37
+ editor.attach(engine);
38
+ enabled = true;
39
+ }
40
+
41
+ function detachEditor() {
42
+ if (!enabled) {
43
+ return;
44
+ }
45
+
46
+ console.log('Disabling editor');
47
+ if (editor !== null) {
48
+ editor.detach();
49
+ }
50
+ enabled = false;
51
+ }
52
+
53
+ function toggleEditor() {
54
+ if (!enabled) {
55
+ attachEditor();
56
+ } else {
57
+ detachEditor();
58
+ }
59
+
60
+ return editor;
61
+ }
62
+
63
+ //bind key for toggling editor
64
+ engine.inputEngine.mapKey(144, {
65
+ on: function () {
66
+ toggleEditor();
67
+ },
68
+ off: function () {
69
+
70
+ }
71
+ });
72
+
73
+ console.warn('Editor mode enabled, use NumLock key to toggle editor mode');
74
+
75
+ return {
76
+ toggle: toggleEditor,
77
+ enable: attachEditor,
78
+ disable: detachEditor,
79
+ get editor() {
80
+ ensureEditor();
81
+
82
+ return editor;
83
+ }
84
+ }
85
+ }
@@ -0,0 +1,33 @@
1
+ import List from "../../src/core/collection/list/List.js";
2
+
3
+
4
+ class MeshLibrary {
5
+
6
+ constructor() {
7
+
8
+ /**
9
+ * @type {List.<string>}
10
+ */
11
+ this.assets = new List();
12
+ }
13
+
14
+ /**
15
+ *
16
+ * @param {string} url
17
+ */
18
+ add(url) {
19
+ const existingAsset = this.assets.find(function (_url) {
20
+ return _url === url;
21
+ });
22
+
23
+ if (existingAsset !== undefined) {
24
+ //already exists
25
+ return;
26
+ }
27
+
28
+ this.assets.add(url);
29
+ }
30
+ }
31
+
32
+
33
+ export { MeshLibrary };