@woosh/meep-engine 2.37.18 → 2.38.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/core/assert.js +1 -1
- package/core/binary/float2uint8.js +8 -0
- package/core/binary/uint82float.js +8 -0
- package/core/bvh2/bvh3/ExplicitBinaryBoundingVolumeHierarchy.js +6 -4
- package/core/collection/array/array_get_index_in_range.js +16 -0
- package/core/collection/array/typed/isTypedArray.js +20 -0
- package/core/collection/array/typedArrayToDataType.js +1 -0
- package/{engine/navigation/grid → core/collection/heap}/BinaryHeap.js +6 -1
- package/{engine/navigation/grid → core/collection/heap}/FastBinaryHeap.js +3 -2
- package/{engine/navigation/grid → core/collection/heap}/FastBinaryHeap.spec.js +3 -3
- package/core/collection/heap/Uin32Heap.spec.js +59 -0
- package/core/collection/heap/Uint32Heap.js +385 -0
- package/core/collection/list/List.d.ts +1 -1
- package/core/collection/table/RowFirstTable.js +34 -0
- package/core/collection/table/RowFirstTable.spec.js +59 -1
- package/core/color/Color.js +83 -1
- package/core/color/YCbCr_to_rgb_uint24.js +3 -4
- package/core/color/hsv2rgb.js +4 -3
- package/core/color/linear_to_sRGB.js +4 -5
- package/core/color/rgb2hex.js +1 -1
- package/core/color/rgb2uint24.js +6 -4
- package/core/color/rgb_to_YCbCr_uint24.js +11 -13
- package/core/events/signal/Signal.d.ts +11 -9
- package/core/events/signal/Signal.spec.js +16 -0
- package/core/geom/2d/quad-tree/qt_collect_by_circle.js +67 -0
- package/core/geom/3d/topology/computeTopoMeshVertexDuplicates.js +9 -6
- package/core/geom/3d/topology/expandConnectivityByLocality.js +5 -5
- package/core/geom/3d/topology/query/query_edge_is_boundary.js +7 -0
- package/core/geom/3d/topology/query/query_edge_is_manifold.js +13 -0
- package/core/geom/3d/topology/query/query_edge_is_manifold_or_boundary.js +11 -0
- package/core/geom/3d/topology/query/query_edge_is_wire.js +13 -0
- package/core/geom/3d/topology/query/query_edge_other_vertex.js +20 -0
- package/core/geom/3d/topology/query/query_edge_share_vert.js +9 -0
- package/core/geom/3d/topology/query/query_face_get_other_edges.js +39 -0
- package/core/geom/3d/topology/query/query_face_next_vertex.js +19 -0
- package/core/geom/3d/topology/query/query_face_prev_vertex.js +18 -0
- package/core/geom/3d/topology/query/query_vertex_in_edge.js +14 -0
- package/core/geom/3d/topology/query/query_vertex_pair_share_face.js +24 -0
- package/core/geom/3d/topology/query/query_vertices_in_edge.js +19 -0
- package/core/geom/3d/topology/simplify/collapseEdge.spec.js +3 -5
- package/core/geom/3d/topology/simplify/collapse_all_degenerate_edges.js +8 -10
- package/core/geom/3d/topology/simplify/compute_face_normal_change_dot_product.js +12 -2
- package/core/geom/3d/topology/simplify/decimate_edge_collapse_snap.js +277 -0
- package/core/geom/3d/topology/simplify/edge_collapse_quadratic.js +126 -0
- package/core/geom/3d/topology/simplify/prototypeMeshSimplification.js +502 -0
- package/core/geom/3d/topology/simplify/quadratic/Quadratic3.js +37 -5
- package/core/geom/3d/topology/simplify/quadratic/build_vertex_quadratics.js +86 -1
- package/core/geom/3d/topology/simplify/simplifyTopoMesh.js +4 -4
- package/core/geom/3d/topology/simplify/simplifyTopoMesh2.js +119 -0
- package/core/geom/3d/topology/simplify/tm_edge_collapse_is_degenerate_flip.js +81 -0
- package/core/geom/3d/topology/{TopoEdge.js → struct/TopoEdge.js} +47 -20
- package/core/geom/3d/topology/{TopoEdge.spec.js → struct/TopoEdge.spec.js} +0 -0
- package/core/geom/3d/topology/{TopoMesh.js → struct/TopoMesh.js} +20 -41
- package/core/geom/3d/topology/{TopoTriangle.js → struct/TopoTriangle.js} +15 -25
- package/core/geom/3d/topology/{TopoVertex.js → struct/TopoVertex.js} +21 -4
- package/core/geom/3d/topology/{TopoVertex.spec.js → struct/TopoVertex.spec.js} +0 -0
- package/core/geom/3d/topology/tm_edge_kill.js +24 -0
- package/core/geom/3d/topology/tm_edge_splice.js +42 -0
- package/core/geom/3d/topology/tm_face_area.js +18 -0
- package/core/geom/3d/topology/tm_face_kill.js +12 -0
- package/core/geom/3d/topology/tm_face_normal.js +14 -0
- package/core/geom/3d/topology/tm_kill_only_edge.js +35 -0
- package/core/geom/3d/topology/tm_kill_only_face.js +12 -0
- package/core/geom/3d/topology/tm_kill_only_vert.js +14 -0
- package/core/geom/3d/topology/tm_vert_kill.js +19 -0
- package/core/geom/3d/topology/tm_vert_splice.js +64 -0
- package/core/geom/3d/topology/tm_vertex_compute_normal.js +42 -0
- package/core/geom/3d/topology/topoMeshToBufferGeometry.js +18 -4
- package/core/geom/3d/topology/weld_duplicate_vertices.js +63 -0
- package/core/geom/Quaternion.d.ts +21 -1
- package/core/geom/Quaternion.js +279 -200
- package/core/geom/Quaternion.spec.js +71 -2
- package/core/geom/Vector2.js +3 -3
- package/core/geom/Vector3.d.ts +2 -0
- package/core/geom/Vector3.js +31 -7
- package/core/geom/Vector3.schema.json +16 -0
- package/core/geom/Vector4.js +16 -0
- package/core/geom/packing/MaxRectangles.js +1 -1
- package/core/graph/cluster_mesh_metis.js +16 -0
- package/core/graph/coarsen_graph.js +1 -1
- package/core/graph/graph_k_means_cluster.js +1 -1
- package/core/json/JsonUtils.js +2 -20
- package/core/math/bell_membership_function.js +19 -0
- package/core/math/exp2.js +8 -0
- package/core/math/interval/NumericInterval.js +17 -0
- package/core/math/physics/brdf/brdf_burley.js +25 -0
- package/core/math/physics/bsdf/bsdf_schlick.js +22 -0
- package/core/math/physics/irradiance/interpolate_irradiance_linear.js +18 -0
- package/{engine/sound/ecs/emitter/attenuate/attenuateSoundLogarithmic.js → core/math/physics/irradiance/interpolate_irradiance_lograrithmic.js} +2 -2
- package/{engine/sound/ecs/emitter/attenuate/attenuateSoundSmith.js → core/math/physics/irradiance/interpolate_irradiance_smith.js} +1 -1
- package/core/math/random/seededRandom.js +2 -31
- package/core/math/random/seededRandom_Mulberry32.js +31 -0
- package/core/math/random/seededRandom_sine.js +33 -0
- package/core/model/ObservedEnum.js +8 -0
- package/editor/Editor.js +97 -1
- package/editor/actions/concrete/ModifyPatchSampler2DAction.js +118 -0
- package/editor/actions/concrete/ModifyPatchSampler2DAction.spec.js +30 -0
- package/editor/actions/concrete/PatchTerrainHeightAction.js +13 -105
- package/editor/ecs/component/FieldDescriptor.js +34 -0
- package/editor/ecs/component/FieldValueAdapter.js +20 -0
- package/editor/ecs/component/TypeEditor.js +33 -0
- package/editor/ecs/component/TypeSchema.d.ts +38 -0
- package/editor/ecs/component/createFieldEditor.js +90 -0
- package/editor/ecs/component/createObjectEditor.js +266 -60
- package/editor/ecs/component/editors/ColorEditor.js +39 -0
- package/editor/ecs/component/editors/HTMLElementEditor.js +17 -0
- package/editor/ecs/component/editors/ImagePathEditor.js +50 -0
- package/editor/ecs/component/editors/NumericIntervalEditor.js +86 -0
- package/editor/ecs/component/editors/ObservedBooleanEditor.js +13 -0
- package/editor/ecs/component/editors/ObservedEnumEditor.js +32 -0
- package/editor/ecs/component/editors/ObservedIntegerEditor.js +43 -0
- package/editor/ecs/component/editors/ObservedStringEditor.js +51 -0
- package/editor/ecs/component/editors/Sampler2DEditor.js +107 -0
- package/editor/ecs/component/editors/collection/ListEditor.js +83 -0
- package/editor/ecs/component/editors/common/BitFlagsEditor.js +80 -0
- package/editor/ecs/component/editors/common/EnumEditor.js +41 -0
- package/editor/ecs/component/editors/common/makeV3_editor.js +85 -0
- package/editor/ecs/component/editors/common/noEditor.js +9 -0
- package/editor/ecs/component/editors/ecs/GridObstacleEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/MinimapMarkerEditor.js +16 -0
- package/editor/ecs/component/editors/ecs/ParameterLookupTableEditor.js +44 -0
- package/editor/ecs/component/editors/ecs/ParameterTrackEditor.js +17 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterEditor.js +58 -0
- package/editor/ecs/component/editors/ecs/ParticleEmitterLayerEditor.js +54 -0
- package/editor/ecs/component/editors/ecs/SimulationStepDefinitionEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/Trail2DEditor.js +33 -0
- package/editor/ecs/component/editors/ecs/TransformEditor.js +23 -0
- package/editor/ecs/component/editors/ecs/terrain/SplatMappingEditor.js +21 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainEditor.js +89 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayerEditor.js +18 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainLayersEditor.js +22 -0
- package/editor/ecs/component/editors/ecs/terrain/TerrainOverlayEditor.js +20 -0
- package/editor/ecs/component/editors/geom/QuaternionEditor.js +56 -0
- package/editor/ecs/component/editors/geom/Vector1Editor.js +57 -0
- package/editor/ecs/component/editors/geom/Vector2Editor.js +11 -0
- package/editor/ecs/component/editors/geom/Vector3Editor.js +13 -0
- package/editor/ecs/component/editors/geom/Vector4Editor.js +12 -0
- package/editor/ecs/component/editors/primitive/ArrayEditor.js +46 -0
- package/editor/ecs/component/editors/primitive/BooleanEditor.js +27 -0
- package/editor/ecs/component/editors/primitive/FunctionEditor.js +29 -0
- package/editor/ecs/component/editors/primitive/NumberEditor.js +60 -0
- package/editor/ecs/component/editors/primitive/ObjectEditor.js +12 -0
- package/editor/ecs/component/editors/primitive/StringEditor.js +31 -0
- package/editor/ecs/component/editors/three/BufferGeometryEditor.js +28 -0
- package/editor/ecs/component/editors/three/MaterialEditor.js +27 -0
- package/editor/ecs/component/editors/three/MeshEditor.js +35 -0
- package/editor/ecs/component/editors/three/TextureEditor.js +32 -0
- package/editor/ecs/component/findNearestRegisteredType.js +59 -0
- package/editor/ecs/component/prototypeObjectEditor.js +379 -0
- package/editor/tools/SelectionTool.js +1 -1
- package/editor/tools/paint/TerrainHeightPaintTool.js +88 -68
- package/editor/tools/paint/TerrainPaintTool.js +2 -1
- package/editor/tools/paint/TerrainTexturePaintTool.js +8 -73
- package/editor/view/EditorView.js +1 -1
- package/editor/view/ecs/ComponentControlView.js +2 -30
- package/editor/view/ecs/EntityEditor.js +61 -139
- package/editor/view/ecs/components/GridObstacleController.js +4 -4
- package/editor/view/ecs/components/TerrainController.js +1 -1
- package/editor/view/ecs/components/common/NumberController.js +19 -7
- package/editor/view/node-graph/NodeGraphView.js +2 -2
- package/editor/view/node-graph/NodeView.js +7 -9
- package/engine/animation/keyed2/AnimationTrack.js +1 -1
- package/engine/asset/AssetManager.d.ts +1 -1
- package/engine/asset/AssetManager.js +390 -388
- package/engine/asset/loaders/gltf/extensions/MSFT_texture_dds.js +14 -2
- package/engine/ecs/components/TagEditor.js +15 -0
- package/engine/ecs/fow/FogOfWarEditor.js +13 -0
- package/engine/ecs/parent/ParentEntitySystem.js +57 -0
- package/engine/ecs/terrain/ecs/OffsetScaleTransform2D.d.ts +6 -0
- package/engine/ecs/terrain/ecs/Terrain.js +44 -43
- package/engine/ecs/terrain/ecs/TerrainSystem.js +2 -2
- package/engine/ecs/terrain/ecs/layers/TerrainLayer.js +1 -1
- package/engine/ecs/terrain/ecs/splat/SplatMapping.js +26 -28
- package/engine/ecs/terrain/overlay/TerrainOverlay.js +71 -66
- package/engine/ecs/terrain/tiles/TerrainTileManager.js +23 -0
- package/engine/ecs/terrain/util/loadVisibleTerrainTiles.js +1 -1
- package/engine/ecs/terrain/util/paintTerrainOverlayViaLookupTable.js +13 -7
- package/engine/ecs/terrain/util/tensionOptimizeUV.js +1 -1
- package/engine/ecs/transform/Transform.d.ts +2 -0
- package/engine/ecs/transform/Transform.editor.schema.json +16 -0
- package/engine/ecs/transform/Transform.js +3 -0
- package/engine/graphics/ecs/highlight/HighlightEditor.js +17 -0
- package/engine/graphics/ecs/light/Light.js +0 -47
- package/engine/graphics/ecs/light/LightSerializationAdapter.js +50 -0
- package/engine/graphics/ecs/mesh/MeshEditor.js +28 -0
- package/engine/graphics/ecs/mesh-v2/DrawMode.js +2 -1
- package/engine/graphics/ecs/mesh-v2/aggregate/prototypeSGMesh.js +3 -3
- package/engine/graphics/ecs/mesh-v2/build_three_object.js +3 -1
- package/engine/graphics/ecs/mesh-v2/sg_compute_hierarchy_bounding_box_by_parent_entity.js +31 -0
- package/engine/graphics/ecs/mesh-v2/sg_hierarchy_compute_bounding_box_via_parent_entity.d.ts +4 -0
- package/engine/graphics/ecs/sprite/Sprite.js +11 -0
- package/engine/graphics/ecs/sprite/SpriteSystemPE.js +133 -0
- package/engine/graphics/ecs/sprite/prototypeSpriteSystem.js +1570 -0
- package/engine/graphics/micron/build/PatchRepresentation.js +7 -3
- package/engine/graphics/micron/build/buildMicronGeometryFromBufferGeometry.js +18 -8
- package/engine/graphics/micron/build/clustering/build_clustering_2.js +1 -1
- package/engine/graphics/micron/build/clustering/build_leaf_patches.js +2 -2
- package/engine/graphics/micron/build/clustering/build_leaf_patches_metis.js +1 -1
- package/engine/graphics/micron/build/hierarchy/buildAbstractPatchHierarchy.js +21 -3
- package/engine/graphics/micron/build/hierarchy/merge_patches.js +96 -43
- package/engine/graphics/micron/build/hierarchy/qvdr_build_simplified_clusters.js +11 -5
- package/engine/graphics/micron/format/VirtualGeometry.js +46 -3
- package/engine/graphics/micron/format/micron_build_proxy_geometry.js +4 -2
- package/engine/graphics/micron/prototypeVirtualGeometry.js +47 -10
- package/engine/graphics/micron/render/instanced/shader/shader_rewrite_standard.js +17 -17
- package/engine/graphics/micron/render/refinement/get_geometry_patch_cut.js +15 -3
- package/engine/graphics/micron/simplifyGeometry.js +1 -1
- package/engine/graphics/particles/particular/engine/ParticularEngine.js +5 -0
- package/engine/graphics/particles/particular/engine/emitter/ParticleLayer.js +17 -9
- package/engine/graphics/particles/particular/engine/renderers/ParticleRenderer.js +12 -10
- package/engine/graphics/particles/particular/engine/renderers/billboard/ParticleBillboardMaterial.js +7 -2
- package/engine/graphics/particles/particular/engine/renderers/billboard/SoftBillboardParticlePool.js +27 -0
- package/engine/graphics/particles/particular/engine/renderers/billboard/SoftBillboardParticleRenderer.js +80 -0
- package/engine/graphics/particles/particular/engine/shader/ShaderManager.js +16 -4
- package/engine/graphics/shaders/TerrainShader.js +8 -8
- package/engine/graphics/texture/atlas/TextureAtlasDebugger.js +2 -1
- package/engine/graphics/texture/sampler/Sampler2D.js +206 -201
- package/engine/graphics/texture/sampler/Sampler2D.spec.js +34 -35
- package/engine/graphics/texture/sampler/bicubic.js +59 -0
- package/engine/graphics/texture/sampler/downsampleSample2D.spec.js +2 -2
- package/engine/graphics/texture/sampler/genericResampleSampler2D.js +0 -2
- package/engine/graphics/texture/sampler/prototypeSamplerFiltering.js +146 -0
- package/engine/graphics/texture/sampler/{downsampleSampler2D.js → sampler2D_scale_down_linear.js} +8 -4
- package/engine/graphics/texture/sampler/sampler2_d_scale_down_lanczos.js +140 -0
- package/engine/graphics/texture/sampler/scaleSampler2D.js +3 -3
- package/engine/graphics/texture/sampler/writeSampler2DDataToDataTexture.js +1 -1
- package/engine/graphics/util/ScaleObject3ToBox.js +14 -1
- package/engine/graphics/util/makeMeshPreviewScene.js +2 -1
- package/engine/grid/components/GridObstacle.js +0 -44
- package/engine/grid/components/GridObstacleSerializationAdapter.js +46 -0
- package/engine/input/devices/PointerDevice.d.ts +1 -1
- package/engine/input/devices/PointerDevice.js +17 -2
- package/engine/input/ecs/util/TerrainCameraTargetSampler.js +2 -2
- package/engine/navigation/ecs/components/Path.d.ts +2 -0
- package/engine/navigation/ecs/components/Path.js +6 -1
- package/engine/navigation/ecs/components/computeNonuniformCatmullRomSplineSample.js +117 -0
- package/engine/navigation/grid/AStar.js +1 -1
- package/engine/navigation/grid/GridField.js +3 -2
- package/engine/platform/GetURLHash.js +27 -0
- package/engine/platform/WebEnginePlatform.js +1 -22
- package/engine/sound/ecs/emitter/SoundEmitter.js +10 -6
- package/engine/ui/DraggableAspect.js +2 -2
- package/generation/GridGenerator.js +7 -6
- package/generation/example/SampleGenerator0.js +39 -35
- package/generation/example/filters/SampleGroundMoistureFilter.js +58 -17
- package/generation/example/generators/interactive/mir_generator_place_buff_objects.js +7 -6
- package/generation/example/generators/mir_generator_place_bases.js +7 -3
- package/generation/example/generators/mir_generator_place_road_decorators.js +3 -3
- package/generation/example/generators/mir_generator_place_starting_point.js +3 -2
- package/generation/example/themes/SampleTheme0.js +11 -7
- package/generation/filtering/numeric/CellFilterLiteralFloat.js +5 -0
- package/generation/filtering/numeric/complex/CellFilterDilate.js +36 -0
- package/generation/filtering/numeric/complex/CellFilterGaussianBlur.js +15 -5
- package/generation/filtering/numeric/complex/CellFilterSimplexNoise.js +53 -1
- package/generation/filtering/numeric/math/CellFilterMax2.js +3 -0
- package/generation/filtering/numeric/math/CellFilterMembershipGeneralizedBell.js +55 -0
- package/generation/filtering/numeric/sampling/AbstractCellFilterSampleGridLayer.js +42 -0
- package/generation/filtering/numeric/sampling/CellFilterSampleLayerCubic.js +36 -0
- package/generation/filtering/numeric/sampling/CellFilterSampleLayerLinear.js +41 -0
- package/generation/grid/GridData.d.ts +5 -1
- package/generation/grid/GridData.js +35 -36
- package/generation/grid/MarkerMatchCounter.js +5 -3
- package/generation/grid/generation/discrete/GridTaskConnectRooms.js +1 -1
- package/generation/grid/generation/discrete/layer/GridTaskBuildSourceDistanceMap.js +1 -1
- package/generation/grid/generation/discrete/layer/GridTaskDistanceToMarkers.js +1 -1
- package/generation/grid/generation/road/GridTaskGenerateRoads.js +1 -1
- package/generation/markers/GridActionRuleSet.js +15 -32
- package/generation/markers/GridCellActionPlaceMarker.js +12 -8
- package/generation/markers/debug/visualizeMarkers.js +56 -36
- package/generation/markers/emitter/MarkerNodeEmitterFromAction.js +8 -8
- package/generation/markers/prototypeGridCellActionPlaceMarker.js +209 -0
- package/generation/markers/transform/MarkerNodeTransformerOffsetPosition.js +1 -5
- package/generation/markers/transform/MarkerNodeTransformerYRotateByFilterGradient.spec.js +2 -2
- package/generation/placement/GridCellPlacementRule.js +31 -25
- package/generation/theme/ThemeEngine.js +1 -1
- package/package.json +1 -1
- package/samples/terrain/from_image.js +7 -3
- package/samples/terrain/main.js +1 -1
- package/view/View.js +23 -1
- package/view/common/LabelView.js +1 -1
- package/view/compose3x3transform.js +32 -8
- package/view/controller/dat/DatGuiUtils.js +1 -1
- package/view/elements/DropDownSelectionView.js +11 -3
- package/view/elements/image/ImageView.js +3 -1
- package/core/model/ObservedReal.js +0 -55
- package/editor/ecs/component/ObjectEditor.js +0 -0
- package/engine/graphics/particles/particular/engine/renderers/SoftBillboardParticleRenderer.js +0 -7
- package/engine/sound/ecs/emitter/attenuate/attenuateSoundLinear.js +0 -11
- package/generation/filtering/numeric/CellFilterReadGridLayer.js +0 -73
package/core/assert.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isTypedArray } from "./json/JsonUtils.js";
|
|
2
1
|
import { isArrayEqualStrict } from "./collection/array/isArrayEqualStrict.js";
|
|
2
|
+
import { isTypedArray } from "./collection/array/typed/isTypedArray.js";
|
|
3
3
|
|
|
4
4
|
function equal(a, b, m) {
|
|
5
5
|
assert(a === b, m) // eslint-disable-line eqeqeq
|
|
@@ -619,20 +619,22 @@ export class ExplicitBinaryBoundingVolumeHierarchy {
|
|
|
619
619
|
while (index !== NULL_NODE) {
|
|
620
620
|
index = this.balance(index);
|
|
621
621
|
|
|
622
|
-
const
|
|
623
|
-
|
|
622
|
+
const node_address = index * ELEMENT_WORD_COUNT;
|
|
623
|
+
|
|
624
|
+
const child1 = uint32[node_address + COLUMN_CHILD_1];
|
|
625
|
+
const child2 = uint32[node_address + COLUMN_CHILD_2];
|
|
624
626
|
|
|
625
627
|
assert.notEqual(child1, NULL_NODE, 'child1 is null');
|
|
626
628
|
assert.notEqual(child2, NULL_NODE, 'child2 is null');
|
|
627
629
|
|
|
628
|
-
uint32[
|
|
630
|
+
uint32[node_address + COLUMN_HEIGHT] = 1 + max2(
|
|
629
631
|
uint32[child1 * ELEMENT_WORD_COUNT + COLUMN_HEIGHT],
|
|
630
632
|
uint32[child2 * ELEMENT_WORD_COUNT + COLUMN_HEIGHT],
|
|
631
633
|
);
|
|
632
634
|
|
|
633
635
|
this.node_set_combined_aabb(index, child1, child2);
|
|
634
636
|
|
|
635
|
-
index = uint32[
|
|
637
|
+
index = uint32[node_address + COLUMN_PARENT];
|
|
636
638
|
}
|
|
637
639
|
}
|
|
638
640
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @template T
|
|
3
|
+
* @param {T[]} array
|
|
4
|
+
* @param {T} needle
|
|
5
|
+
* @param {number} min_index
|
|
6
|
+
* @param {number} max_index
|
|
7
|
+
*/
|
|
8
|
+
export function array_get_index_in_range(array, needle, min_index, max_index) {
|
|
9
|
+
for (let i = min_index; i <= max_index; i++) {
|
|
10
|
+
if (array[i] === needle) {
|
|
11
|
+
return i;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return -1;
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param o
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
function isTypedArray(o) {
|
|
7
|
+
return (
|
|
8
|
+
o instanceof Int8Array ||
|
|
9
|
+
o instanceof Uint8Array ||
|
|
10
|
+
o instanceof Uint8ClampedArray ||
|
|
11
|
+
o instanceof Int16Array ||
|
|
12
|
+
o instanceof Uint16Array ||
|
|
13
|
+
o instanceof Int32Array ||
|
|
14
|
+
o instanceof Uint32Array ||
|
|
15
|
+
o instanceof Float32Array ||
|
|
16
|
+
o instanceof Float64Array
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export { isTypedArray };
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated use {@link FastBinaryHeap} instead
|
|
3
|
+
* @param scoreFunction
|
|
4
|
+
* @constructor
|
|
5
|
+
*/
|
|
1
6
|
function BinaryHeap(scoreFunction) {
|
|
2
7
|
this.content = [];
|
|
3
8
|
this.hash = [];
|
|
@@ -99,7 +104,7 @@ BinaryHeap.prototype = {
|
|
|
99
104
|
element = content[n],
|
|
100
105
|
elemScore = scoreFunction(element);
|
|
101
106
|
|
|
102
|
-
for (
|
|
107
|
+
for (; ;) {
|
|
103
108
|
// Compute the indices of the child elements.
|
|
104
109
|
const child2N = (n + 1) << 1,
|
|
105
110
|
child1N = child2N - 1;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { assert } from "
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Min-Heap implementation with a score function. The data structure is a binary heap where elements are removed in order defined by scoring function
|
|
@@ -6,7 +6,8 @@ import { assert } from "../../../core/assert.js";
|
|
|
6
6
|
*/
|
|
7
7
|
class BinaryHeap {
|
|
8
8
|
/**
|
|
9
|
-
* @
|
|
9
|
+
* @template T
|
|
10
|
+
* @param {function(el:T):number} scoreFunction
|
|
10
11
|
* @constructor
|
|
11
12
|
*/
|
|
12
13
|
constructor(scoreFunction) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { seededRandom } from "
|
|
1
|
+
import { seededRandom } from "../../math/random/seededRandom.js";
|
|
2
2
|
import BinaryHeap from "./FastBinaryHeap.js";
|
|
3
|
-
import { passThrough, returnZero } from "
|
|
4
|
-
import { randomIntegerBetween } from "
|
|
3
|
+
import { passThrough, returnZero } from "../../function/Functions.js";
|
|
4
|
+
import { randomIntegerBetween } from "../../math/random/randomIntegerBetween.js";
|
|
5
5
|
|
|
6
6
|
test("constructor doesn't throw", () => {
|
|
7
7
|
new BinaryHeap(returnZero);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Uint32Heap } from "./Uint32Heap.js";
|
|
2
|
+
|
|
3
|
+
test('initial capacity setting via constructor', () => {
|
|
4
|
+
const heap = new Uint32Heap(3);
|
|
5
|
+
|
|
6
|
+
expect(heap.capacity).toBe(3);
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
test('heap capacity grows as needed', () => {
|
|
10
|
+
const heap = new Uint32Heap(0);
|
|
11
|
+
|
|
12
|
+
heap.insert(1, 1);
|
|
13
|
+
|
|
14
|
+
expect(heap.capacity).toBeGreaterThanOrEqual(1);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('initial heap size is 0', () => {
|
|
18
|
+
const heap = new Uint32Heap();
|
|
19
|
+
|
|
20
|
+
expect(heap.size).toBe(0);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('insert operation increases size by 1', () => {
|
|
24
|
+
const heap = new Uint32Heap();
|
|
25
|
+
|
|
26
|
+
const s0 = heap.size;
|
|
27
|
+
|
|
28
|
+
heap.insert(0, 0);
|
|
29
|
+
|
|
30
|
+
expect(heap.size).toBe(s0 + 1);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test('pop operation reduces size by 1', () => {
|
|
34
|
+
const heap = new Uint32Heap();
|
|
35
|
+
|
|
36
|
+
heap.insert(0, 0);
|
|
37
|
+
|
|
38
|
+
const s0 = heap.size;
|
|
39
|
+
|
|
40
|
+
heap.pop_min();
|
|
41
|
+
|
|
42
|
+
expect(heap.size).toBe(s0 - 1);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test('insert 5 out of order, retrieve in order', () => {
|
|
46
|
+
const heap = new Uint32Heap();
|
|
47
|
+
|
|
48
|
+
heap.insert(3, 4);
|
|
49
|
+
heap.insert(5, 5);
|
|
50
|
+
heap.insert(7, 2);
|
|
51
|
+
heap.insert(11, 3);
|
|
52
|
+
heap.insert(13, 1);
|
|
53
|
+
|
|
54
|
+
expect(heap.pop_min()).toBe(13);
|
|
55
|
+
expect(heap.pop_min()).toBe(7);
|
|
56
|
+
expect(heap.pop_min()).toBe(11);
|
|
57
|
+
expect(heap.pop_min()).toBe(3);
|
|
58
|
+
expect(heap.pop_min()).toBe(5);
|
|
59
|
+
});
|
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
import { assert } from "../../assert.js";
|
|
2
|
+
import { max2 } from "../../math/max2.js";
|
|
3
|
+
|
|
4
|
+
const UINT32_MAX = 4294967295;
|
|
5
|
+
|
|
6
|
+
const DEFAULT_CAPACITY = 64;
|
|
7
|
+
const ELEMENT_BYTE_SIZE = 8;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* % to increase capacity by when growing
|
|
11
|
+
* NOTE: Must be greater than 1
|
|
12
|
+
* @type {number}
|
|
13
|
+
*/
|
|
14
|
+
const RESIZE_GROW_FACTOR = 1.2;
|
|
15
|
+
/**
|
|
16
|
+
* Minimum number of elements to expand the size by when growing
|
|
17
|
+
* NOTE: Must be an integer
|
|
18
|
+
* NOTE: Must be greater than 0
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
const RESIZE_GROW_MIN_COUNT = 16;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {number} i
|
|
26
|
+
* @returns {number}
|
|
27
|
+
*/
|
|
28
|
+
function HEAP_PARENT(i) {
|
|
29
|
+
return ((i) - 1) >> 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param {number} i
|
|
35
|
+
* @returns {number}
|
|
36
|
+
*/
|
|
37
|
+
function HEAP_LEFT(i) {
|
|
38
|
+
return ((i) << 1) + 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* @param {number} i
|
|
44
|
+
* @returns {number}
|
|
45
|
+
*/
|
|
46
|
+
function HEAP_RIGHT(i) {
|
|
47
|
+
return ((i) << 1) + 2;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Binary Heap implementation that stores uin32 ID along with a floating point score value
|
|
52
|
+
* Inspired by Blender's heap implementation found here: https://github.com/blender/blender/blob/594f47ecd2d5367ca936cf6fc6ec8168c2b360d0/source/blender/blenlib/intern/BLI_heap.c
|
|
53
|
+
*/
|
|
54
|
+
export class Uint32Heap {
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {number} [capacity] Can supply initial capacity, heap will still grow when necessary. This allows to prevent needless re-allocations when max heap size is known in advance
|
|
58
|
+
*/
|
|
59
|
+
constructor(capacity = DEFAULT_CAPACITY) {
|
|
60
|
+
assert.isNonNegativeInteger(capacity, 'capacity');
|
|
61
|
+
|
|
62
|
+
this.__data_buffer = new ArrayBuffer(capacity * ELEMENT_BYTE_SIZE);
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Used to access stored IDs
|
|
66
|
+
* @type {Uint32Array}
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
this.__data_uint32 = new Uint32Array(this.__data_buffer);
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Used to access stored Score values
|
|
73
|
+
* @type {Float32Array}
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
this.__data_float32 = new Float32Array(this.__data_buffer);
|
|
77
|
+
|
|
78
|
+
this.__capacity = capacity;
|
|
79
|
+
this.__size = 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
*
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
__capacity_grow() {
|
|
87
|
+
const old_capacity = this.__capacity;
|
|
88
|
+
|
|
89
|
+
const new_capacity = max2(
|
|
90
|
+
old_capacity * RESIZE_GROW_FACTOR,
|
|
91
|
+
old_capacity + RESIZE_GROW_MIN_COUNT
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
assert.greaterThan(new_capacity, old_capacity, 'invalid growth');
|
|
95
|
+
|
|
96
|
+
const new_buffer = new ArrayBuffer(new_capacity * ELEMENT_BYTE_SIZE);
|
|
97
|
+
const new_uint32 = new Uint32Array(new_buffer);
|
|
98
|
+
|
|
99
|
+
// copy old data into new container
|
|
100
|
+
new_uint32.set(this.__data_uint32);
|
|
101
|
+
|
|
102
|
+
this.__data_buffer = new_buffer;
|
|
103
|
+
this.__data_uint32 = new_uint32;
|
|
104
|
+
this.__data_float32 = new Float32Array(new_buffer);
|
|
105
|
+
|
|
106
|
+
// update capacity
|
|
107
|
+
this.__capacity = new_capacity;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* @private
|
|
112
|
+
* @param {number} a index of an element
|
|
113
|
+
* @param {number} b index of an element
|
|
114
|
+
* @returns {boolean}
|
|
115
|
+
*/
|
|
116
|
+
compare(a, b) {
|
|
117
|
+
const float32 = this.__data_float32;
|
|
118
|
+
|
|
119
|
+
return float32[a * 2] < float32[b * 2];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Swap two elements
|
|
124
|
+
* @private
|
|
125
|
+
* @param {number} i element index
|
|
126
|
+
* @param {number} j element index
|
|
127
|
+
*/
|
|
128
|
+
swap(i, j) {
|
|
129
|
+
const i2 = i * 2;
|
|
130
|
+
const j2 = j * 2;
|
|
131
|
+
|
|
132
|
+
const uint32 = this.__data_uint32;
|
|
133
|
+
|
|
134
|
+
const mem_0 = uint32[i2];
|
|
135
|
+
uint32[i2] = uint32[j2];
|
|
136
|
+
uint32[j2] = mem_0;
|
|
137
|
+
|
|
138
|
+
const mem_1 = uint32[i2 + 1];
|
|
139
|
+
uint32[i2 + 1] = uint32[j2 + 1];
|
|
140
|
+
uint32[j2 + 1] = mem_1;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* @private
|
|
145
|
+
* @param {number} index
|
|
146
|
+
*/
|
|
147
|
+
heap_down(index) {
|
|
148
|
+
let i = index;
|
|
149
|
+
|
|
150
|
+
// size does not change, cache it for performance
|
|
151
|
+
const size = this.__size;
|
|
152
|
+
|
|
153
|
+
while (true) {
|
|
154
|
+
const l = ((i) << 1) + 1;
|
|
155
|
+
const r = l + 1;
|
|
156
|
+
|
|
157
|
+
let smallest = i;
|
|
158
|
+
|
|
159
|
+
if (l < size && this.compare(l, smallest)) {
|
|
160
|
+
smallest = l;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (r < size && this.compare(r, smallest)) {
|
|
164
|
+
smallest = r;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (smallest === i) {
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.swap(i, smallest);
|
|
172
|
+
|
|
173
|
+
i = smallest;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Bubble up given element into its correct position
|
|
180
|
+
* @private
|
|
181
|
+
* @param {number} index
|
|
182
|
+
*/
|
|
183
|
+
heap_up(index) {
|
|
184
|
+
let i = index;
|
|
185
|
+
|
|
186
|
+
while (i > 0) {
|
|
187
|
+
// get parent
|
|
188
|
+
const p = ((i) - 1) >> 1;
|
|
189
|
+
|
|
190
|
+
if (this.compare(p, i)) {
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
this.swap(p, i);
|
|
195
|
+
|
|
196
|
+
i = p;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
*
|
|
202
|
+
* @returns {number}
|
|
203
|
+
*/
|
|
204
|
+
get size() {
|
|
205
|
+
return this.__size;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
*
|
|
210
|
+
* @returns {number}
|
|
211
|
+
*/
|
|
212
|
+
get capacity() {
|
|
213
|
+
return this.__capacity;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Node with the lowest score
|
|
218
|
+
* @returns {number}
|
|
219
|
+
*/
|
|
220
|
+
get top_id() {
|
|
221
|
+
return this.__data_uint32[1];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
*
|
|
226
|
+
* @returns {boolean}
|
|
227
|
+
*/
|
|
228
|
+
is_empty() {
|
|
229
|
+
return this.__size === 0;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
pop_min() {
|
|
233
|
+
assert.greaterThan(this.__size, 0, 'heap is empty');
|
|
234
|
+
|
|
235
|
+
const result = this.top_id;
|
|
236
|
+
|
|
237
|
+
this.__size--;
|
|
238
|
+
|
|
239
|
+
if (this.__size > 0) {
|
|
240
|
+
// move top element to the bottom
|
|
241
|
+
this.swap(0, this.__size);
|
|
242
|
+
|
|
243
|
+
// rebalance
|
|
244
|
+
this.heap_down(0);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return result;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
*
|
|
252
|
+
* @param {number} id
|
|
253
|
+
* @returns {number}
|
|
254
|
+
*/
|
|
255
|
+
find_index_by_id(id) {
|
|
256
|
+
const n = this.__size
|
|
257
|
+
const n2 = n * 2;
|
|
258
|
+
|
|
259
|
+
const uint32 = this.__data_uint32;
|
|
260
|
+
|
|
261
|
+
for (let address = 1; address < n2; address += 2) {
|
|
262
|
+
const _id = uint32[address];
|
|
263
|
+
|
|
264
|
+
if (_id === id) {
|
|
265
|
+
return (address >>> 1);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// not found
|
|
270
|
+
return -1;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
*
|
|
276
|
+
* @param {number} id
|
|
277
|
+
*/
|
|
278
|
+
remove(id) {
|
|
279
|
+
const i = this.find_index_by_id(id);
|
|
280
|
+
|
|
281
|
+
if (i !== -1) {
|
|
282
|
+
this.__remove_by_index(i);
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
*
|
|
288
|
+
* @param {number} index
|
|
289
|
+
*/
|
|
290
|
+
__remove_by_index(index) {
|
|
291
|
+
assert.greaterThan(this.__size, 0, 'heap is empty');
|
|
292
|
+
|
|
293
|
+
let i = index;
|
|
294
|
+
|
|
295
|
+
while (i > 0) {
|
|
296
|
+
const p = HEAP_PARENT(i);
|
|
297
|
+
this.swap(p, i);
|
|
298
|
+
|
|
299
|
+
i = p;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
this.pop_min();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
*
|
|
307
|
+
* @param {number} id
|
|
308
|
+
* @param {number} score
|
|
309
|
+
*/
|
|
310
|
+
update_score(id, score) {
|
|
311
|
+
const index = this.find_index_by_id(id);
|
|
312
|
+
|
|
313
|
+
if (index === -1) {
|
|
314
|
+
throw new Error('Not found');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
this.__update_score_by_index(index, score);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
*
|
|
322
|
+
* @param {number} index
|
|
323
|
+
* @param {number} score
|
|
324
|
+
*/
|
|
325
|
+
__update_score_by_index(index, score) {
|
|
326
|
+
|
|
327
|
+
const float32 = this.__data_float32;
|
|
328
|
+
const index2 = index * 2;
|
|
329
|
+
const existing_score = float32[index2];
|
|
330
|
+
|
|
331
|
+
if (score < existing_score) {
|
|
332
|
+
float32[index2] = score;
|
|
333
|
+
this.heap_up(index);
|
|
334
|
+
} else if (score > existing_score) {
|
|
335
|
+
float32[index2] = score;
|
|
336
|
+
this.heap_down(index);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
*
|
|
343
|
+
* @param {number} id
|
|
344
|
+
* @param {number} score
|
|
345
|
+
*/
|
|
346
|
+
insert_or_update(id, score) {
|
|
347
|
+
const i = this.find_index_by_id(id);
|
|
348
|
+
|
|
349
|
+
if (i === -1) {
|
|
350
|
+
this.insert(id, score);
|
|
351
|
+
} else {
|
|
352
|
+
this.__update_score_by_index(i, score);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
*
|
|
358
|
+
* @param {number} id
|
|
359
|
+
* @param {number} score
|
|
360
|
+
*/
|
|
361
|
+
insert(id, score) {
|
|
362
|
+
assert.isNonNegativeInteger(id, 'value');
|
|
363
|
+
assert.lessThanOrEqual(id, UINT32_MAX - 1, 'must be less than or equal to (2^32 - 2)');
|
|
364
|
+
|
|
365
|
+
if (this.__size >= this.__capacity) {
|
|
366
|
+
// need to re-allocate
|
|
367
|
+
this.__capacity_grow();
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// insert at the end
|
|
371
|
+
const index = this.__size;
|
|
372
|
+
const address = index * 2;
|
|
373
|
+
|
|
374
|
+
// write data
|
|
375
|
+
this.__data_float32[address] = score;
|
|
376
|
+
this.__data_uint32[address + 1] = id;
|
|
377
|
+
|
|
378
|
+
// record increased size
|
|
379
|
+
this.__size++;
|
|
380
|
+
|
|
381
|
+
this.heap_up(index);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
|
|
385
|
+
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { assert } from "../../assert.js";
|
|
7
7
|
import Signal from "../../events/signal/Signal.js";
|
|
8
8
|
import { max2 } from "../../math/max2.js";
|
|
9
|
+
import { array_copy } from "../array/copyArray.js";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
*
|
|
@@ -414,6 +415,39 @@ RowFirstTable.prototype.setRow = function (index, record) {
|
|
|
414
415
|
this.writeRowMethod(this.dataView, this.bytesPerRecord * index, record);
|
|
415
416
|
}
|
|
416
417
|
|
|
418
|
+
/**
|
|
419
|
+
* Reverse order of rows, row-0 will end up at and previously last row will become the first row etc.
|
|
420
|
+
*/
|
|
421
|
+
RowFirstTable.prototype.reverse_rows = function () {
|
|
422
|
+
const bpr = this.bytesPerRecord;
|
|
423
|
+
const copy_buffer = new Uint8Array(bpr);
|
|
424
|
+
|
|
425
|
+
const buffer = this.data;
|
|
426
|
+
const wrapper = new Uint8Array(buffer);
|
|
427
|
+
|
|
428
|
+
const length = this.length;
|
|
429
|
+
|
|
430
|
+
if (length <= 1) {
|
|
431
|
+
// need at least 2 rows for reversal to make any change
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const last_row_index = length - 1;
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
const traversal_limit = last_row_index >>> 1;
|
|
439
|
+
for (let i = 0; i <= traversal_limit; i++) {
|
|
440
|
+
const address = i * bpr;
|
|
441
|
+
array_copy(wrapper, address, copy_buffer, 0, bpr);
|
|
442
|
+
|
|
443
|
+
const swap_index = last_row_index - i;
|
|
444
|
+
const swap_address = swap_index * bpr;
|
|
445
|
+
|
|
446
|
+
wrapper.copyWithin(address, swap_address, swap_address + bpr)
|
|
447
|
+
wrapper.set(copy_buffer, swap_address);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
|
|
417
451
|
/**
|
|
418
452
|
* clear out all the data and free memory
|
|
419
453
|
*/
|