@woosh/meep-engine 2.165.3 → 2.165.5

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 (159) hide show
  1. package/editor/Editor.d.ts +65 -65
  2. package/editor/SelectionVisualizer.d.ts +19 -19
  3. package/editor/actions/concrete/ActionUpdateTexture.d.ts +11 -11
  4. package/editor/actions/concrete/ArrayCopyAction.d.ts +19 -19
  5. package/editor/actions/concrete/ComponentAddAction.d.ts +14 -14
  6. package/editor/actions/concrete/ComponentRemoveAction.d.ts +10 -10
  7. package/editor/actions/concrete/EntityCreateAction.d.ts +17 -17
  8. package/editor/actions/concrete/EntityRemoveAction.d.ts +10 -10
  9. package/editor/actions/concrete/ModifyPatchSampler2DAction.d.ts +46 -46
  10. package/editor/actions/concrete/ModifyPatchTextureArray2DAction.d.ts +37 -37
  11. package/editor/actions/concrete/PaintTerrainOverlayAction.d.ts +22 -22
  12. package/editor/actions/concrete/PatchTerrainHeightAction.d.ts +18 -18
  13. package/editor/actions/concrete/SelectionAddAction.d.ts +18 -18
  14. package/editor/actions/concrete/SelectionClearAction.d.ts +8 -8
  15. package/editor/actions/concrete/SelectionRemoveAction.d.ts +9 -9
  16. package/editor/actions/concrete/TransformModifyAction.d.ts +16 -16
  17. package/editor/actions/concrete/WriteGridValueAction.d.ts +14 -14
  18. package/editor/ecs/EditorEntity.d.ts +15 -15
  19. package/editor/ecs/EditorEntitySystem.d.ts +7 -7
  20. package/editor/ecs/component/FieldDescriptor.d.ts +26 -26
  21. package/editor/ecs/component/FieldValueAdapter.d.ts +6 -6
  22. package/editor/ecs/component/TypeEditor.d.ts +24 -24
  23. package/editor/ecs/component/createFieldEditor.d.ts +8 -8
  24. package/editor/ecs/component/createObjectEditor.d.ts +13 -13
  25. package/editor/ecs/component/editors/ColorEditor.d.ts +6 -6
  26. package/editor/ecs/component/editors/HTMLElementEditor.d.ts +6 -6
  27. package/editor/ecs/component/editors/ImagePathEditor.d.ts +6 -6
  28. package/editor/ecs/component/editors/LargeStringEditor.d.ts +15 -15
  29. package/editor/ecs/component/editors/NumericIntervalEditor.d.ts +6 -6
  30. package/editor/ecs/component/editors/ObservedBooleanEditor.d.ts +6 -6
  31. package/editor/ecs/component/editors/ObservedEnumEditor.d.ts +6 -6
  32. package/editor/ecs/component/editors/ObservedIntegerEditor.d.ts +6 -6
  33. package/editor/ecs/component/editors/ObservedStringEditor.d.ts +6 -6
  34. package/editor/ecs/component/editors/Sampler2DEditor.d.ts +6 -6
  35. package/editor/ecs/component/editors/collection/ListEditor.d.ts +7 -7
  36. package/editor/ecs/component/editors/common/BitFlagsEditor.d.ts +11 -11
  37. package/editor/ecs/component/editors/common/EnumEditor.d.ts +7 -7
  38. package/editor/ecs/component/editors/common/makeV3_editor.d.ts +14 -14
  39. package/editor/ecs/component/editors/common/noEditor.d.ts +2 -2
  40. package/editor/ecs/component/editors/ecs/GridObstacleEditor.d.ts +6 -6
  41. package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.d.ts +13 -13
  42. package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.d.ts +66 -66
  43. package/editor/ecs/component/editors/ecs/ParameterTrackEditor.d.ts +11 -11
  44. package/editor/ecs/component/editors/ecs/ParameterTrackSetEditor.d.ts +13 -13
  45. package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.d.ts +51 -51
  46. package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.d.ts +47 -47
  47. package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.d.ts +15 -15
  48. package/editor/ecs/component/editors/ecs/Trail2DEditor.d.ts +29 -29
  49. package/editor/ecs/component/editors/ecs/TransformEditor.d.ts +19 -19
  50. package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.d.ts +18 -18
  51. package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.d.ts +38 -38
  52. package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.d.ts +15 -15
  53. package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.d.ts +18 -18
  54. package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.d.ts +17 -17
  55. package/editor/ecs/component/editors/geom/QuaternionEditor.d.ts +5 -5
  56. package/editor/ecs/component/editors/geom/Vector1Editor.d.ts +6 -6
  57. package/editor/ecs/component/editors/geom/Vector2Editor.d.ts +5 -5
  58. package/editor/ecs/component/editors/geom/Vector3Editor.d.ts +5 -5
  59. package/editor/ecs/component/editors/geom/Vector4Editor.d.ts +5 -5
  60. package/editor/ecs/component/editors/primitive/ArrayEditor.d.ts +7 -7
  61. package/editor/ecs/component/editors/primitive/BooleanEditor.d.ts +6 -6
  62. package/editor/ecs/component/editors/primitive/FunctionEditor.d.ts +6 -6
  63. package/editor/ecs/component/editors/primitive/NumberEditor.d.ts +7 -7
  64. package/editor/ecs/component/editors/primitive/ObjectEditor.d.ts +5 -5
  65. package/editor/ecs/component/editors/primitive/StringEditor.d.ts +6 -6
  66. package/editor/ecs/component/editors/three/BufferGeometryEditor.d.ts +6 -6
  67. package/editor/ecs/component/editors/three/MaterialEditor.d.ts +6 -6
  68. package/editor/ecs/component/editors/three/MeshEditor.d.ts +6 -6
  69. package/editor/ecs/component/editors/three/TextureEditor.d.ts +6 -6
  70. package/editor/ecs/component/findNearestRegisteredType.d.ts +7 -7
  71. package/editor/enableEditor.d.ts +13 -13
  72. package/editor/library/MeshLibrary.d.ts +12 -12
  73. package/editor/process/DisableGameUIProcess.d.ts +7 -7
  74. package/editor/process/EditorProcess.d.ts +18 -18
  75. package/editor/process/ObstacleGridDisplayProcess.d.ts +12 -12
  76. package/editor/process/ProcessEngine.d.ts +29 -29
  77. package/editor/process/SymbolicDisplayProcess.d.ts +18 -18
  78. package/editor/process/symbolic/ComponentSymbolicDisplay.d.ts +10 -10
  79. package/editor/process/symbolic/SymbolicDisplayInternalAPI.d.ts +64 -64
  80. package/editor/process/symbolic/buildThreeJSHelperEntity.d.ts +8 -8
  81. package/editor/process/symbolic/make3DSymbolicDisplay.d.ts +9 -9
  82. package/editor/process/symbolic/makeCameraSymbolicDisplay.d.ts +6 -6
  83. package/editor/process/symbolic/makeGridPositionSymbolDisplay.d.ts +5 -5
  84. package/editor/process/symbolic/makeHelperBoxGeometry.d.ts +2 -2
  85. package/editor/process/symbolic/makeHelperSphereGeometry.d.ts +8 -8
  86. package/editor/process/symbolic/makeLightSymbolicDisplay.d.ts +6 -6
  87. package/editor/process/symbolic/makeParticleEmitterSymbolicDisplay.d.ts +5 -5
  88. package/editor/process/symbolic/makePathSymbolicDisplay.d.ts +6 -6
  89. package/editor/process/symbolic/makePositionedIconDisplaySymbol.d.ts +8 -8
  90. package/editor/process/symbolic/makeSocketsSymbolicDisplay.d.ts +6 -6
  91. package/editor/process/symbolic/makeSolidArrowGeometry.d.ts +25 -25
  92. package/editor/process/symbolic/makeSoundEmitterSymbolicDisplay.d.ts +5 -5
  93. package/editor/process/symbolic/synchronizeTransform.d.ts +11 -11
  94. package/editor/tools/GridPaintTool.d.ts +16 -16
  95. package/editor/tools/SelectionTool.d.ts +26 -26
  96. package/editor/tools/TopDownCameraControlTool.d.ts +12 -12
  97. package/editor/tools/engine/Tool.d.ts +63 -63
  98. package/editor/tools/engine/ToolEngine.d.ts +22 -22
  99. package/editor/tools/engine/ToolState.d.ts +6 -6
  100. package/editor/tools/paint/TerrainHeightPaintTool.d.ts +17 -17
  101. package/editor/tools/paint/TerrainPaintTool.d.ts +30 -30
  102. package/editor/tools/paint/TerrainTexturePaintTool.d.ts +17 -17
  103. package/editor/tools/v2/TransformMode.d.ts +6 -6
  104. package/editor/view/EditorView.d.ts +38 -38
  105. package/editor/view/ecs/ComponentControlFactory.d.ts +18 -18
  106. package/editor/view/ecs/ComponentControlView.d.ts +23 -23
  107. package/editor/view/ecs/EntityEditor.d.ts +29 -29
  108. package/editor/view/ecs/EntityList.d.ts +21 -21
  109. package/editor/view/ecs/HierarchicalEntityListView.d.ts +7 -7
  110. package/editor/view/ecs/components/DatGuiController.d.ts +45 -45
  111. package/editor/view/ecs/components/GridObstacleController.d.ts +13 -13
  112. package/editor/view/ecs/components/color/GaugeView.d.ts +12 -12
  113. package/editor/view/ecs/components/common/AutoCanvasView.d.ts +19 -19
  114. package/editor/view/ecs/components/common/LineView.d.ts +11 -11
  115. package/editor/view/ecs/components/common/NumberController.d.ts +17 -17
  116. package/editor/view/ecs/components/particles/ColorParameterLUTController.d.ts +13 -13
  117. package/editor/view/makeEntityDecorators.d.ts +5 -5
  118. package/editor/view/tools/ToolSettingsView.d.ts +10 -10
  119. package/editor/view/tools/ToolView.d.ts +12 -12
  120. package/editor/view/v2/SplitView.d.ts +16 -16
  121. package/package.json +1 -1
  122. package/samples/generation/grid/GridTags.d.ts +15 -15
  123. package/samples/generation/grid/MirGridLayers.d.ts +7 -7
  124. package/samples/generation/rules/matcher_tag_occupied.d.ts +2 -2
  125. package/samples/generation/rules/matcher_tag_traversable.d.ts +2 -2
  126. package/samples/generation/rules/matcher_tag_unoccupied.d.ts +2 -2
  127. package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_zh.d.ts +21 -0
  128. package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_zh.d.ts.map +1 -0
  129. package/src/core/geom/3d/sphere/harmonics/sh3_convolve_with_zh.js +53 -0
  130. package/src/core/geom/3d/sphere/harmonics/sh3_ggx_zh.d.ts +18 -0
  131. package/src/core/geom/3d/sphere/harmonics/sh3_ggx_zh.d.ts.map +1 -0
  132. package/src/core/geom/3d/sphere/harmonics/sh3_ggx_zh.js +30 -0
  133. package/src/engine/graphics/ecs/light/LightContext.d.ts +8 -0
  134. package/src/engine/graphics/ecs/light/LightContext.d.ts.map +1 -1
  135. package/src/engine/graphics/ecs/light/LightContext.js +33 -3
  136. package/src/engine/graphics/ecs/light/LightSystem.d.ts.map +1 -1
  137. package/src/engine/graphics/ecs/light/LightSystem.js +13 -6
  138. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts +12 -0
  139. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.d.ts.map +1 -1
  140. package/src/engine/graphics/ecs/light/binding/three/ThreeLightBinding.js +184 -6
  141. package/src/engine/graphics/render/buffer/simple-fx/ao/SAOShader.js +381 -362
  142. package/src/engine/graphics/sh3/lpg/LightProbeGridBaker.d.ts +43 -4
  143. package/src/engine/graphics/sh3/lpg/LightProbeGridBaker.d.ts.map +1 -1
  144. package/src/engine/graphics/sh3/lpg/LightProbeGridBaker.js +72 -5
  145. package/src/engine/graphics/sh3/lpg/bake_probe_sh3_resampled.d.ts +37 -0
  146. package/src/engine/graphics/sh3/lpg/bake_probe_sh3_resampled.d.ts.map +1 -0
  147. package/src/engine/graphics/sh3/lpg/bake_probe_sh3_resampled.js +298 -0
  148. package/src/engine/graphics/sh3/lpg/light_probe_grid_dilate.d.ts +18 -0
  149. package/src/engine/graphics/sh3/lpg/light_probe_grid_dilate.d.ts.map +1 -0
  150. package/src/engine/graphics/sh3/lpg/light_probe_grid_dilate.js +142 -0
  151. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts +6 -0
  152. package/src/engine/graphics/sh3/path_tracer/PathTracer.d.ts.map +1 -1
  153. package/src/engine/graphics/sh3/path_tracer/PathTracer.js +1 -1
  154. package/src/engine/graphics/shadows/ShadowMapRenderer.d.ts +10 -0
  155. package/src/engine/graphics/shadows/ShadowMapRenderer.d.ts.map +1 -1
  156. package/src/engine/graphics/shadows/ShadowMapRenderer.js +83 -10
  157. package/src/engine/graphics/shadows/testPointShadowMapRendering.d.ts +2 -0
  158. package/src/engine/graphics/shadows/testPointShadowMapRendering.d.ts.map +1 -0
  159. package/src/engine/graphics/shadows/testPointShadowMapRendering.js +242 -0
@@ -1,4 +1,4 @@
1
- import { DoubleSide, Mesh, MeshDepthMaterial, RGBADepthPacking, Scene } from "three";
1
+ import { DoubleSide, Mesh, MeshDepthMaterial, MeshDistanceMaterial, RGBADepthPacking, Scene, Vector3 } from "three";
2
2
  import { ThreeBypassRenderer } from "../../../../render/utils/ThreeBypassRenderer.js";
3
3
  import { CameraView } from "../../../../render/view/CameraView.js";
4
4
  import { three_setSceneAutoUpdate } from "../../../../three/three_setSceneAutoUpdate.js";
@@ -59,6 +59,68 @@ function __getDepthMaterial(object) {
59
59
  return result;
60
60
  }
61
61
 
62
+ const __distance_material = new MeshDistanceMaterial({
63
+ side: DoubleSide
64
+ });
65
+
66
+ /**
67
+ * Reference values for point light shadow casting, set per render in
68
+ * {@link ThreeLightBinding.__shadowmap_render} before the shadow scene is
69
+ * built. Shadow renders are sequential, so shared state is safe here.
70
+ */
71
+ const __distance_params = {
72
+ reference_position: new Vector3(),
73
+ near_distance: 0,
74
+ far_distance: 0
75
+ };
76
+
77
+ /**
78
+ * Point light shadows compare world-space distance to the light rather than
79
+ * projected depth (three.js getPointShadow), which requires
80
+ * MeshDistanceMaterial instead of MeshDepthMaterial
81
+ * @param {Mesh} object
82
+ * @returns {Material}
83
+ * @private
84
+ */
85
+ function __getDistanceMaterial(object) {
86
+ let result;
87
+
88
+ const customDistanceMaterial = object.customDistanceMaterial;
89
+
90
+ if (customDistanceMaterial !== undefined) {
91
+ result = customDistanceMaterial;
92
+ } else {
93
+
94
+ const source_material = object.material;
95
+ if (
96
+ typeof source_material.alphaTest === "number"
97
+ && source_material.alphaTest > 0
98
+ && source_material.alphaTest < 1
99
+ && source_material.map !== null
100
+ && source_material.map !== undefined
101
+ ) {
102
+ // alpha-tested
103
+ result = new MeshDistanceMaterial({
104
+ side: DoubleSide,
105
+ map: source_material.map,
106
+ alphaTest: source_material.alphaTest
107
+ });
108
+
109
+ } else {
110
+ // generic
111
+ result = __distance_material;
112
+ }
113
+ }
114
+
115
+ if (result.isMeshDistanceMaterial === true) {
116
+ result.referencePosition.copy(__distance_params.reference_position);
117
+ result.nearDistance = __distance_params.near_distance;
118
+ result.farDistance = __distance_params.far_distance;
119
+ }
120
+
121
+ return result;
122
+ }
123
+
62
124
  /**
63
125
  *
64
126
  * @param {THREE.Object3D} object3D
@@ -109,6 +171,11 @@ export function three_set_shadow_resolution(shadow, resolution) {
109
171
  shadow.map = null;
110
172
  }
111
173
 
174
+ if (shadow.mapPass !== null) {
175
+ shadow.mapPass.dispose();
176
+ shadow.mapPass = null;
177
+ }
178
+
112
179
  }
113
180
  }
114
181
 
@@ -157,13 +224,14 @@ export class ThreeLightBinding extends LightBinding {
157
224
  */
158
225
  const cache = this.__system.__three_light_cache;
159
226
 
227
+ // tear down shadow state while the light is still bound
228
+ this.__shadowmap_unlink();
229
+
160
230
  cache.release(this.__three_getLight());
161
231
 
162
232
  // clear bound light
163
233
  this.__c_light.__threeObject = null;
164
234
 
165
- this.__shadowmap_unlink();
166
-
167
235
  super.unlink(ctx);
168
236
  }
169
237
 
@@ -239,6 +307,25 @@ export class ThreeLightBinding extends LightBinding {
239
307
  shadows.remove(this.__shadow_map);
240
308
 
241
309
  this.__shadow_map = null;
310
+
311
+ // release GPU resources of the shadow render targets, they are
312
+ // re-created on demand if shadow casting is enabled again
313
+ const light = this.__three_getLight();
314
+
315
+ const shadow = light === null ? undefined : light.shadow;
316
+
317
+ if (shadow !== undefined) {
318
+
319
+ if (shadow.map !== null) {
320
+ shadow.map.dispose();
321
+ shadow.map = null;
322
+ }
323
+
324
+ if (shadow.mapPass !== null) {
325
+ shadow.mapPass.dispose();
326
+ shadow.mapPass = null;
327
+ }
328
+ }
242
329
  }
243
330
 
244
331
  __shadowmap_prepare_view() {
@@ -250,6 +337,11 @@ export class ThreeLightBinding extends LightBinding {
250
337
  */
251
338
  const light = this.__three_getLight();
252
339
 
340
+ if (light.isPointLight === true) {
341
+ this.__shadowmap_prepare_view_point(cameraView, light);
342
+ return;
343
+ }
344
+
253
345
  /**
254
346
  *
255
347
  * @type {LightShadow}
@@ -269,6 +361,65 @@ export class ThreeLightBinding extends LightBinding {
269
361
 
270
362
  }
271
363
 
364
+ /**
365
+ * A point light shadow renders six cube faces, a single camera frustum
366
+ * would only cull correctly for one of them. Instead, cull by the
367
+ * axis-aligned box bounding the light's sphere of influence: every caster
368
+ * that can shadow any face lies within `distance` of the light. The box is
369
+ * written directly as six inward-facing "frustum" planes and the resulting
370
+ * visible set is shared by all six face renders.
371
+ * @param {CameraView} cameraView
372
+ * @param {THREE.PointLight} light
373
+ * @private
374
+ */
375
+ __shadowmap_prepare_view_point(cameraView, light) {
376
+ const p = this.__c_transform.position;
377
+
378
+ // mirrors PointLightShadow.updateMatrices: distance of 0 means unbounded
379
+ const r = light.distance || light.shadow.camera.far;
380
+
381
+ const f = cameraView.frustum;
382
+
383
+ // plane format: nx, ny, nz, constant; a point is inside a plane when
384
+ // dot(normal, point) + constant >= 0
385
+
386
+ // x >= p.x - r
387
+ f[0] = 1;
388
+ f[1] = 0;
389
+ f[2] = 0;
390
+ f[3] = r - p.x;
391
+
392
+ // x <= p.x + r
393
+ f[4] = -1;
394
+ f[5] = 0;
395
+ f[6] = 0;
396
+ f[7] = r + p.x;
397
+
398
+ // y >= p.y - r
399
+ f[8] = 0;
400
+ f[9] = 1;
401
+ f[10] = 0;
402
+ f[11] = r - p.y;
403
+
404
+ // y <= p.y + r
405
+ f[12] = 0;
406
+ f[13] = -1;
407
+ f[14] = 0;
408
+ f[15] = r + p.y;
409
+
410
+ // z >= p.z - r
411
+ f[16] = 0;
412
+ f[17] = 0;
413
+ f[18] = 1;
414
+ f[19] = r - p.z;
415
+
416
+ // z <= p.z + r
417
+ f[20] = 0;
418
+ f[21] = 0;
419
+ f[22] = -1;
420
+ f[23] = r + p.z;
421
+ }
422
+
272
423
 
273
424
  __shadowmap_render() {
274
425
 
@@ -297,6 +448,14 @@ export class ThreeLightBinding extends LightBinding {
297
448
 
298
449
  const shadow = threeLight.shadow;
299
450
 
451
+ const is_point_light = threeLight.isPointLight === true;
452
+
453
+ if (is_point_light) {
454
+ __distance_params.reference_position.setFromMatrixPosition(threeLight.matrixWorld);
455
+ __distance_params.near_distance = shadow.camera.near;
456
+ // mirrors PointLightShadow.updateMatrices
457
+ __distance_params.far_distance = threeLight.distance || shadow.camera.far;
458
+ }
300
459
 
301
460
  // prepare shadow scene
302
461
  const visible_objects = cameraView.visible_objects;
@@ -306,7 +465,7 @@ export class ThreeLightBinding extends LightBinding {
306
465
  scene: shadow_scene,
307
466
  input: visible_objects.elements,
308
467
  input_size: visible_object_count,
309
- material_extractor: __getDepthMaterial,
468
+ material_extractor: is_point_light ? __getDistanceMaterial : __getDepthMaterial,
310
469
  object_filter: scene_object_filter
311
470
  })
312
471
 
@@ -367,9 +526,28 @@ export class ThreeLightBinding extends LightBinding {
367
526
 
368
527
  // disable automatic shadowmap rendering in three.js
369
528
  shadow.autoUpdate = false;
370
- shadow.camera.matrixAutoUpdate = false;
371
529
 
372
- const resolution = parseInt(settings.shadowResolution);
530
+ let resolution = parseInt(settings.shadowResolution);
531
+
532
+ if (shadow.isPointLightShadow === true) {
533
+ // PointLightShadow.updateMatrices re-orients the camera for
534
+ // every cube face and relies on updateMatrixWorld() to
535
+ // re-compose the matrix, so matrixAutoUpdate must stay enabled
536
+ shadow.camera.matrixAutoUpdate = true;
537
+
538
+ // small offset in normalized [near..far] distance units to
539
+ // suppress acne, casters render double-sided so front faces
540
+ // would otherwise compare against their own stored distance
541
+ shadow.bias = -0.002;
542
+
543
+ // resolution is per cube face and the shadow map allocates a
544
+ // 4x2 face atlas, cap the default to keep memory use sane
545
+ resolution = settings.shadowResolutionPoint !== undefined
546
+ ? parseInt(settings.shadowResolutionPoint)
547
+ : Math.min(resolution, 1024);
548
+ } else {
549
+ shadow.camera.matrixAutoUpdate = false;
550
+ }
373
551
 
374
552
  shadow.radius = 1;
375
553
  shadow.blurSamples = 8;