@woosh/meep-engine 2.43.37 → 2.43.38

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.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * evaluate the basis functions
3
+ * shBasis is an Array[ 9 ]
4
+ *
5
+ * @param {number} x
6
+ * @param {number} y
7
+ * @param {number} z
8
+ * @param {number[]|ArrayLike<number>|Float32Array|Float64Array} shBasis
9
+ */
10
+ export function sh3_basis_at(x, y, z, shBasis) {
11
+
12
+ // normal is assumed to be unit length
13
+
14
+
15
+ // band 0
16
+ shBasis[0] = 0.282095;
17
+
18
+ // band 1
19
+ shBasis[1] = 0.488603 * y;
20
+ shBasis[2] = 0.488603 * z;
21
+ shBasis[3] = 0.488603 * x;
22
+
23
+ // band 2
24
+ shBasis[4] = 1.092548 * x * y;
25
+ shBasis[5] = 1.092548 * y * z;
26
+ shBasis[6] = 0.315392 * (3 * z * z - 1);
27
+ shBasis[7] = 1.092548 * x * z;
28
+ shBasis[8] = 0.546274 * (x * x - y * y);
29
+
30
+ }
@@ -27,21 +27,22 @@ export function sh3_sample_by_direction(
27
27
  let channel_value;
28
28
 
29
29
  for (let i = 0; i < dimension_count; i++) {
30
+ const offset = harmonics_offset + dimension_count * i;
30
31
 
31
32
  // band 0
32
- channel_value = harmonics[harmonics_offset + i] * 0.282095;
33
+ channel_value = harmonics[offset] * 0.282095;
33
34
 
34
35
  // band 1
35
- channel_value += harmonics[harmonics_offset + dimension_count + i] * 0.488603 * y;
36
- channel_value += harmonics[harmonics_offset + dimension_count * 2 + i] * 0.488603 * z;
37
- channel_value += harmonics[harmonics_offset + dimension_count * 3 + i] * 0.488603 * x;
36
+ channel_value += harmonics[offset + 1] * 0.488603 * y;
37
+ channel_value += harmonics[offset + 2] * 0.488603 * z;
38
+ channel_value += harmonics[offset + 3] * 0.488603 * x;
38
39
 
39
40
  // band 2
40
- channel_value += harmonics[harmonics_offset + dimension_count * 4 + i] * 1.092548 * (x * y);
41
- channel_value += harmonics[harmonics_offset + dimension_count * 5 + i] * 1.092548 * (y * z);
42
- channel_value += harmonics[harmonics_offset + dimension_count * 6 + i] * 0.315392 * (3.0 * z * z - 1.0);
43
- channel_value += harmonics[harmonics_offset + dimension_count * 7 + i] * 1.092548 * (x * z);
44
- channel_value += harmonics[harmonics_offset + dimension_count * 8 + i] * 0.546274 * (x * x - y * y);
41
+ channel_value += harmonics[offset + 4] * 1.092548 * (x * y);
42
+ channel_value += harmonics[offset + 5] * 1.092548 * (y * z);
43
+ channel_value += harmonics[offset + 6] * 0.315392 * (3.0 * z * z - 1.0);
44
+ channel_value += harmonics[offset + 7] * 1.092548 * (x * z);
45
+ channel_value += harmonics[offset + 8] * 0.546274 * (x * x - y * y);
45
46
 
46
47
  // write out
47
48
  result[result_offset + i] = channel_value;
@@ -29,40 +29,10 @@ import { build_three_object } from "../ecs/mesh-v2/build_three_object.js";
29
29
  import { ShadedGeometryFlags } from "../ecs/mesh-v2/ShadedGeometryFlags.js";
30
30
  import { v3_length_sqr } from "../../../core/geom/v3_length_sqr.js";
31
31
  import { sh3_dering_optimize_positive } from "../../../core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js";
32
+ import { sh3_basis_at } from "../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
32
33
 
33
34
  const TEMP_CONTACT = new SurfacePoint3();
34
35
 
35
- /**
36
- * evaluate the basis functions
37
- * shBasis is an Array[ 9 ]
38
- *
39
- * @param {number} x
40
- * @param {number} y
41
- * @param {number} z
42
- * @param {number[]|ArrayLike<number>|Float32Array|Float64Array} shBasis
43
- */
44
- function getBasisAt(x, y, z, shBasis) {
45
-
46
- // normal is assumed to be unit length
47
-
48
-
49
- // band 0
50
- shBasis[0] = 0.282095;
51
-
52
- // band 1
53
- shBasis[1] = 0.488603 * y;
54
- shBasis[2] = 0.488603 * z;
55
- shBasis[3] = 0.488603 * x;
56
-
57
- // band 2
58
- shBasis[4] = 1.092548 * x * y;
59
- shBasis[5] = 1.092548 * y * z;
60
- shBasis[6] = 0.315392 * (3 * z * z - 1);
61
- shBasis[7] = 1.092548 * x * z;
62
- shBasis[8] = 0.546274 * (x * x - y * y);
63
-
64
- }
65
-
66
36
  /**
67
37
  *
68
38
  * @param {Uint8Array} data
@@ -160,7 +130,7 @@ function fromCubeRenderTarget(data, renderer, cubeRenderTarget) {
160
130
  normal_z /= length;
161
131
 
162
132
  // evaluate SH basis functions in direction dir
163
- getBasisAt(normal_x, normal_y, normal_z, sh_basis);
133
+ sh3_basis_at(normal_x, normal_y, normal_z, sh_basis);
164
134
 
165
135
  // pixel color, already in linear space so no sRGB->Linear conversion necessary
166
136
 
@@ -266,7 +236,7 @@ class CubeRenderer {
266
236
  //
267
237
  // object3D.material.color.copy(source_material.color);
268
238
  // } else {
269
- object3D.material = source_material.clone();
239
+ object3D.material = source_material.clone();
270
240
  // }
271
241
 
272
242
  applyTransformToThreeObject(object3D, t);
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.43.37",
8
+ "version": "2.43.38",
9
9
  "dependencies": {
10
10
  "gl-matrix": "3.4.3",
11
11
  "fast-levenshtein": "2.0.6",