@woosh/meep-engine 2.46.29 → 2.46.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/editor/Editor.js +793 -0
- package/editor/SelectionVisualizer.js +148 -0
- package/editor/actions/concrete/ActionUpdateTexture.js +21 -0
- package/editor/actions/concrete/ArrayCopyAction.js +39 -0
- package/editor/actions/concrete/ComponentAddAction.js +47 -0
- package/editor/actions/concrete/ComponentRemoveAction.js +38 -0
- package/editor/actions/concrete/EntityCreateAction.js +47 -0
- package/editor/actions/concrete/EntityRemoveAction.js +51 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
- package/editor/actions/concrete/ModifyPatchTextureArray2DAction.js +182 -0
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +45 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.js +67 -0
- package/editor/actions/concrete/PatchTerrainTextureAction.js +152 -0
- package/editor/actions/concrete/SelectionAddAction.js +36 -0
- package/editor/actions/concrete/SelectionClearAction.js +22 -0
- package/editor/actions/concrete/SelectionRemoveAction.js +30 -0
- package/editor/actions/concrete/TransformModifyAction.js +46 -0
- package/editor/actions/concrete/WriteGridValueAction.js +46 -0
- package/editor/ecs/EditorEntity.js +12 -0
- package/editor/ecs/EditorEntitySystem.js +14 -0
- package/editor/ecs/component/FieldDescriptor.js +34 -0
- package/editor/ecs/component/FieldValueAdapter.js +20 -0
- package/editor/ecs/component/TypeEditor.js +33 -0
- package/editor/ecs/component/TypeSchema.d.ts +38 -0
- package/editor/ecs/component/createFieldEditor.js +92 -0
- package/editor/ecs/component/createObjectEditor.js +361 -0
- package/editor/ecs/component/editors/ColorEditor.js +39 -0
- package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
- package/editor/ecs/component/editors/ImagePathEditor.js +82 -0
- package/editor/ecs/component/editors/LargeStrongEditor.js +107 -0
- package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
- package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
- package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
- package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
- package/editor/ecs/component/editors/Sampler2DEditor.js +221 -0
- package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
- package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
- package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
- package/editor/ecs/component/editors/common/noEditor.js +9 -0
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +225 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
- package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
- package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +95 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +63 -0
- package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
- package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
- package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
- package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
- package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
- package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
- package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
- package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
- package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
- package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
- package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
- package/editor/ecs/component/editors/three/TextureEditor.js +112 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/enableEditor.js +85 -0
- package/editor/library/MeshLibrary.js +33 -0
- package/editor/process/DisableGameUIProcess.js +43 -0
- package/editor/process/EditorProcess.js +35 -0
- package/editor/process/ObstacleGridDisplayProcess.js +120 -0
- package/editor/process/ProcessEngine.js +123 -0
- package/editor/process/SymbolicDisplayProcess.js +132 -0
- package/editor/process/symbolic/ComponentSymbolicDisplay.js +34 -0
- package/editor/process/symbolic/SymbolicDisplayInternalAPI.js +159 -0
- package/editor/process/symbolic/buildThreeJSHelperEntity.js +36 -0
- package/editor/process/symbolic/make3DSymbolicDisplay.js +91 -0
- package/editor/process/symbolic/makeCameraSymbolicDisplay.js +32 -0
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +176 -0
- package/editor/process/symbolic/makeHelperBoxGeometry.js +44 -0
- package/editor/process/symbolic/makeHelperSphereGeometry.js +73 -0
- package/editor/process/symbolic/makeLightSymbolicDisplay.js +77 -0
- package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.js +146 -0
- package/editor/process/symbolic/makePathSymbolicDisplay.js +105 -0
- package/editor/process/symbolic/makePositionedIconDisplaySymbol.js +74 -0
- package/editor/process/symbolic/makeSocketsSymbolicDisplay.js +153 -0
- package/editor/process/symbolic/makeSolidArrowGeometry.js +391 -0
- package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.js +89 -0
- package/editor/process/symbolic/makeStoryTriggerSetAreaDisplay.js +114 -0
- package/editor/process/symbolic/synchronizeTransform.js +50 -0
- package/editor/tools/FoliagePaintTool.js +168 -0
- package/editor/tools/GridPaintTool.js +247 -0
- package/editor/tools/SelectionTool.js +407 -0
- package/editor/tools/TopDownCameraControlTool.js +59 -0
- package/editor/tools/TransformTool.js +370 -0
- package/editor/tools/engine/Tool.js +121 -0
- package/editor/tools/engine/ToolEngine.js +193 -0
- package/editor/tools/engine/ToolState.js +9 -0
- package/editor/tools/engine/ToolStateMachine.js +53 -0
- package/editor/tools/paint/TerrainHeightPaintTool.js +297 -0
- package/editor/tools/paint/TerrainPaintTool.js +211 -0
- package/editor/tools/paint/TerrainTexturePaintTool.js +193 -0
- package/editor/tools/paint/prototypeTerrainEditor.js +135 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.d.ts +50 -0
- package/editor/tools/v2/BlenderCameraOrientationGizmo.js +500 -0
- package/editor/tools/v2/TransformControls.d.ts +20 -0
- package/editor/tools/v2/TransformControls.js +1782 -0
- package/editor/tools/v2/prototypeTransformControls.js +92 -0
- package/editor/view/EditorView.js +462 -0
- package/editor/view/GridPickCoordinateView.js +88 -0
- package/editor/view/ecs/ComponentControlFactory.js +48 -0
- package/editor/view/ecs/ComponentControlView.js +214 -0
- package/editor/view/ecs/EntityEditor.js +258 -0
- package/editor/view/ecs/EntityList.js +258 -0
- package/editor/view/ecs/components/BlackboardController.js +50 -0
- package/editor/view/ecs/components/DatGuiController.js +216 -0
- package/editor/view/ecs/components/FogOfWarController.js +78 -0
- package/editor/view/ecs/components/FogOfWarRevealerController.js +44 -0
- package/editor/view/ecs/components/GeneratedArmyController.js +42 -0
- package/editor/view/ecs/components/GridObstacleController.js +72 -0
- package/editor/view/ecs/components/GridPositionController.js +40 -0
- package/editor/view/ecs/components/HeadsUpDisplayController.js +30 -0
- package/editor/view/ecs/components/HighlightController.js +47 -0
- package/editor/view/ecs/components/MeshController.js +125 -0
- package/editor/view/ecs/components/PathFollowerController.js +87 -0
- package/editor/view/ecs/components/TagController.js +80 -0
- package/editor/view/ecs/components/TerrainController.js +225 -0
- package/editor/view/ecs/components/TransformController.js +103 -0
- package/editor/view/ecs/components/UnitShopController.js +112 -0
- package/editor/view/ecs/components/army/ArmyController.js +130 -0
- package/editor/view/ecs/components/color/GaugeView.js +107 -0
- package/editor/view/ecs/components/common/AutoCanvasView.js +53 -0
- package/editor/view/ecs/components/common/LineView.js +17 -0
- package/editor/view/ecs/components/common/NumberController.js +112 -0
- package/editor/view/ecs/components/common/NumericIntervalController.js +64 -0
- package/editor/view/ecs/components/gui/GUIElementController.js +117 -0
- package/editor/view/ecs/components/items/ItemContainerController.js +132 -0
- package/editor/view/ecs/components/items/ItemContainerController.stories.js +50 -0
- package/editor/view/ecs/components/items/ItemController.js +52 -0
- package/editor/view/ecs/components/particles/ColorParameterLUTController.js +444 -0
- package/editor/view/ecs/components/particles/ParameterTrackController.js +51 -0
- package/editor/view/ecs/components/particles/ParticleEmitterController.js +213 -0
- package/editor/view/ecs/components/particles/ParticleLayerController.js +213 -0
- package/editor/view/ecs/components/particles/ScalarParameterLUTController.js +401 -0
- package/editor/view/ecs/components/sockets/AttachmentSocketsController.js +51 -0
- package/editor/view/ecs/components/sound/SoundEmitterController.js +137 -0
- package/editor/view/ecs/components/story/StoryTriggerSetController.js +214 -0
- package/editor/view/ecs/components/unit/AuraController.js +45 -0
- package/editor/view/library/MeshLibraryView.js +164 -0
- package/editor/view/node-graph/NodeGraphEditorView.js +170 -0
- package/editor/view/node-graph/NodeGraphView.js +453 -0
- package/editor/view/node-graph/NodeView.js +135 -0
- package/editor/view/node-graph/PortView.js +69 -0
- package/editor/view/process/ProcessView.js +63 -0
- package/editor/view/tools/ToolSettingsView.js +143 -0
- package/editor/view/tools/ToolView.js +58 -0
- package/package.json +2 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { assert } from "../../../src/core/assert.js";
|
|
2
|
+
import EditorEntity from "../../ecs/EditorEntity.js";
|
|
3
|
+
import { SignalBinding } from "../../../src/core/events/signal/SignalBinding.js";
|
|
4
|
+
import { ComponentSymbolicDisplay } from "./ComponentSymbolicDisplay.js";
|
|
5
|
+
import { SymbolicDisplayInternalAPI } from "./SymbolicDisplayInternalAPI.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param {Engine} engine
|
|
10
|
+
* @param {function(components:[], api:{bind:function(Signal, function, thisArg:*), update: function, bindings:SignalBinding[]})} factory
|
|
11
|
+
* @param {Class[]} components
|
|
12
|
+
* @return {ComponentSymbolicDisplay}
|
|
13
|
+
*/
|
|
14
|
+
export function make3DSymbolicDisplay({
|
|
15
|
+
engine,
|
|
16
|
+
factory,
|
|
17
|
+
components
|
|
18
|
+
}) {
|
|
19
|
+
|
|
20
|
+
assert.defined(engine);
|
|
21
|
+
assert.defined(factory);
|
|
22
|
+
assert.defined(components);
|
|
23
|
+
|
|
24
|
+
assert.typeOf(factory, 'function', 'factory');
|
|
25
|
+
|
|
26
|
+
const entityManager = engine.entityManager;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {SymbolicDisplayInternalAPI[]}
|
|
32
|
+
*/
|
|
33
|
+
const entities = [];
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
function added(...args) {
|
|
37
|
+
const entity = args[args.length - 1];
|
|
38
|
+
|
|
39
|
+
const entityDataset = entityManager.dataset;
|
|
40
|
+
const editorEntity = entityDataset.getComponent(entity, EditorEntity);
|
|
41
|
+
|
|
42
|
+
if (editorEntity !== undefined) {
|
|
43
|
+
//skip editor's own entities
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
const api = new SymbolicDisplayInternalAPI();
|
|
49
|
+
|
|
50
|
+
api.__requestUpdate.add(() => {
|
|
51
|
+
removed(...args);
|
|
52
|
+
added(...args);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
api.initialize({
|
|
56
|
+
ecd: entityDataset,
|
|
57
|
+
engine,
|
|
58
|
+
entity
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
factory(args, api);
|
|
63
|
+
} catch (e) {
|
|
64
|
+
console.error(`Error while creating a helper:`, e, args);
|
|
65
|
+
|
|
66
|
+
api.finalize();
|
|
67
|
+
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
entities[entity] = api;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function removed(...args) {
|
|
75
|
+
const entity = args[args.length - 1];
|
|
76
|
+
|
|
77
|
+
const api = entities[entity];
|
|
78
|
+
|
|
79
|
+
if (api === undefined) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
delete entities[entity];
|
|
84
|
+
|
|
85
|
+
api.finalize();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const display = new ComponentSymbolicDisplay(components, added, removed);
|
|
89
|
+
|
|
90
|
+
return display;
|
|
91
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
2
|
+
import { CameraHelper } from "three";
|
|
3
|
+
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
4
|
+
import Renderable from "../../../src/engine/ecs/components/Renderable.js";
|
|
5
|
+
import { Camera } from "../../../src/engine/graphics/ecs/camera/Camera.js";
|
|
6
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @returns {ComponentSymbolicDisplay}
|
|
11
|
+
* @param {Engine} engine
|
|
12
|
+
*/
|
|
13
|
+
export function makeCameraSymbolicDisplay(engine) {
|
|
14
|
+
|
|
15
|
+
return make3DSymbolicDisplay({
|
|
16
|
+
engine,
|
|
17
|
+
|
|
18
|
+
factory([camera, transform, entity], api) {
|
|
19
|
+
const helper = new CameraHelper(camera.object);
|
|
20
|
+
|
|
21
|
+
const entityBuilder = buildThreeJSHelperEntity(helper);
|
|
22
|
+
|
|
23
|
+
const r = entityBuilder.getComponent(Renderable);
|
|
24
|
+
|
|
25
|
+
r.matrixAutoUpdate = false;
|
|
26
|
+
|
|
27
|
+
api.emit(entityBuilder);
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
components: [Camera, Transform]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { max2 } from "../../../src/core/math/max2.js";
|
|
2
|
+
import { min2 } from "../../../src/core/math/min2.js";
|
|
3
|
+
import Task from "../../../src/core/process/task/Task.js";
|
|
4
|
+
import { TaskSignal } from "../../../src/core/process/task/TaskSignal.js";
|
|
5
|
+
import EntityBuilder from "../../../src/engine/ecs/EntityBuilder.js";
|
|
6
|
+
import { BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial } from "three";
|
|
7
|
+
import Renderable from "../../../src/engine/ecs/components/Renderable.js";
|
|
8
|
+
import { SurfacePoint3 } from "../../../src/core/geom/3d/SurfacePoint3.js";
|
|
9
|
+
import Vector3 from "../../../src/core/geom/Vector3.js";
|
|
10
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
11
|
+
import EditorEntity from "../../ecs/EditorEntity.js";
|
|
12
|
+
import { EventType } from "../../../src/engine/ecs/EntityManager.js";
|
|
13
|
+
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
14
|
+
import GridPosition from "../../../src/engine/grid/components/GridPosition.js";
|
|
15
|
+
import { ProcessState } from "../../../src/core/process/ProcessState.js";
|
|
16
|
+
import { obtainTerrain } from "../../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {Engine} engine
|
|
21
|
+
*/
|
|
22
|
+
export function makeGridPositionSymbolDisplay(engine) {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @type {EntityManager}
|
|
27
|
+
*/
|
|
28
|
+
const em = engine.entityManager;
|
|
29
|
+
|
|
30
|
+
const updateQueue = [];
|
|
31
|
+
|
|
32
|
+
const tTerrainWaiter = new Task({
|
|
33
|
+
name: 'terrain-waiter',
|
|
34
|
+
cycleFunction() {
|
|
35
|
+
if (updateQueue.length === 0) {
|
|
36
|
+
return TaskSignal.Yield;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const f = updateQueue.shift();
|
|
40
|
+
|
|
41
|
+
f();
|
|
42
|
+
|
|
43
|
+
return TaskSignal.Continue;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param {GridPosition} gridPosition
|
|
50
|
+
* @param {Transform} transform
|
|
51
|
+
* @returns {EntityBuilder}
|
|
52
|
+
*/
|
|
53
|
+
function makeHelper(gridPosition, transform) {
|
|
54
|
+
const builder = new EntityBuilder();
|
|
55
|
+
|
|
56
|
+
// TODO replace with {@link VisualSymbolLine}
|
|
57
|
+
|
|
58
|
+
const lineMaterial = new LineBasicMaterial({ color: 0xFFFFFF });
|
|
59
|
+
lineMaterial.depthTest = false;
|
|
60
|
+
|
|
61
|
+
const lineGeometry = new BufferGeometry();
|
|
62
|
+
|
|
63
|
+
const positionAttribute = new Float32BufferAttribute(new Float32Array(6), 3);
|
|
64
|
+
lineGeometry.setAttribute('position', positionAttribute);
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
//find terrain
|
|
68
|
+
const terrain = obtainTerrain(em.dataset);
|
|
69
|
+
|
|
70
|
+
const line = new Line(lineGeometry, lineMaterial);
|
|
71
|
+
|
|
72
|
+
line.updateMatrixWorld();
|
|
73
|
+
line.frustumCulled = false;
|
|
74
|
+
|
|
75
|
+
const renderable = new Renderable(line);
|
|
76
|
+
renderable.matrixAutoUpdate = false;
|
|
77
|
+
|
|
78
|
+
const contact = new SurfacePoint3();
|
|
79
|
+
|
|
80
|
+
const p0 = transform.position;
|
|
81
|
+
const p1 = new Vector3();
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @returns {boolean}
|
|
86
|
+
*/
|
|
87
|
+
function updateGridPosition() {
|
|
88
|
+
|
|
89
|
+
//get grid position in the world
|
|
90
|
+
terrain.mapPointGrid2World(gridPosition.x, gridPosition.y, p1);
|
|
91
|
+
|
|
92
|
+
return terrain.raycastFirstSync(contact, p1.x, -(terrain.heightRange + 1), p1.z, 0, 1, 0);
|
|
93
|
+
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function updateGeometry() {
|
|
97
|
+
const c = contact.position;
|
|
98
|
+
|
|
99
|
+
positionAttribute.setXYZ(0, p0.x, p0.y, p0.z);
|
|
100
|
+
positionAttribute.setXYZ(1, c.x, c.y, c.z);
|
|
101
|
+
|
|
102
|
+
positionAttribute.needsUpdate = true;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function updateBounds() {
|
|
106
|
+
const c = contact.position;
|
|
107
|
+
|
|
108
|
+
const x0 = min2(p0.x, c.x),
|
|
109
|
+
y0 = min2(p0.y, c.y),
|
|
110
|
+
z0 = min2(p0.z, c.z),
|
|
111
|
+
x1 = max2(p0.x, c.x),
|
|
112
|
+
y1 = max2(p0.y, c.y),
|
|
113
|
+
z1 = max2(p0.z, c.z);
|
|
114
|
+
|
|
115
|
+
renderable.boundingBox.setBounds(x0, y0, z0, x1, y1, z1);
|
|
116
|
+
|
|
117
|
+
renderable.bvh.resize(x0, y0, z0, x1, y1, z1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function attemptUpdate() {
|
|
121
|
+
if (updateGridPosition()) {
|
|
122
|
+
updateGeometry();
|
|
123
|
+
updateBounds();
|
|
124
|
+
} else if (updateQueue.indexOf(attemptUpdate) === -1) {
|
|
125
|
+
updateQueue.push(attemptUpdate);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
attemptUpdate();
|
|
130
|
+
|
|
131
|
+
builder
|
|
132
|
+
.add(renderable)
|
|
133
|
+
.add(new Transform())
|
|
134
|
+
.add(new EditorEntity());
|
|
135
|
+
|
|
136
|
+
builder.addEventListener(EventType.EntityRemoved, () => {
|
|
137
|
+
p0.onChanged.remove(attemptUpdate);
|
|
138
|
+
gridPosition.onChanged.remove(attemptUpdate);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
builder.on.built.add(() => {
|
|
142
|
+
p0.onChanged.add(attemptUpdate);
|
|
143
|
+
gridPosition.onChanged.add(attemptUpdate);
|
|
144
|
+
|
|
145
|
+
attemptUpdate();
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return builder;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const display = make3DSymbolicDisplay({
|
|
152
|
+
engine,
|
|
153
|
+
components: [GridPosition, Transform],
|
|
154
|
+
factory([gridPosition, transform, entity], api) {
|
|
155
|
+
|
|
156
|
+
api.emit(makeHelper(gridPosition, transform));
|
|
157
|
+
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
display.__state.onChanged.add((s0, s1) => {
|
|
163
|
+
if (s0 === ProcessState.Running) {
|
|
164
|
+
//started
|
|
165
|
+
engine.executor.run(tTerrainWaiter);
|
|
166
|
+
} else if (s1 === ProcessState.Running) {
|
|
167
|
+
//stopepd
|
|
168
|
+
engine.executor.removeTask(tTerrainWaiter);
|
|
169
|
+
|
|
170
|
+
//purge update queue
|
|
171
|
+
updateQueue.splice(0, updateQueue.length);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
return display;
|
|
176
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { BufferAttribute, BufferGeometry, Float32BufferAttribute } from "three";
|
|
2
|
+
|
|
3
|
+
export function makeHelperBoxGeometry(sx = 1, sy = 1, sz = 1) {
|
|
4
|
+
|
|
5
|
+
const geometry = new BufferGeometry();
|
|
6
|
+
|
|
7
|
+
const dx = sx / 2;
|
|
8
|
+
const dy = sy / 2;
|
|
9
|
+
const dz = sz / 2;
|
|
10
|
+
|
|
11
|
+
const vertices = new Float32Array([
|
|
12
|
+
-dx, -dy, -dz,
|
|
13
|
+
dx, -dy, -dz,
|
|
14
|
+
dx, dy, -dz,
|
|
15
|
+
-dx, dy, -dz,
|
|
16
|
+
|
|
17
|
+
-dx, dy, dz,
|
|
18
|
+
dx, dy, dz,
|
|
19
|
+
dx, -dy, dz,
|
|
20
|
+
-dx, -dy, dz
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
geometry.setAttribute("position", new Float32BufferAttribute(vertices, 3));
|
|
24
|
+
|
|
25
|
+
geometry.setIndex(new BufferAttribute(new Uint8Array([
|
|
26
|
+
0, 1,
|
|
27
|
+
1, 2,
|
|
28
|
+
2, 3,
|
|
29
|
+
3, 0,
|
|
30
|
+
|
|
31
|
+
4, 5,
|
|
32
|
+
5, 6,
|
|
33
|
+
6, 7,
|
|
34
|
+
7, 4,
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
0, 7,
|
|
38
|
+
1, 6,
|
|
39
|
+
2, 5,
|
|
40
|
+
3, 4
|
|
41
|
+
]), 1, false));
|
|
42
|
+
|
|
43
|
+
return geometry;
|
|
44
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { BufferGeometry, Float32BufferAttribute } from "three";
|
|
2
|
+
import { max2 } from "../../../src/core/math/max2.js";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {number[]} vertices
|
|
8
|
+
* @param {number} radius
|
|
9
|
+
* @param {number} angle0
|
|
10
|
+
* @param {number} angle1
|
|
11
|
+
* @param {number} component0
|
|
12
|
+
* @param {number} component1
|
|
13
|
+
* @param {number} offset
|
|
14
|
+
* @param {number} count
|
|
15
|
+
*/
|
|
16
|
+
function addArc(vertices, radius, angle0, angle1, component0, component1, offset, count) {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
22
|
+
const angleSpan = angle1 - angle0;
|
|
23
|
+
|
|
24
|
+
const offset3 = offset * 3;
|
|
25
|
+
|
|
26
|
+
for (var i = 0; i < count; ++i) {
|
|
27
|
+
|
|
28
|
+
const address = i * 3 + offset3;
|
|
29
|
+
|
|
30
|
+
const f = i / (count - 1);
|
|
31
|
+
|
|
32
|
+
const angle = angle0 + angleSpan * f;
|
|
33
|
+
|
|
34
|
+
vertices[address + component0] = Math.cos(angle) * radius;
|
|
35
|
+
vertices[address + component1] = Math.sin(angle) * radius;
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param {number} [radius]
|
|
43
|
+
* @param {number} [resolution]
|
|
44
|
+
* @returns {BufferGeometry}
|
|
45
|
+
*/
|
|
46
|
+
export function makeHelperSphereGeometry(radius = 1, resolution = 64) {
|
|
47
|
+
const geometry = new BufferGeometry();
|
|
48
|
+
|
|
49
|
+
const r_4 = max2(2, Math.floor(resolution / 4));
|
|
50
|
+
|
|
51
|
+
const pointCount = r_4 * 4 * 3;
|
|
52
|
+
|
|
53
|
+
const vertices = new Float32Array(pointCount * 3);
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
let offset = 0;
|
|
57
|
+
|
|
58
|
+
addArc(vertices, radius, 0, Math.PI * 2, 0, 1, offset, r_4 * 4);
|
|
59
|
+
offset += r_4 * 4;
|
|
60
|
+
|
|
61
|
+
addArc(vertices, radius, 0, Math.PI * 1.5, 0, 2, offset, r_4 * 3);
|
|
62
|
+
offset += r_4 * 3;
|
|
63
|
+
|
|
64
|
+
addArc(vertices, radius, -Math.PI * 0.5, Math.PI * 1.5, 1, 2, offset, r_4 * 4);
|
|
65
|
+
offset += r_4 * 4;
|
|
66
|
+
|
|
67
|
+
addArc(vertices, radius, Math.PI * 1.5, Math.PI * 2, 0, 2, offset, r_4);
|
|
68
|
+
|
|
69
|
+
geometry.setAttribute('position', new Float32BufferAttribute(vertices, 3));
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
return geometry;
|
|
73
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Light } from "../../../src/engine/graphics/ecs/light/Light.js";
|
|
2
|
+
import { DirectionalLightHelper, PointLightHelper, SpotLightHelper } from "three";
|
|
3
|
+
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
4
|
+
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
5
|
+
import Renderable from "../../../src/engine/ecs/components/Renderable.js";
|
|
6
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {Engine} engine
|
|
11
|
+
* @returns {ComponentSymbolicDisplay}
|
|
12
|
+
*/
|
|
13
|
+
export function makeLightSymbolicDisplay(engine) {
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
* @param {Light} light
|
|
18
|
+
*/
|
|
19
|
+
function makeHelper(light) {
|
|
20
|
+
const threeObject = light.__threeObject;
|
|
21
|
+
|
|
22
|
+
if (threeObject === null) {
|
|
23
|
+
console.warn('Light object is not initialized', light);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (threeObject === undefined) {
|
|
27
|
+
console.error('Light object is undefined', light);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (light.type.getValue()) {
|
|
32
|
+
case Light.Type.SPOT:
|
|
33
|
+
return new SpotLightHelper(threeObject);
|
|
34
|
+
case Light.Type.POINT:
|
|
35
|
+
return new PointLightHelper(threeObject);
|
|
36
|
+
case Light.Type.DIRECTION:
|
|
37
|
+
return new DirectionalLightHelper(threeObject);
|
|
38
|
+
|
|
39
|
+
default:
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return make3DSymbolicDisplay({
|
|
45
|
+
engine,
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param light
|
|
50
|
+
* @param transform
|
|
51
|
+
* @param entity
|
|
52
|
+
* @param {SymbolicDisplayInternalAPI} api
|
|
53
|
+
*/
|
|
54
|
+
factory([light, transform, entity], api) {
|
|
55
|
+
|
|
56
|
+
const helper = makeHelper(light);
|
|
57
|
+
|
|
58
|
+
if (helper === null) {
|
|
59
|
+
//no helper for this light type
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const entityBuilder = buildThreeJSHelperEntity(helper);
|
|
64
|
+
|
|
65
|
+
const r = entityBuilder.getComponent(Renderable);
|
|
66
|
+
|
|
67
|
+
r.matrixAutoUpdate = false;
|
|
68
|
+
|
|
69
|
+
api.bind(light.type.onChanged, api.update, api);
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
api.emit(entityBuilder);
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
components: [Light, Transform]
|
|
76
|
+
});
|
|
77
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
2
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
3
|
+
import { BoxBufferGeometry, Group, Line, LineBasicMaterial, Mesh, MeshBasicMaterial } from "three";
|
|
4
|
+
import { buildThreeJSHelperEntity } from "./buildThreeJSHelperEntity.js";
|
|
5
|
+
import { ParticleEmitter } from "../../../src/engine/graphics/particles/particular/engine/emitter/ParticleEmitter.js";
|
|
6
|
+
import { makeHelperSphereGeometry } from "./makeHelperSphereGeometry.js";
|
|
7
|
+
import {
|
|
8
|
+
EmissionShapeType
|
|
9
|
+
} from "../../../src/engine/graphics/particles/particular/engine/emitter/EmissionShapeType.js";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {Engine} engine
|
|
14
|
+
*/
|
|
15
|
+
export function makeParticleEmitterSymbolicDisplay(engine) {
|
|
16
|
+
|
|
17
|
+
const wireframeMaterial = new MeshBasicMaterial({ wireframe: true, depthTest: true });
|
|
18
|
+
|
|
19
|
+
const lineMaterial = new LineBasicMaterial({
|
|
20
|
+
depthTest: true,
|
|
21
|
+
depthWrite: false,
|
|
22
|
+
transparent: true,
|
|
23
|
+
linewidth: 1,
|
|
24
|
+
fog: false,
|
|
25
|
+
color: '#FFFFFF',
|
|
26
|
+
opacity: 0.5
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const centerMaterial = new MeshBasicMaterial({ color: 0xFF0000, transparent: true, opacity: 0.2 });
|
|
30
|
+
|
|
31
|
+
const sphereBufferGeometry = makeHelperSphereGeometry(0.5, 64);
|
|
32
|
+
|
|
33
|
+
const boxGeometry = new BoxBufferGeometry(1, 1, 1, 1, 1, 1,);
|
|
34
|
+
|
|
35
|
+
const centerGeometry = new BoxBufferGeometry(0.03, 0.03, 0.03, 1, 1, 1,);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param {ParticleEmitter} emitter
|
|
40
|
+
* @param {Transform} transform
|
|
41
|
+
* @param {number} entity
|
|
42
|
+
* @param {SymbolicDisplayInternalAPI} api
|
|
43
|
+
* @returns {EntityBuilder}
|
|
44
|
+
*/
|
|
45
|
+
function factory([emitter, transform, entity], api) {
|
|
46
|
+
|
|
47
|
+
const group = new Group();
|
|
48
|
+
group.name = 'Particle Emitter Gizmo';
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {ParticleLayer} layer
|
|
53
|
+
*/
|
|
54
|
+
function addLayer(layer) {
|
|
55
|
+
const emissionShape = layer.emissionShape;
|
|
56
|
+
|
|
57
|
+
const center = new Mesh(centerGeometry, centerMaterial);
|
|
58
|
+
center.name = "Center Marker";
|
|
59
|
+
center.frustumCulled = false;
|
|
60
|
+
|
|
61
|
+
center.position.copy(layer.position);
|
|
62
|
+
|
|
63
|
+
group.add(center);
|
|
64
|
+
|
|
65
|
+
let geometry;
|
|
66
|
+
let mesh;
|
|
67
|
+
|
|
68
|
+
if (emissionShape === EmissionShapeType.Box) {
|
|
69
|
+
|
|
70
|
+
geometry = boxGeometry;
|
|
71
|
+
mesh = new Mesh(geometry, wireframeMaterial);
|
|
72
|
+
|
|
73
|
+
} else if (emissionShape === EmissionShapeType.Sphere) {
|
|
74
|
+
|
|
75
|
+
geometry = sphereBufferGeometry;
|
|
76
|
+
mesh = new Line(geometry, lineMaterial);
|
|
77
|
+
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function updateScale() {
|
|
81
|
+
center.scale.set(
|
|
82
|
+
1 / transform.scale.x,
|
|
83
|
+
1 / transform.scale.y,
|
|
84
|
+
1 / transform.scale.z
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
mesh.scale.set(
|
|
88
|
+
layer.scale.x,
|
|
89
|
+
layer.scale.y,
|
|
90
|
+
layer.scale.z
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function updatePosition() {
|
|
95
|
+
mesh.position.copy(layer.position);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (mesh !== undefined) {
|
|
99
|
+
|
|
100
|
+
mesh.frustumCulled = false;
|
|
101
|
+
|
|
102
|
+
updateScale();
|
|
103
|
+
updatePosition();
|
|
104
|
+
|
|
105
|
+
group.add(mesh);
|
|
106
|
+
|
|
107
|
+
api.bind(layer.position.onChanged, updatePosition);
|
|
108
|
+
|
|
109
|
+
api.bind(layer.scale.onChanged, updateScale);
|
|
110
|
+
api.bind(transform.scale.onChanged, updateScale);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @param {ParticleLayer} layer
|
|
117
|
+
*/
|
|
118
|
+
function removeLayer(layer) {
|
|
119
|
+
// TODO implement
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
emitter.traverseLayers(addLayer);
|
|
123
|
+
|
|
124
|
+
const builder = buildThreeJSHelperEntity(group, entity);
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
*
|
|
128
|
+
* @type {Transform}
|
|
129
|
+
*/
|
|
130
|
+
const t = builder.getComponent(Transform);
|
|
131
|
+
|
|
132
|
+
api.bindTransform(transform, t);
|
|
133
|
+
|
|
134
|
+
api.bind(emitter.layers.on.added, addLayer, {});
|
|
135
|
+
api.bind(emitter.layers.on.removed, removeLayer, {});
|
|
136
|
+
|
|
137
|
+
api.emit(builder);
|
|
138
|
+
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return make3DSymbolicDisplay({
|
|
142
|
+
engine,
|
|
143
|
+
components: [ParticleEmitter, Transform],
|
|
144
|
+
factory
|
|
145
|
+
});
|
|
146
|
+
}
|