@woosh/meep-engine 2.47.3 → 2.47.8
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/build/bundle-worker-image-decoder.js +1 -0
- package/build/bundle-worker-terrain.js +1 -0
- package/build/meep.cjs +659 -553
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +659 -553
- package/package.json +2 -2
- package/src/core/binary/BitSet.spec.js +3 -3
- package/src/core/bvh2/BinaryNode.js +12 -10
- package/src/core/bvh2/aabb3/AABB3.js +30 -31
- package/src/core/bvh2/binary/2/BinaryUint32BVH.js +1 -1
- package/src/core/bvh2/binary/BinaryBVH.js +1 -1
- package/src/core/bvh2/binary/RayLeafIntersectionVisitor.js +1 -1
- package/src/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +2 -2
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsFrustum.js +1 -1
- package/src/core/bvh2/bvh3/query/BVHQueryIntersectsRay.js +1 -1
- package/src/core/bvh2/bvh3/query/bvh_collect_user_data.js +10 -8
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_generic.js +14 -22
- package/src/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +13 -15
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_generic.js +14 -21
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_nearest_to_point.js +16 -24
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_frustum.js +23 -26
- package/src/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +10 -11
- package/src/core/bvh2/transform/BottomUpOptimizingRebuilder.js +2 -2
- package/src/core/bvh2/transform/tryRotateSingleNode.js +2 -2
- package/src/core/bvh2/traversal/aabb3_detailed_volume_intersection_callback_based.js +1 -1
- package/src/core/bvh2/traversal/queryBinaryNode_FrustumIntersections.js +1 -1
- package/src/core/collection/SCRATCH_UINT32_TRAVERSAL_STACK.js +13 -0
- package/src/core/color/Color.d.ts +2 -1
- package/src/core/color/Color.js +30 -5
- package/src/core/color/ColorUtils.js +7 -5
- package/src/core/color/parseHex.js +11 -3
- package/src/core/color/rgb2hex.js +1 -1
- package/src/core/geom/3d/SurfacePoint3.d.ts +7 -0
- package/src/core/geom/3d/SurfacePoint3.js +56 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_combine.js +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_contains_point.js +1 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_frustum_degree.js +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_combined_surface_area.js +2 -2
- package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_compute_distance_above_plane_max.spec.js +8 -0
- package/src/core/geom/3d/aabb/{computeAABB3PlaneSide.js → aabb3_compute_plane_side.js} +1 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_detailed_volume_intersection.js +7 -7
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_from_v3_array.js +4 -4
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_from_v3_array_transformed.js +2 -2
- package/src/core/{bvh2/aabb3/aabb3_intersect_aabb3.js → geom/3d/aabb/aabb3_intersects_aabb3.js} +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_frustum_array.js +2 -2
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_frustum_degree.js +4 -4
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_line_segment.js +1 -1
- package/src/core/geom/3d/aabb/aabb3_intersects_ray.js +87 -0
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray.spec.js +1 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray_branchless.js +2 -2
- package/src/core/{bvh2/aabb3/aabb3_intersect_ray_slab.js → geom/3d/aabb/aabb3_intersects_ray_slab.js} +35 -17
- package/src/core/geom/3d/aabb/aabb3_matrix4_project_by_corners.js +5 -1
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_nearest_point_on_surface.js +2 -2
- package/src/core/geom/3d/aabb/aabb3_raycast.js +103 -0
- package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_signed_distance_sqr_to_point.js +1 -1
- package/src/core/geom/3d/aabb/computeBoundingBoxFromVertexData.js +4 -12
- package/src/core/geom/3d/aabb/compute_aabb_from_points.js +8 -1
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +1 -1
- package/src/core/geom/3d/triangle/computeTriangleRayIntersection.js +4 -7
- package/src/core/model/node-graph/DataType.d.ts +4 -0
- package/src/core/model/node-graph/node/NodeDescription.d.ts +11 -1
- package/src/core/model/node-graph/node/NodeRegistry.spec.js +47 -1
- package/src/core/model/node-graph/node/Port.d.ts +3 -0
- package/src/core/model/node-graph/node/Port.js +7 -3
- package/src/core/model/node-graph/node/Port.spec.js +44 -0
- package/src/core/model/node-graph/node/PortDirection.d.ts +5 -0
- package/src/engine/asset/loaders/GLTFAssetLoader.js +1 -1
- package/src/engine/ecs/foliage/InstancedFoliage.js +1 -1
- package/src/engine/ecs/storage/BinaryBufferSerializer.js +13 -1
- package/src/engine/ecs/storage/binary/collection/BinaryCollectionSerializer.js +11 -4
- package/src/engine/ecs/storage/binary/object/BinaryObjectSerializationAdapter2.js +54 -0
- package/src/engine/ecs/systems/RenderSystem.js +1 -33
- package/src/engine/ecs/terrain/ecs/makeTerrainWorkerProxy.js +2 -4
- package/src/engine/ecs/terrain/tiles/TileBuildWorker.js +6 -1
- package/src/engine/graphics/GraphicsEngine.js +5 -1
- package/src/engine/graphics/ecs/decal/v2/Decal.js +44 -2
- package/src/engine/graphics/ecs/decal/v2/DecalSerializationAdapter.js +31 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +16 -5
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +88 -56
- package/src/engine/graphics/geometry/buffered/query/ClippingPlaneContainmentComputingVisitor.js +2 -2
- package/src/engine/graphics/geometry/buffered/query/RaycastNearestHitComputingVisitor.js +1 -1
- package/src/engine/graphics/geometry/instancing/InstancedMeshGroup.js +3 -2
- package/src/engine/graphics/geometry/skining/computeSkinnedMeshBoundingVolumes.js +3 -2
- package/src/engine/graphics/micron/format/MicronGeometry.js +1 -1
- package/src/engine/graphics/micron/format/validate_patch_bounds.js +1 -1
- package/src/engine/graphics/micron/render/refinement/ActivePatchList.js +1 -1
- package/src/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +16 -16
- package/src/engine/graphics/render/forward_plus/LightManager.js +3 -0
- package/src/engine/graphics/render/forward_plus/LightManager.spec.js +5 -5
- package/src/engine/graphics/render/forward_plus/materials/FP_SHADER_CHUNK_APPLY_DECALS.js +4 -0
- package/src/engine/graphics/render/forward_plus/model/Decal.js +10 -2
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_objects.js +2 -2
- package/src/engine/graphics/render/forward_plus/query/query_bvh_frustum_from_texture.js +18 -16
- package/src/engine/graphics/render/gizmo/GizmoShapeRenderingInterface.js +2 -0
- package/src/engine/graphics/render/visibility/IncrementalDeltaSet.js +26 -13
- package/src/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +8 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +3 -3
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +18 -15
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_max.js +1 -1
- package/src/engine/graphics/texture/sampler/sampler2d_channel_compute_min.js +1 -1
- package/src/engine/graphics/three/three_computeObjectBoundingBox.js +56 -0
- package/src/engine/input/devices/{InputDeviceButton.d.ts → InputDeviceSwitch.d.ts} +1 -1
- package/src/engine/input/devices/{InputDeviceButton.js → InputDeviceSwitch.js} +1 -1
- package/src/engine/input/devices/KeyboardDevice.d.ts +2 -2
- package/src/engine/input/devices/KeyboardDevice.js +58 -40
- package/src/engine/input/devices/PointerDevice.js +224 -179
- package/src/core/bvh2/aabb3/aabb3_intersects_ray.js +0 -97
- package/src/core/geom/3d/aabb/aabb3_computeDistanceAbovePlane_max.spec.js +0 -8
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_frustum_array.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_ray.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_array_intersects_ray_array.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_box_surface_area_2.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_compute_half_surface_area.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_compute_surface_area.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_corner_edge_mapping.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_corner_edge_mapping.spec.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_corner_mapping.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_corner_mapping.spec.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_edge_plane_mapping.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_expand_array.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_intersects_ray_fast.js +0 -0
- /package/src/core/{bvh2/aabb3 → geom/3d/aabb}/aabb3_score_boxes_SAH.js +0 -0
- /package/src/core/{bvh2/aabb3/aabb_score_boxes_SAH_delta.js → geom/3d/aabb/aabb3_score_boxes_SAH_delta.js} +0 -0
|
@@ -4,6 +4,7 @@ import { BinaryCollectionSerializer } from "./binary/collection/BinaryCollection
|
|
|
4
4
|
import { COMPONENT_SERIALIZATION_TRANSIENT_FIELD } from "./COMPONENT_SERIALIZATION_TRANSIENT_FIELD.js";
|
|
5
5
|
import { currentTimeInSeconds } from "../../Clock.js";
|
|
6
6
|
import { BinaryObjectSerializationAdapter } from "./binary/object/BinaryObjectSerializationAdapter.js";
|
|
7
|
+
import { logger } from "../../logging/GlobalLogger.js";
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* @template T
|
|
@@ -112,7 +113,10 @@ class BinaryBufferSerializer {
|
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
collectionSerializer.setClass(className);
|
|
115
|
-
|
|
116
|
+
|
|
117
|
+
const problemLog = [];
|
|
118
|
+
|
|
119
|
+
const initialized = collectionSerializer.initialize({
|
|
116
120
|
/**
|
|
117
121
|
*
|
|
118
122
|
* @param {string} className
|
|
@@ -121,9 +125,17 @@ class BinaryBufferSerializer {
|
|
|
121
125
|
*/
|
|
122
126
|
adapterOptionsSupplier(className, klass, adapter) {
|
|
123
127
|
return [engine, objectAdapter];
|
|
128
|
+
},
|
|
129
|
+
problemConsumer(message) {
|
|
130
|
+
problemLog.push(message);
|
|
124
131
|
}
|
|
125
132
|
});
|
|
126
133
|
|
|
134
|
+
if (!initialized) {
|
|
135
|
+
logger.error(`Failed to initialize serializer for class '${className}': ${problemLog.join('; ')}`)
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
|
|
127
139
|
const __start_time = currentTimeInSeconds();
|
|
128
140
|
|
|
129
141
|
let lastEntity = 0;
|
|
@@ -127,23 +127,28 @@ export class BinaryCollectionSerializer {
|
|
|
127
127
|
/**
|
|
128
128
|
*
|
|
129
129
|
* @param {function(string,Class, BinaryClassSerializationAdapter):[]} [adapterOptionsSupplier]
|
|
130
|
+
* @param {function(string):*} [problemConsumer]
|
|
131
|
+
* @returns {boolean}
|
|
130
132
|
*/
|
|
131
133
|
initialize({
|
|
132
|
-
adapterOptionsSupplier = returnEmptyArray
|
|
134
|
+
adapterOptionsSupplier = returnEmptyArray,
|
|
135
|
+
problemConsumer = console.warn
|
|
133
136
|
} = {}) {
|
|
134
137
|
|
|
135
|
-
assert.
|
|
138
|
+
assert.isFunction(adapterOptionsSupplier, 'adapterOptionsSupplier');
|
|
136
139
|
|
|
137
140
|
const className = this.className;
|
|
138
141
|
|
|
139
|
-
assert.
|
|
142
|
+
assert.isString(className, 'className');
|
|
140
143
|
|
|
141
144
|
const registry = this.registry;
|
|
142
145
|
|
|
143
146
|
const adapter = registry.getAdapter(className);
|
|
144
147
|
|
|
145
148
|
if (adapter === undefined) {
|
|
146
|
-
|
|
149
|
+
problemConsumer(`No adapter for class '${className}'`);
|
|
150
|
+
|
|
151
|
+
return false;
|
|
147
152
|
}
|
|
148
153
|
|
|
149
154
|
this.adapter = adapter;
|
|
@@ -181,6 +186,8 @@ export class BinaryCollectionSerializer {
|
|
|
181
186
|
|
|
182
187
|
//clear dictionary
|
|
183
188
|
this.dictionary.clear();
|
|
189
|
+
|
|
190
|
+
return true;
|
|
184
191
|
}
|
|
185
192
|
|
|
186
193
|
finalize() {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export class BinaryObjectSerializationAdapter2 {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @type {BinarySerializationRegistry|null}
|
|
5
|
+
*/
|
|
6
|
+
#registry = null
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {BinaryBuffer} buffer
|
|
11
|
+
* @param {Object} object
|
|
12
|
+
* @param {Object} schema
|
|
13
|
+
*/
|
|
14
|
+
serialize(buffer, object, schema) {
|
|
15
|
+
const typeName = object.constructor.typeName;
|
|
16
|
+
|
|
17
|
+
const nativeAdapter = this.#registry.getAdapter(typeName);
|
|
18
|
+
|
|
19
|
+
// TODO write a header so we can reconstruct the serialization schema on the other side
|
|
20
|
+
|
|
21
|
+
if (nativeAdapter !== undefined) {
|
|
22
|
+
// serialize with native
|
|
23
|
+
nativeAdapter.serialize(buffer, object);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for (const property in schema) {
|
|
28
|
+
|
|
29
|
+
const field_schema = schema[property];
|
|
30
|
+
|
|
31
|
+
const actual_value = object[field_schema];
|
|
32
|
+
|
|
33
|
+
this.serialize(buffer, actual_value, field_schema);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @param {BinaryBuffer} buffer
|
|
41
|
+
* @param {Object} object
|
|
42
|
+
*/
|
|
43
|
+
deserialize(buffer, object) {
|
|
44
|
+
|
|
45
|
+
// read header
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* @readonly
|
|
52
|
+
* @type {number}
|
|
53
|
+
*/
|
|
54
|
+
BinaryObjectSerializationAdapter2.prototype.version = 0;
|
|
@@ -5,44 +5,12 @@ import { System } from '../System.js';
|
|
|
5
5
|
import Renderable from '../components/Renderable.js';
|
|
6
6
|
import { Transform } from '../transform/Transform.js';
|
|
7
7
|
import { SignalBinding } from "../../../core/events/signal/SignalBinding.js";
|
|
8
|
-
import { Box3 } from "three";
|
|
9
8
|
import { RenderableFlags } from "../components/RenderableFlags.js";
|
|
10
9
|
import { rootObject3DFastMatrixUpdate } from "../../graphics/ecs/mesh/rootObject3DFastMatrixUpdate.js";
|
|
11
10
|
import { updateNodeByTransformAndBBB } from "../../graphics/ecs/mesh/updateNodeByTransformAndBBB.js";
|
|
11
|
+
import { three_computeObjectBoundingBox } from "../../graphics/three/three_computeObjectBoundingBox.js";
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* @param {Object3D} object
|
|
17
|
-
* @param {AABB3} result
|
|
18
|
-
*/
|
|
19
|
-
export function three_computeObjectBoundingBox(object, result) {
|
|
20
|
-
const _sX = object.scale.x;
|
|
21
|
-
const _sY = object.scale.y;
|
|
22
|
-
const _sZ = object.scale.z;
|
|
23
|
-
|
|
24
|
-
object.scale.set(1, 1, 1);
|
|
25
|
-
|
|
26
|
-
const box3 = new Box3();
|
|
27
|
-
|
|
28
|
-
box3.expandByObject(object);
|
|
29
|
-
|
|
30
|
-
object.scale.set(_sX, _sY, _sZ);
|
|
31
|
-
|
|
32
|
-
const min = box3.min;
|
|
33
|
-
const max = box3.max;
|
|
34
|
-
|
|
35
|
-
result.setBounds(
|
|
36
|
-
min.x,
|
|
37
|
-
min.y,
|
|
38
|
-
min.z,
|
|
39
|
-
max.x,
|
|
40
|
-
max.y,
|
|
41
|
-
max.z
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
14
|
/**
|
|
47
15
|
* @deprecated use {@link ShadedGeometry} instead
|
|
48
16
|
*/
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import WorkerBuilder from "../../../../core/process/worker/WorkerBuilder.js";
|
|
2
|
-
import { sampler2d_channel_compute_max } from "../../../graphics/texture/sampler/sampler2d_channel_compute_max.js";
|
|
3
|
-
import { sampler2d_channel_compute_min } from "../../../graphics/texture/sampler/sampler2d_channel_compute_min.js";
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
*
|
|
@@ -29,8 +27,8 @@ export function makeTerrainWorkerProxy() {
|
|
|
29
27
|
|
|
30
28
|
useSampler(function (sampler) {
|
|
31
29
|
|
|
32
|
-
const min = sampler2d_channel_compute_min(sampler);
|
|
33
|
-
const max = sampler2d_channel_compute_max(sampler);
|
|
30
|
+
const min = Lib.sampler2d_channel_compute_min(sampler);
|
|
31
|
+
const max = Lib.sampler2d_channel_compute_max(sampler);
|
|
34
32
|
|
|
35
33
|
resolve({
|
|
36
34
|
min: min.value,
|
|
@@ -6,12 +6,17 @@ import * as BinaryBVHFromBufferGeometry from '../../../graphics/geometry/bvh/buf
|
|
|
6
6
|
import { Sampler2D } from '../../../graphics/texture/sampler/Sampler2D.js';
|
|
7
7
|
import BufferedGeometryArraysBuilder from '../BufferedGeometryArraysBuilder.js';
|
|
8
8
|
import { tensionOptimizeUV } from "../util/tensionOptimizeUV.js";
|
|
9
|
+
import { sampler2d_channel_compute_min } from "../../../graphics/texture/sampler/sampler2d_channel_compute_min.js";
|
|
10
|
+
import { sampler2d_channel_compute_max } from "../../../graphics/texture/sampler/sampler2d_channel_compute_max.js";
|
|
11
|
+
|
|
9
12
|
|
|
10
13
|
self.Lib = {
|
|
11
14
|
BinaryBVHFromBufferGeometry,
|
|
12
15
|
Sampler2D,
|
|
13
16
|
BufferedGeometryArraysBuilder,
|
|
14
|
-
tensionOptimizeUV
|
|
17
|
+
tensionOptimizeUV,
|
|
18
|
+
sampler2d_channel_compute_min,
|
|
19
|
+
sampler2d_channel_compute_max
|
|
15
20
|
};
|
|
16
21
|
|
|
17
22
|
|
|
@@ -355,7 +355,11 @@ GraphicsEngine.prototype.start = function () {
|
|
|
355
355
|
antialias: true,
|
|
356
356
|
logarithmicDepthBuffer: false,
|
|
357
357
|
canvas,
|
|
358
|
-
context
|
|
358
|
+
context,
|
|
359
|
+
/**
|
|
360
|
+
* @see https://registry.khronos.org/webgl/specs/latest/1.0/#5.2
|
|
361
|
+
*/
|
|
362
|
+
powerPreference:"high-performance"
|
|
359
363
|
};
|
|
360
364
|
|
|
361
365
|
const webGLRenderer = this.renderer = new WebGLRenderer(rendererParameters);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { Color } from "../../../../../core/color/Color.js";
|
|
2
|
+
import { computeStringHash } from "../../../../../core/primitives/strings/computeStringHash.js";
|
|
3
|
+
|
|
1
4
|
export class Decal {
|
|
2
5
|
constructor() {
|
|
3
6
|
/**
|
|
@@ -12,6 +15,12 @@ export class Decal {
|
|
|
12
15
|
*/
|
|
13
16
|
this.priority = 0;
|
|
14
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Color of the decal will be pre-multiplied by this
|
|
20
|
+
* @type {Color}
|
|
21
|
+
*/
|
|
22
|
+
this.color = new Color(1, 1, 1, 1);
|
|
23
|
+
|
|
15
24
|
/**
|
|
16
25
|
* Internal transient reference to loaded asset
|
|
17
26
|
* @type {Sampler2D|null}
|
|
@@ -26,15 +35,26 @@ export class Decal {
|
|
|
26
35
|
this.__cached_uri = null;
|
|
27
36
|
}
|
|
28
37
|
|
|
38
|
+
static fromJSON(j) {
|
|
39
|
+
const r = new Decal();
|
|
40
|
+
|
|
41
|
+
r.fromJSON(j);
|
|
42
|
+
|
|
43
|
+
return r;
|
|
44
|
+
}
|
|
45
|
+
|
|
29
46
|
toJSON() {
|
|
30
47
|
return {
|
|
31
48
|
uri: this.uri,
|
|
32
|
-
priority: this.priority
|
|
49
|
+
priority: this.priority,
|
|
50
|
+
color: this.color.toCssRGBAString()
|
|
33
51
|
};
|
|
34
52
|
}
|
|
35
53
|
|
|
36
54
|
fromJSON({
|
|
37
|
-
uri,
|
|
55
|
+
uri,
|
|
56
|
+
priority = 0,
|
|
57
|
+
color
|
|
38
58
|
}) {
|
|
39
59
|
this.uri = uri;
|
|
40
60
|
this.priority = priority;
|
|
@@ -44,6 +64,28 @@ export class Decal {
|
|
|
44
64
|
this.__cached_sampler = null;
|
|
45
65
|
this.__cached_uri = null;
|
|
46
66
|
}
|
|
67
|
+
|
|
68
|
+
if (color !== undefined) {
|
|
69
|
+
this.color.parse(color);
|
|
70
|
+
} else {
|
|
71
|
+
this.color.set(1, 1, 1, 1);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
hash() {
|
|
76
|
+
return computeStringHash(this.uri) ^ this.color.hash()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {Decal} other
|
|
82
|
+
* @returns {boolean}
|
|
83
|
+
*/
|
|
84
|
+
equals(other) {
|
|
85
|
+
return this.uri === other.uri
|
|
86
|
+
&& this.color.equals(other.color)
|
|
87
|
+
&& this.priority === other.priority
|
|
88
|
+
;
|
|
47
89
|
}
|
|
48
90
|
}
|
|
49
91
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BinaryClassSerializationAdapter } from "../../../../ecs/storage/binary/BinaryClassSerializationAdapter.js";
|
|
2
|
+
import { Decal } from "./Decal.js";
|
|
3
|
+
|
|
4
|
+
export class DecalSerializationAdapter extends BinaryClassSerializationAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
super();
|
|
7
|
+
|
|
8
|
+
this.klass = Decal;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {BinaryBuffer} buffer
|
|
14
|
+
* @param {Decal} value
|
|
15
|
+
*/
|
|
16
|
+
serialize(buffer, value) {
|
|
17
|
+
|
|
18
|
+
buffer.writeUTF8String(value.uri);
|
|
19
|
+
buffer.writeFloat32(value.priority);
|
|
20
|
+
buffer.writeFloat32Array(value.color, 0, 4);
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
deserialize(buffer, value) {
|
|
25
|
+
|
|
26
|
+
value.uri = buffer.readUTF8String();
|
|
27
|
+
value.priority = buffer.readFloat32();
|
|
28
|
+
buffer.readFloat32Array(value.color, 0, 4);
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
} from "../../../../../core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js";
|
|
18
18
|
import { bvh_query_leaves_ray } from "../../../../../core/bvh2/bvh3/query/bvh_query_leaves_ray.js";
|
|
19
19
|
import { ray3_array_apply_matrix4 } from "../../../../../core/geom/3d/ray/ray3_array_apply_matrix4.js";
|
|
20
|
-
import { aabb3_intersects_ray } from "../../../../../core/bvh2/aabb3/aabb3_intersects_ray.js";
|
|
21
20
|
import { ray3_array_compose } from "../../../../../core/geom/3d/ray/ray3_array_compose.js";
|
|
22
21
|
import { mat4 } from "gl-matrix";
|
|
23
22
|
import { SurfacePoint3 } from "../../../../../core/geom/3d/SurfacePoint3.js";
|
|
24
23
|
import { EBBVHLeafProxy } from "../../../../../core/bvh2/bvh3/EBBVHLeafProxy.js";
|
|
25
24
|
import { aabb3_matrix4_project } from "../../../../../core/geom/3d/aabb/aabb3_matrix4_project.js";
|
|
25
|
+
import { aabb3_raycast } from "../../../../../core/geom/3d/aabb/aabb3_raycast.js";
|
|
26
26
|
|
|
27
27
|
const placeholder_texture = Sampler2D.uint8(4, 1, 1);
|
|
28
28
|
placeholder_texture.data.fill(255);
|
|
@@ -146,9 +146,16 @@ class Context extends SystemEntityContext {
|
|
|
146
146
|
const decal_spec = this.components[0];
|
|
147
147
|
|
|
148
148
|
// propagate draw priority onto decal
|
|
149
|
-
Object.
|
|
150
|
-
|
|
151
|
-
|
|
149
|
+
Object.defineProperties(fpDecal, {
|
|
150
|
+
'draw_priority': {
|
|
151
|
+
get() {
|
|
152
|
+
return decal_spec.priority;
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
'color':{
|
|
156
|
+
get(){
|
|
157
|
+
return decal_spec.color;
|
|
158
|
+
}
|
|
152
159
|
}
|
|
153
160
|
});
|
|
154
161
|
|
|
@@ -298,6 +305,7 @@ export class FPDecalSystem extends AbstractContextSystem {
|
|
|
298
305
|
);
|
|
299
306
|
|
|
300
307
|
const result = [];
|
|
308
|
+
const temp_hit = new Float32Array(6);
|
|
301
309
|
|
|
302
310
|
|
|
303
311
|
for (let i = 0; i < hit_count; i++) {
|
|
@@ -338,7 +346,8 @@ export class FPDecalSystem extends AbstractContextSystem {
|
|
|
338
346
|
// transform ray into decal's local space
|
|
339
347
|
ray3_array_apply_matrix4(scratch_ray_0, 0, scratch_ray_0, 0, scratch_m4);
|
|
340
348
|
|
|
341
|
-
if (
|
|
349
|
+
if (aabb3_raycast(
|
|
350
|
+
temp_hit, 0,
|
|
342
351
|
-0.5, -0.5, -0.5,
|
|
343
352
|
0.5, 0.5, 0.5,
|
|
344
353
|
|
|
@@ -347,6 +356,8 @@ export class FPDecalSystem extends AbstractContextSystem {
|
|
|
347
356
|
)) {
|
|
348
357
|
const contact = new SurfacePoint3();
|
|
349
358
|
|
|
359
|
+
contact.fromArray(temp_hit);
|
|
360
|
+
|
|
350
361
|
// contact will be the center of decal, and normal will follow the decal normal
|
|
351
362
|
contact.applyMatrix4(transform.matrix);
|
|
352
363
|
|
|
@@ -27,6 +27,10 @@ import { OctahedralUvEncoder } from "../../../impostors/octahedral/grid/Octahedr
|
|
|
27
27
|
import { makeSolidArrowGeometry } from "../../../../../../editor/process/symbolic/makeSolidArrowGeometry.js";
|
|
28
28
|
import { vec3 } from "gl-matrix";
|
|
29
29
|
import Quaternion from "../../../../../core/geom/Quaternion.js";
|
|
30
|
+
import { GizmoRenderingPlugin } from "../../../render/gizmo/GizmoRenderingPlugin.js";
|
|
31
|
+
import { Gizmo } from "../../../render/gizmo/Gizmo.js";
|
|
32
|
+
import { ForwardPlusRenderingPlugin } from "../../../render/forward_plus/plugin/ForwardPlusRenderingPlugin.js";
|
|
33
|
+
import { TaskLoadingScreen } from "../../../../../view/task/TaskLoadingScreen.js";
|
|
30
34
|
|
|
31
35
|
const decal_urls = `data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/staff_13_t.png
|
|
32
36
|
data/textures/icons/FantasyIconsMegaPack/MagicItems/MagicItems_png/transparent/x64/artifact_01_t.png
|
|
@@ -371,18 +375,87 @@ function makeNormalTestDecal() {
|
|
|
371
375
|
return entity;
|
|
372
376
|
}
|
|
373
377
|
|
|
378
|
+
function sample_grid(ecd) {
|
|
379
|
+
const q_down = new Quaternion();
|
|
380
|
+
q_down.lookRotation(Vector3.down)
|
|
381
|
+
|
|
382
|
+
makeNormalTestGridDecal(ecd, Transform.fromJSON({
|
|
383
|
+
position: new Vector3(5, 0, 5),
|
|
384
|
+
rotation: q_down
|
|
385
|
+
}));
|
|
386
|
+
|
|
387
|
+
|
|
388
|
+
const q_forward = new Quaternion();
|
|
389
|
+
q_forward.lookRotation(Vector3.forward)
|
|
390
|
+
|
|
391
|
+
const t_forward_grid = Transform.fromJSON({
|
|
392
|
+
position: new Vector3(5, 4, 5),
|
|
393
|
+
rotation: q_forward
|
|
394
|
+
});
|
|
395
|
+
makeNormalTestGridDecal(ecd, t_forward_grid);
|
|
396
|
+
|
|
397
|
+
new EntityBuilder()
|
|
398
|
+
.add(SGMesh.fromURL('data/models/snaps/cube_white.gltf'))
|
|
399
|
+
.add(Transform.fromJSON({
|
|
400
|
+
position: new Vector3(14, 1, 4.8),
|
|
401
|
+
rotation: t_forward_grid.rotation,
|
|
402
|
+
scale: new Vector3(25, 25, 0.1)
|
|
403
|
+
}))
|
|
404
|
+
.build(ecd);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function raycast_tool(engine) {
|
|
408
|
+
let hits = [];
|
|
409
|
+
|
|
410
|
+
engine.graphics.on.preRender.add(() => {
|
|
411
|
+
|
|
412
|
+
hits.forEach(hit => {
|
|
413
|
+
|
|
414
|
+
Gizmo.draw_solid_sphere(hit.contact.position.asArray(), 0.1);
|
|
415
|
+
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
engine.devices.pointer.position.onChanged.add(() => {
|
|
421
|
+
const ray_origin = new Vector3();
|
|
422
|
+
const ray_direction = new Vector3();
|
|
423
|
+
|
|
424
|
+
|
|
425
|
+
const pointer = engine.devices.pointer.position;
|
|
426
|
+
|
|
427
|
+
const ndc = new Vector2();
|
|
428
|
+
|
|
429
|
+
engine.graphics.normalizeViewportPoint(pointer, ndc);
|
|
430
|
+
engine.graphics.viewportProjectionRay(ndc.x, ndc.y, ray_origin, ray_direction);
|
|
431
|
+
|
|
432
|
+
hits = engine.entityManager.getSystem(FPDecalSystem)?.raycast(
|
|
433
|
+
ray_origin.x, ray_origin.y, ray_origin.z,
|
|
434
|
+
ray_direction.x, ray_direction.y, ray_direction.z
|
|
435
|
+
);
|
|
436
|
+
|
|
437
|
+
console.warn(hits);
|
|
438
|
+
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
|
|
374
442
|
/**
|
|
375
443
|
*
|
|
376
444
|
* @param {Engine} engine
|
|
377
445
|
*/
|
|
378
446
|
async function main(engine) {
|
|
379
447
|
|
|
448
|
+
const fpp = engine.plugins.getPlugin(ForwardPlusRenderingPlugin);
|
|
449
|
+
fpp.setClusterResolution(12, 8, 1);
|
|
450
|
+
|
|
451
|
+
const TERRAIN_SIZE = 1000;
|
|
452
|
+
|
|
380
453
|
await EngineHarness.buildBasics({
|
|
381
454
|
engine,
|
|
382
455
|
enableWater: false,
|
|
383
456
|
cameraFarDistance: 300,
|
|
384
457
|
terrainResolution: 1,
|
|
385
|
-
terrainSize: new Vector2(
|
|
458
|
+
terrainSize: new Vector2(TERRAIN_SIZE, TERRAIN_SIZE)
|
|
386
459
|
});
|
|
387
460
|
|
|
388
461
|
new EntityBuilder()
|
|
@@ -396,10 +469,12 @@ async function main(engine) {
|
|
|
396
469
|
|
|
397
470
|
const random = seededRandom();
|
|
398
471
|
|
|
399
|
-
const ENTITY_COUNT =
|
|
472
|
+
const ENTITY_COUNT = 100000;
|
|
400
473
|
|
|
401
474
|
const ecd = engine.entityManager.dataset;
|
|
402
475
|
|
|
476
|
+
console.log('Decal image pool size:', decal_urls.length);
|
|
477
|
+
|
|
403
478
|
function makeOne() {
|
|
404
479
|
const decal = new Decal();
|
|
405
480
|
|
|
@@ -411,17 +486,17 @@ async function main(engine) {
|
|
|
411
486
|
|
|
412
487
|
const transform = new Transform();
|
|
413
488
|
transform.position.set(
|
|
414
|
-
randomFloatBetween(random,
|
|
489
|
+
randomFloatBetween(random, 0, TERRAIN_SIZE),
|
|
415
490
|
randomFloatBetween(random, 0, 0),
|
|
416
|
-
randomFloatBetween(random,
|
|
491
|
+
randomFloatBetween(random, 0, TERRAIN_SIZE)
|
|
417
492
|
);
|
|
418
|
-
transform.rotation.
|
|
419
|
-
transform.scale.
|
|
493
|
+
transform.rotation._lookRotation(0, -1, 0, 0, 1, 0);
|
|
494
|
+
transform.scale.set(1,1,0.5);
|
|
420
495
|
|
|
421
496
|
entity
|
|
422
497
|
.add(transform)
|
|
423
498
|
.add(decal)
|
|
424
|
-
|
|
499
|
+
// .add(BehaviorComponent.fromOne(RotationBehavior.fromJSON({ speed: 1 })))
|
|
425
500
|
|
|
426
501
|
entity.build(ecd);
|
|
427
502
|
}
|
|
@@ -433,34 +508,9 @@ async function main(engine) {
|
|
|
433
508
|
|
|
434
509
|
const task = countTask(0, ENTITY_COUNT, makeOne);
|
|
435
510
|
|
|
436
|
-
|
|
437
|
-
q_down.lookRotation(Vector3.down)
|
|
438
|
-
|
|
439
|
-
makeNormalTestGridDecal(ecd, Transform.fromJSON({
|
|
440
|
-
position: new Vector3(5, 0, 5),
|
|
441
|
-
rotation: q_down
|
|
442
|
-
}));
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
const q_forward = new Quaternion();
|
|
446
|
-
q_forward.lookRotation(Vector3.forward)
|
|
447
|
-
|
|
448
|
-
const t_forward_grid = Transform.fromJSON({
|
|
449
|
-
position: new Vector3(5, 4, 5),
|
|
450
|
-
rotation: q_forward
|
|
451
|
-
});
|
|
452
|
-
makeNormalTestGridDecal(ecd, t_forward_grid);
|
|
453
|
-
|
|
454
|
-
new EntityBuilder()
|
|
455
|
-
.add(SGMesh.fromURL('data/models/snaps/cube_white.gltf'))
|
|
456
|
-
.add(Transform.fromJSON({
|
|
457
|
-
position: new Vector3(14, 1, 4.8),
|
|
458
|
-
rotation: t_forward_grid.rotation,
|
|
459
|
-
scale: new Vector3(25, 25, 0.1)
|
|
460
|
-
}))
|
|
461
|
-
.build(ecd);
|
|
511
|
+
//sample_grid(ecd);
|
|
462
512
|
|
|
463
|
-
|
|
513
|
+
TaskLoadingScreen.instance.load(engine, task);
|
|
464
514
|
|
|
465
515
|
// console.profile('spawn');
|
|
466
516
|
|
|
@@ -468,34 +518,14 @@ async function main(engine) {
|
|
|
468
518
|
// console.profileEnd('spawn');
|
|
469
519
|
});
|
|
470
520
|
|
|
471
|
-
|
|
521
|
+
engine.executor.run(task);
|
|
472
522
|
|
|
473
523
|
|
|
474
524
|
//grid(engine.entityManager.dataset, 20,10,80, 25, .4, .6, .1, decal_urls.slice(105, 105+3));
|
|
475
525
|
|
|
476
526
|
//grid(engine.entityManager.dataset, 20,30,80, 25, .4, .6, .1, decal_urls.slice(105, 105+3));
|
|
477
527
|
// await promise_time_out(10);
|
|
478
|
-
|
|
479
|
-
engine.devices.pointer.position.onChanged.add(() => {
|
|
480
|
-
const ray_origin = new Vector3();
|
|
481
|
-
const ray_direction = new Vector3();
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
const pointer = engine.devices.pointer.position;
|
|
485
|
-
|
|
486
|
-
const ndc = new Vector2();
|
|
487
|
-
|
|
488
|
-
engine.graphics.normalizeViewportPoint(pointer,ndc);
|
|
489
|
-
engine.graphics.viewportProjectionRay(ndc.x, ndc.y, ray_origin, ray_direction);
|
|
490
|
-
|
|
491
|
-
const hits = engine.entityManager.getSystem(FPDecalSystem)?.raycast(
|
|
492
|
-
ray_origin.x, ray_origin.y, ray_origin.z,
|
|
493
|
-
ray_direction.x, ray_direction.y, ray_direction.z
|
|
494
|
-
);
|
|
495
|
-
|
|
496
|
-
console.warn(hits);
|
|
497
|
-
|
|
498
|
-
});
|
|
528
|
+
// raycast_tool(engine);
|
|
499
529
|
|
|
500
530
|
}
|
|
501
531
|
|
|
@@ -504,6 +534,8 @@ new EngineHarness()
|
|
|
504
534
|
configuration(config, engine) {
|
|
505
535
|
const gltfAssetLoader = new GLTFAssetLoader();
|
|
506
536
|
|
|
537
|
+
config.addPlugin(GizmoRenderingPlugin);
|
|
538
|
+
|
|
507
539
|
config.addLoader(GameAssetType.ModelGLTF_JSON, gltfAssetLoader);
|
|
508
540
|
config.addLoader(GameAssetType.ModelGLTF, gltfAssetLoader);
|
|
509
541
|
|
package/src/engine/graphics/geometry/buffered/query/ClippingPlaneContainmentComputingVisitor.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { aabb3_compute_plane_side } from "../../../../../core/geom/3d/aabb/aabb3_compute_plane_side.js";
|
|
2
2
|
import { NodeType } from "../../../../../core/bvh2/binary/NodeType.js";
|
|
3
3
|
import { computeTrianglePlaneSide } from "../../../../../core/geom/3d/triangle/computeTrianglePlaneSide.js";
|
|
4
4
|
import { GeometrySpatialAcceleratorVisitor } from "./GeometryVisitor.js";
|
|
@@ -162,7 +162,7 @@ export class ClippingPlaneContainmentComputingVisitor extends GeometrySpatialAcc
|
|
|
162
162
|
const plane_normal_z = plane.normal.z;
|
|
163
163
|
const plane_constant = plane.constant;
|
|
164
164
|
|
|
165
|
-
const side =
|
|
165
|
+
const side = aabb3_compute_plane_side(
|
|
166
166
|
plane_normal_x,
|
|
167
167
|
plane_normal_y,
|
|
168
168
|
plane_normal_z,
|
|
@@ -3,7 +3,7 @@ import { NodeType } from "../../../../../core/bvh2/binary/NodeType.js";
|
|
|
3
3
|
import Vector3 from "../../../../../core/geom/Vector3.js";
|
|
4
4
|
import { computeTriangleRayIntersection } from "../../../../../core/geom/3d/triangle/computeTriangleRayIntersection.js";
|
|
5
5
|
import { GeometrySpatialAcceleratorVisitor } from "./GeometryVisitor.js";
|
|
6
|
-
import { aabb3_intersects_ray } from "../../../../../core/
|
|
6
|
+
import { aabb3_intersects_ray } from "../../../../../core/geom/3d/aabb/aabb3_intersects_ray.js";
|
|
7
7
|
import { assert } from "../../../../../core/assert.js";
|
|
8
8
|
|
|
9
9
|
export class RaycastNearestHitComputingVisitor extends GeometrySpatialAcceleratorVisitor {
|
|
@@ -17,6 +17,7 @@ import { rewriteMaterial } from "./rewriteMaterial.js";
|
|
|
17
17
|
import { max3 } from "../../../../core/math/max3.js";
|
|
18
18
|
import { min2 } from "../../../../core/math/min2.js";
|
|
19
19
|
import { DrawMode } from "../../ecs/mesh-v2/DrawMode.js";
|
|
20
|
+
import { array_copy } from "../../../../core/collection/array/copyArray.js";
|
|
20
21
|
|
|
21
22
|
export class InstancedMeshGroup {
|
|
22
23
|
/**
|
|
@@ -316,7 +317,7 @@ export class InstancedMeshGroup {
|
|
|
316
317
|
* @param {number[]|ArrayLike<number>|Float32Array} transform 4x4 transform matrix of the instance
|
|
317
318
|
*/
|
|
318
319
|
setTransformAt(index, transform) {
|
|
319
|
-
this.__attributeTransformArray
|
|
320
|
+
array_copy(transform,0,this.__attributeTransformArray,index*16,16);
|
|
320
321
|
}
|
|
321
322
|
|
|
322
323
|
/**
|
|
@@ -325,7 +326,7 @@ export class InstancedMeshGroup {
|
|
|
325
326
|
* @param {number[]|ArrayLike<number>|Float32Array} color RGBA color in uint8 format (0...255), LDR
|
|
326
327
|
*/
|
|
327
328
|
setColorAt(index, color) {
|
|
328
|
-
this.__attributeColorArray
|
|
329
|
+
array_copy(color,0,this.__attributeColorArray,index*4,4);
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
/**
|