@woosh/meep-engine 3.5.0 → 3.7.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.
Files changed (30) hide show
  1. package/package.json +1 -1
  2. package/src/core/geom/3d/gjk/gjk_epa_penetration.d.ts +30 -3
  3. package/src/core/geom/3d/gjk/gjk_epa_penetration.d.ts.map +1 -1
  4. package/src/core/geom/3d/gjk/gjk_epa_penetration.js +83 -10
  5. package/src/core/geom/3d/gjk/mpr.d.ts +7 -1
  6. package/src/core/geom/3d/gjk/mpr.d.ts.map +1 -1
  7. package/src/core/geom/3d/gjk/mpr.js +76 -13
  8. package/src/engine/graphics3/GraphicsEngine3.d.ts +10 -5
  9. package/src/engine/graphics3/GraphicsEngine3.d.ts.map +1 -1
  10. package/src/engine/graphics3/GraphicsEngine3.js +10 -5
  11. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  12. package/src/engine/physics/narrowphase/narrowphase_step.js +20 -2
  13. package/src/engine/physics/queries/shape_cast.d.ts +15 -10
  14. package/src/engine/physics/queries/shape_cast.d.ts.map +1 -1
  15. package/src/engine/physics/queries/shape_cast.js +620 -417
  16. package/src/shade/renderer/global_illumination/brick4/gpu/bake/brick4_bake_basic.js +2 -2
  17. package/src/shade/renderer/scene/bvh/StaticSceneBVH.js +4 -4
  18. package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +1 -1
  19. package/src/engine/graphics/sh3/build_injected_shader.d.ts +0 -51
  20. package/src/engine/graphics/sh3/build_injected_shader.d.ts.map +0 -1
  21. package/src/engine/graphics/sh3/build_injected_shader.js +0 -56
  22. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts +0 -9
  23. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +0 -1
  24. package/src/engine/graphics/sh3/fromCubeRenderTarget.js +0 -142
  25. package/src/engine/graphics/sh3/shader/visualize.frag.d.ts +0 -3
  26. package/src/engine/graphics/sh3/shader/visualize.frag.d.ts.map +0 -1
  27. package/src/engine/graphics/sh3/shader/visualize.frag.js +0 -51
  28. package/src/engine/graphics/sh3/shader/visualize.vert.d.ts +0 -3
  29. package/src/engine/graphics/sh3/shader/visualize.vert.d.ts.map +0 -1
  30. package/src/engine/graphics/sh3/shader/visualize.vert.js +0 -12
@@ -142,7 +142,7 @@ export async function brick4_bake_basic({
142
142
 
143
143
  const cycle_seed = randomIntegerBetween(random, 0, 0xFFFFFFFF) >>> 0;
144
144
 
145
- graph_compute_pass({
145
+ const bake_pass_outputs = graph_compute_pass({
146
146
  graph,
147
147
  shader: shader_brick4_bake_probes,
148
148
  group_count: [dispatch_x],
@@ -186,7 +186,7 @@ export async function brick4_bake_basic({
186
186
  sample_count: SAMPLES_PER_PROBE,
187
187
  output_offset: i,
188
188
  },
189
- input: gr_cycle_trace_data,
189
+ input: bake_pass_outputs.output,
190
190
  output: gr_encoded_probe_results,
191
191
  }
192
192
  })
@@ -390,10 +390,10 @@ export class StaticSceneBVH {
390
390
  let nearest_distance = ray.tMax;
391
391
 
392
392
  const hit_count = bvh_query_user_data_ray(
393
- bvh,
394
- bvh.root,
395
393
  scratch_instance_hits,
396
394
  0,
395
+ bvh,
396
+ bvh.root,
397
397
  ray.origin_x, ray.origin_y, ray.origin_z,
398
398
  ray.direction_x, ray.direction_y, ray.direction_z
399
399
  );
@@ -501,10 +501,10 @@ export class StaticSceneBVH {
501
501
  const bvh = this.instance_bvh;
502
502
 
503
503
  const hit_count = bvh_query_user_data_ray(
504
- bvh,
505
- bvh.root,
506
504
  scratch_instance_hits,
507
505
  0,
506
+ bvh,
507
+ bvh.root,
508
508
  ray.origin_x, ray.origin_y, ray.origin_z,
509
509
  ray.direction_x, ray.direction_y, ray.direction_z
510
510
  );
@@ -83,7 +83,7 @@ const DEFAULT_SHADOWMAP_LOCAL_RESOLUTION = 128;
83
83
  * its turn without permanently starving other lights.
84
84
  * @type {number}
85
85
  */
86
- const SHADOWMAP_UPDATE_BUDGET = 32;
86
+ const SHADOWMAP_UPDATE_BUDGET = 8;
87
87
 
88
88
  /**
89
89
  * Shadows for a single scene
@@ -1,51 +0,0 @@
1
- /**
2
- * Prepend a preamble to a three.js-generated shader and splice a chunk in after
3
- * a named anchor.
4
- *
5
- * WHY THIS EXISTS
6
- *
7
- * The LPV/GI and LPG material paths have eight shader builders between them
8
- * (`space_fragment` and `space_vertex`, vertex and fragment, times two
9
- * subsystems) and every one of them was the same three statements: concatenate
10
- * the preambles ahead of the source, `insert_after` an anchor, return. What
11
- * actually differs is data — which preamble, which anchor, which chunk.
12
- *
13
- * More importantly the two anchors were spelled out in eight separate string
14
- * literals. They are three.js's own chunk include lines, and a mismatch fails
15
- * *quietly* (a console warning and an unmodified shader), so having one
16
- * definition each is worth more than the lines it saves.
17
- *
18
- * Shader assembly happens once per material compile, not per frame.
19
- *
20
- * @param {string} source shader source three.js handed to `onBeforeCompile`
21
- * @param {string} preamble prepended verbatim, ahead of the source
22
- * @param {string} anchor see {@link GLSL_ANCHOR_LIGHTS_FRAGMENT_BEGIN} / {@link GLSL_ANCHOR_FOG_VERTEX}
23
- * @param {string} chunk GLSL spliced in directly after `anchor`
24
- * @returns {string}
25
- */
26
- export function build_injected_shader(source: string, preamble: string, anchor: string, chunk: string): string;
27
- /**
28
- * three.js chunk marker after which a probe-field contribution is added to
29
- * `irradiance` in the fragment stage.
30
- *
31
- * `<lights_fragment_begin>` is where three declares `irradiance` and has not yet
32
- * consumed it, so anything added immediately after it participates in the
33
- * lighting equations normally. The literal must match three's include line
34
- * exactly — `insert_after` warns and silently returns the source unchanged when
35
- * it does not find the term, which shows up as GI simply not appearing.
36
- *
37
- * @type {string}
38
- */
39
- export const GLSL_ANCHOR_LIGHTS_FRAGMENT_BEGIN: string;
40
- /**
41
- * three.js chunk marker after which per-vertex probe work is injected.
42
- *
43
- * `<fog_vertex>` is the last chunk in the standard vertex `main()`, so by that
44
- * point `worldPosition` (when declared), `position` and `normal` are all
45
- * available. Same exact-match requirement as
46
- * {@link GLSL_ANCHOR_LIGHTS_FRAGMENT_BEGIN}.
47
- *
48
- * @type {string}
49
- */
50
- export const GLSL_ANCHOR_FOG_VERTEX: string;
51
- //# sourceMappingURL=build_injected_shader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build_injected_shader.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/sh3/build_injected_shader.js"],"names":[],"mappings":"AA4BA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,8CANW,MAAM,YACN,MAAM,UACN,MAAM,SACN,MAAM,GACJ,MAAM,CAIlB;AArDD;;;;;;;;;;;GAWG;AACH,gDAFU,MAAM,CAEoE;AAEpF;;;;;;;;;GASG;AACH,qCAFU,MAAM,CAE8C"}
@@ -1,56 +0,0 @@
1
- import { insert_after } from "../../../core/primitives/strings/insert_after.js";
2
-
3
- /**
4
- * three.js chunk marker after which a probe-field contribution is added to
5
- * `irradiance` in the fragment stage.
6
- *
7
- * `<lights_fragment_begin>` is where three declares `irradiance` and has not yet
8
- * consumed it, so anything added immediately after it participates in the
9
- * lighting equations normally. The literal must match three's include line
10
- * exactly — `insert_after` warns and silently returns the source unchanged when
11
- * it does not find the term, which shows up as GI simply not appearing.
12
- *
13
- * @type {string}
14
- */
15
- export const GLSL_ANCHOR_LIGHTS_FRAGMENT_BEGIN = '#include <lights_fragment_begin>';
16
-
17
- /**
18
- * three.js chunk marker after which per-vertex probe work is injected.
19
- *
20
- * `<fog_vertex>` is the last chunk in the standard vertex `main()`, so by that
21
- * point `worldPosition` (when declared), `position` and `normal` are all
22
- * available. Same exact-match requirement as
23
- * {@link GLSL_ANCHOR_LIGHTS_FRAGMENT_BEGIN}.
24
- *
25
- * @type {string}
26
- */
27
- export const GLSL_ANCHOR_FOG_VERTEX = '#include <fog_vertex>';
28
-
29
- /**
30
- * Prepend a preamble to a three.js-generated shader and splice a chunk in after
31
- * a named anchor.
32
- *
33
- * WHY THIS EXISTS
34
- *
35
- * The LPV/GI and LPG material paths have eight shader builders between them
36
- * (`space_fragment` and `space_vertex`, vertex and fragment, times two
37
- * subsystems) and every one of them was the same three statements: concatenate
38
- * the preambles ahead of the source, `insert_after` an anchor, return. What
39
- * actually differs is data — which preamble, which anchor, which chunk.
40
- *
41
- * More importantly the two anchors were spelled out in eight separate string
42
- * literals. They are three.js's own chunk include lines, and a mismatch fails
43
- * *quietly* (a console warning and an unmodified shader), so having one
44
- * definition each is worth more than the lines it saves.
45
- *
46
- * Shader assembly happens once per material compile, not per frame.
47
- *
48
- * @param {string} source shader source three.js handed to `onBeforeCompile`
49
- * @param {string} preamble prepended verbatim, ahead of the source
50
- * @param {string} anchor see {@link GLSL_ANCHOR_LIGHTS_FRAGMENT_BEGIN} / {@link GLSL_ANCHOR_FOG_VERTEX}
51
- * @param {string} chunk GLSL spliced in directly after `anchor`
52
- * @returns {string}
53
- */
54
- export function build_injected_shader(source, preamble, anchor, chunk) {
55
- return insert_after(preamble + source, anchor, chunk);
56
- }
@@ -1,9 +0,0 @@
1
- /**
2
- *
3
- * @param {Uint8Array} data
4
- * @param {THREE.WebGLRenderer} renderer
5
- * @param {THREE.WebGLCubeRenderTarget} cubeRenderTarget
6
- * @return {Float64Array}
7
- */
8
- export function fromCubeRenderTarget(data: Uint8Array, renderer: THREE.WebGLRenderer, cubeRenderTarget: THREE.WebGLCubeRenderTarget): Float64Array;
9
- //# sourceMappingURL=fromCubeRenderTarget.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fromCubeRenderTarget.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/sh3/fromCubeRenderTarget.js"],"names":[],"mappings":"AAQA;;;;;;GAMG;AACH,2CALW,UAAU,iFAGT,YAAY,CAgIvB"}
@@ -1,142 +0,0 @@
1
- import { sh3_basis_at } from "../../../core/geom/3d/sphere/harmonics/sh3_basis_at.js";
2
- import { sh3_dering_optimize_positive } from "../../../core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js";
3
- import { sh3_vector_accumulate } from "../../../core/geom/3d/sphere/harmonics/sh3_vector_accumulate.js";
4
- import { vector_scale_offset } from "../../../core/geom/vec/vector_scale_offset.js";
5
- import { v3_length_sqr } from "../../../core/geom/vec3/v3_length_sqr.js";
6
-
7
- const scratch_color = new Float32Array(3);
8
-
9
- /**
10
- *
11
- * @param {Uint8Array} data
12
- * @param {THREE.WebGLRenderer} renderer
13
- * @param {THREE.WebGLCubeRenderTarget} cubeRenderTarget
14
- * @return {Float64Array}
15
- */
16
- export function fromCubeRenderTarget(
17
- data,
18
- renderer,
19
- cubeRenderTarget
20
- ) {
21
-
22
- // The renderTarget must be set to RGBA in order to make readRenderTargetPixels works
23
- let total_weight = 0;
24
-
25
- const __shared_buffer = new ArrayBuffer((27 + 9) * 8);
26
-
27
- const sh_basis = new Float64Array(__shared_buffer, 0, 9);
28
- const coefficients = new Float64Array(__shared_buffer, 9 * 8, 27);
29
-
30
- const image_size = cubeRenderTarget.width;
31
-
32
- const pixel_size = 2 / image_size;
33
-
34
- let normal_x = 0, normal_y = 0, normal_z = 0;
35
-
36
- for (let faceIndex = 0; faceIndex < 6; faceIndex++) {
37
-
38
- renderer.readRenderTargetPixels(cubeRenderTarget, 0, 0, image_size, image_size, data, faceIndex);
39
-
40
- // RGBA assumed
41
-
42
- for (let i = 0, il = data.length; i < il; i += 4) {
43
-
44
-
45
- // pixel coordinate on unit cube
46
-
47
- const pixelIndex = i / 4;
48
-
49
- const col = -1 + (pixelIndex % image_size + 0.5) * pixel_size;
50
-
51
- const row = 1 - (Math.floor(pixelIndex / image_size) + 0.5) * pixel_size;
52
-
53
-
54
- switch (faceIndex) {
55
-
56
- case 0:
57
- normal_x = 1;
58
- normal_y = row;
59
- normal_z = -col;
60
- break;
61
-
62
- case 1:
63
- normal_x = -1;
64
- normal_y = row;
65
- normal_z = col;
66
- break;
67
-
68
- case 2:
69
- normal_x = col;
70
- normal_y = 1;
71
- normal_z = -row;
72
- break;
73
-
74
- case 3:
75
- normal_x = col;
76
- normal_y = -1;
77
- normal_z = row;
78
- break;
79
-
80
- case 4:
81
- normal_x = col;
82
- normal_y = row;
83
- normal_z = 1;
84
- break;
85
-
86
- case 5:
87
- normal_x = -col;
88
- normal_y = row;
89
- normal_z = -1;
90
- break;
91
-
92
- }
93
-
94
- // weight assigned to this pixel
95
-
96
- const length_squared = v3_length_sqr(normal_x, normal_y, normal_z);
97
-
98
- const length = Math.sqrt(length_squared);
99
-
100
- const weight = 4 / (length * length_squared);
101
-
102
- total_weight += weight;
103
-
104
- // direction vector to this pixel
105
- normal_x /= length;
106
- normal_y /= length;
107
- normal_z /= length;
108
-
109
- // evaluate SH basis functions in direction dir
110
- sh3_basis_at(normal_x, normal_y, normal_z, sh_basis);
111
-
112
- // pixel color, already in linear space so no sRGB->Linear conversion necessary
113
-
114
- // 0.003921 constant value is 1/255, a conversion value from UINT8 to normalized float
115
- const weight_conv = weight * 0.00392156862745098;
116
-
117
- scratch_color[0] = data[i] * weight_conv;
118
- scratch_color[1] = data[i + 1] * weight_conv;
119
- scratch_color[2] = data[i + 2] * weight_conv;
120
-
121
- // accumulate
122
- sh3_vector_accumulate(
123
- coefficients, 0,
124
- sh_basis, 0,
125
- scratch_color, 0,
126
- 3
127
- );
128
-
129
- }
130
-
131
- }
132
-
133
- // normalize
134
- const norm = (4 * Math.PI) / total_weight;
135
-
136
- vector_scale_offset(coefficients, 0, coefficients, 0, 27, norm);
137
-
138
- sh3_dering_optimize_positive(coefficients, 0, coefficients, 0, 3);
139
-
140
- return coefficients;
141
-
142
- }
@@ -1,3 +0,0 @@
1
- declare const _default: "\n#define RECIPROCAL_PI 0.318309886\n\nvec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {\n // matrix is assumed to be orthogonal\n return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );\n}\n\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\n//\n// SIGN CONVENTION: coefficients 1, 3, 5 and 7 are SUBTRACTED here, matching\n// three.js's SphericalHarmonics3 and the JS reference\n// core/geom/3d/sphere/harmonics/sh3_sample_irradiance_by_direction.js. The LPV\n// and LPG shader chunks (sh3/{gi,lpg}/material/chunk_*_get_irradiance_at.js)\n// ADD them instead — see the note in chunk_lpv_get_irradiance_at.js. The\n// constants are the same in all four; only these signs differ.\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n // normal is assumed to have unit length\n float x = normal.x, y = normal.y, z = normal.z;\n\n // band 0\n vec3 result = shCoefficients[ 0 ] * 0.8862269254527579;\n\n // band 1\n result -= shCoefficients[ 1 ] * 1.0233267079464885 * y;\n result += shCoefficients[ 2 ] * 1.0233267079464885 * z;\n result -= shCoefficients[ 3 ] * 1.0233267079464885 * x;\n\n // band 2\n result += shCoefficients[ 4 ] * 0.8580855308097834 * x * y;\n result -= shCoefficients[ 5 ] * 0.8580855308097834 * y * z;\n result += shCoefficients[ 6 ] * ( 0.7431238683011272 * z * z - 0.24770795610037571 );\n result -= shCoefficients[ 7 ] * 0.8580855308097834 * x * z;\n result += shCoefficients[ 8 ] * 0.4290427654048917 * ( x * x - y * y );\n\n return result;\n}\n\nuniform vec3 sh[ 9 ]; // sh coefficients\nuniform float intensity; // light probe intensity\nvarying vec3 vNormal;\n\nvoid main() {\n vec3 normal = normalize( vNormal );\n vec3 worldNormal = normalize(inverseTransformDirection( normal, viewMatrix ));\n vec3 irradiance = shGetIrradianceAt( worldNormal, sh );\n vec3 outgoingLight = 1.0 * irradiance * intensity;\n gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );\n}\n";
2
- export default _default;
3
- //# sourceMappingURL=visualize.frag.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"visualize.frag.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/shader/visualize.frag.js"],"names":[],"mappings":""}
@@ -1,51 +0,0 @@
1
- // language=GLSL
2
- export default `
3
- #define RECIPROCAL_PI 0.318309886
4
-
5
- vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
6
- // matrix is assumed to be orthogonal
7
- return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
8
- }
9
-
10
- // source: https://graphics.stanford.edu/papers/envmap/envmap.pdf
11
- //
12
- // SIGN CONVENTION: coefficients 1, 3, 5 and 7 are SUBTRACTED here, matching
13
- // three.js's SphericalHarmonics3 and the JS reference
14
- // core/geom/3d/sphere/harmonics/sh3_sample_irradiance_by_direction.js. The LPV
15
- // and LPG shader chunks (sh3/{gi,lpg}/material/chunk_*_get_irradiance_at.js)
16
- // ADD them instead — see the note in chunk_lpv_get_irradiance_at.js. The
17
- // constants are the same in all four; only these signs differ.
18
- vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
19
- // normal is assumed to have unit length
20
- float x = normal.x, y = normal.y, z = normal.z;
21
-
22
- // band 0
23
- vec3 result = shCoefficients[ 0 ] * 0.8862269254527579;
24
-
25
- // band 1
26
- result -= shCoefficients[ 1 ] * 1.0233267079464885 * y;
27
- result += shCoefficients[ 2 ] * 1.0233267079464885 * z;
28
- result -= shCoefficients[ 3 ] * 1.0233267079464885 * x;
29
-
30
- // band 2
31
- result += shCoefficients[ 4 ] * 0.8580855308097834 * x * y;
32
- result -= shCoefficients[ 5 ] * 0.8580855308097834 * y * z;
33
- result += shCoefficients[ 6 ] * ( 0.7431238683011272 * z * z - 0.24770795610037571 );
34
- result -= shCoefficients[ 7 ] * 0.8580855308097834 * x * z;
35
- result += shCoefficients[ 8 ] * 0.4290427654048917 * ( x * x - y * y );
36
-
37
- return result;
38
- }
39
-
40
- uniform vec3 sh[ 9 ]; // sh coefficients
41
- uniform float intensity; // light probe intensity
42
- varying vec3 vNormal;
43
-
44
- void main() {
45
- vec3 normal = normalize( vNormal );
46
- vec3 worldNormal = normalize(inverseTransformDirection( normal, viewMatrix ));
47
- vec3 irradiance = shGetIrradianceAt( worldNormal, sh );
48
- vec3 outgoingLight = 1.0 * irradiance * intensity;
49
- gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );
50
- }
51
- `
@@ -1,3 +0,0 @@
1
- declare const _default: "\nvarying vec3 vNormal;\n\nvoid main() {\n\n vNormal = normalize( normalMatrix * normal );\n\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n}\n";
2
- export default _default;
3
- //# sourceMappingURL=visualize.vert.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"visualize.vert.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/graphics/sh3/shader/visualize.vert.js"],"names":[],"mappings":""}
@@ -1,12 +0,0 @@
1
- // language=GLSL
2
- export default `
3
- varying vec3 vNormal;
4
-
5
- void main() {
6
-
7
- vNormal = normalize( normalMatrix * normal );
8
-
9
- gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
10
-
11
- }
12
- `