@woosh/meep-engine 2.34.49 → 2.35.2
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/bvh2/BinaryNode.js +19 -35
- package/core/bvh2/aabb3/aabb3_intersects_frustum_array.js +5 -5
- package/core/bvh2/aabb3/aabb3_intersects_frustum_degree.js +6 -6
- package/core/bvh2/aabb3_combined_surface_area.js +21 -0
- package/core/bvh2/traversal/queryBinaryNode_CollectData.js +1 -2
- package/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +42 -17
- package/core/cache/Cache.d.ts +2 -0
- package/core/cache/Cache.js +27 -23
- package/core/collection/HashMap.js +1 -1
- package/core/geom/3d/frustum/frustum_from_projection_matrix_array.js +2 -0
- package/core/math/max2.js +2 -6
- package/core/math/min2.js +2 -6
- package/engine/asset/loaders/geometry/geometry/computeGeometryEquality.js +1 -1
- package/engine/asset/loaders/geometry/geometry/computeGeometryHash.js +9 -1
- package/engine/ecs/EntityComponentDataset.js +7 -2
- package/engine/ecs/foliage/ViewState.js +13 -3
- package/engine/ecs/parent/EntityNode.js +23 -11
- package/engine/ecs/transform/Transform.js +15 -13
- package/engine/graphics/ecs/highlight/system/ShadedGeometryHighlightSystem.js +13 -4
- package/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +46 -108
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +72 -10
- package/engine/graphics/ecs/mesh-v2/build_three_object.js +39 -0
- package/engine/graphics/ecs/mesh-v2/render/AbstractRenderAdapter.js +67 -0
- package/engine/graphics/ecs/mesh-v2/render/GenericRendererAdapter.js +48 -0
- package/engine/graphics/ecs/mesh-v2/render/InstancedRendererAdapter.js +158 -0
- package/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +98 -0
- package/engine/graphics/ecs/mesh-v2/sample/load_gltf.js +5 -0
- package/engine/graphics/ecs/mesh-v2/sample/prototypeShadedGeometry.js +37 -10
- package/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +8 -3
- package/engine/graphics/geometry/instancing/InstancedMeshGroup.js +29 -82
- package/engine/graphics/geometry/instancing/rewriteMaterial.js +9 -45
- package/engine/graphics/material/optimization/BUFFER_GEOMETRY_UVS.js +10 -0
- package/engine/graphics/material/optimization/MaterialDescriptor.js +46 -0
- package/engine/graphics/material/optimization/MaterialOptimizationContext.js +470 -201
- package/engine/graphics/material/optimization/UvContext.js +18 -0
- package/engine/graphics/material/optimization/is_compliant_mesh.js +71 -0
- package/engine/graphics/material/optimization/prepare_atlas_texture.js +23 -0
- package/engine/graphics/material/optimization/prototypeMaterialOptimizer.js +127 -0
- package/engine/graphics/micron/format/MicronGeometryPatch.js +1 -1
- package/engine/graphics/micron/format/VirtualGeometry.js +47 -11
- package/engine/graphics/micron/format/serialization/MicronGeometryBinarySerializationAdapter.js +16 -0
- package/engine/graphics/micron/prototypeVirtualGeometry.js +3 -2
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +5 -7
- package/engine/graphics/micron/render/instanced/AttributeDataTexture.js +1 -45
- package/engine/graphics/micron/render/instanced/ThreeInstancedAdapter.js +18 -7
- package/engine/graphics/micron/render/refinement/RefinementSpec.js +0 -1
- package/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +17 -24
- package/engine/graphics/micron/render/v1/MaterialContext.js +3 -2
- package/engine/graphics/micron/render/v1/VGThreeRenderer.js +20 -4
- package/engine/graphics/render/utils/ThreeBypassRenderer.js +3 -2
- package/engine/graphics/render/visibility/IncrementalDeltaSet.js +1 -0
- package/engine/graphics/texture/normalized_internal_format.js +48 -0
- package/engine/graphics/texture/sampler/Sampler2D.js +6 -0
- package/engine/graphics/texture/sampler/sampler2d_copy_channel_data.js +25 -0
- package/engine/graphics/texture/sampler/scaleSampler2D.js +3 -0
- package/engine/graphics/texture/sampler/util/drawSamplerHTML.js +14 -1
- package/package.json +1 -1
|
@@ -16,6 +16,7 @@ const scratch_mvc = new MaterialVertexSpec();
|
|
|
16
16
|
export class VGThreeRenderer {
|
|
17
17
|
constructor() {
|
|
18
18
|
this.geometry = new VirtualGeometry();
|
|
19
|
+
|
|
19
20
|
this.builder = new VirtualGeometryBuilder();
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -158,6 +159,10 @@ export class VGThreeRenderer {
|
|
|
158
159
|
const contexts = this.__contexts_array;
|
|
159
160
|
const context_count = contexts.length;
|
|
160
161
|
|
|
162
|
+
/**
|
|
163
|
+
*
|
|
164
|
+
* @type {Map<number, MaterialContext>}
|
|
165
|
+
*/
|
|
161
166
|
const instance_to_ctx = new Map();
|
|
162
167
|
|
|
163
168
|
for (let i = 0; i < context_count; i++) {
|
|
@@ -175,18 +180,29 @@ export class VGThreeRenderer {
|
|
|
175
180
|
const patches = geometry.patches;
|
|
176
181
|
|
|
177
182
|
for (let i = 0; i < patch_count; i++) {
|
|
178
|
-
const
|
|
183
|
+
const i3 = i * 3;
|
|
184
|
+
|
|
185
|
+
const instance_id = patches[i3];
|
|
186
|
+
const geometry_id = patches[i3 + 1];
|
|
187
|
+
const patch_id = patches[i3 + 2];
|
|
188
|
+
|
|
189
|
+
const ctx = instance_to_ctx.get(instance_id);
|
|
190
|
+
|
|
191
|
+
const target_address = ctx.__patch_count * 3;
|
|
192
|
+
ctx.__patch_count++;
|
|
179
193
|
|
|
180
|
-
const
|
|
194
|
+
const ctx_patches = ctx.__patches;
|
|
181
195
|
|
|
182
|
-
|
|
196
|
+
ctx_patches[target_address] = instance_id;
|
|
197
|
+
ctx_patches[target_address + 1] = geometry_id;
|
|
198
|
+
ctx_patches[target_address + 2] = patch_id;
|
|
183
199
|
}
|
|
184
200
|
|
|
185
201
|
// build each context
|
|
186
202
|
for (let i = 0; i < context_count; i++) {
|
|
187
203
|
const ctx = contexts[i];
|
|
188
204
|
|
|
189
|
-
ctx.build();
|
|
205
|
+
ctx.build(this.geometry);
|
|
190
206
|
}
|
|
191
207
|
}
|
|
192
208
|
|
|
@@ -72,8 +72,9 @@ export class ThreeBypassRenderer {
|
|
|
72
72
|
|
|
73
73
|
let stack_top = 0;
|
|
74
74
|
let j = 0;
|
|
75
|
+
let i = 0;
|
|
75
76
|
|
|
76
|
-
for (
|
|
77
|
+
for (; i < input_size; i++) {
|
|
77
78
|
const object3D = input[i];
|
|
78
79
|
|
|
79
80
|
if (input_filter(object3D)) {
|
|
@@ -119,7 +120,7 @@ export class ThreeBypassRenderer {
|
|
|
119
120
|
const children = object3D.children;
|
|
120
121
|
const child_count = children.length;
|
|
121
122
|
|
|
122
|
-
for (
|
|
123
|
+
for (i = 0; i < child_count; i++) {
|
|
123
124
|
const child = children[i];
|
|
124
125
|
|
|
125
126
|
stack[stack_top++] = child;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { DataType } from "../../../core/collection/table/DataType.js";
|
|
2
|
+
import { assert } from "../../../core/assert.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @returns {string}
|
|
7
|
+
* @param {DataType} dt
|
|
8
|
+
* @param {number} channel_count
|
|
9
|
+
*/
|
|
10
|
+
export function normalized_internal_format(dt, channel_count) {
|
|
11
|
+
assert.isNonNegativeInteger(channel_count, 'channel_count');
|
|
12
|
+
|
|
13
|
+
let suffix = '';
|
|
14
|
+
switch (dt) {
|
|
15
|
+
case DataType.Uint8:
|
|
16
|
+
suffix = '8';
|
|
17
|
+
break;
|
|
18
|
+
case DataType.Int8:
|
|
19
|
+
suffix = '8_SNORM';
|
|
20
|
+
break;
|
|
21
|
+
case DataType.Uint16:
|
|
22
|
+
suffix = '16UI';
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Unsupported data type '${dt}'`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let prefix = '';
|
|
29
|
+
|
|
30
|
+
switch (channel_count) {
|
|
31
|
+
case 1:
|
|
32
|
+
prefix = 'R';
|
|
33
|
+
break;
|
|
34
|
+
case 2:
|
|
35
|
+
prefix = 'RG';
|
|
36
|
+
break;
|
|
37
|
+
case 3:
|
|
38
|
+
prefix = 'RGB';
|
|
39
|
+
break;
|
|
40
|
+
case 4:
|
|
41
|
+
prefix = 'RGBA';
|
|
42
|
+
break;
|
|
43
|
+
default:
|
|
44
|
+
throw new Error(`Unsupported channel count '${channel_count}'`);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return prefix + suffix;
|
|
48
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
//
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copy single channel from one sampler to another
|
|
5
|
+
* @param {Sampler2D} source
|
|
6
|
+
* @param {number} source_channel
|
|
7
|
+
* @param {Sampler2D} destination
|
|
8
|
+
* @param {number} destination_channel
|
|
9
|
+
*/
|
|
10
|
+
export function sampler2d_copy_channel_data(source, source_channel, destination, destination_channel) {
|
|
11
|
+
const pixel_count = source.height * source.width;
|
|
12
|
+
|
|
13
|
+
const source_item_size = source.itemSize;
|
|
14
|
+
const destination_item_size = destination.itemSize;
|
|
15
|
+
|
|
16
|
+
const source_data = source.data;
|
|
17
|
+
const destination_data = destination.data;
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < pixel_count; i++) {
|
|
20
|
+
const address_source = i * source_item_size + source_channel;
|
|
21
|
+
const address_destination = i * destination_item_size + destination_channel;
|
|
22
|
+
|
|
23
|
+
destination_data[address_destination] = source_data[address_source];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -10,6 +10,9 @@ import { genericResampleSampler2D } from "./genericResampleSampler2D.js";
|
|
|
10
10
|
* @param {Sampler2D} output
|
|
11
11
|
*/
|
|
12
12
|
export function scaleSampler2D(input, output) {
|
|
13
|
+
assert.equal(input.isSampler2D, true, 'input.isSampler2D !== true');
|
|
14
|
+
assert.equal(output.isSampler2D, true, 'output.isSampler2D !== true');
|
|
15
|
+
|
|
13
16
|
const targetItemSize = output.itemSize;
|
|
14
17
|
|
|
15
18
|
assert.equal(input.itemSize, targetItemSize, 'both source and target must have the same number of channels');
|
|
@@ -16,7 +16,20 @@ import { typedArrayConstructorByInstance } from "../typedArrayConstructorByInsta
|
|
|
16
16
|
export function drawSamplerHTML(parentNode, sampler, x, y, scale, offset, size) {
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const TA = typedArrayConstructorByInstance(sampler.data);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
let target_width = size;
|
|
23
|
+
let target_height = size;
|
|
24
|
+
|
|
25
|
+
// apply aspect ratio
|
|
26
|
+
if (sampler.width > sampler.height) {
|
|
27
|
+
target_height = Math.ceil(size * (sampler.height / sampler.width));
|
|
28
|
+
} else if (sampler.width < sampler.height) {
|
|
29
|
+
target_width = Math.ceil(size * (sampler.width / sampler.height));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const target = new Sampler2D(new TA(target_width * target_height * sampler.itemSize), sampler.itemSize, target_width, target_height);
|
|
20
33
|
|
|
21
34
|
scaleSampler2D(sampler, target);
|
|
22
35
|
|
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.
|
|
8
|
+
"version": "2.35.2",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"gl-matrix": "3.4.3",
|
|
11
11
|
"fast-levenshtein": "2.0.6",
|