@woosh/meep-engine 2.33.60 → 2.33.64
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/core/geom/3d/SurfacePoint3.js +44 -5
- package/core/geom/Vector2.d.ts +2 -0
- package/core/geom/packing/MaxRectangles.js +13 -4
- package/core/math/hash/murmur3_32.js +3 -3
- package/ecs/grid/pick.js +44 -0
- package/editor/actions/concrete/PaintTerrainOverlayAction.js +1 -1
- package/editor/process/ObstacleGridDisplayProcess.js +1 -1
- package/editor/process/symbolic/makeGridPositionSymbolDisplay.js +1 -1
- package/editor/tools/FoliagePaintTool.js +1 -1
- package/editor/tools/GridPaintTool.js +2 -2
- package/editor/tools/paint/TerrainPaintTool.js +2 -2
- package/editor/tools/paint/TerrainTexturePaintTool.js +1 -1
- package/editor/view/EditorView.js +1 -1
- package/editor/view/GridPickCoordinateView.js +2 -2
- package/engine/asset/loaders/material/computeTextureHash.js +7 -13
- package/engine/ecs/animation/InverseKinematicsSystem.js +1 -1
- package/engine/ecs/attachment/AttachmentSystem.js +9 -56
- package/engine/ecs/evaluation/world/ReadTerrainLayerWeightPointFitness.js +1 -1
- package/engine/ecs/fow/FogOfWarRevealerSystem.js +2 -2
- package/engine/ecs/grid/HeightMap2NormalMap.js +1 -1
- package/engine/ecs/grid/NormalMap2AOMap.js +1 -1
- package/engine/ecs/gui/position/ViewportPositionSystem.js +5 -5
- package/engine/ecs/parent/EntityNode.d.ts +20 -0
- package/engine/ecs/parent/EntityNode.js +284 -0
- package/engine/ecs/parent/FaceEditor.js +137 -0
- package/engine/ecs/parent/testCompositionEntityNode.js +153 -0
- package/engine/ecs/parent/testHuDPerf.js +123 -0
- package/engine/ecs/team/Team.js +82 -0
- package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
- package/engine/ecs/terrain/ecs/Terrain.js +14 -5
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +112 -0
- package/engine/ecs/terrain/util/obtainTerrain.js +23 -0
- package/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
- package/engine/graphics/GraphicsEngine.js +1 -2
- package/engine/graphics/camera/testClippingPlaneComputation.js +0 -4
- package/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +1 -1
- package/engine/graphics/ecs/light/LightSystem.js +1 -1
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +29 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +158 -1
- package/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/engine/graphics/ecs/water/WaterSystem.js +1 -1
- package/engine/graphics/ecs/water2/shader/testWaterShader.js +1 -1
- package/engine/graphics/geometry/AttributeSpec.d.ts +8 -0
- package/engine/graphics/geometry/VertexDataSpec.d.ts +15 -0
- package/engine/graphics/geometry/buffered/deinterleaveBufferAttribute.js +39 -0
- package/engine/graphics/geometry/buffered/deinterleaveBufferGeometry.js +50 -0
- package/engine/graphics/geometry/buffered/query/GeometrySpatialQueryAccelerator.js +55 -11
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +10 -7
- package/engine/graphics/micron/format/MicronGeometry.d.ts +4 -0
- package/engine/graphics/micron/render/v1/MaterialContext.js +1 -0
- package/engine/graphics/particles/particular/engine/simulator/SimulationStepFixedPhysics.js +19 -3
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -4
- package/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +2 -4
- package/engine/graphics/render/frame_graph/FrameGraphBuilder.js +36 -0
- package/engine/graphics/render/frame_graph/IRenderContext.js +8 -0
- package/engine/graphics/render/frame_graph/RenderPass.js +32 -0
- package/engine/graphics/render/frame_graph/RenderPassFlags.js +6 -0
- package/engine/graphics/render/frame_graph/RenderPassResources.js +15 -0
- package/engine/graphics/render/frame_graph/Resource.js +21 -0
- package/engine/graphics/render/frame_graph/ResourceReference.js +14 -0
- package/engine/graphics/render/frame_graph/TextureDescriptor.js +30 -0
- package/engine/graphics/render/frame_graph/UsageModeType.js +5 -0
- package/engine/graphics/render/frame_graph/sample/deferred/GBufferDrawPass.js +27 -0
- package/engine/graphics/render/frame_graph/sample/deferred/PresentPass.js +17 -0
- package/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
- package/engine/graphics/render/webgpu/sample/MeshInstance.js +108 -0
- package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +71 -0
- package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +39 -0
- package/engine/graphics/render/webgpu/sample/fragmentWriteGBuffers.wgsl +21 -0
- package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +41 -0
- package/engine/graphics/render/webgpu/sample/main.js +604 -0
- package/engine/graphics/render/webgpu/sample/vertexTextureQuad.wgsl +9 -0
- package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +30 -0
- package/engine/graphics/shadows/testShadowMapRendering.js +0 -2
- package/engine/{ecs/grid → graphics/texture/sampler}/sampler2DToFloat32Texture.js +1 -1
- package/engine/graphics/util/modelHitTest.js +63 -0
- package/engine/grid/systems/GridPosition2TransformSystem.js +1 -1
- package/engine/grid/systems/ViewportGridProjectionSystem.js +1 -1
- package/engine/grid/transform2grid/Transform2GridPositionSystem.js +1 -1
- package/engine/scene/transitionToScene.js +1 -1
- package/generation/grid/actions/ContinuousGridCellActionSetTerrainHeight.js +1 -1
- package/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +1 -1
- package/generation/markers/debug/visualizeMarkers.js +1 -1
- package/generation/theme/ThemeEngine.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/main.js +117 -0
- package/view/minimap/Minimap.js +1 -1
- package/engine/ecs/sockets/AttachmentSocketsSystem.js +0 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Quaternion from "../Quaternion.js";
|
|
2
2
|
import Vector3 from "../Vector3.js";
|
|
3
|
+
import { v3_length } from "../v3_length.js";
|
|
3
4
|
|
|
4
5
|
const q = new Quaternion();
|
|
5
6
|
|
|
@@ -14,14 +15,52 @@ export class SurfacePoint3 {
|
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
*
|
|
17
|
-
* @param {
|
|
18
|
+
* @param {number[]|mat4|Float32Array} m4
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
applyMatrix4(m4) {
|
|
21
|
+
// transform position
|
|
22
|
+
const p = this.position;
|
|
23
|
+
|
|
24
|
+
const p_x = p.x;
|
|
25
|
+
const p_y = p.y;
|
|
26
|
+
const p_z = p.z;
|
|
27
|
+
|
|
28
|
+
const result_p_x = m4[0] * p_x + m4[4] * p_y + m4[8] * p_z + m4[12];
|
|
29
|
+
const result_p_y = m4[1] * p_x + m4[5] * p_y + m4[9] * p_z + m4[13];
|
|
30
|
+
const result_p_z = m4[2] * p_x + m4[6] * p_y + m4[10] * p_z + m4[14];
|
|
31
|
+
|
|
32
|
+
this.position.set(
|
|
33
|
+
result_p_x,
|
|
34
|
+
result_p_y,
|
|
35
|
+
result_p_z
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// transform normal
|
|
39
|
+
const n = this.normal;
|
|
40
|
+
|
|
41
|
+
const n_x = n.x;
|
|
42
|
+
const n_y = n.y;
|
|
43
|
+
const n_z = n.z;
|
|
44
|
+
|
|
45
|
+
const result_n_x = m4[0] * n_x + m4[4] * n_y + m4[8] * n_z;
|
|
46
|
+
const result_n_y = m4[1] * n_x + m4[5] * n_y + m4[9] * n_z;
|
|
47
|
+
const result_n_z = m4[2] * n_x + m4[6] * n_y + m4[10] * n_z;
|
|
21
48
|
|
|
22
|
-
|
|
49
|
+
const normal_multiplier = 1 / v3_length(result_n_x, result_n_y, result_n_z);
|
|
23
50
|
|
|
24
|
-
this.normal.
|
|
51
|
+
this.normal.set(
|
|
52
|
+
result_n_x * normal_multiplier,
|
|
53
|
+
result_n_y * normal_multiplier,
|
|
54
|
+
result_n_z * normal_multiplier,
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
*
|
|
60
|
+
* @param {THREE.Matrix4} matrix4
|
|
61
|
+
*/
|
|
62
|
+
applyMatrix4_three(matrix4) {
|
|
63
|
+
this.applyMatrix4(matrix4.elements);
|
|
25
64
|
}
|
|
26
65
|
|
|
27
66
|
/**
|
package/core/geom/Vector2.d.ts
CHANGED
|
@@ -12,9 +12,10 @@ import Vector2 from "../Vector2.js";
|
|
|
12
12
|
* @param {AABB2[]} boxes
|
|
13
13
|
*/
|
|
14
14
|
function removeRedundantBoxesArray(boxes) {
|
|
15
|
+
let i, j;
|
|
15
16
|
let numBoxes = boxes.length;
|
|
16
17
|
|
|
17
|
-
loop_a: for (
|
|
18
|
+
loop_a: for (i = 0; i < numBoxes; i++) {
|
|
18
19
|
const a = boxes[i];
|
|
19
20
|
|
|
20
21
|
const ax0 = a.x0;
|
|
@@ -22,7 +23,7 @@ function removeRedundantBoxesArray(boxes) {
|
|
|
22
23
|
const ax1 = a.x1;
|
|
23
24
|
const ay1 = a.y1;
|
|
24
25
|
|
|
25
|
-
for (
|
|
26
|
+
for (j = i + 1; j < numBoxes; j++) {
|
|
26
27
|
const b = boxes[j];
|
|
27
28
|
|
|
28
29
|
const bx0 = b.x0;
|
|
@@ -157,7 +158,7 @@ function findBestContainer(width, height, boxes, costFunction) {
|
|
|
157
158
|
let best = null;
|
|
158
159
|
let bestScore = Number.POSITIVE_INFINITY;
|
|
159
160
|
|
|
160
|
-
|
|
161
|
+
const visitor = (node) => {
|
|
161
162
|
|
|
162
163
|
if (node.getWidth() < width) {
|
|
163
164
|
//too small, don't traverse deeper
|
|
@@ -195,7 +196,11 @@ function findBestContainer(width, height, boxes, costFunction) {
|
|
|
195
196
|
best = box;
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
|
-
|
|
199
|
+
|
|
200
|
+
return true;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
boxes.traversePreOrder(visitor);
|
|
199
204
|
|
|
200
205
|
return best;
|
|
201
206
|
}
|
|
@@ -337,6 +342,10 @@ export class MaxRectanglesPacker {
|
|
|
337
342
|
this.free = new QuadTreeNode(0, 0, width, height);
|
|
338
343
|
this.free.add(null, 0, 0, width, height);
|
|
339
344
|
|
|
345
|
+
/**
|
|
346
|
+
*
|
|
347
|
+
* @type {AABB2[]}
|
|
348
|
+
*/
|
|
340
349
|
this.boxes = [];
|
|
341
350
|
}
|
|
342
351
|
|
|
@@ -9,9 +9,9 @@ export function murmur3_32(key, seed) {
|
|
|
9
9
|
let k1;
|
|
10
10
|
let i = 0;
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const key_length = key.length;
|
|
13
13
|
|
|
14
|
-
while (i <
|
|
14
|
+
while (i < key_length) {
|
|
15
15
|
k1 = key[i];
|
|
16
16
|
++i;
|
|
17
17
|
|
|
@@ -26,7 +26,7 @@ export function murmur3_32(key, seed) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
// mix in array length
|
|
29
|
-
h1 ^=
|
|
29
|
+
h1 ^= key_length;
|
|
30
30
|
|
|
31
31
|
h1 ^= h1 >>> 16;
|
|
32
32
|
h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16));
|
package/ecs/grid/pick.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { assert } from "../../core/assert.js";
|
|
2
|
+
import Vector3 from "../../core/geom/Vector3.js";
|
|
3
|
+
import { SurfacePoint3 } from "../../core/geom/3d/SurfacePoint3.js";
|
|
4
|
+
import Vector2 from "../../core/geom/Vector2.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {number} x
|
|
9
|
+
* @param {number} y
|
|
10
|
+
* @param {GraphicsEngine} graphicsEngine
|
|
11
|
+
* @param {Terrain} terrain
|
|
12
|
+
* @param {function(gridPosition:Vector2,worldPosition:Vector3,normal:Vector3)} callback
|
|
13
|
+
*/
|
|
14
|
+
export function pick(x, y, graphicsEngine, terrain, callback) {
|
|
15
|
+
|
|
16
|
+
assert.isNumber(x, 'x');
|
|
17
|
+
assert.isNumber(y, 'y');
|
|
18
|
+
|
|
19
|
+
assert.defined(terrain, 'terrain');
|
|
20
|
+
assert.notNull(terrain, 'terrain');
|
|
21
|
+
|
|
22
|
+
assert.isFunction(callback, 'callback');
|
|
23
|
+
|
|
24
|
+
const vSource = new Vector3(x, y, 0);
|
|
25
|
+
const vTarget = new Vector3();
|
|
26
|
+
|
|
27
|
+
graphicsEngine.normalizeViewportPoint(vSource, vSource);
|
|
28
|
+
graphicsEngine.viewportProjectionRay(vSource.x, vSource.y, vSource, vTarget);
|
|
29
|
+
|
|
30
|
+
const surfacePoint3 = new SurfacePoint3();
|
|
31
|
+
|
|
32
|
+
const hitFound = terrain.raycastFirstSync(surfacePoint3, vSource.x, vSource.y, vSource.z, vTarget.x, vTarget.y, vTarget.z);
|
|
33
|
+
|
|
34
|
+
if (!hitFound) {
|
|
35
|
+
// nothing found
|
|
36
|
+
} else {
|
|
37
|
+
|
|
38
|
+
const gridPosition = new Vector2();
|
|
39
|
+
terrain.mapPointWorld2Grid(surfacePoint3.position, gridPosition);
|
|
40
|
+
gridPosition._add(0.5, 0.5);
|
|
41
|
+
callback(gridPosition, surfacePoint3.position, surfacePoint3.normal);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
2
1
|
import Vector4 from "../../../core/geom/Vector4.js";
|
|
3
2
|
import { Action } from "../../../core/process/undo/Action.js";
|
|
3
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
4
4
|
|
|
5
5
|
class PaintTerrainOverlayAction extends Action {
|
|
6
6
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EditorProcess } from "./EditorProcess.js";
|
|
2
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
3
2
|
import GridObstacle from "../../engine/grid/components/GridObstacle.js";
|
|
4
3
|
import GridPosition from "../../engine/grid/components/GridPosition.js";
|
|
5
4
|
import { Sampler2D } from "../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
6
6
|
|
|
7
7
|
class ObstacleGridDisplayProcess extends EditorProcess {
|
|
8
8
|
|
|
@@ -4,7 +4,6 @@ import Task from "../../../core/process/task/Task.js";
|
|
|
4
4
|
import TaskSignal from "../../../core/process/task/TaskSignal.js";
|
|
5
5
|
import EntityBuilder from "../../../engine/ecs/EntityBuilder.js";
|
|
6
6
|
import { BufferGeometry, Float32BufferAttribute, Line, LineBasicMaterial } from "three";
|
|
7
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
8
7
|
import Renderable from "../../../engine/ecs/components/Renderable.js";
|
|
9
8
|
import { SurfacePoint3 } from "../../../core/geom/3d/SurfacePoint3.js";
|
|
10
9
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
@@ -14,6 +13,7 @@ import { EventType } from "../../../engine/ecs/EntityManager.js";
|
|
|
14
13
|
import { make3DSymbolicDisplay } from "./make3DSymbolicDisplay.js";
|
|
15
14
|
import GridPosition from "../../../engine/grid/components/GridPosition.js";
|
|
16
15
|
import { ProcessState } from "../../../core/process/ProcessState.js";
|
|
16
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import Tool from "./engine/Tool.js";
|
|
2
2
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
3
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
4
3
|
import ObservedValue from "../../core/model/ObservedValue.js";
|
|
5
4
|
import Vector4 from "../../core/geom/Vector4.js";
|
|
6
5
|
import loadSampler2D from "../../engine/graphics/texture/sampler/loadSampler2D.js";
|
|
7
6
|
import convertSampler2D2Canvas from "../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
8
7
|
import { InstancedMeshComponent } from "../../engine/ecs/foliage/ecs/InstancedMeshComponent.js";
|
|
9
8
|
import { parseHex } from "../../core/color/parseHex.js";
|
|
9
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
10
10
|
|
|
11
11
|
class FoliagePaintTool extends Tool {
|
|
12
12
|
constructor() {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import Tool from "./engine/Tool.js";
|
|
2
2
|
import GridPosition from "../../engine/grid/components/GridPosition.js";
|
|
3
3
|
import GridObstacle from "../../engine/grid/components/GridObstacle.js";
|
|
4
|
-
import { pick } from "../../../model/game/util/ScreenGridPicker.js";
|
|
5
4
|
import Vector4 from "../../core/geom/Vector4.js";
|
|
6
5
|
import ObservedValue from "../../core/model/ObservedValue.js";
|
|
7
6
|
import Vector1 from "../../core/geom/Vector1.js";
|
|
8
7
|
import WriteGridValueAction from "../actions/concrete/WriteGridValueAction.js";
|
|
9
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
10
8
|
import PaintTerrainOverlayAction from "../actions/concrete/PaintTerrainOverlayAction.js";
|
|
11
9
|
import { decodeMouseEventButtons, PointerDevice } from "../../engine/input/devices/PointerDevice.js";
|
|
12
10
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
13
11
|
import TopDownCameraControllerSystem from "../../engine/graphics/ecs/camera/topdown/TopDownCameraControllerSystem.js";
|
|
14
12
|
import { parseHex } from "../../core/color/parseHex.js";
|
|
13
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
14
|
+
import { pick } from "../../ecs/grid/pick.js";
|
|
15
15
|
|
|
16
16
|
class GridPaintTool extends Tool {
|
|
17
17
|
constructor() {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { max2 } from "../../../core/math/max2.js";
|
|
2
2
|
import Tool from "../engine/Tool.js";
|
|
3
3
|
import { Color } from "../../../core/color/Color.js";
|
|
4
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
5
4
|
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
6
5
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
7
|
-
import { pick } from "../../../../model/game/util/ScreenGridPicker.js";
|
|
8
6
|
import convertSampler2D2Canvas from "../../../engine/graphics/texture/sampler/Sampler2D2Canvas.js";
|
|
9
7
|
import ObservedString from "../../../core/model/ObservedString.js";
|
|
10
8
|
import { GameAssetType } from "../../../engine/asset/GameAssetType.js";
|
|
11
9
|
import Vector1 from "../../../core/geom/Vector1.js";
|
|
10
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
11
|
+
import { pick } from "../../../ecs/grid/pick.js";
|
|
12
12
|
|
|
13
13
|
export class TerrainPaintTool extends Tool {
|
|
14
14
|
constructor() {
|
|
@@ -4,7 +4,7 @@ import { TerrainPaintTool } from "./TerrainPaintTool.js";
|
|
|
4
4
|
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
5
|
import { PatchTerrainTextureAction } from "../../actions/concrete/PatchTerrainTextureAction.js";
|
|
6
6
|
import { convertSampler2D2DataURL } from "../../../engine/graphics/texture/sampler/convertSampler2D2DataURL.js";
|
|
7
|
-
import { obtainTerrain } from "
|
|
7
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
8
8
|
|
|
9
9
|
export class TerrainTexturePaintTool extends TerrainPaintTool {
|
|
10
10
|
constructor() {
|
|
@@ -22,7 +22,6 @@ import MeshLibraryView from "./library/MeshLibraryView.js";
|
|
|
22
22
|
import BottomLeftResizeHandleView from "../../view/elements/BottomLeftResizeHandleView.js";
|
|
23
23
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
24
24
|
import Vector3 from "../../core/geom/Vector3.js";
|
|
25
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
26
25
|
import Mesh from "../../engine/graphics/ecs/mesh/Mesh.js";
|
|
27
26
|
import { Transform } from "../../engine/ecs/transform/Transform.js";
|
|
28
27
|
import SelectionClearAction from "../actions/concrete/SelectionClearAction.js";
|
|
@@ -32,6 +31,7 @@ import SelectionAddAction from "../actions/concrete/SelectionAddAction.js";
|
|
|
32
31
|
import { noop, passThrough } from "../../core/function/Functions.js";
|
|
33
32
|
import { ProcessState } from "../../core/process/ProcessState.js";
|
|
34
33
|
import { MeshEvents } from "../../engine/graphics/ecs/mesh/MeshEvents.js";
|
|
34
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
35
35
|
|
|
36
36
|
class ViewManager extends View {
|
|
37
37
|
constructor() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import View from "../../view/View.js";
|
|
2
|
-
import { pick } from "../../../model/game/util/ScreenGridPicker.js";
|
|
3
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
4
2
|
import domify from "../../view/DOM.js";
|
|
5
3
|
import { PointerDevice } from "../../engine/input/devices/PointerDevice.js";
|
|
4
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
5
|
+
import { pick } from "../../ecs/grid/pick.js";
|
|
6
6
|
|
|
7
7
|
class GridPickCoordinateView extends View {
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { max2 } from "../../../../core/math/max2.js";
|
|
2
1
|
import { computeImageBitmapHash } from "./computeImageBitmapHash.js";
|
|
3
2
|
import { computeHashIntegerArray } from "../../../../core/collection/array/computeHashIntegerArray.js";
|
|
4
3
|
import { computeHashFloat } from "../../../../core/math/hash/computeHashFloat.js";
|
|
4
|
+
import { murmur3_32 } from "../../../../core/math/hash/murmur3_32.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
*
|
|
@@ -59,6 +59,7 @@ export function computeImageDataHash(image) {
|
|
|
59
59
|
*/
|
|
60
60
|
function computeSpecificHash(texture) {
|
|
61
61
|
let dataHash = 0;
|
|
62
|
+
let i;
|
|
62
63
|
|
|
63
64
|
if (texture.image !== null && texture.image !== undefined) {
|
|
64
65
|
|
|
@@ -73,25 +74,18 @@ function computeSpecificHash(texture) {
|
|
|
73
74
|
if (Array.isArray(mipmaps)) {
|
|
74
75
|
const nMipmaps = mipmaps.length;
|
|
75
76
|
|
|
76
|
-
for (
|
|
77
|
+
for (i = 0; i < nMipmaps; i++) {
|
|
77
78
|
const mipmap = mipmaps[i];
|
|
78
79
|
|
|
79
|
-
if (mipmap.width > 16) {
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
80
|
const data = mipmap.data;
|
|
84
|
-
|
|
85
81
|
const dataSize = data.length;
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
for (let i = 0; i < dataSize; i += dataStride) {
|
|
90
|
-
const datum = data[i];
|
|
91
|
-
|
|
92
|
-
dataHash = ((dataHash << 5) - dataHash) + datum;
|
|
83
|
+
if (dataSize > 1024) {
|
|
84
|
+
continue;
|
|
93
85
|
}
|
|
94
86
|
|
|
87
|
+
dataHash = ((dataHash << 5) - dataHash) + murmur3_32(data, 1337);
|
|
88
|
+
|
|
95
89
|
break;
|
|
96
90
|
}
|
|
97
91
|
|
|
@@ -3,9 +3,9 @@ import { InverseKinematics } from "./InverseKinematics.js";
|
|
|
3
3
|
import Mesh, { MeshFlags } from "../../graphics/ecs/mesh/Mesh.js";
|
|
4
4
|
import { TwoBoneInverseKinematicsSolver } from "./TwoBoneInverseKinematicsSolver.js";
|
|
5
5
|
import { extractSkeletonFromMeshComponent } from "../../graphics/ecs/mesh/SkeletonUtils.js";
|
|
6
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
7
6
|
import { OneBoneSurfaceAlignmentSolver } from "./OneBoneSurfaceAlignmentSolver.js";
|
|
8
7
|
import { IKProblem } from "./IKProblem.js";
|
|
8
|
+
import { obtainTerrain } from "../terrain/util/obtainTerrain.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
export class InverseKinematicsSystem extends System {
|
|
@@ -6,39 +6,6 @@ import { assert } from "../../../core/assert.js";
|
|
|
6
6
|
import Mesh from "../../graphics/ecs/mesh/Mesh.js";
|
|
7
7
|
import { BoneAttachmentBinding } from "./BoneAttachmentBinding.js";
|
|
8
8
|
import { TransformAttachmentBinding } from "./TransformAttachmentBinding.js";
|
|
9
|
-
import { MeshSystem } from "../../graphics/ecs/mesh/MeshSystem.js";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @readonly
|
|
13
|
-
* @enum {number}
|
|
14
|
-
*/
|
|
15
|
-
const WaitingType = {
|
|
16
|
-
Entity: 0,
|
|
17
|
-
Socket: 1,
|
|
18
|
-
Mesh: 2,
|
|
19
|
-
Transform: 3
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
class WaitingEntry {
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @param {number} entity
|
|
26
|
-
* @param {WaitingType} type
|
|
27
|
-
*/
|
|
28
|
-
constructor(entity, type) {
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @type {number}
|
|
32
|
-
*/
|
|
33
|
-
this.entity = entity;
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @type {WaitingType}
|
|
37
|
-
*/
|
|
38
|
-
this.type = type;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
9
|
|
|
43
10
|
export class AttachmentSystem extends System {
|
|
44
11
|
constructor() {
|
|
@@ -316,17 +283,10 @@ export class AttachmentSystem extends System {
|
|
|
316
283
|
}
|
|
317
284
|
}
|
|
318
285
|
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
* @param {Mesh} mesh
|
|
322
|
-
* @param {number} entity
|
|
323
|
-
*/
|
|
324
|
-
visitVisibleMesh(mesh, entity) {
|
|
325
|
-
const bindings = this.parentBindingIndex.get(entity);
|
|
286
|
+
__updateAll() {
|
|
287
|
+
for (const [entity, bindings] of this.parentBindingIndex) {
|
|
326
288
|
|
|
327
|
-
if (bindings !== undefined) {
|
|
328
289
|
const n = bindings.length;
|
|
329
|
-
|
|
330
290
|
for (let i = 0; i < n; i++) {
|
|
331
291
|
const binding = bindings[i];
|
|
332
292
|
|
|
@@ -339,21 +299,14 @@ export class AttachmentSystem extends System {
|
|
|
339
299
|
//process wait queue
|
|
340
300
|
this.processWaiting();
|
|
341
301
|
|
|
342
|
-
|
|
343
|
-
*
|
|
344
|
-
* @type {MeshSystem}
|
|
345
|
-
*/
|
|
346
|
-
const meshSystem = this.entityManager.getSystem(MeshSystem);
|
|
302
|
+
const em = this.entityManager;
|
|
347
303
|
|
|
348
|
-
|
|
304
|
+
const ecd = em.dataset;
|
|
349
305
|
|
|
350
|
-
|
|
351
|
-
|
|
306
|
+
if (ecd === null) {
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
352
309
|
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
* @param {AttachmentBinding} binding
|
|
356
|
-
*/
|
|
357
|
-
function updateBinding(binding) {
|
|
358
|
-
binding.update();
|
|
310
|
+
this.__updateAll();
|
|
311
|
+
}
|
|
359
312
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { PointFitnessFunction } from "../PointFitnessFunction.js";
|
|
2
|
-
import { obtainTerrain } from "../../../../../model/game/scenes/SceneUtils.js";
|
|
3
2
|
import Vector3 from "../../../../core/geom/Vector3.js";
|
|
4
3
|
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
5
4
|
import { assert } from "../../../../core/assert.js";
|
|
5
|
+
import { obtainTerrain } from "../../terrain/util/obtainTerrain.js";
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
const v3 = new Vector3();
|
|
@@ -2,10 +2,10 @@ import { System } from "../System.js";
|
|
|
2
2
|
import { FogOfWarRevealer } from "./FogOfWarRevealer.js";
|
|
3
3
|
import { SignalBinding } from "../../../core/events/signal/SignalBinding.js";
|
|
4
4
|
import { FogOfWar } from "./FogOfWar.js";
|
|
5
|
-
import Team from "
|
|
5
|
+
import Team from "../team/Team.js";
|
|
6
6
|
import { Transform } from "../transform/Transform.js";
|
|
7
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
8
7
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
8
|
+
import { obtainTerrain } from "../terrain/util/obtainTerrain.js";
|
|
9
9
|
|
|
10
10
|
const v2 = new Vector2();
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Sampler2D } from '../../graphics/texture/sampler/Sampler2D.js';
|
|
6
6
|
import NormalMapShader from '../../graphics/shaders/NormalMapShader2.js';
|
|
7
7
|
import ImageFilter from '../../graphics/filter/ImageFilter.js';
|
|
8
|
-
import { sampler2DtoFloat32Texture } from "
|
|
8
|
+
import { sampler2DtoFloat32Texture } from "../../graphics/texture/sampler/sampler2DToFloat32Texture.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
function convertChannel(v) {
|
|
@@ -9,7 +9,7 @@ import sampler2D2Texture from '../../graphics/texture/sampler/Sampler2D2Texture.
|
|
|
9
9
|
import AmbientOcclusionShader from '../../graphics/shaders/AmbientOcclusionShader.js';
|
|
10
10
|
import GaussianBlurShader from '../../graphics/shaders/GaussianBlurShader.js';
|
|
11
11
|
import ImageFilter from '../../graphics/filter/ImageFilter.js';
|
|
12
|
-
import { sampler2DtoFloat32Texture } from "
|
|
12
|
+
import { sampler2DtoFloat32Texture } from "../../graphics/texture/sampler/sampler2DToFloat32Texture.js";
|
|
13
13
|
|
|
14
14
|
function filterResult2Texture(data, width, height) {
|
|
15
15
|
const result = new DataTexture();
|
|
@@ -5,7 +5,6 @@ import { System } from '../../System.js';
|
|
|
5
5
|
import ViewportPosition from './ViewportPosition.js';
|
|
6
6
|
import GUIElement from "../GUIElement.js";
|
|
7
7
|
import { assert } from "../../../../core/assert.js";
|
|
8
|
-
import Vector2 from "../../../../core/geom/Vector2.js";
|
|
9
8
|
import { SignalBinding } from "../../../../core/events/signal/SignalBinding.js";
|
|
10
9
|
import { EPSILON } from "../../../../core/math/MathUtils.js";
|
|
11
10
|
import AABB2 from "../../../../core/geom/AABB2.js";
|
|
@@ -202,8 +201,9 @@ function setElementPosition(view, bounds, viewportSize, vp) {
|
|
|
202
201
|
if (vp.stickToScreenEdge) {
|
|
203
202
|
|
|
204
203
|
|
|
205
|
-
const
|
|
206
|
-
const
|
|
204
|
+
const screenEdgeWidth = vp.screenEdgeWidth;
|
|
205
|
+
const clipEdgeX = screenEdgeWidth / viewportSize.x;
|
|
206
|
+
const clipEdgeY = screenEdgeWidth / viewportSize.y;
|
|
207
207
|
|
|
208
208
|
|
|
209
209
|
stickyBounds.set(clipEdgeX, clipEdgeY, 1 - clipEdgeX, 1 - clipEdgeY);
|
|
@@ -241,8 +241,8 @@ function setElementPosition(view, bounds, viewportSize, vp) {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
|
|
244
|
-
const targetX =
|
|
245
|
-
const targetY =
|
|
244
|
+
const targetX = x * (viewportSize.x);
|
|
245
|
+
const targetY = y * (viewportSize.y);
|
|
246
246
|
|
|
247
247
|
const viewPosition = view.position;
|
|
248
248
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import EntityBuilder from "../EntityBuilder";
|
|
2
|
+
import {EntityComponentDataset} from "../EntityComponentDataset";
|
|
3
|
+
import {Transform} from "../transform/Transform";
|
|
4
|
+
|
|
5
|
+
export class EntityNode {
|
|
6
|
+
constructor(entity?: EntityBuilder)
|
|
7
|
+
|
|
8
|
+
parent: EntityNode | null
|
|
9
|
+
entity: EntityBuilder
|
|
10
|
+
|
|
11
|
+
transform: Transform
|
|
12
|
+
|
|
13
|
+
addChild(node: EntityNode): boolean
|
|
14
|
+
|
|
15
|
+
removeChild(node: EntityNode): boolean
|
|
16
|
+
|
|
17
|
+
build(ecd: EntityComponentDataset): void
|
|
18
|
+
|
|
19
|
+
destroy(): void
|
|
20
|
+
}
|