@woosh/meep-engine 2.165.7 → 2.167.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 (146) hide show
  1. package/build/bundle-worker-image-decoder.js +1 -1
  2. package/package.json +1 -1
  3. package/src/CORRECTNESS_HUNT_2026_07_24.md +142 -0
  4. package/src/core/binary/BinaryBuffer.js +1 -1
  5. package/src/core/binary/EncodingBinaryBuffer.d.ts.map +1 -1
  6. package/src/core/binary/EncodingBinaryBuffer.js +3 -1
  7. package/src/core/cache/Cache.d.ts.map +1 -1
  8. package/src/core/cache/Cache.js +0 -4
  9. package/src/core/cache/CacheElement.d.ts.map +1 -1
  10. package/src/core/cache/CacheElement.js +4 -0
  11. package/src/core/cache/FrequencySketch.d.ts +0 -21
  12. package/src/core/cache/FrequencySketch.d.ts.map +1 -1
  13. package/src/core/cache/FrequencySketch.js +66 -65
  14. package/src/core/cache/wtinylfu/CacheElementWTinylfu.d.ts +17 -0
  15. package/src/core/cache/wtinylfu/CacheElementWTinylfu.d.ts.map +1 -0
  16. package/src/core/cache/wtinylfu/CacheElementWTinylfu.js +18 -0
  17. package/src/core/cache/wtinylfu/CacheRegionType.d.ts +10 -0
  18. package/src/core/cache/wtinylfu/CacheRegionType.d.ts.map +1 -0
  19. package/src/core/cache/wtinylfu/CacheRegionType.js +10 -0
  20. package/src/core/cache/wtinylfu/CacheRegionWTinylfu.d.ts +66 -0
  21. package/src/core/cache/wtinylfu/CacheRegionWTinylfu.d.ts.map +1 -0
  22. package/src/core/cache/wtinylfu/CacheRegionWTinylfu.js +183 -0
  23. package/src/core/cache/wtinylfu/CacheWTinylfu.d.ts +279 -0
  24. package/src/core/cache/wtinylfu/CacheWTinylfu.d.ts.map +1 -0
  25. package/src/core/cache/wtinylfu/CacheWTinylfu.js +807 -0
  26. package/src/core/cache/wtinylfu/benchmark/CacheWTinylfu.bench.md +243 -0
  27. package/src/core/cache/wtinylfu/wtinylfuDecisions.d.ts +80 -0
  28. package/src/core/cache/wtinylfu/wtinylfuDecisions.d.ts.map +1 -0
  29. package/src/core/cache/wtinylfu/wtinylfuDecisions.js +102 -0
  30. package/src/core/collection/RingBuffer.d.ts.map +1 -1
  31. package/src/core/collection/RingBuffer.js +15 -3
  32. package/src/core/collection/map/HashMap.d.ts +1 -1
  33. package/src/core/collection/map/HashMap.d.ts.map +1 -1
  34. package/src/core/collection/map/HashMap.js +5 -17
  35. package/src/core/geom/2d/line/line2_compute_segment_point_distance_sqr.d.ts.map +1 -1
  36. package/src/core/geom/2d/line/line2_compute_segment_point_distance_sqr.js +5 -0
  37. package/src/core/geom/ConicRay.d.ts.map +1 -1
  38. package/src/core/geom/ConicRay.js +9 -2
  39. package/src/core/geom/Quaternion.d.ts.map +1 -1
  40. package/src/core/geom/Quaternion.js +7 -3
  41. package/src/core/math/build_gaussian_kernel_1d.d.ts +2 -2
  42. package/src/core/math/build_gaussian_kernel_1d.d.ts.map +1 -1
  43. package/src/core/math/build_gaussian_kernel_1d.js +4 -2
  44. package/src/core/math/build_gaussian_kernel_2d.d.ts +2 -2
  45. package/src/core/math/build_gaussian_kernel_2d.d.ts.map +1 -1
  46. package/src/core/math/build_gaussian_kernel_2d.js +4 -2
  47. package/src/core/math/gaussian.d.ts +2 -2
  48. package/src/core/math/gaussian.js +2 -2
  49. package/src/core/math/spline/spline3_bezier_bounds.d.ts.map +1 -1
  50. package/src/core/math/spline/spline3_bezier_bounds.js +10 -3
  51. package/src/core/math/spline/spline3_bezier_to_hermite.d.ts +8 -7
  52. package/src/core/math/spline/spline3_bezier_to_hermite.d.ts.map +1 -1
  53. package/src/core/math/spline/spline3_bezier_to_hermite.js +13 -12
  54. package/src/core/math/spline/spline3_hermite_bounds.d.ts.map +1 -1
  55. package/src/core/math/spline/spline3_hermite_bounds.js +10 -3
  56. package/src/core/math/spline/spline3_hermite_bounds_t.d.ts.map +1 -1
  57. package/src/core/math/spline/spline3_hermite_bounds_t.js +115 -109
  58. package/src/core/math/spline/spline3_hermite_to_bezier.d.ts +2 -0
  59. package/src/core/math/spline/spline3_hermite_to_bezier.d.ts.map +1 -1
  60. package/src/core/math/spline/spline3_hermite_to_bezier.js +2 -0
  61. package/src/core/math/statistics/computeStatisticalMean.js +1 -1
  62. package/src/core/math/statistics/gaussian_amplitude.d.ts.map +1 -1
  63. package/src/core/math/statistics/gaussian_amplitude.js +3 -1
  64. package/src/engine/animation/clip/ecd_bind_animation_curve.d.ts.map +1 -1
  65. package/src/engine/animation/clip/ecd_bind_animation_curve.js +10 -1
  66. package/src/engine/animation/clip/hemisphere_align_quaternion_values.d.ts +20 -0
  67. package/src/engine/animation/clip/hemisphere_align_quaternion_values.d.ts.map +1 -0
  68. package/src/engine/animation/clip/hemisphere_align_quaternion_values.js +37 -0
  69. package/src/engine/animation/keyed2/AnimationTrackPlayback.d.ts.map +1 -1
  70. package/src/engine/animation/keyed2/AnimationTrackPlayback.js +5 -1
  71. package/src/engine/ecs/EntityComponentDataset.d.ts.map +1 -1
  72. package/src/engine/ecs/EntityComponentDataset.js +5 -21
  73. package/src/engine/ecs/fow/FogOfWar.d.ts +22 -0
  74. package/src/engine/ecs/fow/FogOfWar.d.ts.map +1 -1
  75. package/src/engine/ecs/fow/FogOfWar.js +202 -54
  76. package/src/engine/ecs/fow/FogOfWarEdgeMode.d.ts +16 -0
  77. package/src/engine/ecs/fow/FogOfWarEdgeMode.d.ts.map +1 -0
  78. package/src/engine/ecs/fow/FogOfWarEdgeMode.js +39 -0
  79. package/src/engine/ecs/fow/FogOfWarSystem.d.ts.map +1 -1
  80. package/src/engine/ecs/fow/FogOfWarSystem.js +1 -0
  81. package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.d.ts.map +1 -1
  82. package/src/engine/ecs/fow/serialization/FogOfWarSerializationAdapter.js +3 -0
  83. package/src/engine/ecs/fow/shader/FogOfWarRenderer.d.ts +7 -0
  84. package/src/engine/ecs/fow/shader/FogOfWarRenderer.d.ts.map +1 -1
  85. package/src/engine/ecs/fow/shader/FogOfWarRenderer.js +155 -145
  86. package/src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.d.ts.map +1 -1
  87. package/src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js +33 -8
  88. package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.d.ts.map +1 -1
  89. package/src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js +3 -1
  90. package/src/engine/graphics/GraphicsEngine.d.ts +5 -1
  91. package/src/engine/graphics/GraphicsEngine.d.ts.map +1 -1
  92. package/src/engine/graphics/GraphicsEngine.js +14 -3
  93. package/src/engine/graphics/composit/CompositLayer.d.ts.map +1 -1
  94. package/src/engine/graphics/composit/CompositLayer.js +258 -255
  95. package/src/engine/graphics/composit/LayerCompositer.d.ts +12 -0
  96. package/src/engine/graphics/composit/LayerCompositer.d.ts.map +1 -1
  97. package/src/engine/graphics/composit/LayerCompositer.js +19 -10
  98. package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.d.ts +1 -1
  99. package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.d.ts.map +1 -1
  100. package/src/engine/graphics/ecs/highlight/plugin/OutlineRenderPlugin.js +10 -4
  101. package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.d.ts +6 -0
  102. package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.d.ts.map +1 -1
  103. package/src/engine/graphics/ecs/highlight/renderer/OutlineRenderer.js +21 -0
  104. package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.d.ts.map +1 -1
  105. package/src/engine/graphics/ecs/path/ribbon/RibbonPathBuilder.js +5 -23
  106. package/src/engine/graphics/ecs/path/tube/build/estimatePathViaIterativeIntegral.d.ts.map +1 -1
  107. package/src/engine/graphics/ecs/path/tube/build/estimatePathViaIterativeIntegral.js +6 -4
  108. package/src/engine/graphics/ecs/water/WaterSystem.d.ts.map +1 -1
  109. package/src/engine/graphics/ecs/water/WaterSystem.js +9 -3
  110. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts +12 -0
  111. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.d.ts.map +1 -1
  112. package/src/engine/graphics/particles/ecs/ParticleEmitterSystem.js +46 -9
  113. package/src/engine/graphics/particles/particular/engine/ParticularEngine.d.ts +5 -0
  114. package/src/engine/graphics/particles/particular/engine/ParticularEngine.d.ts.map +1 -1
  115. package/src/engine/graphics/particles/particular/engine/ParticularEngine.js +8 -0
  116. package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.d.ts +7 -0
  117. package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.d.ts.map +1 -1
  118. package/src/engine/graphics/particles/particular/engine/shader/MaterialRecord.js +8 -0
  119. package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.d.ts +10 -2
  120. package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.d.ts.map +1 -1
  121. package/src/engine/graphics/particles/particular/engine/shader/ShaderManager.js +42 -10
  122. package/src/engine/graphics/render/buffer/FrameBuffer.d.ts.map +1 -1
  123. package/src/engine/graphics/render/buffer/FrameBuffer.js +5 -2
  124. package/src/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.d.ts +13 -1
  125. package/src/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.d.ts.map +1 -1
  126. package/src/engine/graphics/render/buffer/simple-fx/ao/AmbientOcclusionPostProcessEffect.js +40 -7
  127. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.d.ts.map +1 -1
  128. package/src/engine/graphics/render/buffer/simple-fx/taa/TemporalSupersamplingRenderPlugin.js +10 -4
  129. package/src/engine/graphics/render/forward_plus/LightManager.d.ts.map +1 -1
  130. package/src/engine/graphics/render/forward_plus/LightManager.js +1235 -1232
  131. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts +5 -0
  132. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.d.ts.map +1 -1
  133. package/src/engine/graphics/render/forward_plus/plugin/ForwardPlusRenderingPlugin.js +11 -10
  134. package/src/engine/graphics/trail/tube/TubeX.d.ts.map +1 -1
  135. package/src/engine/graphics/trail/tube/TubeX.js +557 -555
  136. package/src/engine/graphics/trail/x/RibbonXPlugin.d.ts +12 -1
  137. package/src/engine/graphics/trail/x/RibbonXPlugin.d.ts.map +1 -1
  138. package/src/engine/graphics/trail/x/RibbonXPlugin.js +15 -8
  139. package/src/engine/input/ecs/systems/InputControllerSystem.d.ts.map +1 -1
  140. package/src/engine/input/ecs/systems/InputControllerSystem.js +9 -6
  141. package/src/engine/navigation/ecs/components/Path.d.ts +5 -2
  142. package/src/engine/navigation/ecs/components/Path.d.ts.map +1 -1
  143. package/src/engine/navigation/ecs/components/Path.js +10 -4
  144. package/src/engine/navigation/ecs/path_following/PathFollowingSystem.js +1 -1
  145. package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
  146. package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
@@ -1,145 +1,155 @@
1
- import { Mesh, OrthographicCamera, Scene } from "three";
2
- import { assert } from "../../../../core/assert.js";
3
- import { isValueBetweenInclusive } from "../../../../core/math/interval/isValueBetweenInclusive.js";
4
- import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../../../graphics/geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
5
- import { buildScreenSpaceFogOfWarShader } from "./screenSpaceFogOfWarShader.js";
6
-
7
- /**
8
- *
9
- * @param {FogOfWar} fow
10
- * @param {function(number, number, number, number)} callback
11
- */
12
- export function computeUvTransformFromFogOfWar(fow, callback) {
13
-
14
- const sampler = fow.sampler;
15
-
16
- const samplerWidth = sampler.width;
17
- const samplerHeight = sampler.height;
18
-
19
-
20
- const scaleX = (fow.scale * fow.size.x) * (samplerWidth / (samplerWidth - 3));
21
- const scaleY = (fow.scale * fow.size.y) * (samplerHeight / (samplerHeight - 3));
22
-
23
- const offsetX = 1.5 / samplerWidth;
24
- const offsetY = 1.5 / samplerHeight;
25
-
26
- callback(offsetX, offsetY, 1 / scaleX, 1 / scaleY);
27
- }
28
-
29
- export class FogOfWarRenderer {
30
- constructor() {
31
- /**
32
- *
33
- * @type {ShaderMaterial}
34
- */
35
- this.material = buildScreenSpaceFogOfWarShader();
36
-
37
- this.quad = new Mesh(FULL_SCREEN_TRIANGLE_GEOMETRY, this.material);
38
-
39
- this.camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
40
- this.scene = new Scene();
41
- this.scene.add(this.quad);
42
- }
43
-
44
- /**
45
- *
46
- * @param {FogOfWar} fow
47
- */
48
- setUvTransformFromFog(fow) {
49
- computeUvTransformFromFogOfWar(fow, (offsetX, offsetY, scaleX, scaleY) => {
50
-
51
- this.setUvTransform(offsetX, offsetY, scaleX, scaleY);
52
- });
53
- }
54
-
55
- /**
56
- *
57
- * @param {number} offsetX UV u offset, between 0 and 1
58
- * @param {number} offsetY UV v offset, between 0 and 1
59
- * @param {number} scaleX Transform scale from world coordinate position to UV u coordinate, minus offsetX
60
- * @param {number} scaleY Transform scale from world coordinate position to UV v coordinate, minus offsetY
61
- */
62
- setUvTransform(offsetX, offsetY, scaleX, scaleY) {
63
- assert.isNumber(offsetX, 'offsetX');
64
- assert.notNaN(offsetX, 'offsetX');
65
- assert.ok(isValueBetweenInclusive(offsetX, 0, 1), `expected offsetX to be between 0 and 1, instead was '${offsetX}'`);
66
-
67
- assert.isNumber(offsetY, 'offsetY');
68
- assert.notNaN(offsetY, 'offsetY');
69
- assert.ok(isValueBetweenInclusive(offsetY, 0, 1), `expected offsetY to be between 0 and 1, instead was '${offsetY}'`);
70
-
71
-
72
- assert.isNumber(scaleX, 'scaleX');
73
- assert.notNaN(scaleX, 'scaleX');
74
- assert.isFinite(scaleX, 'scaleX');
75
-
76
- assert.isNumber(scaleY, 'scaleY');
77
- assert.notNaN(scaleY, 'scaleY');
78
- assert.isFinite(scaleY, 'scaleY');
79
-
80
- this.material.uniforms.uFogUvTransform.value.set(offsetX, offsetY, scaleX, scaleY);
81
- }
82
-
83
- /**
84
- *
85
- * @param {Texture} texture
86
- */
87
- setDepthBuffer(texture) {
88
- // assert.equal(texture.type, UnsignedShortType, `expected texture type to be UnsignedShort(=${UnsignedShortType}), instead got something else (=${texture.type})`)
89
-
90
- this.material.uniforms.tDepth.value = texture;
91
- }
92
-
93
- /**
94
- *
95
- * @param {Texture} buffer
96
- */
97
- setFogBuffer(buffer) {
98
- this.material.uniforms.tFog.value = buffer;
99
-
100
- }
101
-
102
- /**
103
- * Resolution of the fog texture
104
- * @param {number} x
105
- * @param {number} y
106
- */
107
- setResolution(x, y) {
108
- this.material.uniforms.uResolution.value.set(x, y);
109
- }
110
-
111
- /**
112
- *
113
- * @param {Vector4} color
114
- */
115
- setFogColor(color) {
116
- this.material.uniforms.uColor.value.copy(color);
117
- }
118
-
119
- /**
120
- *
121
- * @param {WebGLRenderer} renderer
122
- * @param {PerspectiveCamera|OrthographicCamera} camera
123
- * @param {Scene} scene
124
- * @param {WebGLRenderTarget} target
125
- */
126
- render(renderer, camera, scene, target) {
127
- assert.ok(camera.isCamera, 'Not a camera');
128
- assert.ok(camera.isPerspectiveCamera || camera.isOrthographicCamera, 'Unsupported Camera type. Expected PerspectiveCamera or OrthographicCamera');
129
-
130
-
131
- //set up uniforms
132
- const uniforms = this.material.uniforms;
133
-
134
- uniforms.uProjectionInverse.value.copy(camera.projectionMatrixInverse);
135
- uniforms.uViewInverse.value.copy(camera.matrixWorld);
136
-
137
- renderer.setRenderTarget(target);
138
- renderer.clearColor();
139
-
140
- renderer.render(this.scene, this.camera);
141
-
142
-
143
- renderer.setRenderTarget(null);
144
- }
145
- }
1
+ import { Mesh, OrthographicCamera, Scene } from "three";
2
+ import { assert } from "../../../../core/assert.js";
3
+ import { isValueBetweenInclusive } from "../../../../core/math/interval/isValueBetweenInclusive.js";
4
+ import { FULL_SCREEN_TRIANGLE_GEOMETRY } from "../../../graphics/geometry/FULL_SCREEN_TRIANGLE_GEOMETRY.js";
5
+ import { FogOfWarEdgeMode } from "../FogOfWarEdgeMode.js";
6
+ import { buildScreenSpaceFogOfWarShader } from "./screenSpaceFogOfWarShader.js";
7
+
8
+ /**
9
+ *
10
+ * @param {FogOfWar} fow
11
+ * @param {function(number, number, number, number)} callback
12
+ */
13
+ export function computeUvTransformFromFogOfWar(fow, callback) {
14
+
15
+ const sampler = fow.sampler;
16
+
17
+ const samplerWidth = sampler.width;
18
+ const samplerHeight = sampler.height;
19
+
20
+
21
+ const scaleX = (fow.scale * fow.size.x) * (samplerWidth / (samplerWidth - 3));
22
+ const scaleY = (fow.scale * fow.size.y) * (samplerHeight / (samplerHeight - 3));
23
+
24
+ const offsetX = 1.5 / samplerWidth;
25
+ const offsetY = 1.5 / samplerHeight;
26
+
27
+ callback(offsetX, offsetY, 1 / scaleX, 1 / scaleY);
28
+ }
29
+
30
+ export class FogOfWarRenderer {
31
+ constructor() {
32
+ /**
33
+ *
34
+ * @type {ShaderMaterial}
35
+ */
36
+ this.material = buildScreenSpaceFogOfWarShader();
37
+
38
+ this.quad = new Mesh(FULL_SCREEN_TRIANGLE_GEOMETRY, this.material);
39
+
40
+ this.camera = new OrthographicCamera(-1, 1, 1, -1, 0, 1);
41
+ this.scene = new Scene();
42
+ this.scene.add(this.quad);
43
+ }
44
+
45
+ /**
46
+ *
47
+ * @param {FogOfWar} fow
48
+ */
49
+ setUvTransformFromFog(fow) {
50
+ computeUvTransformFromFogOfWar(fow, (offsetX, offsetY, scaleX, scaleY) => {
51
+
52
+ this.setUvTransform(offsetX, offsetY, scaleX, scaleY);
53
+ });
54
+ }
55
+
56
+ /**
57
+ *
58
+ * @param {number} offsetX UV u offset, between 0 and 1
59
+ * @param {number} offsetY UV v offset, between 0 and 1
60
+ * @param {number} scaleX Transform scale from world coordinate position to UV u coordinate, minus offsetX
61
+ * @param {number} scaleY Transform scale from world coordinate position to UV v coordinate, minus offsetY
62
+ */
63
+ setUvTransform(offsetX, offsetY, scaleX, scaleY) {
64
+ assert.isNumber(offsetX, 'offsetX');
65
+ assert.notNaN(offsetX, 'offsetX');
66
+ assert.ok(isValueBetweenInclusive(offsetX, 0, 1), `expected offsetX to be between 0 and 1, instead was '${offsetX}'`);
67
+
68
+ assert.isNumber(offsetY, 'offsetY');
69
+ assert.notNaN(offsetY, 'offsetY');
70
+ assert.ok(isValueBetweenInclusive(offsetY, 0, 1), `expected offsetY to be between 0 and 1, instead was '${offsetY}'`);
71
+
72
+
73
+ assert.isNumber(scaleX, 'scaleX');
74
+ assert.notNaN(scaleX, 'scaleX');
75
+ assert.isFinite(scaleX, 'scaleX');
76
+
77
+ assert.isNumber(scaleY, 'scaleY');
78
+ assert.notNaN(scaleY, 'scaleY');
79
+ assert.isFinite(scaleY, 'scaleY');
80
+
81
+ this.material.uniforms.uFogUvTransform.value.set(offsetX, offsetY, scaleX, scaleY);
82
+ }
83
+
84
+ /**
85
+ *
86
+ * @param {Texture} texture
87
+ */
88
+ setDepthBuffer(texture) {
89
+ // assert.equal(texture.type, UnsignedShortType, `expected texture type to be UnsignedShort(=${UnsignedShortType}), instead got something else (=${texture.type})`)
90
+
91
+ this.material.uniforms.tDepth.value = texture;
92
+ }
93
+
94
+ /**
95
+ *
96
+ * @param {Texture} buffer
97
+ */
98
+ setFogBuffer(buffer) {
99
+ this.material.uniforms.tFog.value = buffer;
100
+
101
+ }
102
+
103
+ /**
104
+ * Resolution of the fog texture
105
+ * @param {number} x
106
+ * @param {number} y
107
+ */
108
+ setResolution(x, y) {
109
+ this.material.uniforms.uResolution.value.set(x, y);
110
+ }
111
+
112
+ /**
113
+ *
114
+ * @param {Vector4} color
115
+ */
116
+ setFogColor(color) {
117
+ this.material.uniforms.uColor.value.copy(color);
118
+ }
119
+
120
+ /**
121
+ * What the fog does outside the fogged area. See {@link FogOfWarEdgeMode}.
122
+ *
123
+ * @param {FogOfWarEdgeMode} mode
124
+ */
125
+ setEdgeMode(mode) {
126
+ this.material.uniforms.uEdgeExtend.value = (mode === FogOfWarEdgeMode.Extend) ? 1 : 0;
127
+ }
128
+
129
+ /**
130
+ *
131
+ * @param {WebGLRenderer} renderer
132
+ * @param {PerspectiveCamera|OrthographicCamera} camera
133
+ * @param {Scene} scene
134
+ * @param {WebGLRenderTarget} target
135
+ */
136
+ render(renderer, camera, scene, target) {
137
+ assert.ok(camera.isCamera, 'Not a camera');
138
+ assert.ok(camera.isPerspectiveCamera || camera.isOrthographicCamera, 'Unsupported Camera type. Expected PerspectiveCamera or OrthographicCamera');
139
+
140
+
141
+ //set up uniforms
142
+ const uniforms = this.material.uniforms;
143
+
144
+ uniforms.uProjectionInverse.value.copy(camera.projectionMatrixInverse);
145
+ uniforms.uViewInverse.value.copy(camera.matrixWorld);
146
+
147
+ renderer.setRenderTarget(target);
148
+ renderer.clearColor();
149
+
150
+ renderer.render(this.scene, this.camera);
151
+
152
+
153
+ renderer.setRenderTarget(null);
154
+ }
155
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"screenSpaceFogOfWarShader.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH,kDAFW,cAAc,CAmKxB;+BAxKyE,OAAO"}
1
+ {"version":3,"file":"screenSpaceFogOfWarShader.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/ecs/fow/shader/screenSpaceFogOfWarShader.js"],"names":[],"mappings":"AAGA;;;GAGG;AACH,kDAFW,cAAc,CA4LxB;+BAjMyE,OAAO"}
@@ -22,9 +22,12 @@ export function buildScreenSpaceFogOfWarShader() {
22
22
  uniform vec2 uResolution;
23
23
 
24
24
  uniform vec4 uColor;
25
-
25
+
26
+ // FogOfWarEdgeMode as a float: 0 = Conceal (legacy), 1 = Extend
27
+ uniform float uEdgeExtend;
28
+
26
29
  varying vec2 vUv;
27
-
30
+
28
31
  const float c_samplesX = 5.0;
29
32
  const float c_samplesY = 5.0;
30
33
 
@@ -43,11 +46,9 @@ export function buildScreenSpaceFogOfWarShader() {
43
46
  // per tap, so a 5-tap kernel reaches +/-2 texels either side of centre.
44
47
  const float texelSpacing = 1.0;
45
48
 
46
- vec3 computeWorldPosition(){
49
+ vec3 computeWorldPosition(const in float normalizedDepth){
47
50
  // Convert screen coordinates to normalized device coordinates (NDC)
48
-
49
- float normalizedDepth = texture2D( tDepth, vUv).x ;
50
-
51
+
51
52
  vec4 ndc = vec4(
52
53
  (vUv.x - 0.5) * 2.0,
53
54
  (vUv.y - 0.5) * 2.0,
@@ -105,9 +106,28 @@ export function buildScreenSpaceFogOfWarShader() {
105
106
  }
106
107
 
107
108
  void main(){
109
+ float sceneDepth = texture2D( tDepth, vUv ).x;
110
+
111
+ // NOTHING WAS DRAWN HERE. The depth is the buffer's clear value, so
112
+ // the position reconstructed from it lands on the far plane: a point
113
+ // with no relationship to the scene, whose fog lookup is whatever the
114
+ // sampler's clamp happens to return. In a world with a visible
115
+ // boundary that is the concealed border ring, and it gets painted
116
+ // across the entire void as a hard rectangle on the world's edge.
117
+ // Under Extend, leave such a pixel alone rather than fog it on the
118
+ // strength of a reconstruction that means nothing.
119
+ //
120
+ // Under Conceal this branch never taken, so the legacy path is
121
+ // bit-identical — including the one case Extend gives up, a real
122
+ // surface sitting exactly on the far plane.
123
+ if (uEdgeExtend > 0.5 && sceneDepth >= 1.0) {
124
+ gl_FragColor = vec4(0.0);
125
+ return;
126
+ }
127
+
108
128
  //get world fragment position
109
- vec3 worldPosition = computeWorldPosition();
110
-
129
+ vec3 worldPosition = computeWorldPosition(sceneDepth);
130
+
111
131
  vec2 fogUv = worldPosition.xz * uFogUvTransform.zw + uFogUvTransform.xy;
112
132
 
113
133
  float fogValue = getFog( fogUv );
@@ -144,6 +164,11 @@ export function buildScreenSpaceFogOfWarShader() {
144
164
  uViewInverse: { type: 'm4', value: new Matrix4() },
145
165
  uProjectionInverse: { type: 'm4', value: new Matrix4() },
146
166
  uColor: { type: 'c', value: new Vector4(0, 0, 0, 1) },
167
+ /**
168
+ * {@link FogOfWarEdgeMode} as a float. Defaults to Conceal, so a consumer
169
+ * that never sets it keeps the pre-option behaviour.
170
+ */
171
+ uEdgeExtend: { type: 'f', value: 0 },
147
172
  uFogUvTransform: { type: 'v4', value: new Vector4(0, 0, 1, 1) },
148
173
  /**
149
174
  * Fog texture resolution
@@ -1 +1 @@
1
- {"version":3,"file":"BinaryCollectionDeSerializer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH;IAEI;;;OAGG;IACH,iBAAgB;IAEhB;;;OAGG;IACH,eAAc;IAEd;;;;OAIG;IACH,4BAA4B;IAC5B;;;;OAIG;IACH,0BAA0B;IAE1B;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,gBAAe;IAEf;;;OAGG;IACH,kBAAiB;IAEjB;;;;OAIG;IACH,yBAAsC;IACtC;;;;OAIG;IACH,yBAAsC;IAEtC;;;OAGG;IACH,cAAsB;IAGtB;;;OAGG;IACH,yDAKC;IAED;;;OAGG;IACH,2CAEC;IAED;;;OAGG;IACH,kBAFW,YAAY,QAOtB;IAED;;;OAGG;IACH,mBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,mBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,mBAFa,WAAS,IAAI,CAUzB;IAED;;;OAGG;IACH,wDAFyB,MAAM,QAgF9B;IAED,iBAWC;IAED;;;OAGG;IACH,uBAeC;IAED;;;OAGG;IACH;;aAF6B,MAAM;MA8DlC;CAEJ;6BAvV4B,4CAA4C"}
1
+ {"version":3,"file":"BinaryCollectionDeSerializer.d.ts","sourceRoot":"","sources":["../../../../../../../src/engine/ecs/storage/binary/collection/BinaryCollectionDeSerializer.js"],"names":[],"mappings":"AAkBA;;;;GAIG;AACH;IAEI;;;OAGG;IACH,iBAAgB;IAEhB;;;OAGG;IACH,eAAc;IAEd;;;;OAIG;IACH,4BAA4B;IAC5B;;;;OAIG;IACH,0BAA0B;IAE1B;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,qBAAiB;IAEjB;;;OAGG;IACH,gBAAe;IAEf;;;OAGG;IACH,kBAAiB;IAEjB;;;;OAIG;IACH,yBAAsC;IACtC;;;;OAIG;IACH,yBAAsC;IAEtC;;;OAGG;IACH,cAAsB;IAGtB;;;OAGG;IACH,yDAKC;IAED;;;OAGG;IACH,2CAEC;IAED;;;OAGG;IACH,kBAFW,YAAY,QAOtB;IAED;;;OAGG;IACH,mBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,mBAFa,MAAM,CAIlB;IAED;;;OAGG;IACH,mBAFa,WAAS,IAAI,CAUzB;IAED;;;OAGG;IACH,wDAFyB,MAAM,QAgF9B;IAED,iBAWC;IAED;;;OAGG;IACH,uBAeC;IAED;;;OAGG;IACH;;aAF6B,MAAM;MAgElC;CAEJ;6BAzV4B,4CAA4C"}
@@ -315,7 +315,9 @@ export class BinaryCollectionDeSerializer {
315
315
  header = buffer.readUint32LE();
316
316
  }
317
317
 
318
- const offset = header >> 2;
318
+ // unsigned: for a first-occurrence offset >= 2^29 the header sets bit 31, and a signed
319
+ // shift would sign-extend it into a negative (wrong) offset
320
+ const offset = header >>> 2;
319
321
 
320
322
  //read address
321
323
  const address = offset + this.startAddress;
@@ -35,7 +35,11 @@ export class GraphicsEngine {
35
35
  */
36
36
  pixelRatio: Vector1;
37
37
  /**
38
- * Final render-target resolution, in device pixels: `viewport.size × pixelRatio × devicePixelRatio`.
38
+ * Final render-target resolution, in whole device pixels: `viewport.size × pixelRatio ×
39
+ * devicePixelRatio`, floored and clamped the same way the attachments themselves are. This is
40
+ * the authority every full-resolution buffer is sized from -- frame buffers, composit layers,
41
+ * and anything that has to sample them on their own texel grid. Zero until the viewport has
42
+ * been sized for the first time.
39
43
  * Kept in sync by {@link GraphicsEngine#updateSize}. Subscribe to `output_resolution.onChanged` to
40
44
  * react to any change in the actual rendered resolution (viewport resize, supersample, or DPR change).
41
45
  * @readonly
@@ -1 +1 @@
1
- {"version":3,"file":"GraphicsEngine.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/GraphicsEngine.js"],"names":[],"mappings":"AAiEA;IAOI;;;;;OAKG;IACH,+BAJW,MAAM,EAgLhB;IAtLD,gCAEC;IAgBG;;;;OAIG;IACH,2BAA+C;IAK/C;;;;;QAOI;;WAEG;;QAEH;;WAEG;;;;;MAMN;IAED;;OAEG;IACH,YAFU,OAAO,CAEe;IAEhC;;;;;;OAMG;IACH,4BAFU,OAAO,CAEyB;IAE1C;;;OAGG;IACH,QAFU,kBAAkB,CAEU;IAWtC;;;OAGG;IACH,aAAkB;IAGlB;;;OAGG;IACH,cAFU,KAAK,CAEgB;IAK/B;;;OAGG;IACH,QAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,UAFU,aAAa,CAEH;IAGpB,+BAA0C;IAU1C;;OAEG;IACH,eAA+B;IAI/B;;;OAGG;IACH,uBAFU,kBAAkB,CAEgB;IAE5C;;;OAGG;IACH,oBAFU,iBAAiB,CAEsB;IAEjD;;;OAGG;IACH,gBAFU,iBAAiB,CAES;IAEpC;;;OAGG;IACH,sBAAoC;IAGpC;;;;OAIG;IACH,UAFU,OAAO,CAEG;IAEpB;;;OAGG;IACH,UAFU,OAAO,CAEG;IAEpB;;;OAGG;IACH,YAFU,MAAM,CAEG;IACnB,kKAcI;IAGR;;;OAGG;IACH,sBAFa,eAAe,CAI3B;IAED;;;OAGG;IACH,eAFa,aAAa,CAIzB;IAED;;;;;;;;;;;;;OAaG;IACH,iCAHW,MAAM,OAAO,eACb,4BAA4B,QAkCtC;IAED,mBA8BC;IAED;;;;OAIG;IACH,iCAEC;IAED;;;OAGG;IACH,0BAFa,MAAM,CAIlB;IAED,+BAcC;IAED,cAgEC;IAzBsB,8BAA0C;IA2BjE;;;OAGG;IACH,cAFa,MAAM,CAYlB;IAED;;OAEG;IACH,aAQC;IAED;;OAEG;IACH,yBAQC;IAED;;;;;;OAMG;IACH,yBALW,MAAM,KACN,MAAM,6CAMhB;IAED;;;;OAIG;IACH,8BAHW,OAAO,UAAQ,UACf,OAAO,UAAQ,QAczB;IAED;;;;;OAKG;IACH,8BAQC;IAED,0BAEC;IAED;;;OAGG;IACH,4BAFW,cAAc,QA8BxB;IAED;;OAEG;IACH,qBAqBC;IAED;;OAEG;IACH,0BAeC;IAED;;OAEG;IACH,eA8CC;;CACJ;mBA7oBkB,oCAAoC;oBACnC,4BAA4B;wBACxB,4BAA4B;mCAajB,uCAAuC;sBAlBnE,OAAO;uBAaS,wBAAwB;8BAbxC,OAAO;4BAYc,+BAA+B;mCAKxB,uCAAuC;kCAKxC,gCAAgC;kCADhC,oCAAoC;gCAPtC,uCAAuC;6CAW1B,2CAA2C;+BANzD,4BAA4B"}
1
+ {"version":3,"file":"GraphicsEngine.d.ts","sourceRoot":"","sources":["../../../../src/engine/graphics/GraphicsEngine.js"],"names":[],"mappings":"AAiEA;IAOI;;;;;OAKG;IACH,+BAJW,MAAM,EAoLhB;IA1LD,gCAEC;IAgBG;;;;OAIG;IACH,2BAA+C;IAK/C;;;;;QAOI;;WAEG;;QAEH;;WAEG;;;;;MAMN;IAED;;OAEG;IACH,YAFU,OAAO,CAEe;IAEhC;;;;;;;;;;OAUG;IACH,4BAFU,OAAO,CAEyB;IAE1C;;;OAGG;IACH,QAFU,kBAAkB,CAEU;IAWtC;;;OAGG;IACH,aAAkB;IAGlB;;;OAGG;IACH,cAFU,KAAK,CAEgB;IAK/B;;;OAGG;IACH,QAFU,MAAM,CAEI;IAEpB;;;OAGG;IACH,UAFU,aAAa,CAEH;IAGpB,+BAA0C;IAU1C;;OAEG;IACH,eAA+B;IAI/B;;;OAGG;IACH,uBAFU,kBAAkB,CAEgB;IAE5C;;;OAGG;IACH,oBAFU,iBAAiB,CAEsB;IAEjD;;;OAGG;IACH,gBAFU,iBAAiB,CAES;IAEpC;;;OAGG;IACH,sBAAoC;IAGpC;;;;OAIG;IACH,UAFU,OAAO,CAEG;IAEpB;;;OAGG;IACH,UAFU,OAAO,CAEG;IAEpB;;;OAGG;IACH,YAFU,MAAM,CAEG;IACnB,kKAcI;IAGR;;;OAGG;IACH,sBAFa,eAAe,CAI3B;IAED;;;OAGG;IACH,eAFa,aAAa,CAIzB;IAED;;;;;;;;;;;;;OAaG;IACH,iCAHW,MAAM,OAAO,eACb,4BAA4B,QAkCtC;IAED,mBAqCC;IAED;;;;OAIG;IACH,iCAEC;IAED;;;OAGG;IACH,0BAFa,MAAM,CAIlB;IAED,+BAcC;IAED,cAgEC;IAzBsB,8BAA0C;IA2BjE;;;OAGG;IACH,cAFa,MAAM,CAYlB;IAED;;OAEG;IACH,aAQC;IAED;;OAEG;IACH,yBAQC;IAED;;;;;;OAMG;IACH,yBALW,MAAM,KACN,MAAM,6CAMhB;IAED;;;;OAIG;IACH,8BAHW,OAAO,UAAQ,UACf,OAAO,UAAQ,QAczB;IAED;;;;;OAKG;IACH,8BAQC;IAED,0BAEC;IAED;;;OAGG;IACH,4BAFW,cAAc,QA8BxB;IAED;;OAEG;IACH,qBAqBC;IAED;;OAEG;IACH,0BAeC;IAED;;OAEG;IACH,eA8CC;;CACJ;mBAxpBkB,oCAAoC;oBACnC,4BAA4B;wBACxB,4BAA4B;mCAajB,uCAAuC;sBAlBnE,OAAO;uBAaS,wBAAwB;8BAbxC,OAAO;4BAYc,+BAA+B;mCAKxB,uCAAuC;kCAKxC,gCAAgC;kCADhC,oCAAoC;gCAPtC,uCAAuC;6CAW1B,2CAA2C;+BANzD,4BAA4B"}
@@ -121,7 +121,11 @@ export class GraphicsEngine {
121
121
  this.pixelRatio = new Vector1(1);
122
122
 
123
123
  /**
124
- * Final render-target resolution, in device pixels: `viewport.size × pixelRatio × devicePixelRatio`.
124
+ * Final render-target resolution, in whole device pixels: `viewport.size × pixelRatio ×
125
+ * devicePixelRatio`, floored and clamped the same way the attachments themselves are. This is
126
+ * the authority every full-resolution buffer is sized from -- frame buffers, composit layers,
127
+ * and anything that has to sample them on their own texel grid. Zero until the viewport has
128
+ * been sized for the first time.
125
129
  * Kept in sync by {@link GraphicsEngine#updateSize}. Subscribe to `output_resolution.onChanged` to
126
130
  * react to any change in the actual rendered resolution (viewport resize, supersample, or DPR change).
127
131
  * @readonly
@@ -342,8 +346,15 @@ export class GraphicsEngine {
342
346
  this.frameBuffers.setSize(_w, _h);
343
347
 
344
348
  // publish the final device-pixel render resolution; `_w/_h` already fold in the engine pixelRatio,
345
- // so this matches the framebuffers/composit layers and what getResolution historically computed
346
- this.output_resolution.set(_w * devicePixelRatio, _h * devicePixelRatio);
349
+ // so this matches the framebuffers/composit layers and what getResolution historically computed.
350
+ // Floored for the same reason three.js floors the drawing buffer: these are whole texels, and
351
+ // every buffer sized off this value must land on exactly the same grid. Clamped to 1 to match
352
+ // those buffers too -- a collapsed viewport still allocates 1x1 attachments, because a 0-sized
353
+ // one trips GL_INVALID_FRAMEBUFFER_OPERATION on clear/draw
354
+ this.output_resolution.set(
355
+ max2(1, Math.floor(_w * devicePixelRatio)),
356
+ max2(1, Math.floor(_h * devicePixelRatio))
357
+ );
347
358
  }
348
359
 
349
360
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"CompositLayer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/composit/CompositLayer.js"],"names":[],"mappings":"AAsCA;IACI;;;;;OAKG;IACH,2DAJW,MAAM,iBAAiB,EAyDjC;IAhDG;;;OAGG;IACH,MAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,YAFU,YAAY,CAEI;IAC1B;;;OAGG;IACH,gCAAgC;IAEhC;;;OAGG;IACH,mBAFU,MAAM,CAE0B;IAE1C,6DAA2E;IAE3E;;;OAGG;IACH,OAFU,MAAM,CAEF;IAEd,cAAyB;IAEzB;;;OAGG;IACH,WAFU,OAAO,CAEI;IAErB;;;OAGG;IACH,SAFU,MAAM,CAEA;IAEhB;;MAEC;IAOL,0BAQC;IAZD,uBAEC;IAYD;;;OAGG;IACH,uBAIC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,0BAMC;IAED;;;OAGG;IACH,uBAEC;IAED,eAKC;IAED,gBAKC;IAED;;;;OAIG;IACH,WAHW,MAAM,KACN,MAAM,QAKhB;IAED,+BAaC;IAED;;;OAGG;IACH,4BAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,4CAKC;IAGD,gCAoCC;CACJ;6BA/O4B,oCAAoC;+BAN1D,OAAO;qBAAP,OAAO;oBAGM,+BAA+B;mBADhC,uCAAuC"}
1
+ {"version":3,"file":"CompositLayer.d.ts","sourceRoot":"","sources":["../../../../../src/engine/graphics/composit/CompositLayer.js"],"names":[],"mappings":"AAsCA;IACI;;;;;OAKG;IACH,2DAJW,MAAM,iBAAiB,EAyDjC;IAhDG;;;OAGG;IACH,MAFU,MAAM,CAEF;IAEd;;;OAGG;IACH,YAFU,YAAY,CAEI;IAC1B;;;OAGG;IACH,gCAAgC;IAEhC;;;OAGG;IACH,mBAFU,MAAM,CAE0B;IAE1C,6DAA2E;IAE3E;;;OAGG;IACH,OAFU,MAAM,CAEF;IAEd,cAAyB;IAEzB;;;OAGG;IACH,WAFU,OAAO,CAEI;IAErB;;;OAGG;IACH,SAFU,MAAM,CAEA;IAEhB;;MAEC;IAOL,0BAQC;IAZD,uBAEC;IAYD;;;OAGG;IACH,uBAIC;IAED;;;OAGG;IACH,oBAEC;IAED;;;OAGG;IACH,0BAMC;IAED;;;OAGG;IACH,uBAEC;IAED,eAKC;IAED,gBAKC;IAED;;;;OAIG;IACH,WAHW,MAAM,KACN,MAAM,QAKhB;IAED,+BAgBC;IAED;;;OAGG;IACH,4BAFW,MAAM,QAShB;IAED;;;;OAIG;IACH,4CAKC;IAGD,gCAoCC;CACJ;6BAlP4B,oCAAoC;+BAN1D,OAAO;qBAAP,OAAO;oBAGM,+BAA+B;mBADhC,uCAAuC"}