@woosh/meep-engine 2.164.0 → 2.165.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.
- package/build/bundle-worker-terrain.js +1 -1
- package/package.json +1 -1
- package/src/core/binary/BitImage2.d.ts +91 -0
- package/src/core/binary/BitImage2.d.ts.map +1 -0
- package/src/core/binary/BitImage2.js +242 -0
- package/src/core/geom/2d/oriented-box/min_area_rect_2d.d.ts +22 -0
- package/src/core/geom/2d/oriented-box/min_area_rect_2d.d.ts.map +1 -0
- package/src/core/geom/2d/oriented-box/min_area_rect_2d.js +69 -0
- package/src/core/geom/2d/packing/skyline.d.ts +116 -0
- package/src/core/geom/2d/packing/skyline.d.ts.map +1 -0
- package/src/core/geom/2d/packing/skyline.js +258 -0
- package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts +18 -0
- package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts.map +1 -0
- package/src/core/geom/2d/triangle/tri2_rasterize_conservative.js +86 -0
- package/src/core/geom/3d/atlas/ATLAS_PORT_PLAN.md +486 -0
- package/src/core/geom/3d/atlas/BFF_PLAN.md +174 -0
- package/src/core/geom/3d/atlas/Chart.d.ts +58 -0
- package/src/core/geom/3d/atlas/Chart.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/Chart.js +77 -0
- package/src/core/geom/3d/atlas/REVIEW_02.md +392 -0
- package/src/core/geom/3d/atlas/atlas_bench_lib.d.ts +73 -0
- package/src/core/geom/3d/atlas/atlas_bench_lib.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/atlas_bench_lib.js +315 -0
- package/src/core/geom/3d/atlas/atlas_chart_type.d.ts +17 -0
- package/src/core/geom/3d/atlas/atlas_chart_type.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/atlas_chart_type.js +16 -0
- package/src/core/geom/3d/atlas/atlas_compute_charts.d.ts +25 -0
- package/src/core/geom/3d/atlas/atlas_compute_charts.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/atlas_compute_charts.js +188 -0
- package/src/core/geom/3d/atlas/atlas_extract_chart.d.ts +17 -0
- package/src/core/geom/3d/atlas/atlas_extract_chart.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/atlas_extract_chart.js +107 -0
- package/src/core/geom/3d/atlas/atlas_generate.d.ts +39 -0
- package/src/core/geom/3d/atlas/atlas_generate.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/atlas_generate.js +43 -0
- package/src/core/geom/3d/atlas/atlas_test_fixtures.d.ts +84 -0
- package/src/core/geom/3d/atlas/atlas_test_fixtures.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/atlas_test_fixtures.js +266 -0
- package/src/core/geom/3d/atlas/atlas_write_chart_uvs.d.ts +25 -0
- package/src/core/geom/3d/atlas/atlas_write_chart_uvs.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/atlas_write_chart_uvs.js +36 -0
- package/src/core/geom/3d/atlas/data/atlas_build_edge_dihedrals.d.ts +22 -0
- package/src/core/geom/3d/atlas/data/atlas_build_edge_dihedrals.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/data/atlas_build_edge_dihedrals.js +62 -0
- package/src/core/geom/3d/atlas/data/atlas_build_edge_lengths.d.ts +9 -0
- package/src/core/geom/3d/atlas/data/atlas_build_edge_lengths.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/data/atlas_build_edge_lengths.js +33 -0
- package/src/core/geom/3d/atlas/data/atlas_build_face_areas.d.ts +9 -0
- package/src/core/geom/3d/atlas/data/atlas_build_face_areas.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/data/atlas_build_face_areas.js +50 -0
- package/src/core/geom/3d/atlas/io/atlas_mesh_weld_colocals.d.ts +27 -0
- package/src/core/geom/3d/atlas/io/atlas_mesh_weld_colocals.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/io/atlas_mesh_weld_colocals.js +39 -0
- package/src/core/geom/3d/atlas/io/bt_loop_uv.d.ts +22 -0
- package/src/core/geom/3d/atlas/io/bt_loop_uv.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/io/bt_loop_uv.js +57 -0
- package/src/core/geom/3d/atlas/pack/ChartPlacement.d.ts +36 -0
- package/src/core/geom/3d/atlas/pack/ChartPlacement.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/pack/ChartPlacement.js +46 -0
- package/src/core/geom/3d/atlas/pack/atlas_pack_charts.d.ts +62 -0
- package/src/core/geom/3d/atlas/pack/atlas_pack_charts.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/pack/atlas_pack_charts.js +551 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_param_validity.d.ts +22 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_param_validity.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_param_validity.js +73 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_bff.d.ts +37 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_bff.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_bff.js +270 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_lscm.d.ts +23 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_lscm.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_lscm.js +224 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_ortho.d.ts +14 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_ortho.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_parameterize_ortho.js +38 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_stretch_metric.d.ts +22 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_stretch_metric.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/param/atlas_chart_stretch_metric.js +86 -0
- package/src/core/geom/3d/atlas/param/atlas_piecewise_resegment.d.ts +20 -0
- package/src/core/geom/3d/atlas/param/atlas_piecewise_resegment.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/param/atlas_piecewise_resegment.js +183 -0
- package/src/core/geom/3d/atlas/param/fit_plane_basis.d.ts +27 -0
- package/src/core/geom/3d/atlas/param/fit_plane_basis.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/param/fit_plane_basis.js +66 -0
- package/src/core/geom/3d/atlas/segment/RegionGraph.d.ts +31 -0
- package/src/core/geom/3d/atlas/segment/RegionGraph.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/segment/RegionGraph.js +40 -0
- package/src/core/geom/3d/atlas/segment/atlas_build_region_graph.d.ts +23 -0
- package/src/core/geom/3d/atlas/segment/atlas_build_region_graph.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/segment/atlas_build_region_graph.js +136 -0
- package/src/core/geom/3d/atlas/segment/atlas_compute_planar_regions.d.ts +24 -0
- package/src/core/geom/3d/atlas/segment/atlas_compute_planar_regions.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/segment/atlas_compute_planar_regions.js +77 -0
- package/src/core/geom/3d/atlas/segment/atlas_merge_charts.d.ts +27 -0
- package/src/core/geom/3d/atlas/segment/atlas_merge_charts.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/segment/atlas_merge_charts.js +113 -0
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts.d.ts +44 -0
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts.js +275 -0
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.d.ts +22 -0
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.d.ts.map +1 -0
- package/src/core/geom/3d/atlas/segment/atlas_segment_charts_atomic.js +199 -0
- package/src/core/geom/3d/line/line3_compute_point_segment_point_distance_unfolded.d.ts +32 -0
- package/src/core/geom/3d/line/line3_compute_point_segment_point_distance_unfolded.d.ts.map +1 -0
- package/src/core/geom/3d/line/line3_compute_point_segment_point_distance_unfolded.js +64 -0
- package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.d.ts +20 -0
- package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.d.ts.map +1 -0
- package/src/core/geom/3d/mat4/m4_from_rotation_translation_scale.js +66 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +13 -11
- package/src/core/geom/3d/sphere/sphere_compute_bounding_of_2_spheres.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/sphere_compute_bounding_of_2_spheres.js +4 -3
- package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +4 -3
- package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/Quadric3.js +4 -3
- package/src/core/geom/3d/topology/simplify/quadratic/apply_border_penalty_to_vertex_quadrics.d.ts.map +1 -1
- package/src/core/geom/3d/topology/simplify/quadratic/apply_border_penalty_to_vertex_quadrics.js +10 -6
- package/src/core/geom/3d/topology/struct/TopoMesh.js +2 -2
- package/src/core/geom/3d/topology/struct/TopoTriangle.d.ts +0 -2
- package/src/core/geom/3d/topology/struct/TopoTriangle.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/TopoTriangle.js +2 -2
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_face_find_path_polyanya.js +8 -27
- package/src/core/geom/vec3/v3_cotangent.d.ts +20 -0
- package/src/core/geom/vec3/v3_cotangent.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_cotangent.js +29 -0
- package/src/core/geom/vec3/v3_matrix3_multiply.d.ts +19 -0
- package/src/core/geom/vec3/v3_matrix3_multiply.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_matrix3_multiply.js +30 -0
- package/src/core/geom/vec3/v3_multiply.d.ts +16 -0
- package/src/core/geom/vec3/v3_multiply.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_multiply.js +19 -0
- package/src/core/math/linalg/cg/cg_solve.d.ts +24 -0
- package/src/core/math/linalg/cg/cg_solve.d.ts.map +1 -0
- package/src/core/math/linalg/cg/cg_solve.js +106 -0
- package/src/core/math/linalg/cg/cg_solve_normal_equations.d.ts +21 -0
- package/src/core/math/linalg/cg/cg_solve_normal_equations.d.ts.map +1 -0
- package/src/core/math/linalg/cg/cg_solve_normal_equations.js +59 -0
- package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts +19 -0
- package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.d.ts.map +1 -0
- package/src/core/math/linalg/eigen/matrix_symmetric_3x3_eigen.js +117 -0
- package/src/core/math/linalg/sparse/SparseMatrixCSR.d.ts +50 -0
- package/src/core/math/linalg/sparse/SparseMatrixCSR.d.ts.map +1 -0
- package/src/core/math/linalg/sparse/SparseMatrixCSR.js +88 -0
- package/src/core/math/linalg/sparse/spm_matvec.d.ts +9 -0
- package/src/core/math/linalg/sparse/spm_matvec.d.ts.map +1 -0
- package/src/core/math/linalg/sparse/spm_matvec.js +22 -0
- package/src/core/math/linalg/sparse/spm_matvec_transpose.d.ts +12 -0
- package/src/core/math/linalg/sparse/spm_matvec_transpose.d.ts.map +1 -0
- package/src/core/math/linalg/sparse/spm_matvec_transpose.js +29 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.d.ts +39 -0
- package/src/core/math/physics/mie/MIE_PARTICLES_STANDARD_PRECOMPUTED.js +22 -1
- package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.d.ts.map +1 -1
- package/src/core/math/physics/mie/compute_mie_particle_properties_rgb.js +32 -9
- package/src/core/math/physics/mie/compute_mie_phase.d.ts +2 -3
- package/src/core/math/physics/mie/compute_mie_phase.d.ts.map +1 -1
- package/src/core/math/physics/mie/compute_mie_phase.js +1 -3
- package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts +0 -1
- package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts.map +1 -1
- package/src/core/math/physics/mie/lorenz_mie_coefs.js +0 -7
- package/src/engine/ecs/attachment/TransformAttachmentBinding.js +3 -3
- package/src/engine/ecs/gui/hud/HeadsUpDisplaySystem.js +2 -2
- package/src/engine/ecs/terrain/ecs/Terrain.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/Terrain.js +4 -3
- package/src/engine/ecs/terrain/tiles/TerrainTile.js +2 -2
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +9 -8
- package/src/engine/graphics/GraphicsEngine.d.ts.map +1 -1
- package/src/engine/graphics/GraphicsEngine.js +2 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +2 -2
- package/src/engine/graphics/ecs/decal/v2/prototypeDecalSystem.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometry.js +2 -2
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +0 -1
- package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/tube/build/computeFrenetFrames.js +8 -7
- package/src/engine/graphics/geometry/MikkT/AvgTSpace.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/AvgTSpace.js +11 -6
- package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.js +2 -3
- package/src/engine/graphics/geometry/MikkT/CalcTexArea.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/CalcTexArea.js +3 -4
- package/src/engine/graphics/geometry/MikkT/DegenEpilogue.js +4 -4
- package/src/engine/graphics/geometry/MikkT/EvalTspace.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/EvalTspace.js +11 -8
- package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js +7 -8
- package/src/engine/graphics/geometry/MikkT/GenerateTSpaces.js +8 -8
- package/src/engine/graphics/geometry/MikkT/InitTriInfo.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/InitTriInfo.js +30 -25
- package/src/engine/graphics/geometry/MikkT/MikkTSpace.js +7 -7
- package/src/engine/graphics/geometry/MikkT/NormalizeSafe.d.ts +0 -1
- package/src/engine/graphics/geometry/MikkT/NormalizeSafe.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/NormalizeSafe.js +6 -4
- package/src/engine/graphics/geometry/MikkT/STSpace.d.ts +0 -2
- package/src/engine/graphics/geometry/MikkT/STSpace.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/STSpace.js +3 -3
- package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.d.ts +0 -2
- package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/v3_scale_dot_sub_normalize.js +0 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts +0 -2
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.d.ts.map +1 -1
- package/src/engine/graphics/impostors/octahedral/ImpostorBaker.js +4 -3
- package/src/engine/graphics/impostors/octahedral/grid/HemiOctahedralUvEncoder.js +2 -2
- package/src/engine/graphics/impostors/octahedral/grid/UvEncoder.d.ts +17 -7
- package/src/engine/graphics/impostors/voxel/VoxelImpostorBaker.js +2 -2
- package/src/engine/graphics/particles/particular/engine/utils/volume/ParticleVolume.js +3 -3
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +4 -3
- package/src/engine/graphics/render/forward_plus/LightManager.js +2 -2
- package/src/engine/graphics/render/forward_plus/model/Decal.d.ts +0 -2
- package/src/engine/graphics/render/forward_plus/model/Decal.d.ts.map +1 -1
- package/src/engine/graphics/render/forward_plus/model/Decal.js +3 -3
- package/src/engine/graphics/render/forward_plus/prototype/prototypeLightManager.js +4 -3
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +6 -4
- package/src/engine/graphics/sh3/lightmap/ARTIFACTS_PLAN.md +146 -0
- package/src/engine/graphics/sh3/lightmap/CODE_REVIEW.md +121 -0
- package/src/engine/graphics/sh3/lightmap/LIGHTMAPPER_REVIEW.md +183 -0
- package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.d.ts +90 -0
- package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/bake_lightmap_for_scene.js +678 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_build_geometry.d.ts +32 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_build_geometry.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_build_geometry.js +155 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_denoise.d.ts +49 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_denoise.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_denoise.js +136 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_dilate.d.ts +19 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_dilate.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_dilate.js +89 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_gather.d.ts +54 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_gather.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_gather.js +168 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_rasterize_triangle.d.ts +30 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_rasterize_triangle.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_rasterize_triangle.js +145 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_seam_fix.d.ts +38 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_seam_fix.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/lightmap_seam_fix.js +152 -0
- package/src/engine/graphics/sh3/lightmap/prototypeLightmapBaker.d.ts +2 -0
- package/src/engine/graphics/sh3/lightmap/prototypeLightmapBaker.d.ts.map +1 -0
- package/src/engine/graphics/sh3/lightmap/prototypeLightmapBaker.js +186 -0
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/PathTracedMesh.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/PathTracer.js +2 -2
- package/src/engine/graphics/sh3/path_tracer/prepare_scene_gltf.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/prepare_scene_gltf.js +6 -4
- package/src/engine/graphics/sh3/path_tracer/prototypePathTracer.js +3 -3
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +5 -4
- package/src/engine/graphics/sh3/sky/hosek/prototype_hosek.js +2 -2
- package/src/engine/input/devices/KeyboardDevice.d.ts +61 -14
- package/src/engine/input/devices/KeyboardDevice.d.ts.map +1 -1
- package/src/engine/input/devices/KeyboardDevice.js +41 -15
- package/src/engine/input/devices/isHTMLElementFocusable.d.ts.map +1 -1
- package/src/engine/input/devices/isHTMLElementFocusable.js +2 -9
- package/src/engine/sound/simulation/prototypeAcousticSolver.js +261 -143
|
@@ -1 +1 @@
|
|
|
1
|
-
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function e(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint8ClampedArray||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float16Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}class n{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,r){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,r){throw new Error("Not Implemented")}}class r{describeTo(t){throw new Error("Not Implemented")}}class i extends r{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class s{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class o extends n{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,r){return this.appendList(t,e,n,new s(r)),this}appendList(t,e,n,r){let i=!1;this.appendText(t);const s=r[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())i&&this.appendText(e),this.appendDescriptionOf(t.value),i=!0;return this.appendText(n),this}}class a extends o{value="";appendText(t){return this.value+=t,this}}function c(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n="value"){if(-1===e.indexOf(t))throw new Error(`${n} must be one of [${e.join(", ")}], instead was '${t}'`)}const u=["string","boolean","number","object","undefined","function","symbol"];function d(t,e,n,r,i){let s,o,a;for(a=0;a<i;a++)s=e+a,o=r+a,n[o]=t[s]}c.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},c.notEqual=function(t,e,n){c(t!==e,n)},c.notOk=function(t,e){c(!t,e)},c.equal=function(t,e,n){if(t!==e){const r=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${r}`:r)}},c.logicalyEqual=function(t,e,n){},c.ok=c,c.greaterThan=function(t,e,n){if(!(t>e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} > ${e}.`,new Error(r)}},c.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} >= ${e}.`,new Error(r)}},c.lessThan=function(t,e,n){if(!(t<e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} < ${e}.`,new Error(r)}},c.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} <= ${e}.`,new Error(r)}},c.typeOf=function(t,e,n="value"){h(typeof t,u);const r=typeof t;if(r!==e)throw new Error(`expected ${n} to be ${e}, instead was '${r}'(=${t})`)},c.arrayHas=function(t,e,n="Array does not contain the item"){},c.arrayHasNo=function(t,e,n="Array contains the item"){},c.arrayEqual=function(e,n,r="Arrays are not equal"){if(!t(e,n))throw new Error(r)},c.isOneOf=h,c.isInstanceOf=function(t,e,n="value",r=e.name){},c.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},c.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},c.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},c.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},c.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},c.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},c.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},c.isPositiveInteger=function(t,e="value"){if(t<=0)throw new Error(`${e} must be > 0, instead was ${t}`)},c.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},c.isArrayLike=function(t,n="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(e(t))return!0;const n=t.length;return!("number"!=typeof n&&!Number.isInteger(n)||n<0)}(t))throw new Error(`expected ${n} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},c.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},c.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},c.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},c.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},c.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},c.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},c.that=function(t,e,n){if(n.matches(t))return;const r=new a;throw r.appendText(`Expected ${e} to be `),n.describeTo(r),r.appendText(" instead "),n.describeMismatch(t,r),new Error(r.value)};const l=new Uint32Array(781250);function f(t,e){return t<e?e:t}function g(t,e){return t<e?t:e}function p(t,e,n,r,i,s){const o=n[r+0],a=n[r+1],c=n[r+2],h=n[r+3],u=n[r+4],d=n[r+5],l=i[s+0],p=i[s+1],y=i[s+2],w=i[s+3],_=i[s+4],m=i[s+5],v=g(o,l),A=g(a,p),x=g(c,y),b=f(h,w),E=f(u,_),F=f(d,m);t[e+0]=v,t[e+1]=A,t[e+2]=x,t[e+3]=b,t[e+4]=E,t[e+5]=F}function y(t,e,n,r,i,s,o,a){t[e]=n,t[e+1]=r,t[e+2]=i,t[e+3]=s,t[e+4]=o,t[e+5]=a}function w(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function m(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];y(t,e,r,i,s,r,i,s)}function v(t,e,n){const r=t[e],i=t[e+1],s=t[e+2];return function(t,e,n,r){const i=r[0],s=r[1],o=r[2];return function(t,e,n){const r=1023*t,i=1023*e,s=1023*n;return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(r),Math.round(i),Math.round(s))}((t-i)/(r[3]-i),(e-s)/(r[4]-s),(n-o)/(r[5]-o))}(.5*(r+t[e+3]),.5*(i+t[e+4]),.5*(s+t[e+5]),n)}l.pointer=0;const A=l;class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,r,i,s,o,a){const c=this.getLeafAddress(t);y(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){d(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=w(e[0],e[1],e[2],e[3],e[4],e[5])}return t}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;const n=A.pointer;let r,i,s=n;A[s++]=0,A[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=A[s+1],a=A[s];r=a,i=n;const c=v(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;v(o,7*r+e,t)<c;)r++;for(;v(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(A[s++]=a,A[s++]=i),r<n&&(A[s++]=r,A[s++]=n)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),r=7*t+n,i=7*e+n;!function(t,e,n,r,i){for(let i=0;i<7;i++){const s=e+i,o=r+i,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,r,this.__data_float32,i)}build(){const t=this.__node_count_binary,e=6*t;let n,r,i,s,o=Math.floor(Math.log(t)/Math.log(2));i=Math.pow(2,o),r=6*(i-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<i;n++){const t=n<<1,i=t+1,s=e+7*t;i<a?p(c,r,c,s,c,e+7*i):t<a?d(c,s,c,r,6):m(this.__data_float32,r,r-6),r+=6}for(o--;o>=0;o--)for(i=1<<o,s=i-1,n=0;n<i;n++){const t=6*(1+(s<<1));p(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function E(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function F(t,e,n,r,i,s){const o=t.getLeafAddress(e);!function(t,e,n,r,i,s){const o=3*r,a=3*i,c=3*s,h=n[o],u=n[o+1],d=n[o+2],l=n[a],f=n[a+1],g=n[a+2],p=n[c],y=n[c+1],w=n[c+2];t[e]=E(h,l,p),t[e+1]=E(u,f,y),t[e+2]=E(d,g,w),t[e+3]=b(h,l,p),t[e+4]=b(u,f,y),t[e+5]=b(d,g,w)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function $(t){return 1===t.faces.length}function U(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}var S,z="undefined"!=typeof Float32Array?Float32Array:Array;function C(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function V(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function B(){}function q(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function L(t,e,n=0,r=t.length){const i=n+r;for(let r=n;r<i;r++)if(t[r]===e)return t.splice(r,1),!0;return!1}function T(t,e){return t.v0===e||t.v1===e}function I(t,e,n){const r=t.v0,i=t.v1;return!(r!==e&&r!==n||i!==e&&i!==n)}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)}),S=new z(3),z!=Float32Array&&(S[0]=0,S[1]=0,S[2]=0);let M=0;class k{index=M++;v0=null;v1=null;faces=[];lengthSqr=-1;get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new k;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsEdge(this)||(t(`Missing back-link from face[${i}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,r=n.length;for(let t=0;t<r;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){throw new Error('deprecated, use "query_edge_is_boundary" instead')}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,r=t.y,i=t.z,s=n-e.x,o=r-e.y,a=i-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,r=e.length;for(let i=0;i<r;i++){const r=e[i];r.removeEdge(t),-1===n.indexOf(r)&&(n.push(r),r.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){V(this.faces,t)}removeFace(t){L(this.faces,t)}getOtherVertex(t){return U(this,t)}containsVertex(t){return T(this,t)}containsBothVertices(t,e){return I(this,t,e)}containsSameVerticesAs(t){return I(this,t.v0,t.v1)}}function N(t,e,n){const r=t.length;for(let i=0;i<r;i++)t[i]===e&&(t[i]=n);return t}function O(t,e,n){return t*t+e*e+n*n}function j(t,e,n,r,i,s,o,a,c,h,u){const d=c-s,l=h-o,f=u-a,g=n-s,p=r-o,y=i-a,w=l*y-f*p,_=f*g-d*y,m=d*p-l*g,v=O(w,_,m);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const A=1/Math.sqrt(v),x=w*A,b=_*A,E=m*A;t[e]=x,t[e+1]=b,t[e+2]=E}k.prototype.isTopoEdge=!0;let D=0;class R{index=D++;edges=[];faces=[];x=0;y=0;z=0;get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new R;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsVertex(this)||(t(`Missing back-link from face[${i}]`),e=!1);const i=this.edges,s=i.length;for(let n=0;n<s;n++)T(i[n],this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,r=this.z,i=t.x-e,s=t.y-n,o=t.z-r,Math.sqrt(i*i+s*s+o*o);var e,n,r,i,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return V(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){L(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}replaceEdge(t,e){const n=this.edges,r=n.indexOf(t);n[r]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return L(this.edges,t)}computeNeighbourVertices(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].getOtherVertex(this);t[e+n]=i,n++}return n}static from(t,e,n){const r=new R;return r.x=t,r.y=e,r.z=n,r}}R.prototype.isTopoVertex=!0;let P=0;class J{index=P++;vertices=[];edges=[];normal=[0,0,0];get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),C(this.normal,t.normal)}clone(){const t=new J;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,r=n.length;3!==r&&(t(`Expected number of vertices is 3, instead got ${r}`),e=!1);for(let i=0;i<r;i++)n[i].containsFace(this)||(t(`Missing back-link from vertex[${i}]`),e=!1);const i=this.edges,s=i.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)i[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){N(this.edges,t,e)}replaceVertex(t,e){N(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],r=t[2];return e===n||e===r||n===r}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,r=n.length;for(let t=0;t<r;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return V(this.edges,t)}removeEdge(t){L(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],r=t[2];!function(t,e,n,r){j(t,0,e[0],e[1],e[2],n[0],n[1],n[2],r[0],r[1],r[2])}(this.normal,e,n,r)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].faces,o=i.length;for(let r=0;r<o;r++){const s=i[r];s!==this&&(t[e+n]=s,n++)}}return n}static fromPoints(t,e,n,r,i,s,o,a,c){const h=R.from(t,e,n),u=R.from(r,i,s),d=R.from(o,a,c),l=new k,f=new k,g=new k;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new J;return p.edges.push(l,f,g),p.vertices.push(h,u,d),h.faces.push(p),u.faces.push(p),d.faces.push(p),l.faces.push(p),f.faces.push(p),g.faces.push(p),h.edges.push(l,g),u.edges.push(l,f),d.edges.push(f,g),p}}J.prototype.isTopoFace=!0;class H{vertices=[];__edges=new Set;__faces=new Set;get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t=B){let e=!0,n="",r=0;function i(i){t(`${n}[${r}]: ${i}`),e=!1}n="Edge",r=0;const s=this.getEdges();for(let t of s){t.validate(i),this.containsVertex(t.v0)||i("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||i("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||i(`Link to off-mesh face[${t}]`)}r++}const o=this.getFaces();n="Face",r=0;for(let t of o){t.validate(i);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||i(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||i(`Link to off-mesh vertex[${t}]`)}r++}const a=this.vertices,c=a.length;n="Vertex";for(let t=0;t<c;t++){r=t;const e=a[t];e.validate(i);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||i(`Link to off-mesh edge[${t}]`)}const o=e.faces,c=o.length;for(let t=0;t<c;t++){const e=o[t];this.containsFace(e)||i(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new H;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let r=0;r<n;r++){const n=e[r];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new J;C(n.normal,t.normal);const r=t.vertices;for(let t=0;t<3;t++){const i=r[t];let s=e.get(i.index);void 0===s&&(s=new R,s.index=i.index,s.x=i.x,s.y=i.y,s.z=i.z,e.set(i.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],r=e[1],i=e[2],s=this.ensureEdge(n,r),o=this.ensureEdge(r,i),a=this.ensureEdge(i,n);s.addUniqueFace(t),o.addUniqueFace(t),a.addUniqueFace(t),t.addUniqueEdge(s),t.addUniqueEdge(o),t.addUniqueEdge(a)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){V(this.vertices,t)}removeVertex(t){throw new Error("deprecated, use tm_vertex_kill_only instead")}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){throw new Error("deprecated, use tm_edge_kill_only instead")}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const r=t.vertices,i=r.length;for(let t=0;t<i;t++){const e=r[t];this.addUniqueVertex(e)}}removeFace(t){throw new Error("deprecated, use tm_face_kill_only instead")}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,r=n.length;for(let i=0;i<r;i++){const r=n[i];if(U(r,t)===e)return r}const i=new k;return i.v0=t,i.v1=e,t.edges.push(i),e.edges.push(i),this.__edges.add(i),i}mergeEdges(){const t=this.getEdges();for(let n of t){const r=n.v0,i=n.v1;for(let s of t){if(n===s)continue;const t=s.v0,o=s.v1;if(r===t){if(i!==o)continue}else{if(r!==o)continue;if(i!==t)continue}e=s,this.__edges.delete(e),n.merge(s)}}var e}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}setVerticesFromArray(t){const e=t.length/3,n=this.vertices;for(let r=0;r<e;r++){const e=3*r,i=new R;i.index=r,i.x=t[e],i.y=t[e+1],i.z=t[e+2],n[r]=i}}setFacesFromIndexArray(t){const e=t.length,n=this.vertices,r=e/3;for(let e=0;e<r;e++){const r=3*e,i=t[r],s=t[r+1],o=t[r+2];this.createTriangle(e,n[i],n[s],n[o])}}setFacedUnindexed(){const t=this.vertices,e=t.length/3;for(let n=0;n<e;n++){const e=3*n;this.createTriangle(n,t[e],t[e+1],t[e+2])}}build(t,e){this.setVerticesFromArray(t),null==e?this.setFacedUnindexed():this.setFacesFromIndexArray(e)}createTriangle(t,e,n,r){const i=new J;i.index=t;const s=this.ensureEdge(e,n),o=this.ensureEdge(n,r),a=this.ensureEdge(r,e);return s.faces.push(i),o.faces.push(i),a.faces.push(i),i.vertices.push(e,n,r),i.edges.push(s,o,a),e.faces.push(i),n.faces.push(i),r.faces.push(i),this.__faces.add(i),i}toString(){return`TopoMesh{ vertices: ${q(this.vertices.length)}, edges: ${q(this.getEdges().size)}, faces: ${q(this.getFaces().size)} }`}}H.prototype.isTopoMesh=!0;const W=[],G=[],Y="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)W[t]=Y[t],G[Y.charCodeAt(t)]=t;function K(t,e,n){const r=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);r.push(W[(i=e)>>18&63]+W[i>>12&63]+W[i>>6&63]+W[63&i])}var i;return r.join("")}G["-".charCodeAt(0)]=62,G["_".charCodeAt(0)]=63;const Q=16383;class X{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=Q){const n=K(t,e,e+Q>i?i:e+Q);r.push(n)}if(1===n){const n=t[e-1];r.push(W[n>>2]+W[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(W[n>>10]+W[n>>4&63]+W[n<<2&63]+"=")}return r.join("")}(new Uint8Array(t))}static decode(t){return function(t){let e;const n=function(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=n[0],i=n[1],s=new Uint8Array(function(t,e){return 3*(t+e)/4-e}(r,i));let o=0;const a=i>0?r-4:r;let c=0;for(;c<a;c+=4){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2),a=t.charCodeAt(c+3);e=G[n]<<18|G[r]<<12|G[i]<<6|G[a],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=255&e}if(2===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1);e=G[n]<<2|G[r]>>4,s[o++]=255&e}if(1===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2);e=G[n]<<10|G[r]<<4|G[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const Z="uint8",tt="uint16",et="uint32",nt="int8",rt="int16",it="int32",st="float16",ot="float32",at="float64",ct={[Z]:Uint8Array,[tt]:Uint16Array,[et]:Uint32Array,[nt]:Int8Array,[rt]:Int16Array,[it]:Int32Array,[st]:Float16Array,[ot]:Float32Array,[at]:Float64Array};function ht(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return Z;case Uint16Array:return tt;case Uint32Array:return et;case Int8Array:return nt;case Int16Array:return rt;case Int32Array:return it;case Float16Array:return st;case Float32Array:return ot;case Array:case Float64Array:return at;default:throw new Error(`unsupported constructor type ${e.name}`)}}function ut(t,e,n){return t<e?e:t>n?n:t}function dt(t,e,n){return(e-t)*n+t}function lt(t,e,n,r,i){return.5*(r-e+(2*e-5*n+4*r-i+(3*(n-r)+i-e)*t)*t)*t+n}const ft=4294967295;function gt(t){const e=t>>0;return ft-((t-e)*ft>>>0)^e}class pt{constructor(t=[],e=1,n=0,r=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(r)||n<0)throw new Error(`height must be a non-negative integer, instead was ${r}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*r*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*r*e}`);this.width=n,this.height=r,this.itemSize=e,this.data=t,this.version=0}sampleCatmullRomUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelCatmullRomUV(t,e,i)}sampleChannelCatmullRomUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelCatmullRom(r,i,n)}sampleChannelCatmullRom(t,e,n){const r=Math.floor(t),i=Math.floor(e),s=t-r,o=e-i,a=s*(s*(1-.5*s)-.5),c=o*(o*(1-.5*o)-.5),h=s*(.5+s*(2-1.5*s)),u=o*(.5+o*(2-1.5*o)),d=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+h,g=1+o*o*(1.5*o-2.5)+u,p=r-1,y=i-1,w=r+2,_=i+2,m=r+h/f,v=i+u/g;let A=0;return A+=this.sampleChannelBilinear(p,y,n)*a*c,A+=this.sampleChannelBilinear(m,y,n)*f*c,A+=this.sampleChannelBilinear(w,y,n)*d*c,A+=this.sampleChannelBilinear(p,v,n)*a*g,A+=this.sampleChannelBilinear(m,v,n)*f*g,A+=this.sampleChannelBilinear(w,v,n)*d*g,A+=this.sampleChannelBilinear(p,_,n)*a*l,A+=this.sampleChannelBilinear(m,_,n)*f*l,A+=this.sampleChannelBilinear(w,_,n)*d*l,A}sampleBicubicUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelBicubicUV(t,e,i)}sampleBicubic(t,e,n,r){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const r=t*this.width,i=e*this.height;return this.sampleChannelBicubic(r-.5,i-.5,n)}sampleChannelBicubic(t,e,n){const r=this.itemSize,i=this.width,s=this.height,o=this.data,a=i*r,c=i-1,h=s-1,u=ut(t,0,c),d=ut(e,0,h),l=0|u,p=0|d,y=u-l,w=d-p,_=f(0,l-1),m=f(0,p-1),v=g(c,l+1),A=g(h,p+1),x=g(c,v+1),b=m*a+n,E=p*a+n,F=A*a+n,$=g(h,A+1)*a+n,U=_*r,S=l*r,z=v*r,C=x*r,V=o[b+U],B=o[b+S],q=o[b+z],L=o[b+C],T=o[E+U],I=o[E+S],M=o[E+z],k=o[E+C],N=o[F+U],O=o[F+S],j=o[F+z],D=o[F+C],R=o[$+U],P=o[$+S],J=o[$+z],H=o[$+C],W=lt(y,V,B,q,L),G=lt(y,T,I,M,k),Y=lt(y,N,O,j,D),K=lt(y,R,P,J,H);return lt(w,W,G,Y,K)}sampleBilinearUV(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelBilinear(r,i,n)}sampleChannelBilinear(t,e,n){const r=this.itemSize,i=this.width,s=i*r,o=this.height-1,a=ut(t,0,i-1),c=ut(e,0,o),h=a>>>0,u=c>>>0,d=u*s,l=h*r+n,f=d+l;let g,p;g=a===h?h:h+1,p=c===u?u:u+1;const y=this.data,w=y[f];if(h===g&&u===p)return w;const _=a-h,m=c-u,v=g*r+n,A=p*s,x=A+l,b=A+v,E=y[d+v],F=y[x],$=y[b],U=dt(w,E,_),S=dt(F,$,_);return dt(U,S,m)}sampleNearestUV(t,e,n){const r=this.width,i=this.height,s=Math.round(t*r-.5),o=Math.round(e*i-.5);this.read(ut(s,0,r-1),ut(o,0,i-1),n)}readChannel(t,e,n){const r=(e*this.width+t)*this.itemSize+n;return this.data[r]}read(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)n[t]=this.data[s+t]}write(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)this.data[s+t]=n[t];this.version++}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,r=t%n,i=t/n|0;e.set(r,i)}copy(t,e,n,r,i,s,o){const a=Math.min(s,t.width-e,this.width-r),c=Math.min(o,t.height-n,this.height-i),h=this.itemSize,u=t.itemSize,d=Math.min(h,u),l=h*this.width,f=u*t.width,g=t.data,p=this.data;let y,w,_;for(w=0;w<c;w++){const t=(w+i)*l,s=(w+n)*f;for(y=0;y<a;y++){const n=t+(y+r)*h,i=s+(y+e)*u;for(_=0;_<d;_++)p[n+_]=g[i+_]}}this.version++}zeroFill(t,e,n,r){const i=ut(t,0,this.width),s=ut(e,0,this.height),o=ut(t+n,0,this.width),a=ut(e+r,0,this.height),c=this.data,h=this.itemSize,u=h*this.width,d=i*h,l=o*h;let f;for(f=s;f<a;f++){const t=f*u;c.fill(0,t+d,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,r=this.data,i=r.length;for(let s=t;s<i;s+=n)r[s]=e;this.version++}fill(t,e,n,r,i){const s=this.width,o=this.height,a=ut(t,0,s),c=ut(e,0,o),h=ut(t+n,0,s),u=ut(e+r,0,o),d=this.data,l=this.itemSize,f=l*s;let g,p,y;for(g=c;g<u;g++){const t=g*f;for(p=a;p<h;p++){const e=t+p*l;for(y=0;y<l;y++)d[e+y]=i[y]}}this.version++}writeChannel(t,e,n,r){const i=(e*this.width+t)*this.itemSize+n;this.data[i]=r,this.version++}traverseCircle(t,e,n,r){let i,s;const o=0|t,a=0|e,c=n*n,h=Math.ceil(n);for(s=-h;s<=h;s++){const t=s*s;for(i=-h;i<=h;i++)i*i+t<=c&&r(o+i,a+s,this)}}resize(t,e,n=!0){const r=this.width,i=this.height;if(r===t&&i===e)return;const s=this.itemSize,o=t*e*s,a=this.data,c=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float16Array)return Float16Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===r)c.set(a.subarray(0,Math.min(a.length,o)));else{const n=g(e,i),o=g(t,r);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const i=(e*t+n)*s,o=(e*r+n)*s;for(let t=0;t<s;t++)c[i+t]=a[o+t]}}this.width=t,this.height=e,this.data=c,this.version++}computeByteSize(){let t;const e=this.data;return t=Array.isArray(e)?8*e.length:e.byteLength,t+280}equals(e){return null!=e&&(this===e||this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const r=e.length;if(r!==n.length)return!1;const i=e.constructor;if(i!==n.constructor)return!1;if(0===r)return!0;if(r<128)return t(e,n);const s=e.byteLength;if(s!==n.byteLength)return!1;const o=e.buffer,a=n.buffer,c=e.byteOffset,h=n.byteOffset;if(o===a&&c===h)return!0;let u=e,d=n;const l=i.BYTES_PER_ELEMENT,f=function(t,e,n){const r=t|e|n;return 0==(3&r)?4:0==(1&r)?2:1}(c,h,s),g="undefined"!=typeof Float16Array&&i===Float16Array||i===Float32Array||i===Float64Array;return!g&&l<4&&4===f?(u=new Uint32Array(o,c,s>>>2),d=new Uint32Array(a,h,s>>>2)):!g&&l<2&&2===f&&(u=new Uint16Array(o,c,s>>>1),d=new Uint16Array(a,h,s>>>1)),t(u,d)}(this.data,e.data))}hash(){const t=this.itemSize,n=this.width,r=this.height,i=this.data;let s=((65535&n)<<16|65535&r)^t;const o=n*r*t;if(e(i))s^=function(t,e,n){const r=e|n;return 0==(3&r)?function(t,e,n){let r=n;for(let e=0;e<n;++e)r=(r<<5)-r+t[e];return r}(new Uint32Array(t,e,n>>>2),0,n>>>2):0==(1&r)?function(t,e,n){let r=n,i=0;for(0!=(1&n)&&(r=(r<<5)-r+t[i++]);i<n;i+=2)r=(r<<5)-r+(t[i]<<16|t[i+1]);return r}(new Uint16Array(t,e,n>>>1),0,n>>>1):function(t,e,n){let r=n,i=0;const s=3&n;for(;i<0+s;i++)r=(r<<5)-r+t[i];for(;i<n;i+=4)r=(r<<5)-r+(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24);return r}(new Uint8Array(t,e,n),0,n)}(i.buffer,i.byteOffset,i.byteLength);else for(let t=0;t<o;++t)s=(s<<5)-s+gt(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new pt(t,this.itemSize,this.width,this.height)}toJSON(){const t=X.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:ht(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=ct[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=X.decode(i);this.data=new s(t)}else{if(!Array.isArray(i))throw new Error("Unsupported data format");this.data=new s(i)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const r=new Uint8ClampedArray(e*n*t);return new pt(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new pt(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new pt(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new pt(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new pt(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new pt(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new pt(r,t,e,n)}static float16(t,e,n){const r=new Float16Array(e*n*t);return new pt(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new pt(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new pt(r,t,e,n)}}function yt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2];t[e]+=i,t[e+1]+=s,t[e+2]+=o}function wt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;j(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[c],s[c+1],s[c+2])}function _t(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=O(i,s,o),c=0!==a?1/Math.sqrt(a):1;t[e]=i*c,t[e+1]=s*c,t[e+2]=o*c}pt.prototype.isSampler2D=!0,pt.typeName="Sampler2D";const mt=new Float64Array(3),vt={build:function(t,e,n,r,i,s){const o=n.x*s,a=n.y*s,c=o-1,h=a-1;let u=0,d=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),p=new Float32Array(2*l);let y,w;const _=n.y/i.y/h,m=n.x/i.x/c,v=e.y/i.y,A=e.x/i.x,x=i.x*r.x,b=i.y*r.y;let E,F,$;for(y=0;y<a;y++){const e=y*_+v;for($=e*b,w=0;w<o;w++){const n=w*m+A;E=n*x,F=t.sampleChannelBicubicUV(n,e,0),f[u]=E,f[u+1]=F,f[u+2]=$,p[d]=n,p[d+1]=e,u+=3,d+=2}}u=0;const U=new(function(t){if(t<=256)return Uint8Array;if(t<=65536)return Uint16Array;if(t<=4294967295)return Uint32Array;throw new Error(`Unsupported size ${t}`)}(f.length/3))(c*h*6);for(y=0;y<h;y++)for(w=0;w<c;w++){const t=w+o*y,e=w+o*(y+1),n=w+1+o*(y+1),r=w+1+o*y;U[u]=t,U[u+1]=e,U[u+2]=r,U[u+3]=e,U[u+4]=n,U[u+5]=r,u+=6}return function(t,e,n){const r=n.length;for(let i=0;i<r;i+=3){const r=n[i],s=n[i+1],o=n[i+2];wt(mt,0,r,s,o,t),yt(e,3*r,mt,0),yt(e,3*s,mt,0),yt(e,3*o,mt,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)_t(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:p}}};self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const r=n.length/3;t.setLeafCount(r),t.initialize_structure();for(let i=0;i<r;i++){const r=3*i;F(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:pt,BufferedGeometryArraysBuilder:vt,tensionOptimizeUV:function(t,e,n,r=3){const i=new H;i.build(t,n),i.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<r;t++)t:for(let t=0;t<s;t++){const n=i.vertices[t],r=n.edges,s=r.length;if(0===s)continue;let o=0,a=0,c=0;for(let t=0;t<s;t++){const i=r[t];if($(i))continue t;const s=2*U(i,n).index,h=e[s],u=e[s+1],d=1/i.lengthSqr;o+=h*d,a+=u*d,c+=d}const h=o/c,u=a/c,d=2*n.index;e[d]=h,e[d+1]=u}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s>e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s<e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}}};
|
|
1
|
+
function t(t,e){const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function e(t){if("object"!=typeof t)return!1;if(null===t)return!1;const e=t.constructor;return e===Uint8Array||e===Uint8ClampedArray||e===Uint16Array||e===Uint32Array||e===Int8Array||e===Int16Array||e===Int32Array||e===Float16Array||e===Float32Array||e===Float64Array||e===BigUint64Array||e===BigInt64Array}class n{appendDescriptionOf(t){throw new Error("Not Implemented")}appendList(t,e,n,r){throw new Error("Not Implemented")}appendText(t){throw new Error("Not Implemented")}appendValue(t){throw new Error("Not Implemented")}appendValueList(t,e,n,r){throw new Error("Not Implemented")}}class r{describeTo(t){throw new Error("Not Implemented")}}class i extends r{value;constructor(t){super(),this.value=t}describeTo(t){t.appendValue(this.value)}}class s{#t;constructor(t){this.#t=t}*[Symbol.iterator](){for(const t of this.#t)yield new i(t)}}class o extends n{appendDescriptionOf(t){return t.describeTo(this),this}#e(t){this.appendText('"'),this.appendText(t),this.appendText('"')}appendValue(t){return null==t?this.appendText("null"):void 0===t?this.appendText("undefined"):"string"==typeof t?this.#e(t):"number"==typeof t?this.appendText(function(t){return String(t)}(t)):Array.isArray(t)?this.appendValueList("[",", ","]",t):(this.appendText("<"),this.appendText(function(t){try{return String(t)}catch(t){return"VALUE@0"}}(t)),this.appendText(">")),this}appendValueList(t,e,n,r){return this.appendList(t,e,n,new s(r)),this}appendList(t,e,n,r){let i=!1;this.appendText(t);const s=r[Symbol.iterator]();for(let t=s.next();!0!==t.done;t=s.next())i&&this.appendText(e),this.appendDescriptionOf(t.value),i=!0;return this.appendText(n),this}}class a extends o{value="";appendText(t){return this.value+=t,this}}function c(t,e){if(!t)throw new Error(e||"AssertionError")}function h(t,e,n="value"){if(-1===e.indexOf(t))throw new Error(`${n} must be one of [${e.join(", ")}], instead was '${t}'`)}const u=["string","boolean","number","object","undefined","function","symbol"];function d(t,e,n,r,i){let s,o,a;for(a=0;a<i;a++)s=e+a,o=r+a,n[o]=t[s]}c.enum=function(t,e,n="value"){for(let n in e)if(e[n]===t)return;throw new Error(`${n}(=${t}) is not a valid enumerable value, valid values are: [${Object.values(e).join(", ")}]`)},c.notEqual=function(t,e,n){c(t!==e,n)},c.notOk=function(t,e){c(!t,e)},c.equal=function(t,e,n){if(t!==e){const r=`${t} !== ${e}`;throw new Error(void 0!==n&&""!==n?`${n}. ${r}`:r)}},c.logicalyEqual=function(t,e,n){},c.ok=c,c.greaterThan=function(t,e,n){if(!(t>e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} > ${e}.`,new Error(r)}},c.greaterThanOrEqual=function(t,e,n){if(!(t>=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} >= ${e}.`,new Error(r)}},c.lessThan=function(t,e,n){if(!(t<e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} < ${e}.`,new Error(r)}},c.lessThanOrEqual=function(t,e,n){if(!(t<=e)){let r="";throw void 0!==n&&(r+=n+". "),r+=`Expected ${t} <= ${e}.`,new Error(r)}},c.typeOf=function(t,e,n="value"){h(typeof t,u);const r=typeof t;if(r!==e)throw new Error(`expected ${n} to be ${e}, instead was '${r}'(=${t})`)},c.arrayHas=function(t,e,n="Array does not contain the item"){},c.arrayHasNo=function(t,e,n="Array contains the item"){},c.arrayEqual=function(e,n,r="Arrays are not equal"){if(!t(e,n))throw new Error(r)},c.isOneOf=h,c.isInstanceOf=function(t,e,n="value",r=e.name){},c.isNumber=function(t,e="value"){const n=typeof t;if("number"!==n)throw new Error(`expected ${e} to be a number, instead was '${n}'(=${t})`)},c.isString=function(t,e="value"){const n=typeof t;if("string"!==n)throw new Error(`expected ${e} to be a string, instead was '${n}'(=${t})`)},c.isBoolean=function(t,e="value"){const n=typeof t;if("boolean"!==n)throw new Error(`expected ${e} to be a boolean, instead was '${n}'(=${t})`)},c.isFunction=function(t,e="value"){const n=typeof t;if("function"!==n)throw new Error(`expected ${e} to be a function, instead was '${n}'(=${t})`)},c.isObject=function(t,e="value"){const n=typeof t;if("object"!==n)throw new Error(`expected ${e} to be an object, instead was '${n}'(=${t})`)},c.isInteger=function(t,e="value"){if(!Number.isInteger(t))throw new Error(`${e} must be an integer, instead was ${t}`)},c.isNonNegativeInteger=function(t,e="value"){if(t<0)throw new Error(`${e} must be >= 0, instead was ${t}`)},c.isPositiveInteger=function(t,e="value"){if(t<=0)throw new Error(`${e} must be > 0, instead was ${t}`)},c.isArray=function(t,e="value"){if(!Array.isArray(t))throw new Error(`expected ${e} to be an array, instead was something else (typeof ='${typeof t}')`)},c.isArrayLike=function(t,n="value"){if(!function(t){if(Array.isArray(t))return!0;if("object"!=typeof t)return!1;if(null===t)return!1;if(e(t))return!0;const n=t.length;return!("number"!=typeof n&&!Number.isInteger(n)||n<0)}(t))throw new Error(`expected ${n} to be an array-like structure, instead was something else (typeof ='${typeof t}')`)},c.defined=function(t,e="value"){if(void 0===t)throw new Error(`${e} is undefined`)},c.undefined=function(t,e="value"){if(void 0!==t)throw new Error(`${e} is not undefined`)},c.isNull=function(t,e){if(null!==t)throw new Error(`${e} is NOT null`)},c.notNull=function(t,e="value"){if(null===t)throw new Error(`${e} is null`)},c.notNaN=function(t,e="value"){if(Number.isNaN(t))throw new Error(`${e} must be a valid number, instead was NaN`)},c.isFinite=function(t,e="value"){if(!Number.isFinite(t))throw new Error(`${e} must be a finite number, instead was ${t}`)},c.that=function(t,e,n){if(n.matches(t))return;const r=new a;throw r.appendText(`Expected ${e} to be `),n.describeTo(r),r.appendText(" instead "),n.describeMismatch(t,r),new Error(r.value)};const l=new Uint32Array(781250);function f(t,e){return t<e?e:t}function g(t,e){return t<e?t:e}function p(t,e,n,r,i,s){const o=n[r+0],a=n[r+1],c=n[r+2],h=n[r+3],u=n[r+4],d=n[r+5],l=i[s+0],p=i[s+1],y=i[s+2],w=i[s+3],_=i[s+4],m=i[s+5],v=g(o,l),A=g(a,p),x=g(c,y),b=f(h,w),E=f(u,_),$=f(d,m);t[e+0]=v,t[e+1]=A,t[e+2]=x,t[e+3]=b,t[e+4]=E,t[e+5]=$}function y(t,e,n,r,i,s,o,a){t[e]=n,t[e+1]=r,t[e+2]=i,t[e+3]=s,t[e+4]=o,t[e+5]=a}function w(t,e,n,r,i,s){const o=r-t,a=s-n;return(i-e)*(o+a)+a*o}function _(t){let e=t;return e=50331903&(e|e<<16),e=50393103&(e|e<<8),e=51130563&(e|e<<4),e=153391689&(e|e<<2),e}function m(t,e,n){const r=t[n],i=t[n+1],s=t[n+2];y(t,e,r,i,s,r,i,s)}function v(t,e,n){const r=t[e],i=t[e+1],s=t[e+2];return function(t,e,n,r){const i=r[0],s=r[1],o=r[2];return function(t,e,n){const r=1023*t,i=1023*e,s=1023*n;return function(t,e,n){return _(t)|_(e)<<1|_(n)<<2}(Math.round(r),Math.round(i),Math.round(s))}((t-i)/(r[3]-i),(e-s)/(r[4]-s),(n-o)/(r[5]-o))}(.5*(r+t[e+3]),.5*(i+t[e+4]),.5*(s+t[e+5]),n)}l.pointer=0;const A=l;class x{__data_buffer;__data_float32;__data_uint32;__node_count_binary=0;__node_count_leaf=0;constructor(){this.data=new ArrayBuffer(320)}estimateByteSize(){return this.data.byteLength+248}getTotalBoxCount(){return this.__node_count_binary+this.__node_count_leaf}get binary_node_count(){return this.__node_count_binary}get leaf_node_count(){return this.__node_count_leaf}getLeafBlockAddress(){return 6*this.__node_count_binary}get float32(){return this.__data_float32}get uint32(){return this.__data_uint32}set data(t){this.__data_buffer=t,this.__data_float32=new Float32Array(this.__data_buffer),this.__data_uint32=new Uint32Array(this.__data_buffer)}get data(){return this.__data_buffer}getNodeAddress(t){const e=this.__node_count_binary,n=t-e;return n<0?6*t:6*e+7*n}initialize_structure(){const t=4*(6*this.__node_count_binary+7*this.__node_count_leaf);this.__data_buffer.byteLength<t&&(this.data=new ArrayBuffer(t))}setLeafCount(t){this.__node_count_leaf=t;const e=function(t){let e=t-1;return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e++,e}(t);this.__node_count_binary=t<=1?e:e-1}getLeafAddress(t){return 7*t+6*this.__node_count_binary}setLeafData(t,e,n,r,i,s,o,a){const c=this.getLeafAddress(t);y(this.__data_float32,c,n,r,i,s,o,a),this.__data_uint32[c+6]=e}readBounds(t,e,n){d(this.__data_float32,t,e,n,6)}readLeafPayload(t){const e=this.getLeafBlockAddress()+7*t+6;return this.__data_uint32[e]}compute_total_surface_area(){let t=0;const e=new Float32Array(6);for(let n=0;n<this.getTotalBoxCount();n++){let r;r=n<this.__node_count_binary?6*n:7*(n-this.__node_count_binary)+this.getLeafBlockAddress(),this.readBounds(r,e,0),t+=w(e[0],e[1],e[2],e[3],e[4],e[5])}return t}sort_morton(t){const e=6*this.__node_count_binary;if(this.__node_count_leaf<2)return;const n=A.pointer;let r,i,s=n;A[s++]=0,A[s++]=this.__node_count_leaf-1;const o=this.__data_float32;for(;s>n;){s-=2;const n=A[s+1],a=A[s];r=a,i=n;const c=v(o,7*(a+n>>1)+e,t);for(;r<=i;){for(;v(o,7*r+e,t)<c;)r++;for(;v(o,7*i+e,t)>c;)i--;r<=i&&(r!==i&&this.__swap_leaves(r,i),r++,i--)}a<i&&(A[s++]=a,A[s++]=i),r<n&&(A[s++]=r,A[s++]=n)}}__swap_leaves(t,e){const n=this.getLeafBlockAddress(),r=7*t+n,i=7*e+n;!function(t,e,n,r,i){for(let i=0;i<7;i++){const s=e+i,o=r+i,a=n[o];n[o]=t[s],t[s]=a}}(this.__data_float32,r,this.__data_float32,i)}build(){const t=this.__node_count_binary,e=6*t;let n,r,i,s,o=Math.floor(Math.log(t)/Math.log(2));i=Math.pow(2,o),r=6*(i-1);const a=this.__node_count_leaf,c=this.__data_float32;for(n=0;n<i;n++){const t=n<<1,i=t+1,s=e+7*t;i<a?p(c,r,c,s,c,e+7*i):t<a?d(c,s,c,r,6):m(this.__data_float32,r,r-6),r+=6}for(o--;o>=0;o--)for(i=1<<o,s=i-1,n=0;n<i;n++){const t=6*(1+(s<<1));p(c,6*s,c,t,c,t+6),s++}}}function b(t,e,n){let r=t;return r<e&&(r=e),r<n&&(r=n),r}function E(t,e,n){let r=t;return r>e&&(r=e),r>n&&(r=n),r}function $(t,e,n,r,i,s){const o=t.getLeafAddress(e);!function(t,e,n,r,i,s){const o=3*r,a=3*i,c=3*s,h=n[o],u=n[o+1],d=n[o+2],l=n[a],f=n[a+1],g=n[a+2],p=n[c],y=n[c+1],w=n[c+2];t[e]=E(h,l,p),t[e+1]=E(u,f,y),t[e+2]=E(d,g,w),t[e+3]=b(h,l,p),t[e+4]=b(u,f,y),t[e+5]=b(d,g,w)}(t.__data_float32,o,n,r,i,s),t.__data_uint32[o+6]=e}function F(t){return 1===t.faces.length}function U(t,e){return t.v0===e?t.v1:t.v1===e?t.v0:null}function S(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2];t[e]=i,t[e+1]=s,t[e+2]=o}function z(t,e){return-1===t.indexOf(e)&&(t.push(e),!0)}function C(){}function V(t,e=","){return t.toString().replace(/\B(?=(\d{3})+(?!\d))/g,e)}function B(t,e,n=0,r=t.length){const i=n+r;for(let r=n;r<i;r++)if(t[r]===e)return t.splice(r,1),!0;return!1}function L(t,e){return t.v0===e||t.v1===e}function q(t,e,n){const r=t.v0,i=t.v1;return!(r!==e&&r!==n||i!==e&&i!==n)}let T=0;class I{index=T++;v0=null;v1=null;faces=[];lengthSqr=-1;get byteSize(){return 128+8*this.faces.length+10}getVertexByIndex(t){if(0===t)return this.v0;if(1===t)return this.v1;throw new Error("Index out of bounds")}copy(t){this.v0=t.v0,this.v1=t.v1,this.lengthSqr=t.lengthSqr,this.faces=t.faces.slice()}clone(){const t=new I;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsEdge(this)||(t(`Missing back-link from face[${i}]`),e=!1);return this.v0.containsEdge(this)||(t("Missing back-link from vertex v0"),e=!1),this.v1.containsEdge(this)||(t("Missing back-link from vertex v1"),e=!1),e}isLinked(){return this.v0.containsEdge(this)}unlink(){const t=this.v0,e=this.v1;t.removeEdge(this),t!==e&&e.removeEdge(this);const n=this.faces,r=n.length;for(let t=0;t<r;t++)n[t].removeEdge(this)}isDegenerateEdge(){return this.v0===this.v1}isTopologyBorder(){throw new Error('deprecated, use "query_edge_is_boundary" instead')}get length(){return this.lengthSqr<0&&this.computeSquaredLength(),Math.sqrt(this.lengthSqr)}computeSquaredLength(){const t=this.v0,e=this.v1,n=t.x,r=t.y,i=t.z,s=n-e.x,o=r-e.y,a=i-e.z;this.lengthSqr=s*s+o*o+a*a}replaceVertex(t,e){t===this.v0&&(this.v0=e),t===this.v1&&(this.v1=e)}merge(t){const e=t.faces,n=this.faces,r=e.length;for(let i=0;i<r;i++){const r=e[i];r.removeEdge(t),-1===n.indexOf(r)&&(n.push(r),r.addUniqueEdge(this))}t.v0.removeEdge(t),t.v1.removeEdge(t)}containsFace(t){return-1!==this.faces.indexOf(t)}addFace(t){this.faces.push(t)}addUniqueFace(t){z(this.faces,t)}removeFace(t){B(this.faces,t)}getOtherVertex(t){return U(this,t)}containsVertex(t){return L(this,t)}containsBothVertices(t,e){return q(this,t,e)}containsSameVerticesAs(t){return q(this,t.v0,t.v1)}}function M(t,e,n){const r=t.length;for(let i=0;i<r;i++)t[i]===e&&(t[i]=n);return t}function k(t,e,n){return t*t+e*e+n*n}function N(t,e,n,r,i,s,o,a,c,h,u){const d=c-s,l=h-o,f=u-a,g=n-s,p=r-o,y=i-a,w=l*y-f*p,_=f*g-d*y,m=d*p-l*g,v=k(w,_,m);if(0===v)return t[e]=0,t[e+1]=1,void(t[e+2]=0);const A=1/Math.sqrt(v),x=w*A,b=_*A,E=m*A;t[e]=x,t[e+1]=b,t[e+2]=E}I.prototype.isTopoEdge=!0;let O=0;class j{index=O++;edges=[];faces=[];x=0;y=0;z=0;get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}get byteSize(){return 112+8*this.edges.length+10+8*this.faces.length+10}copy(t){this.x=t.x,this.y=t.y,this.z=t.z,this.index=t.index,this.faces=t.faces.slice(),this.edges=t.edges.slice()}clone(){const t=new j;return t.copy(this),t}validate(t){let e=!0;const n=this.faces,r=n.length;for(let i=0;i<r;i++)n[i].containsVertex(this)||(t(`Missing back-link from face[${i}]`),e=!1);const i=this.edges,s=i.length;for(let n=0;n<s;n++)L(i[n],this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}distanceTo(t){return e=this.x,n=this.y,r=this.z,i=t.x-e,s=t.y-n,o=t.z-r,Math.sqrt(i*i+s*s+o*o);var e,n,r,i,s,o}addFace(t){this.faces.push(t)}addUniqueFace(t){return z(this.faces,t)}containsFace(t){return-1!==this.faces.indexOf(t)}removeFace(t){B(this.faces,t)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return z(this.edges,t)}replaceEdge(t,e){const n=this.edges,r=n.indexOf(t);n[r]=e}containsEdge(t){return-1!==this.edges.indexOf(t)}removeEdge(t){return B(this.edges,t)}computeNeighbourVertices(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].getOtherVertex(this);t[e+n]=i,n++}return n}static from(t,e,n){const r=new j;return r.x=t,r.y=e,r.z=n,r}}j.prototype.isTopoVertex=!0;let D=0;class R{index=D++;vertices=[];edges=[];normal=[0,0,0];get byteSize(){return 100+8*this.vertices.length+10+8*this.edges.length+10+24+10}copy(t){this.index=t.index,this.vertices=t.vertices.slice(),this.edges=t.edges.slice(),S(this.normal,0,t.normal,0)}clone(){const t=new R;return t.copy(this),t}validate(t){let e=!0;const n=this.vertices,r=n.length;3!==r&&(t(`Expected number of vertices is 3, instead got ${r}`),e=!1);for(let i=0;i<r;i++)n[i].containsFace(this)||(t(`Missing back-link from vertex[${i}]`),e=!1);const i=this.edges,s=i.length;3!==s&&(t(`Expected number of edges is 3, instead got ${s}`),e=!1);for(let n=0;n<s;n++)i[n].containsFace(this)||(t(`Missing back-link from edge[${n}]`),e=!1);return e}isLinked(){return this.vertices[0].containsFace(this)}replaceEdge(t,e){M(this.edges,t,e)}replaceVertex(t,e){M(this.vertices,t,e)}isDegenerateTopology(){const t=this.vertices,e=t[0],n=t[1],r=t[2];return e===n||e===r||n===r}unlink(){const t=this.vertices,e=t.length;for(let n=0;n<e;n++)t[n].removeFace(this);const n=this.edges,r=n.length;for(let t=0;t<r;t++)n[t].removeFace(this)}addEdge(t){this.edges.push(t)}addUniqueEdge(t){return z(this.edges,t)}removeEdge(t){B(this.edges,t)}containsEdge(t){return-1!==this.edges.indexOf(t)}computeNormal(){const t=this.vertices,e=t[0],n=t[1],r=t[2];!function(t,e,n,r){N(t,0,e[0],e[1],e[2],n[0],n[1],n[2],r[0],r[1],r[2])}(this.normal,e,n,r)}setVertexAt(t,e){this.vertices[t]=e}containsVertex(t){return-1!==this.vertices.indexOf(t)}getEdgeNeighbours(t,e){let n=0;const r=this.edges,i=r.length;for(let s=0;s<i;s++){const i=r[s].faces,o=i.length;for(let r=0;r<o;r++){const s=i[r];s!==this&&(t[e+n]=s,n++)}}return n}static fromPoints(t,e,n,r,i,s,o,a,c){const h=j.from(t,e,n),u=j.from(r,i,s),d=j.from(o,a,c),l=new I,f=new I,g=new I;l.v0=h,l.v1=u,f.v0=u,f.v1=d,g.v0=d,g.v1=h;const p=new R;return p.edges.push(l,f,g),p.vertices.push(h,u,d),h.faces.push(p),u.faces.push(p),d.faces.push(p),l.faces.push(p),f.faces.push(p),g.faces.push(p),h.edges.push(l,g),u.edges.push(l,f),d.edges.push(f,g),p}}R.prototype.isTopoFace=!0;class P{vertices=[];__edges=new Set;__faces=new Set;get byteSize(){let t=0;for(let e=0;e<this.vertices.length;e++)t+=this.vertices[e].byteSize;for(const e of this.__edges)t+=e.byteSize;for(const e of this.__faces)t+=e.byteSize;return t}getEdges(){return this.__edges}getFaces(){return this.__faces}getFaceByIndex(t){for(const e of this.__faces)if(e.index===t)return e}validate(t=C){let e=!0,n="",r=0;function i(i){t(`${n}[${r}]: ${i}`),e=!1}n="Edge",r=0;const s=this.getEdges();for(let t of s){t.validate(i),this.containsVertex(t.v0)||i("Link to off-mesh vertex v0"),this.containsVertex(t.v1)||i("Link to off-mesh vertex v1");const e=t.faces,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsFace(n)||i(`Link to off-mesh face[${t}]`)}r++}const o=this.getFaces();n="Face",r=0;for(let t of o){t.validate(i);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.containsEdge(n)||i(`Link to off-mesh edge[${t}]`)}const s=t.vertices,o=s.length;for(let t=0;t<o;t++){const e=s[t];this.containsVertex(e)||i(`Link to off-mesh vertex[${t}]`)}r++}const a=this.vertices,c=a.length;n="Vertex";for(let t=0;t<c;t++){r=t;const e=a[t];e.validate(i);const n=e.edges,s=n.length;for(let t=0;t<s;t++){const e=n[t];this.containsEdge(e)||i(`Link to off-mesh edge[${t}]`)}const o=e.faces,c=o.length;for(let t=0;t<c;t++){const e=o[t];this.containsFace(e)||i(`Link to off-mesh face[${t}]`)}}return e}clone(){const t=new P;return t.add(this),t}buildVertexMapping(){const t=new Map,e=this.vertices,n=e.length;for(let r=0;r<n;r++){const n=e[r];t.set(n.index,n)}return t}_addWithVertexMap(t,e){const n=t.getFaces();for(let t of n)this.addFaceCopy(t,e)}addFaceCopy(t,e){const n=new R;S(n.normal,0,t.normal,0);const r=t.vertices;for(let t=0;t<3;t++){const i=r[t];let s=e.get(i.index);void 0===s&&(s=new j,s.index=i.index,s.x=i.x,s.y=i.y,s.z=i.z,e.set(i.index,s),this.addVertex(s)),n.setVertexAt(t,s),s.addUniqueFace(n)}this.addFace(n),this.patchFaceEdges(n)}patchFaceEdges(t){const e=t.vertices,n=e[0],r=e[1],i=e[2],s=this.ensureEdge(n,r),o=this.ensureEdge(r,i),a=this.ensureEdge(i,n);s.addUniqueFace(t),o.addUniqueFace(t),a.addUniqueFace(t),t.addUniqueEdge(s),t.addUniqueEdge(o),t.addUniqueEdge(a)}add(t){const e=this.buildVertexMapping();this._addWithVertexMap(t,e)}addVertex(t){this.vertices.push(t)}addUniqueVertex(t){z(this.vertices,t)}removeVertex(t){throw new Error("deprecated, use tm_vertex_kill_only instead")}containsVertex(t){return-1!==this.vertices.indexOf(t)}addEdge(t){this.__edges.add(t)}addUniqueEdge(t){this.__edges.add(t)}removeEdge(t){throw new Error("deprecated, use tm_edge_kill_only instead")}containsEdge(t){return this.__edges.has(t)}addFace(t){this.__faces.add(t)}injectManyFaces(t){for(let e of t)this.injectFace(e)}injectFace(t){this.addFace(t);const e=t.edges,n=e.length;for(let t=0;t<n;t++){const n=e[t];this.addUniqueEdge(n)}const r=t.vertices,i=r.length;for(let t=0;t<i;t++){const e=r[t];this.addUniqueVertex(e)}}removeFace(t){throw new Error("deprecated, use tm_face_kill_only instead")}containsFace(t){return this.__faces.has(t)}ensureEdge(t,e){const n=t.edges,r=n.length;for(let i=0;i<r;i++){const r=n[i];if(U(r,t)===e)return r}const i=new I;return i.v0=t,i.v1=e,t.edges.push(i),e.edges.push(i),this.__edges.add(i),i}mergeEdges(){const t=this.getEdges();for(let n of t){const r=n.v0,i=n.v1;for(let s of t){if(n===s)continue;const t=s.v0,o=s.v1;if(r===t){if(i!==o)continue}else{if(r!==o)continue;if(i!==t)continue}e=s,this.__edges.delete(e),n.merge(s)}}var e}computeEdgeSquaredLengths(){const t=this.getEdges();for(let e of t)e.computeSquaredLength()}setVerticesFromArray(t){const e=t.length/3,n=this.vertices;for(let r=0;r<e;r++){const e=3*r,i=new j;i.index=r,i.x=t[e],i.y=t[e+1],i.z=t[e+2],n[r]=i}}setFacesFromIndexArray(t){const e=t.length,n=this.vertices,r=e/3;for(let e=0;e<r;e++){const r=3*e,i=t[r],s=t[r+1],o=t[r+2];this.createTriangle(e,n[i],n[s],n[o])}}setFacedUnindexed(){const t=this.vertices,e=t.length/3;for(let n=0;n<e;n++){const e=3*n;this.createTriangle(n,t[e],t[e+1],t[e+2])}}build(t,e){this.setVerticesFromArray(t),null==e?this.setFacedUnindexed():this.setFacesFromIndexArray(e)}createTriangle(t,e,n,r){const i=new R;i.index=t;const s=this.ensureEdge(e,n),o=this.ensureEdge(n,r),a=this.ensureEdge(r,e);return s.faces.push(i),o.faces.push(i),a.faces.push(i),i.vertices.push(e,n,r),i.edges.push(s,o,a),e.faces.push(i),n.faces.push(i),r.faces.push(i),this.__faces.add(i),i}toString(){return`TopoMesh{ vertices: ${V(this.vertices.length)}, edges: ${V(this.getEdges().size)}, faces: ${V(this.getFaces().size)} }`}}P.prototype.isTopoMesh=!0;const J=[],H=[],W="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let t=0,e=64;t<e;++t)J[t]=W[t],H[W.charCodeAt(t)]=t;function G(t,e,n){const r=[];for(let s=e;s<n;s+=3){const e=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]);r.push(J[(i=e)>>18&63]+J[i>>12&63]+J[i>>6&63]+J[63&i])}var i;return r.join("")}H["-".charCodeAt(0)]=62,H["_".charCodeAt(0)]=63;const Y=16383;class K{static encode(t){return function(t){const e=t.length,n=e%3,r=[],i=e-n;for(let e=0;e<i;e+=Y){const n=G(t,e,e+Y>i?i:e+Y);r.push(n)}if(1===n){const n=t[e-1];r.push(J[n>>2]+J[n<<4&63]+"==")}else if(2===n){const n=(t[e-2]<<8)+t[e-1];r.push(J[n>>10]+J[n>>4&63]+J[n<<2&63]+"=")}return r.join("")}(new Uint8Array(t))}static decode(t){return function(t){let e;const n=function(t){const e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");let n=t.indexOf("=");return-1===n&&(n=e),[n,n===e?0:4-n%4]}(t),r=n[0],i=n[1],s=new Uint8Array(function(t,e){return 3*(t+e)/4-e}(r,i));let o=0;const a=i>0?r-4:r;let c=0;for(;c<a;c+=4){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2),a=t.charCodeAt(c+3);e=H[n]<<18|H[r]<<12|H[i]<<6|H[a],s[o++]=e>>16&255,s[o++]=e>>8&255,s[o++]=255&e}if(2===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1);e=H[n]<<2|H[r]>>4,s[o++]=255&e}if(1===i){const n=t.charCodeAt(c),r=t.charCodeAt(c+1),i=t.charCodeAt(c+2);e=H[n]<<10|H[r]<<4|H[i]>>2,s[o++]=e>>8&255,s[o++]=255&e}return s}(t).buffer}}const Q="uint8",X="uint16",Z="uint32",tt="int8",et="int16",nt="int32",rt="float16",it="float32",st="float64",ot={[Q]:Uint8Array,[X]:Uint16Array,[Z]:Uint32Array,[tt]:Int8Array,[et]:Int16Array,[nt]:Int32Array,[rt]:Float16Array,[it]:Float32Array,[st]:Float64Array};function at(t){const e=Object.getPrototypeOf(t).constructor;switch(e){case Uint8Array:case Uint8ClampedArray:return Q;case Uint16Array:return X;case Uint32Array:return Z;case Int8Array:return tt;case Int16Array:return et;case Int32Array:return nt;case Float16Array:return rt;case Float32Array:return it;case Array:case Float64Array:return st;default:throw new Error(`unsupported constructor type ${e.name}`)}}function ct(t,e,n){return t<e?e:t>n?n:t}function ht(t,e,n){return(e-t)*n+t}function ut(t,e,n,r,i){return.5*(r-e+(2*e-5*n+4*r-i+(3*(n-r)+i-e)*t)*t)*t+n}const dt=4294967295;function lt(t){const e=t>>0;return dt-((t-e)*dt>>>0)^e}class ft{constructor(t=[],e=1,n=0,r=0){if(!Number.isInteger(e)||e<0)throw new Error(`itemSize must be a non-negative integer, instead was ${e}`);if(!Number.isInteger(n)||n<0)throw new Error(`width must be a non-negative integer, instead was ${n}`);if(!Number.isInteger(r)||n<0)throw new Error(`height must be a non-negative integer, instead was ${r}`);if(void 0===t)throw new Error("data was undefined");if(t.length<n*r*e)throw new Error(`Buffer underflow, data.length(=${t.length}) is too small. Expected at least ${n*r*e}`);this.width=n,this.height=r,this.itemSize=e,this.data=t,this.version=0}sampleCatmullRomUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelCatmullRomUV(t,e,i)}sampleChannelCatmullRomUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelCatmullRom(r,i,n)}sampleChannelCatmullRom(t,e,n){const r=Math.floor(t),i=Math.floor(e),s=t-r,o=e-i,a=s*(s*(1-.5*s)-.5),c=o*(o*(1-.5*o)-.5),h=s*(.5+s*(2-1.5*s)),u=o*(.5+o*(2-1.5*o)),d=s*s*(.5*s-.5),l=o*o*(.5*o-.5),f=1+s*s*(1.5*s-2.5)+h,g=1+o*o*(1.5*o-2.5)+u,p=r-1,y=i-1,w=r+2,_=i+2,m=r+h/f,v=i+u/g;let A=0;return A+=this.sampleChannelBilinear(p,y,n)*a*c,A+=this.sampleChannelBilinear(m,y,n)*f*c,A+=this.sampleChannelBilinear(w,y,n)*d*c,A+=this.sampleChannelBilinear(p,v,n)*a*g,A+=this.sampleChannelBilinear(m,v,n)*f*g,A+=this.sampleChannelBilinear(w,v,n)*d*g,A+=this.sampleChannelBilinear(p,_,n)*a*l,A+=this.sampleChannelBilinear(m,_,n)*f*l,A+=this.sampleChannelBilinear(w,_,n)*d*l,A}sampleBicubicUV(t,e,n){const r=this.itemSize;for(let i=0;i<r;i++)n[i]=this.sampleChannelBicubicUV(t,e,i)}sampleBicubic(t,e,n,r){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBicubic(t,e,s)}sampleChannelBicubicUV(t,e,n){const r=t*this.width,i=e*this.height;return this.sampleChannelBicubic(r-.5,i-.5,n)}sampleChannelBicubic(t,e,n){const r=this.itemSize,i=this.width,s=this.height,o=this.data,a=i*r,c=i-1,h=s-1,u=ct(t,0,c),d=ct(e,0,h),l=0|u,p=0|d,y=u-l,w=d-p,_=f(0,l-1),m=f(0,p-1),v=g(c,l+1),A=g(h,p+1),x=g(c,v+1),b=m*a+n,E=p*a+n,$=A*a+n,F=g(h,A+1)*a+n,U=_*r,S=l*r,z=v*r,C=x*r,V=o[b+U],B=o[b+S],L=o[b+z],q=o[b+C],T=o[E+U],I=o[E+S],M=o[E+z],k=o[E+C],N=o[$+U],O=o[$+S],j=o[$+z],D=o[$+C],R=o[F+U],P=o[F+S],J=o[F+z],H=o[F+C],W=ut(y,V,B,L,q),G=ut(y,T,I,M,k),Y=ut(y,N,O,j,D),K=ut(y,R,P,J,H);return ut(w,W,G,Y,K)}sampleBilinearUV(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinearUV(t,e,s)}sampleBilinear(t,e,n,r=0){const i=this.itemSize;for(let s=0;s<i;s++)n[s+r]=this.sampleChannelBilinear(t,e,s)}sampleChannelBilinearUV(t,e,n){const r=t*this.width-.5,i=e*this.height-.5;return this.sampleChannelBilinear(r,i,n)}sampleChannelBilinear(t,e,n){const r=this.itemSize,i=this.width,s=i*r,o=this.height-1,a=ct(t,0,i-1),c=ct(e,0,o),h=a>>>0,u=c>>>0,d=u*s,l=h*r+n,f=d+l;let g,p;g=a===h?h:h+1,p=c===u?u:u+1;const y=this.data,w=y[f];if(h===g&&u===p)return w;const _=a-h,m=c-u,v=g*r+n,A=p*s,x=A+l,b=A+v,E=y[d+v],$=y[x],F=y[b],U=ht(w,E,_),S=ht($,F,_);return ht(U,S,m)}sampleNearestUV(t,e,n){const r=this.width,i=this.height,s=Math.round(t*r-.5),o=Math.round(e*i-.5);this.read(ct(s,0,r-1),ct(o,0,i-1),n)}readChannel(t,e,n){const r=(e*this.width+t)*this.itemSize+n;return this.data[r]}read(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)n[t]=this.data[s+t]}write(t,e,n){const r=this.width,i=this.itemSize,s=(e*r+t)*i;for(let t=0;t<i;t++)this.data[s+t]=n[t];this.version++}point2index(t,e){return t+e*this.width}index2point(t,e){const n=this.width,r=t%n,i=t/n|0;e.set(r,i)}copy(t,e,n,r,i,s,o){const a=Math.min(s,t.width-e,this.width-r),c=Math.min(o,t.height-n,this.height-i),h=this.itemSize,u=t.itemSize,d=Math.min(h,u),l=h*this.width,f=u*t.width,g=t.data,p=this.data;let y,w,_;for(w=0;w<c;w++){const t=(w+i)*l,s=(w+n)*f;for(y=0;y<a;y++){const n=t+(y+r)*h,i=s+(y+e)*u;for(_=0;_<d;_++)p[n+_]=g[i+_]}}this.version++}zeroFill(t,e,n,r){const i=ct(t,0,this.width),s=ct(e,0,this.height),o=ct(t+n,0,this.width),a=ct(e+r,0,this.height),c=this.data,h=this.itemSize,u=h*this.width,d=i*h,l=o*h;let f;for(f=s;f<a;f++){const t=f*u;c.fill(0,t+d,t+l)}this.version++}channelFill(t,e){const n=this.itemSize,r=this.data,i=r.length;for(let s=t;s<i;s+=n)r[s]=e;this.version++}fill(t,e,n,r,i){const s=this.width,o=this.height,a=ct(t,0,s),c=ct(e,0,o),h=ct(t+n,0,s),u=ct(e+r,0,o),d=this.data,l=this.itemSize,f=l*s;let g,p,y;for(g=c;g<u;g++){const t=g*f;for(p=a;p<h;p++){const e=t+p*l;for(y=0;y<l;y++)d[e+y]=i[y]}}this.version++}writeChannel(t,e,n,r){const i=(e*this.width+t)*this.itemSize+n;this.data[i]=r,this.version++}traverseCircle(t,e,n,r){let i,s;const o=0|t,a=0|e,c=n*n,h=Math.ceil(n);for(s=-h;s<=h;s++){const t=s*s;for(i=-h;i<=h;i++)i*i+t<=c&&r(o+i,a+s,this)}}resize(t,e,n=!0){const r=this.width,i=this.height;if(r===t&&i===e)return;const s=this.itemSize,o=t*e*s,a=this.data,c=new(function(t){if(t instanceof Int8Array)return Int8Array;if(t instanceof Int16Array)return Int16Array;if(t instanceof Int32Array)return Int32Array;if(t instanceof Uint8Array)return Uint8Array;if(t instanceof Uint8ClampedArray)return Uint8ClampedArray;if(t instanceof Uint16Array)return Uint16Array;if(t instanceof Uint32Array)return Uint32Array;if(t instanceof Float16Array)return Float16Array;if(t instanceof Float32Array)return Float32Array;if(t instanceof Float64Array)return Float64Array;if(Array.isArray(t))return Array;throw new TypeError("Unsupported array type")}(a))(o);if(n)if(t===r)c.set(a.subarray(0,Math.min(a.length,o)));else{const n=g(e,i),o=g(t,r);for(let e=0;e<n;e++)for(let n=0;n<o;n++){const i=(e*t+n)*s,o=(e*r+n)*s;for(let t=0;t<s;t++)c[i+t]=a[o+t]}}this.width=t,this.height=e,this.data=c,this.version++}computeByteSize(){let t;const e=this.data;return t=Array.isArray(e)?8*e.length:e.byteLength,t+280}equals(e){return null!=e&&(this===e||this.width===e.width&&this.height===e.height&&this.itemSize===e.itemSize&&function(e,n){if(e===n)return!0;const r=e.length;if(r!==n.length)return!1;const i=e.constructor;if(i!==n.constructor)return!1;if(0===r)return!0;if(r<128)return t(e,n);const s=e.byteLength;if(s!==n.byteLength)return!1;const o=e.buffer,a=n.buffer,c=e.byteOffset,h=n.byteOffset;if(o===a&&c===h)return!0;let u=e,d=n;const l=i.BYTES_PER_ELEMENT,f=function(t,e,n){const r=t|e|n;return 0==(3&r)?4:0==(1&r)?2:1}(c,h,s),g="undefined"!=typeof Float16Array&&i===Float16Array||i===Float32Array||i===Float64Array;return!g&&l<4&&4===f?(u=new Uint32Array(o,c,s>>>2),d=new Uint32Array(a,h,s>>>2)):!g&&l<2&&2===f&&(u=new Uint16Array(o,c,s>>>1),d=new Uint16Array(a,h,s>>>1)),t(u,d)}(this.data,e.data))}hash(){const t=this.itemSize,n=this.width,r=this.height,i=this.data;let s=((65535&n)<<16|65535&r)^t;const o=n*r*t;if(e(i))s^=function(t,e,n){const r=e|n;return 0==(3&r)?function(t,e,n){let r=n;for(let e=0;e<n;++e)r=(r<<5)-r+t[e];return r}(new Uint32Array(t,e,n>>>2),0,n>>>2):0==(1&r)?function(t,e,n){let r=n,i=0;for(0!=(1&n)&&(r=(r<<5)-r+t[i++]);i<n;i+=2)r=(r<<5)-r+(t[i]<<16|t[i+1]);return r}(new Uint16Array(t,e,n>>>1),0,n>>>1):function(t,e,n){let r=n,i=0;const s=3&n;for(;i<0+s;i++)r=(r<<5)-r+t[i];for(;i<n;i+=4)r=(r<<5)-r+(t[i]|t[i+1]<<8|t[i+2]<<16|t[i+3]<<24);return r}(new Uint8Array(t,e,n),0,n)}(i.buffer,i.byteOffset,i.byteLength);else for(let t=0;t<o;++t)s=(s<<5)-s+lt(i[t]);return s}clone(){let t;return t=Array.isArray(this.data)?this.data.slice():new(0,this.data.constructor)(this.data),new ft(t,this.itemSize,this.width,this.height)}toJSON(){const t=K.encode(this.data.buffer);return{height:this.height,width:this.width,itemSize:this.itemSize,type:at(this.data),data:t}}fromJSON({height:t,width:e,itemSize:n,type:r,data:i}){const s=function(t){const e=ot[t];if(void 0===e)throw new Error(`Unsupported data type '${t}'`);return e}(r);if("string"==typeof i){const t=K.decode(i);this.data=new s(t)}else{if(!Array.isArray(i))throw new Error("Unsupported data format");this.data=new s(i)}this.height=t,this.width=e,this.itemSize=n}static uint8clamped(t,e,n){const r=new Uint8ClampedArray(e*n*t);return new ft(r,t,e,n)}static uint8(t,e,n){const r=new Uint8Array(e*n*t);return new ft(r,t,e,n)}static uint16(t,e,n){const r=new Uint16Array(e*n*t);return new ft(r,t,e,n)}static uint32(t,e,n){const r=new Uint32Array(e*n*t);return new ft(r,t,e,n)}static int8(t,e,n){const r=new Int8Array(e*n*t);return new ft(r,t,e,n)}static int16(t,e,n){const r=new Int16Array(e*n*t);return new ft(r,t,e,n)}static int32(t,e,n){const r=new Int32Array(e*n*t);return new ft(r,t,e,n)}static float16(t,e,n){const r=new Float16Array(e*n*t);return new ft(r,t,e,n)}static float32(t,e,n){const r=new Float32Array(e*n*t);return new ft(r,t,e,n)}static float64(t,e,n){const r=new Float64Array(e*n*t);return new ft(r,t,e,n)}}function gt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2];t[e]+=i,t[e+1]+=s,t[e+2]+=o}function pt(t,e,n,r,i,s){const o=3*n,a=3*r,c=3*i;N(t,e,s[o],s[o+1],s[o+2],s[a],s[a+1],s[a+2],s[c],s[c+1],s[c+2])}function yt(t,e,n,r){const i=n[r],s=n[r+1],o=n[r+2],a=k(i,s,o),c=0!==a?1/Math.sqrt(a):1;t[e]=i*c,t[e+1]=s*c,t[e+2]=o*c}ft.prototype.isSampler2D=!0,ft.typeName="Sampler2D";const wt=new Float64Array(3),_t={build:function(t,e,n,r,i,s){const o=n.x*s,a=n.y*s,c=o-1,h=a-1;let u=0,d=0;const l=o*a,f=new Float32Array(3*l),g=new Float32Array(3*l),p=new Float32Array(2*l);let y,w;const _=n.y/i.y/h,m=n.x/i.x/c,v=e.y/i.y,A=e.x/i.x,x=i.x*r.x,b=i.y*r.y;let E,$,F;for(y=0;y<a;y++){const e=y*_+v;for(F=e*b,w=0;w<o;w++){const n=w*m+A;E=n*x,$=t.sampleChannelBicubicUV(n,e,0),f[u]=E,f[u+1]=$,f[u+2]=F,p[d]=n,p[d+1]=e,u+=3,d+=2}}u=0;const U=new(function(t){if(t<=256)return Uint8Array;if(t<=65536)return Uint16Array;if(t<=4294967295)return Uint32Array;throw new Error(`Unsupported size ${t}`)}(f.length/3))(c*h*6);for(y=0;y<h;y++)for(w=0;w<c;w++){const t=w+o*y,e=w+o*(y+1),n=w+1+o*(y+1),r=w+1+o*y;U[u]=t,U[u+1]=e,U[u+2]=r,U[u+3]=e,U[u+4]=n,U[u+5]=r,u+=6}return function(t,e,n){const r=n.length;for(let i=0;i<r;i+=3){const r=n[i],s=n[i+1],o=n[i+2];pt(wt,0,r,s,o,t),gt(e,3*r,wt,0),gt(e,3*s,wt,0),gt(e,3*o,wt,0)}!function(t,e=0,n=t.length-e){const r=e+n;for(let n=e;n<r;n+=3)yt(t,n,t,n)}(e)}(f,g,U),{indices:U,vertices:f,normals:g,uvs:p}}};self.Lib={build_bvh(t,e){const n=new x;return function(t,e,n){const r=n.length/3;t.setLeafCount(r),t.initialize_structure();for(let i=0;i<r;i++){const r=3*i;$(t,i,e,n[r],n[r+1],n[r+2])}t.build()}(n,t,e),n},Sampler2D:ft,BufferedGeometryArraysBuilder:_t,tensionOptimizeUV:function(t,e,n,r=3){const i=new P;i.build(t,n),i.computeEdgeSquaredLengths();const s=t.length/3;for(let t=0;t<r;t++)t:for(let t=0;t<s;t++){const n=i.vertices[t],r=n.edges,s=r.length;if(0===s)continue;let o=0,a=0,c=0;for(let t=0;t<s;t++){const i=r[t];if(F(i))continue t;const s=2*U(i,n).index,h=e[s],u=e[s+1],d=1/i.lengthSqr;o+=h*d,a+=u*d,c+=d}const h=o/c,u=a/c,d=2*n.index;e[d]=h,e[d+1]=u}},sampler2d_channel_compute_min:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s>e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}},sampler2d_channel_compute_max:function(t,e=0){const n=t.itemSize,r=t.data,i=r.length;if(0===i)return;let s=r[e],o=e;for(let t=e+n;t<i;t+=n){const e=r[t];s<e&&(s=e,o=t)}const a=t.width,c=o/n|0;return{index:o,value:s,x:c%a,y:c/a|0}}};
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"author": "Alexander Goldring",
|
|
9
|
-
"version": "2.
|
|
9
|
+
"version": "2.165.0",
|
|
10
10
|
"main": "build/meep.module.js",
|
|
11
11
|
"module": "build/meep.module.js",
|
|
12
12
|
"exports": {
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A 2D bitmap with word-packed rows (one bit per cell), built for atlas
|
|
3
|
+
* packing: fast shifted-OR collision tests between a chart mask and the atlas
|
|
4
|
+
* occupancy, plus blit, dilation and content-preserving growth. This is the
|
|
5
|
+
* `BitImage` xatlas uses for `canBlit` placement; meep's 1D {@link BitSet} has
|
|
6
|
+
* no 2D addressing or shifted collision, so this is a distinct structure.
|
|
7
|
+
*
|
|
8
|
+
* Rows are padded to whole 32-bit words. Bits at column >= width are never set
|
|
9
|
+
* (set() enforces the bound), so the trailing-word garbage that would otherwise
|
|
10
|
+
* break a shifted collision test simply does not exist — no explicit masking is
|
|
11
|
+
* needed.
|
|
12
|
+
*
|
|
13
|
+
* Fields are public so packing hot loops can read `data`/`words_per_row`
|
|
14
|
+
* directly, mirroring CSRGraph.
|
|
15
|
+
*/
|
|
16
|
+
export class BitImage2 {
|
|
17
|
+
/**
|
|
18
|
+
* @param {number} width
|
|
19
|
+
* @param {number} height
|
|
20
|
+
*/
|
|
21
|
+
constructor(width: number, height: number);
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
words_per_row: number;
|
|
25
|
+
data: Uint32Array;
|
|
26
|
+
/** @param {number} x @param {number} y @returns {number} 0 or 1 */
|
|
27
|
+
get(x: number, y: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* Set the bit at (x, y). x must be < width (no out-of-row bits).
|
|
30
|
+
*
|
|
31
|
+
* @param {number} x
|
|
32
|
+
* @param {number} y
|
|
33
|
+
*/
|
|
34
|
+
set(x: number, y: number): void;
|
|
35
|
+
/** Zero every bit. */
|
|
36
|
+
reset(): void;
|
|
37
|
+
/** @returns {number} number of set bits */
|
|
38
|
+
cardinality(): number;
|
|
39
|
+
/**
|
|
40
|
+
* Can `other` be placed with its (0,0) at (ox, oy) of this image without
|
|
41
|
+
* overlapping any set bit and while fitting fully inside the bounds?
|
|
42
|
+
*
|
|
43
|
+
* @param {BitImage2} other
|
|
44
|
+
* @param {number} ox
|
|
45
|
+
* @param {number} oy
|
|
46
|
+
* @returns {boolean}
|
|
47
|
+
*/
|
|
48
|
+
canBlit(other: BitImage2, ox: number, oy: number): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* OR `other`'s set bits into this image with its (0,0) at (ox, oy). Caller
|
|
51
|
+
* must have verified placement with {@link canBlit}.
|
|
52
|
+
*
|
|
53
|
+
* @param {BitImage2} other
|
|
54
|
+
* @param {number} ox
|
|
55
|
+
* @param {number} oy
|
|
56
|
+
*/
|
|
57
|
+
or_blit(other: BitImage2, ox: number, oy: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* Grow the set region by `passes` cells (Chebyshev / 3x3 OR per pass),
|
|
60
|
+
* in place. Used to reserve the padding gutter around a chart mask.
|
|
61
|
+
*
|
|
62
|
+
* @param {number} passes
|
|
63
|
+
*/
|
|
64
|
+
dilate(passes: number): void;
|
|
65
|
+
/**
|
|
66
|
+
* Grow to (new_width, new_height) >= current, preserving content. The row
|
|
67
|
+
* stride changes when the word count per row changes, so each row must be
|
|
68
|
+
* re-laid-out — a flat copy would corrupt the image.
|
|
69
|
+
*
|
|
70
|
+
* @param {number} new_width
|
|
71
|
+
* @param {number} new_height
|
|
72
|
+
*/
|
|
73
|
+
grow_preserving(new_width: number, new_height: number): void;
|
|
74
|
+
/**
|
|
75
|
+
* A new image that is this image transposed (x/y swapped): the 90-degree
|
|
76
|
+
* orientation tried during rotated chart placement. Allocates the target;
|
|
77
|
+
* use {@link copy_transposed} to transpose into a reused buffer.
|
|
78
|
+
*
|
|
79
|
+
* @returns {BitImage2}
|
|
80
|
+
*/
|
|
81
|
+
transposed(): BitImage2;
|
|
82
|
+
/**
|
|
83
|
+
* Write this image's transpose (x/y swapped) into `out` — the non-allocating
|
|
84
|
+
* path. `out` is cleared first and must be sized (this.height x this.width).
|
|
85
|
+
* Bit count is preserved.
|
|
86
|
+
*
|
|
87
|
+
* @param {BitImage2} out target image, dimensions (this.height, this.width)
|
|
88
|
+
*/
|
|
89
|
+
copy_transposed(out: BitImage2): void;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=BitImage2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BitImage2.d.ts","sourceRoot":"","sources":["../../../../src/core/binary/BitImage2.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH;IACI;;;OAGG;IACH,mBAHW,MAAM,UACN,MAAM,EAUhB;IAJG,cAAkB;IAClB,eAAoB;IACpB,sBAAuD;IACvD,kBAAqE;IAGzE,mEAAmE;IACnE,OADY,MAAM,KAAY,MAAM,GAAc,MAAM,CAGvD;IAED;;;;;OAKG;IACH,OAHW,MAAM,KACN,MAAM,QAIhB;IAED,sBAAsB;IACtB,cAEC;IAED,2CAA2C;IAC3C,eADc,MAAM,CAanB;IAED;;;;;;;;OAQG;IACH,eALW,SAAS,MACT,MAAM,MACN,MAAM,GACJ,OAAO,CAkCnB;IAED;;;;;;;OAOG;IACH,eAJW,SAAS,MACT,MAAM,MACN,MAAM,QAwBhB;IAED;;;;;OAKG;IACH,eAFW,MAAM,QA0BhB;IAED;;;;;;;OAOG;IACH,2BAHW,MAAM,cACN,MAAM,QA0BhB;IAED;;;;;;OAMG;IACH,cAFa,SAAS,CAMrB;IAED;;;;;;OAMG;IACH,qBAFW,SAAS,QAcnB;CACJ"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { assert } from "../assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A 2D bitmap with word-packed rows (one bit per cell), built for atlas
|
|
5
|
+
* packing: fast shifted-OR collision tests between a chart mask and the atlas
|
|
6
|
+
* occupancy, plus blit, dilation and content-preserving growth. This is the
|
|
7
|
+
* `BitImage` xatlas uses for `canBlit` placement; meep's 1D {@link BitSet} has
|
|
8
|
+
* no 2D addressing or shifted collision, so this is a distinct structure.
|
|
9
|
+
*
|
|
10
|
+
* Rows are padded to whole 32-bit words. Bits at column >= width are never set
|
|
11
|
+
* (set() enforces the bound), so the trailing-word garbage that would otherwise
|
|
12
|
+
* break a shifted collision test simply does not exist — no explicit masking is
|
|
13
|
+
* needed.
|
|
14
|
+
*
|
|
15
|
+
* Fields are public so packing hot loops can read `data`/`words_per_row`
|
|
16
|
+
* directly, mirroring CSRGraph.
|
|
17
|
+
*/
|
|
18
|
+
export class BitImage2 {
|
|
19
|
+
/**
|
|
20
|
+
* @param {number} width
|
|
21
|
+
* @param {number} height
|
|
22
|
+
*/
|
|
23
|
+
constructor(width, height) {
|
|
24
|
+
assert.isNonNegativeInteger(width, "width");
|
|
25
|
+
assert.isNonNegativeInteger(height, "height");
|
|
26
|
+
|
|
27
|
+
this.width = width;
|
|
28
|
+
this.height = height;
|
|
29
|
+
this.words_per_row = Math.max(1, Math.ceil(width / 32));
|
|
30
|
+
this.data = new Uint32Array(this.words_per_row * Math.max(1, height));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** @param {number} x @param {number} y @returns {number} 0 or 1 */
|
|
34
|
+
get(x, y) {
|
|
35
|
+
return (this.data[y * this.words_per_row + (x >>> 5)] >>> (x & 31)) & 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Set the bit at (x, y). x must be < width (no out-of-row bits).
|
|
40
|
+
*
|
|
41
|
+
* @param {number} x
|
|
42
|
+
* @param {number} y
|
|
43
|
+
*/
|
|
44
|
+
set(x, y) {
|
|
45
|
+
this.data[y * this.words_per_row + (x >>> 5)] |= (1 << (x & 31));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Zero every bit. */
|
|
49
|
+
reset() {
|
|
50
|
+
this.data.fill(0);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** @returns {number} number of set bits */
|
|
54
|
+
cardinality() {
|
|
55
|
+
const data = this.data;
|
|
56
|
+
let count = 0;
|
|
57
|
+
for (let i = 0; i < data.length; i++) {
|
|
58
|
+
let w = data[i];
|
|
59
|
+
// Hamming weight (SWAR popcount)
|
|
60
|
+
w = w - ((w >>> 1) & 0x55555555);
|
|
61
|
+
w = (w & 0x33333333) + ((w >>> 2) & 0x33333333);
|
|
62
|
+
w = (w + (w >>> 4)) & 0x0f0f0f0f;
|
|
63
|
+
count += (Math.imul(w, 0x01010101) >>> 24);
|
|
64
|
+
}
|
|
65
|
+
return count;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Can `other` be placed with its (0,0) at (ox, oy) of this image without
|
|
70
|
+
* overlapping any set bit and while fitting fully inside the bounds?
|
|
71
|
+
*
|
|
72
|
+
* @param {BitImage2} other
|
|
73
|
+
* @param {number} ox
|
|
74
|
+
* @param {number} oy
|
|
75
|
+
* @returns {boolean}
|
|
76
|
+
*/
|
|
77
|
+
canBlit(other, ox, oy) {
|
|
78
|
+
if (ox < 0 || oy < 0 || ox + other.width > this.width || oy + other.height > this.height) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const ow = other.words_per_row;
|
|
83
|
+
const tw = this.words_per_row;
|
|
84
|
+
const oh = other.height;
|
|
85
|
+
|
|
86
|
+
for (let r = 0; r < oh; r++) {
|
|
87
|
+
const o_base = r * ow;
|
|
88
|
+
const t_base = (oy + r) * tw;
|
|
89
|
+
for (let w = 0; w < ow; w++) {
|
|
90
|
+
const ov = other.data[o_base + w];
|
|
91
|
+
if (ov === 0) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const bit = ox + (w << 5);
|
|
95
|
+
const wi = bit >>> 5;
|
|
96
|
+
const bo = bit & 31;
|
|
97
|
+
if ((this.data[t_base + wi] & (ov << bo)) !== 0) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
if (bo !== 0) {
|
|
101
|
+
const hi = ov >>> (32 - bo);
|
|
102
|
+
if (hi !== 0 && (this.data[t_base + wi + 1] & hi) !== 0) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* OR `other`'s set bits into this image with its (0,0) at (ox, oy). Caller
|
|
113
|
+
* must have verified placement with {@link canBlit}.
|
|
114
|
+
*
|
|
115
|
+
* @param {BitImage2} other
|
|
116
|
+
* @param {number} ox
|
|
117
|
+
* @param {number} oy
|
|
118
|
+
*/
|
|
119
|
+
or_blit(other, ox, oy) {
|
|
120
|
+
const ow = other.words_per_row;
|
|
121
|
+
const tw = this.words_per_row;
|
|
122
|
+
const oh = other.height;
|
|
123
|
+
|
|
124
|
+
for (let r = 0; r < oh; r++) {
|
|
125
|
+
const o_base = r * ow;
|
|
126
|
+
const t_base = (oy + r) * tw;
|
|
127
|
+
for (let w = 0; w < ow; w++) {
|
|
128
|
+
const ov = other.data[o_base + w];
|
|
129
|
+
if (ov === 0) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const bit = ox + (w << 5);
|
|
133
|
+
const wi = bit >>> 5;
|
|
134
|
+
const bo = bit & 31;
|
|
135
|
+
this.data[t_base + wi] |= (ov << bo);
|
|
136
|
+
if (bo !== 0) {
|
|
137
|
+
this.data[t_base + wi + 1] |= (ov >>> (32 - bo));
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Grow the set region by `passes` cells (Chebyshev / 3x3 OR per pass),
|
|
145
|
+
* in place. Used to reserve the padding gutter around a chart mask.
|
|
146
|
+
*
|
|
147
|
+
* @param {number} passes
|
|
148
|
+
*/
|
|
149
|
+
dilate(passes) {
|
|
150
|
+
const wpr = this.words_per_row;
|
|
151
|
+
const W = this.width;
|
|
152
|
+
const H = this.height;
|
|
153
|
+
|
|
154
|
+
for (let p = 0; p < passes; p++) {
|
|
155
|
+
const src = this.data.slice();
|
|
156
|
+
for (let y = 0; y < H; y++) {
|
|
157
|
+
for (let x = 0; x < W; x++) {
|
|
158
|
+
if (((src[y * wpr + (x >>> 5)] >>> (x & 31)) & 1) === 0) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const x0 = x > 0 ? x - 1 : 0;
|
|
162
|
+
const x1 = x < W - 1 ? x + 1 : W - 1;
|
|
163
|
+
const y0 = y > 0 ? y - 1 : 0;
|
|
164
|
+
const y1 = y < H - 1 ? y + 1 : H - 1;
|
|
165
|
+
for (let yy = y0; yy <= y1; yy++) {
|
|
166
|
+
for (let xx = x0; xx <= x1; xx++) {
|
|
167
|
+
this.set(xx, yy);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Grow to (new_width, new_height) >= current, preserving content. The row
|
|
177
|
+
* stride changes when the word count per row changes, so each row must be
|
|
178
|
+
* re-laid-out — a flat copy would corrupt the image.
|
|
179
|
+
*
|
|
180
|
+
* @param {number} new_width
|
|
181
|
+
* @param {number} new_height
|
|
182
|
+
*/
|
|
183
|
+
grow_preserving(new_width, new_height) {
|
|
184
|
+
assert.greaterThanOrEqual(new_width, this.width, "new_width");
|
|
185
|
+
assert.greaterThanOrEqual(new_height, this.height, "new_height");
|
|
186
|
+
|
|
187
|
+
if (new_width === this.width && new_height === this.height) {
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const new_wpr = Math.max(1, Math.ceil(new_width / 32));
|
|
192
|
+
const new_data = new Uint32Array(new_wpr * Math.max(1, new_height));
|
|
193
|
+
|
|
194
|
+
const copy_words = Math.min(this.words_per_row, new_wpr);
|
|
195
|
+
for (let y = 0; y < this.height; y++) {
|
|
196
|
+
const src_base = y * this.words_per_row;
|
|
197
|
+
const dst_base = y * new_wpr;
|
|
198
|
+
for (let w = 0; w < copy_words; w++) {
|
|
199
|
+
new_data[dst_base + w] = this.data[src_base + w];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
this.width = new_width;
|
|
204
|
+
this.height = new_height;
|
|
205
|
+
this.words_per_row = new_wpr;
|
|
206
|
+
this.data = new_data;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* A new image that is this image transposed (x/y swapped): the 90-degree
|
|
211
|
+
* orientation tried during rotated chart placement. Allocates the target;
|
|
212
|
+
* use {@link copy_transposed} to transpose into a reused buffer.
|
|
213
|
+
*
|
|
214
|
+
* @returns {BitImage2}
|
|
215
|
+
*/
|
|
216
|
+
transposed() {
|
|
217
|
+
const out = new BitImage2(this.height, this.width);
|
|
218
|
+
this.copy_transposed(out);
|
|
219
|
+
return out;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Write this image's transpose (x/y swapped) into `out` — the non-allocating
|
|
224
|
+
* path. `out` is cleared first and must be sized (this.height x this.width).
|
|
225
|
+
* Bit count is preserved.
|
|
226
|
+
*
|
|
227
|
+
* @param {BitImage2} out target image, dimensions (this.height, this.width)
|
|
228
|
+
*/
|
|
229
|
+
copy_transposed(out) {
|
|
230
|
+
assert.equal(out.width, this.height, "out.width must equal this.height");
|
|
231
|
+
assert.equal(out.height, this.width, "out.height must equal this.width");
|
|
232
|
+
|
|
233
|
+
out.reset();
|
|
234
|
+
for (let y = 0; y < this.height; y++) {
|
|
235
|
+
for (let x = 0; x < this.width; x++) {
|
|
236
|
+
if (this.get(x, y) === 1) {
|
|
237
|
+
out.set(y, x);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimum-area oriented bounding rectangle of a 2D point set, via rotating
|
|
3
|
+
* calipers over the convex hull. By the standard theorem the min-area rectangle
|
|
4
|
+
* has one side collinear with a hull edge, so each hull edge is tried as the box
|
|
5
|
+
* orientation and the tightest is kept.
|
|
6
|
+
*
|
|
7
|
+
* The returned `angle` is the direction of that hull edge (the box's local
|
|
8
|
+
* x-axis); rotating the point set by `-angle` makes its axis-aligned bounding
|
|
9
|
+
* box equal to this oriented box. `width`/`height` are the box extents along the
|
|
10
|
+
* edge and its perpendicular.
|
|
11
|
+
*
|
|
12
|
+
* @param {number[]|Float32Array|Float64Array} points flat xy
|
|
13
|
+
* @param {number} point_count
|
|
14
|
+
* @returns {{angle:number, width:number, height:number, area:number}}
|
|
15
|
+
*/
|
|
16
|
+
export function min_area_rect_2d(points: number[] | Float32Array | Float64Array, point_count: number): {
|
|
17
|
+
angle: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
area: number;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=min_area_rect_2d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"min_area_rect_2d.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/oriented-box/min_area_rect_2d.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,yCAJW,MAAM,EAAE,GAAC,YAAY,GAAC,YAAY,eAClC,MAAM,GACJ;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAM,EAAC,MAAM,CAAC;IAAC,IAAI,EAAC,MAAM,CAAA;CAAC,CAqDpE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { convex_hull_monotone_2d } from "../convex-hull/convex_hull_monotone_2d.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Minimum-area oriented bounding rectangle of a 2D point set, via rotating
|
|
5
|
+
* calipers over the convex hull. By the standard theorem the min-area rectangle
|
|
6
|
+
* has one side collinear with a hull edge, so each hull edge is tried as the box
|
|
7
|
+
* orientation and the tightest is kept.
|
|
8
|
+
*
|
|
9
|
+
* The returned `angle` is the direction of that hull edge (the box's local
|
|
10
|
+
* x-axis); rotating the point set by `-angle` makes its axis-aligned bounding
|
|
11
|
+
* box equal to this oriented box. `width`/`height` are the box extents along the
|
|
12
|
+
* edge and its perpendicular.
|
|
13
|
+
*
|
|
14
|
+
* @param {number[]|Float32Array|Float64Array} points flat xy
|
|
15
|
+
* @param {number} point_count
|
|
16
|
+
* @returns {{angle:number, width:number, height:number, area:number}}
|
|
17
|
+
*/
|
|
18
|
+
export function min_area_rect_2d(points, point_count) {
|
|
19
|
+
const hull = convex_hull_monotone_2d(points, point_count);
|
|
20
|
+
const h = hull.length;
|
|
21
|
+
|
|
22
|
+
if (h < 2) {
|
|
23
|
+
return { angle: 0, width: 0, height: 0, area: 0 };
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
let best_area = Infinity;
|
|
27
|
+
let best_angle = 0;
|
|
28
|
+
let best_width = 0;
|
|
29
|
+
let best_height = 0;
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < h; i++) {
|
|
32
|
+
const a = hull[i];
|
|
33
|
+
const b = hull[(i + 1) % h];
|
|
34
|
+
|
|
35
|
+
let ex = points[b * 2] - points[a * 2];
|
|
36
|
+
let ey = points[b * 2 + 1] - points[a * 2 + 1];
|
|
37
|
+
const len = Math.sqrt(ex * ex + ey * ey);
|
|
38
|
+
if (len < 1e-12) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
ex /= len;
|
|
42
|
+
ey /= len;
|
|
43
|
+
|
|
44
|
+
let min_u = Infinity, max_u = -Infinity, min_v = Infinity, max_v = -Infinity;
|
|
45
|
+
for (let k = 0; k < h; k++) {
|
|
46
|
+
const px = points[hull[k] * 2];
|
|
47
|
+
const py = points[hull[k] * 2 + 1];
|
|
48
|
+
const u = px * ex + py * ey;
|
|
49
|
+
const v = -px * ey + py * ex;
|
|
50
|
+
if (u < min_u) min_u = u;
|
|
51
|
+
if (u > max_u) max_u = u;
|
|
52
|
+
if (v < min_v) min_v = v;
|
|
53
|
+
if (v > max_v) max_v = v;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const width = max_u - min_u;
|
|
57
|
+
const height = max_v - min_v;
|
|
58
|
+
const area = width * height;
|
|
59
|
+
|
|
60
|
+
if (area < best_area) {
|
|
61
|
+
best_area = area;
|
|
62
|
+
best_angle = Math.atan2(ey, ex);
|
|
63
|
+
best_width = width;
|
|
64
|
+
best_height = height;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { angle: best_angle, width: best_width, height: best_height, area: best_area };
|
|
69
|
+
}
|