@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,193 @@
|
|
|
1
|
+
import { TerrainPaintTool } from "./TerrainPaintTool.js";
|
|
2
|
+
import { convertSampler2D2DataURL } from "../../../src/engine/graphics/texture/sampler/convertSampler2D2DataURL.js";
|
|
3
|
+
import { obtainTerrain } from "../../../src/engine/ecs/terrain/util/obtainTerrain.js";
|
|
4
|
+
import { ModifyPatchTextureArray2DAction } from "../../actions/concrete/ModifyPatchTextureArray2DAction.js";
|
|
5
|
+
import { ArrayCopyAction } from "../../actions/concrete/ArrayCopyAction.js";
|
|
6
|
+
import { ActionUpdateTexture } from "../../actions/concrete/ActionUpdateTexture.js";
|
|
7
|
+
|
|
8
|
+
export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
|
|
12
|
+
this.name = "texture-paint-terrain";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @type {number}
|
|
17
|
+
*/
|
|
18
|
+
this.settings.splatIndex = 0;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @type {Float32Array}
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
this.__splatMapScratch = new Float32Array(0);
|
|
26
|
+
|
|
27
|
+
this.__iconLayer = null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
updateIcon(editor) {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* @type {Terrain}
|
|
36
|
+
*/
|
|
37
|
+
const terrain = obtainTerrain(editor.engine.entityManager.dataset);
|
|
38
|
+
|
|
39
|
+
if (terrain === null) {
|
|
40
|
+
// no terrain
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
* @type {TerrainLayer}
|
|
47
|
+
*/
|
|
48
|
+
const layer = terrain.layers.get(this.settings.splatIndex);
|
|
49
|
+
|
|
50
|
+
if (layer === this.__iconLayer) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
this.__iconLayer = layer;
|
|
55
|
+
|
|
56
|
+
this.buildIcon(terrain);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
*
|
|
61
|
+
* @param {Terrain} terrain
|
|
62
|
+
*/
|
|
63
|
+
buildIcon(terrain) {
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @type {TerrainLayer}
|
|
68
|
+
*/
|
|
69
|
+
const layer = terrain.layers.get(this.settings.splatIndex);
|
|
70
|
+
|
|
71
|
+
if (layer === undefined) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const url = convertSampler2D2DataURL(layer.diffuse);
|
|
76
|
+
|
|
77
|
+
this.icon.set(url);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
initialize() {
|
|
81
|
+
super.initialize();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
shutdown() {
|
|
85
|
+
super.shutdown();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async paint(timeDelta) {
|
|
89
|
+
|
|
90
|
+
const power = this.settings.brushStrength * timeDelta;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* @type {Terrain}
|
|
95
|
+
*/
|
|
96
|
+
const terrain = this.terrain;
|
|
97
|
+
|
|
98
|
+
const brushPosition = this.__brushPosition;
|
|
99
|
+
const brushSize = this.settings.brushSize;
|
|
100
|
+
|
|
101
|
+
const terrainSize = terrain.size;
|
|
102
|
+
|
|
103
|
+
const terrainHeight = terrainSize.y;
|
|
104
|
+
const terrainWidth = terrainSize.x;
|
|
105
|
+
|
|
106
|
+
const uv_x = brushPosition.x / terrainWidth;
|
|
107
|
+
const uv_y = brushPosition.y / terrainHeight;
|
|
108
|
+
|
|
109
|
+
const uv_w = brushSize / terrainWidth;
|
|
110
|
+
const uv_h = brushSize / terrainHeight;
|
|
111
|
+
|
|
112
|
+
const uv_x0 = uv_x - uv_w / 2;
|
|
113
|
+
const uv_x1 = uv_x + uv_w / 2;
|
|
114
|
+
|
|
115
|
+
const uv_y0 = uv_y - uv_h / 2;
|
|
116
|
+
const uv_y1 = uv_y + uv_h / 2;
|
|
117
|
+
|
|
118
|
+
const marker = this.settings.marker;
|
|
119
|
+
|
|
120
|
+
const direction = this.modifiers.shift ? -1 : 1;
|
|
121
|
+
|
|
122
|
+
const speed = power * direction;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
*
|
|
126
|
+
* @type {Float32Array}
|
|
127
|
+
*/
|
|
128
|
+
const weightData = this.__splatMapScratch;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
*
|
|
132
|
+
* @type {SplatMapping}
|
|
133
|
+
*/
|
|
134
|
+
const splat = terrain.splat;
|
|
135
|
+
|
|
136
|
+
const splatWidth = splat.size.x;
|
|
137
|
+
const splatHeight = splat.size.y;
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
const h_x0 = uv_x0 * splatWidth;
|
|
141
|
+
const h_x1 = uv_x1 * splatWidth;
|
|
142
|
+
|
|
143
|
+
const h_y0 = uv_y0 * splatHeight;
|
|
144
|
+
const h_y1 = uv_y1 * splatHeight;
|
|
145
|
+
|
|
146
|
+
const x0 = Math.ceil(h_x0);
|
|
147
|
+
const x1 = Math.floor(h_x1);
|
|
148
|
+
|
|
149
|
+
const y0 = Math.ceil(h_y0);
|
|
150
|
+
const y1 = Math.floor(h_y1);
|
|
151
|
+
|
|
152
|
+
const splatIndex = this.settings.splatIndex;
|
|
153
|
+
|
|
154
|
+
//create action
|
|
155
|
+
|
|
156
|
+
// const m_action = new ModifyPatchSampler2DAction(splat_layer_sampler, [x0, y0, x1, y1]);
|
|
157
|
+
const m_action = new ModifyPatchTextureArray2DAction(weightData, [splat.size.x, splat.size.y, splat.depth], [x0, y0, x1, y1]);
|
|
158
|
+
|
|
159
|
+
m_action.applyWeightStampToLayer(
|
|
160
|
+
uv_x * splat.size.x, uv_y * splat.size.y,
|
|
161
|
+
marker, splatIndex, speed,
|
|
162
|
+
0, 255
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
await this.editor.actions.doMany([
|
|
166
|
+
m_action,
|
|
167
|
+
new ArrayCopyAction(weightData, splat.weightData),
|
|
168
|
+
new ActionUpdateTexture(splat.weightTexture)
|
|
169
|
+
]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
start() {
|
|
173
|
+
super.start();
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* @type {Terrain}
|
|
178
|
+
*/
|
|
179
|
+
const terrain = this.terrain;
|
|
180
|
+
|
|
181
|
+
const splat = terrain.splat;
|
|
182
|
+
|
|
183
|
+
const weightData = splat.weightData;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* @type {Float32Array}
|
|
188
|
+
*/
|
|
189
|
+
this.__splatMapScratch = new Float32Array(weightData);
|
|
190
|
+
|
|
191
|
+
this.editor.actions.mark('paint terrain texture');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { EngineHarness } from "../../../src/engine/EngineHarness.js";
|
|
2
|
+
import { GizmoRenderingPlugin } from "../../../src/engine/graphics/render/gizmo/GizmoRenderingPlugin.js";
|
|
3
|
+
import { GameAssetType } from "../../../src/engine/asset/GameAssetType.js";
|
|
4
|
+
import { TextureAssetLoader } from "../../../src/engine/asset/loaders/texture/TextureAssetLoader.js";
|
|
5
|
+
import Vector2 from "../../../src/core/geom/Vector2.js";
|
|
6
|
+
import { enableEditor } from "../../enableEditor.js";
|
|
7
|
+
import { initializeEditor } from "../../../../model/game/initializeEditor.js";
|
|
8
|
+
|
|
9
|
+
import '../../../../../../css/game.scss';
|
|
10
|
+
import '../../../../../../css/editor/EntityEditorView.scss';
|
|
11
|
+
import '../../../../../../css/editor/EditorView.scss';
|
|
12
|
+
import { TerrainLayer } from "../../../src/engine/ecs/terrain/ecs/layers/TerrainLayer.js";
|
|
13
|
+
import Terrain from "../../../src/engine/ecs/terrain/ecs/Terrain.js";
|
|
14
|
+
import Vector3 from "../../../src/core/geom/Vector3.js";
|
|
15
|
+
import { BlenderCameraOrientationGizmo } from "../v2/BlenderCameraOrientationGizmo.js";
|
|
16
|
+
import { Transform } from "../../../src/engine/ecs/transform/Transform.js";
|
|
17
|
+
import TopDownCameraController from "../../../src/engine/graphics/ecs/camera/topdown/TopDownCameraController.js";
|
|
18
|
+
|
|
19
|
+
new EngineHarness()
|
|
20
|
+
.initialize({
|
|
21
|
+
configuration(config, engine) {
|
|
22
|
+
|
|
23
|
+
config.addPlugin(GizmoRenderingPlugin);
|
|
24
|
+
|
|
25
|
+
config.addLoader(GameAssetType.Texture, new TextureAssetLoader());
|
|
26
|
+
}
|
|
27
|
+
}).then(main);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param {Engine} engine
|
|
32
|
+
* @returns {Promise<void>}
|
|
33
|
+
*/
|
|
34
|
+
async function main(engine) {
|
|
35
|
+
await EngineHarness.buildBasics({
|
|
36
|
+
engine,
|
|
37
|
+
focus: new Vector3(128, 0, 128),
|
|
38
|
+
distance: 30,
|
|
39
|
+
terrainResolution: 1,
|
|
40
|
+
terrainSize: new Vector2(128, 128),
|
|
41
|
+
enableWater: false
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const ecd = engine.entityManager.dataset;
|
|
45
|
+
const terrain_entity = ecd.getAnyComponent(Terrain);
|
|
46
|
+
const terrain = terrain_entity.component;
|
|
47
|
+
|
|
48
|
+
terrain.samplerHeight.resize(256, 256);
|
|
49
|
+
await terrain.updateHeights();
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
terrain.layers.addLayer(TerrainLayer.from("data/textures/materials/terrain_township_set/512/Grass_1.png", 20, 20));
|
|
53
|
+
terrain.layers.addLayer(TerrainLayer.from("data/textures/materials/terrain_township_set/512/Ground_1.png", 20, 20));
|
|
54
|
+
terrain.layers.addLayer(TerrainLayer.from("data/textures/materials/RAYGEAS/Stylized Ground Textures/Sand_2/Sand_2_AlbedoSmoothness.png", 20, 20));
|
|
55
|
+
terrain.layers.buildTexture();
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
terrain.splat.resize(256, 256, terrain.layers.count())
|
|
59
|
+
|
|
60
|
+
await terrain.layers.loadTextureData(engine.assetManager);
|
|
61
|
+
|
|
62
|
+
terrain.splat.fillLayerWeights(0, 50);
|
|
63
|
+
|
|
64
|
+
terrain.splat.weightTexture.needsUpdate = true;
|
|
65
|
+
terrain.updateMaterial();
|
|
66
|
+
|
|
67
|
+
const editor_controls = enableEditor(engine, initializeEditor);
|
|
68
|
+
|
|
69
|
+
editor_controls.enable();
|
|
70
|
+
|
|
71
|
+
const camera_orientation_gizmo = new BlenderCameraOrientationGizmo();
|
|
72
|
+
|
|
73
|
+
camera_orientation_gizmo.css({
|
|
74
|
+
position: 'absolute',
|
|
75
|
+
top: 0,
|
|
76
|
+
right: 0,
|
|
77
|
+
pointerEvents: 'auto'
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
camera_orientation_gizmo.on.axisSelected.add((axis) => {
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @type {TopDownCameraController}
|
|
85
|
+
*/
|
|
86
|
+
const tdcc = editor_controls.editor.cameraEntity.getComponent(TopDownCameraController);
|
|
87
|
+
|
|
88
|
+
tdcc.pitch = 0;
|
|
89
|
+
tdcc.yaw = 0;
|
|
90
|
+
tdcc.roll = 0;
|
|
91
|
+
|
|
92
|
+
switch (axis) {
|
|
93
|
+
case 'x':
|
|
94
|
+
tdcc.yaw = Math.PI / 2;
|
|
95
|
+
break;
|
|
96
|
+
case '-x':
|
|
97
|
+
tdcc.yaw = -Math.PI / 2;
|
|
98
|
+
break;
|
|
99
|
+
case 'z':
|
|
100
|
+
tdcc.yaw = 0;
|
|
101
|
+
break;
|
|
102
|
+
case '-z':
|
|
103
|
+
tdcc.yaw = Math.PI;
|
|
104
|
+
break;
|
|
105
|
+
case 'y':
|
|
106
|
+
tdcc.pitch = Math.PI / 2;
|
|
107
|
+
break;
|
|
108
|
+
case '-y':
|
|
109
|
+
tdcc.pitch = -Math.PI / 2;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
engine.gameView.addChild(camera_orientation_gizmo);
|
|
115
|
+
|
|
116
|
+
engine.graphics.on.preRender.add(() => {
|
|
117
|
+
const camera_transform = editor_controls.editor.cameraEntity.getComponent(Transform);
|
|
118
|
+
|
|
119
|
+
if (camera_transform === null) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
camera_orientation_gizmo.orientation = camera_transform.rotation;
|
|
124
|
+
|
|
125
|
+
camera_orientation_gizmo.update();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
setTimeout(() => {
|
|
129
|
+
editor_controls.editor.selection.add(terrain_entity.entity);
|
|
130
|
+
|
|
131
|
+
// camera_orientation_gizmo.orientation =;
|
|
132
|
+
}, 100);
|
|
133
|
+
|
|
134
|
+
console.warn(terrain);
|
|
135
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import View, {IViewSignals} from "../../../src/view/View";
|
|
2
|
+
import Quaternion from "../../../src/core/geom/Quaternion";
|
|
3
|
+
import Signal from "../../../src/core/events/signal/Signal";
|
|
4
|
+
|
|
5
|
+
interface ISignals extends IViewSignals {
|
|
6
|
+
readonly axisSelected: Signal<string>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface IDirectionStyle {
|
|
10
|
+
near_fill?: string
|
|
11
|
+
near_stroke_width?: number
|
|
12
|
+
near_stroke_color?: string
|
|
13
|
+
|
|
14
|
+
far_fill?: string
|
|
15
|
+
far_stroke_width?: number
|
|
16
|
+
far_stroke_color?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface IOptions {
|
|
20
|
+
size?: number,
|
|
21
|
+
padding?: number,
|
|
22
|
+
bubbleSizePrimary?: number,
|
|
23
|
+
bubbleSizeSecondary?: number,
|
|
24
|
+
lineWidth?: number,
|
|
25
|
+
fontSize?: string,
|
|
26
|
+
fontFamily?: string,
|
|
27
|
+
fontWeight?: string,
|
|
28
|
+
fontColor?: string,
|
|
29
|
+
fontYAdjust?: number,
|
|
30
|
+
selectionFontColor?: string,
|
|
31
|
+
axisStyles?: {
|
|
32
|
+
px?: IDirectionStyle,
|
|
33
|
+
py?: IDirectionStyle,
|
|
34
|
+
pz?: IDirectionStyle,
|
|
35
|
+
|
|
36
|
+
nx?: IDirectionStyle,
|
|
37
|
+
ny?: IDirectionStyle,
|
|
38
|
+
nz?: IDirectionStyle,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class BlenderCameraOrientationGizmo extends View {
|
|
43
|
+
constructor(options?: IOptions)
|
|
44
|
+
|
|
45
|
+
on: ISignals
|
|
46
|
+
|
|
47
|
+
orientation: Quaternion | null
|
|
48
|
+
|
|
49
|
+
update(): void
|
|
50
|
+
}
|