@woosh/meep-engine 2.138.20 → 2.139.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/package.json +1 -1
- package/src/core/collection/PairUint32Map.d.ts +100 -0
- package/src/core/collection/PairUint32Map.d.ts.map +1 -0
- package/src/core/collection/PairUint32Map.js +321 -0
- package/src/core/collection/Uint32Map.d.ts +119 -0
- package/src/core/collection/Uint32Map.d.ts.map +1 -0
- package/src/core/collection/Uint32Map.js +345 -0
- package/src/core/collection/array/array_shuffle.d.ts +10 -3
- package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
- package/src/core/collection/array/array_shuffle.js +27 -22
- package/src/core/collection/heap/FibonacciHeap.d.ts +195 -0
- package/src/core/collection/heap/FibonacciHeap.d.ts.map +1 -0
- package/src/core/collection/heap/FibonacciHeap.js +586 -0
- package/src/core/collection/heap/Uint32Heap.js +1 -1
- package/src/core/collection/heap/Uint32Heap4.d.ts +169 -0
- package/src/core/collection/heap/Uint32Heap4.d.ts.map +1 -0
- package/src/core/collection/heap/Uint32Heap4.js +490 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts +27 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.d.ts.map +1 -0
- package/src/core/geom/3d/line/line3_closest_points_segment_segment.js +88 -0
- package/src/core/geom/3d/shape/BoxShape3D.d.ts +61 -0
- package/src/core/geom/3d/shape/BoxShape3D.d.ts.map +1 -0
- package/src/core/geom/3d/shape/BoxShape3D.js +158 -0
- package/src/core/geom/3d/shape/CapsuleShape3D.d.ts +11 -0
- package/src/core/geom/3d/shape/CapsuleShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/CapsuleShape3D.js +12 -0
- package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts +37 -9
- package/src/core/geom/3d/shape/UnitCubeShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnitCubeShape3D.js +45 -98
- package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts +10 -0
- package/src/core/geom/3d/shape/UnitSphereShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnitSphereShape3D.js +11 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts +61 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -0
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +148 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts +39 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedral_mesh_from_surface.js +147 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts +15 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/compute_tetrahedron_quality.js +22 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts +2 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/prototype_tetrahedrize_mesh.js +673 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts +26 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_carve_outside_surface.js +222 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts +34 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_find_tets_around_edge.js +146 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts +36 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_23.js +232 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts +33 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_flip_32.js +255 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts +68 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_improve_quality.js +365 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +31 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.js +112 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +22 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.js +55 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts +32 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedron_compute_quality.js +66 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryElementPool.js +49 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts +134 -0
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/BinaryTopology.js +276 -3
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts +17 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_close_boundary_holes.js +135 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts +14 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_compact.js +177 -0
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_face_decouple.js +20 -4
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/bt_mesh_simplify.js +5 -3
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_create.js +9 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_get_or_create.js +21 -45
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill.js +7 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts +8 -6
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_edge_kill_parallels.js +8 -6
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_kill_short_edges.js +73 -0
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/vertex/bt_vertex_replace.js +51 -1
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts +10 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_edge_get.js +42 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts +28 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_sample_interior_grid_points.js +227 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts +13 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js +108 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts +11 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js +20 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts +20 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.d.ts.map +1 -0
- package/src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js +38 -0
- package/src/core/graph/csr/CSRGraph.d.ts +168 -0
- package/src/core/graph/csr/CSRGraph.d.ts.map +1 -0
- package/src/core/graph/csr/CSRGraph.js +319 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts +12 -0
- package/src/core/graph/metis/cluster_mesh_metis.d.ts.map +1 -1
- package/src/core/graph/metis/cluster_mesh_metis.js +12 -0
- package/src/core/graph/metis/metis.d.ts +19 -0
- package/src/core/graph/metis/metis.d.ts.map +1 -1
- package/src/core/graph/metis/metis.js +20 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts +11 -0
- package/src/core/graph/metis/metis_cluster_bs.d.ts.map +1 -1
- package/src/core/graph/metis/metis_cluster_bs.js +11 -0
- package/src/core/graph/metis/metis_options.d.ts +17 -2
- package/src/core/graph/metis/metis_options.d.ts.map +1 -1
- package/src/core/graph/metis/metis_options.js +17 -2
- package/src/core/graph/metis/native/MetisGraph.d.ts +144 -0
- package/src/core/graph/metis/native/MetisGraph.d.ts.map +1 -0
- package/src/core/graph/metis/native/MetisGraph.js +212 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts +72 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/BisectionScratch.js +101 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.d.ts +37 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/bisect_graph.js +100 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts +15 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/compute_2way_params.js +84 -0
- package/src/core/graph/metis/native/bisection/fm_2way.d.ts +30 -0
- package/src/core/graph/metis/native/bisection/fm_2way.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/fm_2way.js +290 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.d.ts +23 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/grow_bisection.js +137 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts +28 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.d.ts.map +1 -0
- package/src/core/graph/metis/native/bisection/split_graph_two_way.js +119 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts +20 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/coarsen_graph.js +94 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts +24 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/create_coarse_graph.js +158 -0
- package/src/core/graph/metis/native/coarsen/match_shem.d.ts +41 -0
- package/src/core/graph/metis/native/coarsen/match_shem.d.ts.map +1 -0
- package/src/core/graph/metis/native/coarsen/match_shem.js +175 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts +24 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.d.ts.map +1 -0
- package/src/core/graph/metis/native/initial/initial_kway_bfs.js +122 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts +29 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.d.ts.map +1 -0
- package/src/core/graph/metis/native/initial/initial_kway_recursive_bisection.js +170 -0
- package/src/core/graph/metis/native/metis_partition_kway.d.ts +41 -0
- package/src/core/graph/metis/native/metis_partition_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/metis_partition_kway.js +126 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts +62 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/IndexedFloatMaxHeap.js +261 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.d.ts +45 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/RefinementScratch.js +53 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts +18 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/compute_kway_params.js +138 -0
- package/src/core/graph/metis/native/refine/fm_kway.d.ts +63 -0
- package/src/core/graph/metis/native/refine/fm_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/fm_kway.js +462 -0
- package/src/core/graph/metis/native/refine/project_kway.d.ts +22 -0
- package/src/core/graph/metis/native/refine/project_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/project_kway.js +43 -0
- package/src/core/graph/metis/native/refine/refine_kway.d.ts +34 -0
- package/src/core/graph/metis/native/refine/refine_kway.d.ts.map +1 -0
- package/src/core/graph/metis/native/refine/refine_kway.js +43 -0
- package/src/core/math/linalg/eigen/matrix_householder_in_place.d.ts +2 -2
- package/src/core/math/linalg/eigen/matrix_householder_in_place.js +2 -2
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts +6 -4
- package/src/core/math/linalg/eigen/matrix_qr_in_place.d.ts.map +1 -1
- package/src/core/math/linalg/eigen/matrix_qr_in_place.js +69 -23
- package/src/engine/EngineHarness.d.ts +3 -1
- package/src/engine/EngineHarness.d.ts.map +1 -1
- package/src/engine/EngineHarness.js +3 -0
- package/src/engine/control/first-person/DESIGN.md +30 -6
- package/src/engine/control/first-person/DESIGN_EXTENSIONS.md +563 -0
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +102 -9
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerController.js +38 -3
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +533 -4
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +315 -6
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +220 -22
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +858 -241
- package/src/engine/control/first-person/TODO.md +127 -0
- package/src/engine/control/first-person/abilities/Ability.d.ts +101 -0
- package/src/engine/control/first-person/abilities/Ability.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Ability.js +119 -0
- package/src/engine/control/first-person/abilities/AbilitySet.d.ts +86 -0
- package/src/engine/control/first-person/abilities/AbilitySet.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/AbilitySet.js +185 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +62 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/LedgeGrab.js +199 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts +45 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Mantle.js +188 -0
- package/src/engine/control/first-person/abilities/Slide.d.ts +33 -0
- package/src/engine/control/first-person/abilities/Slide.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/Slide.js +158 -0
- package/src/engine/control/first-person/abilities/WallJump.d.ts +45 -0
- package/src/engine/control/first-person/abilities/WallJump.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/WallJump.js +131 -0
- package/src/engine/control/first-person/abilities/WallRun.d.ts +44 -0
- package/src/engine/control/first-person/abilities/WallRun.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/WallRun.js +180 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts +49 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.d.ts.map +1 -0
- package/src/engine/control/first-person/composer/EyeOffsetStack.js +60 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts +100 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/BreathRhythmEvaluator.js +133 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.d.ts +10 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/DecisionPoint.js +30 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts +61 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/FootAsymmetryTurnEvaluator.js +109 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts +40 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasteryEvaluator.js +45 -0
- package/src/engine/control/first-person/mastery/MasteryScore.d.ts +68 -0
- package/src/engine/control/first-person/mastery/MasteryScore.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasteryScore.js +100 -0
- package/src/engine/control/first-person/mastery/MasterySet.d.ts +60 -0
- package/src/engine/control/first-person/mastery/MasterySet.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/MasterySet.js +86 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts +58 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/SlideInitiationTimingEvaluator.js +83 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts +69 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.d.ts.map +1 -0
- package/src/engine/control/first-person/mastery/StrideTimingJumpEvaluator.js +109 -0
- package/src/engine/control/first-person/math/Spring.d.ts +56 -0
- package/src/engine/control/first-person/math/Spring.d.ts.map +1 -0
- package/src/engine/control/first-person/math/Spring.js +71 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts +26 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.d.ts.map +1 -0
- package/src/engine/control/first-person/math/computeLRCBreathRate.js +41 -0
- package/src/engine/control/first-person/math/computeMassRatios.d.ts +35 -0
- package/src/engine/control/first-person/math/computeMassRatios.d.ts.map +1 -0
- package/src/engine/control/first-person/math/computeMassRatios.js +44 -0
- package/src/engine/control/first-person/pose/FirstPersonPose.d.ts +31 -1
- package/src/engine/control/first-person/pose/FirstPersonPose.d.ts.map +1 -1
- package/src/engine/control/first-person/pose/FirstPersonPose.js +49 -3
- package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts +7 -0
- package/src/engine/control/first-person/pose/FirstPersonPosture.d.ts.map +1 -0
- package/src/engine/control/first-person/pose/FirstPersonPosture.js +27 -0
- package/src/engine/control/first-person/prototype_first_person_controller.js +550 -119
- package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts +58 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensors.d.ts.map +1 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensors.js +77 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts +80 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.d.ts.map +1 -0
- package/src/engine/control/first-person/sensors/FirstPersonSensorsSystem.js +196 -0
- package/src/engine/control/first-person/test/buildTestPlayer.d.ts +20 -0
- package/src/engine/control/first-person/test/buildTestPlayer.d.ts.map +1 -0
- package/src/engine/control/first-person/test/buildTestPlayer.js +28 -0
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +0 -2
- package/src/engine/graphics/ecs/light/Light.d.ts.map +1 -1
- package/src/engine/graphics/ecs/light/Light.js +27 -0
- package/src/engine/graphics/ecs/light/LightSystem.js +1 -1
- package/src/engine/graphics/ecs/path/PathDisplaySystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/path/testPathDisplaySystem.js +0 -2
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +0 -2
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +0 -2
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +0 -2
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +0 -2
- package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.js +11 -2
- package/src/engine/navigation/mesh/bt_mesh_face_find_path.d.ts.map +1 -1
- package/src/engine/navigation/mesh/bt_mesh_face_find_path.js +11 -1
- package/src/engine/physics/PLAN.md +236 -0
- package/src/engine/physics/body/BodyStorage.d.ts +187 -0
- package/src/engine/physics/body/BodyStorage.d.ts.map +1 -0
- package/src/engine/physics/body/BodyStorage.js +427 -0
- package/src/engine/physics/broadphase/PairList.d.ts +62 -0
- package/src/engine/physics/broadphase/PairList.d.ts.map +1 -0
- package/src/engine/physics/broadphase/PairList.js +97 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts +30 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.d.ts.map +1 -0
- package/src/engine/physics/broadphase/aabb_transform_oriented.js +93 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +16 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -0
- package/src/engine/physics/broadphase/compute_fat_world_aabb.js +61 -0
- package/src/engine/physics/broadphase/generate_pairs.d.ts +38 -0
- package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -0
- package/src/engine/physics/broadphase/generate_pairs.js +101 -0
- package/src/engine/physics/contact/ManifoldStore.d.ts +226 -0
- package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -0
- package/src/engine/physics/contact/ManifoldStore.js +499 -0
- package/src/engine/physics/ecs/BodyKind.d.ts +23 -0
- package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -0
- package/src/engine/physics/ecs/BodyKind.js +24 -0
- package/src/engine/physics/ecs/Collider.d.ts +98 -0
- package/src/engine/physics/ecs/Collider.d.ts.map +1 -0
- package/src/engine/physics/ecs/Collider.js +136 -0
- package/src/engine/physics/ecs/ColliderFlags.d.ts +14 -0
- package/src/engine/physics/ecs/ColliderFlags.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderFlags.js +15 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.d.ts +58 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderObserverSystem.js +103 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts +25 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.d.ts.map +1 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.js +37 -0
- package/src/engine/physics/ecs/PhysicsEvents.d.ts +15 -0
- package/src/engine/physics/ecs/PhysicsEvents.d.ts.map +1 -0
- package/src/engine/physics/ecs/PhysicsEvents.js +16 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +520 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -0
- package/src/engine/physics/ecs/PhysicsSystem.js +1159 -0
- package/src/engine/physics/ecs/RigidBody.d.ts +197 -0
- package/src/engine/physics/ecs/RigidBody.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBody.js +240 -0
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts +21 -0
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBodyFlags.js +22 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +28 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +81 -0
- package/src/engine/physics/ecs/SleepState.d.ts +11 -0
- package/src/engine/physics/ecs/SleepState.d.ts.map +1 -0
- package/src/engine/physics/ecs/SleepState.js +12 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts +46 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -0
- package/src/engine/physics/events/ContactEventBuffer.js +83 -0
- package/src/engine/physics/events/diff_manifolds.d.ts +25 -0
- package/src/engine/physics/events/diff_manifolds.d.ts.map +1 -0
- package/src/engine/physics/events/diff_manifolds.js +50 -0
- package/src/engine/physics/fluid/FluidField.d.ts +294 -16
- package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidField.js +510 -66
- package/src/engine/physics/fluid/FluidSimulator.d.ts +188 -5
- package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidSimulator.js +455 -95
- package/src/engine/physics/fluid/SliceVisualiser.d.ts +29 -6
- package/src/engine/physics/fluid/SliceVisualiser.d.ts.map +1 -1
- package/src/engine/physics/fluid/SliceVisualiser.js +190 -165
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +154 -0
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidComponent.js +238 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts +45 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidEffectorsComponent.js +89 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +107 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts.map +1 -0
- package/src/engine/physics/fluid/ecs/FluidSystem.js +278 -0
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts +62 -1
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/AbstractFluidEffector.js +81 -6
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts +17 -4
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/GlobalFluidEffector.js +105 -12
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts +43 -0
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.d.ts.map +1 -0
- package/src/engine/physics/fluid/effector/ImpulseFluidEffector.js +210 -0
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts +62 -1
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/WakeFluidEffector.js +302 -8
- package/src/engine/physics/fluid/prototype.js +102 -91
- package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts +33 -0
- package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/optimal_sor_omega.js +41 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts +20 -5
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.js +60 -38
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts +25 -4
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.js +93 -73
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts +23 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_scalar_advection.js +60 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts +23 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_divergence.js +68 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +30 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +66 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts +26 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_uniform.js +113 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts +30 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_shift_in_place.js +107 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +49 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +126 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +93 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +424 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts +20 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_unmasked_legacy.js +83 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +26 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +70 -0
- package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
- package/src/engine/physics/gjk/expanding_polytope_algorithm.js +8 -10
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts +29 -0
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -0
- package/src/engine/physics/inertia/world_inverse_inertia.js +79 -0
- package/src/engine/physics/integration/integrate_position.d.ts +16 -0
- package/src/engine/physics/integration/integrate_position.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_position.js +48 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts +25 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_velocity.js +79 -0
- package/src/engine/physics/integration/quat_integrate.d.ts +27 -0
- package/src/engine/physics/integration/quat_integrate.d.ts.map +1 -0
- package/src/engine/physics/integration/quat_integrate.js +62 -0
- package/src/engine/physics/island/IslandBuilder.d.ts +167 -0
- package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -0
- package/src/engine/physics/island/IslandBuilder.js +411 -0
- package/src/engine/physics/island/union_find.d.ts +51 -0
- package/src/engine/physics/island/union_find.d.ts.map +1 -0
- package/src/engine/physics/island/union_find.js +76 -0
- package/src/engine/physics/narrowphase/PosedShape.d.ts +59 -0
- package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/PosedShape.js +110 -0
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts +32 -0
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/box_box_manifold.js +543 -0
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts +122 -0
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/capsule_contacts.js +508 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts +11 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/narrowphase_step.js +382 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.d.ts +38 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/sphere_box_contact.js +130 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts +26 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/sphere_sphere_contact.js +51 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts +83 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.d.ts.map +1 -0
- package/src/engine/physics/queries/PhysicsSurfacePoint.js +100 -0
- package/src/engine/physics/queries/raycast.d.ts +20 -0
- package/src/engine/physics/queries/raycast.d.ts.map +1 -0
- package/src/engine/physics/queries/raycast.js +249 -0
- package/src/engine/physics/solver/friction_cone.d.ts +16 -0
- package/src/engine/physics/solver/friction_cone.d.ts.map +1 -0
- package/src/engine/physics/solver/friction_cone.js +37 -0
- package/src/engine/physics/solver/solve_contacts.d.ts +36 -0
- package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -0
- package/src/engine/physics/solver/solve_contacts.js +598 -0
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts +0 -34
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/OrderedEdge.js +0 -66
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts +0 -2
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/bt_mesh_calc_edges.js +0 -54
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts +0 -2
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.d.ts.map +0 -1
- package/src/core/geom/3d/topology/struct/binary/io/edge/get_or_create_edge_map.js +0 -26
- package/src/engine/ecs/components/Motion.d.ts +0 -21
- package/src/engine/ecs/components/Motion.d.ts.map +0 -1
- package/src/engine/ecs/components/Motion.js +0 -27
- package/src/engine/ecs/components/MotionSerializationAdapter.d.ts +0 -20
- package/src/engine/ecs/components/MotionSerializationAdapter.d.ts.map +0 -1
- package/src/engine/ecs/components/MotionSerializationAdapter.js +0 -26
- package/src/engine/ecs/systems/MotionSystem.d.ts +0 -9
- package/src/engine/ecs/systems/MotionSystem.d.ts.map +0 -1
- package/src/engine/ecs/systems/MotionSystem.js +0 -29
- package/src/engine/physics/fluid/Fluid.d.ts +0 -26
- package/src/engine/physics/fluid/Fluid.d.ts.map +0 -1
- package/src/engine/physics/fluid/Fluid.js +0 -221
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts +0 -7
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.d.ts.map +0 -1
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_reverse.js +0 -8
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { assert } from "../../../../../../assert.js";
|
|
2
|
+
import { BVH, NULL_NODE } from "../../../../../../bvh2/bvh3/BVH.js";
|
|
3
|
+
import { bvh_query_user_data_ray } from "../../../../../../bvh2/bvh3/query/bvh_query_user_data_ray.js";
|
|
4
|
+
import { seededRandom } from "../../../../../../math/random/seededRandom.js";
|
|
5
|
+
import { SurfacePoint3 } from "../../../../SurfacePoint3.js";
|
|
6
|
+
import { computeTriangleRayIntersection } from "../../../../triangle/computeTriangleRayIntersection.js";
|
|
7
|
+
|
|
8
|
+
// Three irrational, mutually unrelated ray directions for parity ray-cast
|
|
9
|
+
// majority vote. Same scheme as tetrahedral_mesh_carve_outside_surface — a
|
|
10
|
+
// single ray is fragile at grazing edges, three independent rays settle the
|
|
11
|
+
// vote correctly except in vanishingly improbable configurations.
|
|
12
|
+
const RAY_DIRECTIONS = [
|
|
13
|
+
0.97123, 0.18927, 0.14431,
|
|
14
|
+
0.34219, 0.91283, -0.22971,
|
|
15
|
+
-0.51237, 0.27894, 0.81235,
|
|
16
|
+
];
|
|
17
|
+
const RAY_COUNT = RAY_DIRECTIONS.length / 3;
|
|
18
|
+
|
|
19
|
+
// Stratification offset cap (as a fraction of a cell). 0 = perfect grid
|
|
20
|
+
// (worst case for Delaunay sliver count), 0.5 = candidates can sit anywhere
|
|
21
|
+
// in the cell. 0.35 is the usual sweet spot: enough jitter to break all
|
|
22
|
+
// face/edge alignments without losing the locality benefits of the grid.
|
|
23
|
+
const JITTER = 0.35;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Build a BVH whose leaves are the surface's triangle faces. User data on
|
|
27
|
+
* each leaf is the source face ID.
|
|
28
|
+
*/
|
|
29
|
+
function build_surface_bvh(bvh, mesh) {
|
|
30
|
+
bvh.release_all();
|
|
31
|
+
|
|
32
|
+
const face_count = mesh.faces.size;
|
|
33
|
+
const v = [0, 0, 0];
|
|
34
|
+
|
|
35
|
+
for (let f = 0; f < face_count; f++) {
|
|
36
|
+
if (!mesh.faces.is_allocated(f)) continue;
|
|
37
|
+
|
|
38
|
+
const l0 = mesh.face_read_loop(f);
|
|
39
|
+
const l1 = mesh.loop_read_next(l0);
|
|
40
|
+
const l2 = mesh.loop_read_next(l1);
|
|
41
|
+
|
|
42
|
+
const v0 = mesh.loop_read_vertex(l0);
|
|
43
|
+
const v1 = mesh.loop_read_vertex(l1);
|
|
44
|
+
const v2 = mesh.loop_read_vertex(l2);
|
|
45
|
+
|
|
46
|
+
mesh.vertex_read_coordinate(v, 0, v0);
|
|
47
|
+
let minx = v[0], miny = v[1], minz = v[2];
|
|
48
|
+
let maxx = v[0], maxy = v[1], maxz = v[2];
|
|
49
|
+
|
|
50
|
+
mesh.vertex_read_coordinate(v, 0, v1);
|
|
51
|
+
if (v[0] < minx) minx = v[0]; else if (v[0] > maxx) maxx = v[0];
|
|
52
|
+
if (v[1] < miny) miny = v[1]; else if (v[1] > maxy) maxy = v[1];
|
|
53
|
+
if (v[2] < minz) minz = v[2]; else if (v[2] > maxz) maxz = v[2];
|
|
54
|
+
|
|
55
|
+
mesh.vertex_read_coordinate(v, 0, v2);
|
|
56
|
+
if (v[0] < minx) minx = v[0]; else if (v[0] > maxx) maxx = v[0];
|
|
57
|
+
if (v[1] < miny) miny = v[1]; else if (v[1] > maxy) maxy = v[1];
|
|
58
|
+
if (v[2] < minz) minz = v[2]; else if (v[2] > maxz) maxz = v[2];
|
|
59
|
+
|
|
60
|
+
const node = bvh.allocate_node();
|
|
61
|
+
bvh.node_set_user_data(node, f);
|
|
62
|
+
bvh.node_set_aabb_primitive(node, minx, miny, minz, maxx, maxy, maxz);
|
|
63
|
+
bvh.insert_leaf(node);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const ray_hit = new SurfacePoint3();
|
|
68
|
+
const ray_candidates = [];
|
|
69
|
+
const va = [0, 0, 0];
|
|
70
|
+
const vb = [0, 0, 0];
|
|
71
|
+
const vc = [0, 0, 0];
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Parity ray-cast across `RAY_COUNT` directions; majority decides
|
|
75
|
+
* inside/outside. Returns true if (strict majority of) rays cross the
|
|
76
|
+
* surface an odd number of times.
|
|
77
|
+
*/
|
|
78
|
+
function point_is_inside(mesh, bvh, ox, oy, oz) {
|
|
79
|
+
const root = bvh.root;
|
|
80
|
+
if (root === NULL_NODE) return false;
|
|
81
|
+
|
|
82
|
+
let inside_votes = 0;
|
|
83
|
+
|
|
84
|
+
for (let r = 0; r < RAY_COUNT; r++) {
|
|
85
|
+
const dx = RAY_DIRECTIONS[r * 3];
|
|
86
|
+
const dy = RAY_DIRECTIONS[r * 3 + 1];
|
|
87
|
+
const dz = RAY_DIRECTIONS[r * 3 + 2];
|
|
88
|
+
|
|
89
|
+
const candidate_count = bvh_query_user_data_ray(
|
|
90
|
+
bvh, root,
|
|
91
|
+
ray_candidates, 0,
|
|
92
|
+
ox, oy, oz,
|
|
93
|
+
dx, dy, dz
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
let hits = 0;
|
|
97
|
+
for (let i = 0; i < candidate_count; i++) {
|
|
98
|
+
const f = ray_candidates[i];
|
|
99
|
+
const l0 = mesh.face_read_loop(f);
|
|
100
|
+
const l1 = mesh.loop_read_next(l0);
|
|
101
|
+
const l2 = mesh.loop_read_next(l1);
|
|
102
|
+
|
|
103
|
+
mesh.vertex_read_coordinate(va, 0, mesh.loop_read_vertex(l0));
|
|
104
|
+
mesh.vertex_read_coordinate(vb, 0, mesh.loop_read_vertex(l1));
|
|
105
|
+
mesh.vertex_read_coordinate(vc, 0, mesh.loop_read_vertex(l2));
|
|
106
|
+
|
|
107
|
+
const hit = computeTriangleRayIntersection(
|
|
108
|
+
ray_hit,
|
|
109
|
+
ox, oy, oz,
|
|
110
|
+
dx, dy, dz,
|
|
111
|
+
va[0], va[1], va[2],
|
|
112
|
+
vb[0], vb[1], vb[2],
|
|
113
|
+
vc[0], vc[1], vc[2]
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
if (hit) hits++;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if ((hits & 1) === 1) inside_votes++;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return inside_votes * 2 > RAY_COUNT;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Sample interior Steiner points for the volume enclosed by a closed
|
|
127
|
+
* triangle surface, on a jittered axis-aligned grid sized by
|
|
128
|
+
* `cells_per_dim`. Points outside the surface are discarded; what remains
|
|
129
|
+
* is a Float32Array of (x, y, z) tuples that lies strictly inside the
|
|
130
|
+
* surface (modulo classification noise on near-surface samples).
|
|
131
|
+
*
|
|
132
|
+
* Intended as input to `compute_delaunay_tetrahedral_mesh` alongside the
|
|
133
|
+
* surface vertices, so the Delaunay tet mesh has interior detail rather
|
|
134
|
+
* than being made entirely of surface-bound tets. Without these Steiner
|
|
135
|
+
* points, every tet of a non-trivial volume straddles or touches the
|
|
136
|
+
* surface, blowing up centroid-classification discretization error in
|
|
137
|
+
* the carving step.
|
|
138
|
+
*
|
|
139
|
+
* Grid cells are scaled so the longest bounding-box axis gets
|
|
140
|
+
* `cells_per_dim` cells; other axes get a proportional share rounded to
|
|
141
|
+
* the nearest integer (minimum 1). Each cell contributes one candidate
|
|
142
|
+
* point at its center, perturbed by a deterministic seeded jitter of up
|
|
143
|
+
* to ±0.35 cell widths — enough to break Delaunay-pathological
|
|
144
|
+
* alignments without losing the grid's spatial uniformity.
|
|
145
|
+
*
|
|
146
|
+
* @param {BinaryTopology} mesh closed surface
|
|
147
|
+
* @param {number} cells_per_dim grid resolution along the longest bbox axis
|
|
148
|
+
* @param {number} [seed] seed for the jitter RNG; same seed → same points
|
|
149
|
+
* @returns {Float32Array} flat (x, y, z) interior point positions
|
|
150
|
+
*/
|
|
151
|
+
export function bt_mesh_sample_interior_grid_points(mesh, cells_per_dim, seed = 0) {
|
|
152
|
+
assert.defined(mesh, 'mesh');
|
|
153
|
+
assert.equal(mesh.isBinaryTopology, true, 'mesh.isBinaryTopology !== true');
|
|
154
|
+
assert.isPositiveInteger(cells_per_dim, 'cells_per_dim');
|
|
155
|
+
|
|
156
|
+
// Compute bounding box from vertex pool.
|
|
157
|
+
const vertices = mesh.vertices;
|
|
158
|
+
const vertex_count = vertices.size;
|
|
159
|
+
const coord = [0, 0, 0];
|
|
160
|
+
|
|
161
|
+
let min_x = Infinity, min_y = Infinity, min_z = Infinity;
|
|
162
|
+
let max_x = -Infinity, max_y = -Infinity, max_z = -Infinity;
|
|
163
|
+
|
|
164
|
+
for (let v = 0; v < vertex_count; v++) {
|
|
165
|
+
if (!vertices.is_allocated(v)) continue;
|
|
166
|
+
mesh.vertex_read_coordinate(coord, 0, v);
|
|
167
|
+
if (coord[0] < min_x) min_x = coord[0]; if (coord[0] > max_x) max_x = coord[0];
|
|
168
|
+
if (coord[1] < min_y) min_y = coord[1]; if (coord[1] > max_y) max_y = coord[1];
|
|
169
|
+
if (coord[2] < min_z) min_z = coord[2]; if (coord[2] > max_z) max_z = coord[2];
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (!isFinite(min_x)) {
|
|
173
|
+
// Empty mesh.
|
|
174
|
+
return new Float32Array(0);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const dx = max_x - min_x;
|
|
178
|
+
const dy = max_y - min_y;
|
|
179
|
+
const dz = max_z - min_z;
|
|
180
|
+
const longest = Math.max(dx, dy, dz);
|
|
181
|
+
|
|
182
|
+
if (longest === 0) {
|
|
183
|
+
// Degenerate: all vertices coincide. No interior to sample.
|
|
184
|
+
return new Float32Array(0);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Per-axis cell count, rounded so cells are roughly cubical.
|
|
188
|
+
const cells_x = Math.max(1, Math.round((cells_per_dim * dx) / longest));
|
|
189
|
+
const cells_y = Math.max(1, Math.round((cells_per_dim * dy) / longest));
|
|
190
|
+
const cells_z = Math.max(1, Math.round((cells_per_dim * dz) / longest));
|
|
191
|
+
|
|
192
|
+
const cell_w = dx / cells_x;
|
|
193
|
+
const cell_h = dy / cells_y;
|
|
194
|
+
const cell_d = dz / cells_z;
|
|
195
|
+
|
|
196
|
+
// Build BVH over surface triangles for the inside-test.
|
|
197
|
+
const bvh = new BVH();
|
|
198
|
+
build_surface_bvh(bvh, mesh);
|
|
199
|
+
|
|
200
|
+
const rng = seededRandom(seed);
|
|
201
|
+
const out = []; // grow dynamically; copy to Float32Array at the end
|
|
202
|
+
|
|
203
|
+
for (let iz = 0; iz < cells_z; iz++) {
|
|
204
|
+
const cz0 = min_z + (iz + 0.5) * cell_d;
|
|
205
|
+
for (let iy = 0; iy < cells_y; iy++) {
|
|
206
|
+
const cy0 = min_y + (iy + 0.5) * cell_h;
|
|
207
|
+
for (let ix = 0; ix < cells_x; ix++) {
|
|
208
|
+
const cx0 = min_x + (ix + 0.5) * cell_w;
|
|
209
|
+
|
|
210
|
+
// Jitter each axis independently within ±JITTER cells.
|
|
211
|
+
const jx = (rng() * 2 - 1) * JITTER * cell_w;
|
|
212
|
+
const jy = (rng() * 2 - 1) * JITTER * cell_h;
|
|
213
|
+
const jz = (rng() * 2 - 1) * JITTER * cell_d;
|
|
214
|
+
|
|
215
|
+
const px = cx0 + jx;
|
|
216
|
+
const py = cy0 + jy;
|
|
217
|
+
const pz = cz0 + jz;
|
|
218
|
+
|
|
219
|
+
if (point_is_inside(mesh, bvh, px, py, pz)) {
|
|
220
|
+
out.push(px, py, pz);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return new Float32Array(out);
|
|
227
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumerate the boundary edge cycles of a BinaryTopology mesh as ordered
|
|
3
|
+
* sequences of edge IDs. Each cycle traces a single hole in the surface, in
|
|
4
|
+
* the order the edges appear along the boundary.
|
|
5
|
+
*
|
|
6
|
+
* Throws if any boundary vertex has more than two boundary edges (figure-8 /
|
|
7
|
+
* bridged loops are not supported in this pass — repair the mesh first).
|
|
8
|
+
*
|
|
9
|
+
* @param {BinaryTopology} mesh
|
|
10
|
+
* @returns {number[][]} array of cycles; each cycle is an array of boundary edge IDs
|
|
11
|
+
*/
|
|
12
|
+
export function bt_mesh_walk_boundary_loops(mesh: BinaryTopology): number[][];
|
|
13
|
+
//# sourceMappingURL=bt_mesh_walk_boundary_loops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bt_mesh_walk_boundary_loops.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/query/bt_mesh_walk_boundary_loops.js"],"names":[],"mappings":"AAwDA;;;;;;;;;;GAUG;AACH,mEAFa,MAAM,EAAE,EAAE,CA0CtB"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { NULL_POINTER } from "../BinaryTopology.js";
|
|
2
|
+
import { bt_query_edge_is_boundary } from "./bt_query_edge_is_boundary.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Step one position around the disk cycle of `vertex`, starting from `edge`.
|
|
6
|
+
* @param {BinaryTopology} mesh
|
|
7
|
+
* @param {number} edge
|
|
8
|
+
* @param {number} vertex
|
|
9
|
+
* @returns {number} next edge in the disk cycle around `vertex`
|
|
10
|
+
*/
|
|
11
|
+
function disk_next(mesh, edge, vertex) {
|
|
12
|
+
if (mesh.edge_read_vertex1(edge) === vertex) {
|
|
13
|
+
return mesh.edge_read_v1_disk_next(edge);
|
|
14
|
+
}
|
|
15
|
+
return mesh.edge_read_v2_disk_next(edge);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Find the unique boundary edge incident to `vertex` other than `from_edge`.
|
|
20
|
+
* Throws if the vertex does not have exactly 2 boundary edges (a 2-manifold
|
|
21
|
+
* boundary vertex must have exactly 2; fewer or more means the boundary is
|
|
22
|
+
* not a simple cycle — e.g., a figure-8 / bridged pinch).
|
|
23
|
+
*
|
|
24
|
+
* @param {BinaryTopology} mesh
|
|
25
|
+
* @param {number} vertex
|
|
26
|
+
* @param {number} from_edge
|
|
27
|
+
* @returns {number}
|
|
28
|
+
*/
|
|
29
|
+
function next_boundary_edge_at_vertex(mesh, vertex, from_edge) {
|
|
30
|
+
const first_edge = mesh.vertex_read_edge(vertex);
|
|
31
|
+
|
|
32
|
+
let found = NULL_POINTER;
|
|
33
|
+
let extras = 0;
|
|
34
|
+
|
|
35
|
+
let edge = first_edge;
|
|
36
|
+
do {
|
|
37
|
+
if (edge !== from_edge && bt_query_edge_is_boundary(mesh, edge)) {
|
|
38
|
+
if (found === NULL_POINTER) {
|
|
39
|
+
found = edge;
|
|
40
|
+
} else {
|
|
41
|
+
extras++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
edge = disk_next(mesh, edge, vertex);
|
|
45
|
+
} while (edge !== first_edge);
|
|
46
|
+
|
|
47
|
+
if (found === NULL_POINTER) {
|
|
48
|
+
throw new Error(`boundary at vertex ${vertex} is malformed: only one boundary edge attached (dead-end)`);
|
|
49
|
+
}
|
|
50
|
+
if (extras > 0) {
|
|
51
|
+
throw new Error(`boundary at vertex ${vertex} is malformed: ${extras + 2} boundary edges attached (pinch / figure-8 loops are not supported)`);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return found;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Enumerate the boundary edge cycles of a BinaryTopology mesh as ordered
|
|
59
|
+
* sequences of edge IDs. Each cycle traces a single hole in the surface, in
|
|
60
|
+
* the order the edges appear along the boundary.
|
|
61
|
+
*
|
|
62
|
+
* Throws if any boundary vertex has more than two boundary edges (figure-8 /
|
|
63
|
+
* bridged loops are not supported in this pass — repair the mesh first).
|
|
64
|
+
*
|
|
65
|
+
* @param {BinaryTopology} mesh
|
|
66
|
+
* @returns {number[][]} array of cycles; each cycle is an array of boundary edge IDs
|
|
67
|
+
*/
|
|
68
|
+
export function bt_mesh_walk_boundary_loops(mesh) {
|
|
69
|
+
const cycles = [];
|
|
70
|
+
const edges = mesh.edges;
|
|
71
|
+
const edge_count = edges.size;
|
|
72
|
+
|
|
73
|
+
const visited = new Uint8Array(edge_count);
|
|
74
|
+
|
|
75
|
+
for (let seed = 0; seed < edge_count; seed++) {
|
|
76
|
+
if (visited[seed]) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (!edges.is_allocated(seed)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if (!bt_query_edge_is_boundary(mesh, seed)) {
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const cycle = [];
|
|
87
|
+
let edge = seed;
|
|
88
|
+
let from_vertex = mesh.edge_read_vertex1(edge);
|
|
89
|
+
|
|
90
|
+
do {
|
|
91
|
+
visited[edge] = 1;
|
|
92
|
+
cycle.push(edge);
|
|
93
|
+
|
|
94
|
+
const v1 = mesh.edge_read_vertex1(edge);
|
|
95
|
+
const v2 = mesh.edge_read_vertex2(edge);
|
|
96
|
+
const next_vertex = (v1 === from_vertex) ? v2 : v1;
|
|
97
|
+
|
|
98
|
+
const next_edge = next_boundary_edge_at_vertex(mesh, next_vertex, edge);
|
|
99
|
+
|
|
100
|
+
edge = next_edge;
|
|
101
|
+
from_vertex = next_vertex;
|
|
102
|
+
} while (edge !== seed);
|
|
103
|
+
|
|
104
|
+
cycles.push(cycle);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return cycles;
|
|
108
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An edge is a boundary edge when exactly one face uses it — i.e., its radial
|
|
3
|
+
* cycle contains a single loop. Wire edges (no loops on the radial cycle) and
|
|
4
|
+
* manifold edges (two loops) return false.
|
|
5
|
+
*
|
|
6
|
+
* @param {BinaryTopology} mesh
|
|
7
|
+
* @param {number} edge_id
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function bt_query_edge_is_boundary(mesh: BinaryTopology, edge_id: number): boolean;
|
|
11
|
+
//# sourceMappingURL=bt_query_edge_is_boundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bt_query_edge_is_boundary.d.ts","sourceRoot":"","sources":["../../../../../../../../../src/core/geom/3d/topology/struct/binary/query/bt_query_edge_is_boundary.js"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,yEAHW,MAAM,GACJ,OAAO,CAUnB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { NULL_POINTER } from "../BinaryTopology.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* An edge is a boundary edge when exactly one face uses it — i.e., its radial
|
|
5
|
+
* cycle contains a single loop. Wire edges (no loops on the radial cycle) and
|
|
6
|
+
* manifold edges (two loops) return false.
|
|
7
|
+
*
|
|
8
|
+
* @param {BinaryTopology} mesh
|
|
9
|
+
* @param {number} edge_id
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*/
|
|
12
|
+
export function bt_query_edge_is_boundary(mesh, edge_id) {
|
|
13
|
+
const loop = mesh.edge_read_loop(edge_id);
|
|
14
|
+
|
|
15
|
+
if (loop === NULL_POINTER) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return mesh.loop_read_radial_next(loop) === loop;
|
|
20
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the signed volume enclosed by a triangle surface mesh given as
|
|
3
|
+
* flat positions + indices, via the divergence theorem.
|
|
4
|
+
*
|
|
5
|
+
* For every triangle (a, b, c) this sums the signed volume of the
|
|
6
|
+
* tetrahedron (origin, a, b, c); when the mesh is closed and consistently
|
|
7
|
+
* wound (CCW from outside → positive volume), the per-triangle contributions
|
|
8
|
+
* cancel everywhere except inside the surface, leaving the enclosed volume.
|
|
9
|
+
*
|
|
10
|
+
* Useful as a ground truth for validating volumetric mesh generation: the
|
|
11
|
+
* tetrahedralized version of the same closed surface should have a total tet
|
|
12
|
+
* volume close to this value (small discretization gap aside).
|
|
13
|
+
*
|
|
14
|
+
* @param {ArrayLike<number>} positions flat (x,y,z,…) array
|
|
15
|
+
* @param {ArrayLike<number>} indices 3 entries per triangle
|
|
16
|
+
* @returns {number} signed volume — positive for CCW-from-outside winding,
|
|
17
|
+
* negative if flipped, zero for an open or self-cancelling mesh
|
|
18
|
+
*/
|
|
19
|
+
export function triangle_mesh_compute_signed_volume(positions: ArrayLike<number>, indices: ArrayLike<number>): number;
|
|
20
|
+
//# sourceMappingURL=triangle_mesh_compute_signed_volume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"triangle_mesh_compute_signed_volume.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/triangle_mesh_compute_signed_volume.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,+DALW,UAAU,MAAM,CAAC,WACjB,UAAU,MAAM,CAAC,GACf,MAAM,CAoBlB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { triangle_compute_signed_volume } from "./triangle_compute_signed_volume.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compute the signed volume enclosed by a triangle surface mesh given as
|
|
5
|
+
* flat positions + indices, via the divergence theorem.
|
|
6
|
+
*
|
|
7
|
+
* For every triangle (a, b, c) this sums the signed volume of the
|
|
8
|
+
* tetrahedron (origin, a, b, c); when the mesh is closed and consistently
|
|
9
|
+
* wound (CCW from outside → positive volume), the per-triangle contributions
|
|
10
|
+
* cancel everywhere except inside the surface, leaving the enclosed volume.
|
|
11
|
+
*
|
|
12
|
+
* Useful as a ground truth for validating volumetric mesh generation: the
|
|
13
|
+
* tetrahedralized version of the same closed surface should have a total tet
|
|
14
|
+
* volume close to this value (small discretization gap aside).
|
|
15
|
+
*
|
|
16
|
+
* @param {ArrayLike<number>} positions flat (x,y,z,…) array
|
|
17
|
+
* @param {ArrayLike<number>} indices 3 entries per triangle
|
|
18
|
+
* @returns {number} signed volume — positive for CCW-from-outside winding,
|
|
19
|
+
* negative if flipped, zero for an open or self-cancelling mesh
|
|
20
|
+
*/
|
|
21
|
+
export function triangle_mesh_compute_signed_volume(positions, indices) {
|
|
22
|
+
let total = 0;
|
|
23
|
+
|
|
24
|
+
const n = indices.length;
|
|
25
|
+
for (let i = 0; i < n; i += 3) {
|
|
26
|
+
const a3 = indices[i] * 3;
|
|
27
|
+
const b3 = indices[i + 1] * 3;
|
|
28
|
+
const c3 = indices[i + 2] * 3;
|
|
29
|
+
|
|
30
|
+
total += triangle_compute_signed_volume(
|
|
31
|
+
positions[a3], positions[a3 + 1], positions[a3 + 2],
|
|
32
|
+
positions[b3], positions[b3 + 1], positions[b3 + 2],
|
|
33
|
+
positions[c3], positions[c3 + 1], positions[c3 + 2],
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return total;
|
|
38
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compressed Sparse Row representation of a weighted graph.
|
|
3
|
+
*
|
|
4
|
+
* The four parallel typed arrays — `edge_addresses`, `adjacency`,
|
|
5
|
+
* `edge_weights`, `vertex_weights` — share a single `ArrayBuffer` so that
|
|
6
|
+
* they are co-located in memory. This gives the allocator one allocation
|
|
7
|
+
* instead of four, the GC one reference to track, and the cache one
|
|
8
|
+
* contiguous region to prefetch when walking adjacency rows.
|
|
9
|
+
*
|
|
10
|
+
* Layout inside the buffer (all uint32, 4 bytes each):
|
|
11
|
+
* [0] edge_addresses, length vertex_count + 1
|
|
12
|
+
* [vertex_count + 1] adjacency, length adjacency_length
|
|
13
|
+
* [+adjacency_length] edge_weights, length adjacency_length
|
|
14
|
+
* [+adjacency_length] vertex_weights, length vertex_count
|
|
15
|
+
*
|
|
16
|
+
* Conventions match `mesh_to_metis_graph`:
|
|
17
|
+
* - `edge_addresses[v]` = start of vertex v's adjacency in `adjacency`
|
|
18
|
+
* - `edge_addresses[v + 1]` = end (exclusive)
|
|
19
|
+
* - `adjacency[k]` = neighbour vertex id
|
|
20
|
+
* - `edge_weights[k]` = weight of that edge
|
|
21
|
+
* - `vertex_weights[v]` = vertex weight (default 1)
|
|
22
|
+
*
|
|
23
|
+
* The class deliberately exposes the raw typed arrays as fields rather than
|
|
24
|
+
* via accessor methods. Hot loops in graph algorithms want
|
|
25
|
+
* `for (let k = xadj[v]; k < xadj[v+1]; k++) { ... adj[k] ... }` patterns; a
|
|
26
|
+
* callback-based iterator API would force a closure allocation per outer
|
|
27
|
+
* iteration and defeat V8's inlining.
|
|
28
|
+
*
|
|
29
|
+
* @author Alex Goldring
|
|
30
|
+
* @copyright Company Named Limited (c) 2026
|
|
31
|
+
*/
|
|
32
|
+
export class CSRGraph {
|
|
33
|
+
/**
|
|
34
|
+
* Construct a CSRGraph from existing arrays by COPYING into a new
|
|
35
|
+
* shared-buffer instance. The input arrays are not retained.
|
|
36
|
+
*
|
|
37
|
+
* `vertex_weights` is optional — if not provided, the new graph keeps the
|
|
38
|
+
* default all-1s vertex weights and `total_vertex_weight = vertex_count`.
|
|
39
|
+
*
|
|
40
|
+
* @param {number} vertex_count
|
|
41
|
+
* @param {ArrayLike<number>} edge_addresses length vertex_count + 1
|
|
42
|
+
* @param {ArrayLike<number>} adjacency length edge_addresses[vertex_count]
|
|
43
|
+
* @param {ArrayLike<number>} edge_weights parallel to adjacency
|
|
44
|
+
* @param {ArrayLike<number>} [vertex_weights] optional; length vertex_count
|
|
45
|
+
* @returns {CSRGraph}
|
|
46
|
+
*/
|
|
47
|
+
static fromArrays(vertex_count: number, edge_addresses: ArrayLike<number>, adjacency: ArrayLike<number>, edge_weights: ArrayLike<number>, vertex_weights?: ArrayLike<number>): CSRGraph;
|
|
48
|
+
/**
|
|
49
|
+
* @param {number} vertex_count
|
|
50
|
+
* @param {number} adjacency_length total length of the adjacency list
|
|
51
|
+
* (each undirected edge appears twice for symmetric graphs)
|
|
52
|
+
*/
|
|
53
|
+
constructor(vertex_count: number, adjacency_length: number);
|
|
54
|
+
/** @type {number} */
|
|
55
|
+
vertex_count: number;
|
|
56
|
+
/** @type {number} */
|
|
57
|
+
adjacency_length: number;
|
|
58
|
+
/**
|
|
59
|
+
* Single backing buffer for all four arrays.
|
|
60
|
+
* @type {ArrayBuffer}
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private __data_buffer;
|
|
64
|
+
/**
|
|
65
|
+
* CSR row pointers. Length = vertex_count + 1; the final entry equals
|
|
66
|
+
* adjacency_length.
|
|
67
|
+
* @type {Uint32Array}
|
|
68
|
+
*/
|
|
69
|
+
edge_addresses: Uint32Array;
|
|
70
|
+
/**
|
|
71
|
+
* CSR column indices — neighbour vertex ids.
|
|
72
|
+
* @type {Uint32Array}
|
|
73
|
+
*/
|
|
74
|
+
adjacency: Uint32Array;
|
|
75
|
+
/**
|
|
76
|
+
* Edge weights parallel to `adjacency`.
|
|
77
|
+
* @type {Uint32Array}
|
|
78
|
+
*/
|
|
79
|
+
edge_weights: Uint32Array;
|
|
80
|
+
/**
|
|
81
|
+
* Per-vertex weight. Initialised to all-1s; overwrite via direct
|
|
82
|
+
* indexing or `vertex_weights.set(...)` if your domain needs non-uniform
|
|
83
|
+
* weights. Remember to call `refresh_total_vertex_weight()` after.
|
|
84
|
+
* @type {Uint32Array}
|
|
85
|
+
*/
|
|
86
|
+
vertex_weights: Uint32Array;
|
|
87
|
+
/**
|
|
88
|
+
* Cached `Σ vertex_weights[v]`. Kept in sync via `refresh_total_vertex_weight()`.
|
|
89
|
+
* @type {number}
|
|
90
|
+
*/
|
|
91
|
+
total_vertex_weight: number;
|
|
92
|
+
/**
|
|
93
|
+
* The underlying shared buffer. Useful for fast bulk operations and for
|
|
94
|
+
* passing the graph between Web Workers via transfer.
|
|
95
|
+
* @returns {ArrayBuffer}
|
|
96
|
+
*/
|
|
97
|
+
get arrayBuffer(): ArrayBuffer;
|
|
98
|
+
/**
|
|
99
|
+
* Degree of vertex `vertex` (number of outgoing edges in the CSR).
|
|
100
|
+
* @param {number} vertex
|
|
101
|
+
* @returns {number}
|
|
102
|
+
*/
|
|
103
|
+
degree_of(vertex: number): number;
|
|
104
|
+
/**
|
|
105
|
+
* Sum of all entries in `edge_weights[0..adjacency_length)`.
|
|
106
|
+
* Each undirected edge contributes twice for a symmetric graph.
|
|
107
|
+
* @returns {number}
|
|
108
|
+
*/
|
|
109
|
+
sum_of_edge_weights(): number;
|
|
110
|
+
/**
|
|
111
|
+
* Recompute and store `total_vertex_weight` from the current `vertex_weights`.
|
|
112
|
+
*/
|
|
113
|
+
refresh_total_vertex_weight(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Shrink `adjacency` and `edge_weights` in place to `new_adjacency_length`.
|
|
116
|
+
*
|
|
117
|
+
* Use after a worst-case allocation has been partially filled (e.g. during
|
|
118
|
+
* coarse-graph contraction where the exact edge count is only known after
|
|
119
|
+
* the merge pass). Reallocates the shared buffer at the smaller size and
|
|
120
|
+
* recreates all four typed-array views; existing references to
|
|
121
|
+
* `this.adjacency` etc. are invalidated.
|
|
122
|
+
*
|
|
123
|
+
* Vertex-side data (`edge_addresses`, `vertex_weights`) and
|
|
124
|
+
* `total_vertex_weight` are preserved.
|
|
125
|
+
*
|
|
126
|
+
* No-op if `new_adjacency_length === adjacency_length`.
|
|
127
|
+
*
|
|
128
|
+
* @param {number} new_adjacency_length must be <= current `adjacency_length`
|
|
129
|
+
*/
|
|
130
|
+
truncate_adjacency(new_adjacency_length: number): void;
|
|
131
|
+
/**
|
|
132
|
+
* Copy the contents of `other` into `this`. Other must have matching
|
|
133
|
+
* `vertex_count` and `adjacency_length` (so the layouts align).
|
|
134
|
+
*
|
|
135
|
+
* Performed as a single bulk Uint32Array `.set()` thanks to the shared
|
|
136
|
+
* buffer layout — significantly faster than copying the four arrays
|
|
137
|
+
* individually.
|
|
138
|
+
*
|
|
139
|
+
* @param {CSRGraph} other
|
|
140
|
+
*/
|
|
141
|
+
copy(other: CSRGraph): void;
|
|
142
|
+
/**
|
|
143
|
+
* Deep copy. Returns a new `CSRGraph` with independent buffers.
|
|
144
|
+
* @returns {CSRGraph}
|
|
145
|
+
*/
|
|
146
|
+
clone(): CSRGraph;
|
|
147
|
+
/**
|
|
148
|
+
* Structural equality — same shape and same buffer contents.
|
|
149
|
+
* @param {CSRGraph} other
|
|
150
|
+
* @returns {boolean}
|
|
151
|
+
*/
|
|
152
|
+
equals(other: CSRGraph): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* 32-bit hash mixing the metadata fields and the entire buffer contents.
|
|
155
|
+
* Uses meep's standard `(h*31 + element)` convention via `uint32_array_hash`.
|
|
156
|
+
*
|
|
157
|
+
* @returns {number}
|
|
158
|
+
*/
|
|
159
|
+
hash(): number;
|
|
160
|
+
/**
|
|
161
|
+
* Type-check marker — avoids `instanceof` across module realms while still
|
|
162
|
+
* letting us assert "is a CSRGraph" cheaply.
|
|
163
|
+
* @readonly
|
|
164
|
+
* @type {boolean}
|
|
165
|
+
*/
|
|
166
|
+
readonly isCSRGraph: boolean;
|
|
167
|
+
}
|
|
168
|
+
//# sourceMappingURL=CSRGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CSRGraph.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/csr/CSRGraph.js"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH;IAsPI;;;;;;;;;;;;;OAaG;IACH,gCAPW,MAAM,kBACN,UAAU,MAAM,CAAC,aACjB,UAAU,MAAM,CAAC,gBACjB,UAAU,MAAM,CAAC,mBACjB,UAAU,MAAM,CAAC,GACf,QAAQ,CAgBpB;IAjRD;;;;OAIG;IACH,0BAJW,MAAM,oBACN,MAAM,EA8DhB;IAvDG,qBAAqB;IACrB,cADW,MAAM,CACe;IAChC,qBAAqB;IACrB,kBADW,MAAM,CACuB;IAOxC;;;;OAIG;IACH,sBAA4D;IAI5D;;;;OAIG;IACH,gBAFU,WAAW,CAEmE;IAGxF;;;OAGG;IACH,WAFU,WAAW,CAE8D;IAGnF;;;OAGG;IACH,cAFU,WAAW,CAEiE;IAGtF;;;;;OAKG;IACH,gBAFU,WAAW,CAE+D;IAGpF;;;OAGG;IACH,qBAFU,MAAM,CAEuB;IAG3C;;;;OAIG;IACH,+BAEC;IAED;;;;OAIG;IACH,kBAHW,MAAM,GACJ,MAAM,CAIlB;IAED;;;;OAIG;IACH,uBAFa,MAAM,CAUlB;IAED;;OAEG;IACH,oCAQC;IAED;;;;;;;;;;;;;;;OAeG;IACH,yCAFW,MAAM,QA6ChB;IAED;;;;;;;;;OASG;IACH,YAFW,QAAQ,QASlB;IAED;;;OAGG;IACH,SAFa,QAAQ,CAMpB;IAED;;;;OAIG;IACH,cAHW,QAAQ,GACN,OAAO,CAsBnB;IAED;;;;;OAKG;IACH,QAFa,MAAM,CAUlB;IAiCL;;;;;OAKG;IACH,qBAFU,OAAO,CAEY;CAR5B"}
|