@woosh/meep-engine 2.43.53 → 2.44.0

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.
@@ -15,6 +15,9 @@ export class Cache<K, V> {
15
15
  capacity?: number
16
16
  })
17
17
 
18
+ readonly weight: number
19
+ readonly maxWeight: number
20
+
18
21
  size(): number
19
22
 
20
23
  put(k: K, v: V): void
@@ -0,0 +1,46 @@
1
+ import { read_frustum_corner } from "../../../../engine/graphics/render/forward_plus/read_frustum_corner.js";
2
+
3
+ /**
4
+ *
5
+ * @param {number[]} output
6
+ * @param {number} i_z_0
7
+ * @param {number} tr_xy_1
8
+ * @param {number} i_y_0
9
+ * @param {number} tr_x_1
10
+ * @param {number} i_x_0
11
+ * @param {number[]} cluster_frustum_points
12
+ */
13
+ export function read_cluster_frustum_corners(output, i_z_0, tr_xy_1, i_y_0, tr_x_1, i_x_0, cluster_frustum_points) {
14
+
15
+ // construct addressed of individual corner points
16
+
17
+ const frustum_point_index_000 = i_z_0 * tr_xy_1 + i_y_0 * tr_x_1 + i_x_0;
18
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_000, output, 0);
19
+
20
+ const i_x_1 = i_x_0 + 1;
21
+
22
+ const frustum_point_index_100 = i_z_0 * tr_xy_1 + i_y_0 * tr_x_1 + i_x_1;
23
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_100, output, 12);
24
+
25
+ const i_y_1 = i_y_0 + 1;
26
+
27
+ const frustum_point_index_010 = i_z_0 * tr_xy_1 + i_y_1 * tr_x_1 + i_x_0;
28
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_010, output, 6);
29
+
30
+ const frustum_point_index_110 = i_z_0 * tr_xy_1 + i_y_1 * tr_x_1 + i_x_1;
31
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_110, output, 18);
32
+
33
+ const i_z_1 = i_z_0 + 1;
34
+
35
+ const frustum_point_index_001 = i_z_1 * tr_xy_1 + i_y_0 * tr_x_1 + i_x_0;
36
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_001, output, 3);
37
+
38
+ const frustum_point_index_101 = i_z_1 * tr_xy_1 + i_y_0 * tr_x_1 + i_x_1;
39
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_101, output, 15);
40
+
41
+ const frustum_point_index_011 = i_z_1 * tr_xy_1 + i_y_1 * tr_x_1 + i_x_0;
42
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_011, output, 9);
43
+
44
+ const frustum_point_index_111 = i_z_1 * tr_xy_1 + i_y_1 * tr_x_1 + i_x_1;
45
+ read_frustum_corner(cluster_frustum_points, frustum_point_index_111, output, 21);
46
+ }
@@ -0,0 +1,92 @@
1
+ /**
2
+ * TODO compute slices to minimize world-space volume difference between clusters
3
+ * @param {number[]} input_frustum_corners corners of input frustum
4
+ * @param {number} tr_x slices in X axis
5
+ * @param {number} tr_y slices in Y axis
6
+ * @param {number} tr_z slices in Z axis
7
+ * @param {number[]} output_frustum_corners
8
+ */
9
+ export function slice_frustum_linear_to_points(input_frustum_corners, tr_x, tr_y, tr_z, output_frustum_corners) {
10
+ // read out view frustum scratch_corners
11
+ const x_000 = input_frustum_corners[0];
12
+ const y_000 = input_frustum_corners[1];
13
+ const z_000 = input_frustum_corners[2];
14
+
15
+ const x_001 = input_frustum_corners[3];
16
+ const y_001 = input_frustum_corners[4];
17
+ const z_001 = input_frustum_corners[5];
18
+
19
+ const x_010 = input_frustum_corners[6];
20
+ const y_010 = input_frustum_corners[7];
21
+ const z_010 = input_frustum_corners[8];
22
+
23
+ const x_011 = input_frustum_corners[9];
24
+ const y_011 = input_frustum_corners[10];
25
+ const z_011 = input_frustum_corners[11];
26
+
27
+ const x_100 = input_frustum_corners[12];
28
+ const y_100 = input_frustum_corners[13];
29
+ const z_100 = input_frustum_corners[14];
30
+
31
+ const x_101 = input_frustum_corners[15];
32
+ const y_101 = input_frustum_corners[16];
33
+ const z_101 = input_frustum_corners[17];
34
+
35
+ const x_110 = input_frustum_corners[18];
36
+ const y_110 = input_frustum_corners[19];
37
+ const z_110 = input_frustum_corners[20];
38
+
39
+ const x_111 = input_frustum_corners[21];
40
+ const y_111 = input_frustum_corners[22];
41
+ const z_111 = input_frustum_corners[23];
42
+
43
+
44
+ const x_plane_count = tr_x + 1;
45
+ const y_plane_count = tr_y + 1;
46
+ const z_plane_count = tr_z + 1;
47
+
48
+ const z_slice_stride = x_plane_count * y_plane_count;
49
+
50
+ for (let i_z = 0; i_z < z_plane_count; i_z++) {
51
+ const r_0 = i_z / (tr_z);
52
+ const r_1 = 1 - r_0;
53
+
54
+ const z_offset = i_z * z_slice_stride;
55
+
56
+ for (let i_y = 0; i_y < y_plane_count; i_y++) {
57
+
58
+ const v_0 = i_y / tr_y;
59
+ const v_1 = 1 - v_0;
60
+
61
+ const y_offset = z_offset + i_y * x_plane_count;
62
+
63
+ for (let i_x = 0; i_x < x_plane_count; i_x++) {
64
+ const u_0 = i_x / tr_x;
65
+ const u_1 = 1 - u_0;
66
+
67
+ const m_000 = u_1 * v_1 * r_1;
68
+ const m_001 = u_1 * v_1 * r_0;
69
+ const m_010 = u_1 * v_0 * r_1;
70
+ const m_011 = u_1 * v_0 * r_0;
71
+ const m_100 = u_0 * v_1 * r_1;
72
+ const m_101 = u_0 * v_1 * r_0;
73
+ const m_110 = u_0 * v_0 * r_1;
74
+ const m_111 = u_0 * v_0 * r_0;
75
+
76
+ // interpolate view frustum scratch_corners
77
+ const x = x_000 * m_000 + x_001 * m_001 + x_010 * m_010 + x_011 * m_011 + x_100 * m_100 + x_101 * m_101 + x_110 * m_110 + x_111 * m_111;
78
+ const y = y_000 * m_000 + y_001 * m_001 + y_010 * m_010 + y_011 * m_011 + y_100 * m_100 + y_101 * m_101 + y_110 * m_110 + y_111 * m_111;
79
+ const z = z_000 * m_000 + z_001 * m_001 + z_010 * m_010 + z_011 * m_011 + z_100 * m_100 + z_101 * m_101 + z_110 * m_110 + z_111 * m_111;
80
+
81
+ // write out cluster corner position
82
+ const index = y_offset + i_x
83
+ const address = index * 3;
84
+
85
+ output_frustum_corners[address] = x;
86
+ output_frustum_corners[address + 1] = y;
87
+ output_frustum_corners[address + 2] = z;
88
+ }
89
+
90
+ }
91
+ }
92
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ *
3
+ * @param {{id:number}} a
4
+ * @param {{id:number}} b
5
+ * @returns {number}
6
+ */
7
+ export function compareObjectsByNumericId(a,b){
8
+ return a.id - b.id;
9
+ }
@@ -272,7 +272,9 @@ function makeNormalTestGridDecal(ecd, root_transform = new Transform()) {
272
272
 
273
273
  const GRID_SIZE = 9;
274
274
 
275
- const SPACING = 2;
275
+ const CELL_SIZE = 1;
276
+
277
+ const SPACING = CELL_SIZE*1.2;
276
278
 
277
279
  const DEBUG_BOX = makeHelperBoxGeometry();
278
280
 
@@ -300,7 +302,7 @@ function makeNormalTestGridDecal(ecd, root_transform = new Transform()) {
300
302
  SPACING * j,
301
303
  0,
302
304
  );
303
- transform.scale.setScalar(3);
305
+ transform.scale.setScalar(CELL_SIZE);
304
306
  transform.rotation._lookRotation(direction[0],direction[2], direction[1] , 0, 1, 0);
305
307
 
306
308
  transform.multiplyTransforms(root_transform, transform);