@woosh/meep-engine 2.138.20 → 2.140.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/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.d.ts +3 -3
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.js +4 -4
- 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/aabb/aabb3_transform_oriented.d.ts +30 -0
- package/src/core/geom/3d/aabb/aabb3_transform_oriented.d.ts.map +1 -0
- package/src/core/geom/3d/aabb/aabb3_transform_oriented.js +93 -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/quaternion/quat3_to_matrix3.d.ts +54 -0
- package/src/core/geom/3d/quaternion/quat3_to_matrix3.d.ts.map +1 -0
- package/src/core/geom/3d/quaternion/quat3_to_matrix3.js +69 -0
- package/src/core/geom/3d/shape/AbstractShape3D.d.ts +24 -2
- package/src/core/geom/3d/shape/AbstractShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/AbstractShape3D.js +24 -1
- 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/HeightMapShape3D.d.ts +148 -0
- package/src/core/geom/3d/shape/HeightMapShape3D.d.ts.map +1 -0
- package/src/core/geom/3d/shape/HeightMapShape3D.js +451 -0
- package/src/core/geom/3d/shape/MeshShape3D.d.ts +210 -0
- package/src/core/geom/3d/shape/MeshShape3D.d.ts.map +1 -0
- package/src/core/geom/3d/shape/MeshShape3D.js +593 -0
- package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/TransformedShape3D.js +46 -2
- package/src/core/geom/3d/shape/Triangle3D.d.ts +95 -0
- package/src/core/geom/3d/shape/Triangle3D.d.ts.map +1 -0
- package/src/core/geom/3d/shape/Triangle3D.js +318 -0
- package/src/core/geom/3d/shape/UnionShape3D.js +13 -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/shape_mesh_from_geometry.d.ts +30 -0
- package/src/core/geom/3d/shape/shape_mesh_from_geometry.d.ts.map +1 -0
- package/src/core/geom/3d/shape/shape_mesh_from_geometry.js +64 -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 +671 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.d.ts +28 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_build_vertex_to_tets_map.js +48 -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 +387 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_smooth_vertex.d.ts +35 -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 +140 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_vertex_is_boundary.d.ts +31 -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 +97 -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 +41 -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 +124 -13
- 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/geom/3d/triangle/v3_compute_triangle_normal.d.ts +2 -2
- package/src/core/geom/3d/triangle/v3_compute_triangle_normal.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/v3_compute_triangle_normal.js +1 -1
- package/src/core/geom/vec3/v3_dot_array_array.d.ts +3 -3
- package/src/core/geom/vec3/v3_dot_array_array.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_dot_array_array.js +2 -2
- package/src/core/geom/vec3/v3_negate_array.d.ts +3 -3
- package/src/core/geom/vec3/v3_negate_array.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_negate_array.js +2 -2
- package/src/core/geom/vec3/v3_quat3_apply.d.ts +29 -0
- package/src/core/geom/vec3/v3_quat3_apply.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_quat3_apply.js +39 -0
- package/src/core/geom/vec3/v3_quat3_apply_inverse.d.ts +30 -0
- package/src/core/geom/vec3/v3_quat3_apply_inverse.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_quat3_apply_inverse.js +41 -0
- package/src/core/geom/vec3/v3_triple_cross_product.d.ts +32 -0
- package/src/core/geom/vec3/v3_triple_cross_product.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_triple_cross_product.js +45 -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 +115 -9
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerController.js +211 -176
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +601 -8
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +349 -8
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +319 -23
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +1789 -799
- package/src/engine/control/first-person/TODO.md +173 -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 +166 -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 +637 -120
- 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 +36 -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/geometry/CapsuleGeometry.d.ts +42 -0
- package/src/engine/graphics/geometry/CapsuleGeometry.d.ts.map +1 -0
- package/src/engine/graphics/geometry/CapsuleGeometry.js +171 -0
- 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/BULLET_REVIEW.md +945 -0
- package/src/engine/physics/CANNON_REVIEW.md +1300 -0
- package/src/engine/physics/JOLT_REVIEW.md +913 -0
- package/src/engine/physics/PLAN.md +461 -0
- package/src/engine/physics/RAPIER_REVIEW.md +934 -0
- package/src/engine/physics/REVIEW_001_ACTION_PLAN.md +642 -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/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 +299 -0
- package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -0
- package/src/engine/physics/contact/ManifoldStore.js +608 -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 +628 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -0
- package/src/engine/physics/ecs/PhysicsSystem.js +1301 -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 +456 -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_subtract_pressure_gradient.d.ts +48 -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 +92 -0
- package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts +6 -6
- package/src/engine/physics/gjk/expanding_polytope_algorithm.d.ts.map +1 -1
- package/src/engine/physics/gjk/expanding_polytope_algorithm.js +76 -32
- package/src/engine/physics/gjk/gjk.d.ts +28 -2
- package/src/engine/physics/gjk/gjk.d.ts.map +1 -1
- package/src/engine/physics/gjk/gjk.js +421 -378
- package/src/engine/physics/gjk/minkowski_support.d.ts +37 -0
- package/src/engine/physics/gjk/minkowski_support.d.ts.map +1 -0
- package/src/engine/physics/gjk/minkowski_support.js +75 -0
- package/src/engine/physics/gjk/mpr.d.ts +56 -0
- package/src/engine/physics/gjk/mpr.d.ts.map +1 -0
- package/src/engine/physics/gjk/mpr.js +344 -0
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts +44 -0
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -0
- package/src/engine/physics/inertia/world_inverse_inertia.js +77 -0
- package/src/engine/physics/integration/integrate_position.d.ts +34 -0
- package/src/engine/physics/integration/integrate_position.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_position.js +79 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts +55 -0
- package/src/engine/physics/integration/integrate_velocity.d.ts.map +1 -0
- package/src/engine/physics/integration/integrate_velocity.js +160 -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 +51 -0
- package/src/engine/physics/narrowphase/PosedShape.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/PosedShape.js +108 -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 +639 -0
- package/src/engine/physics/narrowphase/box_triangle_contact.d.ts +30 -0
- package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/box_triangle_contact.js +811 -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 +462 -0
- package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts +71 -0
- package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/capsule_triangle_contact.js +375 -0
- package/src/engine/physics/narrowphase/compute_penetration.d.ts +91 -0
- package/src/engine/physics/narrowphase/compute_penetration.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/compute_penetration.js +396 -0
- package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts +35 -0
- package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.js +80 -0
- package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts +31 -0
- package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/decomposition/decompose_to_triangles.js +55 -0
- package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts +42 -0
- package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.js +204 -0
- package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts +42 -0
- package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.js +94 -0
- package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts +37 -0
- package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/decomposition/triangle_buffer_layout.js +37 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts +17 -0
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/narrowphase_step.js +1422 -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 +123 -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/narrowphase/sphere_triangle_contact.d.ts +48 -0
- package/src/engine/physics/narrowphase/sphere_triangle_contact.d.ts.map +1 -0
- package/src/engine/physics/narrowphase/sphere_triangle_contact.js +143 -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/overlap_shape.d.ts +51 -0
- package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -0
- package/src/engine/physics/queries/overlap_shape.js +183 -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/queries/shape_cast.d.ts +56 -0
- package/src/engine/physics/queries/shape_cast.d.ts.map +1 -0
- package/src/engine/physics/queries/shape_cast.js +387 -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 +122 -0
- package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -0
- package/src/engine/physics/solver/solve_contacts.js +1016 -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,126 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Popcount lookup for the 6-bit neighbour mask. Index = mask value (0–63 used in
|
|
5
|
+
* practice; the table is sized 64 so the read is a single bounded indexed access).
|
|
6
|
+
* Values are the SOR denominator (number of fluid neighbours) for each mask.
|
|
7
|
+
*
|
|
8
|
+
* @type {Uint8Array}
|
|
9
|
+
*/
|
|
10
|
+
const POPCOUNT_6 = (function () {
|
|
11
|
+
const t = new Uint8Array(64);
|
|
12
|
+
for (let i = 0; i < 64; i++) {
|
|
13
|
+
let c = 0;
|
|
14
|
+
for (let b = 0; b < 6; b++) if (i & (1 << b)) c++;
|
|
15
|
+
t[i] = c;
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
})();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Solve the pressure Poisson equation `∇²p = div(v)` by red-black Successive
|
|
22
|
+
* Over-Relaxation (SOR), gated by a pre-baked per-cell neighbour mask.
|
|
23
|
+
*
|
|
24
|
+
* Per cell, the update is:
|
|
25
|
+
*
|
|
26
|
+
* p_jacobi(c) = ( sum_of_fluid_neighbour_pressures - div(c) ) / count
|
|
27
|
+
* p(c) = (1 - ω) * p(c) + ω * p_jacobi(c)
|
|
28
|
+
*
|
|
29
|
+
* "Which neighbours count as fluid" is determined entirely by `neighbour_mask`,
|
|
30
|
+
* a Uint8Array allocated and populated by {@link FluidField} via
|
|
31
|
+
* {@link FluidField.recomputeSolidNeighbourMask}. The encoding is:
|
|
32
|
+
*
|
|
33
|
+
* bit 0 (= 1) : -x neighbour is fluid
|
|
34
|
+
* bit 1 (= 2) : +x neighbour is fluid
|
|
35
|
+
* bit 2 (= 4) : -y neighbour is fluid
|
|
36
|
+
* bit 3 (= 8) : +y neighbour is fluid
|
|
37
|
+
* bit 4 (= 16) : -z neighbour is fluid
|
|
38
|
+
* bit 5 (= 32) : +z neighbour is fluid
|
|
39
|
+
*
|
|
40
|
+
* Solid cells encode as `mask = 0`, so the inner loop's `mask === 0 ? skip` covers
|
|
41
|
+
* both self-solid AND fluid-with-no-fluid-neighbours in one comparison. This
|
|
42
|
+
* eliminates six boundary checks plus six solid-neighbour checks per cell per
|
|
43
|
+
* iteration, replacing them with a single mask read and six bit-tests on a
|
|
44
|
+
* register-resident value. Boundary handling (cells at x=0, x=last, etc.) is
|
|
45
|
+
* implicit — the recompute step writes 0 into the boundary-facing bit, so the
|
|
46
|
+
* SOR loop never reads out-of-range memory.
|
|
47
|
+
*
|
|
48
|
+
* Cells are visited in two passes per iteration: first "red" (`(x+y+z) % 2 === 0`)
|
|
49
|
+
* then "black". Adjacent cells have opposite colour, so each pass reads only
|
|
50
|
+
* cells of the other colour and writes are independent — same in-place red-black
|
|
51
|
+
* scheme as the un-masked variant.
|
|
52
|
+
*
|
|
53
|
+
* @param {Float32Array|Float16Array} pressure Mutated in place. Pre-fill with 0
|
|
54
|
+
* or with the previous step's solution to warm-start.
|
|
55
|
+
* @param {Float32Array|Float16Array} divergence From
|
|
56
|
+
* {@link v3_grid_compute_divergence}. Same dtype as pressure.
|
|
57
|
+
* @param {number} res_x
|
|
58
|
+
* @param {number} res_y
|
|
59
|
+
* @param {number} res_z
|
|
60
|
+
* @param {number} iterations Number of red-black sweeps.
|
|
61
|
+
* @param {number} omega SOR relaxation factor in (0, 2). Near-optimal values
|
|
62
|
+
* come from {@link optimal_sor_omega}.
|
|
63
|
+
* @param {Uint8Array} neighbour_mask Length ≥ res_x*res_y*res_z. Each byte
|
|
64
|
+
* encodes the fluid-neighbour bitmask (see above). MUST be recomputed
|
|
65
|
+
* whenever the underlying solid mask changes.
|
|
66
|
+
*/
|
|
67
|
+
export function v3_grid_solve_pressure(pressure, divergence, res_x, res_y, res_z, iterations, omega, neighbour_mask) {
|
|
68
|
+
const cell_count = res_x * res_y * res_z;
|
|
69
|
+
|
|
70
|
+
assert.notEqual(pressure, divergence, "pressure must not alias divergence");
|
|
71
|
+
assert.greaterThanOrEqual(pressure.length, cell_count, "pressure covers grid");
|
|
72
|
+
assert.greaterThanOrEqual(divergence.length, cell_count, "divergence covers grid");
|
|
73
|
+
assert.greaterThanOrEqual(neighbour_mask.length, cell_count, "neighbour_mask covers grid");
|
|
74
|
+
assert.isNonNegativeInteger(iterations, "iterations");
|
|
75
|
+
assert.greaterThan(omega, 0, "omega");
|
|
76
|
+
assert.lessThan(omega, 2, "omega");
|
|
77
|
+
|
|
78
|
+
if (iterations === 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const slice_size = res_x * res_y;
|
|
83
|
+
const one_minus_omega = 1 - omega;
|
|
84
|
+
|
|
85
|
+
for (let iter = 0; iter < iterations; iter++) {
|
|
86
|
+
|
|
87
|
+
// Two passes per iteration: red (parity 0), then black (parity 1). Inside each
|
|
88
|
+
// pass the cell colour determines which x-positions we visit per scanline.
|
|
89
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
90
|
+
|
|
91
|
+
for (let z = 0; z < res_z; z++) {
|
|
92
|
+
const z_off = z * slice_size;
|
|
93
|
+
|
|
94
|
+
for (let y = 0; y < res_y; y++) {
|
|
95
|
+
const y_off = y * res_x;
|
|
96
|
+
|
|
97
|
+
// First x for this scanline of the requested colour.
|
|
98
|
+
const x_start = ((z + y) & 1) ^ pass;
|
|
99
|
+
|
|
100
|
+
for (let x = x_start; x < res_x; x += 2) {
|
|
101
|
+
const c = z_off + y_off + x;
|
|
102
|
+
|
|
103
|
+
const mask = neighbour_mask[c];
|
|
104
|
+
if (mask === 0) {
|
|
105
|
+
// Solid cell OR isolated fluid with no fluid neighbours.
|
|
106
|
+
// Either way, no degrees of freedom — skip.
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
let sum = 0;
|
|
111
|
+
if (mask & 1) sum += pressure[c - 1];
|
|
112
|
+
if (mask & 2) sum += pressure[c + 1];
|
|
113
|
+
if (mask & 4) sum += pressure[c - res_x];
|
|
114
|
+
if (mask & 8) sum += pressure[c + res_x];
|
|
115
|
+
if (mask & 16) sum += pressure[c - slice_size];
|
|
116
|
+
if (mask & 32) sum += pressure[c + slice_size];
|
|
117
|
+
|
|
118
|
+
const count = POPCOUNT_6[mask];
|
|
119
|
+
const p_target = (sum - divergence[c]) / count;
|
|
120
|
+
pressure[c] = one_minus_omega * pressure[c] + omega * p_target;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pressure Poisson solver: Modified Incomplete Cholesky preconditioned Conjugate
|
|
3
|
+
* Gradient — MIC(0)-PCG.
|
|
4
|
+
*
|
|
5
|
+
* Solves `A * p = -div(v)` where A is the 7-point discrete Laplacian over fluid
|
|
6
|
+
* cells (same sign convention as {@link v3_grid_solve_pressure} — that
|
|
7
|
+
* function's SOR update is exactly the splitting `A * p = -div`). Per cell:
|
|
8
|
+
*
|
|
9
|
+
* A[c, c] = number of fluid neighbours (= popcount(neighbour_mask[c]))
|
|
10
|
+
* A[c, c'] = -1 if c' is a fluid neighbour of c, else 0
|
|
11
|
+
*
|
|
12
|
+
* PCG converges in roughly `O(√κ)` iterations where κ is the spectral condition
|
|
13
|
+
* number of `M⁻¹A`. The MIC(0) preconditioner reduces κ from `O(N²)` (raw
|
|
14
|
+
* Laplacian) to `O(N)`, so a single PCG iter does a lot more useful work than
|
|
15
|
+
* a single SOR sweep.
|
|
16
|
+
*
|
|
17
|
+
* **Empirical finding (V8 / Node, single-thread, this implementation).** Each
|
|
18
|
+
* PCG iter involves ~8 separate per-cell passes (As compute, axpy×2,
|
|
19
|
+
* mean-subtract, fwd+bwd triangular solves, dot, s update) vs SOR's 2. In
|
|
20
|
+
* native code each pass is bandwidth-bound and per-iter ratio approaches the
|
|
21
|
+
* textbook 2× — yielding the canonical 1.5–2× wall-time win for PCG. In V8,
|
|
22
|
+
* per-pass loop overhead dominates; the actual per-iter ratio is closer to
|
|
23
|
+
* 4-6× and PCG ends up SLOWER than SOR at iso-quality on production grids:
|
|
24
|
+
*
|
|
25
|
+
* res=64: SOR 16 iter / 75 ms, max|div| 3.09e-1
|
|
26
|
+
* PCG 8 iter / 181 ms, max|div| 3.72e-3 (PCG 2.4× slower)
|
|
27
|
+
*
|
|
28
|
+
* res=128: SOR 32 iter / 862 ms, max|div| 8.74e-1
|
|
29
|
+
* PCG 8 iter /1452 ms, max|div| 5.65e-3 (PCG 1.7× slower)
|
|
30
|
+
*
|
|
31
|
+
* (Reproduce via `bench: MIC-PCG vs SOR` in bench.spec.js.)
|
|
32
|
+
*
|
|
33
|
+
* Where PCG still wins: **convergence depth**. At the SAME iter count it
|
|
34
|
+
* produces dramatically lower residual divergence (84× better max|div| at
|
|
35
|
+
* 64³, 247× at 128³). If you need quality below the cell-centered operator
|
|
36
|
+
* floor SOR plateaus at — e.g. quantitative pressure inspection, or
|
|
37
|
+
* extreme-impulse scenes where the SOR floor is visible — PCG is the answer.
|
|
38
|
+
* For visual-fluids steady state, **leave the default at SOR**.
|
|
39
|
+
*
|
|
40
|
+
* If this code is ever ported to WASM SIMD or WebGPU the perf comparison
|
|
41
|
+
* flips: per-iter overhead becomes negligible in those environments and the
|
|
42
|
+
* theoretical 1.5–2× PCG win re-emerges. Worth re-running the bench then.
|
|
43
|
+
*
|
|
44
|
+
* Algorithm (Bridson "Fluid Simulation for Computer Graphics" §5.6, Saad
|
|
45
|
+
* §10.2):
|
|
46
|
+
*
|
|
47
|
+
* 1. build_preconditioner: walk fluid cells in lex order, computing
|
|
48
|
+
* precon[c] = 1 / sqrt(e[c]) where e[c] is the modified Cholesky
|
|
49
|
+
* diagonal. Backward neighbours (-x, -y, -z) contribute to the
|
|
50
|
+
* subtraction.
|
|
51
|
+
*
|
|
52
|
+
* 2. r₀ = -div - A * p₀ (initial residual; p₀ is the warm-start)
|
|
53
|
+
* z₀ = M⁻¹ * r₀ (apply preconditioner — two triangular solves)
|
|
54
|
+
* s₀ = z₀
|
|
55
|
+
* σ₀ = r₀ · z₀
|
|
56
|
+
*
|
|
57
|
+
* 3. For k = 0, 1, …, max_iter-1:
|
|
58
|
+
* A·sₖ
|
|
59
|
+
* α = σₖ / (sₖ · A·sₖ)
|
|
60
|
+
* p ← p + α·sₖ
|
|
61
|
+
* r ← r - α·A·sₖ
|
|
62
|
+
* z ← M⁻¹ · r
|
|
63
|
+
* σₖ₊₁ = r · z
|
|
64
|
+
* β = σₖ₊₁ / σₖ
|
|
65
|
+
* s ← z + β·s
|
|
66
|
+
*
|
|
67
|
+
* Preconditioner apply is a forward sweep (L·y = r) followed by a backward
|
|
68
|
+
* sweep (Lᵀ·z = y). Both sweeps are O(N) and inherently sequential — they're
|
|
69
|
+
* the hot path that prevents MIC-PCG from parallelizing onto a GPU without
|
|
70
|
+
* substantial reformulation. On single-thread JS that's not a concern.
|
|
71
|
+
*
|
|
72
|
+
* Solid cells (mask = 0) are excluded from the system: their pressure stays at
|
|
73
|
+
* whatever it was (typically 0), their entries in r, z, s, As stay 0, and they
|
|
74
|
+
* contribute nothing to dot products.
|
|
75
|
+
*
|
|
76
|
+
* @param {Float32Array|Float16Array} pressure Mutated in place. Pre-fill with 0
|
|
77
|
+
* or with the previous step's solution to warm-start.
|
|
78
|
+
* @param {Float32Array|Float16Array} divergence From `v3_grid_compute_divergence`.
|
|
79
|
+
* @param {number} res_x
|
|
80
|
+
* @param {number} res_y
|
|
81
|
+
* @param {number} res_z
|
|
82
|
+
* @param {number} max_iterations Cap. Converged early-exits via implicit-zero
|
|
83
|
+
* dot product (sigma reaches 0 or numerical noise).
|
|
84
|
+
* @param {Uint8Array} neighbour_mask From `v3_grid_compute_solid_neighbour_mask`.
|
|
85
|
+
* @param {Float32Array} scratch_r Length ≥ rx*ry*rz. Residual.
|
|
86
|
+
* @param {Float32Array} scratch_z Length ≥ rx*ry*rz. Preconditioned residual.
|
|
87
|
+
* @param {Float32Array} scratch_s Length ≥ rx*ry*rz. Search direction.
|
|
88
|
+
* @param {Float32Array} scratch_As Length ≥ rx*ry*rz. A applied to s.
|
|
89
|
+
* @param {Float32Array} scratch_precon Length ≥ rx*ry*rz. Preconditioner
|
|
90
|
+
* diagonal (1/sqrt(e_c) per fluid cell, 0 for solid).
|
|
91
|
+
*/
|
|
92
|
+
export function v3_grid_solve_pressure_pcg(pressure: Float32Array | Float16Array, divergence: Float32Array | Float16Array, res_x: number, res_y: number, res_z: number, max_iterations: number, neighbour_mask: Uint8Array, scratch_r: Float32Array, scratch_z: Float32Array, scratch_s: Float32Array, scratch_As: Float32Array, scratch_precon: Float32Array): void;
|
|
93
|
+
//# sourceMappingURL=v3_grid_solve_pressure_pcg.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v3_grid_solve_pressure_pcg.d.ts","sourceRoot":"","sources":["../../../../../../src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js"],"names":[],"mappings":"AAuCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0FG;AACH,qDAhBW,YAAY,eAAa,cAEzB,YAAY,eAAa,SACzB,MAAM,SACN,MAAM,SACN,MAAM,kBACN,MAAM,kBAEN,UAAU,aACV,YAAY,aACZ,YAAY,aACZ,YAAY,cACZ,YAAY,kBACZ,YAAY,QAuNtB"}
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import { assert } from "../../../../core/assert.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Popcount table for the 6-bit neighbour mask — same encoding used by
|
|
5
|
+
* {@link v3_grid_solve_pressure}. Indexed by the mask byte (0-63), value is the
|
|
6
|
+
* SOR / Laplacian denominator = number of fluid neighbours.
|
|
7
|
+
*
|
|
8
|
+
* @type {Uint8Array}
|
|
9
|
+
*/
|
|
10
|
+
const POPCOUNT_6 = (function () {
|
|
11
|
+
const t = new Uint8Array(64);
|
|
12
|
+
for (let i = 0; i < 64; i++) {
|
|
13
|
+
let c = 0;
|
|
14
|
+
for (let b = 0; b < 6; b++) if (i & (1 << b)) c++;
|
|
15
|
+
t[i] = c;
|
|
16
|
+
}
|
|
17
|
+
return t;
|
|
18
|
+
})();
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* MIC(0) modification weight. Bridson's recommendation is 0.97; the factor scales
|
|
22
|
+
* how much "would-have-been-fill-in" we re-add onto the diagonal. Lower → closer
|
|
23
|
+
* to plain IC(0). Higher → stronger preconditioning but riskier (can produce a
|
|
24
|
+
* non-SPD matrix). 0.97 is the canonical sweet spot from the literature.
|
|
25
|
+
*
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
28
|
+
const MIC_TAU = 0.97;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Diagonal safeguard threshold. If the computed Cholesky diagonal element falls
|
|
32
|
+
* below `MIC_SIGMA * A_diag`, we discard the IC factorization for that cell and
|
|
33
|
+
* fall back to `e = A_diag` (i.e. Jacobi for that cell). Prevents `1/sqrt(small)`
|
|
34
|
+
* from blowing up.
|
|
35
|
+
*
|
|
36
|
+
* @type {number}
|
|
37
|
+
*/
|
|
38
|
+
const MIC_SIGMA = 0.25;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Pressure Poisson solver: Modified Incomplete Cholesky preconditioned Conjugate
|
|
42
|
+
* Gradient — MIC(0)-PCG.
|
|
43
|
+
*
|
|
44
|
+
* Solves `A * p = -div(v)` where A is the 7-point discrete Laplacian over fluid
|
|
45
|
+
* cells (same sign convention as {@link v3_grid_solve_pressure} — that
|
|
46
|
+
* function's SOR update is exactly the splitting `A * p = -div`). Per cell:
|
|
47
|
+
*
|
|
48
|
+
* A[c, c] = number of fluid neighbours (= popcount(neighbour_mask[c]))
|
|
49
|
+
* A[c, c'] = -1 if c' is a fluid neighbour of c, else 0
|
|
50
|
+
*
|
|
51
|
+
* PCG converges in roughly `O(√κ)` iterations where κ is the spectral condition
|
|
52
|
+
* number of `M⁻¹A`. The MIC(0) preconditioner reduces κ from `O(N²)` (raw
|
|
53
|
+
* Laplacian) to `O(N)`, so a single PCG iter does a lot more useful work than
|
|
54
|
+
* a single SOR sweep.
|
|
55
|
+
*
|
|
56
|
+
* **Empirical finding (V8 / Node, single-thread, this implementation).** Each
|
|
57
|
+
* PCG iter involves ~8 separate per-cell passes (As compute, axpy×2,
|
|
58
|
+
* mean-subtract, fwd+bwd triangular solves, dot, s update) vs SOR's 2. In
|
|
59
|
+
* native code each pass is bandwidth-bound and per-iter ratio approaches the
|
|
60
|
+
* textbook 2× — yielding the canonical 1.5–2× wall-time win for PCG. In V8,
|
|
61
|
+
* per-pass loop overhead dominates; the actual per-iter ratio is closer to
|
|
62
|
+
* 4-6× and PCG ends up SLOWER than SOR at iso-quality on production grids:
|
|
63
|
+
*
|
|
64
|
+
* res=64: SOR 16 iter / 75 ms, max|div| 3.09e-1
|
|
65
|
+
* PCG 8 iter / 181 ms, max|div| 3.72e-3 (PCG 2.4× slower)
|
|
66
|
+
*
|
|
67
|
+
* res=128: SOR 32 iter / 862 ms, max|div| 8.74e-1
|
|
68
|
+
* PCG 8 iter /1452 ms, max|div| 5.65e-3 (PCG 1.7× slower)
|
|
69
|
+
*
|
|
70
|
+
* (Reproduce via `bench: MIC-PCG vs SOR` in bench.spec.js.)
|
|
71
|
+
*
|
|
72
|
+
* Where PCG still wins: **convergence depth**. At the SAME iter count it
|
|
73
|
+
* produces dramatically lower residual divergence (84× better max|div| at
|
|
74
|
+
* 64³, 247× at 128³). If you need quality below the cell-centered operator
|
|
75
|
+
* floor SOR plateaus at — e.g. quantitative pressure inspection, or
|
|
76
|
+
* extreme-impulse scenes where the SOR floor is visible — PCG is the answer.
|
|
77
|
+
* For visual-fluids steady state, **leave the default at SOR**.
|
|
78
|
+
*
|
|
79
|
+
* If this code is ever ported to WASM SIMD or WebGPU the perf comparison
|
|
80
|
+
* flips: per-iter overhead becomes negligible in those environments and the
|
|
81
|
+
* theoretical 1.5–2× PCG win re-emerges. Worth re-running the bench then.
|
|
82
|
+
*
|
|
83
|
+
* Algorithm (Bridson "Fluid Simulation for Computer Graphics" §5.6, Saad
|
|
84
|
+
* §10.2):
|
|
85
|
+
*
|
|
86
|
+
* 1. build_preconditioner: walk fluid cells in lex order, computing
|
|
87
|
+
* precon[c] = 1 / sqrt(e[c]) where e[c] is the modified Cholesky
|
|
88
|
+
* diagonal. Backward neighbours (-x, -y, -z) contribute to the
|
|
89
|
+
* subtraction.
|
|
90
|
+
*
|
|
91
|
+
* 2. r₀ = -div - A * p₀ (initial residual; p₀ is the warm-start)
|
|
92
|
+
* z₀ = M⁻¹ * r₀ (apply preconditioner — two triangular solves)
|
|
93
|
+
* s₀ = z₀
|
|
94
|
+
* σ₀ = r₀ · z₀
|
|
95
|
+
*
|
|
96
|
+
* 3. For k = 0, 1, …, max_iter-1:
|
|
97
|
+
* A·sₖ
|
|
98
|
+
* α = σₖ / (sₖ · A·sₖ)
|
|
99
|
+
* p ← p + α·sₖ
|
|
100
|
+
* r ← r - α·A·sₖ
|
|
101
|
+
* z ← M⁻¹ · r
|
|
102
|
+
* σₖ₊₁ = r · z
|
|
103
|
+
* β = σₖ₊₁ / σₖ
|
|
104
|
+
* s ← z + β·s
|
|
105
|
+
*
|
|
106
|
+
* Preconditioner apply is a forward sweep (L·y = r) followed by a backward
|
|
107
|
+
* sweep (Lᵀ·z = y). Both sweeps are O(N) and inherently sequential — they're
|
|
108
|
+
* the hot path that prevents MIC-PCG from parallelizing onto a GPU without
|
|
109
|
+
* substantial reformulation. On single-thread JS that's not a concern.
|
|
110
|
+
*
|
|
111
|
+
* Solid cells (mask = 0) are excluded from the system: their pressure stays at
|
|
112
|
+
* whatever it was (typically 0), their entries in r, z, s, As stay 0, and they
|
|
113
|
+
* contribute nothing to dot products.
|
|
114
|
+
*
|
|
115
|
+
* @param {Float32Array|Float16Array} pressure Mutated in place. Pre-fill with 0
|
|
116
|
+
* or with the previous step's solution to warm-start.
|
|
117
|
+
* @param {Float32Array|Float16Array} divergence From `v3_grid_compute_divergence`.
|
|
118
|
+
* @param {number} res_x
|
|
119
|
+
* @param {number} res_y
|
|
120
|
+
* @param {number} res_z
|
|
121
|
+
* @param {number} max_iterations Cap. Converged early-exits via implicit-zero
|
|
122
|
+
* dot product (sigma reaches 0 or numerical noise).
|
|
123
|
+
* @param {Uint8Array} neighbour_mask From `v3_grid_compute_solid_neighbour_mask`.
|
|
124
|
+
* @param {Float32Array} scratch_r Length ≥ rx*ry*rz. Residual.
|
|
125
|
+
* @param {Float32Array} scratch_z Length ≥ rx*ry*rz. Preconditioned residual.
|
|
126
|
+
* @param {Float32Array} scratch_s Length ≥ rx*ry*rz. Search direction.
|
|
127
|
+
* @param {Float32Array} scratch_As Length ≥ rx*ry*rz. A applied to s.
|
|
128
|
+
* @param {Float32Array} scratch_precon Length ≥ rx*ry*rz. Preconditioner
|
|
129
|
+
* diagonal (1/sqrt(e_c) per fluid cell, 0 for solid).
|
|
130
|
+
*/
|
|
131
|
+
export function v3_grid_solve_pressure_pcg(
|
|
132
|
+
pressure, divergence,
|
|
133
|
+
res_x, res_y, res_z,
|
|
134
|
+
max_iterations,
|
|
135
|
+
neighbour_mask,
|
|
136
|
+
scratch_r, scratch_z, scratch_s, scratch_As, scratch_precon
|
|
137
|
+
) {
|
|
138
|
+
const cells = res_x * res_y * res_z;
|
|
139
|
+
|
|
140
|
+
assert.notEqual(pressure, divergence, "pressure must not alias divergence");
|
|
141
|
+
assert.greaterThanOrEqual(pressure.length, cells, "pressure covers grid");
|
|
142
|
+
assert.greaterThanOrEqual(divergence.length, cells, "divergence covers grid");
|
|
143
|
+
assert.greaterThanOrEqual(neighbour_mask.length, cells, "neighbour_mask covers grid");
|
|
144
|
+
assert.greaterThanOrEqual(scratch_r.length, cells, "scratch_r covers grid");
|
|
145
|
+
assert.greaterThanOrEqual(scratch_z.length, cells, "scratch_z covers grid");
|
|
146
|
+
assert.greaterThanOrEqual(scratch_s.length, cells, "scratch_s covers grid");
|
|
147
|
+
assert.greaterThanOrEqual(scratch_As.length, cells, "scratch_As covers grid");
|
|
148
|
+
assert.greaterThanOrEqual(scratch_precon.length, cells, "scratch_precon covers grid");
|
|
149
|
+
assert.isNonNegativeInteger(max_iterations, "max_iterations");
|
|
150
|
+
|
|
151
|
+
if (max_iterations === 0) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const rx = res_x;
|
|
156
|
+
const slice = res_x * res_y;
|
|
157
|
+
|
|
158
|
+
const precon = scratch_precon;
|
|
159
|
+
const r = scratch_r;
|
|
160
|
+
const z = scratch_z;
|
|
161
|
+
const s = scratch_s;
|
|
162
|
+
const As = scratch_As;
|
|
163
|
+
|
|
164
|
+
// Count fluid cells for the null-space projection (mean subtraction). With
|
|
165
|
+
// all-Neumann boundary conditions and no Dirichlet anchor, the discrete
|
|
166
|
+
// Laplacian has a 1-D null space (constant pressure). Plain (P)CG drifts
|
|
167
|
+
// along that direction — iterates can explode within ~10 sweeps even
|
|
168
|
+
// though the residual stays small in the orthogonal complement. Projecting
|
|
169
|
+
// r back onto the mean-zero subspace after every update keeps the search
|
|
170
|
+
// direction perpendicular to the null space and lets PCG converge as
|
|
171
|
+
// theory predicts.
|
|
172
|
+
//
|
|
173
|
+
// (Standard fluids practice — see Bridson §5.5. The alternative is to pin
|
|
174
|
+
// one cell to a Dirichlet value and exclude it from the system, but mean
|
|
175
|
+
// subtraction has the same effect with simpler bookkeeping.)
|
|
176
|
+
let fluid_count = 0;
|
|
177
|
+
for (let c = 0; c < cells; c++) {
|
|
178
|
+
if (neighbour_mask[c] !== 0) fluid_count++;
|
|
179
|
+
}
|
|
180
|
+
if (fluid_count === 0) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ─── 1. Build MIC(0) preconditioner ─────────────────────────────────────
|
|
185
|
+
//
|
|
186
|
+
// Walk fluid cells in lex order; for each, compute the modified Cholesky
|
|
187
|
+
// diagonal e[c] from the backward (-x, -y, -z) fluid neighbours and store
|
|
188
|
+
// precon[c] = 1 / sqrt(e[c]). Solid / isolated cells keep precon = 0.
|
|
189
|
+
//
|
|
190
|
+
// The "modified" piece adds tau * (off-direction terms) back onto the
|
|
191
|
+
// diagonal — it compensates for fill-in that plain IC(0) drops, and makes
|
|
192
|
+
// PCG converge in O(√N) instead of O(N²/³).
|
|
193
|
+
precon.fill(0);
|
|
194
|
+
for (let c = 0; c < cells; c++) {
|
|
195
|
+
const mask = neighbour_mask[c];
|
|
196
|
+
if (mask === 0) {
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
const a_diag = POPCOUNT_6[mask];
|
|
200
|
+
let e = a_diag;
|
|
201
|
+
|
|
202
|
+
if (mask & 1) { // -x backward neighbour is fluid
|
|
203
|
+
const c_prev = c - 1;
|
|
204
|
+
const p_prev = precon[c_prev];
|
|
205
|
+
const p_prev_sq = p_prev * p_prev;
|
|
206
|
+
// (A[c, c_prev] * precon[c_prev])^2 = precon_prev^2 since A = -1.
|
|
207
|
+
e -= p_prev_sq;
|
|
208
|
+
// Modification: tau * A[c, c_prev] * (off-direction A entries from c_prev) * precon_prev^2.
|
|
209
|
+
// A[c, c_prev] = -1. Off-directions from c_prev pointing away from c
|
|
210
|
+
// are +y (bit 3 of c_prev's mask) and +z (bit 5).
|
|
211
|
+
const m_prev = neighbour_mask[c_prev];
|
|
212
|
+
const off = ((m_prev >> 3) & 1) + ((m_prev >> 5) & 1);
|
|
213
|
+
// Contribution: tau * (-1) * (-(off)) * precon_prev^2 = tau * off * precon_prev^2
|
|
214
|
+
e -= MIC_TAU * off * p_prev_sq;
|
|
215
|
+
}
|
|
216
|
+
if (mask & 4) { // -y
|
|
217
|
+
const c_prev = c - rx;
|
|
218
|
+
const p_prev = precon[c_prev];
|
|
219
|
+
const p_prev_sq = p_prev * p_prev;
|
|
220
|
+
e -= p_prev_sq;
|
|
221
|
+
const m_prev = neighbour_mask[c_prev];
|
|
222
|
+
// Off-directions from c_prev: +x (bit 1), +z (bit 5).
|
|
223
|
+
const off = ((m_prev >> 1) & 1) + ((m_prev >> 5) & 1);
|
|
224
|
+
e -= MIC_TAU * off * p_prev_sq;
|
|
225
|
+
}
|
|
226
|
+
if (mask & 16) { // -z
|
|
227
|
+
const c_prev = c - slice;
|
|
228
|
+
const p_prev = precon[c_prev];
|
|
229
|
+
const p_prev_sq = p_prev * p_prev;
|
|
230
|
+
e -= p_prev_sq;
|
|
231
|
+
const m_prev = neighbour_mask[c_prev];
|
|
232
|
+
// Off-directions from c_prev: +x (bit 1), +y (bit 3).
|
|
233
|
+
const off = ((m_prev >> 1) & 1) + ((m_prev >> 3) & 1);
|
|
234
|
+
e -= MIC_TAU * off * p_prev_sq;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Safeguard: if e dropped below sigma*A_diag, the factorization is
|
|
238
|
+
// becoming non-SPD-friendly; fall back to plain Jacobi for this cell.
|
|
239
|
+
if (e < MIC_SIGMA * a_diag) {
|
|
240
|
+
e = a_diag;
|
|
241
|
+
}
|
|
242
|
+
precon[c] = 1 / Math.sqrt(e);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// ─── 2. r = -div - A * pressure (initial residual) ─────────────────────
|
|
246
|
+
|
|
247
|
+
for (let c = 0; c < cells; c++) {
|
|
248
|
+
const mask = neighbour_mask[c];
|
|
249
|
+
if (mask === 0) {
|
|
250
|
+
r[c] = 0;
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
let Ap = POPCOUNT_6[mask] * pressure[c];
|
|
254
|
+
if (mask & 1) Ap -= pressure[c - 1];
|
|
255
|
+
if (mask & 2) Ap -= pressure[c + 1];
|
|
256
|
+
if (mask & 4) Ap -= pressure[c - rx];
|
|
257
|
+
if (mask & 8) Ap -= pressure[c + rx];
|
|
258
|
+
if (mask & 16) Ap -= pressure[c - slice];
|
|
259
|
+
if (mask & 32) Ap -= pressure[c + slice];
|
|
260
|
+
r[c] = -divergence[c] - Ap;
|
|
261
|
+
}
|
|
262
|
+
subtract_mean_fluid(r, neighbour_mask, cells, fluid_count);
|
|
263
|
+
|
|
264
|
+
// ─── 3. z = M⁻¹ * r, s = z, sigma = r · z ───────────────────────────────
|
|
265
|
+
|
|
266
|
+
apply_preconditioner(r, z, precon, neighbour_mask, cells, rx, slice);
|
|
267
|
+
|
|
268
|
+
let sigma = 0;
|
|
269
|
+
for (let c = 0; c < cells; c++) {
|
|
270
|
+
s[c] = z[c];
|
|
271
|
+
sigma += r[c] * z[c];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
if (sigma === 0) {
|
|
275
|
+
// Initial residual was already zero (or pathological). Either way,
|
|
276
|
+
// nothing to do.
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ─── 4. PCG outer loop ──────────────────────────────────────────────────
|
|
281
|
+
|
|
282
|
+
for (let iter = 0; iter < max_iterations; iter++) {
|
|
283
|
+
|
|
284
|
+
// As = A * s, accumulating s · As in the same pass.
|
|
285
|
+
let s_dot_As = 0;
|
|
286
|
+
for (let c = 0; c < cells; c++) {
|
|
287
|
+
const mask = neighbour_mask[c];
|
|
288
|
+
if (mask === 0) {
|
|
289
|
+
As[c] = 0;
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
let val = POPCOUNT_6[mask] * s[c];
|
|
293
|
+
if (mask & 1) val -= s[c - 1];
|
|
294
|
+
if (mask & 2) val -= s[c + 1];
|
|
295
|
+
if (mask & 4) val -= s[c - rx];
|
|
296
|
+
if (mask & 8) val -= s[c + rx];
|
|
297
|
+
if (mask & 16) val -= s[c - slice];
|
|
298
|
+
if (mask & 32) val -= s[c + slice];
|
|
299
|
+
As[c] = val;
|
|
300
|
+
s_dot_As += s[c] * val;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (s_dot_As === 0) {
|
|
304
|
+
// Degenerate search direction; stop.
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
const alpha = sigma / s_dot_As;
|
|
309
|
+
|
|
310
|
+
// pressure += alpha * s
|
|
311
|
+
// r -= alpha * As
|
|
312
|
+
for (let c = 0; c < cells; c++) {
|
|
313
|
+
pressure[c] += alpha * s[c];
|
|
314
|
+
r[c] -= alpha * As[c];
|
|
315
|
+
}
|
|
316
|
+
// Project r back onto the mean-zero (range(A)) subspace. Round-off
|
|
317
|
+
// accumulates a constant component each iter; without this, alpha
|
|
318
|
+
// explodes within ~8 iters once s aligns with the null space.
|
|
319
|
+
subtract_mean_fluid(r, neighbour_mask, cells, fluid_count);
|
|
320
|
+
|
|
321
|
+
// z = M⁻¹ * r
|
|
322
|
+
apply_preconditioner(r, z, precon, neighbour_mask, cells, rx, slice);
|
|
323
|
+
|
|
324
|
+
// sigma_new = r · z
|
|
325
|
+
let sigma_new = 0;
|
|
326
|
+
for (let c = 0; c < cells; c++) {
|
|
327
|
+
sigma_new += r[c] * z[c];
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
if (sigma_new === 0) {
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const beta = sigma_new / sigma;
|
|
335
|
+
|
|
336
|
+
// s = z + beta * s
|
|
337
|
+
for (let c = 0; c < cells; c++) {
|
|
338
|
+
s[c] = z[c] + beta * s[c];
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
sigma = sigma_new;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* Apply the MIC(0) preconditioner: solve M · z = r where M = L · Lᵀ.
|
|
347
|
+
*
|
|
348
|
+
* Two sequential sweeps:
|
|
349
|
+
* - forward (L · y = r): walk fluid cells in lex order, using backward
|
|
350
|
+
* fluid neighbours' already-computed y values.
|
|
351
|
+
* - backward (Lᵀ · z = y): walk in reverse lex order, using forward
|
|
352
|
+
* fluid neighbours' already-computed z values.
|
|
353
|
+
*
|
|
354
|
+
* Both write into `z` in place; the forward pass stores y in z, the backward
|
|
355
|
+
* pass overwrites with the final z. Solid cells stay at 0 throughout.
|
|
356
|
+
*
|
|
357
|
+
* For our normalized Laplacian (A = -1 off-diagonal, popcount diagonal), the
|
|
358
|
+
* L factor has L[c, c-1] = -precon[c-1] etc., L[c, c] = 1/precon[c], so each
|
|
359
|
+
* triangular solve degenerates to ~4 floating-point ops per cell.
|
|
360
|
+
*
|
|
361
|
+
* @param {Float32Array} r
|
|
362
|
+
* @param {Float32Array} z
|
|
363
|
+
* @param {Float32Array} precon
|
|
364
|
+
* @param {Uint8Array} mask_array
|
|
365
|
+
* @param {number} cells
|
|
366
|
+
* @param {number} rx
|
|
367
|
+
* @param {number} slice
|
|
368
|
+
*/
|
|
369
|
+
/**
|
|
370
|
+
* Subtract the mean (over fluid cells) from a buffer in place. Used to project
|
|
371
|
+
* a vector onto range(A) = mean-zero subspace; required for CG to converge on
|
|
372
|
+
* a system with a non-trivial null space (pure Neumann pressure Poisson).
|
|
373
|
+
*
|
|
374
|
+
* @param {Float32Array} v
|
|
375
|
+
* @param {Uint8Array} mask_array
|
|
376
|
+
* @param {number} cells
|
|
377
|
+
* @param {number} fluid_count
|
|
378
|
+
*/
|
|
379
|
+
function subtract_mean_fluid(v, mask_array, cells, fluid_count) {
|
|
380
|
+
let sum = 0;
|
|
381
|
+
for (let c = 0; c < cells; c++) {
|
|
382
|
+
if (mask_array[c] !== 0) sum += v[c];
|
|
383
|
+
}
|
|
384
|
+
const mean = sum / fluid_count;
|
|
385
|
+
for (let c = 0; c < cells; c++) {
|
|
386
|
+
if (mask_array[c] !== 0) v[c] -= mean;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function apply_preconditioner(r, z, precon, mask_array, cells, rx, slice) {
|
|
391
|
+
// Forward solve L · y = r. Store y in z (we won't read z[c'] for c' > c).
|
|
392
|
+
for (let c = 0; c < cells; c++) {
|
|
393
|
+
const mask = mask_array[c];
|
|
394
|
+
if (mask === 0) {
|
|
395
|
+
z[c] = 0;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
let t = r[c];
|
|
399
|
+
// L[c, c-1] = -precon[c-1] when -x neighbour fluid → subtracting L·y is
|
|
400
|
+
// adding precon[c-1] * y[c-1].
|
|
401
|
+
if (mask & 1) t += precon[c - 1] * z[c - 1];
|
|
402
|
+
if (mask & 4) t += precon[c - rx] * z[c - rx];
|
|
403
|
+
if (mask & 16) t += precon[c - slice] * z[c - slice];
|
|
404
|
+
// L[c, c] = 1 / precon[c] → dividing by it is multiplying by precon[c].
|
|
405
|
+
z[c] = t * precon[c];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Backward solve Lᵀ · z = y, in place. When we read z[c+1], z[c+rx],
|
|
409
|
+
// z[c+slice], those were written in this same backward pass (higher
|
|
410
|
+
// indices, processed first in reverse).
|
|
411
|
+
for (let c = cells - 1; c >= 0; c--) {
|
|
412
|
+
const mask = mask_array[c];
|
|
413
|
+
if (mask === 0) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
let t = z[c]; // = y[c] from forward pass
|
|
417
|
+
// L[c+1, c] = -precon[c] when c+1's -x neighbour (= c) is fluid, which
|
|
418
|
+
// is equivalent to "c's +x neighbour (= c+1) is fluid", i.e. mask & 2.
|
|
419
|
+
if (mask & 2) t += precon[c] * z[c + 1];
|
|
420
|
+
if (mask & 8) t += precon[c] * z[c + rx];
|
|
421
|
+
if (mask & 32) t += precon[c] * z[c + slice];
|
|
422
|
+
z[c] = t * precon[c];
|
|
423
|
+
}
|
|
424
|
+
}
|