@woosh/meep-engine 2.156.0 → 2.157.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/README.md +1 -3
- package/editor/view/ecs/components/common/AutoCanvasView.js +100 -53
- package/editor/view/ecs/components/common/TextController.js +59 -0
- package/editor/view/node-graph/NodeGraphCamera.js +90 -0
- package/editor/view/node-graph/NodeGraphEditorView.js +121 -22
- package/editor/view/node-graph/NodeGraphSelection.js +89 -0
- package/editor/view/node-graph/NodeGraphView.js +669 -453
- package/editor/view/node-graph/NodeView.js +211 -135
- package/editor/view/node-graph/actions/ConnectionCreateAction.js +53 -0
- package/editor/view/node-graph/actions/ConnectionDeleteAction.js +36 -0
- package/editor/view/node-graph/actions/NodeDeleteAction.js +88 -0
- package/editor/view/node-graph/actions/NodeParameterSetAction.js +52 -0
- package/editor/view/node-graph/actions/NodesMoveAction.js +41 -0
- package/editor/view/node-graph/actions/SelectionSetAction.js +60 -0
- package/editor/view/node-graph/connection_wire_geometry.js +107 -0
- package/package.json +1 -1
- package/samples/generation/SampleGenerator0.js +8 -1
- package/src/core/binary/reinterpret_float32_as_uint32.d.ts +7 -0
- package/src/core/binary/reinterpret_float32_as_uint32.d.ts.map +1 -0
- package/src/core/binary/reinterpret_float32_as_uint32.js +13 -0
- package/src/core/binary/reinterpret_uint32_as_float32.d.ts +7 -0
- package/src/core/binary/reinterpret_uint32_as_float32.d.ts.map +1 -0
- package/src/core/binary/reinterpret_uint32_as_float32.js +14 -0
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_for_geometry_incremental.js +1 -3
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.d.ts +12 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.d.ts.map +1 -0
- package/src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_sphere.js +92 -0
- package/src/core/bvh8/BVH8.d.ts +127 -0
- package/src/core/bvh8/BVH8.d.ts.map +1 -0
- package/src/core/bvh8/BVH8.js +436 -0
- package/src/core/bvh8/NOTES.md +63 -0
- package/src/core/bvh8/build/BVH8Converter.d.ts +59 -0
- package/src/core/bvh8/build/BVH8Converter.d.ts.map +1 -0
- package/src/core/bvh8/build/BVH8Converter.js +588 -0
- package/src/core/bvh8/build/NodeProxy.d.ts +66 -0
- package/src/core/bvh8/build/NodeProxy.d.ts.map +1 -0
- package/src/core/bvh8/build/NodeProxy.js +308 -0
- package/src/core/bvh8/build/TriangleCluster.d.ts +29 -0
- package/src/core/bvh8/build/TriangleCluster.d.ts.map +1 -0
- package/src/core/bvh8/build/TriangleCluster.js +123 -0
- package/src/core/bvh8/build/aabb3_compute_merge_cost.d.ts +8 -0
- package/src/core/bvh8/build/aabb3_compute_merge_cost.d.ts.map +1 -0
- package/src/core/bvh8/build/aabb3_compute_merge_cost.js +29 -0
- package/src/core/bvh8/build/aabb3_from_triangle_by_index.d.ts +10 -0
- package/src/core/bvh8/build/aabb3_from_triangle_by_index.d.ts.map +1 -0
- package/src/core/bvh8/build/aabb3_from_triangle_by_index.js +18 -0
- package/src/core/bvh8/build/bvh8_build_for_geometry.d.ts +10 -0
- package/src/core/bvh8/build/bvh8_build_for_geometry.d.ts.map +1 -0
- package/src/core/bvh8/build/bvh8_build_for_geometry.js +303 -0
- package/src/core/bvh8/build/bvh8_from_proxy.d.ts +9 -0
- package/src/core/bvh8/build/bvh8_from_proxy.d.ts.map +1 -0
- package/src/core/bvh8/build/bvh8_from_proxy.js +256 -0
- package/src/core/bvh8/build/byte.d.ts +7 -0
- package/src/core/bvh8/build/byte.d.ts.map +1 -0
- package/src/core/bvh8/build/byte.js +10 -0
- package/src/core/bvh8/build/encode_bounds_e.d.ts +9 -0
- package/src/core/bvh8/build/encode_bounds_e.d.ts.map +1 -0
- package/src/core/bvh8/build/encode_bounds_e.js +12 -0
- package/src/core/bvh8/bvh8_convert_to_dot.d.ts +11 -0
- package/src/core/bvh8/bvh8_convert_to_dot.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_convert_to_dot.js +133 -0
- package/src/core/bvh8/bvh8_count_primitives.d.ts +22 -0
- package/src/core/bvh8/bvh8_count_primitives.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_count_primitives.js +98 -0
- package/src/core/bvh8/bvh8_geometry_validate.d.ts +16 -0
- package/src/core/bvh8/bvh8_geometry_validate.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_geometry_validate.js +149 -0
- package/src/core/bvh8/bvh8_geometry_validate_indirect.d.ts +16 -0
- package/src/core/bvh8/bvh8_geometry_validate_indirect.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_geometry_validate_indirect.js +177 -0
- package/src/core/bvh8/bvh8_get_node_bounds.d.ts +9 -0
- package/src/core/bvh8/bvh8_get_node_bounds.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_get_node_bounds.js +35 -0
- package/src/core/bvh8/bvh8_get_node_child_bounds.d.ts +10 -0
- package/src/core/bvh8/bvh8_get_node_child_bounds.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_get_node_child_bounds.js +53 -0
- package/src/core/bvh8/bvh8_node_child_surface_area.d.ts +9 -0
- package/src/core/bvh8/bvh8_node_child_surface_area.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_node_child_surface_area.js +18 -0
- package/src/core/bvh8/bvh8_node_count_triangles.d.ts +8 -0
- package/src/core/bvh8/bvh8_node_count_triangles.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_node_count_triangles.js +28 -0
- package/src/core/bvh8/bvh8_quality.d.ts +8 -0
- package/src/core/bvh8/bvh8_quality.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_quality.js +73 -0
- package/src/core/bvh8/bvh8_validate_structure.d.ts +15 -0
- package/src/core/bvh8/bvh8_validate_structure.d.ts.map +1 -0
- package/src/core/bvh8/bvh8_validate_structure.js +87 -0
- package/src/core/collection/Uint32MinHeap.d.ts +56 -0
- package/src/core/collection/Uint32MinHeap.d.ts.map +1 -0
- package/src/core/collection/Uint32MinHeap.js +109 -0
- package/src/core/collection/list/FilteredListProjection.js +1 -1
- package/src/{engine/physics/island → core/collection/union-find}/union_find.d.ts +8 -5
- package/src/core/collection/union-find/union_find.d.ts.map +1 -0
- package/src/{engine/physics/island → core/collection/union-find}/union_find.js +8 -5
- package/src/core/dom/isImageBitmap.d.ts +7 -0
- package/src/core/dom/isImageBitmap.d.ts.map +1 -0
- package/src/core/dom/isImageBitmap.js +12 -0
- package/src/core/function/frameThrottle.d.ts +8 -0
- package/src/core/function/frameThrottle.d.ts.map +1 -0
- package/src/core/function/frameThrottle.js +23 -0
- package/src/{engine/physics/narrowphase/clip_against_axis_uv.d.ts → core/geom/2d/polygon/polygon2_clip_axis_halfplane.d.ts} +3 -3
- package/src/core/geom/2d/polygon/polygon2_clip_axis_halfplane.d.ts.map +1 -0
- package/src/{engine/physics/narrowphase/clip_against_axis_uv.js → core/geom/2d/polygon/polygon2_clip_axis_halfplane.js} +51 -51
- package/src/{engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts → core/geom/3d/aabb/aabb3_transform_oriented_inverse.d.ts} +9 -7
- package/src/core/geom/3d/aabb/aabb3_transform_oriented_inverse.d.ts.map +1 -0
- package/src/{engine/physics/narrowphase/decomposition/aabb_world_to_local.js → core/geom/3d/aabb/aabb3_transform_oriented_inverse.js} +9 -7
- package/src/core/geom/3d/aabb/compute_triangle_group_aabb3.d.ts +12 -0
- package/src/core/geom/3d/aabb/compute_triangle_group_aabb3.d.ts.map +1 -0
- package/src/core/geom/3d/aabb/compute_triangle_group_aabb3.js +46 -0
- package/src/core/geom/3d/box/box3_projected_half_extent.d.ts +28 -0
- package/src/core/geom/3d/box/box3_projected_half_extent.d.ts.map +1 -0
- package/src/core/geom/3d/box/box3_projected_half_extent.js +35 -0
- package/src/core/geom/3d/frustum/read_cluster_frustum_corners.js +1 -1
- package/src/core/geom/3d/frustum/read_frustum_corner.d.ts +9 -0
- package/src/core/geom/3d/frustum/read_frustum_corner.d.ts.map +1 -0
- package/src/core/geom/3d/frustum/read_frustum_corner.js +14 -0
- package/src/core/geom/3d/gjk/gjk.d.ts.map +1 -0
- package/src/{engine/physics → core/geom/3d}/gjk/gjk.js +430 -372
- package/src/{engine/physics → core/geom/3d}/gjk/gjk_epa_penetration.d.ts +8 -5
- package/src/core/geom/3d/gjk/gjk_epa_penetration.d.ts.map +1 -0
- package/src/{engine/physics → core/geom/3d}/gjk/gjk_epa_penetration.js +520 -544
- package/src/{engine/physics → core/geom/3d}/gjk/minkowski_support.d.ts +5 -4
- package/src/core/geom/3d/gjk/minkowski_support.d.ts.map +1 -0
- package/src/{engine/physics → core/geom/3d}/gjk/minkowski_support.js +71 -70
- package/src/{engine/physics → core/geom/3d}/gjk/mpr.d.ts +3 -3
- package/src/core/geom/3d/gjk/mpr.d.ts.map +1 -0
- package/src/{engine/physics → core/geom/3d}/gjk/mpr.js +368 -362
- package/src/{engine/physics/integration/quat_integrate.d.ts → core/geom/3d/quaternion/quat3_integrate.d.ts} +2 -2
- package/src/core/geom/3d/quaternion/quat3_integrate.d.ts.map +1 -0
- package/src/{engine/physics/integration/quat_integrate.js → core/geom/3d/quaternion/quat3_integrate.js} +1 -1
- package/src/{engine/physics/narrowphase/PosedShape.d.ts → core/geom/3d/shape/PosedShape3D.d.ts} +9 -8
- package/src/{engine/physics/narrowphase/PosedShape.d.ts.map → core/geom/3d/shape/PosedShape3D.d.ts.map} +1 -1
- package/src/{engine/physics/narrowphase/PosedShape.js → core/geom/3d/shape/PosedShape3D.js} +10 -9
- package/src/core/geom/3d/shape/TransformedShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/TransformedShape3D.js +15 -11
- package/src/core/geom/vec3/v3_quat3_apply_inverse.d.ts +1 -1
- package/src/core/geom/vec3/v3_quat3_apply_inverse.js +1 -1
- package/src/core/math/complex/complex_add.d.ts +1 -1
- package/src/core/math/complex/complex_add.d.ts.map +1 -1
- package/src/core/math/complex/complex_add.js +12 -3
- package/src/core/math/complex/complex_div.d.ts +1 -1
- package/src/core/math/complex/complex_div.d.ts.map +1 -1
- package/src/core/math/complex/complex_div.js +11 -4
- package/src/core/math/complex/complex_mul.d.ts +1 -1
- package/src/core/math/complex/complex_mul.d.ts.map +1 -1
- package/src/core/math/complex/complex_mul.js +10 -3
- package/src/core/math/complex/complex_sub.d.ts +1 -1
- package/src/core/math/complex/complex_sub.d.ts.map +1 -1
- package/src/core/math/complex/complex_sub.js +12 -3
- package/src/{engine/physics/fluid/solver/optimal_sor_omega.d.ts → core/math/linalg/sor_optimal_omega.d.ts} +4 -3
- package/src/core/math/linalg/sor_optimal_omega.d.ts.map +1 -0
- package/src/{engine/physics/fluid/solver/optimal_sor_omega.js → core/math/linalg/sor_optimal_omega.js} +4 -3
- package/src/core/math/lookup/ParameterLookupTable.d.ts +123 -0
- package/src/core/math/lookup/ParameterLookupTable.d.ts.map +1 -0
- package/src/core/math/lookup/ParameterLookupTable.js +495 -0
- package/src/core/math/lookup/ParameterLookupTableFlags.d.ts +5 -0
- package/src/core/math/lookup/ParameterLookupTableFlags.d.ts.map +1 -0
- package/src/core/math/lookup/ParameterLookupTableFlags.js +6 -0
- package/src/core/math/physics/kinematics/computeInterceptPoint.d.ts.map +1 -0
- package/src/{engine/physics → core/math/physics/kinematics}/computeInterceptPoint.js +79 -79
- package/src/core/math/physics/mie/ri_air.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_air.js +1 -3
- package/src/core/math/physics/mie/ri_ammonium_sulfate.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_ammonium_sulfate.js +1 -3
- package/src/core/math/physics/mie/ri_brine.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_brine.js +1 -3
- package/src/core/math/physics/mie/ri_dust.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_dust.js +1 -3
- package/src/core/math/physics/mie/ri_pollen.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_pollen.js +1 -3
- package/src/core/math/physics/mie/ri_smoke.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_smoke.js +1 -3
- package/src/core/math/physics/mie/ri_soot.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_soot.js +1 -3
- package/src/core/math/physics/mie/ri_water.d.ts.map +1 -1
- package/src/core/math/physics/mie/ri_water.js +1 -3
- package/src/core/math/random/random_pick_weighted_index.d.ts +10 -0
- package/src/core/math/random/random_pick_weighted_index.d.ts.map +1 -0
- package/src/core/math/random/random_pick_weighted_index.js +26 -0
- package/src/core/model/node-graph/NodeGraph.d.ts +9 -0
- package/src/core/model/node-graph/NodeGraph.d.ts.map +1 -1
- package/src/core/model/node-graph/NodeGraph.js +38 -0
- package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts +23 -0
- package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/NodeGraphVisualData.js +54 -0
- package/src/core/path/convertPathToURL.d.ts +9 -0
- package/src/core/path/convertPathToURL.d.ts.map +1 -0
- package/src/core/path/convertPathToURL.js +107 -0
- package/src/core/process/worker/WorkerBuilder.js +1 -1
- package/src/core/process/worker/extractTransferables.js +1 -1
- package/src/engine/animation/curve/draw/build_tangent_editor.d.ts.map +1 -1
- package/src/engine/animation/curve/draw/build_tangent_editor.js +8 -1
- package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.d.ts.map +1 -1
- package/src/engine/animation/curve/editor/createKeyframeDraggableAspect.js +11 -5
- package/src/engine/asset/Asset.d.ts.map +1 -1
- package/src/engine/asset/Asset.js +16 -6
- package/src/engine/asset/AssetManager.d.ts +61 -52
- package/src/engine/asset/AssetManager.d.ts.map +1 -1
- package/src/engine/asset/AssetManager.js +1411 -1045
- package/src/engine/asset/AssetRequest.d.ts +1 -1
- package/src/engine/asset/AssetRequest.d.ts.map +1 -1
- package/src/engine/asset/AssetRequest.js +1 -1
- package/src/engine/asset/AssetRequestScope.d.ts.map +1 -1
- package/src/engine/asset/AssetRequestScope.js +7 -0
- package/src/engine/asset/PendingAsset.d.ts +32 -1
- package/src/engine/asset/PendingAsset.d.ts.map +1 -1
- package/src/engine/asset/PendingAsset.js +108 -61
- package/src/engine/asset/loaders/ArrayBufferLoader.js +2 -2
- package/src/engine/asset/loaders/AssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/AssetLoader.js +19 -2
- package/src/engine/asset/loaders/GLTFAssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/GLTFAssetLoader.js +123 -114
- package/src/engine/asset/loaders/JavascriptAssetLoader.d.ts +1 -1
- package/src/engine/asset/loaders/JavascriptAssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/JavascriptAssetLoader.js +31 -47
- package/src/engine/asset/loaders/JsonAssetLoader.js +1 -1
- package/src/engine/asset/loaders/SVGAssetLoader.js +2 -2
- package/src/engine/asset/loaders/SoundAssetLoader.js +1 -1
- package/src/engine/asset/loaders/TextAssetLoader.js +2 -2
- package/src/{core → engine/asset/loaders}/font/FontAsset.d.ts +1 -1
- package/src/engine/asset/loaders/font/FontAsset.d.ts.map +1 -0
- package/src/{core → engine/asset/loaders}/font/FontAsset.js +21 -21
- package/src/{core → engine/asset/loaders}/font/FontAssetLoader.d.ts +1 -1
- package/src/engine/asset/loaders/font/FontAssetLoader.d.ts.map +1 -0
- package/src/{core → engine/asset/loaders}/font/FontAssetLoader.js +20 -20
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts +1 -1
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/image/ImageRGBADataLoader.js +11 -20
- package/src/engine/asset/loaders/texture/TextureAssetLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/texture/TextureAssetLoader.js +8 -2
- package/src/engine/asset/preloader/AssetPreloader.js +1 -1
- package/src/engine/ecs/sockets/serialization/AttachmentSocketsAssetLoader.d.ts +1 -1
- package/src/engine/ecs/sockets/serialization/AttachmentSocketsAssetLoader.d.ts.map +1 -1
- package/src/engine/ecs/sockets/serialization/AttachmentSocketsAssetLoader.js +19 -22
- package/src/engine/graphics/FrameThrottle.d.ts +1 -7
- package/src/engine/graphics/FrameThrottle.d.ts.map +1 -1
- package/src/engine/graphics/FrameThrottle.js +2 -24
- package/src/{core/geom/3d/shape/util → engine/graphics/debug}/shape_to_visual_entity.d.ts +1 -1
- package/src/engine/graphics/debug/shape_to_visual_entity.d.ts.map +1 -0
- package/src/{core/geom/3d/shape/util → engine/graphics/debug}/shape_to_visual_entity.js +159 -159
- package/src/{core/geom/3d/tetrahedra → engine/graphics/debug}/visualize_tetrahedral_mesh.d.ts +1 -1
- package/src/engine/graphics/debug/visualize_tetrahedral_mesh.d.ts.map +1 -0
- package/src/{core/geom/3d/tetrahedra → engine/graphics/debug}/visualize_tetrahedral_mesh.js +46 -46
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionAssetLoader.d.ts +1 -1
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionAssetLoader.d.ts.map +1 -1
- package/src/engine/graphics/ecs/animation/animator/graph/definition/serialization/AnimationGraphDefinitionAssetLoader.js +22 -32
- package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/emitter/serde/ParameterLookupTableSerializationAdapter.js +2 -76
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTable.js +2 -427
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTableFlags.d.ts +1 -4
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTableFlags.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/engine/parameter/ParameterLookupTableFlags.js +2 -6
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/render/forward_plus/read_frustum_corner.d.ts +1 -8
- package/src/engine/graphics/render/forward_plus/read_frustum_corner.d.ts.map +1 -1
- package/src/engine/graphics/render/forward_plus/read_frustum_corner.js +2 -14
- package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.d.ts +1 -11
- package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.d.ts.map +1 -1
- package/src/engine/graphics/sh3/path_tracer/geometry/compute_triangle_group_aabb3.js +2 -46
- package/src/engine/graphics/sh3/prototypeSH3Probe.js +1 -1
- package/src/engine/graphics/texture/3d/scs3d_sample_linear3.d.ts +27 -0
- package/src/engine/graphics/texture/3d/scs3d_sample_linear3.d.ts.map +1 -0
- package/src/engine/graphics/texture/3d/scs3d_sample_linear3.js +81 -0
- package/src/engine/graphics/texture/isImageBitmap.d.ts +1 -6
- package/src/engine/graphics/texture/isImageBitmap.d.ts.map +1 -1
- package/src/engine/graphics/texture/isImageBitmap.js +2 -12
- package/src/{core/process/action → engine/intelligence/behavior/util}/AsynchronousDelayAction.d.ts +2 -2
- package/src/engine/intelligence/behavior/util/AsynchronousDelayAction.d.ts.map +1 -0
- package/src/{core/process/action → engine/intelligence/behavior/util}/AsynchronousDelayAction.js +55 -55
- package/src/engine/network/NetworkSession.d.ts +12 -1
- package/src/engine/network/NetworkSession.d.ts.map +1 -1
- package/src/engine/network/NetworkSession.js +52 -1
- package/src/engine/network/README.md +45 -0
- package/src/engine/network/convertPathToURL.d.ts +1 -8
- package/src/engine/network/convertPathToURL.d.ts.map +1 -1
- package/src/engine/network/convertPathToURL.js +2 -107
- package/src/engine/network/core/quantize/quantize_float.d.ts.map +1 -1
- package/src/engine/network/core/quantize/quantize_float.js +7 -0
- package/src/engine/network/core/quantize/quantize_position.d.ts.map +1 -1
- package/src/engine/network/core/quantize/quantize_position.js +12 -1
- package/src/engine/network/orchestrator/NetworkPeer.d.ts.map +1 -1
- package/src/engine/network/orchestrator/NetworkPeer.js +15 -1
- package/src/engine/network/replication/Replicator.d.ts +8 -0
- package/src/engine/network/replication/Replicator.d.ts.map +1 -1
- package/src/engine/network/replication/Replicator.js +48 -0
- package/src/engine/network/transport/Channel.d.ts.map +1 -1
- package/src/engine/network/transport/Channel.js +46 -12
- package/src/engine/network/transport/ReliableCommandPipeline.d.ts +16 -0
- package/src/engine/network/transport/ReliableCommandPipeline.d.ts.map +1 -1
- package/src/engine/network/transport/ReliableCommandPipeline.js +29 -0
- package/src/engine/network/transport/adapters/NodeUDPTransport.d.ts.map +1 -1
- package/src/engine/network/transport/adapters/NodeUDPTransport.js +7 -1
- package/src/engine/network/transport/fragments/packet_size.d.ts +5 -5
- package/src/engine/network/transport/fragments/packet_size.d.ts.map +1 -1
- package/src/engine/network/transport/fragments/packet_size.js +5 -5
- package/src/engine/physics/BULLET_REVIEW.md +1 -1
- package/src/engine/physics/JOLT_REVIEW.md +2 -2
- package/src/engine/physics/PLAN.md +1094 -945
- package/src/engine/physics/RAPIER_REVIEW.md +2 -2
- package/src/engine/physics/body/BodyStorage.d.ts +2 -12
- package/src/engine/physics/body/BodyStorage.d.ts.map +1 -1
- package/src/engine/physics/body/BodyStorage.js +406 -452
- package/src/engine/physics/body/SolverBodyState.d.ts.map +1 -1
- package/src/engine/physics/body/SolverBodyState.js +12 -3
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts +28 -3
- package/src/engine/physics/broadphase/compute_fat_world_aabb.d.ts.map +1 -1
- package/src/engine/physics/broadphase/compute_fat_world_aabb.js +60 -24
- package/src/engine/physics/broadphase/generate_pairs.d.ts +9 -5
- package/src/engine/physics/broadphase/generate_pairs.d.ts.map +1 -1
- package/src/engine/physics/broadphase/generate_pairs.js +52 -37
- package/src/engine/physics/ccd/linear_sweep.d.ts +15 -5
- package/src/engine/physics/ccd/linear_sweep.d.ts.map +1 -1
- package/src/engine/physics/ccd/linear_sweep.js +122 -40
- package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
- package/src/engine/physics/constraint/solve_constraints.js +830 -805
- package/src/engine/physics/contact/ManifoldStore.d.ts +91 -16
- package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
- package/src/engine/physics/contact/ManifoldStore.js +204 -60
- package/src/engine/physics/ecs/BodyKind.d.ts +7 -3
- package/src/engine/physics/ecs/BodyKind.d.ts.map +1 -1
- package/src/engine/physics/ecs/BodyKind.js +29 -25
- package/src/engine/physics/ecs/Collider.d.ts +7 -0
- package/src/engine/physics/ecs/Collider.d.ts.map +1 -1
- package/src/engine/physics/ecs/Collider.js +7 -0
- package/src/engine/physics/ecs/ColliderSerializationAdapter.js +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +110 -6
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +467 -45
- package/src/engine/physics/ecs/RigidBody.d.ts +20 -5
- package/src/engine/physics/ecs/RigidBody.d.ts.map +1 -1
- package/src/engine/physics/ecs/RigidBody.js +307 -286
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts +6 -3
- package/src/engine/physics/ecs/RigidBodyFlags.d.ts.map +1 -1
- package/src/engine/physics/ecs/RigidBodyFlags.js +31 -28
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts +12 -4
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.d.ts.map +1 -1
- package/src/engine/physics/ecs/RigidBodySerializationAdapter.js +19 -5
- package/src/engine/physics/ecs/RigidBodySerializationUpgrader_0_1.d.ts +10 -0
- package/src/engine/physics/ecs/RigidBodySerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/engine/physics/ecs/RigidBodySerializationUpgrader_0_1.js +37 -0
- package/src/engine/physics/ecs/find_non_finite_physics_state.d.ts +28 -0
- package/src/engine/physics/ecs/find_non_finite_physics_state.d.ts.map +1 -0
- package/src/engine/physics/ecs/find_non_finite_physics_state.js +76 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts +11 -0
- package/src/engine/physics/events/ContactEventBuffer.d.ts.map +1 -1
- package/src/engine/physics/events/ContactEventBuffer.js +40 -0
- package/src/engine/physics/events/diff_manifolds.d.ts +30 -13
- package/src/engine/physics/events/diff_manifolds.d.ts.map +1 -1
- package/src/engine/physics/events/diff_manifolds.js +87 -50
- package/src/engine/physics/fluid/FluidField.d.ts +45 -17
- package/src/engine/physics/fluid/FluidField.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidField.js +53 -23
- package/src/engine/physics/fluid/FluidSimulator.d.ts +141 -5
- package/src/engine/physics/fluid/FluidSimulator.d.ts.map +1 -1
- package/src/engine/physics/fluid/FluidSimulator.js +336 -43
- package/src/engine/physics/fluid/REVIEW_02_PLAN.md +114 -0
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts +4 -3
- package/src/engine/physics/fluid/ecs/FluidComponent.d.ts.map +1 -1
- package/src/engine/physics/fluid/ecs/FluidComponent.js +4 -3
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
- package/src/engine/physics/fluid/effector/AmbientWindFluidEffector.d.ts +41 -0
- package/src/engine/physics/fluid/effector/AmbientWindFluidEffector.d.ts.map +1 -0
- package/src/engine/physics/fluid/effector/AmbientWindFluidEffector.js +124 -0
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts +27 -8
- package/src/engine/physics/fluid/effector/WakeFluidEffector.d.ts.map +1 -1
- package/src/engine/physics/fluid/effector/WakeFluidEffector.js +67 -18
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_scalar.d.ts +42 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_scalar.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_scalar.js +136 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_velocity.d.ts +37 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_velocity.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_maccormack_velocity.js +169 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_sl_velocity.d.ts +36 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_sl_velocity.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_advect_sl_velocity.js +100 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_advection_forward.d.ts +6 -0
- 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 +6 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_diffusion.d.ts +7 -2
- 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 +17 -12
- package/src/engine/physics/fluid/solver/v3_grid_apply_vorticity_confinement.d.ts +42 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_vorticity_confinement.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_apply_vorticity_confinement.js +131 -0
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts +32 -22
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_compute_solid_neighbour_mask.js +43 -26
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_constant.d.ts +31 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_constant.d.ts.map +1 -0
- package/src/engine/physics/fluid/solver/v3_grid_patch_edges_constant.js +77 -0
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts +26 -19
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure.js +46 -42
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts +38 -10
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_solve_pressure_pcg.js +158 -75
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts +22 -17
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.d.ts.map +1 -1
- package/src/engine/physics/fluid/solver/v3_grid_subtract_pressure_gradient.js +108 -96
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts +30 -1
- package/src/engine/physics/inertia/world_inverse_inertia.d.ts.map +1 -1
- package/src/engine/physics/inertia/world_inverse_inertia.js +160 -116
- package/src/engine/physics/integration/integrate_position.js +97 -97
- package/src/engine/physics/island/IslandBuilder.d.ts +49 -8
- package/src/engine/physics/island/IslandBuilder.d.ts.map +1 -1
- package/src/engine/physics/island/IslandBuilder.js +93 -14
- package/src/engine/physics/narrowphase/box_box_manifold.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/box_box_manifold.js +683 -673
- package/src/engine/physics/narrowphase/box_triangle_contact.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/box_triangle_contact.js +899 -749
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts +27 -0
- package/src/engine/physics/narrowphase/capsule_contacts.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/capsule_contacts.js +624 -459
- package/src/engine/physics/narrowphase/capsule_triangle_contact.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/capsule_triangle_contact.js +58 -38
- package/src/engine/physics/narrowphase/compute_penetration.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/compute_penetration.js +369 -325
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts +3 -1
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/convex_convex_manifold.js +568 -422
- package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts +6 -3
- package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/decomposition/heightmap_enumerate_triangles.js +66 -10
- package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts +4 -1
- package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/decomposition/mesh_enumerate_triangles.js +97 -94
- package/src/engine/physics/narrowphase/mesh_mesh_tet_manifold.js +117 -117
- package/src/engine/physics/narrowphase/narrowphase_step.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/narrowphase_step.js +1738 -1739
- package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts +14 -7
- package/src/engine/physics/narrowphase/reduce_manifold_contacts.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/reduce_manifold_contacts.js +74 -69
- package/src/engine/physics/persistence/solver_caches.d.ts +20 -0
- package/src/engine/physics/persistence/solver_caches.d.ts.map +1 -0
- package/src/engine/physics/persistence/solver_caches.js +309 -0
- package/src/engine/physics/queries/overlap_shape.d.ts.map +1 -1
- package/src/engine/physics/queries/overlap_shape.js +187 -184
- package/src/engine/physics/queries/raycast.d.ts +3 -2
- package/src/engine/physics/queries/raycast.d.ts.map +1 -1
- package/src/engine/physics/queries/raycast.js +37 -11
- package/src/engine/physics/queries/shape_cast.d.ts +18 -5
- package/src/engine/physics/queries/shape_cast.d.ts.map +1 -1
- package/src/engine/physics/queries/shape_cast.js +417 -393
- package/src/engine/physics/solver/solve_contacts.d.ts +22 -6
- package/src/engine/physics/solver/solve_contacts.d.ts.map +1 -1
- package/src/engine/physics/solver/solve_contacts.js +1482 -1338
- package/src/engine/physics/vehicle/RaycastVehicle.d.ts.map +1 -1
- package/src/engine/physics/vehicle/RaycastVehicle.js +344 -339
- package/src/engine/ui/DraggableAspect.d.ts +12 -3
- package/src/engine/ui/DraggableAspect.d.ts.map +1 -1
- package/src/engine/ui/DraggableAspect.js +115 -83
- package/src/generation/COORDINATES.md +54 -0
- package/src/generation/GridTaskGroup.js +2 -2
- package/src/generation/REVIEW_01_ACTION_PLAN.md +628 -0
- package/src/generation/automata/CaveGeneratorCellularAutomata.d.ts +9 -1
- package/src/generation/automata/CaveGeneratorCellularAutomata.d.ts.map +1 -1
- package/src/generation/automata/CaveGeneratorCellularAutomata.js +79 -59
- package/src/generation/automata/CellularAutomata.d.ts +6 -3
- package/src/generation/automata/CellularAutomata.d.ts.map +1 -1
- package/src/generation/automata/CellularAutomata.js +22 -19
- package/src/generation/filtering/CellFilter.d.ts +17 -0
- package/src/generation/filtering/CellFilter.d.ts.map +1 -1
- package/src/generation/filtering/CellFilter.js +117 -77
- package/src/generation/filtering/CellFilterCellMatcher.d.ts.map +1 -1
- package/src/generation/filtering/CellFilterCellMatcher.js +2 -0
- package/src/generation/filtering/boolean/CellFilterLiteralBoolean.d.ts +5 -0
- package/src/generation/filtering/boolean/CellFilterLiteralBoolean.d.ts.map +1 -1
- package/src/generation/filtering/boolean/CellFilterLiteralBoolean.js +15 -0
- package/src/generation/filtering/core/CellFilterBinaryOperation.d.ts +0 -1
- package/src/generation/filtering/core/CellFilterBinaryOperation.d.ts.map +1 -1
- package/src/generation/filtering/core/CellFilterBinaryOperation.js +37 -50
- package/src/generation/filtering/core/CellFilterOperationTertiary.d.ts +0 -1
- package/src/generation/filtering/core/CellFilterOperationTertiary.d.ts.map +1 -1
- package/src/generation/filtering/core/CellFilterOperationTertiary.js +43 -59
- package/src/generation/filtering/core/CellFilterUnaryOperation.d.ts +0 -1
- package/src/generation/filtering/core/CellFilterUnaryOperation.d.ts.map +1 -1
- package/src/generation/filtering/core/CellFilterUnaryOperation.js +29 -33
- package/src/generation/filtering/numeric/CellFilterCache.d.ts +1 -0
- package/src/generation/filtering/numeric/CellFilterCache.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.d.ts +3 -2
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterAngleToNormal.js +9 -35
- package/src/generation/filtering/numeric/complex/CellFilterCurvature.d.ts +0 -1
- package/src/generation/filtering/numeric/complex/CellFilterCurvature.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterCurvature.js +19 -43
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.d.ts +0 -1
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterFXAA.js +2 -6
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +9 -12
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +2 -1
- package/src/generation/filtering/numeric/complex/CellFilterSobel.d.ts +0 -1
- package/src/generation/filtering/numeric/complex/CellFilterSobel.d.ts.map +1 -1
- package/src/generation/filtering/numeric/complex/CellFilterSobel.js +2 -6
- package/src/generation/filtering/numeric/math/CellFilterInverseLerp.d.ts +5 -4
- package/src/generation/filtering/numeric/math/CellFilterInverseLerp.d.ts.map +1 -1
- package/src/generation/filtering/numeric/math/CellFilterInverseLerp.js +5 -4
- package/src/generation/filtering/numeric/process/computeFilterSurfaceNormal.d.ts +17 -0
- package/src/generation/filtering/numeric/process/computeFilterSurfaceNormal.d.ts.map +1 -0
- package/src/generation/filtering/numeric/process/computeFilterSurfaceNormal.js +42 -0
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.d.ts.map +1 -1
- package/src/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +7 -1
- package/src/generation/filtering/numeric/util/populateSampler2DFromCellFilter.d.ts.map +1 -1
- package/src/generation/filtering/numeric/util/populateSampler2DFromCellFilter.js +7 -10
- package/src/generation/filtering/numeric/util/sampler_from_filter.d.ts.map +1 -1
- package/src/generation/filtering/numeric/util/sampler_from_filter.js +2 -1
- package/src/generation/grid/GridData.d.ts.map +1 -1
- package/src/generation/grid/GridData.js +14 -1
- package/src/generation/grid/actions/ContinuousGridCellAction.d.ts +10 -3
- package/src/generation/grid/actions/ContinuousGridCellAction.d.ts.map +1 -1
- package/src/generation/grid/actions/ContinuousGridCellAction.js +18 -3
- package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainHeight.d.ts +11 -1
- package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainHeight.d.ts.map +1 -1
- package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainHeight.js +13 -3
- package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.d.ts +1 -1
- package/src/generation/grid/actions/ContinuousGridCellActionSetTerrainObstacle.js +2 -2
- package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.d.ts +1 -1
- package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.d.ts.map +1 -1
- package/src/generation/grid/actions/ContinuousGridCellActionWriteObstacle.js +4 -6
- package/src/generation/grid/coords/grid_to_texel.d.ts +9 -0
- package/src/generation/grid/coords/grid_to_texel.d.ts.map +1 -0
- package/src/generation/grid/coords/grid_to_texel.js +10 -0
- package/src/generation/grid/coords/texel_to_grid.d.ts +9 -0
- package/src/generation/grid/coords/texel_to_grid.d.ts.map +1 -0
- package/src/generation/grid/coords/texel_to_grid.js +10 -0
- package/src/generation/grid/generation/GridTaskApplyActionToCells.d.ts +2 -2
- package/src/generation/grid/generation/GridTaskApplyActionToCells.d.ts.map +1 -1
- package/src/generation/grid/generation/GridTaskApplyActionToCells.js +10 -6
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.d.ts.map +1 -1
- package/src/generation/grid/generation/GridTaskDensityMarkerDistribution.js +20 -21
- package/src/generation/grid/generation/GridTaskExecuteRuleTimes.d.ts +7 -0
- package/src/generation/grid/generation/GridTaskExecuteRuleTimes.d.ts.map +1 -1
- package/src/generation/grid/generation/GridTaskExecuteRuleTimes.js +18 -10
- package/src/generation/grid/generation/discrete/GridTaskCellularAutomata.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskCellularAutomata.js +16 -7
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts +5 -3
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/GridTaskConnectRooms.js +26 -23
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.d.ts.map +1 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +10 -1
- package/src/generation/grid/generation/grid/select/CellSupplierBestN.d.ts.map +1 -1
- package/src/generation/grid/generation/grid/select/CellSupplierBestN.js +4 -0
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.d.ts +15 -8
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.d.ts.map +1 -1
- package/src/generation/grid/generation/road/GridTaskGenerateRoads.js +89 -92
- package/src/generation/markers/GridActionRuleSet.d.ts.map +1 -1
- package/src/generation/markers/GridActionRuleSet.js +10 -2
- package/src/generation/markers/GridCellActionPlaceMarker.d.ts +11 -0
- package/src/generation/markers/GridCellActionPlaceMarker.d.ts.map +1 -1
- package/src/generation/markers/GridCellActionPlaceMarker.js +20 -3
- package/src/generation/markers/GridCellActionPlaceMarkerGroup.d.ts +3 -1
- package/src/generation/markers/GridCellActionPlaceMarkerGroup.d.ts.map +1 -1
- package/src/generation/markers/GridCellActionPlaceMarkerGroup.js +9 -2
- package/src/generation/markers/MarkerNode.d.ts +8 -3
- package/src/generation/markers/MarkerNode.d.ts.map +1 -1
- package/src/generation/markers/MarkerNode.js +12 -5
- package/src/generation/markers/actions/MarkerNodeActionEntityPlacement.js +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessor.d.ts +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessor.d.ts.map +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessor.js +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.d.ts +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.d.ts.map +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorClingToTerrain.js +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.d.ts +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.d.ts.map +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorRandomRotation.js +2 -2
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorSequence.d.ts +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorSequence.d.ts.map +1 -1
- package/src/generation/markers/actions/placement/MarkerNodeEntityProcessorSequence.js +2 -2
- package/src/generation/markers/actions/probability/MarkerNodeActionSelectWeighted.d.ts.map +1 -1
- package/src/generation/markers/actions/probability/MarkerNodeActionSelectWeighted.js +6 -4
- package/src/generation/markers/actions/probability/MarkerNodeActionWeightedElement.d.ts.map +1 -1
- package/src/generation/markers/actions/probability/MarkerNodeActionWeightedElement.js +1 -3
- package/src/generation/markers/actions/terrain/MarkerNodeActionPaintTerrain.d.ts.map +1 -1
- package/src/generation/markers/actions/terrain/MarkerNodeActionPaintTerrain.js +12 -11
- package/src/generation/markers/matcher/MarkerNodeMatcherAnd.js +2 -2
- package/src/generation/markers/transform/MarkerNodeTransformer.d.ts +4 -1
- package/src/generation/markers/transform/MarkerNodeTransformer.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformer.js +4 -1
- package/src/generation/markers/transform/MarkerNodeTransformerAddPositionYFromFilter.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerAddPositionYFromFilter.js +1 -3
- package/src/generation/markers/transform/MarkerNodeTransformerOffsetPosition.d.ts +5 -0
- package/src/generation/markers/transform/MarkerNodeTransformerOffsetPosition.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +15 -0
- package/src/generation/markers/transform/MarkerNodeTransformerRecordProperty.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerRecordProperty.js +1 -3
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilter.js +2 -4
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.d.ts.map +1 -1
- package/src/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.js +1 -3
- package/src/generation/placement/GridCellPlacementRule.d.ts.map +1 -1
- package/src/generation/placement/GridCellPlacementRule.js +1 -3
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.d.ts.map +1 -1
- package/src/generation/placement/action/GridCellActionWriteFilterToLayer.js +8 -10
- package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.d.ts.map +1 -1
- package/src/generation/placement/action/random/weighted/CellActionSelectWeightedRandom.js +6 -4
- package/src/generation/placement/action/random/weighted/WeightedGridCellAction.d.ts.map +1 -1
- package/src/generation/placement/action/random/weighted/WeightedGridCellAction.js +1 -3
- package/src/generation/rules/CellMatcher.d.ts +3 -1
- package/src/generation/rules/CellMatcher.d.ts.map +1 -1
- package/src/generation/rules/CellMatcher.js +3 -1
- package/src/generation/rules/CellMatcherFromFilter.d.ts.map +1 -1
- package/src/generation/rules/CellMatcherFromFilter.js +1 -3
- package/src/generation/rules/CellMatcherLayerBitMaskTest.d.ts.map +1 -1
- package/src/generation/rules/CellMatcherLayerBitMaskTest.js +6 -20
- package/src/generation/test_support/executeTaskTreeSync.d.ts +9 -0
- package/src/generation/test_support/executeTaskTreeSync.d.ts.map +1 -0
- package/src/generation/test_support/executeTaskTreeSync.js +78 -0
- package/src/generation/theme/TerrainLayerRuleAggregator.d.ts +2 -1
- package/src/generation/theme/TerrainLayerRuleAggregator.d.ts.map +1 -1
- package/src/generation/theme/TerrainLayerRuleAggregator.js +9 -6
- package/src/generation/theme/Theme.d.ts +1 -1
- package/src/generation/theme/Theme.d.ts.map +1 -1
- package/src/generation/theme/Theme.js +2 -2
- package/src/generation/theme/ThemeEngine.d.ts +3 -3
- package/src/generation/theme/ThemeEngine.d.ts.map +1 -1
- package/src/generation/theme/ThemeEngine.js +26 -16
- package/src/generation/theme/cell/CellProcessingRule.d.ts +3 -3
- package/src/generation/theme/cell/CellProcessingRule.d.ts.map +1 -1
- package/src/generation/theme/cell/CellProcessingRule.js +6 -10
- package/src/generation/theme/cell/CellProcessingRuleSet.d.ts +1 -1
- package/src/generation/theme/cell/CellProcessingRuleSet.d.ts.map +1 -1
- package/src/generation/theme/cell/CellProcessingRuleSet.js +2 -2
- package/src/view/common/ListView.js +1 -1
- package/src/view/elements/BottomLeftResizeHandleView.d.ts.map +1 -1
- package/src/view/elements/BottomLeftResizeHandleView.js +13 -5
- package/src/core/font/FontAsset.d.ts.map +0 -1
- package/src/core/font/FontAssetLoader.d.ts.map +0 -1
- package/src/core/geom/3d/shape/util/shape_to_visual_entity.d.ts.map +0 -1
- package/src/core/geom/3d/tetrahedra/visualize_tetrahedral_mesh.d.ts.map +0 -1
- package/src/core/process/action/AsynchronousDelayAction.d.ts.map +0 -1
- package/src/engine/physics/computeInterceptPoint.d.ts.map +0 -1
- package/src/engine/physics/fluid/solver/optimal_sor_omega.d.ts.map +0 -1
- package/src/engine/physics/gjk/gjk.d.ts.map +0 -1
- package/src/engine/physics/gjk/gjk_epa_penetration.d.ts.map +0 -1
- package/src/engine/physics/gjk/minkowski_support.d.ts.map +0 -1
- package/src/engine/physics/gjk/mpr.d.ts.map +0 -1
- package/src/engine/physics/integration/quat_integrate.d.ts.map +0 -1
- package/src/engine/physics/island/union_find.d.ts.map +0 -1
- package/src/engine/physics/narrowphase/clip_against_axis_uv.d.ts.map +0 -1
- package/src/engine/physics/narrowphase/decomposition/aabb_world_to_local.d.ts.map +0 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.d.ts +0 -21
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.d.ts.map +0 -1
- package/src/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +0 -68
- package/src/generation/grid/generation/grid/GridTaskGridAlignedNodeGenerator.d.ts +0 -10
- package/src/generation/grid/generation/grid/GridTaskGridAlignedNodeGenerator.d.ts.map +0 -1
- package/src/generation/grid/generation/grid/GridTaskGridAlignedNodeGenerator.js +0 -17
- /package/src/{engine/physics → core/geom/3d}/gjk/NOTES.md +0 -0
- /package/src/{engine/physics → core/geom/3d}/gjk/gjk.d.ts +0 -0
- /package/src/{engine/physics → core/math/physics/kinematics}/computeInterceptPoint.d.ts +0 -0
|
@@ -1,544 +1,520 @@
|
|
|
1
|
-
import { v3_compute_triangle_normal } from "
|
|
2
|
-
import { v3_array_copy } from "
|
|
3
|
-
import { v3_cross } from "
|
|
4
|
-
import { v3_dot } from "
|
|
5
|
-
import { v3_length_sqr } from "
|
|
6
|
-
import { v3_subtract } from "
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
*
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
DIR[
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
*
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
let
|
|
452
|
-
|
|
453
|
-
if (
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const bn = best * 3;
|
|
522
|
-
out[0] = FACE_N[bn];
|
|
523
|
-
out[1] = FACE_N[bn + 1];
|
|
524
|
-
out[2] = FACE_N[bn + 2];
|
|
525
|
-
return FACE_DIST[best];
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Penetration depth + normal between two convex support providers at world pose.
|
|
530
|
-
* Writes the unit separation normal (B→A) into `out` and returns the depth
|
|
531
|
-
* (positive on overlap, 0 if separated — `out` untouched on 0).
|
|
532
|
-
*
|
|
533
|
-
* @param {Float64Array|number[]} out destination for the unit normal, length ≥ 3
|
|
534
|
-
* @param {SupportProvider} A world-space support provider (e.g. PosedShape)
|
|
535
|
-
* @param {SupportProvider} B world-space support provider (e.g. PosedShape)
|
|
536
|
-
* @returns {number} penetration depth, or 0 if separated
|
|
537
|
-
*/
|
|
538
|
-
export function gjk_epa_penetration(out, A, B) {
|
|
539
|
-
if (gjk(A, B) < 4) {
|
|
540
|
-
return 0;
|
|
541
|
-
}
|
|
542
|
-
const depth = epa(A, B, out);
|
|
543
|
-
return depth > 0 && Number.isFinite(depth) ? depth : 0;
|
|
544
|
-
}
|
|
1
|
+
import { v3_compute_triangle_normal } from "../triangle/v3_compute_triangle_normal.js";
|
|
2
|
+
import { v3_array_copy } from "../../vec3/v3_array_copy.js";
|
|
3
|
+
import { v3_cross } from "../../vec3/v3_cross.js";
|
|
4
|
+
import { v3_dot } from "../../vec3/v3_dot.js";
|
|
5
|
+
import { v3_length_sqr } from "../../vec3/v3_length_sqr.js";
|
|
6
|
+
import { v3_subtract } from "../../vec3/v3_subtract.js";
|
|
7
|
+
import { minkowski_support } from "./minkowski_support.js";
|
|
8
|
+
import { v3_triple_cross_product } from "../../vec3/v3_triple_cross_product.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Robust GJK + EPA penetration for convex shapes — the narrowphase's
|
|
12
|
+
* convex-fallback and concave-per-triangle penetration query. Replaced the
|
|
13
|
+
* `gjk.js` `gjk_with_axis` + `expanding_polytope_algorithm.js` pair, which
|
|
14
|
+
* returned a non-minimal axis for polytopes because its GJK handed EPA a
|
|
15
|
+
* degenerate (origin-on-face) simplex (see memory: feedback_epa_unreliable_polytopes).
|
|
16
|
+
*
|
|
17
|
+
* Structure follows Bullet's btGjkEpa2: GJK produces a rank-4 simplex that
|
|
18
|
+
* strictly encloses the origin; EPA builds outward-oriented faces from it and
|
|
19
|
+
* expands toward the closest face, rebuilding the horizon each step. Operates on
|
|
20
|
+
* any support provider with `support(out, off, dx, dy, dz)` in WORLD space (e.g.
|
|
21
|
+
* {@link PosedShape3D}); the penetration normal + depth come from the Minkowski
|
|
22
|
+
* difference's closest face to the origin. No cross-frame state → reset-and-
|
|
23
|
+
* resimulate determinism preserved.
|
|
24
|
+
*
|
|
25
|
+
* Allocation-free hot path: the GJK simplex lives in a flat `Float64Array(12)`
|
|
26
|
+
* and the EPA polytope in pooled flat typed arrays (vertices, face vertex-indices,
|
|
27
|
+
* face normals, face distances, horizon edges). All vector math goes through
|
|
28
|
+
* `v3_*` out-parameter helpers writing into module scratch — no per-call arrays
|
|
29
|
+
* or face objects. The pools are module-level scratch reused across calls; the
|
|
30
|
+
* engine is single-threaded and GJK/EPA is never re-entered, matching the rest
|
|
31
|
+
* of the physics core's scratch convention.
|
|
32
|
+
*
|
|
33
|
+
* @author Alex Goldring
|
|
34
|
+
* @copyright Company Named Limited (c) 2026
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
const GJK_MAX_ITER = 64;
|
|
38
|
+
const EPA_MAX_ITER = 64;
|
|
39
|
+
const EPA_EPS = 1e-8;
|
|
40
|
+
const DIR_EPS = 1e-18;
|
|
41
|
+
|
|
42
|
+
// EPA pool capacities. EPA adds at most one vertex per iteration, so vertices are
|
|
43
|
+
// bounded by 4 + EPA_MAX_ITER (= 68), faces by Euler's 2V−4 (= 132) and horizon
|
|
44
|
+
// edges by 3V−6 (= 198). These caps clear those bounds with margin, so for the
|
|
45
|
+
// convex inputs the narrowphase feeds they are never reached; the guards below
|
|
46
|
+
// degrade to "use the current best face" purely as a defence against degenerate
|
|
47
|
+
// input rather than growing the pools.
|
|
48
|
+
const VERT_CAP = 128;
|
|
49
|
+
const FACE_CAP = 256;
|
|
50
|
+
const EDGE_CAP = 256;
|
|
51
|
+
|
|
52
|
+
// --- support scratch ---
|
|
53
|
+
const _w = new Float64Array(3); // newly sampled support point
|
|
54
|
+
|
|
55
|
+
// --- GJK simplex + search direction ---
|
|
56
|
+
const SIMPLEX = new Float64Array(12); // 4 points, 3 floats each; slot 0 = newest (a)
|
|
57
|
+
const DIR = new Float64Array(3);
|
|
58
|
+
|
|
59
|
+
// --- vector scratch (shared; GJK and EPA never run concurrently) ---
|
|
60
|
+
const _ab = new Float64Array(3);
|
|
61
|
+
const _ac = new Float64Array(3);
|
|
62
|
+
const _ad = new Float64Array(3);
|
|
63
|
+
const _abc = new Float64Array(3);
|
|
64
|
+
const _acd = new Float64Array(3);
|
|
65
|
+
const _adb = new Float64Array(3);
|
|
66
|
+
const _t = new Float64Array(3);
|
|
67
|
+
|
|
68
|
+
// --- EPA polytope pools ---
|
|
69
|
+
const VERTS = new Float64Array(VERT_CAP * 3);
|
|
70
|
+
const FACE_IDX = new Int32Array(FACE_CAP * 3); // vertex indices, 3 per face
|
|
71
|
+
const FACE_N = new Float64Array(FACE_CAP * 3); // outward unit normal, 3 per face
|
|
72
|
+
const FACE_DIST = new Float64Array(FACE_CAP); // perpendicular distance from origin
|
|
73
|
+
const EDGE = new Int32Array(EDGE_CAP * 2); // horizon edges, 2 vertex indices each
|
|
74
|
+
const CEN = new Float64Array(3); // polytope centroid (for outward orientation)
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A convex shape exposing a world-space support mapping: `support(out, off, dx,
|
|
78
|
+
* dy, dz)` writes the farthest point of the shape in direction `(dx, dy, dz)`
|
|
79
|
+
* into `out[off..off+2]` (e.g. {@link PosedShape3D}).
|
|
80
|
+
*
|
|
81
|
+
* @typedef {{ support: function(Float64Array, number, number, number, number): void }} SupportProvider
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* GJK intersection. Fills {@link SIMPLEX} with a rank-4 simplex enclosing the
|
|
86
|
+
* origin and returns 4 on overlap; returns 0 if the shapes are separated.
|
|
87
|
+
* `SIMPLEX` slot 0 is the most-recent point throughout (Muratori convention).
|
|
88
|
+
*
|
|
89
|
+
* @param {SupportProvider} A first support provider
|
|
90
|
+
* @param {SupportProvider} B second support provider
|
|
91
|
+
* @returns {number} 4 if the origin is enclosed (shapes overlap), 0 if separated
|
|
92
|
+
*/
|
|
93
|
+
function gjk(A, B) {
|
|
94
|
+
minkowski_support(SIMPLEX, 0, A, B, 1, 0, 0);
|
|
95
|
+
if (v3_length_sqr(SIMPLEX[0], SIMPLEX[1], SIMPLEX[2]) < DIR_EPS) {
|
|
96
|
+
minkowski_support(SIMPLEX, 0, A, B, 0, 1, 0);
|
|
97
|
+
}
|
|
98
|
+
DIR[0] = -SIMPLEX[0];
|
|
99
|
+
DIR[1] = -SIMPLEX[1];
|
|
100
|
+
DIR[2] = -SIMPLEX[2];
|
|
101
|
+
let count = 1;
|
|
102
|
+
|
|
103
|
+
for (let iter = 0; iter < GJK_MAX_ITER; iter++) {
|
|
104
|
+
if (v3_length_sqr(DIR[0], DIR[1], DIR[2]) < DIR_EPS) {
|
|
105
|
+
return 0; // search direction collapsed → touching/separated
|
|
106
|
+
}
|
|
107
|
+
minkowski_support(_w, 0, A, B, DIR[0], DIR[1], DIR[2]);
|
|
108
|
+
if (v3_dot(_w[0], _w[1], _w[2], DIR[0], DIR[1], DIR[2]) < 0) {
|
|
109
|
+
return 0; // farthest point short of the origin → separated
|
|
110
|
+
}
|
|
111
|
+
// push the new point to slot 0, shifting the existing points down one slot
|
|
112
|
+
// (copyWithin is memmove-style: the overlapping forward copy is well-defined)
|
|
113
|
+
SIMPLEX.copyWithin(3, 0, count * 3);
|
|
114
|
+
SIMPLEX[0] = _w[0];
|
|
115
|
+
SIMPLEX[1] = _w[1];
|
|
116
|
+
SIMPLEX[2] = _w[2];
|
|
117
|
+
count++;
|
|
118
|
+
|
|
119
|
+
count = do_simplex(count);
|
|
120
|
+
if (count === 0) {
|
|
121
|
+
return 4; // origin enclosed by the tetrahedron
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Evolve the simplex toward the origin. Reorders {@link SIMPLEX} in place and
|
|
129
|
+
* writes the next search direction into {@link DIR}. Returns the new simplex size,
|
|
130
|
+
* or 0 when a tetrahedron encloses the origin.
|
|
131
|
+
*
|
|
132
|
+
* @param {number} count current simplex size (2, 3, or 4)
|
|
133
|
+
* @returns {number} the new simplex size (1–3), or 0 when the origin is enclosed
|
|
134
|
+
*/
|
|
135
|
+
function do_simplex(count) {
|
|
136
|
+
if (count === 2) {
|
|
137
|
+
return line_case();
|
|
138
|
+
}
|
|
139
|
+
if (count === 3) {
|
|
140
|
+
return triangle_case();
|
|
141
|
+
}
|
|
142
|
+
return tetra_case();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Line (2-point) simplex sub-case: pick the Voronoi region of segment [a, b] the
|
|
147
|
+
* origin projects into and set the next search direction in {@link DIR}.
|
|
148
|
+
*
|
|
149
|
+
* @returns {number} the new simplex size (1 keeps [a], 2 keeps [a, b])
|
|
150
|
+
*/
|
|
151
|
+
function line_case() {
|
|
152
|
+
const ax = SIMPLEX[0], ay = SIMPLEX[1], az = SIMPLEX[2];
|
|
153
|
+
const bx = SIMPLEX[3], by = SIMPLEX[4], bz = SIMPLEX[5];
|
|
154
|
+
v3_subtract(_ab, 0, bx, by, bz, ax, ay, az); // ab = b − a
|
|
155
|
+
const aox = -ax, aoy = -ay, aoz = -az; // ao = −a
|
|
156
|
+
|
|
157
|
+
if (v3_dot(_ab[0], _ab[1], _ab[2], aox, aoy, aoz) > 0) {
|
|
158
|
+
v3_triple_cross_product(DIR, 0, _ab[0], _ab[1], _ab[2], aox, aoy, aoz); // (ab×ao)×ab
|
|
159
|
+
if (v3_length_sqr(DIR[0], DIR[1], DIR[2]) < DIR_EPS) {
|
|
160
|
+
// Origin on the line — pick any perpendicular to ab. Cross against
|
|
161
|
+
// the coordinate axis of ab's smallest-magnitude component: that
|
|
162
|
+
// axis is the farthest from parallel, so the product cannot vanish
|
|
163
|
+
// for a nonzero ab. The selection must compare ab's components to
|
|
164
|
+
// EACH OTHER — a fixed length threshold on the unnormalised ab can
|
|
165
|
+
// pick a near-parallel axis (short axis-aligned CSO segments).
|
|
166
|
+
const px = Math.abs(_ab[0]), py = Math.abs(_ab[1]), pz = Math.abs(_ab[2]);
|
|
167
|
+
if (px <= py && px <= pz) {
|
|
168
|
+
v3_cross(DIR, 0, _ab[0], _ab[1], _ab[2], 1, 0, 0);
|
|
169
|
+
} else if (py <= pz) {
|
|
170
|
+
v3_cross(DIR, 0, _ab[0], _ab[1], _ab[2], 0, 1, 0);
|
|
171
|
+
} else {
|
|
172
|
+
v3_cross(DIR, 0, _ab[0], _ab[1], _ab[2], 0, 0, 1);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return 2; // keep [a, b]
|
|
176
|
+
}
|
|
177
|
+
DIR[0] = aox;
|
|
178
|
+
DIR[1] = aoy;
|
|
179
|
+
DIR[2] = aoz;
|
|
180
|
+
return 1; // keep [a]
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Triangle (3-point) simplex sub-case: classify the origin against triangle
|
|
185
|
+
* [a, b, c]'s edges and faces, reorder {@link SIMPLEX}, and set the next search
|
|
186
|
+
* direction in {@link DIR}.
|
|
187
|
+
*
|
|
188
|
+
* @returns {number} the new simplex size (1, 2, or 3)
|
|
189
|
+
*/
|
|
190
|
+
function triangle_case() {
|
|
191
|
+
const ax = SIMPLEX[0], ay = SIMPLEX[1], az = SIMPLEX[2];
|
|
192
|
+
const bx = SIMPLEX[3], by = SIMPLEX[4], bz = SIMPLEX[5];
|
|
193
|
+
const cx = SIMPLEX[6], cy = SIMPLEX[7], cz = SIMPLEX[8];
|
|
194
|
+
v3_subtract(_ab, 0, bx, by, bz, ax, ay, az);
|
|
195
|
+
v3_subtract(_ac, 0, cx, cy, cz, ax, ay, az);
|
|
196
|
+
const aox = -ax, aoy = -ay, aoz = -az;
|
|
197
|
+
v3_cross(_abc, 0, _ab[0], _ab[1], _ab[2], _ac[0], _ac[1], _ac[2]); // abc = ab×ac
|
|
198
|
+
|
|
199
|
+
// outside edge ac? (abc×ac) · ao > 0
|
|
200
|
+
v3_cross(_t, 0, _abc[0], _abc[1], _abc[2], _ac[0], _ac[1], _ac[2]);
|
|
201
|
+
if (v3_dot(_t[0], _t[1], _t[2], aox, aoy, aoz) > 0) {
|
|
202
|
+
if (v3_dot(_ac[0], _ac[1], _ac[2], aox, aoy, aoz) > 0) {
|
|
203
|
+
// keep [a, c]: move c into slot 1
|
|
204
|
+
v3_array_copy(SIMPLEX, 3, SIMPLEX, 6);
|
|
205
|
+
v3_triple_cross_product(DIR, 0, _ac[0], _ac[1], _ac[2], aox, aoy, aoz); // (ac×ao)×ac
|
|
206
|
+
return 2;
|
|
207
|
+
}
|
|
208
|
+
return star_case();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// outside edge ab? (ab×abc) · ao > 0
|
|
212
|
+
v3_cross(_t, 0, _ab[0], _ab[1], _ab[2], _abc[0], _abc[1], _abc[2]);
|
|
213
|
+
if (v3_dot(_t[0], _t[1], _t[2], aox, aoy, aoz) > 0) {
|
|
214
|
+
return star_case();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// origin within the triangle's prism — above or below the face
|
|
218
|
+
if (v3_dot(_abc[0], _abc[1], _abc[2], aox, aoy, aoz) > 0) {
|
|
219
|
+
DIR[0] = _abc[0];
|
|
220
|
+
DIR[1] = _abc[1];
|
|
221
|
+
DIR[2] = _abc[2];
|
|
222
|
+
} else {
|
|
223
|
+
// below: reorder to [a, c, b] so the winding faces the origin; DIR = −abc
|
|
224
|
+
SIMPLEX[3] = cx;
|
|
225
|
+
SIMPLEX[4] = cy;
|
|
226
|
+
SIMPLEX[5] = cz;
|
|
227
|
+
SIMPLEX[6] = bx;
|
|
228
|
+
SIMPLEX[7] = by;
|
|
229
|
+
SIMPLEX[8] = bz;
|
|
230
|
+
DIR[0] = -_abc[0];
|
|
231
|
+
DIR[1] = -_abc[1];
|
|
232
|
+
DIR[2] = -_abc[2];
|
|
233
|
+
}
|
|
234
|
+
return 3; // keep the triangle
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Edge region shared by the two triangle edges that fold back toward [a]: keep
|
|
239
|
+
* segment [a, b] or vertex [a] and set the next search direction in {@link DIR}.
|
|
240
|
+
*
|
|
241
|
+
* @returns {number} the new simplex size (1 keeps [a], 2 keeps [a, b])
|
|
242
|
+
*/
|
|
243
|
+
function star_case() {
|
|
244
|
+
const ax = SIMPLEX[0], ay = SIMPLEX[1], az = SIMPLEX[2];
|
|
245
|
+
const bx = SIMPLEX[3], by = SIMPLEX[4], bz = SIMPLEX[5];
|
|
246
|
+
v3_subtract(_ab, 0, bx, by, bz, ax, ay, az);
|
|
247
|
+
const aox = -ax, aoy = -ay, aoz = -az;
|
|
248
|
+
|
|
249
|
+
if (v3_dot(_ab[0], _ab[1], _ab[2], aox, aoy, aoz) > 0) {
|
|
250
|
+
v3_triple_cross_product(DIR, 0, _ab[0], _ab[1], _ab[2], aox, aoy, aoz);
|
|
251
|
+
return 2; // keep [a, b]
|
|
252
|
+
}
|
|
253
|
+
DIR[0] = aox;
|
|
254
|
+
DIR[1] = aoy;
|
|
255
|
+
DIR[2] = aoz;
|
|
256
|
+
return 1; // keep [a]
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Tetrahedron (4-point) simplex sub-case: if the origin lies outside one of the
|
|
261
|
+
* three faces incident to [a], reorder {@link SIMPLEX} to that triangle and
|
|
262
|
+
* recurse into {@link triangle_case}; otherwise the origin is enclosed.
|
|
263
|
+
*
|
|
264
|
+
* @returns {number} the new simplex size (1–3), or 0 when the origin is enclosed
|
|
265
|
+
*/
|
|
266
|
+
function tetra_case() {
|
|
267
|
+
const ax = SIMPLEX[0], ay = SIMPLEX[1], az = SIMPLEX[2];
|
|
268
|
+
const bx = SIMPLEX[3], by = SIMPLEX[4], bz = SIMPLEX[5];
|
|
269
|
+
const cx = SIMPLEX[6], cy = SIMPLEX[7], cz = SIMPLEX[8];
|
|
270
|
+
const dx = SIMPLEX[9], dy = SIMPLEX[10], dz = SIMPLEX[11];
|
|
271
|
+
v3_subtract(_ab, 0, bx, by, bz, ax, ay, az);
|
|
272
|
+
v3_subtract(_ac, 0, cx, cy, cz, ax, ay, az);
|
|
273
|
+
v3_subtract(_ad, 0, dx, dy, dz, ax, ay, az);
|
|
274
|
+
const aox = -ax, aoy = -ay, aoz = -az;
|
|
275
|
+
v3_cross(_abc, 0, _ab[0], _ab[1], _ab[2], _ac[0], _ac[1], _ac[2]);
|
|
276
|
+
v3_cross(_acd, 0, _ac[0], _ac[1], _ac[2], _ad[0], _ad[1], _ad[2]);
|
|
277
|
+
v3_cross(_adb, 0, _ad[0], _ad[1], _ad[2], _ab[0], _ab[1], _ab[2]);
|
|
278
|
+
|
|
279
|
+
if (v3_dot(_abc[0], _abc[1], _abc[2], aox, aoy, aoz) > 0) {
|
|
280
|
+
// outside face abc → keep [a, b, c] (slots already correct)
|
|
281
|
+
return triangle_case();
|
|
282
|
+
}
|
|
283
|
+
if (v3_dot(_acd[0], _acd[1], _acd[2], aox, aoy, aoz) > 0) {
|
|
284
|
+
// outside face acd → reorder to [a, c, d]
|
|
285
|
+
SIMPLEX[3] = cx;
|
|
286
|
+
SIMPLEX[4] = cy;
|
|
287
|
+
SIMPLEX[5] = cz;
|
|
288
|
+
SIMPLEX[6] = dx;
|
|
289
|
+
SIMPLEX[7] = dy;
|
|
290
|
+
SIMPLEX[8] = dz;
|
|
291
|
+
return triangle_case();
|
|
292
|
+
}
|
|
293
|
+
if (v3_dot(_adb[0], _adb[1], _adb[2], aox, aoy, aoz) > 0) {
|
|
294
|
+
// outside face adb → reorder to [a, d, b]
|
|
295
|
+
SIMPLEX[3] = dx;
|
|
296
|
+
SIMPLEX[4] = dy;
|
|
297
|
+
SIMPLEX[5] = dz;
|
|
298
|
+
SIMPLEX[6] = bx;
|
|
299
|
+
SIMPLEX[7] = by;
|
|
300
|
+
SIMPLEX[8] = bz;
|
|
301
|
+
return triangle_case();
|
|
302
|
+
}
|
|
303
|
+
return 0; // origin inside the tetrahedron
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/**
|
|
307
|
+
* Append a face spanning vertices (i, j, k) with an OUTWARD unit normal (away
|
|
308
|
+
* from the polytope centroid {@link CEN}); winding is flipped if needed to keep
|
|
309
|
+
* the normal outward.
|
|
310
|
+
*
|
|
311
|
+
* @param {number} i first vertex index into {@link VERTS}
|
|
312
|
+
* @param {number} j second vertex index into {@link VERTS}
|
|
313
|
+
* @param {number} k third vertex index into {@link VERTS}
|
|
314
|
+
* @param {number} face_count current number of faces (the new face's slot)
|
|
315
|
+
* @returns {number} the new face count
|
|
316
|
+
*/
|
|
317
|
+
function add_face(i, j, k, face_count) {
|
|
318
|
+
const ax = VERTS[i * 3], ay = VERTS[i * 3 + 1], az = VERTS[i * 3 + 2];
|
|
319
|
+
const bx = VERTS[j * 3], by = VERTS[j * 3 + 1], bz = VERTS[j * 3 + 2];
|
|
320
|
+
const cx = VERTS[k * 3], cy = VERTS[k * 3 + 1], cz = VERTS[k * 3 + 2];
|
|
321
|
+
// (b−a)×(c−a), normalised (degenerate → (0,1,0)); see v3_compute_triangle_normal
|
|
322
|
+
v3_compute_triangle_normal(_t, 0, ax, ay, az, bx, by, bz, cx, cy, cz);
|
|
323
|
+
let nx = _t[0], ny = _t[1], nz = _t[2];
|
|
324
|
+
|
|
325
|
+
// orient outward: the normal must point away from the interior (centroid)
|
|
326
|
+
if (v3_dot(nx, ny, nz, ax - CEN[0], ay - CEN[1], az - CEN[2]) < 0) {
|
|
327
|
+
nx = -nx;
|
|
328
|
+
ny = -ny;
|
|
329
|
+
nz = -nz;
|
|
330
|
+
const swap = j;
|
|
331
|
+
j = k;
|
|
332
|
+
k = swap;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
const fb = face_count * 3;
|
|
336
|
+
FACE_IDX[fb] = i;
|
|
337
|
+
FACE_IDX[fb + 1] = j;
|
|
338
|
+
FACE_IDX[fb + 2] = k;
|
|
339
|
+
FACE_N[fb] = nx;
|
|
340
|
+
FACE_N[fb + 1] = ny;
|
|
341
|
+
FACE_N[fb + 2] = nz;
|
|
342
|
+
FACE_DIST[face_count] = v3_dot(nx, ny, nz, ax, ay, az); // ≥ 0 once outward
|
|
343
|
+
return face_count + 1;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Add a horizon edge (i, j) with cancellation: if the reverse edge (j, i) is
|
|
348
|
+
* already present, both are interior to the visible region and drop out.
|
|
349
|
+
* Order is irrelevant to the horizon, so removal is an O(1) swap-with-last.
|
|
350
|
+
*
|
|
351
|
+
* @param {number} edge_count current number of horizon edges in {@link EDGE}
|
|
352
|
+
* @param {number} i edge start (vertex index)
|
|
353
|
+
* @param {number} j edge end (vertex index)
|
|
354
|
+
* @returns {number} the new edge count
|
|
355
|
+
*/
|
|
356
|
+
function add_edge(edge_count, i, j) {
|
|
357
|
+
for (let k = 0; k < edge_count; k++) {
|
|
358
|
+
if (EDGE[k * 2] === j && EDGE[k * 2 + 1] === i) {
|
|
359
|
+
const last = edge_count - 1;
|
|
360
|
+
EDGE[k * 2] = EDGE[last * 2];
|
|
361
|
+
EDGE[k * 2 + 1] = EDGE[last * 2 + 1];
|
|
362
|
+
return last;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (edge_count >= EDGE_CAP) {
|
|
366
|
+
return edge_count; // horizon pool full (unreachable for convex inputs)
|
|
367
|
+
}
|
|
368
|
+
EDGE[edge_count * 2] = i;
|
|
369
|
+
EDGE[edge_count * 2 + 1] = j;
|
|
370
|
+
return edge_count + 1;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* Copy a face record (vertex indices, normal, distance) from slot `src` to slot
|
|
375
|
+
* `dst` — used to compact surviving faces over removed ones.
|
|
376
|
+
*
|
|
377
|
+
* @param {number} dst destination face slot
|
|
378
|
+
* @param {number} src source face slot
|
|
379
|
+
* @returns {void}
|
|
380
|
+
*/
|
|
381
|
+
function copy_face(dst, src) {
|
|
382
|
+
const db = dst * 3, sb = src * 3;
|
|
383
|
+
FACE_IDX[db] = FACE_IDX[sb];
|
|
384
|
+
FACE_IDX[db + 1] = FACE_IDX[sb + 1];
|
|
385
|
+
FACE_IDX[db + 2] = FACE_IDX[sb + 2];
|
|
386
|
+
FACE_N[db] = FACE_N[sb];
|
|
387
|
+
FACE_N[db + 1] = FACE_N[sb + 1];
|
|
388
|
+
FACE_N[db + 2] = FACE_N[sb + 2];
|
|
389
|
+
FACE_DIST[dst] = FACE_DIST[src];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* EPA over the Minkowski difference, seeded by the rank-4 enclosing simplex left
|
|
394
|
+
* in {@link SIMPLEX} by {@link gjk}. Writes the unit penetration normal (A→B —
|
|
395
|
+
* the closest-face outward normal of the A−B Minkowski difference; consumers
|
|
396
|
+
* that need B→A negate it, as the narrowphase sign-check sites do)
|
|
397
|
+
* into `out` and returns the depth.
|
|
398
|
+
*
|
|
399
|
+
* @param {SupportProvider} A first support provider
|
|
400
|
+
* @param {SupportProvider} B second support provider
|
|
401
|
+
* @param {Float64Array|number[]} out destination for the unit penetration normal (A→B)
|
|
402
|
+
* @returns {number} penetration depth, or 0 if the polytope degenerated
|
|
403
|
+
*/
|
|
404
|
+
function epa(A, B, out) {
|
|
405
|
+
// seed the vertex pool with the simplex points
|
|
406
|
+
v3_array_copy(VERTS, 0, SIMPLEX, 0);
|
|
407
|
+
v3_array_copy(VERTS, 3, SIMPLEX, 3);
|
|
408
|
+
v3_array_copy(VERTS, 6, SIMPLEX, 6);
|
|
409
|
+
v3_array_copy(VERTS, 9, SIMPLEX, 9);
|
|
410
|
+
let vert_count = 4;
|
|
411
|
+
|
|
412
|
+
CEN[0] = (VERTS[0] + VERTS[3] + VERTS[6] + VERTS[9]) / 4;
|
|
413
|
+
CEN[1] = (VERTS[1] + VERTS[4] + VERTS[7] + VERTS[10]) / 4;
|
|
414
|
+
CEN[2] = (VERTS[2] + VERTS[5] + VERTS[8] + VERTS[11]) / 4;
|
|
415
|
+
|
|
416
|
+
let face_count = 0;
|
|
417
|
+
face_count = add_face(0, 1, 2, face_count);
|
|
418
|
+
face_count = add_face(0, 2, 3, face_count);
|
|
419
|
+
face_count = add_face(0, 3, 1, face_count);
|
|
420
|
+
face_count = add_face(1, 3, 2, face_count);
|
|
421
|
+
|
|
422
|
+
for (let iter = 0; iter < EPA_MAX_ITER; iter++) {
|
|
423
|
+
// closest face to the origin
|
|
424
|
+
let best = 0;
|
|
425
|
+
for (let f = 1; f < face_count; f++) {
|
|
426
|
+
if (FACE_DIST[f] < FACE_DIST[best]) {
|
|
427
|
+
best = f;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
const bn = best * 3;
|
|
432
|
+
minkowski_support(_w, 0, A, B, FACE_N[bn], FACE_N[bn + 1], FACE_N[bn + 2]);
|
|
433
|
+
const wdist = v3_dot(FACE_N[bn], FACE_N[bn + 1], FACE_N[bn + 2], _w[0], _w[1], _w[2]) - FACE_DIST[best];
|
|
434
|
+
if (wdist < EPA_EPS) {
|
|
435
|
+
break; // converged onto the closest face
|
|
436
|
+
}
|
|
437
|
+
if (vert_count >= VERT_CAP) {
|
|
438
|
+
break; // vertex pool full (unreachable: EPA_MAX_ITER caps vertices at 68)
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
const wi = vert_count;
|
|
442
|
+
VERTS[wi * 3] = _w[0];
|
|
443
|
+
VERTS[wi * 3 + 1] = _w[1];
|
|
444
|
+
VERTS[wi * 3 + 2] = _w[2];
|
|
445
|
+
vert_count++;
|
|
446
|
+
|
|
447
|
+
// remove faces visible from w, compacting the survivors; collect the
|
|
448
|
+
// horizon (edges on exactly one removed face) with cancellation
|
|
449
|
+
let edge_count = 0;
|
|
450
|
+
let kept = 0;
|
|
451
|
+
for (let f = 0; f < face_count; f++) {
|
|
452
|
+
const fn = f * 3;
|
|
453
|
+
if (v3_dot(FACE_N[fn], FACE_N[fn + 1], FACE_N[fn + 2], _w[0], _w[1], _w[2]) - FACE_DIST[f] > EPA_EPS) {
|
|
454
|
+
const i0 = FACE_IDX[fn], i1 = FACE_IDX[fn + 1], i2 = FACE_IDX[fn + 2];
|
|
455
|
+
edge_count = add_edge(edge_count, i0, i1);
|
|
456
|
+
edge_count = add_edge(edge_count, i1, i2);
|
|
457
|
+
edge_count = add_edge(edge_count, i2, i0);
|
|
458
|
+
} else {
|
|
459
|
+
if (kept !== f) {
|
|
460
|
+
copy_face(kept, f);
|
|
461
|
+
}
|
|
462
|
+
kept++;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
face_count = kept;
|
|
466
|
+
|
|
467
|
+
for (let e = 0; e < edge_count; e++) {
|
|
468
|
+
if (face_count >= FACE_CAP) {
|
|
469
|
+
break; // face pool full (unreachable for convex inputs)
|
|
470
|
+
}
|
|
471
|
+
face_count = add_face(EDGE[e * 2], EDGE[e * 2 + 1], wi, face_count);
|
|
472
|
+
}
|
|
473
|
+
if (face_count === 0) {
|
|
474
|
+
break; // degenerate polytope (all faces visible + horizon cancelled)
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
if (face_count === 0) {
|
|
479
|
+
// Degenerate: no face survived. Report no usable axis (the caller treats a
|
|
480
|
+
// non-positive depth as a miss) rather than reading a stale face and
|
|
481
|
+
// throwing out of the narrowphase step.
|
|
482
|
+
out[0] = 0;
|
|
483
|
+
out[1] = 0;
|
|
484
|
+
out[2] = 0;
|
|
485
|
+
return 0;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
let best = 0;
|
|
489
|
+
for (let f = 1; f < face_count; f++) {
|
|
490
|
+
if (FACE_DIST[f] < FACE_DIST[best]) {
|
|
491
|
+
best = f;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
const bn = best * 3;
|
|
495
|
+
out[0] = FACE_N[bn];
|
|
496
|
+
out[1] = FACE_N[bn + 1];
|
|
497
|
+
out[2] = FACE_N[bn + 2];
|
|
498
|
+
return FACE_DIST[best];
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Penetration depth + normal between two convex support providers at world pose.
|
|
503
|
+
* Writes the unit separation normal (A→B: the direction A must move along
|
|
504
|
+
* NEGATED to separate — equivalently, negate `out` for the B→A push axis;
|
|
505
|
+
* the narrowphase sign-check sites canonicalise it against the body centres)
|
|
506
|
+
* into `out` and returns the depth (positive on overlap, 0 if separated —
|
|
507
|
+
* `out` untouched on 0).
|
|
508
|
+
*
|
|
509
|
+
* @param {Float64Array|number[]} out destination for the unit normal, length ≥ 3
|
|
510
|
+
* @param {SupportProvider} A world-space support provider (e.g. PosedShape3D)
|
|
511
|
+
* @param {SupportProvider} B world-space support provider (e.g. PosedShape3D)
|
|
512
|
+
* @returns {number} penetration depth, or 0 if separated
|
|
513
|
+
*/
|
|
514
|
+
export function gjk_epa_penetration(out, A, B) {
|
|
515
|
+
if (gjk(A, B) < 4) {
|
|
516
|
+
return 0;
|
|
517
|
+
}
|
|
518
|
+
const depth = epa(A, B, out);
|
|
519
|
+
return depth > 0 && Number.isFinite(depth) ? depth : 0;
|
|
520
|
+
}
|