@woosh/meep-engine 2.154.0 → 2.156.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 -1
- package/build/bundle-worker-image-decoder.js +1 -1
- package/build/bundle-worker-terrain.js +1 -1
- package/editor/view/ecs/ComponentControlView.d.ts +0 -9
- package/editor/view/ecs/ComponentControlView.js +2 -98
- package/package.json +1 -1
- package/src/core/binary/32BitEncoder.js +1 -1
- package/src/core/binary/to_half_float_uint16.js +3 -3
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.d.ts.map +1 -1
- package/src/core/bvh2/bvh3/ebvh_build_hierarchy_radix.js +275 -253
- package/src/core/cache/Cache.d.ts.map +1 -1
- package/src/core/cache/Cache.js +7 -0
- package/src/core/cache/FrequencySketch.d.ts.map +1 -1
- package/src/core/cache/FrequencySketch.js +8 -4
- package/src/core/clipboard/obtainClipBoard.d.ts +6 -0
- package/src/core/clipboard/obtainClipBoard.d.ts.map +1 -0
- package/src/core/clipboard/obtainClipBoard.js +29 -0
- package/src/core/clipboard/safeClipboardReadText.d.ts +6 -0
- package/src/core/clipboard/safeClipboardReadText.d.ts.map +1 -0
- package/src/core/clipboard/safeClipboardReadText.js +55 -0
- package/src/core/clipboard/safeClipboardWriteText.d.ts +8 -0
- package/src/core/clipboard/safeClipboardWriteText.d.ts.map +1 -0
- package/src/core/clipboard/safeClipboardWriteText.js +23 -0
- package/src/core/collection/array/array_quick_sort_by_lookup_map.js +1 -1
- package/src/core/collection/array/array_set_diff_sorting.d.ts.map +1 -1
- package/src/core/collection/array/array_set_diff_sorting.js +4 -1
- package/src/core/collection/array/array_shuffle.d.ts.map +1 -1
- package/src/core/collection/array/array_shuffle.js +30 -27
- package/src/core/collection/array/binarySearchLowIndex.d.ts.map +1 -1
- package/src/core/collection/array/binarySearchLowIndex.js +4 -3
- package/src/core/collection/array/typed/array_buffer_hash.js +1 -1
- package/src/core/collection/array/typed/is_typed_array_equals.d.ts.map +1 -1
- package/src/core/collection/array/typed/is_typed_array_equals.js +12 -2
- package/src/core/collection/heap/BinaryHeap.d.ts.map +1 -1
- package/src/core/collection/heap/BinaryHeap.js +12 -2
- package/src/core/collection/queue/Deque.d.ts.map +1 -1
- package/src/core/collection/queue/Deque.js +10 -8
- package/src/core/collection/table/RowFirstTable.d.ts.map +1 -1
- package/src/core/collection/table/RowFirstTable.js +4 -2
- package/src/core/collection/table/RowFirstTableSpec.js +2 -2
- package/src/core/color/operations/color_lerp.d.ts.map +1 -1
- package/src/core/color/operations/color_lerp.js +10 -3
- package/src/core/color/rgb2uint32.js +1 -1
- package/src/core/color/rgbe9995_to_rgb.js +1 -1
- package/src/core/function/objectsEqual.d.ts.map +1 -1
- package/src/core/function/objectsEqual.js +2 -1
- package/src/core/geom/2d/aabb/AABB2.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/AABB2.js +12 -11
- package/src/core/geom/2d/convex-hull/convex_hull_jarvis_2d.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/convex_hull_jarvis_2d.js +30 -4
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.d.ts.map +1 -1
- package/src/core/geom/2d/convex-hull/fixed_convex_hull_relaxation.js +6 -2
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.d.ts.map +1 -1
- package/src/core/geom/2d/hash-grid/SpatialHashGrid.js +388 -386
- package/src/core/geom/2d/hash-grid/shg_query_elements_line.d.ts.map +1 -1
- package/src/core/geom/2d/hash-grid/shg_query_elements_line.js +8 -3
- package/src/core/geom/2d/quad-tree/QuadTreeDatum.d.ts.map +1 -1
- package/src/core/geom/2d/quad-tree/QuadTreeDatum.js +9 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.d.ts +3 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.d.ts.map +1 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_nearest_to_point.js +3 -1
- package/src/core/geom/2d/quad-tree-binary/QuadTree.js +714 -714
- package/src/core/geom/2d/r-tree/StaticR2Tree.d.ts.map +1 -1
- package/src/core/geom/2d/r-tree/StaticR2Tree.js +5 -4
- package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_detailed_volume_intersection.js +33 -29
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_near_distance_to_intersection_ray_segment.js +3 -1
- package/src/core/geom/3d/aabb/aabb3_signed_distance_to_aabb3.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_signed_distance_to_aabb3.js +10 -7
- package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.d.ts.map +1 -1
- package/src/core/geom/3d/aabb/aabb3_transformed_compute_plane_side.js +30 -9
- package/src/core/geom/3d/aabb/compute_aabb_from_points.js +3 -3
- package/src/core/geom/3d/box/box3_raycast.d.ts +37 -0
- package/src/core/geom/3d/box/box3_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/box/box3_raycast.js +81 -0
- package/src/core/geom/3d/capsule/capsule_raycast.d.ts +35 -0
- package/src/core/geom/3d/capsule/capsule_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/capsule/capsule_raycast.js +93 -0
- package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.d.ts.map +1 -1
- package/src/core/geom/3d/cone/compute_bounding_cone_of_2_cones.js +4 -0
- package/src/core/geom/3d/frustum/frustum3_computeNearestPointToPoint.js +1 -1
- package/src/core/geom/3d/line/line3_compute_segment_point_distance_eikonal.d.ts.map +1 -1
- package/src/core/geom/3d/line/line3_compute_segment_point_distance_eikonal.js +3 -2
- package/src/core/geom/3d/mat4/decompose_matrix_4_array.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/decompose_matrix_4_array.js +12 -2
- package/src/core/geom/3d/mat4/eulerAnglesFromMatrix.js +2 -2
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts +1 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.d.ts.map +1 -1
- package/src/core/geom/3d/mat4/m4_multiply_alphatensor.js +19 -13
- package/src/core/geom/3d/octahedra/octahedral_direction_to_uv.d.ts.map +1 -1
- package/src/core/geom/3d/octahedra/octahedral_direction_to_uv.js +3 -2
- package/src/core/geom/3d/plane/plane3_compute_plane_intersection.js +3 -2
- package/src/core/geom/3d/shape/MeshShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/MeshShape3D.js +7 -0
- package/src/core/geom/3d/shape/UnionShape3D.d.ts.map +1 -1
- package/src/core/geom/3d/shape/UnionShape3D.js +3 -2
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.d.ts.map +1 -1
- package/src/core/geom/3d/shape/util/shape3d_voxelize_to_grid.js +153 -148
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_dering_optimize_positive.js +7 -0
- package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.d.ts.map +1 -1
- package/src/core/geom/3d/sphere/harmonics/sh3_sample_by_direction.js +13 -10
- package/src/core/geom/3d/sphere/sphere_projected_sphere_radius_sqr.d.ts +1 -1
- package/src/core/geom/3d/sphere/sphere_projected_sphere_radius_sqr.js +2 -2
- package/src/core/geom/3d/sphere/sphere_raycast.d.ts +33 -0
- package/src/core/geom/3d/sphere/sphere_raycast.d.ts.map +1 -0
- package/src/core/geom/3d/sphere/sphere_raycast.js +47 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_tet_get_neighbours.d.ts +24 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_tet_get_neighbours.d.ts.map +1 -0
- package/src/core/geom/3d/tetrahedra/tetrahedral_mesh_tet_get_neighbours.js +39 -0
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.d.ts.map +1 -1
- package/src/core/geom/3d/tetrahedra/triangle/trace_triangular_depth_map.js +4 -2
- package/src/core/geom/3d/topology/bounds/computeTriangleClusterNormalBoundingCone.js +3 -3
- package/src/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +1 -1
- package/src/core/geom/3d/topology/tm_vertex_compute_normal.d.ts.map +1 -1
- package/src/core/geom/3d/topology/tm_vertex_compute_normal.js +4 -2
- package/src/core/geom/3d/util/make_justified_point_grid.d.ts.map +1 -1
- package/src/core/geom/3d/util/make_justified_point_grid.js +18 -10
- package/src/core/geom/ConicRay.d.ts.map +1 -1
- package/src/core/geom/ConicRay.js +11 -13
- package/src/core/geom/packing/max-rect/removeRedundantBoxes.d.ts.map +1 -1
- package/src/core/geom/packing/max-rect/removeRedundantBoxes.js +19 -4
- package/src/core/geom/vec3/v3_array_copy.d.ts +3 -3
- package/src/core/geom/vec3/v3_array_copy.d.ts.map +1 -1
- package/src/core/geom/vec3/v3_array_copy.js +2 -2
- package/src/core/geom/vec3/v3_cross.d.ts +17 -0
- package/src/core/geom/vec3/v3_cross.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_cross.js +20 -0
- package/src/core/geom/vec3/v3_orthonormal_matrix_from_normal.d.ts.map +1 -0
- package/src/{engine/graphics/sh3/path_tracer/sampling → core/geom/vec3}/v3_orthonormal_matrix_from_normal.js +1 -1
- package/src/core/geom/vec3/v3_subtract.d.ts +16 -0
- package/src/core/geom/vec3/v3_subtract.d.ts.map +1 -0
- package/src/core/geom/vec3/v3_subtract.js +19 -0
- package/src/core/graph/coloring/colorizeGraph.js +2 -2
- package/src/core/graph/csr/CSRGraph.d.ts.map +1 -1
- package/src/core/graph/csr/CSRGraph.js +325 -319
- package/src/core/graph/layout/CircleLayout.d.ts.map +1 -1
- package/src/core/graph/layout/CircleLayout.js +8 -6
- package/src/core/graph/metis/native/refine/compute_kway_params.d.ts.map +1 -1
- package/src/core/graph/metis/native/refine/compute_kway_params.js +139 -138
- package/src/core/graph/mn_graph_coarsen.d.ts.map +1 -1
- package/src/core/graph/mn_graph_coarsen.js +4 -2
- package/src/core/graph/v2/NodeContainer.js +7 -7
- package/src/core/localization/LocalizationEngine.js +1 -1
- package/src/core/math/bell_membership_function.d.ts.map +1 -1
- package/src/core/math/bell_membership_function.js +3 -1
- package/src/core/math/complex/complex_add.d.ts +4 -4
- package/src/core/math/complex/complex_add.d.ts.map +1 -1
- package/src/core/math/complex/complex_add.js +3 -3
- package/src/core/math/complex/complex_div.d.ts +4 -4
- package/src/core/math/complex/complex_div.d.ts.map +1 -1
- package/src/core/math/complex/complex_div.js +3 -3
- package/src/core/math/complex/complex_mul.d.ts +4 -4
- package/src/core/math/complex/complex_mul.d.ts.map +1 -1
- package/src/core/math/complex/complex_mul.js +3 -3
- package/src/core/math/complex/complex_sub.d.ts +4 -4
- package/src/core/math/complex/complex_sub.d.ts.map +1 -1
- package/src/core/math/complex/complex_sub.js +3 -3
- package/src/core/math/idct_1d.d.ts +4 -4
- package/src/core/math/idct_1d.d.ts.map +1 -1
- package/src/core/math/idct_1d.js +3 -3
- package/src/core/math/noise/create_simplex_noise_2d.d.ts.map +1 -1
- package/src/core/math/noise/create_simplex_noise_2d.js +4 -2
- package/src/core/math/noise/sdnoise.d.ts.map +1 -1
- package/src/core/math/noise/sdnoise.js +12 -9
- package/src/core/math/physics/mie/compute_bhmie_optical_properties.d.ts.map +1 -1
- package/src/core/math/physics/mie/compute_bhmie_optical_properties.js +94 -50
- package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts +3 -6
- package/src/core/math/physics/mie/lorenz_mie_coefs.d.ts.map +1 -1
- package/src/core/math/physics/mie/lorenz_mie_coefs.js +180 -157
- package/src/core/math/physics/mie/mie_ab_to_optical_properties.d.ts +3 -4
- package/src/core/math/physics/mie/mie_ab_to_optical_properties.d.ts.map +1 -1
- package/src/core/math/physics/mie/mie_ab_to_optical_properties.js +47 -21
- package/src/core/math/random/randomIntegerBetween.d.ts.map +1 -1
- package/src/core/math/random/randomIntegerBetween.js +4 -1
- package/src/core/math/solveCubic.d.ts.map +1 -1
- package/src/core/math/solveCubic.js +95 -82
- package/src/core/math/spline/computeCatmullRomSplineUniformDistance.d.ts.map +1 -1
- package/src/core/math/spline/computeCatmullRomSplineUniformDistance.js +13 -0
- package/src/core/math/statistics/softmax.js +1 -1
- package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts +1 -0
- package/src/core/model/node-graph/visual/NodeGraphVisualData.d.ts.map +1 -1
- package/src/core/model/node-graph/visual/NodeGraphVisualData.js +2 -1
- package/src/core/model/node-graph/visual/NodeVisualData.js +1 -1
- package/src/core/model/object/ImmutableObjectPool.d.ts +7 -0
- package/src/core/model/object/ImmutableObjectPool.d.ts.map +1 -1
- package/src/core/model/object/ImmutableObjectPool.js +20 -10
- package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.d.ts.map +1 -1
- package/src/core/model/reactive/evaluation/MultiPredicateEvaluator.js +39 -2
- package/src/core/model/reactive/model/terminal/ReactiveReference.d.ts.map +1 -1
- package/src/core/model/reactive/model/terminal/ReactiveReference.js +2 -0
- package/src/core/parser/simple/readHexToken.d.ts.map +1 -1
- package/src/core/parser/simple/readHexToken.js +6 -0
- package/src/core/primitives/numbers/number_pretty_print.d.ts.map +1 -1
- package/src/core/primitives/numbers/number_pretty_print.js +4 -1
- package/src/core/primitives/strings/string_jaro_winkler.js +1 -1
- package/src/core/process/CompositeProcess.js +1 -1
- package/src/core/process/action/AsynchronousDelayAction.d.ts.map +1 -1
- package/src/core/process/action/AsynchronousDelayAction.js +3 -0
- package/src/core/process/executor/ConcurrentExecutor.d.ts.map +1 -1
- package/src/core/process/executor/ConcurrentExecutor.js +3 -2
- package/src/core/process/task/util/randomCountTask.d.ts.map +1 -1
- package/src/core/process/task/util/randomCountTask.js +3 -1
- package/src/core/process/undo/ActionProcessor.d.ts.map +1 -1
- package/src/core/process/undo/ActionProcessor.js +5 -3
- package/src/core/process/worker/WorkerBuilder.js +3 -3
- package/src/engine/animation/curve/AnimationCurve.d.ts.map +1 -1
- package/src/engine/animation/curve/AnimationCurve.js +4 -2
- package/src/engine/control/first-person/DESIGN.md +1 -1
- package/src/engine/control/first-person/FirstPersonMotionPhase.d.ts +55 -0
- package/src/engine/control/first-person/FirstPersonMotionPhase.d.ts.map +1 -0
- package/src/engine/control/first-person/FirstPersonMotionPhase.js +134 -0
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts +23 -2
- package/src/engine/control/first-person/FirstPersonPlayerController.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerController.js +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts +168 -0
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerConfig.js +115 -0
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts +71 -0
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.d.ts.map +1 -1
- package/src/engine/control/first-person/FirstPersonPlayerControllerSystem.js +255 -55
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts +82 -43
- package/src/engine/control/first-person/abilities/LedgeGrab.d.ts.map +1 -1
- package/src/engine/control/first-person/abilities/LedgeGrab.js +405 -213
- package/src/engine/control/first-person/abilities/Mantle.d.ts +6 -0
- package/src/engine/control/first-person/abilities/Mantle.d.ts.map +1 -1
- package/src/engine/control/first-person/abilities/Mantle.js +104 -45
- package/src/engine/control/first-person/abilities/ScrambleUp.d.ts +61 -0
- package/src/engine/control/first-person/abilities/ScrambleUp.d.ts.map +1 -0
- package/src/engine/control/first-person/abilities/ScrambleUp.js +182 -0
- package/src/engine/control/first-person/math/jumpDynamics.d.ts +84 -0
- package/src/engine/control/first-person/math/jumpDynamics.d.ts.map +1 -0
- package/src/engine/control/first-person/math/jumpDynamics.js +108 -0
- package/src/engine/control/first-person/prototype_first_person_controller.js +45 -1
- package/src/engine/graphics/camera/testClippingPlaneComputation.js +1 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.d.ts.map +1 -1
- package/src/engine/graphics/ecs/decal/v2/FPDecalSystem.js +8 -0
- package/src/engine/graphics/ecs/path/tube/prototypeAnimatedPathMask.js +1 -1
- package/src/engine/graphics/particles/particular/engine/utils/volume/prototypeParticleVolume.js +1 -1
- package/src/engine/graphics/render/buffer/buffers/prototypeNormalFrameBuffer.js +1 -1
- package/src/engine/graphics/render/forward_plus/plugin/ptototypeFPPlugin.js +1 -1
- package/src/engine/graphics/render/visibility/hiz/prototypeHiZ.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/texture/sample_material.js +1 -1
- package/src/engine/graphics/shadows/testShadowMapRendering.js +1 -1
- package/src/engine/physics/CONSTRAINT_SOLVER_BENCH_LOG.md +208 -0
- package/src/engine/physics/CONSTRAINT_SOLVER_IMPROVEMENTS_PLAN.md +364 -0
- package/src/engine/physics/PLAN.md +6 -5
- 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 +147 -33
- package/src/engine/physics/ecs/PhysicsSystem.d.ts.map +1 -1
- package/src/engine/physics/ecs/PhysicsSystem.js +1750 -1747
- package/src/engine/physics/fluid/ecs/FluidSystem.d.ts +3 -3
- package/src/engine/physics/gjk/gjk_epa_penetration.d.ts +12 -8
- package/src/engine/physics/gjk/gjk_epa_penetration.d.ts.map +1 -1
- package/src/engine/physics/gjk/gjk_epa_penetration.js +447 -158
- package/src/engine/physics/narrowphase/convex_convex_manifold.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/convex_convex_manifold.js +22 -25
- package/src/engine/physics/narrowphase/convex_decomposition.d.ts +32 -13
- package/src/engine/physics/narrowphase/convex_decomposition.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/convex_decomposition.js +61 -65
- package/src/engine/physics/narrowphase/mesh_convex_hull.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/mesh_convex_hull.js +13 -8
- package/src/engine/physics/narrowphase/refine_ray_concave.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_concave.js +5 -3
- package/src/engine/physics/narrowphase/refine_ray_hit.d.ts.map +1 -1
- package/src/engine/physics/narrowphase/refine_ray_hit.js +81 -78
- package/src/engine/sound/SoundEngine.d.ts.map +1 -1
- package/src/engine/sound/SoundEngine.js +28 -0
- package/src/engine/sound/dB2Volume.d.ts +1 -1
- package/src/engine/sound/dB2Volume.d.ts.map +1 -1
- package/src/engine/sound/dB2Volume.js +1 -1
- package/src/engine/sound/ecs/SoundController.d.ts +4 -0
- package/src/engine/sound/ecs/SoundController.d.ts.map +1 -1
- package/src/engine/sound/ecs/SoundController.js +4 -0
- package/src/engine/sound/ecs/SoundControllerSystem.d.ts +5 -0
- package/src/engine/sound/ecs/SoundControllerSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/SoundControllerSystem.js +5 -0
- package/src/engine/sound/ecs/audio/AudioEmitter.d.ts +69 -0
- package/src/engine/sound/ecs/audio/AudioEmitter.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/AudioEmitter.js +83 -0
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts +97 -0
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/AudioEmitterSystem.js +238 -0
- package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts +90 -0
- package/src/engine/sound/ecs/audio/LiveEmitterSet.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/LiveEmitterSet.js +324 -0
- package/src/engine/sound/ecs/audio/SpatialAudioIndex.d.ts +59 -0
- package/src/engine/sound/ecs/audio/SpatialAudioIndex.d.ts.map +1 -0
- package/src/engine/sound/ecs/audio/SpatialAudioIndex.js +140 -0
- package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts +16 -65
- package/src/engine/sound/ecs/emitter/SoundEmitter.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitter.js +19 -224
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.d.ts +26 -29
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterComponentContext.js +168 -135
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts +36 -59
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterSystem.js +154 -390
- package/src/engine/sound/ecs/emitter/SoundTrack.d.ts +20 -23
- package/src/engine/sound/ecs/emitter/SoundTrack.d.ts.map +1 -1
- package/src/engine/sound/ecs/emitter/SoundTrack.js +34 -152
- package/src/engine/sound/sopra/IMPLEMENTATION_PLAN.md +993 -0
- package/src/engine/sound/sopra/README.md +643 -7
- package/src/engine/sound/sopra/SopraEngine.d.ts +229 -0
- package/src/engine/sound/sopra/SopraEngine.d.ts.map +1 -0
- package/src/engine/sound/sopra/SopraEngine.js +423 -0
- package/src/engine/sound/sopra/asset/AssetManagerBufferProvider.d.ts +26 -0
- package/src/engine/sound/sopra/asset/AssetManagerBufferProvider.d.ts.map +1 -0
- package/src/engine/sound/sopra/asset/AssetManagerBufferProvider.js +71 -0
- package/src/engine/sound/sopra/asset/BufferProvider.d.ts +24 -0
- package/src/engine/sound/sopra/asset/BufferProvider.d.ts.map +1 -0
- package/src/engine/sound/sopra/asset/BufferProvider.js +29 -0
- package/src/engine/sound/sopra/asset/StubBufferProvider.d.ts +31 -0
- package/src/engine/sound/sopra/asset/StubBufferProvider.d.ts.map +1 -0
- package/src/engine/sound/sopra/asset/StubBufferProvider.js +58 -0
- package/src/engine/sound/sopra/definition/BusDefinition.d.ts +83 -0
- package/src/engine/sound/sopra/definition/BusDefinition.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/BusDefinition.js +142 -0
- package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/BusDefinitionSerializationAdapter.js +54 -0
- package/src/engine/sound/sopra/definition/DuckingRule.d.ts +71 -0
- package/src/engine/sound/sopra/definition/DuckingRule.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/DuckingRule.js +106 -0
- package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/DuckingRuleSerializationAdapter.js +31 -0
- package/src/engine/sound/sopra/definition/EventDescription.d.ts +132 -0
- package/src/engine/sound/sopra/definition/EventDescription.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/EventDescription.js +259 -0
- package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/EventDescriptionSerializationAdapter.js +71 -0
- package/src/engine/sound/sopra/definition/MixerSnapshot.d.ts +51 -0
- package/src/engine/sound/sopra/definition/MixerSnapshot.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/MixerSnapshot.js +83 -0
- package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/MixerSnapshotSerializationAdapter.js +39 -0
- package/src/engine/sound/sopra/definition/ParameterDefinition.d.ts +72 -0
- package/src/engine/sound/sopra/definition/ParameterDefinition.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/ParameterDefinition.js +117 -0
- package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/ParameterDefinitionSerializationAdapter.js +31 -0
- package/src/engine/sound/sopra/definition/SopraPanningModel.d.ts +14 -0
- package/src/engine/sound/sopra/definition/SopraPanningModel.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/SopraPanningModel.js +20 -0
- package/src/engine/sound/sopra/definition/VoiceStealMode.d.ts +10 -0
- package/src/engine/sound/sopra/definition/VoiceStealMode.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/VoiceStealMode.js +18 -0
- package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts +93 -0
- package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/AbstractAudioClip.js +109 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts +80 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClip.js +181 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/BlendContainerAudioClipSerializationAdapter.js +74 -0
- package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.d.ts +34 -0
- package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/ContainerAudioClip.js +100 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts +101 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClip.js +230 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/RandomContainerAudioClipSerializationAdapter.js +54 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts +103 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClip.js +191 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SampleAudioClipSerializationAdapter.js +39 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts +40 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClip.js +91 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SequenceContainerAudioClipSerializationAdapter.js +42 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.d.ts +44 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClip.js +77 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SilenceAudioClipSerializationAdapter.js +27 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts +65 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClip.js +131 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.d.ts +17 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/clip/SwitchContainerAudioClipSerializationAdapter.js +41 -0
- package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.d.ts +24 -0
- package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/AbstractAudioEffect.js +24 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts +70 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffect.js +120 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/CompressorEffectSerializationAdapter.js +31 -0
- package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts +74 -0
- package/src/engine/sound/sopra/definition/effect/EqEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/EqEffect.js +128 -0
- package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/EqEffectSerializationAdapter.js +29 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffect.d.ts +49 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffect.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffect.js +101 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.d.ts +18 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.d.ts.map +1 -0
- package/src/engine/sound/sopra/definition/effect/ReverbEffectSerializationAdapter.js +25 -0
- package/src/engine/sound/sopra/legacy/soundEmitterToEventDescription.d.ts +31 -0
- package/src/engine/sound/sopra/legacy/soundEmitterToEventDescription.d.ts.map +1 -0
- package/src/engine/sound/sopra/legacy/soundEmitterToEventDescription.js +106 -0
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts +79 -0
- package/src/engine/sound/sopra/runtime/BusGraph.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/BusGraph.js +227 -0
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts +144 -0
- package/src/engine/sound/sopra/runtime/EventInstance.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/EventInstance.js +579 -0
- package/src/engine/sound/sopra/runtime/ParameterStore.d.ts +42 -0
- package/src/engine/sound/sopra/runtime/ParameterStore.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/ParameterStore.js +98 -0
- package/src/engine/sound/sopra/runtime/SopraPlaybackContext.d.ts +42 -0
- package/src/engine/sound/sopra/runtime/SopraPlaybackContext.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/SopraPlaybackContext.js +68 -0
- package/src/engine/sound/sopra/runtime/Voice.d.ts +67 -0
- package/src/engine/sound/sopra/runtime/Voice.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/Voice.js +145 -0
- package/src/engine/sound/sopra/runtime/VoiceManager.d.ts +38 -0
- package/src/engine/sound/sopra/runtime/VoiceManager.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/VoiceManager.js +136 -0
- package/src/engine/sound/sopra/runtime/VoicePool.d.ts +12 -0
- package/src/engine/sound/sopra/runtime/VoicePool.d.ts.map +1 -0
- package/src/engine/sound/sopra/runtime/VoicePool.js +17 -0
- package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.d.ts +11 -0
- package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.d.ts.map +1 -0
- package/src/engine/sound/sopra/serialization/populateSopraSerializationRegistry.js +42 -0
- package/src/engine/sound/sopra/serialization/sopraJSON.d.ts +33 -0
- package/src/engine/sound/sopra/serialization/sopraJSON.d.ts.map +1 -0
- package/src/engine/sound/sopra/serialization/sopraJSON.js +99 -0
- package/src/engine/sound/sopra/serialization/sopraSerializationHarness.d.ts +27 -0
- package/src/engine/sound/sopra/serialization/sopraSerializationHarness.d.ts.map +1 -0
- package/src/engine/sound/sopra/serialization/sopraSerializationHarness.js +49 -0
- package/src/engine/sound/sopra/util/MockAudioContext.d.ts +74 -0
- package/src/engine/sound/sopra/util/MockAudioContext.d.ts.map +1 -0
- package/src/engine/sound/sopra/util/MockAudioContext.js +215 -0
- package/src/engine/sound/sopra/util/buildAttenuationCurve.d.ts +15 -0
- package/src/engine/sound/sopra/util/buildAttenuationCurve.d.ts.map +1 -0
- package/src/engine/sound/sopra/util/buildAttenuationCurve.js +40 -0
- package/src/engine/sound/sopra/util/fadeOutAndStop.d.ts +34 -0
- package/src/engine/sound/sopra/util/fadeOutAndStop.d.ts.map +1 -0
- package/src/engine/sound/sopra/util/fadeOutAndStop.js +60 -0
- package/src/engine/sound/volume2dB.d.ts +1 -1
- package/src/engine/sound/volume2dB.d.ts.map +1 -1
- package/src/engine/sound/volume2dB.js +1 -1
- package/src/engine/graphics/sh3/path_tracer/sampling/v3_orthonormal_matrix_from_normal.d.ts.map +0 -1
- package/src/engine/physics/narrowphase/ray_shapes.d.ts +0 -66
- package/src/engine/physics/narrowphase/ray_shapes.d.ts.map +0 -1
- package/src/engine/physics/narrowphase/ray_shapes.js +0 -187
- package/src/engine/sound/ecs/emitter/SoundEmitterChannel.d.ts +0 -23
- package/src/engine/sound/ecs/emitter/SoundEmitterChannel.d.ts.map +0 -1
- package/src/engine/sound/ecs/emitter/SoundEmitterChannel.js +0 -32
- package/src/engine/sound/ecs/emitter/SoundTrackNodes.d.ts +0 -18
- package/src/engine/sound/ecs/emitter/SoundTrackNodes.d.ts.map +0 -1
- package/src/engine/sound/ecs/emitter/SoundTrackNodes.js +0 -18
- package/src/engine/sound/sopra/AbstractAudioClip.d.ts +0 -26
- package/src/engine/sound/sopra/AbstractAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/AbstractAudioClip.js +0 -29
- package/src/engine/sound/sopra/ContainerAudioClip.d.ts +0 -12
- package/src/engine/sound/sopra/ContainerAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/ContainerAudioClip.js +0 -13
- package/src/engine/sound/sopra/RandomContainerAudioClip.d.ts +0 -12
- package/src/engine/sound/sopra/RandomContainerAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/RandomContainerAudioClip.js +0 -15
- package/src/engine/sound/sopra/SequenceContainerAudioClip.d.ts +0 -7
- package/src/engine/sound/sopra/SequenceContainerAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/SequenceContainerAudioClip.js +0 -8
- package/src/engine/sound/sopra/SilenceAudioClip.d.ts +0 -13
- package/src/engine/sound/sopra/SilenceAudioClip.d.ts.map +0 -1
- package/src/engine/sound/sopra/SilenceAudioClip.js +0 -15
- /package/src/{engine/graphics/sh3/path_tracer/sampling → core/geom/vec3}/v3_orthonormal_matrix_from_normal.d.ts +0 -0
|
@@ -1,319 +1,325 @@
|
|
|
1
|
-
import { assert } from "../../assert.js";
|
|
2
|
-
import { is_typed_array_equals } from "../../collection/array/typed/is_typed_array_equals.js";
|
|
3
|
-
import { uint32_array_hash } from "../../collection/array/typed/uint32_array_hash.js";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Compressed Sparse Row representation of a weighted graph.
|
|
7
|
-
*
|
|
8
|
-
* The four parallel typed arrays — `edge_addresses`, `adjacency`,
|
|
9
|
-
* `edge_weights`, `vertex_weights` — share a single `ArrayBuffer` so that
|
|
10
|
-
* they are co-located in memory. This gives the allocator one allocation
|
|
11
|
-
* instead of four, the GC one reference to track, and the cache one
|
|
12
|
-
* contiguous region to prefetch when walking adjacency rows.
|
|
13
|
-
*
|
|
14
|
-
* Layout inside the buffer (all uint32, 4 bytes each):
|
|
15
|
-
* [0] edge_addresses, length vertex_count + 1
|
|
16
|
-
* [vertex_count + 1] adjacency, length adjacency_length
|
|
17
|
-
* [+adjacency_length] edge_weights, length adjacency_length
|
|
18
|
-
* [+adjacency_length] vertex_weights, length vertex_count
|
|
19
|
-
*
|
|
20
|
-
* Conventions match `mesh_to_metis_graph`:
|
|
21
|
-
* - `edge_addresses[v]` = start of vertex v's adjacency in `adjacency`
|
|
22
|
-
* - `edge_addresses[v + 1]` = end (exclusive)
|
|
23
|
-
* - `adjacency[k]` = neighbour vertex id
|
|
24
|
-
* - `edge_weights[k]` = weight of that edge
|
|
25
|
-
* - `vertex_weights[v]` = vertex weight (default 1)
|
|
26
|
-
*
|
|
27
|
-
* The class deliberately exposes the raw typed arrays as fields rather than
|
|
28
|
-
* via accessor methods. Hot loops in graph algorithms want
|
|
29
|
-
* `for (let k = xadj[v]; k < xadj[v+1]; k++) { ... adj[k] ... }` patterns; a
|
|
30
|
-
* callback-based iterator API would force a closure allocation per outer
|
|
31
|
-
* iteration and defeat V8's inlining.
|
|
32
|
-
*
|
|
33
|
-
* @author Alex Goldring
|
|
34
|
-
* @copyright Company Named Limited (c) 2026
|
|
35
|
-
*/
|
|
36
|
-
export class CSRGraph {
|
|
37
|
-
/**
|
|
38
|
-
* @param {number} vertex_count
|
|
39
|
-
* @param {number} adjacency_length total length of the adjacency list
|
|
40
|
-
* (each undirected edge appears twice for symmetric graphs)
|
|
41
|
-
*/
|
|
42
|
-
constructor(vertex_count, adjacency_length) {
|
|
43
|
-
assert.isNonNegativeInteger(vertex_count, 'vertex_count');
|
|
44
|
-
assert.isNonNegativeInteger(adjacency_length, 'adjacency_length');
|
|
45
|
-
|
|
46
|
-
/** @type {number} */
|
|
47
|
-
this.vertex_count = vertex_count;
|
|
48
|
-
/** @type {number} */
|
|
49
|
-
this.adjacency_length = adjacency_length;
|
|
50
|
-
|
|
51
|
-
// Total uint32 slots: (vertex_count + 1) for edge_addresses,
|
|
52
|
-
// adjacency_length × 2 for adjacency and edge_weights,
|
|
53
|
-
// vertex_count for vertex_weights.
|
|
54
|
-
const total_uint32_slots = (vertex_count + 1) + (adjacency_length * 2) + vertex_count;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Single backing buffer for all four arrays.
|
|
58
|
-
* @type {ArrayBuffer}
|
|
59
|
-
* @private
|
|
60
|
-
*/
|
|
61
|
-
this.__data_buffer = new ArrayBuffer(total_uint32_slots * 4);
|
|
62
|
-
|
|
63
|
-
let byte_offset = 0;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* CSR row pointers. Length = vertex_count + 1; the final entry equals
|
|
67
|
-
* adjacency_length.
|
|
68
|
-
* @type {Uint32Array}
|
|
69
|
-
*/
|
|
70
|
-
this.edge_addresses = new Uint32Array(this.__data_buffer, byte_offset, vertex_count + 1);
|
|
71
|
-
byte_offset += (vertex_count + 1) * 4;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* CSR column indices — neighbour vertex ids.
|
|
75
|
-
* @type {Uint32Array}
|
|
76
|
-
*/
|
|
77
|
-
this.adjacency = new Uint32Array(this.__data_buffer, byte_offset, adjacency_length);
|
|
78
|
-
byte_offset += adjacency_length * 4;
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Edge weights parallel to `adjacency`.
|
|
82
|
-
* @type {Uint32Array}
|
|
83
|
-
*/
|
|
84
|
-
this.edge_weights = new Uint32Array(this.__data_buffer, byte_offset, adjacency_length);
|
|
85
|
-
byte_offset += adjacency_length * 4;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Per-vertex weight. Initialised to all-1s; overwrite via direct
|
|
89
|
-
* indexing or `vertex_weights.set(...)` if your domain needs non-uniform
|
|
90
|
-
* weights. Remember to call `refresh_total_vertex_weight()` after.
|
|
91
|
-
* @type {Uint32Array}
|
|
92
|
-
*/
|
|
93
|
-
this.vertex_weights = new Uint32Array(this.__data_buffer, byte_offset, vertex_count);
|
|
94
|
-
this.vertex_weights.fill(1);
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Cached `Σ vertex_weights[v]`. Kept in sync via `refresh_total_vertex_weight()`.
|
|
98
|
-
* @type {number}
|
|
99
|
-
*/
|
|
100
|
-
this.total_vertex_weight = vertex_count;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* The underlying shared buffer. Useful for fast bulk operations and for
|
|
105
|
-
* passing the graph between Web Workers via transfer.
|
|
106
|
-
* @returns {ArrayBuffer}
|
|
107
|
-
*/
|
|
108
|
-
get arrayBuffer() {
|
|
109
|
-
return this.__data_buffer;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Degree of vertex `vertex` (number of outgoing edges in the CSR).
|
|
114
|
-
* @param {number} vertex
|
|
115
|
-
* @returns {number}
|
|
116
|
-
*/
|
|
117
|
-
degree_of(vertex) {
|
|
118
|
-
return this.edge_addresses[vertex + 1] - this.edge_addresses[vertex];
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Sum of all entries in `edge_weights[0..adjacency_length)`.
|
|
123
|
-
* Each undirected edge contributes twice for a symmetric graph.
|
|
124
|
-
* @returns {number}
|
|
125
|
-
*/
|
|
126
|
-
sum_of_edge_weights() {
|
|
127
|
-
const edge_weights = this.edge_weights;
|
|
128
|
-
const n = this.adjacency_length;
|
|
129
|
-
let sum = 0;
|
|
130
|
-
for (let i = 0; i < n; i++) {
|
|
131
|
-
sum += edge_weights[i];
|
|
132
|
-
}
|
|
133
|
-
return sum;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Recompute and store `total_vertex_weight` from the current `vertex_weights`.
|
|
138
|
-
*/
|
|
139
|
-
refresh_total_vertex_weight() {
|
|
140
|
-
const vertex_weights = this.vertex_weights;
|
|
141
|
-
const n = this.vertex_count;
|
|
142
|
-
let sum = 0;
|
|
143
|
-
for (let i = 0; i < n; i++) {
|
|
144
|
-
sum += vertex_weights[i];
|
|
145
|
-
}
|
|
146
|
-
this.total_vertex_weight = sum;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Shrink `adjacency` and `edge_weights` in place to `new_adjacency_length`.
|
|
151
|
-
*
|
|
152
|
-
* Use after a worst-case allocation has been partially filled (e.g. during
|
|
153
|
-
* coarse-graph contraction where the exact edge count is only known after
|
|
154
|
-
* the merge pass). Reallocates the shared buffer at the smaller size and
|
|
155
|
-
* recreates all four typed-array views; existing references to
|
|
156
|
-
* `this.adjacency` etc. are invalidated.
|
|
157
|
-
*
|
|
158
|
-
* Vertex-side data (`edge_addresses`, `vertex_weights`) and
|
|
159
|
-
* `total_vertex_weight` are preserved.
|
|
160
|
-
*
|
|
161
|
-
* No-op if `new_adjacency_length === adjacency_length`.
|
|
162
|
-
*
|
|
163
|
-
* @param {number} new_adjacency_length must be <= current `adjacency_length`
|
|
164
|
-
*/
|
|
165
|
-
truncate_adjacency(new_adjacency_length) {
|
|
166
|
-
assert.isNonNegativeInteger(new_adjacency_length, 'new_adjacency_length');
|
|
167
|
-
assert.lessThanOrEqual(new_adjacency_length, this.adjacency_length, 'truncate_adjacency cannot grow');
|
|
168
|
-
|
|
169
|
-
if (new_adjacency_length === this.adjacency_length) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
// Keep references to the OLD views — they remain valid because the old
|
|
174
|
-
// buffer stays alive until we drop the last reference to it (which
|
|
175
|
-
// happens implicitly when we reassign this.__data_buffer at the end).
|
|
176
|
-
// We can copy DIRECTLY from old views into new views with no
|
|
177
|
-
// intermediate snapshot, since the two buffers don't overlap.
|
|
178
|
-
const old_edge_addresses = this.edge_addresses;
|
|
179
|
-
const old_adjacency = this.adjacency;
|
|
180
|
-
const old_edge_weights = this.edge_weights;
|
|
181
|
-
const old_vertex_weights = this.vertex_weights;
|
|
182
|
-
|
|
183
|
-
const total_uint32_slots = (this.vertex_count + 1) + (new_adjacency_length * 2) + this.vertex_count;
|
|
184
|
-
const new_buffer = new ArrayBuffer(total_uint32_slots * 4);
|
|
185
|
-
|
|
186
|
-
let byte_offset = 0;
|
|
187
|
-
const new_edge_addresses = new Uint32Array(new_buffer, byte_offset, this.vertex_count + 1);
|
|
188
|
-
byte_offset += (this.vertex_count + 1) * 4;
|
|
189
|
-
const new_adjacency = new Uint32Array(new_buffer, byte_offset, new_adjacency_length);
|
|
190
|
-
byte_offset += new_adjacency_length * 4;
|
|
191
|
-
const new_edge_weights = new Uint32Array(new_buffer, byte_offset, new_adjacency_length);
|
|
192
|
-
byte_offset += new_adjacency_length * 4;
|
|
193
|
-
const new_vertex_weights = new Uint32Array(new_buffer, byte_offset, this.vertex_count);
|
|
194
|
-
|
|
195
|
-
// Direct old-view → new-view copies. `subarray` is a view, not a copy,
|
|
196
|
-
// so the only data movement is the underlying `.set()`.
|
|
197
|
-
new_edge_addresses.set(old_edge_addresses);
|
|
198
|
-
new_adjacency.set(old_adjacency.subarray(0, new_adjacency_length));
|
|
199
|
-
new_edge_weights.set(old_edge_weights.subarray(0, new_adjacency_length));
|
|
200
|
-
new_vertex_weights.set(old_vertex_weights);
|
|
201
|
-
|
|
202
|
-
this.__data_buffer = new_buffer;
|
|
203
|
-
this.edge_addresses = new_edge_addresses;
|
|
204
|
-
this.adjacency = new_adjacency;
|
|
205
|
-
this.edge_weights = new_edge_weights;
|
|
206
|
-
this.vertex_weights = new_vertex_weights;
|
|
207
|
-
this.adjacency_length = new_adjacency_length;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Copy the contents of `other` into `this`. Other must have matching
|
|
212
|
-
* `vertex_count` and `adjacency_length` (so the layouts align).
|
|
213
|
-
*
|
|
214
|
-
* Performed as a single bulk Uint32Array `.set()` thanks to the shared
|
|
215
|
-
* buffer layout — significantly faster than copying the four arrays
|
|
216
|
-
* individually.
|
|
217
|
-
*
|
|
218
|
-
* @param {CSRGraph} other
|
|
219
|
-
*/
|
|
220
|
-
copy(other) {
|
|
221
|
-
assert.equal(other.isCSRGraph, true, 'other.isCSRGraph !== true');
|
|
222
|
-
assert.equal(this.vertex_count, other.vertex_count, 'vertex_count mismatch');
|
|
223
|
-
assert.equal(this.adjacency_length, other.adjacency_length, 'adjacency_length mismatch');
|
|
224
|
-
|
|
225
|
-
new Uint32Array(this.__data_buffer).set(new Uint32Array(other.__data_buffer));
|
|
226
|
-
this.total_vertex_weight = other.total_vertex_weight;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Deep copy. Returns a new `CSRGraph` with independent buffers.
|
|
231
|
-
* @returns {CSRGraph}
|
|
232
|
-
*/
|
|
233
|
-
clone() {
|
|
234
|
-
const out = new CSRGraph(this.vertex_count, this.adjacency_length);
|
|
235
|
-
out.copy(this);
|
|
236
|
-
return out;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* Structural equality — same shape and same buffer contents.
|
|
241
|
-
* @param {CSRGraph} other
|
|
242
|
-
* @returns {boolean}
|
|
243
|
-
*/
|
|
244
|
-
equals(other) {
|
|
245
|
-
if (this === other) {
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
if (other === null || other === undefined || other.isCSRGraph !== true) {
|
|
249
|
-
return false;
|
|
250
|
-
}
|
|
251
|
-
if (this.vertex_count !== other.vertex_count) {
|
|
252
|
-
return false;
|
|
253
|
-
}
|
|
254
|
-
if (this.adjacency_length !== other.adjacency_length) {
|
|
255
|
-
return false;
|
|
256
|
-
}
|
|
257
|
-
if (this.total_vertex_weight !== other.total_vertex_weight) {
|
|
258
|
-
return false;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
*
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
h = ((h << 5) - h) +
|
|
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
|
-
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { is_typed_array_equals } from "../../collection/array/typed/is_typed_array_equals.js";
|
|
3
|
+
import { uint32_array_hash } from "../../collection/array/typed/uint32_array_hash.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Compressed Sparse Row representation of a weighted graph.
|
|
7
|
+
*
|
|
8
|
+
* The four parallel typed arrays — `edge_addresses`, `adjacency`,
|
|
9
|
+
* `edge_weights`, `vertex_weights` — share a single `ArrayBuffer` so that
|
|
10
|
+
* they are co-located in memory. This gives the allocator one allocation
|
|
11
|
+
* instead of four, the GC one reference to track, and the cache one
|
|
12
|
+
* contiguous region to prefetch when walking adjacency rows.
|
|
13
|
+
*
|
|
14
|
+
* Layout inside the buffer (all uint32, 4 bytes each):
|
|
15
|
+
* [0] edge_addresses, length vertex_count + 1
|
|
16
|
+
* [vertex_count + 1] adjacency, length adjacency_length
|
|
17
|
+
* [+adjacency_length] edge_weights, length adjacency_length
|
|
18
|
+
* [+adjacency_length] vertex_weights, length vertex_count
|
|
19
|
+
*
|
|
20
|
+
* Conventions match `mesh_to_metis_graph`:
|
|
21
|
+
* - `edge_addresses[v]` = start of vertex v's adjacency in `adjacency`
|
|
22
|
+
* - `edge_addresses[v + 1]` = end (exclusive)
|
|
23
|
+
* - `adjacency[k]` = neighbour vertex id
|
|
24
|
+
* - `edge_weights[k]` = weight of that edge
|
|
25
|
+
* - `vertex_weights[v]` = vertex weight (default 1)
|
|
26
|
+
*
|
|
27
|
+
* The class deliberately exposes the raw typed arrays as fields rather than
|
|
28
|
+
* via accessor methods. Hot loops in graph algorithms want
|
|
29
|
+
* `for (let k = xadj[v]; k < xadj[v+1]; k++) { ... adj[k] ... }` patterns; a
|
|
30
|
+
* callback-based iterator API would force a closure allocation per outer
|
|
31
|
+
* iteration and defeat V8's inlining.
|
|
32
|
+
*
|
|
33
|
+
* @author Alex Goldring
|
|
34
|
+
* @copyright Company Named Limited (c) 2026
|
|
35
|
+
*/
|
|
36
|
+
export class CSRGraph {
|
|
37
|
+
/**
|
|
38
|
+
* @param {number} vertex_count
|
|
39
|
+
* @param {number} adjacency_length total length of the adjacency list
|
|
40
|
+
* (each undirected edge appears twice for symmetric graphs)
|
|
41
|
+
*/
|
|
42
|
+
constructor(vertex_count, adjacency_length) {
|
|
43
|
+
assert.isNonNegativeInteger(vertex_count, 'vertex_count');
|
|
44
|
+
assert.isNonNegativeInteger(adjacency_length, 'adjacency_length');
|
|
45
|
+
|
|
46
|
+
/** @type {number} */
|
|
47
|
+
this.vertex_count = vertex_count;
|
|
48
|
+
/** @type {number} */
|
|
49
|
+
this.adjacency_length = adjacency_length;
|
|
50
|
+
|
|
51
|
+
// Total uint32 slots: (vertex_count + 1) for edge_addresses,
|
|
52
|
+
// adjacency_length × 2 for adjacency and edge_weights,
|
|
53
|
+
// vertex_count for vertex_weights.
|
|
54
|
+
const total_uint32_slots = (vertex_count + 1) + (adjacency_length * 2) + vertex_count;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Single backing buffer for all four arrays.
|
|
58
|
+
* @type {ArrayBuffer}
|
|
59
|
+
* @private
|
|
60
|
+
*/
|
|
61
|
+
this.__data_buffer = new ArrayBuffer(total_uint32_slots * 4);
|
|
62
|
+
|
|
63
|
+
let byte_offset = 0;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* CSR row pointers. Length = vertex_count + 1; the final entry equals
|
|
67
|
+
* adjacency_length.
|
|
68
|
+
* @type {Uint32Array}
|
|
69
|
+
*/
|
|
70
|
+
this.edge_addresses = new Uint32Array(this.__data_buffer, byte_offset, vertex_count + 1);
|
|
71
|
+
byte_offset += (vertex_count + 1) * 4;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* CSR column indices — neighbour vertex ids.
|
|
75
|
+
* @type {Uint32Array}
|
|
76
|
+
*/
|
|
77
|
+
this.adjacency = new Uint32Array(this.__data_buffer, byte_offset, adjacency_length);
|
|
78
|
+
byte_offset += adjacency_length * 4;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Edge weights parallel to `adjacency`.
|
|
82
|
+
* @type {Uint32Array}
|
|
83
|
+
*/
|
|
84
|
+
this.edge_weights = new Uint32Array(this.__data_buffer, byte_offset, adjacency_length);
|
|
85
|
+
byte_offset += adjacency_length * 4;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Per-vertex weight. Initialised to all-1s; overwrite via direct
|
|
89
|
+
* indexing or `vertex_weights.set(...)` if your domain needs non-uniform
|
|
90
|
+
* weights. Remember to call `refresh_total_vertex_weight()` after.
|
|
91
|
+
* @type {Uint32Array}
|
|
92
|
+
*/
|
|
93
|
+
this.vertex_weights = new Uint32Array(this.__data_buffer, byte_offset, vertex_count);
|
|
94
|
+
this.vertex_weights.fill(1);
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Cached `Σ vertex_weights[v]`. Kept in sync via `refresh_total_vertex_weight()`.
|
|
98
|
+
* @type {number}
|
|
99
|
+
*/
|
|
100
|
+
this.total_vertex_weight = vertex_count;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* The underlying shared buffer. Useful for fast bulk operations and for
|
|
105
|
+
* passing the graph between Web Workers via transfer.
|
|
106
|
+
* @returns {ArrayBuffer}
|
|
107
|
+
*/
|
|
108
|
+
get arrayBuffer() {
|
|
109
|
+
return this.__data_buffer;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Degree of vertex `vertex` (number of outgoing edges in the CSR).
|
|
114
|
+
* @param {number} vertex
|
|
115
|
+
* @returns {number}
|
|
116
|
+
*/
|
|
117
|
+
degree_of(vertex) {
|
|
118
|
+
return this.edge_addresses[vertex + 1] - this.edge_addresses[vertex];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Sum of all entries in `edge_weights[0..adjacency_length)`.
|
|
123
|
+
* Each undirected edge contributes twice for a symmetric graph.
|
|
124
|
+
* @returns {number}
|
|
125
|
+
*/
|
|
126
|
+
sum_of_edge_weights() {
|
|
127
|
+
const edge_weights = this.edge_weights;
|
|
128
|
+
const n = this.adjacency_length;
|
|
129
|
+
let sum = 0;
|
|
130
|
+
for (let i = 0; i < n; i++) {
|
|
131
|
+
sum += edge_weights[i];
|
|
132
|
+
}
|
|
133
|
+
return sum;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Recompute and store `total_vertex_weight` from the current `vertex_weights`.
|
|
138
|
+
*/
|
|
139
|
+
refresh_total_vertex_weight() {
|
|
140
|
+
const vertex_weights = this.vertex_weights;
|
|
141
|
+
const n = this.vertex_count;
|
|
142
|
+
let sum = 0;
|
|
143
|
+
for (let i = 0; i < n; i++) {
|
|
144
|
+
sum += vertex_weights[i];
|
|
145
|
+
}
|
|
146
|
+
this.total_vertex_weight = sum;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Shrink `adjacency` and `edge_weights` in place to `new_adjacency_length`.
|
|
151
|
+
*
|
|
152
|
+
* Use after a worst-case allocation has been partially filled (e.g. during
|
|
153
|
+
* coarse-graph contraction where the exact edge count is only known after
|
|
154
|
+
* the merge pass). Reallocates the shared buffer at the smaller size and
|
|
155
|
+
* recreates all four typed-array views; existing references to
|
|
156
|
+
* `this.adjacency` etc. are invalidated.
|
|
157
|
+
*
|
|
158
|
+
* Vertex-side data (`edge_addresses`, `vertex_weights`) and
|
|
159
|
+
* `total_vertex_weight` are preserved.
|
|
160
|
+
*
|
|
161
|
+
* No-op if `new_adjacency_length === adjacency_length`.
|
|
162
|
+
*
|
|
163
|
+
* @param {number} new_adjacency_length must be <= current `adjacency_length`
|
|
164
|
+
*/
|
|
165
|
+
truncate_adjacency(new_adjacency_length) {
|
|
166
|
+
assert.isNonNegativeInteger(new_adjacency_length, 'new_adjacency_length');
|
|
167
|
+
assert.lessThanOrEqual(new_adjacency_length, this.adjacency_length, 'truncate_adjacency cannot grow');
|
|
168
|
+
|
|
169
|
+
if (new_adjacency_length === this.adjacency_length) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Keep references to the OLD views — they remain valid because the old
|
|
174
|
+
// buffer stays alive until we drop the last reference to it (which
|
|
175
|
+
// happens implicitly when we reassign this.__data_buffer at the end).
|
|
176
|
+
// We can copy DIRECTLY from old views into new views with no
|
|
177
|
+
// intermediate snapshot, since the two buffers don't overlap.
|
|
178
|
+
const old_edge_addresses = this.edge_addresses;
|
|
179
|
+
const old_adjacency = this.adjacency;
|
|
180
|
+
const old_edge_weights = this.edge_weights;
|
|
181
|
+
const old_vertex_weights = this.vertex_weights;
|
|
182
|
+
|
|
183
|
+
const total_uint32_slots = (this.vertex_count + 1) + (new_adjacency_length * 2) + this.vertex_count;
|
|
184
|
+
const new_buffer = new ArrayBuffer(total_uint32_slots * 4);
|
|
185
|
+
|
|
186
|
+
let byte_offset = 0;
|
|
187
|
+
const new_edge_addresses = new Uint32Array(new_buffer, byte_offset, this.vertex_count + 1);
|
|
188
|
+
byte_offset += (this.vertex_count + 1) * 4;
|
|
189
|
+
const new_adjacency = new Uint32Array(new_buffer, byte_offset, new_adjacency_length);
|
|
190
|
+
byte_offset += new_adjacency_length * 4;
|
|
191
|
+
const new_edge_weights = new Uint32Array(new_buffer, byte_offset, new_adjacency_length);
|
|
192
|
+
byte_offset += new_adjacency_length * 4;
|
|
193
|
+
const new_vertex_weights = new Uint32Array(new_buffer, byte_offset, this.vertex_count);
|
|
194
|
+
|
|
195
|
+
// Direct old-view → new-view copies. `subarray` is a view, not a copy,
|
|
196
|
+
// so the only data movement is the underlying `.set()`.
|
|
197
|
+
new_edge_addresses.set(old_edge_addresses);
|
|
198
|
+
new_adjacency.set(old_adjacency.subarray(0, new_adjacency_length));
|
|
199
|
+
new_edge_weights.set(old_edge_weights.subarray(0, new_adjacency_length));
|
|
200
|
+
new_vertex_weights.set(old_vertex_weights);
|
|
201
|
+
|
|
202
|
+
this.__data_buffer = new_buffer;
|
|
203
|
+
this.edge_addresses = new_edge_addresses;
|
|
204
|
+
this.adjacency = new_adjacency;
|
|
205
|
+
this.edge_weights = new_edge_weights;
|
|
206
|
+
this.vertex_weights = new_vertex_weights;
|
|
207
|
+
this.adjacency_length = new_adjacency_length;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Copy the contents of `other` into `this`. Other must have matching
|
|
212
|
+
* `vertex_count` and `adjacency_length` (so the layouts align).
|
|
213
|
+
*
|
|
214
|
+
* Performed as a single bulk Uint32Array `.set()` thanks to the shared
|
|
215
|
+
* buffer layout — significantly faster than copying the four arrays
|
|
216
|
+
* individually.
|
|
217
|
+
*
|
|
218
|
+
* @param {CSRGraph} other
|
|
219
|
+
*/
|
|
220
|
+
copy(other) {
|
|
221
|
+
assert.equal(other.isCSRGraph, true, 'other.isCSRGraph !== true');
|
|
222
|
+
assert.equal(this.vertex_count, other.vertex_count, 'vertex_count mismatch');
|
|
223
|
+
assert.equal(this.adjacency_length, other.adjacency_length, 'adjacency_length mismatch');
|
|
224
|
+
|
|
225
|
+
new Uint32Array(this.__data_buffer).set(new Uint32Array(other.__data_buffer));
|
|
226
|
+
this.total_vertex_weight = other.total_vertex_weight;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Deep copy. Returns a new `CSRGraph` with independent buffers.
|
|
231
|
+
* @returns {CSRGraph}
|
|
232
|
+
*/
|
|
233
|
+
clone() {
|
|
234
|
+
const out = new CSRGraph(this.vertex_count, this.adjacency_length);
|
|
235
|
+
out.copy(this);
|
|
236
|
+
return out;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Structural equality — same shape and same buffer contents.
|
|
241
|
+
* @param {CSRGraph} other
|
|
242
|
+
* @returns {boolean}
|
|
243
|
+
*/
|
|
244
|
+
equals(other) {
|
|
245
|
+
if (this === other) {
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
if (other === null || other === undefined || other.isCSRGraph !== true) {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
if (this.vertex_count !== other.vertex_count) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
if (this.adjacency_length !== other.adjacency_length) {
|
|
255
|
+
return false;
|
|
256
|
+
}
|
|
257
|
+
if (this.total_vertex_weight !== other.total_vertex_weight) {
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
// Compare the logical regions, NOT the whole __data_buffer: the buffer may be over-allocated past
|
|
261
|
+
// adjacency_length (a documented, first-class state), and comparing the raw buffer would report two
|
|
262
|
+
// logically-equal graphs as unequal whenever their buffers differ in size or tail contents.
|
|
263
|
+
return is_typed_array_equals(this.edge_addresses, other.edge_addresses)
|
|
264
|
+
&& is_typed_array_equals(this.adjacency, other.adjacency)
|
|
265
|
+
&& is_typed_array_equals(this.edge_weights, other.edge_weights)
|
|
266
|
+
&& is_typed_array_equals(this.vertex_weights, other.vertex_weights);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* 32-bit hash mixing the metadata fields and the entire buffer contents.
|
|
271
|
+
* Uses meep's standard `(h*31 + element)` convention via `uint32_array_hash`.
|
|
272
|
+
*
|
|
273
|
+
* @returns {number}
|
|
274
|
+
*/
|
|
275
|
+
hash() {
|
|
276
|
+
let h = this.vertex_count;
|
|
277
|
+
h = ((h << 5) - h) + this.adjacency_length;
|
|
278
|
+
h = ((h << 5) - h) + this.total_vertex_weight;
|
|
279
|
+
// Hash the logical regions, NOT the whole __data_buffer (which may be over-allocated past
|
|
280
|
+
// adjacency_length); otherwise two logically-equal graphs with differently-sized buffers hash unequally.
|
|
281
|
+
h = ((h << 5) - h) + uint32_array_hash(this.edge_addresses, 0, this.edge_addresses.length);
|
|
282
|
+
h = ((h << 5) - h) + uint32_array_hash(this.adjacency, 0, this.adjacency.length);
|
|
283
|
+
h = ((h << 5) - h) + uint32_array_hash(this.edge_weights, 0, this.edge_weights.length);
|
|
284
|
+
h = ((h << 5) - h) + uint32_array_hash(this.vertex_weights, 0, this.vertex_weights.length);
|
|
285
|
+
return h | 0;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Construct a CSRGraph from existing arrays by COPYING into a new
|
|
290
|
+
* shared-buffer instance. The input arrays are not retained.
|
|
291
|
+
*
|
|
292
|
+
* `vertex_weights` is optional — if not provided, the new graph keeps the
|
|
293
|
+
* default all-1s vertex weights and `total_vertex_weight = vertex_count`.
|
|
294
|
+
*
|
|
295
|
+
* @param {number} vertex_count
|
|
296
|
+
* @param {ArrayLike<number>} edge_addresses length vertex_count + 1
|
|
297
|
+
* @param {ArrayLike<number>} adjacency length edge_addresses[vertex_count]
|
|
298
|
+
* @param {ArrayLike<number>} edge_weights parallel to adjacency
|
|
299
|
+
* @param {ArrayLike<number>} [vertex_weights] optional; length vertex_count
|
|
300
|
+
* @returns {CSRGraph}
|
|
301
|
+
*/
|
|
302
|
+
static fromArrays(vertex_count, edge_addresses, adjacency, edge_weights, vertex_weights) {
|
|
303
|
+
const adjacency_length = edge_addresses[vertex_count];
|
|
304
|
+
const out = new CSRGraph(vertex_count, adjacency_length);
|
|
305
|
+
|
|
306
|
+
out.edge_addresses.set(edge_addresses);
|
|
307
|
+
out.adjacency.set(adjacency);
|
|
308
|
+
out.edge_weights.set(edge_weights);
|
|
309
|
+
|
|
310
|
+
if (vertex_weights !== undefined) {
|
|
311
|
+
out.vertex_weights.set(vertex_weights);
|
|
312
|
+
out.refresh_total_vertex_weight();
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return out;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* Type-check marker — avoids `instanceof` across module realms while still
|
|
321
|
+
* letting us assert "is a CSRGraph" cheaply.
|
|
322
|
+
* @readonly
|
|
323
|
+
* @type {boolean}
|
|
324
|
+
*/
|
|
325
|
+
CSRGraph.prototype.isCSRGraph = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CircleLayout.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/layout/CircleLayout.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CircleLayout.d.ts","sourceRoot":"","sources":["../../../../../src/core/graph/layout/CircleLayout.js"],"names":[],"mappings":"AAmJA;;;;;GAKG;AACH,yCAJW,MAAM,EAAE,yBAER,OAAO,QAyEjB;AAsBD;;;;GAIG;AACH,kDAHW,MAAM,EAAE,UACR,OAAO,QAcjB;AA2TD,sGAsBC;AA4MD;;;;GAIG;AACH,8CAHW,MAAM,WACN,MAAM,EAAE,QAgBlB;AAED;;;;;GAKG;AACH,4CAJW,MAAM,EAAE,UACR,OAAO,YACP,MAAM,QAkBhB;AAED;;;;;GAKG;AACH,qDAJW,MAAM,WACN,MAAM,EAAE,GACP,MAAM,CA2EjB;mBA95BkB,gCAAgC;oBAK/B,uBAAuB"}
|