@woosh/meep-engine 2.168.1 → 2.169.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 +2 -2
- package/build/bundle-worker-image-decoder.js +1 -1
- package/package.json +1 -1
- package/src/REVIEW_2026_08_06/adv-core.md +511 -0
- package/src/REVIEW_2026_08_06/adv-gfx.md +480 -0
- package/src/REVIEW_2026_08_06/adv-view.md +446 -0
- package/src/REVIEW_2026_08_06/api-core.md +296 -0
- package/src/REVIEW_2026_08_06/api-engine.md +195 -0
- package/src/REVIEW_2026_08_06/bvh-phys-sound-net.md +507 -0
- package/src/REVIEW_2026_08_06/core-binary.md +348 -0
- package/src/REVIEW_2026_08_06/core-collection.md +376 -0
- package/src/REVIEW_2026_08_06/core-math.md +221 -0
- package/src/REVIEW_2026_08_06/core-process.md +266 -0
- package/src/REVIEW_2026_08_06/core-science.md +223 -0
- package/src/REVIEW_2026_08_06/engine-ai-nav.md +279 -0
- package/src/REVIEW_2026_08_06/engine-animation.md +167 -0
- package/src/REVIEW_2026_08_06/engine-asset.md +166 -0
- package/src/REVIEW_2026_08_06/engine-ecs.md +920 -0
- package/src/REVIEW_2026_08_06/engine-input.md +197 -0
- package/src/REVIEW_2026_08_06/engine-misc.md +248 -0
- package/src/REVIEW_2026_08_06/engine-terrain.md +52 -0
- package/src/REVIEW_2026_08_06/generation.md +176 -0
- package/src/REVIEW_2026_08_06/geom-2d.md +434 -0
- package/src/REVIEW_2026_08_06/geom-3d.md +117 -0
- package/src/REVIEW_2026_08_06/gfx-gi.md +143 -0
- package/src/REVIEW_2026_08_06/gfx-render.md +740 -0
- package/src/REVIEW_2026_08_06/gfx-texture.md +690 -0
- package/src/REVIEW_2026_08_06/prior-criticals.md +49 -0
- package/src/REVIEW_2026_08_06/prior-highs.md +138 -0
- package/src/REVIEW_2026_08_06/test-gaps.md +364 -0
- package/src/REVIEW_2026_08_06/view.md +667 -0
- package/src/REVIEW_2026_08_06.md +571 -0
- package/src/core/binary/BinaryBuffer.d.ts.map +1 -1
- package/src/core/binary/BinaryBuffer.js +12 -1
- package/src/core/binary/BitImage2.d.ts +5 -1
- package/src/core/binary/BitImage2.d.ts.map +1 -1
- package/src/core/binary/BitImage2.js +5 -1
- package/src/core/bvh8/build/NodeProxy.d.ts.map +1 -1
- package/src/core/bvh8/build/NodeProxy.js +314 -308
- package/src/core/collection/list/List.d.ts +15 -0
- package/src/core/collection/list/List.d.ts.map +1 -1
- package/src/core/collection/list/List.js +34 -0
- package/src/core/collection/list/SortedListProjection.d.ts.map +1 -1
- package/src/core/collection/list/SortedListProjection.js +4 -1
- package/src/core/collection/map/BiMap.d.ts +25 -2
- package/src/core/collection/map/BiMap.d.ts.map +1 -1
- package/src/core/collection/map/BiMap.js +57 -3
- package/src/core/debug/matchers/IsAnything.d.ts.map +1 -1
- package/src/core/debug/matchers/IsAnything.js +5 -1
- package/src/core/events/signal/Signal.d.ts.map +1 -1
- package/src/core/events/signal/Signal.js +3 -1
- package/src/core/geom/2d/polygon/TRIANGULATION_DESIGN.md +433 -0
- package/src/core/geom/2d/polygon/polygon2_is_counter_clockwise.d.ts +31 -0
- package/src/core/geom/2d/polygon/polygon2_is_counter_clockwise.d.ts.map +1 -0
- package/src/core/geom/2d/polygon/polygon2_is_counter_clockwise.js +84 -0
- package/src/core/geom/2d/polygon/polygon2_signed_area.d.ts +24 -2
- package/src/core/geom/2d/polygon/polygon2_signed_area.d.ts.map +1 -1
- package/src/core/geom/2d/polygon/polygon2_signed_area.js +52 -34
- package/src/core/geom/2d/polygon/polygon2_triangulate.corpus.d.ts +28 -0
- package/src/core/geom/2d/polygon/polygon2_triangulate.corpus.d.ts.map +1 -0
- package/src/core/geom/2d/polygon/polygon2_triangulate.corpus.js +86 -0
- package/src/core/geom/2d/polygon/polygon2_triangulate.d.ts +40 -0
- package/src/core/geom/2d/polygon/polygon2_triangulate.d.ts.map +1 -0
- package/src/core/geom/2d/polygon/polygon2_triangulate.js +1280 -0
- package/src/core/geom/2d/polygon/polygon2_triangulation_deviation.d.ts +28 -0
- package/src/core/geom/2d/polygon/polygon2_triangulation_deviation.d.ts.map +1 -0
- package/src/core/geom/2d/polygon/polygon2_triangulation_deviation.js +77 -0
- package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts +6 -3
- package/src/core/geom/2d/triangle/tri2_rasterize_conservative.d.ts.map +1 -1
- package/src/core/geom/2d/triangle/tri2_rasterize_conservative.js +26 -13
- package/src/core/geom/2d/triangle/tri2_signed_area.d.ts +17 -1
- package/src/core/geom/2d/triangle/tri2_signed_area.d.ts.map +1 -1
- package/src/core/geom/2d/triangle/tri2_signed_area.js +35 -23
- package/src/core/geom/2d/v2_morton_encode.d.ts +20 -0
- package/src/core/geom/2d/v2_morton_encode.d.ts.map +1 -0
- package/src/core/geom/2d/v2_morton_encode.js +23 -0
- package/src/core/geom/3d/atlas/segment/atlas_merge_charts.d.ts.map +1 -1
- package/src/core/geom/3d/atlas/segment/atlas_merge_charts.js +4 -1
- package/src/core/geom/3d/polygon/polygon3_compute_normal.d.ts +27 -0
- package/src/core/geom/3d/polygon/polygon3_compute_normal.d.ts.map +1 -0
- package/src/core/geom/3d/polygon/polygon3_compute_normal.js +60 -0
- package/src/core/geom/3d/polygon/polygon3_triangulate.d.ts +34 -0
- package/src/core/geom/3d/polygon/polygon3_triangulate.d.ts.map +1 -0
- package/src/core/geom/3d/polygon/polygon3_triangulate.js +94 -0
- package/src/core/geom/3d/quaternion/quat3_multiply.d.ts +8 -2
- package/src/core/geom/3d/quaternion/quat3_multiply.d.ts.map +1 -1
- package/src/core/geom/3d/quaternion/quat3_multiply.js +8 -2
- package/src/core/geom/3d/shape/ConvexHullShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/ConvexHullShape3D.js +32 -2
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.d.ts +23 -6
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.d.ts.map +1 -1
- package/src/core/geom/3d/topology/struct/binary/io/face/bt_face_triangulate.js +268 -124
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_assert_valid.d.ts +17 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_assert_valid.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_assert_valid.js +44 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_count_edge_faces.d.ts +20 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_count_edge_faces.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_count_edge_faces.js +40 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_closed.d.ts +19 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_closed.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_closed.js +34 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_manifold.d.ts +22 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_manifold.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_is_manifold.js +37 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_validate.d.ts +87 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_validate.d.ts.map +1 -0
- package/src/core/geom/3d/topology/struct/binary/query/bt_mesh_validate.js +599 -0
- package/src/core/geom/3d/triangle/tri3_compute_signed_volume.d.ts +32 -0
- package/src/core/geom/3d/triangle/tri3_compute_signed_volume.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/tri3_compute_signed_volume.js +66 -7
- package/src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.d.ts +22 -1
- package/src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.d.ts.map +1 -1
- package/src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.js +83 -38
- package/src/core/geom/MANIFOLD_COMPARISON_2026_08_01.md +554 -0
- package/src/core/geom/vec3/v3_cotangent.d.ts +6 -2
- package/src/core/geom/vec3/v3_cotangent.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_cotangent.js +6 -2
- package/src/core/geom/vec3/v3_cross.d.ts +6 -2
- package/src/core/geom/vec3/v3_cross.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_cross.js +6 -2
- package/src/core/geom/vec3/v3_multiply.d.ts +6 -2
- package/src/core/geom/vec3/v3_multiply.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_multiply.js +6 -2
- package/src/core/geom/vec3/v3_subtract.d.ts +6 -2
- package/src/core/geom/vec3/v3_subtract.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_subtract.js +6 -2
- package/src/core/localization/Localization.js +1 -1
- package/src/core/math/random/randomSeed.d.ts +13 -0
- package/src/core/math/random/randomSeed.d.ts.map +1 -0
- package/src/core/math/random/randomSeed.js +16 -0
- package/src/core/math/spline/spline3_hermite_apply_transform.d.ts +50 -0
- package/src/core/math/spline/spline3_hermite_apply_transform.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_apply_transform.js +107 -0
- package/src/core/math/spline/spline3_hermite_reverse.d.ts +34 -0
- package/src/core/math/spline/spline3_hermite_reverse.d.ts.map +1 -0
- package/src/core/math/spline/spline3_hermite_reverse.js +49 -0
- package/src/core/math/statistics/hammersley_sequence.d.ts +17 -4
- package/src/core/math/statistics/hammersley_sequence.d.ts.map +1 -1
- package/src/core/math/statistics/hammersley_sequence.js +25 -16
- package/src/core/process/Future.d.ts.map +1 -1
- package/src/core/process/Future.js +12 -0
- package/src/core/process/PromiseWatcher.d.ts.map +1 -1
- package/src/core/process/PromiseWatcher.js +9 -2
- package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
- package/src/core/process/executor/ConcurrentExecutor.js +12 -2
- package/src/core/process/worker/WorkerProxy.d.ts.map +1 -1
- package/src/core/process/worker/WorkerProxy.js +5 -2
- package/src/core/process/worker/extractTransferables.d.ts.map +1 -1
- package/src/core/process/worker/extractTransferables.js +4 -1
- package/src/engine/Engine.d.ts +12 -12
- package/src/engine/Engine.d.ts.map +1 -1
- package/src/engine/Engine.js +149 -10
- package/src/engine/asset/loaders/ArrayBufferLoader.d.ts.map +1 -1
- package/src/engine/asset/loaders/ArrayBufferLoader.js +7 -0
- package/src/engine/ecs/speaker/lines/sets/LineSetDescription.d.ts.map +1 -1
- package/src/engine/ecs/speaker/lines/sets/LineSetDescription.js +3 -1
- package/src/engine/ecs/terrain/ecs/TerrainSystem.d.ts.map +1 -1
- package/src/engine/ecs/terrain/ecs/TerrainSystem.js +4 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts +29 -0
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.d.ts.map +1 -1
- package/src/engine/ecs/terrain/tiles/TerrainTileManager.js +84 -23
- package/src/engine/graphics/CONTEXT_LOSS_RECOVERY_PLAN.md +446 -0
- package/src/engine/graphics/GraphicsEngine.d.ts +56 -7
- package/src/engine/graphics/GraphicsEngine.d.ts.map +1 -1
- package/src/engine/graphics/GraphicsEngine.js +196 -24
- package/src/engine/graphics/context/WebGLContextFailureReason.d.ts +9 -0
- package/src/engine/graphics/context/WebGLContextFailureReason.d.ts.map +1 -0
- package/src/engine/graphics/context/WebGLContextFailureReason.js +17 -0
- package/src/engine/graphics/context/WebGLContextMonitor.d.ts +106 -0
- package/src/engine/graphics/context/WebGLContextMonitor.d.ts.map +1 -0
- package/src/engine/graphics/context/WebGLContextMonitor.js +341 -0
- package/src/engine/graphics/context/WebGLContextState.d.ts +14 -0
- package/src/engine/graphics/context/WebGLContextState.d.ts.map +1 -0
- package/src/engine/graphics/context/WebGLContextState.js +24 -0
- package/src/engine/graphics/context/testWebGLContextLoss.d.ts +2 -0
- package/src/engine/graphics/context/testWebGLContextLoss.d.ts.map +1 -0
- package/src/engine/graphics/context/testWebGLContextLoss.js +696 -0
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.d.ts.map +1 -1
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationAdapter.js +68 -32
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationUpgrader_0_1.d.ts +14 -0
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationUpgrader_0_1.d.ts.map +1 -0
- package/src/engine/graphics/ecs/camera/serialization/CameraSerializationUpgrader_0_1.js +41 -0
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +1 -1
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/mesh-v2/ShadedGeometrySystem.js +5 -0
- package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts +1 -1
- package/src/engine/graphics/ecs/trail2d/Trail2DSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/trail2d/Trail2DSystem.js +2 -1
- package/src/engine/graphics/ecs/trail3d/Trail3DSystem.d.ts +1 -1
- package/src/engine/graphics/ecs/trail3d/Trail3DSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/trail3d/Trail3DSystem.js +3 -5
- package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/BuildNeighborsFast.js +3 -2
- package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.d.ts.map +1 -1
- package/src/engine/graphics/geometry/MikkT/GenerateSharedVerticesIndexList.js +3 -1
- package/src/engine/graphics/geometry/computeMeshSurfaceArea.js +1 -1
- package/src/engine/graphics/load_and_set_cubemap_v0.d.ts +5 -0
- package/src/engine/graphics/load_and_set_cubemap_v0.d.ts.map +1 -1
- package/src/engine/graphics/load_and_set_cubemap_v0.js +26 -21
- package/src/engine/graphics/particles/particular/group/ParticleGroup.d.ts.map +1 -1
- package/src/engine/graphics/particles/particular/group/ParticleGroup.js +19 -8
- package/src/engine/graphics/particles/particular/group/optimizeCommandQueue.js +1 -1
- package/src/engine/graphics/texture/atlas/AtlasLookupTexture.d.ts.map +1 -1
- package/src/engine/graphics/texture/atlas/AtlasLookupTexture.js +10 -3
- package/src/engine/graphics/texture/atlas/TextureAtlas.d.ts.map +1 -1
- package/src/engine/graphics/texture/atlas/TextureAtlas.js +4 -1
- package/src/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.d.ts.map +1 -1
- package/src/engine/graphics/texture/atlas/gpu/WebGLTextureAtlas.js +11 -0
- package/src/engine/graphics/texture/cubemap/load_environment_map.d.ts.map +1 -1
- package/src/engine/graphics/texture/cubemap/load_environment_map.js +5 -2
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/distance/computeSignedDistanceField_Chamfer.js +26 -18
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts +15 -2
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/filter/sampler2d_blur_gaussian.js +29 -3
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.d.ts +11 -1
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.d.ts.map +1 -1
- package/src/engine/graphics/texture/sampler/resize/sampler2d_scale_down_lanczos.js +158 -171
- package/src/engine/graphics/texture/sampler/sampler2d_paint.js +1 -1
- package/src/engine/graphics/texture/sampler/util/bitSet2Sampler2D.js +2 -2
- package/src/engine/input/ecs/util/TopDownCameraControllerHelper.d.ts.map +1 -1
- package/src/engine/input/ecs/util/TopDownCameraControllerHelper.js +10 -3
- package/src/engine/navigation/ecs/components/PathSerializationUpgrader_2_3.d.ts +14 -0
- package/src/engine/navigation/ecs/components/PathSerializationUpgrader_2_3.d.ts.map +1 -0
- package/src/engine/navigation/ecs/components/PathSerializationUpgrader_2_3.js +38 -0
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.d.ts.map +1 -1
- package/src/engine/network/orchestrator/ServerAuthoritativeClient.js +433 -425
- package/src/engine/physics/constraint/solve_constraints.d.ts +4 -1
- package/src/engine/physics/constraint/solve_constraints.d.ts.map +1 -1
- package/src/engine/physics/constraint/solve_constraints.js +38 -13
- package/src/engine/physics/contact/ManifoldStore.d.ts +15 -3
- package/src/engine/physics/contact/ManifoldStore.d.ts.map +1 -1
- package/src/engine/physics/contact/ManifoldStore.js +15 -3
- package/src/engine/physics/ecs/Joint.d.ts +7 -4
- package/src/engine/physics/ecs/Joint.d.ts.map +1 -1
- package/src/engine/physics/ecs/Joint.js +7 -4
- package/src/engine/physics/ecs/PhysicsSystem.d.ts +14 -0
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +16 -0
- package/src/engine/physics/fluid/ecs/FluidObstacleSystem.d.ts +4 -4
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts +15 -7
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/convex_convex_manifold.js +33 -10
- package/src/engine/physics/narrowphase/refine_ray_concave.d.ts +6 -2
- package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_concave.js +6 -2
- package/src/engine/physics/narrowphase/refine_ray_hit.d.ts +6 -2
- package/src/engine/physics/narrowphase/refine_ray_hit.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_hit.js +6 -2
- package/src/engine/physics/queries/raycast.d.ts.map +1 -1
- package/src/engine/physics/queries/raycast.js +11 -4
- package/src/engine/save/storage/IndexedDBStorage.d.ts.map +1 -1
- package/src/engine/save/storage/IndexedDBStorage.js +21 -3
- package/src/engine/simulation/Ticker.d.ts +12 -0
- package/src/engine/simulation/Ticker.d.ts.map +1 -1
- package/src/engine/simulation/Ticker.js +18 -0
- package/src/engine/sound/simulation/AcousticSimulator.d.ts.map +1 -1
- package/src/engine/sound/simulation/AcousticSimulator.js +9 -1
- package/src/engine/sound/simulation/core/VolumeField.d.ts +6 -2
- package/src/engine/sound/simulation/core/VolumeField.d.ts.map +1 -1
- package/src/engine/sound/simulation/core/VolumeField.js +6 -2
- package/src/engine/sound/simulation/probe/AcousticProbeField.d.ts +6 -2
- package/src/engine/sound/simulation/probe/AcousticProbeField.d.ts.map +1 -1
- package/src/engine/sound/simulation/probe/AcousticProbeField.js +6 -2
- package/src/engine/sound/simulation/probe/acoustic_probe_transfer.d.ts +6 -2
- package/src/engine/sound/simulation/probe/acoustic_probe_transfer.d.ts.map +1 -1
- package/src/engine/sound/simulation/probe/acoustic_probe_transfer.js +6 -2
- package/src/engine/sound/simulation/probe/bakeProbeReflectors.d.ts +3 -1
- package/src/engine/sound/simulation/probe/bakeProbeReflectors.d.ts.map +1 -1
- package/src/engine/sound/simulation/probe/bakeProbeReflectors.js +3 -1
- package/src/engine/ui/GUIEngine.d.ts.map +1 -1
- package/src/engine/ui/GUIEngine.js +8 -1
- package/src/generation/theme/TerrainTheme.d.ts.map +1 -1
- package/src/generation/theme/TerrainTheme.js +2 -1
- package/src/generation/theme/ThemeEngine.d.ts.map +1 -1
- package/src/generation/theme/ThemeEngine.js +6 -5
- package/src/view/ViewGroup.d.ts.map +1 -1
- package/src/view/ViewGroup.js +9 -7
- package/src/view/graphics/WebGLContextFailureView.d.ts +19 -0
- package/src/view/graphics/WebGLContextFailureView.d.ts.map +1 -0
- package/src/view/graphics/WebGLContextFailureView.js +76 -0
- package/src/view/minimap/Minimap.d.ts +8 -0
- package/src/view/minimap/Minimap.d.ts.map +1 -1
- package/src/view/minimap/Minimap.js +16 -3
- package/src/view/minimap/dom/MinimapMarkerView.d.ts.map +1 -1
- package/src/view/minimap/dom/MinimapMarkerView.js +3 -1
|
@@ -3,6 +3,38 @@ const ONE_OVER_SIX = 1.0 / 6.0;
|
|
|
3
3
|
/**
|
|
4
4
|
* Compute signed volume of a tetrahedron with the last point at the origin
|
|
5
5
|
* Triangle is defined by points A,B,C
|
|
6
|
+
*
|
|
7
|
+
* Evaluated as `p · ((q - p) × (r - p))` where `(p, q, r)` is the cyclic
|
|
8
|
+
* rotation of `(a, b, c)` that puts the vertex nearest the origin first. Both
|
|
9
|
+
* steps are exact rewrites of `a · (b × c)`: a cyclic rotation leaves a 3×3
|
|
10
|
+
* determinant unchanged, and the two extra terms the edge form introduces,
|
|
11
|
+
* `p · (q × p)` and `p · (p × r)`, are identically zero.
|
|
12
|
+
*
|
|
13
|
+
* The rotation is not cosmetic — the two forms fail in opposite regimes, and
|
|
14
|
+
* picking the apex is what makes the result well conditioned in both. The
|
|
15
|
+
* error behaves like `eps · |p| · |q - p| · |r - p|`:
|
|
16
|
+
*
|
|
17
|
+
* - the expanded determinant of absolute coordinates loses everything for a
|
|
18
|
+
* SMALL triangle FAR from the origin. Summed over a unit cube translated to
|
|
19
|
+
* (1e6, 1e6, 1e6) it returned 256, and −262144 at 1e7;
|
|
20
|
+
* - anchoring unconditionally on `a` instead loses everything for a LARGE
|
|
21
|
+
* triangle reaching IN toward the origin, where `|b - a|` and `|c - a|` are
|
|
22
|
+
* both as large as `|a|`. `(1e8, 1e8, 1e8), (1, 0, 0), (0, 1, 0)` returned
|
|
23
|
+
* 0 for a true volume of 16666666.67, and flipped the sign of a needle
|
|
24
|
+
* tetrahedron often enough to break callers using this as an orientation
|
|
25
|
+
* predicate.
|
|
26
|
+
*
|
|
27
|
+
* Anchoring on the vertex nearest the origin is exact in both, and measured at
|
|
28
|
+
* a worst relative error of 8e-13 over 400k triangles with each vertex drawn
|
|
29
|
+
* from an independent magnitude decade up to 1e9.
|
|
30
|
+
*
|
|
31
|
+
* Distance is compared by largest absolute component rather than by squared
|
|
32
|
+
* length, which is cheaper and cannot overflow for coordinates above ~1e154.
|
|
33
|
+
*
|
|
34
|
+
* A caller summing over a whole mesh should still subtract a reference point,
|
|
35
|
+
* as {@link tri3_mesh_compute_signed_volume} does: this conditions each term,
|
|
36
|
+
* but only the caller can stop the terms themselves from being enormous.
|
|
37
|
+
*
|
|
6
38
|
* @see "EFFICIENT FEATURE EXTRACTION FOR 2D/3D OBJECTS IN MESH REPRESENTATION" by Cha Zhang and Tsuhan Chen
|
|
7
39
|
* @param {number} ax
|
|
8
40
|
* @param {number} ay
|
|
@@ -21,13 +53,40 @@ export function tri3_compute_signed_volume(
|
|
|
21
53
|
cx, cy, cz
|
|
22
54
|
) {
|
|
23
55
|
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const v132 = ax * cy * bz;
|
|
28
|
-
const v213 = bx * ay * cz;
|
|
29
|
-
const v123 = ax * by * cz;
|
|
56
|
+
const ea = Math.max(Math.abs(ax), Math.abs(ay), Math.abs(az));
|
|
57
|
+
const eb = Math.max(Math.abs(bx), Math.abs(by), Math.abs(bz));
|
|
58
|
+
const ec = Math.max(Math.abs(cx), Math.abs(cy), Math.abs(cz));
|
|
30
59
|
|
|
31
|
-
|
|
60
|
+
// (p, q, r) is a CYCLIC rotation of (a, b, c) — swapping any two would
|
|
61
|
+
// negate the determinant.
|
|
62
|
+
let px, py, pz, qx, qy, qz, rx, ry, rz;
|
|
63
|
+
|
|
64
|
+
if (eb <= ea && eb <= ec) {
|
|
65
|
+
px = bx; py = by; pz = bz;
|
|
66
|
+
qx = cx; qy = cy; qz = cz;
|
|
67
|
+
rx = ax; ry = ay; rz = az;
|
|
68
|
+
} else if (ec <= ea && ec <= eb) {
|
|
69
|
+
px = cx; py = cy; pz = cz;
|
|
70
|
+
qx = ax; qy = ay; qz = az;
|
|
71
|
+
rx = bx; ry = by; rz = bz;
|
|
72
|
+
} else {
|
|
73
|
+
px = ax; py = ay; pz = az;
|
|
74
|
+
qx = bx; qy = by; qz = bz;
|
|
75
|
+
rx = cx; ry = cy; rz = cz;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const e1x = qx - px;
|
|
79
|
+
const e1y = qy - py;
|
|
80
|
+
const e1z = qz - pz;
|
|
81
|
+
|
|
82
|
+
const e2x = rx - px;
|
|
83
|
+
const e2y = ry - py;
|
|
84
|
+
const e2z = rz - pz;
|
|
85
|
+
|
|
86
|
+
const nx = e1y * e2z - e1z * e2y;
|
|
87
|
+
const ny = e1z * e2x - e1x * e2z;
|
|
88
|
+
const nz = e1x * e2y - e1y * e2x;
|
|
89
|
+
|
|
90
|
+
return ONE_OVER_SIX * (px * nx + py * ny + pz * nz);
|
|
32
91
|
|
|
33
92
|
}
|
|
@@ -11,10 +11,31 @@
|
|
|
11
11
|
* tetrahedralized version of the same closed surface should have a total tet
|
|
12
12
|
* volume close to this value (small discretization gap aside).
|
|
13
13
|
*
|
|
14
|
+
* Two things make the sum trustworthy away from the origin.
|
|
15
|
+
*
|
|
16
|
+
* The apex of every tetrahedron is the mesh's own first referenced vertex
|
|
17
|
+
* rather than the origin. For a closed mesh the total is invariant to that
|
|
18
|
+
* choice, but the conditioning is not: with the origin as apex, a mesh sitting
|
|
19
|
+
* at 1e7 produces per-triangle terms around 1e21 that must cancel down to the
|
|
20
|
+
* enclosed volume, and there is no precision left to cancel with. Anchored to
|
|
21
|
+
* the mesh itself, each term is on the scale of the mesh, not of its distance
|
|
22
|
+
* from the origin.
|
|
23
|
+
*
|
|
24
|
+
* The terms are then accumulated with Neumaier compensation, which recovers the
|
|
25
|
+
* low-order bits lost whenever a term is added to a running total of a very
|
|
26
|
+
* different magnitude — the situation for any shape whose bounding box dwarfs
|
|
27
|
+
* its volume, such as a thin shell.
|
|
28
|
+
*
|
|
29
|
+
* Note this changes what an OPEN mesh reports, which was already documented as
|
|
30
|
+
* not being an enclosed volume: the cone is now measured from the first
|
|
31
|
+
* referenced vertex instead of the origin, so the number is at least a property
|
|
32
|
+
* of the mesh rather than of where the mesh happens to be. For a closed mesh
|
|
33
|
+
* nothing changes but the accuracy.
|
|
34
|
+
*
|
|
14
35
|
* @param {ArrayLike<number>} positions flat (x,y,z,…) array
|
|
15
36
|
* @param {ArrayLike<number>} indices 3 entries per triangle
|
|
16
37
|
* @returns {number} signed volume — positive for CCW-from-outside winding,
|
|
17
|
-
* negative if flipped, zero for an
|
|
38
|
+
* negative if flipped, zero for an empty or self-cancelling mesh
|
|
18
39
|
*/
|
|
19
40
|
export function tri3_mesh_compute_signed_volume(positions: ArrayLike<number>, indices: ArrayLike<number>): number;
|
|
20
41
|
//# sourceMappingURL=tri3_mesh_compute_signed_volume.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tri3_mesh_compute_signed_volume.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.js"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"tri3_mesh_compute_signed_volume.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/3d/triangle/tri3_mesh_compute_signed_volume.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,2DALW,UAAU,MAAM,CAAC,WACjB,UAAU,MAAM,CAAC,GACf,MAAM,CA4ClB"}
|
|
@@ -1,38 +1,83 @@
|
|
|
1
|
-
import { tri3_compute_signed_volume } from "./tri3_compute_signed_volume.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Compute the signed volume enclosed by a triangle surface mesh given as
|
|
5
|
-
* flat positions + indices, via the divergence theorem.
|
|
6
|
-
*
|
|
7
|
-
* For every triangle (a, b, c) this sums the signed volume of the
|
|
8
|
-
* tetrahedron (origin, a, b, c); when the mesh is closed and consistently
|
|
9
|
-
* wound (CCW from outside → positive volume), the per-triangle contributions
|
|
10
|
-
* cancel everywhere except inside the surface, leaving the enclosed volume.
|
|
11
|
-
*
|
|
12
|
-
* Useful as a ground truth for validating volumetric mesh generation: the
|
|
13
|
-
* tetrahedralized version of the same closed surface should have a total tet
|
|
14
|
-
* volume close to this value (small discretization gap aside).
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
1
|
+
import { tri3_compute_signed_volume } from "./tri3_compute_signed_volume.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Compute the signed volume enclosed by a triangle surface mesh given as
|
|
5
|
+
* flat positions + indices, via the divergence theorem.
|
|
6
|
+
*
|
|
7
|
+
* For every triangle (a, b, c) this sums the signed volume of the
|
|
8
|
+
* tetrahedron (origin, a, b, c); when the mesh is closed and consistently
|
|
9
|
+
* wound (CCW from outside → positive volume), the per-triangle contributions
|
|
10
|
+
* cancel everywhere except inside the surface, leaving the enclosed volume.
|
|
11
|
+
*
|
|
12
|
+
* Useful as a ground truth for validating volumetric mesh generation: the
|
|
13
|
+
* tetrahedralized version of the same closed surface should have a total tet
|
|
14
|
+
* volume close to this value (small discretization gap aside).
|
|
15
|
+
*
|
|
16
|
+
* Two things make the sum trustworthy away from the origin.
|
|
17
|
+
*
|
|
18
|
+
* The apex of every tetrahedron is the mesh's own first referenced vertex
|
|
19
|
+
* rather than the origin. For a closed mesh the total is invariant to that
|
|
20
|
+
* choice, but the conditioning is not: with the origin as apex, a mesh sitting
|
|
21
|
+
* at 1e7 produces per-triangle terms around 1e21 that must cancel down to the
|
|
22
|
+
* enclosed volume, and there is no precision left to cancel with. Anchored to
|
|
23
|
+
* the mesh itself, each term is on the scale of the mesh, not of its distance
|
|
24
|
+
* from the origin.
|
|
25
|
+
*
|
|
26
|
+
* The terms are then accumulated with Neumaier compensation, which recovers the
|
|
27
|
+
* low-order bits lost whenever a term is added to a running total of a very
|
|
28
|
+
* different magnitude — the situation for any shape whose bounding box dwarfs
|
|
29
|
+
* its volume, such as a thin shell.
|
|
30
|
+
*
|
|
31
|
+
* Note this changes what an OPEN mesh reports, which was already documented as
|
|
32
|
+
* not being an enclosed volume: the cone is now measured from the first
|
|
33
|
+
* referenced vertex instead of the origin, so the number is at least a property
|
|
34
|
+
* of the mesh rather than of where the mesh happens to be. For a closed mesh
|
|
35
|
+
* nothing changes but the accuracy.
|
|
36
|
+
*
|
|
37
|
+
* @param {ArrayLike<number>} positions flat (x,y,z,…) array
|
|
38
|
+
* @param {ArrayLike<number>} indices 3 entries per triangle
|
|
39
|
+
* @returns {number} signed volume — positive for CCW-from-outside winding,
|
|
40
|
+
* negative if flipped, zero for an empty or self-cancelling mesh
|
|
41
|
+
*/
|
|
42
|
+
export function tri3_mesh_compute_signed_volume(positions, indices) {
|
|
43
|
+
const n = indices.length;
|
|
44
|
+
|
|
45
|
+
if (n === 0) {
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Anchor the tetrahedra at the mesh instead of at the origin.
|
|
50
|
+
const origin3 = indices[0] * 3;
|
|
51
|
+
|
|
52
|
+
const ox = positions[origin3];
|
|
53
|
+
const oy = positions[origin3 + 1];
|
|
54
|
+
const oz = positions[origin3 + 2];
|
|
55
|
+
|
|
56
|
+
let total = 0;
|
|
57
|
+
// Neumaier compensation: the bits that fell off the bottom of `total`.
|
|
58
|
+
let compensation = 0;
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < n; i += 3) {
|
|
61
|
+
const a3 = indices[i] * 3;
|
|
62
|
+
const b3 = indices[i + 1] * 3;
|
|
63
|
+
const c3 = indices[i + 2] * 3;
|
|
64
|
+
|
|
65
|
+
const term = tri3_compute_signed_volume(
|
|
66
|
+
positions[a3] - ox, positions[a3 + 1] - oy, positions[a3 + 2] - oz,
|
|
67
|
+
positions[b3] - ox, positions[b3 + 1] - oy, positions[b3 + 2] - oz,
|
|
68
|
+
positions[c3] - ox, positions[c3 + 1] - oy, positions[c3 + 2] - oz,
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const sum = total + term;
|
|
72
|
+
|
|
73
|
+
if (Math.abs(total) >= Math.abs(term)) {
|
|
74
|
+
compensation += (total - sum) + term;
|
|
75
|
+
} else {
|
|
76
|
+
compensation += (term - sum) + total;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
total = sum;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return total + compensation;
|
|
83
|
+
}
|