@woosh/meep-engine 3.4.0 → 3.6.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 (66) 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/Engine.js +2 -2
  9. package/src/engine/graphics/CONTEXT_LOSS_RECOVERY_PLAN.md +1 -1
  10. package/src/engine/graphics3/GraphicsEngine3.d.ts +7 -0
  11. package/src/engine/graphics3/GraphicsEngine3.d.ts.map +1 -1
  12. package/src/engine/graphics3/GraphicsEngine3.js +9 -0
  13. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  14. package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
  15. package/src/engine/physics/narrowphase/narrowphase_step.js +20 -2
  16. package/src/shade/playground/skinned_blas_refit/README.md +56 -33
  17. package/src/shade/playground/skinned_blas_refit/place_character.d.ts +2 -1
  18. package/src/shade/playground/skinned_blas_refit/place_character.d.ts.map +1 -1
  19. package/src/shade/playground/skinned_blas_refit/place_character.js +2 -1
  20. package/src/shade/renderer/scene/bvh/StaticSceneBVH.js +4 -4
  21. package/src/view/graphics/{WebGLContextFailureView.d.ts → GraphicsContextFailureView.d.ts} +2 -2
  22. package/src/view/graphics/GraphicsContextFailureView.d.ts.map +1 -0
  23. package/src/view/graphics/{WebGLContextFailureView.js → GraphicsContextFailureView.js} +1 -1
  24. package/src/core/geom/3d/aabb/aabb3_from_three_geometry.d.ts +0 -7
  25. package/src/core/geom/3d/aabb/aabb3_from_three_geometry.d.ts.map +0 -1
  26. package/src/core/geom/3d/aabb/aabb3_from_three_geometry.js +0 -18
  27. package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.d.ts +0 -7
  28. package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.d.ts.map +0 -1
  29. package/src/core/geom/3d/aabb/aabb3_from_threejs_geometry.js +0 -7
  30. package/src/engine/ecs/transform/copy_three_transform.d.ts +0 -7
  31. package/src/engine/ecs/transform/copy_three_transform.d.ts.map +0 -1
  32. package/src/engine/ecs/transform/copy_three_transform.js +0 -15
  33. package/src/engine/graphics/ecs/mesh-v2/DeferredBoundsQueue.d.ts +0 -48
  34. package/src/engine/graphics/ecs/mesh-v2/DeferredBoundsQueue.d.ts.map +0 -1
  35. package/src/engine/graphics/ecs/mesh-v2/DeferredBoundsQueue.js +0 -88
  36. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.d.ts +0 -63
  37. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.d.ts.map +0 -1
  38. package/src/engine/graphics/ecs/mesh-v2/aggregate/SGMeshSystem.js +0 -314
  39. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.d.ts +0 -67
  40. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.d.ts.map +0 -1
  41. package/src/engine/graphics/ecs/mesh-v2/render/adapters/AbstractRenderAdapter.js +0 -130
  42. package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.d.ts +0 -42
  43. package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.d.ts.map +0 -1
  44. package/src/engine/graphics/ecs/mesh-v2/render/adapters/SGCacheKey.js +0 -71
  45. package/src/engine/graphics/ecs/mesh-v2/render/optimization/RuntimeDrawMethodOptimizer.d.ts +0 -20
  46. package/src/engine/graphics/ecs/mesh-v2/render/optimization/RuntimeDrawMethodOptimizer.d.ts.map +0 -1
  47. package/src/engine/graphics/ecs/mesh-v2/render/optimization/RuntimeDrawMethodOptimizer.js +0 -123
  48. package/src/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.d.ts +0 -8
  49. package/src/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.d.ts.map +0 -1
  50. package/src/engine/graphics/ecs/mesh-v2/three_object_to_entity_composition.js +0 -55
  51. package/src/engine/graphics/impostors/octahedral/util/load_mesh_for_bake.d.ts +0 -12
  52. package/src/engine/graphics/impostors/octahedral/util/load_mesh_for_bake.d.ts.map +0 -1
  53. package/src/engine/graphics/impostors/octahedral/util/load_mesh_for_bake.js +0 -31
  54. package/src/engine/graphics/sh3/build_injected_shader.d.ts +0 -51
  55. package/src/engine/graphics/sh3/build_injected_shader.d.ts.map +0 -1
  56. package/src/engine/graphics/sh3/build_injected_shader.js +0 -56
  57. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts +0 -9
  58. package/src/engine/graphics/sh3/fromCubeRenderTarget.d.ts.map +0 -1
  59. package/src/engine/graphics/sh3/fromCubeRenderTarget.js +0 -142
  60. package/src/engine/graphics/sh3/shader/visualize.frag.d.ts +0 -3
  61. package/src/engine/graphics/sh3/shader/visualize.frag.d.ts.map +0 -1
  62. package/src/engine/graphics/sh3/shader/visualize.frag.js +0 -51
  63. package/src/engine/graphics/sh3/shader/visualize.vert.d.ts +0 -3
  64. package/src/engine/graphics/sh3/shader/visualize.vert.d.ts.map +0 -1
  65. package/src/engine/graphics/sh3/shader/visualize.vert.js +0 -12
  66. package/src/view/graphics/WebGLContextFailureView.d.ts.map +0 -1
@@ -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
- `
@@ -1 +0,0 @@
1
- {"version":3,"file":"WebGLContextFailureView.d.ts","sourceRoot":"","sources":["../../../../src/view/graphics/WebGLContextFailureView.js"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH;IACI;;;;;OAKG;IACH,oDALW,MAAM,EA4DhB;CACJ;sBA1EqB,0BAA0B"}