@woosh/meep-engine 3.78.3 → 3.78.4
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.
- package/CHANGELOG.md +46 -13
- package/editor/view/node-graph/NodeGraphView.d.ts +1 -1
- package/editor/view/node-graph/NodeGraphView.js +1 -1
- package/package.json +1 -1
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts +2 -1
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.d.ts.map +1 -1
- package/src/core/math/physics/brdf/fresnel_Schlick_optimized.js +2 -1
- package/src/core/math/snap_to_integer.d.ts +13 -0
- package/src/core/math/snap_to_integer.d.ts.map +1 -0
- package/src/core/math/snap_to_integer.js +20 -0
- package/src/core/model/node-graph/NodeGraph.d.ts +0 -1
- package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
- package/src/core/model/node-graph/NodeGraph.js +0 -1
- package/src/engine/graphics/hair/groom_bind_to_mesh.d.ts +1 -1
- package/src/engine/graphics/hair/groom_bind_to_mesh.js +1 -1
- package/src/engine/graphics/hair/groom_build_guides.d.ts +1 -1
- package/src/engine/graphics/hair/groom_build_guides.js +1 -1
- package/src/engine/graphics/impostors/voxel/README.md +11 -11
- package/src/engine/physics/cloth/collider/ClothColliderKind.js +1 -1
- package/src/engine/physics/cloth/ecs/cloth_geodesic.d.ts +1 -1
- package/src/engine/physics/cloth/ecs/cloth_geodesic.js +1 -1
- package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.d.ts +2 -3
- package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.d.ts.map +1 -1
- package/src/engine/physics/cloth/solver/constraint/cloth_backstop_row.js +2 -3
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.d.ts +0 -2
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.d.ts.map +1 -1
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +0 -5
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.d.ts.map +1 -1
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.js +5 -3
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.d.ts.map +1 -1
- package/src/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +5 -3
- package/src/generation/grid/coords/grid_to_texel.d.ts +7 -1
- package/src/generation/grid/coords/grid_to_texel.d.ts.map +1 -1
- package/src/generation/grid/coords/grid_to_texel.js +11 -1
- package/src/generation/grid/coords/grid_to_texel_span.d.ts +15 -0
- package/src/generation/grid/coords/grid_to_texel_span.d.ts.map +1 -0
- package/src/generation/grid/coords/grid_to_texel_span.js +38 -0
- package/src/generation/grid/coords/texel_to_grid.d.ts +2 -1
- package/src/generation/grid/coords/texel_to_grid.d.ts.map +1 -1
- package/src/generation/grid/coords/texel_to_grid.js +6 -1
- package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts +32 -1
- package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js +114 -9
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts +8 -0
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +91 -29
- package/src/generation/grid/layers/GridDataLayer.d.ts +21 -2
- package/src/generation/grid/layers/GridDataLayer.d.ts.map +1 -1
- package/src/generation/grid/layers/GridDataLayer.js +43 -4
- package/src/generation/placement/action/GridCellActionPlaceTags.d.ts +7 -1
- package/src/generation/placement/action/GridCellActionPlaceTags.d.ts.map +1 -1
- package/src/generation/placement/action/GridCellActionPlaceTags.js +42 -16
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts +5 -0
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts.map +1 -1
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +32 -9
- package/src/generation/rules/CellMatcherLayerBitMaskTest.d.ts.map +1 -1
- package/src/generation/rules/CellMatcherLayerBitMaskTest.js +6 -2
- package/src/generation/wfc/GridWFCCompiledTileSet.d.ts +4 -2
- package/src/generation/wfc/GridWFCCompiledTileSet.d.ts.map +1 -1
- package/src/generation/wfc/GridWFCCompiledTileSet.js +2 -2
- package/src/generation/wfc/GridWFCTileSet.d.ts +16 -7
- package/src/generation/wfc/GridWFCTileSet.d.ts.map +1 -1
- package/src/generation/wfc/GridWFCTileSet.js +32 -8
- package/src/shade/playground/contact_shadows/shader_contact_lab_composite.js +2 -2
- package/src/shade/playground/particle_editor/README.md +2 -2
- package/src/shade/playground/probe_clipmap/index.html +1 -1
- package/src/shade/playground/screen_probes/README.md +5 -5
- package/src/shade/playground/screen_probes/main.js +1 -1
- package/src/shade/playground/tonemap_sdr/README.md +3 -2
- package/src/shade/playground/vgeo_scene/README.md +1 -3
- package/src/shade/playground/vgeo_scene/main.js +3 -3
- package/src/shade/renderer/Renderer.d.ts +3 -3
- package/src/shade/renderer/Renderer.js +4 -4
- package/src/shade/renderer/ShadeIndirectLightingMode.js +1 -1
- package/src/shade/renderer/camera/PerspectiveCamera.js +1 -1
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts +11 -13
- package/src/shade/renderer/deferred/tonemap/ColorGrade.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/ColorGrade.js +11 -13
- package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/TONE_MAP_OPERATOR_ACES.js +6 -7
- package/src/shade/renderer/deferred/tonemap/ToneMapper.d.ts +1 -1
- package/src/shade/renderer/deferred/tonemap/ToneMapper.js +1 -1
- package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts +6 -8
- package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.d.ts.map +1 -1
- package/src/shade/renderer/deferred/tonemap/m3_white_balance_rec709.js +7 -10
- package/src/shade/renderer/geometry/sdf/MESH_SDF.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/MESH_SDF.js +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_classify.js +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/bake/shader_mesh_sdf_evaluate.js +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts +1 -2
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_blas_query_band_sdf.js +1 -2
- package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.d.ts.map +1 -1
- package/src/shade/renderer/geometry/sdf/chunk_scene_point_query_volume_sign.js +2 -1
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.d.ts +1 -1
- package/src/shade/renderer/geometry/sdf/surface/MESH_SURFACE_BAKE.js +1 -1
- package/src/shade/renderer/geometry/virtual/build/level/vgeo_build_cluster_graph.js +1 -1
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_DEFAULT_PAGE_SIZE.d.ts +2 -2
- package/src/shade/renderer/geometry/virtual/format/page/VGEO_DEFAULT_PAGE_SIZE.js +2 -2
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_access.d.ts +2 -2
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_access.js +4 -4
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.d.ts +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/cut/chunk_vgeo_cut_instance.js +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/cut/shader_vgeo_cut_collect.js +1 -1
- package/src/shade/renderer/geometry/virtual/runtime/layout/VGEO_INSTANCE_OFFSET.d.ts +3 -3
- package/src/shade/renderer/geometry/virtual/runtime/layout/VGEO_INSTANCE_OFFSET.js +3 -3
- package/src/shade/renderer/global_illumination/brick4/README.md +2 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts +4 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/ProbeClipmapSettings.js +4 -6
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_MOVERS.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/BRICK_MOVERS.js +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/chunk_brick_clipmap_trace.js +2 -2
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.d.ts +1 -1
- package/src/shade/renderer/global_illumination/probe_clipmap/brick/mesh/chunk_mesh_brick_texel.js +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.d.ts +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/GPUScreenProbeGI.js +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts +28 -35
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/SCREEN_PROBE.js +28 -35
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts +21 -24
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/ScreenProbeSettings.js +21 -24
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.d.ts +8 -8
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe.js +8 -8
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.d.ts +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_brdf_density.js +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts +3 -5
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_interpolate.js +3 -5
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.d.ts +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_lighting_history.js +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts +2 -3
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_rough_specular.js +2 -3
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.d.ts +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_screen_march.js +4 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/chunk_screen_probe_surface.js +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_brick.js +2 -4
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts +13 -17
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_gather.js +13 -17
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts +11 -14
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_importance.js +11 -14
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.d.ts +2 -2
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_pick.js +2 -2
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.d.ts +9 -9
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_place.js +9 -9
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts +15 -18
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_resolve.js +16 -19
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts +10 -11
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.d.ts.map +1 -1
- package/src/shade/renderer/global_illumination/screen_probe/shader_screen_probe_trace_screen.js +11 -12
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts +9 -8
- package/src/shade/renderer/hair/chunk_hair_bsdf.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_bsdf.js +10 -9
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts +5 -6
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.d.ts.map +1 -1
- package/src/shade/renderer/hair/chunk_hair_dual_scattering.js +5 -6
- package/src/shade/renderer/hair/hair_lighting.d.ts +3 -3
- package/src/shade/renderer/hair/hair_lighting.d.ts.map +1 -1
- package/src/shade/renderer/hair/hair_lighting.js +4 -5
- package/src/shade/renderer/hair/hair_scattering_lut.d.ts +5 -5
- package/src/shade/renderer/hair/hair_scattering_lut.js +5 -5
- package/src/shade/renderer/hair/shader_hair_roots.d.ts +2 -2
- package/src/shade/renderer/hair/shader_hair_roots.js +2 -2
- package/src/shade/renderer/light/environment/DEFINES.d.ts +1 -1
- package/src/shade/renderer/light/environment/DEFINES.js +1 -1
- package/src/shade/renderer/light/environment/shader_convolve_reflection_map_from_blurred.js +2 -2
- package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts +1 -2
- package/src/shade/renderer/material/dispatch/MaterialDispatch.d.ts.map +1 -1
- package/src/shade/renderer/material/dispatch/MaterialDispatch.js +1 -2
- package/src/shade/renderer/material/standard/fragment_gbuffer.d.ts.map +1 -1
- package/src/shade/renderer/material/standard/fragment_gbuffer.js +2 -1
- package/src/shade/renderer/material/util/dielectric_specular_color.d.ts +1 -1
- package/src/shade/renderer/material/util/dielectric_specular_color.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_CONFIG.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_CONFIG.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_PRESETS.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_SETTINGS_STRUCT.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_SETTINGS_STRUCT.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_TEXTURE_FORMAT.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DOF2_TEXTURE_FORMAT.js +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.d.ts +3 -4
- package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/dof/gather/DepthOfFieldU.js +3 -4
- package/src/shade/renderer/postprocess/dof/gather/graph_postprocess_dof2.d.ts +1 -1
- package/src/shade/renderer/postprocess/dof/gather/graph_postprocess_dof2.js +1 -1
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.d.ts +1 -1
- package/src/shade/renderer/postprocess/eye/GPUCameraExposureManager.js +1 -1
- package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/gtao/ao_reproject_shader.js +2 -3
- package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.d.ts +1 -2
- package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/motion_blur/MOTION_BLUR_CONFIG.js +1 -2
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts +2 -3
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.d.ts.map +1 -1
- package/src/shade/renderer/postprocess/taa/chunk_fsr2_compute_depth_clip.js +2 -3
- package/src/shade/renderer/postprocess/taa/filter_blackman_harris.d.ts +1 -1
- package/src/shade/renderer/postprocess/taa/filter_blackman_harris.js +1 -1
- package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.d.ts +1 -1
- package/src/shade/renderer/rasterize/native/depth/shadow_cascade_rasterization_pass_descriptor.js +1 -1
- package/src/shade/renderer/rasterize/native/depth/shadow_rasterization_alpha_tested_pass_descriptor.js +1 -1
- package/src/shade/renderer/restir/di/ReSTIRDI.d.ts +3 -3
- package/src/shade/renderer/restir/di/ReSTIRDI.js +3 -3
- package/src/shade/renderer/restir/di/chunk_restir_trace_visibility.d.ts +1 -1
- package/src/shade/renderer/restir/di/chunk_restir_trace_visibility.js +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_MIN_DIELECTRICS_F0.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_MIN_DIELECTRICS_F0.js +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts +1 -2
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/brdf/chunk_shadowed_F90.js +1 -2
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts +4 -5
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/conversion/chunk_CRM_REC709_AP1.js +4 -5
- package/src/shade/renderer/shader/chunk/color/grade/chunk_color_grade.js +2 -2
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_aces_ue_matrices.d.ts +2 -2
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_aces_ue_matrices.js +2 -2
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.d.ts +14 -17
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/color/tonemap/aces/chunk_tonemap_ue_filmic.js +18 -21
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris.js +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris229.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_filter_blackman_harris229.js +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts +3 -4
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.d.ts.map +1 -1
- package/src/shade/renderer/shader/chunk/filter/chunk_multiscale_mean.js +3 -4
- package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.d.ts +1 -1
- package/src/shade/renderer/shader/chunk/material/chunk_re_direct_multiscatter.js +1 -1
- package/src/shade/renderer/shadow/map/GPUSceneShadowmapContext.js +3 -3
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts +6 -8
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_sample_shadowmap_cascade.js +8 -10
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts +5 -7
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.d.ts.map +1 -1
- package/src/shade/renderer/shadow/map/shader/chunk_shadow_caster_depth_bias.js +5 -7
- package/src/shade/renderer/texture/virtual/README.md +257 -257
- package/src/shade/renderer/volumetrics/shader_volumetrics_build_lighting.js +2 -2
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
* {@link GridWFCTileSet}, and every pair of neighbours shows the same socket on the edge they
|
|
4
4
|
* share. Each tile's {@link GridCellAction} is then run on its cell, turned the way the tile is.
|
|
5
5
|
*
|
|
6
|
+
* The solve is laid on a {@link GridDataLayer}, named by {@link layer}: its texels are the cells of
|
|
7
|
+
* the solve, and each ends up holding the value of the tile laid there, for the stages after this
|
|
8
|
+
* one to read. A layer at resolution 1/2 makes every tile a block of two cells by two, for art that
|
|
9
|
+
* size (a paving slab two cells across).
|
|
10
|
+
*
|
|
6
11
|
* What adjacency alone cannot say is said around the solve:
|
|
7
12
|
* - {@link restrictions} narrow what a cell may hold before it starts — keep these cells open,
|
|
8
13
|
* let paving stand only where that field is high;
|
|
@@ -20,6 +25,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
20
25
|
* @param {Object} options
|
|
21
26
|
* @param {string} [options.name]
|
|
22
27
|
* @param {GridWFCTileSet} options.tiles
|
|
28
|
+
* @param {string} options.layer id of the {@link GridDataLayer} the solve is laid on and written into
|
|
23
29
|
* @param {{matcher: CellMatcher, tag: string}[]} [options.restrictions]
|
|
24
30
|
* @param {string|null} [options.boundary]
|
|
25
31
|
* @param {string|null} [options.connected]
|
|
@@ -28,9 +34,10 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
28
34
|
* @param {string|null} [options.fallback]
|
|
29
35
|
* @returns {GridTaskWaveFunctionCollapse}
|
|
30
36
|
*/
|
|
31
|
-
static from({ name, tiles, restrictions, boundary, connected, cell_choice, attempts, fallback }: {
|
|
37
|
+
static from({ name, tiles, layer, restrictions, boundary, connected, cell_choice, attempts, fallback }: {
|
|
32
38
|
name?: string;
|
|
33
39
|
tiles: GridWFCTileSet;
|
|
40
|
+
layer: string;
|
|
34
41
|
restrictions?: {
|
|
35
42
|
matcher: CellMatcher;
|
|
36
43
|
tag: string;
|
|
@@ -45,6 +52,30 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
45
52
|
* @type {GridWFCTileSet}
|
|
46
53
|
*/
|
|
47
54
|
tiles: GridWFCTileSet;
|
|
55
|
+
/**
|
|
56
|
+
* Id of the {@link GridDataLayer} the solve is laid on. Its texels are the cells of the solve,
|
|
57
|
+
* and once the solve is done each holds the value its tile has in the {@link GridWFCTileSet} —
|
|
58
|
+
* the prototype's index, unless the set gives one — so that every stage after this one can read
|
|
59
|
+
* what was laid. The whole result is written before any tile's action runs.
|
|
60
|
+
*
|
|
61
|
+
* At resolution 1 a tile is a cell. At `1/n` a tile stands for a block of `n` by `n` cells, and
|
|
62
|
+
* the layer has to be {@link GridDataLayer#stretch stretched}, so that its texels are such blocks
|
|
63
|
+
* laid from the grid's first cell; unstretched, its texel 0 is centred on cell 0 and stands for
|
|
64
|
+
* part of a block. Any other resolution is refused: a tile is a whole number of cells. A last row
|
|
65
|
+
* or column of texels that the grid cuts short holds no tile, since its art would reach past the
|
|
66
|
+
* grid, and keeps what the layer held there.
|
|
67
|
+
*
|
|
68
|
+
* Everything else is then about blocks. A restriction holds on a block when its matcher matches
|
|
69
|
+
* every one of the block's cells — so a restriction and its negation never both hold on one
|
|
70
|
+
* block, and a block half on a building is not the building's. The boundary is the outer ring of
|
|
71
|
+
* whole blocks. A tile's action runs once for its block, written as if the block's first cell
|
|
72
|
+
* (lowest x, lowest y) were its own cell and turned with the tile about the block's centre: an
|
|
73
|
+
* action marking cells (0,0) to (n-1,n-1) from where it runs marks exactly its block, whichever
|
|
74
|
+
* way the tile is turned.
|
|
75
|
+
*
|
|
76
|
+
* @type {string}
|
|
77
|
+
*/
|
|
78
|
+
layer: string;
|
|
48
79
|
/**
|
|
49
80
|
* A cell that `matcher` matches may only hold tiles carrying `tag`. A cell matched by several
|
|
50
81
|
* may only hold tiles carrying all their tags.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridTaskWaveFunctionCollapse.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GridTaskWaveFunctionCollapse.d.ts","sourceRoot":"","sources":["../../../../../../src/generation/grid/generation/discrete/GridTaskWaveFunctionCollapse.js"],"names":[],"mappings":"AA+BA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH;IAgGI;;;;;;;;;;;;OAYG;IACH;QAX4B,IAAI,GAArB,MAAM;QACkB,KAAK;QACb,KAAK,EAArB,MAAM;QAC0C,YAAY,GAA5D;YAAC,OAAO,cAAc;YAAC,GAAG,EAAE,MAAM,CAAA;SAAC,EAAE;QACf,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACW,SAAS,GAA/B,MAAM,GAAC,IAAI;QACa,WAAW,GAAnC,aAAa;QACI,QAAQ,GAAzB,MAAM;QACgB,QAAQ,GAA9B,MAAM,GAAC,IAAI;QACT,4BAA4B,CAoCxC;IA7ID;;OAEG;IACH,sBAAa;IAEb;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAFU,MAAM,CAEH;IAEb;;;;;OAKG;IACH,cAFU;QAAC,OAAO,cAAc;QAAC,GAAG,EAAE,MAAM,CAAA;KAAC,EAAE,CAE7B;IAElB;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;;;;;;;;OAYG;IACH,WAFU,MAAM,GAAC,IAAI,CAEJ;IAEjB;;OAEG;IACH,aAFU,aAAa,CAEc;IAErC;;;;;OAKG;IACH,UAFU,MAAM,CAEH;IAEb;;;;;;;OAOG;IACH,UAFU,MAAM,GAAC,IAAI,CAEL;IAEhB;;;;;OAKG;IACH,YAFU;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAA;KAAC,CAEb;IAyDzF,iDA8cC;CACJ;kCAvoBiC,4BAA4B;8BAThC,uCAAuC;sBAJ/C,4CAA4C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assert } from "../../../../core/assert.js";
|
|
2
2
|
import { array_shuffle } from "../../../../core/collection/array/array_shuffle.js";
|
|
3
3
|
import { uf_find, uf_init, uf_union } from "../../../../core/collection/union-find/union_find.js";
|
|
4
|
+
import { v2_rotate } from "../../../../core/geom/vec2/v2_rotate.js";
|
|
4
5
|
import { PI_HALF } from "../../../../core/math/PI_HALF.js";
|
|
5
6
|
import { seededRandom } from "../../../../core/math/random/seededRandom.js";
|
|
6
7
|
import Task from "../../../../core/process/task/Task.js";
|
|
@@ -33,6 +34,11 @@ const OPERATIONS_PER_CYCLE = 4096;
|
|
|
33
34
|
* {@link GridWFCTileSet}, and every pair of neighbours shows the same socket on the edge they
|
|
34
35
|
* share. Each tile's {@link GridCellAction} is then run on its cell, turned the way the tile is.
|
|
35
36
|
*
|
|
37
|
+
* The solve is laid on a {@link GridDataLayer}, named by {@link layer}: its texels are the cells of
|
|
38
|
+
* the solve, and each ends up holding the value of the tile laid there, for the stages after this
|
|
39
|
+
* one to read. A layer at resolution 1/2 makes every tile a block of two cells by two, for art that
|
|
40
|
+
* size (a paving slab two cells across).
|
|
41
|
+
*
|
|
36
42
|
* What adjacency alone cannot say is said around the solve:
|
|
37
43
|
* - {@link restrictions} narrow what a cell may hold before it starts — keep these cells open,
|
|
38
44
|
* let paving stand only where that field is high;
|
|
@@ -52,6 +58,31 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
52
58
|
*/
|
|
53
59
|
tiles = null;
|
|
54
60
|
|
|
61
|
+
/**
|
|
62
|
+
* Id of the {@link GridDataLayer} the solve is laid on. Its texels are the cells of the solve,
|
|
63
|
+
* and once the solve is done each holds the value its tile has in the {@link GridWFCTileSet} —
|
|
64
|
+
* the prototype's index, unless the set gives one — so that every stage after this one can read
|
|
65
|
+
* what was laid. The whole result is written before any tile's action runs.
|
|
66
|
+
*
|
|
67
|
+
* At resolution 1 a tile is a cell. At `1/n` a tile stands for a block of `n` by `n` cells, and
|
|
68
|
+
* the layer has to be {@link GridDataLayer#stretch stretched}, so that its texels are such blocks
|
|
69
|
+
* laid from the grid's first cell; unstretched, its texel 0 is centred on cell 0 and stands for
|
|
70
|
+
* part of a block. Any other resolution is refused: a tile is a whole number of cells. A last row
|
|
71
|
+
* or column of texels that the grid cuts short holds no tile, since its art would reach past the
|
|
72
|
+
* grid, and keeps what the layer held there.
|
|
73
|
+
*
|
|
74
|
+
* Everything else is then about blocks. A restriction holds on a block when its matcher matches
|
|
75
|
+
* every one of the block's cells — so a restriction and its negation never both hold on one
|
|
76
|
+
* block, and a block half on a building is not the building's. The boundary is the outer ring of
|
|
77
|
+
* whole blocks. A tile's action runs once for its block, written as if the block's first cell
|
|
78
|
+
* (lowest x, lowest y) were its own cell and turned with the tile about the block's centre: an
|
|
79
|
+
* action marking cells (0,0) to (n-1,n-1) from where it runs marks exactly its block, whichever
|
|
80
|
+
* way the tile is turned.
|
|
81
|
+
*
|
|
82
|
+
* @type {string}
|
|
83
|
+
*/
|
|
84
|
+
layer = null;
|
|
85
|
+
|
|
55
86
|
/**
|
|
56
87
|
* A cell that `matcher` matches may only hold tiles carrying `tag`. A cell matched by several
|
|
57
88
|
* may only hold tiles carrying all their tags.
|
|
@@ -120,6 +151,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
120
151
|
* @param {Object} options
|
|
121
152
|
* @param {string} [options.name]
|
|
122
153
|
* @param {GridWFCTileSet} options.tiles
|
|
154
|
+
* @param {string} options.layer id of the {@link GridDataLayer} the solve is laid on and written into
|
|
123
155
|
* @param {{matcher: CellMatcher, tag: string}[]} [options.restrictions]
|
|
124
156
|
* @param {string|null} [options.boundary]
|
|
125
157
|
* @param {string|null} [options.connected]
|
|
@@ -131,6 +163,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
131
163
|
static from({
|
|
132
164
|
name = 'wave function collapse',
|
|
133
165
|
tiles,
|
|
166
|
+
layer,
|
|
134
167
|
restrictions = [],
|
|
135
168
|
boundary = null,
|
|
136
169
|
connected = null,
|
|
@@ -139,6 +172,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
139
172
|
fallback = null
|
|
140
173
|
}) {
|
|
141
174
|
assert.defined(tiles, 'tiles');
|
|
175
|
+
assert.isString(layer, 'layer');
|
|
142
176
|
assert.isArray(restrictions, 'restrictions');
|
|
143
177
|
assert.isPositiveInteger(attempts, 'attempts');
|
|
144
178
|
|
|
@@ -151,6 +185,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
151
185
|
|
|
152
186
|
r.name = name;
|
|
153
187
|
r.tiles = tiles;
|
|
188
|
+
r.layer = layer;
|
|
154
189
|
r.restrictions = restrictions;
|
|
155
190
|
r.boundary = boundary;
|
|
156
191
|
r.connected = connected;
|
|
@@ -162,20 +197,65 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
162
197
|
}
|
|
163
198
|
|
|
164
199
|
computeWrites() {
|
|
165
|
-
|
|
200
|
+
const writes = compute_writes_union(this.tiles.prototypes.map(p => p.action).filter(a => a !== null));
|
|
201
|
+
|
|
202
|
+
return writes.includes(this.layer) ? writes : writes.concat(this.layer);
|
|
166
203
|
}
|
|
167
204
|
|
|
168
205
|
build(grid, ecd, seed) {
|
|
169
206
|
const compiled = this.tiles.compile();
|
|
170
207
|
const prototypes = compiled.prototypes;
|
|
171
208
|
|
|
172
|
-
|
|
173
|
-
const
|
|
209
|
+
// real throws, like the fallback's below: what the layer is depends on the grid built on
|
|
210
|
+
const layer = grid.getLayerById(this.layer);
|
|
211
|
+
|
|
212
|
+
if (layer === undefined) {
|
|
213
|
+
throw new Error(`Layer '${this.layer}' not found`);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// cells along a side of the block a texel stands for
|
|
217
|
+
const pitch = Math.round(1 / layer.resolution);
|
|
218
|
+
|
|
219
|
+
if (!Number.isSafeInteger(pitch) || pitch < 1 || 1 / pitch !== layer.resolution) {
|
|
220
|
+
throw new Error(`layer '${this.layer}' has resolution ${layer.resolution}: a tile stands for a whole number of cells, so it must be 1/n for a whole number n`);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (pitch > 1 && !layer.stretch) {
|
|
224
|
+
throw new Error(`layer '${this.layer}' at resolution 1/${pitch} is not stretched: its texel 0 is centred on cell 0, so its texels are not blocks laid from the grid's first cell`);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const sampler = layer.sampler;
|
|
228
|
+
|
|
229
|
+
// The solve's cells, the layer's texels: blocks of `pitch` by `pitch` grid cells (one, at
|
|
230
|
+
// resolution 1), and whole ones only. Everything below indexes these; only matching, acting
|
|
231
|
+
// and writing go back to the grid and the layer.
|
|
232
|
+
const width = Math.floor(grid.width / pitch);
|
|
233
|
+
const height = Math.floor(grid.height / pitch);
|
|
174
234
|
const cell_count = width * height;
|
|
175
235
|
|
|
176
|
-
// y on axis 0, so a cell's index in the lattice is the grid's own
|
|
236
|
+
// y on axis 0, so a cell's index in the lattice is `y * width + x`, the grid's own at resolution 1
|
|
177
237
|
const lattice = cell_count > 0 ? WFCLattice.from_shape([height, width]) : null;
|
|
178
238
|
|
|
239
|
+
/**
|
|
240
|
+
* Does `matcher` match every grid cell of the block at lattice cell (x, y)?
|
|
241
|
+
*
|
|
242
|
+
* @param {CellMatcher} matcher
|
|
243
|
+
* @param {number} x
|
|
244
|
+
* @param {number} y
|
|
245
|
+
* @returns {boolean}
|
|
246
|
+
*/
|
|
247
|
+
const matches_block = (matcher, x, y) => {
|
|
248
|
+
for (let dy = 0; dy < pitch; dy++) {
|
|
249
|
+
for (let dx = 0; dx < pitch; dx++) {
|
|
250
|
+
if (!matcher.match(grid, x * pitch + dx, y * pitch + dy, 0)) {
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return true;
|
|
257
|
+
};
|
|
258
|
+
|
|
179
259
|
const restrictions = this.restrictions;
|
|
180
260
|
const boundary = this.boundary;
|
|
181
261
|
const connected = this.connected;
|
|
@@ -259,7 +339,7 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
259
339
|
let key = '';
|
|
260
340
|
|
|
261
341
|
for (let i = 0; i < restrictions.length; i++) {
|
|
262
|
-
if (restrictions[i].matcher
|
|
342
|
+
if (matches_block(restrictions[i].matcher, x, y)) {
|
|
263
343
|
key += i + ',';
|
|
264
344
|
}
|
|
265
345
|
}
|
|
@@ -547,17 +627,42 @@ export class GridTaskWaveFunctionCollapse extends GridTaskGenerator {
|
|
|
547
627
|
|
|
548
628
|
tSolve.addDependency(tInitialize);
|
|
549
629
|
|
|
630
|
+
// the whole result into the layer before any action runs, so an action may read it too
|
|
631
|
+
const tWrite = countTask(0, cell_count, cell => {
|
|
632
|
+
const value = prototypes[compiled.tile_prototype[result[cell]]].value;
|
|
633
|
+
|
|
634
|
+
sampler.writeChannel(cell % width, (cell / width) | 0, 0, value);
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
tWrite.addDependency(tSolve);
|
|
638
|
+
|
|
639
|
+
// half the block's side less a cell: from its first cell to its centre, along each axis
|
|
640
|
+
const centre = (pitch - 1) / 2;
|
|
641
|
+
const turned = new Float64Array(2);
|
|
642
|
+
|
|
550
643
|
const tApply = countTask(0, cell_count, cell => {
|
|
551
644
|
const tile = result[cell];
|
|
552
645
|
const action = prototypes[compiled.tile_prototype[tile]].action;
|
|
553
646
|
|
|
554
|
-
if (action
|
|
555
|
-
|
|
647
|
+
if (action === null) {
|
|
648
|
+
return;
|
|
556
649
|
}
|
|
650
|
+
|
|
651
|
+
const rotation = compiled.tile_turns[tile] * PI_HALF;
|
|
652
|
+
|
|
653
|
+
// Turned about the block's centre, the block's first cell lands at the centre less the
|
|
654
|
+
// turned offset to it — always on a cell, so the action runs there and its own turn
|
|
655
|
+
// carries the rest of the block round. At resolution 1 it is the cell itself.
|
|
656
|
+
v2_rotate(turned, 0, centre, centre, rotation);
|
|
657
|
+
|
|
658
|
+
const x = (cell % width) * pitch + Math.round(centre - turned[0]);
|
|
659
|
+
const y = ((cell / width) | 0) * pitch + Math.round(centre - turned[1]);
|
|
660
|
+
|
|
661
|
+
action.execute(grid, x, y, rotation);
|
|
557
662
|
});
|
|
558
663
|
|
|
559
|
-
tApply.addDependency(
|
|
664
|
+
tApply.addDependency(tWrite);
|
|
560
665
|
|
|
561
|
-
return new TaskGroup([tInitialize, tSolve, tApply], this.name);
|
|
666
|
+
return new TaskGroup([tInitialize, tSolve, tWrite, tApply], this.name);
|
|
562
667
|
}
|
|
563
668
|
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Build a map of distances across the grid, using 2 concepts: source cells and passable cells. Source cells are where the distance is 0, and passable cells are those that can be travelled through
|
|
3
|
+
*
|
|
4
|
+
* The map is the layer's: the search steps from texel to edge-sharing texel. On a layer as fine as the grid or finer,
|
|
5
|
+
* a texel is a source, or passable, as the matchers find the grid at its centre ({@link texel_to_grid}). On a coarser
|
|
6
|
+
* one a texel holds a block of cells — those whose nearest texel it is, which is where a matcher at the cell reads —
|
|
7
|
+
* and is a source if any of them is, passable if all of them are, so that a wall one cell thick still stops the
|
|
8
|
+
* search. Distances are in cells whatever the resolution, a step between neighbouring texels being `1 / resolution`
|
|
9
|
+
* cells, and are written into the layer when the search is done, converted to its type there; a texel no source
|
|
10
|
+
* reaches holds {@link initial}.
|
|
3
11
|
*/
|
|
4
12
|
export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
5
13
|
/**
|
package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridTaskBuildSourceDistanceMap.d.ts","sourceRoot":"","sources":["../../../../../../../src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GridTaskBuildSourceDistanceMap.d.ts","sourceRoot":"","sources":["../../../../../../../src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js"],"names":[],"mappings":"AAaA;;;;;;;;;;GAUG;AACH;IA0BI;;;;;;;OAOG;IACH;;;;;;uCAgBC;IAhDD;;;OAGG;IACH,2BAAqB;IAErB;;;OAGG;IACH,yBAAmB;IAEnB;;;OAGG;IACH,cAAa;IAEb;;;OAGG;IACH,SAFU,MAAM,CAEA;IAgChB,iDA0MC;CACJ;kCAhRiC,+BAA+B;sBAN3C,+CAA+C"}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { assert } from "../../../../../core/assert.js";
|
|
2
2
|
import { BitSet } from "../../../../../core/binary/BitSet.js";
|
|
3
3
|
import BinaryHeap from "../../../../../core/collection/heap/BinaryHeap.js";
|
|
4
|
+
import { snap_to_integer } from "../../../../../core/math/snap_to_integer.js";
|
|
4
5
|
import Task from "../../../../../core/process/task/Task.js";
|
|
5
6
|
import TaskGroup from "../../../../../core/process/task/TaskGroup.js";
|
|
6
7
|
import { TaskSignal } from "../../../../../core/process/task/TaskSignal.js";
|
|
7
8
|
import { actionTask } from "../../../../../core/process/task/util/actionTask.js";
|
|
8
9
|
import { countTask } from "../../../../../core/process/task/util/countTask.js";
|
|
10
|
+
import { grid_to_texel } from "../../../coords/grid_to_texel.js";
|
|
11
|
+
import { texel_to_grid } from "../../../coords/texel_to_grid.js";
|
|
9
12
|
import { GridTaskGenerator } from "../../../GridTaskGenerator.js";
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Build a map of distances across the grid, using 2 concepts: source cells and passable cells. Source cells are where the distance is 0, and passable cells are those that can be travelled through
|
|
16
|
+
*
|
|
17
|
+
* The map is the layer's: the search steps from texel to edge-sharing texel. On a layer as fine as the grid or finer,
|
|
18
|
+
* a texel is a source, or passable, as the matchers find the grid at its centre ({@link texel_to_grid}). On a coarser
|
|
19
|
+
* one a texel holds a block of cells — those whose nearest texel it is, which is where a matcher at the cell reads —
|
|
20
|
+
* and is a source if any of them is, passable if all of them are, so that a wall one cell thick still stops the
|
|
21
|
+
* search. Distances are in cells whatever the resolution, a step between neighbouring texels being `1 / resolution`
|
|
22
|
+
* cells, and are written into the layer when the search is done, converted to its type there; a texel no source
|
|
23
|
+
* reaches holds {@link initial}.
|
|
13
24
|
*/
|
|
14
25
|
export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
15
26
|
|
|
@@ -92,10 +103,28 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
|
92
103
|
throw new Error(`Layer '${this.layer}' doesn't exist`);
|
|
93
104
|
}
|
|
94
105
|
|
|
95
|
-
const
|
|
106
|
+
const resolution = layer.resolution;
|
|
107
|
+
const stretch = layer.stretch;
|
|
108
|
+
|
|
109
|
+
// the layer's texels are the nodes of the search
|
|
110
|
+
const width = layer.sampler.width;
|
|
111
|
+
const height = layer.sampler.height;
|
|
112
|
+
const texel_count = width * height;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Steps from the nearest source to each texel, Infinity where none reaches. Whole steps, so that a distance
|
|
116
|
+
* is one conversion to cells and not a sum of fractions of a cell.
|
|
117
|
+
* @type {Float64Array}
|
|
118
|
+
*/
|
|
119
|
+
const steps = new Float64Array(texel_count);
|
|
120
|
+
|
|
121
|
+
/** @type {Uint8Array} */
|
|
122
|
+
const is_source = new Uint8Array(texel_count);
|
|
123
|
+
/** @type {Uint8Array} */
|
|
124
|
+
const is_passable = new Uint8Array(texel_count);
|
|
96
125
|
|
|
97
126
|
const open = new BinaryHeap(function (i) {
|
|
98
|
-
return
|
|
127
|
+
return steps[i];
|
|
99
128
|
});
|
|
100
129
|
|
|
101
130
|
/**
|
|
@@ -110,12 +139,12 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
|
110
139
|
*/
|
|
111
140
|
const inOpen = new BitSet();
|
|
112
141
|
|
|
113
|
-
const width = grid.width;
|
|
114
|
-
const height = grid.height;
|
|
115
|
-
|
|
116
142
|
const tInitialize = actionTask(() => {
|
|
117
|
-
|
|
118
|
-
|
|
143
|
+
steps.fill(Infinity);
|
|
144
|
+
|
|
145
|
+
is_source.fill(0);
|
|
146
|
+
// a texel of cells is passable until one of them is not
|
|
147
|
+
is_passable.fill(resolution > 1 ? 0 : 1);
|
|
119
148
|
|
|
120
149
|
//initialize matchers
|
|
121
150
|
sourceMatcher.initialize(grid, seed);
|
|
@@ -123,23 +152,54 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
|
123
152
|
|
|
124
153
|
});
|
|
125
154
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
155
|
+
const grid_width = grid.width;
|
|
156
|
+
|
|
157
|
+
const tClassify = resolution > 1
|
|
158
|
+
? countTask(0, texel_count, index => {
|
|
159
|
+
// a texel inside a cell: what the grid is at its centre
|
|
160
|
+
const x = texel_to_grid(index % width, resolution, stretch);
|
|
161
|
+
const y = texel_to_grid((index / width) | 0, resolution, stretch);
|
|
162
|
+
|
|
163
|
+
is_source[index] = sourceMatcher.match(grid, x, y, 0) ? 1 : 0;
|
|
164
|
+
is_passable[index] = passMatcher.match(grid, x, y, 0) ? 1 : 0;
|
|
165
|
+
})
|
|
166
|
+
: countTask(0, grid_width * grid.height, cell => {
|
|
167
|
+
// a cell into the texel holding it
|
|
168
|
+
const x = cell % grid_width;
|
|
169
|
+
const y = (cell / grid_width) | 0;
|
|
170
|
+
|
|
171
|
+
const texel_x = Math.round(grid_to_texel(x, resolution, stretch));
|
|
172
|
+
const texel_y = Math.round(grid_to_texel(y, resolution, stretch));
|
|
173
|
+
|
|
174
|
+
if (texel_x < 0 || texel_x >= width || texel_y < 0 || texel_y >= height) {
|
|
175
|
+
// a cell past the last texel of an unstretched layer
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const index = texel_y * width + texel_x;
|
|
180
|
+
|
|
181
|
+
if (sourceMatcher.match(grid, x, y, 0)) {
|
|
182
|
+
is_source[index] = 1;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!passMatcher.match(grid, x, y, 0)) {
|
|
186
|
+
is_passable[index] = 0;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
130
189
|
|
|
131
|
-
|
|
190
|
+
tClassify.addDependency(tInitialize);
|
|
132
191
|
|
|
133
|
-
|
|
192
|
+
//collect start texels
|
|
193
|
+
const tCollectSources = countTask(0, texel_count, index => {
|
|
194
|
+
if (is_source[index] === 1) {
|
|
134
195
|
open.push(index);
|
|
135
196
|
inOpen.set(index, true);
|
|
136
197
|
|
|
137
|
-
|
|
138
|
-
target[index] = 0;
|
|
198
|
+
steps[index] = 0;
|
|
139
199
|
}
|
|
140
200
|
});
|
|
141
201
|
|
|
142
|
-
tCollectSources.addDependency(
|
|
202
|
+
tCollectSources.addDependency(tClassify);
|
|
143
203
|
|
|
144
204
|
/**
|
|
145
205
|
*
|
|
@@ -148,14 +208,8 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
|
148
208
|
*/
|
|
149
209
|
function processNeighbor(iNeighbor, iCurrent) {
|
|
150
210
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const x = iNeighbor % width;
|
|
154
|
-
|
|
155
|
-
const isPassable = passMatcher.match(grid, x, y, 0);
|
|
156
|
-
|
|
157
|
-
if (!isPassable) {
|
|
158
|
-
//cell is an obstacle
|
|
211
|
+
if (is_passable[iNeighbor] === 0) {
|
|
212
|
+
//texel is an obstacle
|
|
159
213
|
return;
|
|
160
214
|
}
|
|
161
215
|
|
|
@@ -164,16 +218,16 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
|
164
218
|
return;
|
|
165
219
|
}
|
|
166
220
|
|
|
167
|
-
const
|
|
221
|
+
const d = steps[iCurrent] + 1;
|
|
168
222
|
|
|
169
223
|
const notInOpen = !inOpen.get(iNeighbor);
|
|
170
224
|
|
|
171
225
|
if (notInOpen) {
|
|
172
|
-
|
|
226
|
+
steps[iNeighbor] = d;
|
|
173
227
|
open.push(iNeighbor);
|
|
174
228
|
inOpen.set(iNeighbor, true);
|
|
175
|
-
} else if (
|
|
176
|
-
|
|
229
|
+
} else if (d < steps[iNeighbor]) {
|
|
230
|
+
steps[iNeighbor] = d;
|
|
177
231
|
open.updateElementScore(iNeighbor);
|
|
178
232
|
}
|
|
179
233
|
}
|
|
@@ -182,6 +236,14 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
|
182
236
|
name: 'Build Distance Map',
|
|
183
237
|
cycleFunction() {
|
|
184
238
|
if (open.size() === 0) {
|
|
239
|
+
const target = layer.sampler.data;
|
|
240
|
+
|
|
241
|
+
for (let i = 0; i < texel_count; i++) {
|
|
242
|
+
const s = steps[i];
|
|
243
|
+
|
|
244
|
+
target[i] = s === Infinity ? initial : snap_to_integer(s / resolution);
|
|
245
|
+
}
|
|
246
|
+
|
|
185
247
|
return TaskSignal.EndSuccess;
|
|
186
248
|
}
|
|
187
249
|
|
|
@@ -217,6 +279,6 @@ export class GridTaskBuildSourceDistanceMap extends GridTaskGenerator {
|
|
|
217
279
|
|
|
218
280
|
tMain.addDependency(tCollectSources);
|
|
219
281
|
|
|
220
|
-
return new TaskGroup([tInitialize, tCollectSources, tMain]);
|
|
282
|
+
return new TaskGroup([tInitialize, tClassify, tCollectSources, tMain]);
|
|
221
283
|
}
|
|
222
284
|
}
|
|
@@ -4,9 +4,10 @@ export class GridDataLayer {
|
|
|
4
4
|
* @param {string} id
|
|
5
5
|
* @param {BinaryDataType} type
|
|
6
6
|
* @param {number} [resolution=1]
|
|
7
|
+
* @param {boolean} [stretch=false] see {@link GridDataLayer#stretch}
|
|
7
8
|
* @returns {GridDataLayer}
|
|
8
9
|
*/
|
|
9
|
-
static from(id: string, type: BinaryDataType, resolution?: number): GridDataLayer;
|
|
10
|
+
static from(id: string, type: BinaryDataType, resolution?: number, stretch?: boolean): GridDataLayer;
|
|
10
11
|
/**
|
|
11
12
|
* Unique ID to reference the layer
|
|
12
13
|
* @type {string}
|
|
@@ -17,13 +18,31 @@ export class GridDataLayer {
|
|
|
17
18
|
* @type {number}
|
|
18
19
|
*/
|
|
19
20
|
resolution: number;
|
|
21
|
+
/**
|
|
22
|
+
* Whether a texel is stretched over the cells it stands for, laid from the grid's first corner, rather than
|
|
23
|
+
* centred on a point.
|
|
24
|
+
*
|
|
25
|
+
* Unstretched, texel `t` is centred on grid position `t / resolution` (`texel = grid · resolution`, see
|
|
26
|
+
* `generation/COORDINATES.md`), and the grid must be a whole number of texels across. At resolution 0.5 that puts
|
|
27
|
+
* texel 0 on cell 0, texel 1 on cell 2, and a cell between them half way.
|
|
28
|
+
*
|
|
29
|
+
* Stretched, texel `t` covers the cells from `t / resolution` up to `(t + 1) / resolution`, counted from the grid's
|
|
30
|
+
* first corner: at resolution 0.5, cells `2t` and `2t + 1`; at 2, a cell is two texels across. The layer has as
|
|
31
|
+
* many texels as covering the grid takes, so any grid size will do; on one that is not a whole number of texels
|
|
32
|
+
* across, the last row and column reach past the grid's far edge.
|
|
33
|
+
*
|
|
34
|
+
* At resolution 1 the two are the same. Set it before the layer is added to a grid.
|
|
35
|
+
*
|
|
36
|
+
* @type {boolean}
|
|
37
|
+
*/
|
|
38
|
+
stretch: boolean;
|
|
20
39
|
/**
|
|
21
40
|
*
|
|
22
41
|
* @type {Sampler2D}
|
|
23
42
|
*/
|
|
24
43
|
sampler: Sampler2D;
|
|
25
44
|
/**
|
|
26
|
-
*
|
|
45
|
+
* Size of the grid the sampler was last sized for, in cells; the empty sampler a layer starts with is for none
|
|
27
46
|
* @type {Vector2}
|
|
28
47
|
*/
|
|
29
48
|
size: Vector2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridDataLayer.d.ts","sourceRoot":"","sources":["../../../../../src/generation/grid/layers/GridDataLayer.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GridDataLayer.d.ts","sourceRoot":"","sources":["../../../../../src/generation/grid/layers/GridDataLayer.js"],"names":[],"mappings":"AAqBA;IA4CI;;;;;;;OAOG;IACH,gBANW,MAAM,QACN,cAAc,eACd,MAAM,YACN,OAAO,GACL,aAAa,CAwBzB;IAzED;;;OAGG;IACH,IAFU,MAAM,CAER;IAER;;;OAGG;IACH,YAFU,MAAM,CAED;IAEf;;;;;;;;;;;;;;;;OAgBG;IACH,SAFU,OAAO,CAED;IAEhB;;;OAGG;IACH,SAFU,SAAS,CAEkB;IAErC;;;OAGG;IACH,MAFU,OAAO,CAEQ;IAkCzB;;;;OAIG;IACH,UAHW,MAAM,KACN,MAAM,QAehB;IAIL;;;OAGG;IACH,0BAFU,OAAO,CAEsB;CANtC;0BA9GyB,uDAAuD;oBAF7D,+BAA+B;+BAJpB,6CAA6C"}
|
|
@@ -4,8 +4,21 @@ import {
|
|
|
4
4
|
DataType2TypedArrayConstructorMapping
|
|
5
5
|
} from "../../../core/binary/type/DataType2TypedArrayConstructorMapping.js";
|
|
6
6
|
import Vector2 from "../../../core/geom/Vector2.js";
|
|
7
|
+
import { snap_to_integer } from "../../../core/math/snap_to_integer.js";
|
|
7
8
|
import { Sampler2D } from "../../../engine/graphics/texture/sampler/Sampler2D.js";
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Texels of `1 / resolution` cells it takes to cover `cells` cells from the first: `ceil(cells · resolution)` of the
|
|
12
|
+
* product meant, so 525 cells at 1/75 are seven texels, not eight.
|
|
13
|
+
*
|
|
14
|
+
* @param {number} cells
|
|
15
|
+
* @param {number} resolution
|
|
16
|
+
* @returns {number}
|
|
17
|
+
*/
|
|
18
|
+
function texels_covering(cells, resolution) {
|
|
19
|
+
return Math.ceil(snap_to_integer(cells * resolution));
|
|
20
|
+
}
|
|
21
|
+
|
|
9
22
|
export class GridDataLayer {
|
|
10
23
|
/**
|
|
11
24
|
* Unique ID to reference the layer
|
|
@@ -19,6 +32,25 @@ export class GridDataLayer {
|
|
|
19
32
|
*/
|
|
20
33
|
resolution = 1;
|
|
21
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Whether a texel is stretched over the cells it stands for, laid from the grid's first corner, rather than
|
|
37
|
+
* centred on a point.
|
|
38
|
+
*
|
|
39
|
+
* Unstretched, texel `t` is centred on grid position `t / resolution` (`texel = grid · resolution`, see
|
|
40
|
+
* `generation/COORDINATES.md`), and the grid must be a whole number of texels across. At resolution 0.5 that puts
|
|
41
|
+
* texel 0 on cell 0, texel 1 on cell 2, and a cell between them half way.
|
|
42
|
+
*
|
|
43
|
+
* Stretched, texel `t` covers the cells from `t / resolution` up to `(t + 1) / resolution`, counted from the grid's
|
|
44
|
+
* first corner: at resolution 0.5, cells `2t` and `2t + 1`; at 2, a cell is two texels across. The layer has as
|
|
45
|
+
* many texels as covering the grid takes, so any grid size will do; on one that is not a whole number of texels
|
|
46
|
+
* across, the last row and column reach past the grid's far edge.
|
|
47
|
+
*
|
|
48
|
+
* At resolution 1 the two are the same. Set it before the layer is added to a grid.
|
|
49
|
+
*
|
|
50
|
+
* @type {boolean}
|
|
51
|
+
*/
|
|
52
|
+
stretch = false;
|
|
53
|
+
|
|
22
54
|
/**
|
|
23
55
|
*
|
|
24
56
|
* @type {Sampler2D}
|
|
@@ -26,22 +58,24 @@ export class GridDataLayer {
|
|
|
26
58
|
sampler = new Sampler2D([], 1, 0, 0);
|
|
27
59
|
|
|
28
60
|
/**
|
|
29
|
-
*
|
|
61
|
+
* Size of the grid the sampler was last sized for, in cells; the empty sampler a layer starts with is for none
|
|
30
62
|
* @type {Vector2}
|
|
31
63
|
*/
|
|
32
|
-
size = new Vector2(
|
|
64
|
+
size = new Vector2(0, 0);
|
|
33
65
|
|
|
34
66
|
/**
|
|
35
67
|
*
|
|
36
68
|
* @param {string} id
|
|
37
69
|
* @param {BinaryDataType} type
|
|
38
70
|
* @param {number} [resolution=1]
|
|
71
|
+
* @param {boolean} [stretch=false] see {@link GridDataLayer#stretch}
|
|
39
72
|
* @returns {GridDataLayer}
|
|
40
73
|
*/
|
|
41
|
-
static from(id, type, resolution = 1) {
|
|
74
|
+
static from(id, type, resolution = 1, stretch = false) {
|
|
42
75
|
assert.isString(id, 'id');
|
|
43
76
|
assert.enum(type, BinaryDataType, 'type');
|
|
44
77
|
assert.isNumber(resolution, 'resolution');
|
|
78
|
+
assert.isBoolean(stretch, 'stretch');
|
|
45
79
|
|
|
46
80
|
const TypedArrayConstructor = DataType2TypedArrayConstructorMapping[type];
|
|
47
81
|
|
|
@@ -54,6 +88,7 @@ export class GridDataLayer {
|
|
|
54
88
|
layer.sampler.data = new TypedArrayConstructor();
|
|
55
89
|
|
|
56
90
|
layer.resolution = resolution;
|
|
91
|
+
layer.stretch = stretch;
|
|
57
92
|
|
|
58
93
|
layer.id = id;
|
|
59
94
|
|
|
@@ -73,7 +108,11 @@ export class GridDataLayer {
|
|
|
73
108
|
|
|
74
109
|
this.size.set(x, y);
|
|
75
110
|
|
|
76
|
-
|
|
111
|
+
if (this.stretch) {
|
|
112
|
+
this.sampler.resize(texels_covering(x, this.resolution), texels_covering(y, this.resolution));
|
|
113
|
+
} else {
|
|
114
|
+
this.sampler.resize(x * this.resolution, y * this.resolution);
|
|
115
|
+
}
|
|
77
116
|
}
|
|
78
117
|
|
|
79
118
|
}
|
|
@@ -40,7 +40,13 @@ export class GridCellActionPlaceTags extends GridCellAction {
|
|
|
40
40
|
*/
|
|
41
41
|
resize(x: number, y: number): void;
|
|
42
42
|
/**
|
|
43
|
-
* Write placement tags into the grid at a given position, the tag pattern will be rotated as specified
|
|
43
|
+
* Write placement tags into the grid at a given position, the tag pattern will be rotated as specified.
|
|
44
|
+
*
|
|
45
|
+
* Each cell of the pattern lands on a grid cell, and goes into that cell's texels as a write at the cell would
|
|
46
|
+
* ({@link grid_to_texel_span}): the texel a {@link CellMatcherLayerBitMaskTest} reads at that cell, all of the
|
|
47
|
+
* cell's texels on a stretched layer finer than the grid, and on a coarser layer the texel holding the cell, where
|
|
48
|
+
* it is combined by {@link operation} with whatever else the pattern put there. A pattern cell off the grid writes
|
|
49
|
+
* nothing, though a texel of a coarse layer may reach there.
|
|
44
50
|
*/
|
|
45
51
|
execute(data: any, x: any, y: any, rotation: any): void;
|
|
46
52
|
}
|