@woosh/meep-engine 2.33.62 → 2.33.67
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/FilePath.js +28 -2
- package/core/binary/BinaryBuffer.js +13 -0
- package/core/geom/2d/quad-tree/QuadTreeNode.js +3 -2
- package/ecs/grid/pick.js +44 -0
- package/editor/tools/GridPaintTool.js +1 -1
- package/editor/tools/paint/TerrainPaintTool.js +1 -1
- package/editor/view/GridPickCoordinateView.js +1 -1
- package/engine/asset/AssetManager.js +1 -1
- package/engine/asset/AssetTransformer.js +2 -1
- package/engine/asset/loaders/GLTFAssetLoader.js +5 -21
- package/engine/asset/loaders/async_traverse_three_object.js +24 -0
- package/engine/ecs/attachment/AttachmentSystem.js +3 -51
- package/engine/ecs/fow/FogOfWarRevealerSystem.js +1 -1
- package/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js +2 -10
- package/engine/ecs/grid/NormalMap2AOMap.js +10 -13
- package/engine/ecs/team/Team.js +82 -0
- package/engine/ecs/terrain/ecs/BuildLightTexture.js +106 -0
- package/engine/ecs/terrain/ecs/PromiseSamplerHeight.js +59 -0
- package/engine/ecs/terrain/ecs/Terrain.js +14 -153
- package/engine/ecs/tooltip/TooltipComponentSystem.js +1 -1
- package/engine/graphics/FULL_SCREEN_QUAD_VERTEX_SHADER.js +10 -0
- package/engine/graphics/filter/ImageFilter.js +6 -2
- 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/micron/MICRON_GEOMETRY_FIELD.js +1 -0
- package/engine/graphics/micron/MICRON_URI_FIELD.js +1 -0
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +10 -7
- package/engine/graphics/micron/convert_three_object_to_micron.js +31 -5
- package/engine/graphics/micron/format/MicronGeometry.d.ts +4 -0
- package/engine/graphics/micron/format/MicronGeometry.js +6 -0
- package/engine/graphics/micron/plugin/MicronRenderPlugin.js +110 -6
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +4 -2
- package/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/engine/graphics/render/webgpu/sample/MeshInstance.js +21 -0
- package/engine/graphics/render/webgpu/sample/main.js +2 -2
- package/engine/graphics/shaders/AmbientOcclusionShader.js +57 -77
- package/engine/graphics/shaders/DenoiseShader.js +119 -0
- package/engine/graphics/texture/noise_octaves.js +33 -0
- package/engine/graphics/texture/sampler/Sampler2D2Texture.js +7 -18
- package/engine/graphics/texture/sampler/debug/paintSamplerOnHTML.js +8 -5
- package/engine/graphics/texture/sampler/sampler2DToFloat32Texture.js +10 -3
- package/engine/graphics/util/modelHitTest.js +63 -0
- package/generation/example/filters/SampleGroundMoistureFilter.js +2 -1
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +29 -13
- package/generation/grid/GridData.js +17 -2
- package/package.json +1 -1
|
@@ -10,20 +10,23 @@ import { typedArrayConstructorByInstance } from "../typedArrayConstructorByInsta
|
|
|
10
10
|
* @param {number} y
|
|
11
11
|
* @param scale
|
|
12
12
|
* @param offset
|
|
13
|
+
* @param {number} resolution
|
|
13
14
|
*/
|
|
14
|
-
export function paintSamplerOnHTML(s, x, y, scale, offset) {
|
|
15
|
+
export function paintSamplerOnHTML(s, x, y, scale, offset, resolution=256) {
|
|
15
16
|
|
|
16
|
-
const d =
|
|
17
|
+
const d = resolution;
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
+
const TA = typedArrayConstructorByInstance(s.data);
|
|
20
|
+
|
|
21
|
+
const target = new Sampler2D(new TA(d * d * s.itemSize), s.itemSize, d, d);
|
|
19
22
|
|
|
20
23
|
scaleSampler2D(s, target);
|
|
21
24
|
|
|
22
25
|
const c = convertSampler2D2Canvas(target, scale, offset);
|
|
23
26
|
c.style.zIndex = 1000;
|
|
24
27
|
c.style.position = "absolute";
|
|
25
|
-
c.style.left = `${x
|
|
26
|
-
c.style.top = `${y
|
|
28
|
+
c.style.left = `${x}px`;
|
|
29
|
+
c.style.top = `${y}px`;
|
|
27
30
|
|
|
28
31
|
document.body.appendChild(c);
|
|
29
32
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import { ClampToEdgeWrapping, DataTexture, FloatType, LinearFilter, NearestFilter
|
|
1
|
+
import { ClampToEdgeWrapping, DataTexture, FloatType, LinearFilter, NearestFilter } from "three";
|
|
2
2
|
import { assert } from "../../../../core/assert.js";
|
|
3
|
+
import { channelCountToThreeTextureFormat } from "../channelCountToThreeTextureFormat.js";
|
|
4
|
+
import { computeThreeTextureInternalFormatFromDataType } from "../../render/forward_plus/data/computeThreeTextureInternalFormatFromDataType.js";
|
|
5
|
+
import { DataType } from "../../../../core/collection/table/DataType.js";
|
|
3
6
|
|
|
4
7
|
/**
|
|
5
8
|
*
|
|
@@ -12,7 +15,7 @@ export function sampler2DtoFloat32Texture(sampler) {
|
|
|
12
15
|
const width = sampler.width;
|
|
13
16
|
const height = sampler.height;
|
|
14
17
|
|
|
15
|
-
const texture = new DataTexture(sampler.data, width, height
|
|
18
|
+
const texture = new DataTexture(sampler.data, width, height);
|
|
16
19
|
|
|
17
20
|
texture.wrapS = ClampToEdgeWrapping;
|
|
18
21
|
texture.wrapT = ClampToEdgeWrapping;
|
|
@@ -24,7 +27,11 @@ export function sampler2DtoFloat32Texture(sampler) {
|
|
|
24
27
|
|
|
25
28
|
texture.flipY = false;
|
|
26
29
|
|
|
27
|
-
texture.
|
|
30
|
+
texture.type = FloatType;
|
|
31
|
+
texture.format = channelCountToThreeTextureFormat(sampler.itemSize);
|
|
32
|
+
texture.internalFormat = computeThreeTextureInternalFormatFromDataType(DataType.Float32, sampler.itemSize);
|
|
33
|
+
|
|
34
|
+
texture.needsUpdate = true;
|
|
28
35
|
|
|
29
36
|
return texture;
|
|
30
37
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import Vector2 from "../../../core/geom/Vector2.js";
|
|
2
|
+
import Mesh from "../ecs/mesh/Mesh.js";
|
|
3
|
+
|
|
4
|
+
const tempPoint = new Vector2();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {SurfacePoint3} result
|
|
9
|
+
* @param {Array.<Number>} entities
|
|
10
|
+
* @param {EntityComponentDataset} ecd
|
|
11
|
+
* @param {GraphicsEngine} ge
|
|
12
|
+
* @param {Number} x
|
|
13
|
+
* @param {Number} y
|
|
14
|
+
* @returns {Number} entity number or -1 in case of failed test
|
|
15
|
+
*/
|
|
16
|
+
function modelHitTest(result, entities, ecd, ge, x, y) {
|
|
17
|
+
tempPoint.set(x, y);
|
|
18
|
+
|
|
19
|
+
ge.normalizeViewportPoint(tempPoint, tempPoint);
|
|
20
|
+
|
|
21
|
+
let i = 0;
|
|
22
|
+
const l = entities.length;
|
|
23
|
+
|
|
24
|
+
for (; i < l; i++) {
|
|
25
|
+
|
|
26
|
+
const entity = entities[i];
|
|
27
|
+
|
|
28
|
+
const model = ecd.getComponent(entity, Mesh);
|
|
29
|
+
|
|
30
|
+
if (model === null) {
|
|
31
|
+
//entity no longer exists most likely
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @type {Intersection[]}
|
|
38
|
+
*/
|
|
39
|
+
const hits = ge.intersectObjectUnderViewportPoint(tempPoint.x, tempPoint.y, model.mesh, true);
|
|
40
|
+
|
|
41
|
+
// get hit
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if (hits.length > 0) {
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @type {Intersection}
|
|
48
|
+
*/
|
|
49
|
+
const hit = hits[0];
|
|
50
|
+
|
|
51
|
+
result.position.copy(hit.point);
|
|
52
|
+
|
|
53
|
+
//TODO extract normal
|
|
54
|
+
|
|
55
|
+
return entity;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export { modelHitTest };
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { CellFilter } from "../../CellFilter.js";
|
|
2
2
|
import { gaussian } from "../../../../core/math/gaussian.js";
|
|
3
|
-
|
|
3
|
+
import { max2 } from "../../../../core/math/max2.js";
|
|
4
|
+
import { assert } from "../../../../core/assert.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @param {number[]} result
|
|
9
|
+
* @param {number} samplesX
|
|
10
|
+
* @param {number} samplesY
|
|
11
|
+
* @param {number} sigma_x
|
|
12
|
+
* @param {number} sigma_y
|
|
13
|
+
* @return {number}
|
|
14
|
+
*/
|
|
4
15
|
function buildKernel(result, samplesX, samplesY, sigma_x, sigma_y) {
|
|
5
|
-
|
|
6
|
-
|
|
16
|
+
assert.isNonNegativeInteger(samplesX, 'samplesX');
|
|
17
|
+
assert.isNonNegativeInteger(samplesY, 'samplesY');
|
|
18
|
+
|
|
19
|
+
const half_samples_x = samplesX * 0.5;
|
|
20
|
+
const half_samples_y = samplesY * 0.5;
|
|
7
21
|
|
|
8
22
|
let powerTotal = 0;
|
|
9
23
|
let ix, iy;
|
|
@@ -70,6 +84,8 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
70
84
|
if (!this.source.initialized) {
|
|
71
85
|
this.source.initialize(grid, seed);
|
|
72
86
|
|
|
87
|
+
this.__kernel = new Float32Array(this.samples_x * this.samples_y);
|
|
88
|
+
|
|
73
89
|
// initialize kernel
|
|
74
90
|
this.__kernel_total_power = buildKernel(this.__kernel, this.samples_x, this.samples_y, this.sigma_x, this.sigma_y);
|
|
75
91
|
}
|
|
@@ -84,13 +100,13 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
84
100
|
* @param {number} quality
|
|
85
101
|
* @returns {CellFilterGaussianBlur}
|
|
86
102
|
*/
|
|
87
|
-
static from(source, x, y, quality =
|
|
103
|
+
static from(source, x, y, quality = 3) {
|
|
88
104
|
const r = new CellFilterGaussianBlur();
|
|
89
105
|
|
|
90
106
|
r.source = source;
|
|
91
107
|
|
|
92
|
-
r.samples_x = quality * x;
|
|
93
|
-
r.samples_y = quality * y;
|
|
108
|
+
r.samples_x = max2(2, Math.round(quality * x));
|
|
109
|
+
r.samples_y = max2(2, Math.round(quality * y));
|
|
94
110
|
|
|
95
111
|
r.size_x = x;
|
|
96
112
|
r.size_y = y;
|
|
@@ -102,24 +118,24 @@ export class CellFilterGaussianBlur extends CellFilter {
|
|
|
102
118
|
const samplesX = this.samples_x;
|
|
103
119
|
const samplesY = this.samples_y;
|
|
104
120
|
|
|
105
|
-
const half_samples_x = (samplesX
|
|
106
|
-
const half_samples_y = (samplesY
|
|
121
|
+
const half_samples_x = (samplesX - 1) * 0.5;
|
|
122
|
+
const half_samples_y = (samplesY - 1) * 0.5;
|
|
107
123
|
|
|
108
124
|
const sizeX = this.size_x;
|
|
109
125
|
const sizeY = this.size_y;
|
|
110
126
|
|
|
111
|
-
const local_u_scale = 1 / samplesX;
|
|
112
|
-
const local_v_scale = 1 / samplesY;
|
|
127
|
+
const local_u_scale = 1 / (samplesX - 1);
|
|
128
|
+
const local_v_scale = 1 / (samplesY - 1);
|
|
113
129
|
|
|
114
130
|
let sum = 0;
|
|
115
|
-
let ix, iy;
|
|
131
|
+
let ix, iy = 0;
|
|
116
132
|
|
|
117
133
|
const source = this.source;
|
|
118
134
|
const kernel = this.__kernel;
|
|
119
135
|
|
|
120
|
-
const i_samples_x = samplesX|0;
|
|
136
|
+
const i_samples_x = samplesX | 0;
|
|
121
137
|
|
|
122
|
-
for (
|
|
138
|
+
for (; iy < samplesY; iy++) {
|
|
123
139
|
const local_y = iy - half_samples_y;
|
|
124
140
|
|
|
125
141
|
const ny = local_y * local_v_scale;
|
|
@@ -2,6 +2,7 @@ import { assert } from "../../core/assert.js";
|
|
|
2
2
|
import { QuadTreeNode } from "../../core/geom/2d/quad-tree/QuadTreeNode.js";
|
|
3
3
|
import { OffsetScaleTransform2D } from "../../engine/ecs/terrain/ecs/OffsetScaleTransform2D.js";
|
|
4
4
|
import { MarkerMatchCounter } from "./MarkerMatchCounter.js";
|
|
5
|
+
import { max2 } from "../../core/math/max2.js";
|
|
5
6
|
|
|
6
7
|
const scratch_match_counter = new MarkerMatchCounter();
|
|
7
8
|
|
|
@@ -167,8 +168,14 @@ export class GridData {
|
|
|
167
168
|
* @param {number} height
|
|
168
169
|
*/
|
|
169
170
|
resize(width, height) {
|
|
170
|
-
assert.
|
|
171
|
-
assert.
|
|
171
|
+
assert.isNumber(width, 'width');
|
|
172
|
+
assert.isNumber(height, 'height');
|
|
173
|
+
|
|
174
|
+
assert.isNonNegativeInteger(width,'width');
|
|
175
|
+
assert.isNonNegativeInteger(height,'height');
|
|
176
|
+
|
|
177
|
+
assert.isFiniteNumber(width, 'width');
|
|
178
|
+
assert.isFiniteNumber(height, 'width');
|
|
172
179
|
|
|
173
180
|
if (width === this.width && height === this.height) {
|
|
174
181
|
//no need, already the right size
|
|
@@ -187,6 +194,14 @@ export class GridData {
|
|
|
187
194
|
|
|
188
195
|
layer.resize(width, height);
|
|
189
196
|
}
|
|
197
|
+
|
|
198
|
+
// resize the quad tree pre-emptively, to avoid expensive re-balancing operations later on
|
|
199
|
+
this.markers.resize(
|
|
200
|
+
-max2(1, width * 0.5),
|
|
201
|
+
-max2(1, height * 0.5),
|
|
202
|
+
max2(width + 1, width * 1.5),
|
|
203
|
+
max2(height + 1, height * 1.5)
|
|
204
|
+
);
|
|
190
205
|
}
|
|
191
206
|
|
|
192
207
|
/**
|
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.67",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|