@woosh/meep-engine 2.33.61 → 2.33.62
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/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 +1 -1
- package/editor/tools/paint/TerrainPaintTool.js +1 -1
- package/editor/tools/paint/TerrainTexturePaintTool.js +1 -1
- package/editor/view/EditorView.js +1 -1
- package/editor/view/GridPickCoordinateView.js +1 -1
- package/engine/ecs/animation/InverseKinematicsSystem.js +1 -1
- package/engine/ecs/evaluation/world/ReadTerrainLayerWeightPointFitness.js +1 -1
- package/engine/ecs/fow/FogOfWarRevealerSystem.js +1 -1
- package/engine/ecs/terrain/ecs/ClingToTerrainSystem.js +2 -2
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +112 -0
- package/engine/ecs/terrain/util/obtainTerrain.js +23 -0
- package/engine/graphics/ecs/camera/topdown/TopDownCameraLanderSystem.js +1 -1
- package/engine/graphics/ecs/water/WaterSystem.js +1 -1
- package/engine/graphics/ecs/water2/shader/testWaterShader.js +1 -1
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/engine/graphics/render/webgpu/sample/MeshInstance.js +87 -0
- package/engine/graphics/render/webgpu/sample/fragmentDeferredRendering.wgsl +7 -3
- package/engine/graphics/render/webgpu/sample/fragmentGBuffersDebugView.wgsl +4 -3
- package/engine/graphics/render/webgpu/sample/lightUpdate.wgsl +13 -6
- package/engine/graphics/render/webgpu/sample/main.js +82 -44
- package/engine/graphics/render/webgpu/sample/vertexWriteGBuffers.wgsl +5 -3
- 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 +1 -1
- package/view/minimap/Minimap.js +1 -1
- package/engine/graphics/render/webgpu/sample/_main.ts +0 -650
|
@@ -5,62 +5,95 @@ import fragmentWriteGBuffers from './fragmentWriteGBuffers.wgsl';
|
|
|
5
5
|
import vertexTextureQuad from './vertexTextureQuad.wgsl';
|
|
6
6
|
import fragmentGBuffersDebugView from './fragmentGBuffersDebugView.wgsl';
|
|
7
7
|
import fragmentDeferredRendering from './fragmentDeferredRendering.wgsl';
|
|
8
|
-
import
|
|
8
|
+
import dat from "dat.gui";
|
|
9
|
+
import { PLYLoader } from "three/examples/jsm/loaders/PLYLoader.js";
|
|
10
|
+
import { noop } from "../../../../../core/function/Functions.js";
|
|
11
|
+
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js";
|
|
12
|
+
import { MeshInstance } from "./MeshInstance.js";
|
|
9
13
|
|
|
10
14
|
const kMaxNumLights = 1024;
|
|
11
15
|
const lightExtentMin = vec3.fromValues(-50, -30, -50);
|
|
12
16
|
const lightExtentMax = vec3.fromValues(50, 50, 50);
|
|
13
|
-
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {string} path
|
|
21
|
+
* @return {Promise<THREE.BufferGeometry>}
|
|
22
|
+
*/
|
|
23
|
+
function load_geometry(path) {
|
|
24
|
+
const loader = new PLYLoader();
|
|
25
|
+
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
|
|
28
|
+
loader.load(path, resolve, noop, reject);
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function load_geometry_gltf(path) {
|
|
33
|
+
const loader = new GLTFLoader();
|
|
34
|
+
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
loader.load(path, (gltf) => {
|
|
37
|
+
let r = null;
|
|
38
|
+
|
|
39
|
+
gltf.scene.traverse(o => {
|
|
40
|
+
if (o.isMesh) {
|
|
41
|
+
r = o.geometry;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
resolve(r);
|
|
46
|
+
|
|
47
|
+
}, noop, reject);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
14
50
|
|
|
15
51
|
const init = async ({ canvasRef, gui }) => {
|
|
52
|
+
|
|
53
|
+
// const mesh = await load_geometry("data/models/stanford/dragon_recon/dragon_vrip.ply");
|
|
54
|
+
const mesh = await load_geometry_gltf("data/models/stanford/DragonAttenuation.glb");
|
|
55
|
+
|
|
56
|
+
|
|
16
57
|
const adapter = await navigator.gpu.requestAdapter();
|
|
17
58
|
const device = await adapter.requestDevice();
|
|
18
|
-
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* @type {HTMLCanvasElement}
|
|
63
|
+
*/
|
|
64
|
+
const canvas = canvasRef.current;
|
|
65
|
+
|
|
66
|
+
if (canvas === null) {
|
|
19
67
|
return;
|
|
20
|
-
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
*
|
|
72
|
+
* @type {GPUCanvasContext}
|
|
73
|
+
*/
|
|
74
|
+
const context = canvas.getContext('webgpu');
|
|
75
|
+
|
|
21
76
|
const devicePixelRatio = window.devicePixelRatio || 1;
|
|
77
|
+
|
|
22
78
|
const presentationSize = [
|
|
23
|
-
|
|
24
|
-
|
|
79
|
+
canvas.clientWidth * devicePixelRatio,
|
|
80
|
+
canvas.clientHeight * devicePixelRatio,
|
|
25
81
|
];
|
|
82
|
+
|
|
26
83
|
const aspect = presentationSize[0] / presentationSize[1];
|
|
84
|
+
|
|
27
85
|
const presentationFormat = context.getPreferredFormat(adapter);
|
|
86
|
+
|
|
28
87
|
context.configure({
|
|
29
88
|
device,
|
|
30
89
|
format: presentationFormat,
|
|
31
90
|
size: presentationSize,
|
|
32
91
|
});
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
usage: GPUBufferUsage.VERTEX,
|
|
39
|
-
mappedAtCreation: true,
|
|
40
|
-
});
|
|
41
|
-
{
|
|
42
|
-
const mapping = new Float32Array(vertexBuffer.getMappedRange());
|
|
43
|
-
for (let i = 0; i < mesh.positions.length; ++i) {
|
|
44
|
-
mapping.set(mesh.positions[i], kVertexStride * i);
|
|
45
|
-
mapping.set(mesh.normals[i], kVertexStride * i + 3);
|
|
46
|
-
mapping.set(mesh.uvs[i], kVertexStride * i + 6);
|
|
47
|
-
}
|
|
48
|
-
vertexBuffer.unmap();
|
|
49
|
-
}
|
|
50
|
-
// Create the model index buffer.
|
|
51
|
-
const indexCount = mesh.triangles.length * 3;
|
|
52
|
-
const indexBuffer = device.createBuffer({
|
|
53
|
-
size: indexCount * Uint16Array.BYTES_PER_ELEMENT,
|
|
54
|
-
usage: GPUBufferUsage.INDEX,
|
|
55
|
-
mappedAtCreation: true,
|
|
56
|
-
});
|
|
57
|
-
{
|
|
58
|
-
const mapping = new Uint16Array(indexBuffer.getMappedRange());
|
|
59
|
-
for (let i = 0; i < mesh.triangles.length; ++i) {
|
|
60
|
-
mapping.set(mesh.triangles[i], 3 * i);
|
|
61
|
-
}
|
|
62
|
-
indexBuffer.unmap();
|
|
63
|
-
}
|
|
92
|
+
|
|
93
|
+
const m_instance = new MeshInstance();
|
|
94
|
+
m_instance.geometry = mesh;
|
|
95
|
+
m_instance.init(device);
|
|
96
|
+
|
|
64
97
|
// GBuffer texture render targets
|
|
65
98
|
const gBufferTexture2DFloat = device.createTexture({
|
|
66
99
|
size: [...presentationSize, 3],
|
|
@@ -486,7 +519,7 @@ const init = async ({ canvasRef, gui }) => {
|
|
|
486
519
|
|
|
487
520
|
// Rotates the camera around the origin based on time.
|
|
488
521
|
function getCameraViewProjMatrix() {
|
|
489
|
-
const eyePosition = vec3.fromValues(0, 50, -
|
|
522
|
+
const eyePosition = vec3.fromValues(0, 50, -10);
|
|
490
523
|
const rad = Math.PI * (Date.now() / 5000);
|
|
491
524
|
vec3.rotateY(eyePosition, eyePosition, origin, rad);
|
|
492
525
|
const viewMatrix = mat4.create();
|
|
@@ -497,7 +530,7 @@ const init = async ({ canvasRef, gui }) => {
|
|
|
497
530
|
|
|
498
531
|
function frame() {
|
|
499
532
|
// Sample is no longer the active page.
|
|
500
|
-
if (!
|
|
533
|
+
if (!canvas)
|
|
501
534
|
return;
|
|
502
535
|
const cameraViewProj = getCameraViewProjMatrix();
|
|
503
536
|
device.queue.writeBuffer(cameraUniformBuffer, 0, cameraViewProj.buffer, cameraViewProj.byteOffset, cameraViewProj.byteLength);
|
|
@@ -507,9 +540,9 @@ const init = async ({ canvasRef, gui }) => {
|
|
|
507
540
|
const gBufferPass = commandEncoder.beginRenderPass(writeGBufferPassDescriptor);
|
|
508
541
|
gBufferPass.setPipeline(writeGBuffersPipeline);
|
|
509
542
|
gBufferPass.setBindGroup(0, sceneUniformBindGroup);
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
543
|
+
|
|
544
|
+
m_instance.draw(gBufferPass);
|
|
545
|
+
|
|
513
546
|
gBufferPass.endPass();
|
|
514
547
|
}
|
|
515
548
|
{
|
|
@@ -557,10 +590,15 @@ const init = async ({ canvasRef, gui }) => {
|
|
|
557
590
|
};
|
|
558
591
|
|
|
559
592
|
const canvas_el = document.createElement('canvas');
|
|
593
|
+
canvas_el.width = window.innerWidth;
|
|
594
|
+
canvas_el.height = window.innerHeight;
|
|
560
595
|
|
|
596
|
+
document.body.appendChild(canvas_el);
|
|
597
|
+
|
|
598
|
+
const gui = new dat.GUI();
|
|
561
599
|
init({
|
|
562
600
|
canvasRef: {
|
|
563
601
|
current: canvas_el,
|
|
564
|
-
|
|
565
|
-
|
|
602
|
+
},
|
|
603
|
+
gui: gui
|
|
566
604
|
});
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
struct Uniforms {
|
|
2
2
|
modelMatrix : mat4x4<f32>;
|
|
3
3
|
normalModelMatrix : mat4x4<f32>;
|
|
4
4
|
};
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
struct Camera {
|
|
6
7
|
viewProjectionMatrix : mat4x4<f32>;
|
|
7
8
|
};
|
|
9
|
+
|
|
8
10
|
[[group(0), binding(0)]] var<uniform> uniforms : Uniforms;
|
|
9
11
|
[[group(0), binding(1)]] var<uniform> camera : Camera;
|
|
10
12
|
|
|
@@ -25,4 +27,4 @@ fn main([[location(0)]] position : vec3<f32>,
|
|
|
25
27
|
output.fragNormal = normalize((uniforms.normalModelMatrix * vec4<f32>(normal, 1.0)).xyz);
|
|
26
28
|
output.fragUV = uv;
|
|
27
29
|
return output;
|
|
28
|
-
}
|
|
30
|
+
}
|
|
@@ -6,8 +6,8 @@ import { Transform } from '../../ecs/transform/Transform.js';
|
|
|
6
6
|
import GridPosition from '../components/GridPosition.js';
|
|
7
7
|
import { GridPosition2Transform } from '../components/GridPosition2Transform.js';
|
|
8
8
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
9
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
10
9
|
import { GridPosition2TransformFlags } from "../components/GridPosition2TransformFlags.js";
|
|
10
|
+
import { obtainTerrain } from "../../ecs/terrain/util/obtainTerrain.js";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
export class GridPosition2TransformSystem extends System {
|
|
@@ -5,9 +5,9 @@ import { System } from '../../ecs/System.js';
|
|
|
5
5
|
import GeometryBVH from '../../ecs/components/GeometryBVH.js';
|
|
6
6
|
import GridPosition from '../components/GridPosition.js';
|
|
7
7
|
import ViewportGridProjection from '../components/ViewportGridProjection.js';
|
|
8
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
9
8
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
10
9
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
10
|
+
import { obtainTerrain } from "../../ecs/terrain/util/obtainTerrain.js";
|
|
11
11
|
|
|
12
12
|
class ViewportGridProjectionSystem extends System {
|
|
13
13
|
constructor(grid, graphicsEngine) {
|
|
@@ -2,9 +2,9 @@ import { System } from "../../ecs/System.js";
|
|
|
2
2
|
import { Transform2GridPosition } from "./Transform2GridPosition.js";
|
|
3
3
|
import GridPosition from "../components/GridPosition.js";
|
|
4
4
|
import { Transform } from "../../ecs/transform/Transform.js";
|
|
5
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
6
5
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
7
6
|
import { Transform2GridPositionMode } from "./Transform2GridPositionMode.js";
|
|
7
|
+
import { obtainTerrain } from "../../ecs/terrain/util/obtainTerrain.js";
|
|
8
8
|
|
|
9
9
|
const v2 = new Vector2();
|
|
10
10
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { actionTask, delayTask, wrapTaskIgnoreFailure } from "../../core/process/task/TaskUtils.js";
|
|
2
|
-
import { loadVisibleTerrainTiles } from "../../../model/game/scenes/SceneUtils.js";
|
|
3
2
|
import TaskGroup from "../../core/process/task/TaskGroup.js";
|
|
4
3
|
import Task from "../../core/process/task/Task.js";
|
|
5
4
|
import TaskState from "../../core/process/task/TaskState.js";
|
|
6
5
|
import { noop } from "../../core/function/Functions.js";
|
|
7
6
|
import { compileAllMaterials } from "../graphics/ecs/compileAllMaterials.js";
|
|
8
7
|
import { createTaskWaitForMeshesToLoad } from "../graphics/ecs/mesh/createTaskWaitForMeshesToLoad.js";
|
|
8
|
+
import { loadVisibleTerrainTiles } from "../ecs/terrain/util/loadVisibleTerrainTiles.js";
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -2,9 +2,9 @@ import { lerp } from "../../../core/math/lerp.js";
|
|
|
2
2
|
import { min2 } from "../../../core/math/min2.js";
|
|
3
3
|
import { ContinuousGridCellAction } from "./ContinuousGridCellAction.js";
|
|
4
4
|
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
5
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
6
5
|
import { assert } from "../../../core/assert.js";
|
|
7
6
|
import { CellFilterLiteralFloat } from "../../filtering/numeric/CellFilterLiteralFloat.js";
|
|
7
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
8
8
|
|
|
9
9
|
export class ContinuousGridCellActionSetTerrainHeight extends ContinuousGridCellAction {
|
|
10
10
|
constructor() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MarkerNodeEntityProcessor } from "./MarkerNodeEntityProcessor.js";
|
|
2
|
-
import { obtainTerrain } from "../../../../../model/game/scenes/SceneUtils.js";
|
|
3
2
|
import { SurfacePoint3 } from "../../../../core/geom/3d/SurfacePoint3.js";
|
|
4
3
|
import { alignToVector } from "../../../../engine/ecs/terrain/ecs/ClingToTerrainSystem.js";
|
|
4
|
+
import { obtainTerrain } from "../../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
5
5
|
|
|
6
6
|
const p = new SurfacePoint3();
|
|
7
7
|
|
|
@@ -11,13 +11,13 @@ import {
|
|
|
11
11
|
import EntityBuilder from "../../../engine/ecs/EntityBuilder.js";
|
|
12
12
|
import Renderable from "../../../engine/ecs/components/Renderable.js";
|
|
13
13
|
import { Transform } from "../../../engine/ecs/transform/Transform.js";
|
|
14
|
-
import { obtainTerrain } from "../../../../model/game/scenes/SceneUtils.js";
|
|
15
14
|
import LabelView from "../../../view/common/LabelView.js";
|
|
16
15
|
import GUIElement from "../../../engine/ecs/gui/GUIElement.js";
|
|
17
16
|
import ViewportPosition from "../../../engine/ecs/gui/position/ViewportPosition.js";
|
|
18
17
|
import HeadsUpDisplay from "../../../engine/ecs/gui/hud/HeadsUpDisplay.js";
|
|
19
18
|
import Vector3 from "../../../core/geom/Vector3.js";
|
|
20
19
|
import { MarkerNodeMatcherAny } from "../matcher/MarkerNodeMatcherAny.js";
|
|
20
|
+
import { obtainTerrain } from "../../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
21
21
|
|
|
22
22
|
function formatValue(v) {
|
|
23
23
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { QuadTreeNode } from "../../core/geom/2d/quad-tree/QuadTreeNode.js";
|
|
2
2
|
import { assert } from "../../core/assert.js";
|
|
3
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
4
3
|
import { seededRandom } from "../../core/math/random/seededRandom.js";
|
|
5
4
|
import { TerrainLayerRuleAggregator } from "./TerrainLayerRuleAggregator.js";
|
|
6
5
|
import { actionTask, countTask, emptyTask, futureTask } from "../../core/process/task/TaskUtils.js";
|
|
@@ -17,6 +16,7 @@ import { TerrainLayer } from "../../engine/ecs/terrain/ecs/layers/TerrainLayer.j
|
|
|
17
16
|
import { TerrainFlags } from "../../engine/ecs/terrain/ecs/TerrainFlags.js";
|
|
18
17
|
import { binarySearchLowIndex } from "../../core/collection/array/binarySearchLowIndex.js";
|
|
19
18
|
import { randomFloatBetween } from "../../core/math/random/randomFloatBetween.js";
|
|
19
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
*
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"productName": "Meep",
|
|
6
6
|
"description": "production-ready JavaScript game engine based on Entity Component System Architecture",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.33.
|
|
8
|
+
"version": "2.33.62",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|
package/samples/terrain/main.js
CHANGED
|
@@ -2,11 +2,11 @@ import { EngineConfiguration } from "../../engine/EngineConfiguration.js";
|
|
|
2
2
|
import { EngineHarness } from "../../engine/EngineHarness.js";
|
|
3
3
|
import { GameAssetType } from "../../engine/asset/GameAssetType.js";
|
|
4
4
|
import { TextureAssetLoader } from "../../engine/asset/loaders/texture/TextureAssetLoader.js";
|
|
5
|
-
import { obtainTerrain } from "../../../model/game/scenes/SceneUtils.js";
|
|
6
5
|
import { ImprovedNoise } from "three/examples/jsm/math/ImprovedNoise.js";
|
|
7
6
|
import { lerp } from "../../core/math/lerp.js";
|
|
8
7
|
import Vector2 from "../../core/geom/Vector2.js";
|
|
9
8
|
import Vector3 from "../../core/geom/Vector3.js";
|
|
9
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
10
10
|
|
|
11
11
|
const eh = new EngineHarness();
|
|
12
12
|
|
package/view/minimap/Minimap.js
CHANGED
|
@@ -19,7 +19,7 @@ import { MinimapWorldGL } from "./gl/MinimapWorldGL.js";
|
|
|
19
19
|
import { MinimapCameraView } from "./dom/MinimapCameraView.js";
|
|
20
20
|
import { MinimapFogOfWar } from "./gl/MinimapFogOfWar.js";
|
|
21
21
|
import { MinimapTerrainGL } from "./gl/MinimapTerrainGL.js";
|
|
22
|
-
import { obtainTerrain } from "
|
|
22
|
+
import { obtainTerrain } from "../../engine/ecs/terrain/util/obtainTerrain.js";
|
|
23
23
|
|
|
24
24
|
|
|
25
25
|
class MinimapView extends View {
|