@woosh/meep-engine 2.43.16 → 2.43.18

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.
Files changed (53) hide show
  1. package/core/assert.js +3 -1
  2. package/core/bvh2/aabb3/aabb3_intersects_ray.js +14 -9
  3. package/core/bvh2/aabb3/aabb3_intersects_ray_branchless.js +52 -0
  4. package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.d.ts +2 -0
  5. package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +214 -5
  6. package/core/bvh2/bvh3/bvh_query_leaves_ray.js +32 -29
  7. package/core/collection/array/typed/typed_array_copy.js +2 -2
  8. package/core/geom/3d/aabb/compute_aabb_from_points.js +4 -3
  9. package/core/geom/3d/compute_triangle_normal.js +76 -0
  10. package/core/geom/3d/topology/samples/sampleFloodFill.js +1 -1
  11. package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +1 -1
  12. package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +1 -1
  13. package/core/geom/3d/topology/struct/TopoTriangle.js +1 -57
  14. package/core/geom/3d/topology/tm_face_normal.js +1 -1
  15. package/core/geom/3d/topology/tm_vertex_compute_normal.js +1 -1
  16. package/core/geom/3d/triangle/computeTriangleRayIntersection.js +195 -27
  17. package/core/geom/Vector3.js +12 -12
  18. package/core/math/physics/brdf/D_GGX.js +13 -0
  19. package/editor/tools/v2/prototypeTransformControls.js +14 -2
  20. package/engine/ecs/parent/EntityNode.js +80 -7
  21. package/engine/ecs/parent/EntityNodeFlags.js +8 -0
  22. package/engine/ecs/terrain/tiles/TerrainTile.js +7 -9
  23. package/engine/graphics/ecs/path/PathDisplaySystem.d.ts +3 -0
  24. package/engine/graphics/ecs/path/PathDisplaySystem.js +10 -0
  25. package/engine/graphics/geometry/AttributeSpec.js +18 -3
  26. package/engine/graphics/geometry/VertexDataSpec.js +53 -3
  27. package/engine/graphics/micron/format/VirtualGeometry.js +7 -0
  28. package/engine/graphics/micron/render/VirtualGeometryBuilder.js +1 -1
  29. package/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +5 -2
  30. package/engine/graphics/particles/particular/engine/parameter/sample/RGBA_LUT_HEATMAP_IR.js +11 -0
  31. package/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +2 -9
  32. package/engine/graphics/sh3/README.md +1 -0
  33. package/engine/graphics/sh3/path_tracer/GeometryBVHBatched.js +324 -0
  34. package/engine/graphics/sh3/path_tracer/PathTracedMesh.js +85 -0
  35. package/engine/graphics/sh3/path_tracer/PathTracer.js +469 -0
  36. package/engine/graphics/sh3/path_tracer/apply_texture_clamping_to_coordinate.js +22 -0
  37. package/engine/graphics/sh3/path_tracer/compute_triangle_group_aabb3.js +36 -0
  38. package/engine/graphics/sh3/path_tracer/getBiasedNormalSample.js +55 -0
  39. package/engine/graphics/sh3/path_tracer/make_sky_hosek.js +44 -0
  40. package/engine/graphics/sh3/path_tracer/make_sky_rtiw.js +15 -0
  41. package/engine/graphics/sh3/path_tracer/prototypePathTracer.js +619 -0
  42. package/engine/graphics/sh3/path_tracer/random_in_hemisphere.js +39 -0
  43. package/engine/graphics/sh3/path_tracer/ray_hit_apply_transform.js +42 -0
  44. package/engine/graphics/sh3/path_tracer/ray_reflect.js +27 -0
  45. package/engine/graphics/sh3/path_tracer/sample_triangle_attribute.js +35 -0
  46. package/engine/graphics/sh3/path_tracer/vec3_uint8_to_float.js +12 -0
  47. package/engine/graphics/sh3/sky/hosek/README.md +4 -0
  48. package/engine/graphics/sh3/sky/hosek/prototype_hosek.js +71 -0
  49. package/engine/graphics/sh3/sky/hosek/sky_hosek_compute_irradiance_by_direction.js +4171 -0
  50. package/engine/graphics/texture/sampler/convertTexture2Sampler2D.js +2 -0
  51. package/package.json +1 -1
  52. package/view/elements/progress/SmoothProgressBar.js +1 -1
  53. package/view/task/TaskProgressView.js +6 -8
@@ -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,4 @@
1
+ based on The Hosek Clear Sky model. (From "An Analytic Model for Full Spectral Sky-Dome Radiance", Hosek & Wilkie.)
2
+
3
+ code is heavily influenced by this implementation:
4
+ https://github.com/andrewwillmott/sun-sky
@@ -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
+