@woosh/meep-engine 2.43.17 → 2.43.19
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/assert.js +3 -1
- package/core/bvh2/aabb3/aabb3_intersects_ray.js +14 -9
- package/core/bvh2/aabb3/aabb3_intersects_ray_branchless.js +52 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +2 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +162 -10
- package/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +34 -0
- package/core/bvh2/bvh3/ebvh_build_for_geometry_morton.js +175 -0
- package/core/bvh2/bvh3/ebvh_sort_for_traversal_depth_first.js +122 -0
- package/core/bvh2/bvh3/{bvh_collect_user_data.js → query/bvh_collect_user_data.js} +1 -1
- package/core/bvh2/bvh3/{bvh_query_leaves_generic.js → query/bvh_query_leaves_generic.js} +1 -1
- package/core/bvh2/bvh3/query/bvh_query_leaves_ray.js +97 -0
- package/core/bvh2/bvh3/{bvh_query_user_data_generic.js → query/bvh_query_user_data_generic.js} +1 -1
- package/core/bvh2/bvh3/{bvh_query_user_data_nearest_to_point.js → query/bvh_query_user_data_nearest_to_point.js} +3 -3
- package/core/bvh2/bvh3/{bvh_query_user_data_nearest_to_point.spec.js → query/bvh_query_user_data_nearest_to_point.spec.js} +1 -1
- package/core/bvh2/bvh3/{bvh_query_user_data_overlaps_frustum.js → query/bvh_query_user_data_overlaps_frustum.js} +2 -2
- package/core/bvh2/bvh3/query/compute_tight_near_far_clipping_planes.js +1 -1
- package/core/collection/array/arrayQuickSort.js +1 -1
- package/core/collection/array/typed/typed_array_copy.js +2 -2
- package/core/geom/3d/aabb/compute_aabb_from_points.js +4 -3
- package/core/geom/3d/compute_triangle_normal.js +76 -0
- package/core/geom/3d/topology/samples/sampleFloodFill.js +1 -1
- package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
- package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
- package/core/geom/3d/topology/struct/TopoTriangle.js +1 -57
- package/core/geom/3d/topology/tm_face_normal.js +1 -1
- package/core/geom/3d/topology/tm_vertex_compute_normal.js +1 -1
- package/core/geom/3d/triangle/computeTriangleRayIntersection.js +195 -27
- package/core/geom/Vector3.js +12 -12
- package/core/math/physics/brdf/D_GGX.js +13 -0
- package/editor/tools/v2/prototypeTransformControls.js +14 -2
- package/engine/ecs/parent/EntityNode.js +80 -7
- package/engine/ecs/parent/EntityNodeFlags.js +8 -0
- package/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +2 -2
- package/engine/graphics/ecs/mesh-v2/aggregate/SGMesh.js +9 -1
- package/engine/graphics/ecs/mesh-v2/render/ShadedGeometryRendererContext.js +1 -1
- package/engine/graphics/geometry/AttributeSpec.js +18 -3
- package/engine/graphics/geometry/VertexDataSpec.js +53 -3
- package/engine/graphics/micron/format/VirtualGeometry.js +7 -0
- package/engine/graphics/micron/render/VirtualGeometryBuilder.js +1 -1
- package/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +5 -2
- package/engine/graphics/particles/particular/engine/parameter/sample/RGBA_LUT_HEATMAP_IR.js +11 -0
- package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -9
- package/engine/graphics/render/forward_plus/model/DirectionalLight.js +40 -0
- package/engine/graphics/sh3/README.md +1 -0
- package/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +265 -0
- package/engine/graphics/sh3/path_tracer/PathTracedMesh.js +85 -0
- package/engine/graphics/sh3/path_tracer/PathTracer.js +534 -0
- package/engine/graphics/sh3/path_tracer/apply_texture_clamping_to_coordinate.js +22 -0
- package/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +36 -0
- package/engine/graphics/sh3/path_tracer/getBiasedNormalSample.js +55 -0
- package/engine/graphics/sh3/path_tracer/make_one_vector3.js +7 -0
- package/engine/graphics/sh3/path_tracer/make_sky_hosek.js +44 -0
- package/engine/graphics/sh3/path_tracer/make_sky_rtiw.js +17 -0
- package/engine/graphics/sh3/path_tracer/make_zero_vector3.js +7 -0
- package/engine/graphics/sh3/path_tracer/prototypePathTracer.js +631 -0
- package/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +39 -0
- package/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +42 -0
- package/engine/graphics/sh3/path_tracer/ray_reflect.js +27 -0
- package/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +35 -0
- package/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +12 -0
- package/engine/graphics/sh3/sky/hosek/README.md +4 -0
- package/engine/graphics/sh3/sky/hosek/prototype_hosek.js +71 -0
- package/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +4171 -0
- package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +2 -0
- package/package.json +1 -1
- package/view/elements/progress/SmoothProgressBar.js +1 -1
- package/view/task/TaskProgressView.js +6 -8
- package/core/bvh2/bvh3/bvh_query_leaves_ray.js +0 -95
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { v3_length } from "../../../../core/geom/v3_length.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} output
|
|
6
|
+
* @param {number[]} hit
|
|
7
|
+
* @param {number[]} m 4x4 matrix
|
|
8
|
+
*/
|
|
9
|
+
export function ray_hit_apply_transform(output, hit, m) {
|
|
10
|
+
|
|
11
|
+
// transform position
|
|
12
|
+
const p_x = hit[0];
|
|
13
|
+
const p_y = hit[1];
|
|
14
|
+
const p_z = hit[2];
|
|
15
|
+
|
|
16
|
+
// compute perspective projection
|
|
17
|
+
const w = 1 / (m[3] * p_x + m[7] * p_y + m[11] * p_z + m[15]);
|
|
18
|
+
|
|
19
|
+
const result_p_x = (m[0] * p_x + m[4] * p_y + m[8] * p_z + m[12]) * w;
|
|
20
|
+
const result_p_y = (m[1] * p_x + m[5] * p_y + m[9] * p_z + m[13]) * w;
|
|
21
|
+
const result_p_z = (m[2] * p_x + m[6] * p_y + m[10] * p_z + m[14]) * w;
|
|
22
|
+
|
|
23
|
+
output[0] = result_p_x;
|
|
24
|
+
output[1] = result_p_y;
|
|
25
|
+
output[2] = result_p_z;
|
|
26
|
+
|
|
27
|
+
// transform normal
|
|
28
|
+
const n_x = hit[3];
|
|
29
|
+
const n_y = hit[4];
|
|
30
|
+
const n_z = hit[5];
|
|
31
|
+
|
|
32
|
+
const result_n_x = m[0] * n_x + m[4] * n_y + m[8] * n_z;
|
|
33
|
+
const result_n_y = m[1] * n_x + m[5] * n_y + m[9] * n_z;
|
|
34
|
+
const result_n_z = m[2] * n_x + m[6] * n_y + m[10] * n_z;
|
|
35
|
+
|
|
36
|
+
const normal_multiplier = 1 / v3_length(result_n_x, result_n_y, result_n_z);
|
|
37
|
+
|
|
38
|
+
output[3] = result_n_x * normal_multiplier;
|
|
39
|
+
output[4] = result_n_y * normal_multiplier;
|
|
40
|
+
output[5] = result_n_z * normal_multiplier;
|
|
41
|
+
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { v3_dot } from "../../../../core/geom/v3_dot.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} out
|
|
6
|
+
* @param {number} output_offset
|
|
7
|
+
* @param {number[]} v
|
|
8
|
+
* @param {number} input_offset
|
|
9
|
+
* @param {number[]} n
|
|
10
|
+
* @param {number} normal_offset
|
|
11
|
+
*/
|
|
12
|
+
function ray_reflect(out, output_offset, v, input_offset, n, normal_offset) {
|
|
13
|
+
const input_x = v[0 + input_offset];
|
|
14
|
+
const input_y = v[1 + input_offset];
|
|
15
|
+
const input_z = v[2 + input_offset];
|
|
16
|
+
|
|
17
|
+
const nx = n[normal_offset + 0];
|
|
18
|
+
const ny = n[normal_offset + 1];
|
|
19
|
+
const nz = n[normal_offset + 2];
|
|
20
|
+
|
|
21
|
+
const dot = v3_dot(input_x, input_y, input_z, nx, ny, nz);
|
|
22
|
+
|
|
23
|
+
out[output_offset + 0] = input_x - 2 * dot * nx;
|
|
24
|
+
out[output_offset + 1] = input_y - 2 * dot * ny;
|
|
25
|
+
out[output_offset + 2] = input_z - 2 * dot * nz;
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} out
|
|
4
|
+
* @param {number} out_offset
|
|
5
|
+
* @param {number} a vertex index 0
|
|
6
|
+
* @param {number} b vertex index 0
|
|
7
|
+
* @param {number} c vertex index 0
|
|
8
|
+
* @param {number[]} attribute_array
|
|
9
|
+
* @param {number} dimensions
|
|
10
|
+
* @param {number} u
|
|
11
|
+
* @param {number} v
|
|
12
|
+
*/
|
|
13
|
+
export function sample_triangle_attribute(
|
|
14
|
+
out, out_offset,
|
|
15
|
+
a, b, c,
|
|
16
|
+
attribute_array, dimensions,
|
|
17
|
+
u, v
|
|
18
|
+
) {
|
|
19
|
+
|
|
20
|
+
const a_address = a * dimensions;
|
|
21
|
+
const b_address = b * dimensions;
|
|
22
|
+
const c_address = c * dimensions;
|
|
23
|
+
|
|
24
|
+
for (let i = 0; i < dimensions; i++) {
|
|
25
|
+
|
|
26
|
+
// construct edges
|
|
27
|
+
const a_v = attribute_array[a_address + i];
|
|
28
|
+
|
|
29
|
+
const edge1_v = attribute_array[b_address + i] - a_v;
|
|
30
|
+
const edge2_v = attribute_array[c_address + i] - a_v;
|
|
31
|
+
|
|
32
|
+
// sample edge
|
|
33
|
+
out[out_offset + i] = edge1_v * u + edge2_v * v + a_v;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { uint82float } from "../../../../core/binary/uint82float.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {number[]} out
|
|
6
|
+
* @param {number[]} input
|
|
7
|
+
*/
|
|
8
|
+
export function vec3_uint8_to_float(out, input) {
|
|
9
|
+
out[0] = uint82float(input[0]);
|
|
10
|
+
out[1] = uint82float(input[1]);
|
|
11
|
+
out[2] = uint82float(input[2]);
|
|
12
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Sampler2D } from "../../../texture/sampler/Sampler2D.js";
|
|
2
|
+
import { CanvasView } from "../../../../../view/elements/CanvasView.js";
|
|
3
|
+
import sampler2D2Canvas from "../../../texture/sampler/Sampler2D2Canvas.js";
|
|
4
|
+
import { vec3 } from "gl-matrix";
|
|
5
|
+
import { make_sky_hosek } from "../../path_tracer/make_sky_hosek.js";
|
|
6
|
+
|
|
7
|
+
const view = new CanvasView();
|
|
8
|
+
|
|
9
|
+
view.css({
|
|
10
|
+
position: 'fixed',
|
|
11
|
+
left: '10px',
|
|
12
|
+
top: '10px',
|
|
13
|
+
zIndex: 5
|
|
14
|
+
});
|
|
15
|
+
view.size.set(400, 400);
|
|
16
|
+
|
|
17
|
+
document.body.append(view.el);
|
|
18
|
+
|
|
19
|
+
view.link();
|
|
20
|
+
|
|
21
|
+
const sampler = Sampler2D.float32(4, 400, 400);
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const sky = make_sky_hosek(
|
|
25
|
+
[0, 0.8, 0.4],
|
|
26
|
+
1,
|
|
27
|
+
0,
|
|
28
|
+
[0,0,0]
|
|
29
|
+
);
|
|
30
|
+
const vl_halfPi = Math.PI / 2;
|
|
31
|
+
const color = [1, 1, 1, 1];
|
|
32
|
+
for (let i = 0; i < sampler.width; i++) {
|
|
33
|
+
const u = i / (sampler.width - 1);
|
|
34
|
+
|
|
35
|
+
const x = u * 2 - 1;
|
|
36
|
+
|
|
37
|
+
for (let j = 0; j < sampler.height; j++) {
|
|
38
|
+
const v = j / (sampler.height - 1);
|
|
39
|
+
|
|
40
|
+
const y = v * 2 - 1;
|
|
41
|
+
const y2 = y * y;
|
|
42
|
+
// fisheye projection
|
|
43
|
+
|
|
44
|
+
const x2 = x * x;
|
|
45
|
+
const h2 = x2 + y2;
|
|
46
|
+
|
|
47
|
+
const theta = vl_halfPi - vl_halfPi * Math.sqrt(h2);
|
|
48
|
+
const phi = Math.atan2(y, x);
|
|
49
|
+
const v_x = Math.cos(phi) * Math.cos(theta);
|
|
50
|
+
const v_y = Math.sin(phi) * Math.cos(theta);
|
|
51
|
+
const v_z = Math.sin(theta);
|
|
52
|
+
|
|
53
|
+
const direction = [v_x, v_z, v_y];
|
|
54
|
+
|
|
55
|
+
vec3.normalize(direction, direction);
|
|
56
|
+
|
|
57
|
+
sky(color, 0, direction, 0);
|
|
58
|
+
|
|
59
|
+
sampler.set(i, j, color);
|
|
60
|
+
|
|
61
|
+
// sampler.set(i, j, [f, f, f, 1]);
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
// sampler.set(i, sampler.height - 1, [f, f, f, 1]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log(sampler);
|
|
68
|
+
|
|
69
|
+
sampler2D2Canvas(sampler, 255, 0, view.el);
|
|
70
|
+
|
|
71
|
+
|