brepjs 18.82.5 → 18.82.7
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/dist/2d.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{blueprint-DjzevNhB.js → blueprint-DmvnSTKs.js} +7 -7
- package/dist/{blueprint-BBUOweQy.cjs → blueprint-lbpshPPC.cjs} +7 -7
- package/dist/{blueprintFns-CxSMnMfl.js → blueprintFns-Bhmqz0_E.js} +2 -2
- package/dist/{blueprintFns-CRES_5vP.cjs → blueprintFns-Nl1hnrJX.cjs} +2 -2
- package/dist/{blueprintSketcher-CIydRzRr.js → blueprintSketcher-DzCTWt_f.js} +140 -86
- package/dist/{blueprintSketcher-CFa32JZU.cjs → blueprintSketcher-NDZKJGYh.cjs} +140 -86
- package/dist/{boolean2D-BRWPIJhe.js → boolean2D-DGtpfl2g.js} +4 -4
- package/dist/{boolean2D-Z0KE98a4.cjs → boolean2D-Dzs9Vkjv.cjs} +4 -4
- package/dist/brepjs.cjs +25 -25
- package/dist/brepjs.js +25 -25
- package/dist/{cameraFns-B3Wb4Br9.js → cameraFns-B2WR42Tm.js} +2 -2
- package/dist/{cameraFns-Drgka78Q.cjs → cameraFns-p4G3cFuC.cjs} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{cornerFinder-BuYpqGO8.cjs → cornerFinder-B_SuHSBj.cjs} +1 -1
- package/dist/{cornerFinder-BRYZAgdE.js → cornerFinder-KoakXQze.js} +1 -1
- package/dist/{curveFns-BA5zsoce.cjs → curveFns-CJWxgcHu.cjs} +1 -1
- package/dist/{curveFns-XSz4F9j3.js → curveFns-XRM_FMU4.js} +1 -1
- package/dist/{drawFns-DK3DGHku.cjs → drawFns-7qn35uWm.cjs} +12 -12
- package/dist/{drawFns-C5Mdr0iH.js → drawFns-D7q8qpEI.js} +12 -12
- package/dist/{faceFns-6AarivqH.cjs → faceFns-B3bYfnGX.cjs} +2 -2
- package/dist/{faceFns-BO8IXhhf.js → faceFns-hGTQhRXB.js} +2 -2
- package/dist/{healingFns-D3BkAVML.cjs → healingFns-BpFs-Puf.cjs} +5 -5
- package/dist/{healingFns-C4JZHv8K.js → healingFns-CUn6v5p4.js} +5 -5
- package/dist/{helpers-DN6s-TLC.cjs → helpers-D6yNdVOO.cjs} +6 -6
- package/dist/{helpers-CTc8ZbY8.js → helpers-DOE4GlZ0.js} +6 -6
- package/dist/{importFns-Cb-cmpGG.cjs → importFns-BQTQKGbi.cjs} +2 -2
- package/dist/{importFns-D4Xet5aD.js → importFns-CPZWa8WK.js} +2 -2
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/brepkit/brepkitWasmTypes.d.ts +35 -6
- package/dist/kernel/occtWasm/kernel2dOps.d.ts +8 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/{loftFns-DxhcdpAu.cjs → loftFns-B8UzGtwS.cjs} +1 -1
- package/dist/{loftFns-BVbzy6gm.js → loftFns-DusJd7Qq.js} +1 -1
- package/dist/{measureFns-7Nz5JklM.js → measureFns-Bka10mrS.js} +3 -3
- package/dist/{measureFns-BNHvjShh.cjs → measureFns-DwHd423H.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-YXFipjjx.cjs → meshFns-B2k02WJJ.cjs} +3 -3
- package/dist/{meshFns-CWwOpBlM.js → meshFns-CNfOU3D1.js} +3 -3
- package/dist/{occtWasmAdapter-BMV179Ji.js → occtWasmAdapter-BK6h0nKd.js} +29 -5
- package/dist/{occtWasmAdapter-5hzzhkME.cjs → occtWasmAdapter-Bfz5Zfmk.cjs} +29 -5
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{primitiveFns-DkuLOFkI.js → primitiveFns-C-kQixz1.js} +4 -4
- package/dist/{primitiveFns-BPfYb_t5.cjs → primitiveFns-D3y2t4FS.cjs} +4 -4
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{shapeFns-sF0x5Zhj.cjs → shapeFns-BPvq4QYa.cjs} +2 -2
- package/dist/{shapeFns-B6UAiYAx.js → shapeFns-kVgikxkG.js} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeRefFns-NdQvPa5J.js → shapeRefFns-CXWVzhbm.js} +4 -4
- package/dist/{shapeRefFns-Bb0aQZWz.cjs → shapeRefFns-CxB7OXOc.cjs} +4 -4
- package/dist/{shapeTypes-D4Evnmz_.js → shapeTypes-Caa9T1VR.js} +61 -6
- package/dist/{shapeTypes-D1eUDuzl.cjs → shapeTypes-DpDcMU0a.cjs} +61 -6
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-QUpJdbiK.js → solidBuilders-BHRL7010.js} +5 -5
- package/dist/{solidBuilders-lDXPwoCz.cjs → solidBuilders-Cve7yf13.cjs} +5 -5
- package/dist/{surfaceBuilders-R4DKNFkI.cjs → surfaceBuilders-5hLC_QeE.cjs} +2 -2
- package/dist/{surfaceBuilders-CLMyFimy.js → surfaceBuilders-BDEc8WSE.js} +2 -2
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-f8cgx9vi.js → textBlueprints-Cl5P2MkE.js} +7 -7
- package/dist/{textBlueprints-D4pLmVno.cjs → textBlueprints-bMa5164s.cjs} +7 -7
- package/dist/{textMetrics-DTRuXeXr.cjs → textMetrics-BDr82S48.cjs} +1 -1
- package/dist/{textMetrics-CQtQI4vF.js → textMetrics-DBEv2A2N.js} +1 -1
- package/dist/{threadFns-CvLvKdwB.js → threadFns-74sXf2tN.js} +6 -6
- package/dist/{threadFns-DvSdQiRw.cjs → threadFns-Cw1TzGd2.cjs} +6 -6
- package/dist/topology.cjs +8 -8
- package/dist/topology.js +8 -8
- package/dist/{topologyQueryFns-5EeBz6_7.js → topologyQueryFns-CR7zQvDK.js} +1 -1
- package/dist/{topologyQueryFns-Nnu56Ke2.cjs → topologyQueryFns-imRz9gK2.cjs} +1 -1
- package/package.json +16 -16
package/dist/2d.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
2
|
+
const require_shapeTypes = require("./shapeTypes-DpDcMU0a.cjs");
|
|
3
3
|
const require_errors = require("./errors-CXJtc4I7.cjs");
|
|
4
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
5
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
6
|
-
const require_blueprint = require("./blueprint-
|
|
7
|
-
const require_boolean2D = require("./boolean2D-
|
|
8
|
-
const require_blueprintFns = require("./blueprintFns-
|
|
4
|
+
const require_topologyQueryFns = require("./topologyQueryFns-imRz9gK2.cjs");
|
|
5
|
+
const require_blueprintSketcher = require("./blueprintSketcher-NDZKJGYh.cjs");
|
|
6
|
+
const require_blueprint = require("./blueprint-lbpshPPC.cjs");
|
|
7
|
+
const require_boolean2D = require("./boolean2D-Dzs9Vkjv.cjs");
|
|
8
|
+
const require_blueprintFns = require("./blueprintFns-Nl1hnrJX.cjs");
|
|
9
9
|
//#region src/core/curve2dHandle.ts
|
|
10
10
|
/**
|
|
11
11
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
package/dist/2d.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { B as createKernelHandle, Q as getKernel2D, a as createEdge } from "./shapeTypes-
|
|
1
|
+
import { B as createKernelHandle, Q as getKernel2D, a as createEdge } from "./shapeTypes-Caa9T1VR.js";
|
|
2
2
|
import { A as ok, b as err, d as validationError, t as BrepErrorCode } from "./errors-DNWJsfVU.js";
|
|
3
|
-
import { w as kernelCallRaw } from "./topologyQueryFns-
|
|
4
|
-
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-
|
|
5
|
-
import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./blueprint-
|
|
6
|
-
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-
|
|
7
|
-
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-
|
|
3
|
+
import { w as kernelCallRaw } from "./topologyQueryFns-CR7zQvDK.js";
|
|
4
|
+
import { a as Blueprints, i as CompoundBlueprint, r as organiseBlueprints } from "./blueprintSketcher-DzCTWt_f.js";
|
|
5
|
+
import { _ as Curve2D, t as Blueprint, y as BoundingBox2d } from "./blueprint-DmvnSTKs.js";
|
|
6
|
+
import { a as fuseBlueprints, c as roundedRectangleBlueprint, i as cutBlueprints, n as fuse2D, o as intersectBlueprints, r as intersect2D, s as polysidesBlueprint, t as cut2D } from "./boolean2D-DGtpfl2g.js";
|
|
7
|
+
import { S as reverseCurve, _ as curve2dIsOnCurve, a as isInside2D, b as curve2dSplitAt, c as scale2D, d as stretch2D, f as toSVGPathD, g as curve2dFirstPoint, h as curve2dDistanceFrom, i as getOrientation2D, l as sketchOnFace2D, m as curve2dBoundingBox, o as mirror2D, p as translate2D, r as getBounds2D, s as rotate2D, t as createBlueprint, u as sketchOnPlane2D, v as curve2dLastPoint, x as curve2dTangentAt, y as curve2dParameter } from "./blueprintFns-Bhmqz0_E.js";
|
|
8
8
|
//#region src/core/curve2dHandle.ts
|
|
9
9
|
/**
|
|
10
10
|
* Wrap a raw kernel 2D curve handle with brand + disposal tracking.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { G as unregisterFromCleanup, Q as getKernel2D, U as registerForCleanup, Z as getKernel, a as createEdge, u as createWire } from "./shapeTypes-
|
|
1
|
+
import { G as unregisterFromCleanup, Q as getKernel2D, U as registerForCleanup, Z as getKernel, a as createEdge, u as createWire } from "./shapeTypes-Caa9T1VR.js";
|
|
2
2
|
import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
|
|
3
3
|
import { A as ok, R as unwrap, b as err, d as validationError, h as bug, n as computationError } from "./errors-DNWJsfVU.js";
|
|
4
4
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
import { r as toVec3 } from "./types-D24Y27N0.js";
|
|
6
6
|
import { r as makePlane } from "./planeOps-DSjjtrjg.js";
|
|
7
|
-
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-
|
|
8
|
-
import { p as getOrientation } from "./curveFns-
|
|
7
|
+
import { _ as cast, h as uvCoordinates, i as faceGeomType, m as uvBounds, r as faceCenter } from "./faceFns-hGTQhRXB.js";
|
|
8
|
+
import { p as getOrientation } from "./curveFns-XRM_FMU4.js";
|
|
9
9
|
import { n as getAtOrThrow, r as lastOrThrow, t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
10
|
-
import { r as makeFace } from "./surfaceBuilders-
|
|
11
|
-
import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-
|
|
10
|
+
import { r as makeFace } from "./surfaceBuilders-BDEc8WSE.js";
|
|
11
|
+
import { _ as samePoint, b as subtract2d, l as add2d, o as normalize2d, p as distance2d, t as getSingleFace, v as scalarMultiply2d } from "./helpers-DOE4GlZ0.js";
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -587,7 +587,7 @@ var transformCurves = (curves, transformation) => {
|
|
|
587
587
|
};
|
|
588
588
|
/** Create a 2D affinity (non-uniform scale) transformation along a direction. */
|
|
589
589
|
var stretchTransform2d = (ratio, direction, origin = [0, 0]) => {
|
|
590
|
-
return getKernel().createAffinityGTrsf2d(origin[0], origin[1], direction[
|
|
590
|
+
return getKernel().createAffinityGTrsf2d(origin[0], origin[1], -direction[1], direction[0], ratio);
|
|
591
591
|
};
|
|
592
592
|
/** Create a 2D translation transformation. */
|
|
593
593
|
var translationTransform2d = (translation) => {
|
|
@@ -626,7 +626,7 @@ function curvesAsEdgesOnFace(curves, face, scale = "original") {
|
|
|
626
626
|
const cylData = kernel.getSurfaceCylinderData(geomSurf);
|
|
627
627
|
if (!cylData) return err(validationError("UNSUPPORTED_FACE_TYPE", "Could not extract cylinder data from face surface"));
|
|
628
628
|
if (!cylData.isDirect) geomSurf = kernel.reverseSurfaceU(geomSurf);
|
|
629
|
-
transformation = stretchTransform2d(1 / cylData.radius, [
|
|
629
|
+
transformation = stretchTransform2d(1 / cylData.radius, [1, 0]);
|
|
630
630
|
}
|
|
631
631
|
if (scale === "bounds") {
|
|
632
632
|
transformation = kernel.createIdentityGTrsf2d();
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
1
|
+
const require_shapeTypes = require("./shapeTypes-DpDcMU0a.cjs");
|
|
2
2
|
const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
|
|
3
3
|
const require_errors = require("./errors-CXJtc4I7.cjs");
|
|
4
4
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
5
5
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
6
6
|
const require_planeOps = require("./planeOps-BA4HfgQu.cjs");
|
|
7
|
-
const require_faceFns = require("./faceFns-
|
|
8
|
-
const require_curveFns = require("./curveFns-
|
|
7
|
+
const require_faceFns = require("./faceFns-B3bYfnGX.cjs");
|
|
8
|
+
const require_curveFns = require("./curveFns-CJWxgcHu.cjs");
|
|
9
9
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
10
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
11
|
-
const require_helpers = require("./helpers-
|
|
10
|
+
const require_surfaceBuilders = require("./surfaceBuilders-5hLC_QeE.cjs");
|
|
11
|
+
const require_helpers = require("./helpers-D6yNdVOO.cjs");
|
|
12
12
|
//#region src/2d/lib/definitions.ts
|
|
13
13
|
/** Type guard that checks whether a value is a `Point2D`. */
|
|
14
14
|
function isPoint2D(point) {
|
|
@@ -587,7 +587,7 @@ var transformCurves = (curves, transformation) => {
|
|
|
587
587
|
};
|
|
588
588
|
/** Create a 2D affinity (non-uniform scale) transformation along a direction. */
|
|
589
589
|
var stretchTransform2d = (ratio, direction, origin = [0, 0]) => {
|
|
590
|
-
return require_shapeTypes.getKernel().createAffinityGTrsf2d(origin[0], origin[1], direction[
|
|
590
|
+
return require_shapeTypes.getKernel().createAffinityGTrsf2d(origin[0], origin[1], -direction[1], direction[0], ratio);
|
|
591
591
|
};
|
|
592
592
|
/** Create a 2D translation transformation. */
|
|
593
593
|
var translationTransform2d = (translation) => {
|
|
@@ -626,7 +626,7 @@ function curvesAsEdgesOnFace(curves, face, scale = "original") {
|
|
|
626
626
|
const cylData = kernel.getSurfaceCylinderData(geomSurf);
|
|
627
627
|
if (!cylData) return require_errors.err(require_errors.validationError("UNSUPPORTED_FACE_TYPE", "Could not extract cylinder data from face surface"));
|
|
628
628
|
if (!cylData.isDirect) geomSurf = kernel.reverseSurfaceU(geomSurf);
|
|
629
|
-
transformation = stretchTransform2d(1 / cylData.radius, [
|
|
629
|
+
transformation = stretchTransform2d(1 / cylData.radius, [1, 0]);
|
|
630
630
|
}
|
|
631
631
|
if (scale === "bounds") {
|
|
632
632
|
transformation = kernel.createIdentityGTrsf2d();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A as ok, b as err, d as validationError, t as BrepErrorCode } from "./errors-DNWJsfVU.js";
|
|
2
|
-
import { i as CompoundBlueprint } from "./blueprintSketcher-
|
|
3
|
-
import { t as Blueprint } from "./blueprint-
|
|
2
|
+
import { i as CompoundBlueprint } from "./blueprintSketcher-DzCTWt_f.js";
|
|
3
|
+
import { t as Blueprint } from "./blueprint-DmvnSTKs.js";
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_errors = require("./errors-CXJtc4I7.cjs");
|
|
2
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
3
|
-
const require_blueprint = require("./blueprint-
|
|
2
|
+
const require_blueprintSketcher = require("./blueprintSketcher-NDZKJGYh.cjs");
|
|
3
|
+
const require_blueprint = require("./blueprint-lbpshPPC.cjs");
|
|
4
4
|
//#region src/2d/lib/curve2dFns.ts
|
|
5
5
|
/**
|
|
6
6
|
* Return a reversed copy of the curve (non-mutating).
|
|
@@ -1,18 +1,36 @@
|
|
|
1
|
-
import { Q as getKernel2D, Z as getKernel } from "./shapeTypes-
|
|
1
|
+
import { Q as getKernel2D, Z as getKernel } from "./shapeTypes-Caa9T1VR.js";
|
|
2
2
|
import { n as wasmIndex } from "./vec3-Dpha8d5k.js";
|
|
3
3
|
import { A as ok, R as unwrap, T as isOk, b as err, h as bug, n as computationError, s as safeIndex } from "./errors-DNWJsfVU.js";
|
|
4
4
|
import { r as RAD2DEG, t as DEG2RAD } from "./constants-ITRzCnCp.js";
|
|
5
5
|
import { t as firstOrThrow } from "./arrayAccess-DrUGPADn.js";
|
|
6
|
-
import { _ as samePoint, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, v as scalarMultiply2d } from "./helpers-
|
|
7
|
-
import { _ as Curve2D, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./blueprint-
|
|
6
|
+
import { _ as samePoint, b as subtract2d, d as cartesianToPolar, f as crossProduct2d, g as rotate2d, h as polarToCartesian, l as add2d, m as polarAngle2d, o as normalize2d, p as distance2d, v as scalarMultiply2d } from "./helpers-DOE4GlZ0.js";
|
|
7
|
+
import { _ as Curve2D, c as make2dCircle, f as make2dSegmentCurve, h as approximateAsBSpline, m as make2dThreePointArc, n as asSVG, o as make2dArcFromCenter, p as make2dTangentArc, r as viewbox, s as make2dBezierCurve, t as Blueprint, u as make2dEllipseArc, x as isPoint2D, y as BoundingBox2d } from "./blueprint-DmvnSTKs.js";
|
|
8
8
|
//#region node_modules/flatqueue/index.js
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @typedef {Float64ArrayConstructor | Float32ArrayConstructor |
|
|
11
|
+
* Uint32ArrayConstructor | Int32ArrayConstructor | Uint16ArrayConstructor |
|
|
12
|
+
* Int16ArrayConstructor | Uint8ArrayConstructor | Int8ArrayConstructor} TypedArrayConstructor
|
|
13
|
+
*/
|
|
14
|
+
/** @template [T=number] */
|
|
10
15
|
var FlatQueue = class {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Creates an empty queue. If `capacity` is provided, the queue is backed by fixed-size typed
|
|
18
|
+
* arrays for better performance and memory use, but can't grow beyond `capacity`. `values` uses
|
|
19
|
+
* `ValuesArray` (default `Float64Array`) and `ids` uses `IdsArray` (default `Uint32Array`); pass
|
|
20
|
+
* narrower constructors like `Uint16Array` if your values or ids are known to fit them.
|
|
21
|
+
*
|
|
22
|
+
* @param {number} [capacity]
|
|
23
|
+
* @param {TypedArrayConstructor} [ValuesArray]
|
|
24
|
+
* @param {TypedArrayConstructor} [IdsArray]
|
|
25
|
+
*/
|
|
26
|
+
constructor(capacity = Infinity, ValuesArray = Float64Array, IdsArray = Uint32Array) {
|
|
27
|
+
const fixed = capacity !== Infinity;
|
|
28
|
+
/** @type {T[]} */
|
|
29
|
+
this.ids = fixed ? new IdsArray(capacity) : [];
|
|
30
|
+
/** @type {number[]} */
|
|
31
|
+
this.values = fixed ? new ValuesArray(capacity) : [];
|
|
32
|
+
/** Maximum number of items the queue can hold; `Infinity` for regular-array queues, which grow on demand. */
|
|
33
|
+
this.capacity = capacity;
|
|
16
34
|
/** Number of items in the queue. */
|
|
17
35
|
this.length = 0;
|
|
18
36
|
}
|
|
@@ -26,10 +44,13 @@ var FlatQueue = class {
|
|
|
26
44
|
* `priority` must be a number. Items are sorted and returned from low to high priority. Multiple items
|
|
27
45
|
* with the same priority value can be added to the queue, but there is no guaranteed order between these items.
|
|
28
46
|
*
|
|
47
|
+
* For fixed-capacity queues, throws a `RangeError` if the queue is already full.
|
|
48
|
+
*
|
|
29
49
|
* @param {T} item
|
|
30
50
|
* @param {number} priority
|
|
31
51
|
*/
|
|
32
52
|
push(item, priority) {
|
|
53
|
+
if (this.length === this.capacity) throw new RangeError("Queue is at capacity.");
|
|
33
54
|
let pos = this.length++;
|
|
34
55
|
while (pos > 0) {
|
|
35
56
|
const parent = pos - 1 >> 1;
|
|
@@ -80,14 +101,15 @@ var FlatQueue = class {
|
|
|
80
101
|
return this.length > 0 ? this.values[0] : void 0;
|
|
81
102
|
}
|
|
82
103
|
/**
|
|
83
|
-
* Shrinks the internal arrays to `this.length`.
|
|
104
|
+
* Shrinks the internal arrays to `this.length`. No-op for queues with fixed capacity.
|
|
84
105
|
*
|
|
85
106
|
* `pop()` and `clear()` calls don't free memory automatically to avoid unnecessary resize operations.
|
|
86
107
|
* This also means that items that have been added to the queue can't be garbage collected until
|
|
87
108
|
* a new item is pushed in their place, or this method is called.
|
|
88
109
|
*/
|
|
89
110
|
shrink() {
|
|
90
|
-
this.ids
|
|
111
|
+
if (Array.isArray(this.ids)) this.ids.length = this.length;
|
|
112
|
+
if (Array.isArray(this.values)) this.values.length = this.length;
|
|
91
113
|
}
|
|
92
114
|
};
|
|
93
115
|
//#endregion
|
|
@@ -105,6 +127,7 @@ var ARRAY_TYPES = [
|
|
|
105
127
|
];
|
|
106
128
|
var VERSION = 3;
|
|
107
129
|
/** @typedef {Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor} TypedArrayConstructor */
|
|
130
|
+
/** @typedef {Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array} TypedArray */
|
|
108
131
|
var Flatbush = class Flatbush {
|
|
109
132
|
/**
|
|
110
133
|
* Recreate a Flatbush index from raw `ArrayBuffer` or `SharedArrayBuffer` data.
|
|
@@ -114,7 +137,7 @@ var Flatbush = class Flatbush {
|
|
|
114
137
|
*/
|
|
115
138
|
static from(data, byteOffset = 0) {
|
|
116
139
|
if (byteOffset % 8 !== 0) throw new Error("byteOffset must be 8-byte aligned.");
|
|
117
|
-
if (!data || data.byteLength === void 0 || data
|
|
140
|
+
if (!data || data.byteLength === void 0 || "buffer" in data) throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");
|
|
118
141
|
const [magic, versionAndType] = new Uint8Array(data, byteOffset + 0, 2);
|
|
119
142
|
if (magic !== 251) throw new Error("Data does not appear to be in a Flatbush format.");
|
|
120
143
|
const version = versionAndType >> 4;
|
|
@@ -153,10 +176,14 @@ var Flatbush = class Flatbush {
|
|
|
153
176
|
const arrayTypeIndex = ARRAY_TYPES.indexOf(ArrayType);
|
|
154
177
|
const nodesByteSize = numNodes * 4 * ArrayType.BYTES_PER_ELEMENT;
|
|
155
178
|
if (arrayTypeIndex < 0) throw new Error(`Unexpected typed array class: ${ArrayType}.`);
|
|
179
|
+
/** @type {new(b: ArrayBufferLike, o: number, l: number) => TypedArray} */
|
|
180
|
+
const BoxCtor = ArrayType;
|
|
181
|
+
/** @type {new(b: ArrayBufferLike, o: number, l: number) => Uint16Array | Uint32Array} */
|
|
182
|
+
const IdxCtor = this.IndexArrayType;
|
|
156
183
|
if (data) {
|
|
157
184
|
this.data = data;
|
|
158
|
-
this._boxes = new
|
|
159
|
-
this._indices = new
|
|
185
|
+
this._boxes = new BoxCtor(data, byteOffset + 8, numNodes * 4);
|
|
186
|
+
this._indices = new IdxCtor(data, byteOffset + 8 + nodesByteSize, numNodes);
|
|
160
187
|
this._pos = numNodes * 4;
|
|
161
188
|
this.minX = this._boxes[this._pos - 4];
|
|
162
189
|
this.minY = this._boxes[this._pos - 3];
|
|
@@ -164,8 +191,8 @@ var Flatbush = class Flatbush {
|
|
|
164
191
|
this.maxY = this._boxes[this._pos - 1];
|
|
165
192
|
} else {
|
|
166
193
|
const data = this.data = new ArrayBufferType(8 + nodesByteSize + numNodes * this.IndexArrayType.BYTES_PER_ELEMENT);
|
|
167
|
-
this._boxes = new
|
|
168
|
-
this._indices = new
|
|
194
|
+
this._boxes = new BoxCtor(data, 8, numNodes * 4);
|
|
195
|
+
this._indices = new IdxCtor(data, 8 + nodesByteSize, numNodes);
|
|
169
196
|
this._pos = 0;
|
|
170
197
|
this.minX = Infinity;
|
|
171
198
|
this.minY = Infinity;
|
|
@@ -213,7 +240,7 @@ var Flatbush = class Flatbush {
|
|
|
213
240
|
}
|
|
214
241
|
const width = this.maxX - this.minX || 1;
|
|
215
242
|
const height = this.maxY - this.minY || 1;
|
|
216
|
-
const hilbertValues = new
|
|
243
|
+
const hilbertValues = new Int32Array(this.numItems);
|
|
217
244
|
const hilbertMax = 65535;
|
|
218
245
|
for (let i = 0, pos = 0; i < this.numItems; i++) {
|
|
219
246
|
const minX = boxes[pos++];
|
|
@@ -256,30 +283,62 @@ var Flatbush = class Flatbush {
|
|
|
256
283
|
*/
|
|
257
284
|
search(minX, minY, maxX, maxY, filterFn) {
|
|
258
285
|
if (this._pos !== this._boxes.length) throw new Error("Data not yet indexed - call index.finish().");
|
|
286
|
+
const { _boxes: boxes, _levelBounds: levelBounds, _indices: indices, nodeSize } = this;
|
|
287
|
+
const numItems4 = this.numItems * 4;
|
|
259
288
|
/** @type number | undefined */
|
|
260
|
-
let nodeIndex =
|
|
261
|
-
|
|
289
|
+
let nodeIndex = boxes.length - 4;
|
|
290
|
+
let level = levelBounds.length - 1;
|
|
291
|
+
const q = [];
|
|
262
292
|
const results = [];
|
|
293
|
+
let contained = false;
|
|
263
294
|
while (nodeIndex !== void 0) {
|
|
264
|
-
const end = Math.min(nodeIndex +
|
|
265
|
-
|
|
266
|
-
|
|
295
|
+
const end = Math.min(nodeIndex + nodeSize * 4, levelBounds[level]);
|
|
296
|
+
const isNode = nodeIndex >= numItems4;
|
|
297
|
+
if (contained) this._collectContained(nodeIndex, end, level, isNode, q, results, filterFn);
|
|
298
|
+
else for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
299
|
+
const x0 = boxes[pos];
|
|
267
300
|
if (maxX < x0) continue;
|
|
268
|
-
const y0 =
|
|
301
|
+
const y0 = boxes[pos + 1];
|
|
269
302
|
if (maxY < y0) continue;
|
|
270
|
-
const x1 =
|
|
303
|
+
const x1 = boxes[pos + 2];
|
|
271
304
|
if (minX > x1) continue;
|
|
272
|
-
const y1 =
|
|
305
|
+
const y1 = boxes[pos + 3];
|
|
273
306
|
if (minY > y1) continue;
|
|
274
|
-
const index =
|
|
275
|
-
if (
|
|
276
|
-
|
|
307
|
+
const index = indices[pos >> 2] | 0;
|
|
308
|
+
if (isNode) {
|
|
309
|
+
const c = +(minX <= x0 && minY <= y0 && maxX >= x1 && maxY >= y1);
|
|
310
|
+
q.push(index | c, level - 1);
|
|
311
|
+
} else if (filterFn === void 0 || filterFn(index, x0, y0, x1, y1)) results.push(index);
|
|
312
|
+
}
|
|
313
|
+
level = q.pop();
|
|
314
|
+
nodeIndex = q.pop();
|
|
315
|
+
if (nodeIndex !== void 0) {
|
|
316
|
+
contained = (nodeIndex & 1) === 1;
|
|
317
|
+
nodeIndex &= -2;
|
|
277
318
|
}
|
|
278
|
-
nodeIndex = queue.pop();
|
|
279
319
|
}
|
|
280
320
|
return results;
|
|
281
321
|
}
|
|
282
322
|
/**
|
|
323
|
+
* Collect children of a node whose bbox is fully inside the query, skipping intersection tests.
|
|
324
|
+
* @param {number} nodeIndex
|
|
325
|
+
* @param {number} end
|
|
326
|
+
* @param {number} level
|
|
327
|
+
* @param {boolean} isNode whether the children are tree nodes (vs leaf items)
|
|
328
|
+
* @param {number[]} q the traversal queue
|
|
329
|
+
* @param {number[]} results
|
|
330
|
+
* @param {((index: number, x0: number, y0: number, x1: number, y1: number) => boolean) | undefined} filterFn
|
|
331
|
+
*/
|
|
332
|
+
_collectContained(nodeIndex, end, level, isNode, q, results, filterFn) {
|
|
333
|
+
const boxes = this._boxes;
|
|
334
|
+
const indices = this._indices;
|
|
335
|
+
if (isNode) for (let pos = nodeIndex; pos < end; pos += 4) q.push(indices[pos >> 2] | 1, level - 1);
|
|
336
|
+
else for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
337
|
+
const index = indices[pos >> 2] | 0;
|
|
338
|
+
if (filterFn === void 0 || filterFn(index, boxes[pos], boxes[pos + 1], boxes[pos + 2], boxes[pos + 3])) results.push(index);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
283
342
|
* Search items in order of distance from the given point.
|
|
284
343
|
* @param {number} x
|
|
285
344
|
* @param {number} y
|
|
@@ -290,32 +349,39 @@ var Flatbush = class Flatbush {
|
|
|
290
349
|
*/
|
|
291
350
|
neighbors(x, y, maxResults = Infinity, maxDistance = Infinity, filterFn) {
|
|
292
351
|
if (this._pos !== this._boxes.length) throw new Error("Data not yet indexed - call index.finish().");
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
const
|
|
352
|
+
const { _boxes: boxes, _levelBounds: levelBounds, _indices: indices, _queue: q, nodeSize } = this;
|
|
353
|
+
const numItems4 = this.numItems * 4;
|
|
354
|
+
const nodeSize4 = nodeSize * 4;
|
|
296
355
|
const results = [];
|
|
297
356
|
const maxDistSquared = maxDistance * maxDistance;
|
|
298
|
-
|
|
299
|
-
|
|
357
|
+
q.push(boxes.length - 4 << 1, 0);
|
|
358
|
+
while (q.length) {
|
|
359
|
+
const top = q.ids[0];
|
|
360
|
+
if (top & 1) {
|
|
361
|
+
if (q.values[0] > maxDistSquared) break;
|
|
362
|
+
q.pop();
|
|
363
|
+
results.push(top >> 1);
|
|
364
|
+
if (results.length === maxResults) break;
|
|
365
|
+
continue;
|
|
366
|
+
}
|
|
367
|
+
q.pop();
|
|
368
|
+
const nodeIndex = top >> 1;
|
|
369
|
+
const isLeafLevel = nodeIndex < numItems4;
|
|
370
|
+
const end = Math.min(nodeIndex + nodeSize4, upperBound(nodeIndex, levelBounds));
|
|
300
371
|
for (let pos = nodeIndex; pos < end; pos += 4) {
|
|
301
|
-
const
|
|
302
|
-
const minX =
|
|
303
|
-
const minY =
|
|
304
|
-
const maxX =
|
|
305
|
-
const maxY =
|
|
372
|
+
const childIndex = indices[pos >> 2] | 0;
|
|
373
|
+
const minX = boxes[pos];
|
|
374
|
+
const minY = boxes[pos + 1];
|
|
375
|
+
const maxX = boxes[pos + 2];
|
|
376
|
+
const maxY = boxes[pos + 3];
|
|
306
377
|
const dx = x < minX ? minX - x : x > maxX ? x - maxX : 0;
|
|
307
378
|
const dy = y < minY ? minY - y : y > maxY ? y - maxY : 0;
|
|
308
379
|
const dist = dx * dx + dy * dy;
|
|
309
380
|
if (dist > maxDistSquared) continue;
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
while (q.length && q.peek() & 1) {
|
|
314
|
-
if (q.peekValue() > maxDistSquared) break outer;
|
|
315
|
-
results.push(q.pop() >> 1);
|
|
316
|
-
if (results.length === maxResults) break outer;
|
|
381
|
+
if (isLeafLevel) {
|
|
382
|
+
if (filterFn === void 0 || filterFn(childIndex)) q.push(childIndex << 1 | 1, dist);
|
|
383
|
+
} else q.push(childIndex << 1, dist);
|
|
317
384
|
}
|
|
318
|
-
nodeIndex = q.length ? q.pop() >> 1 : void 0;
|
|
319
385
|
}
|
|
320
386
|
q.clear();
|
|
321
387
|
return results;
|
|
@@ -338,8 +404,8 @@ function upperBound(value, arr) {
|
|
|
338
404
|
}
|
|
339
405
|
/**
|
|
340
406
|
* Custom quicksort that partially sorts bbox data alongside the hilbert values.
|
|
341
|
-
* @param {
|
|
342
|
-
* @param {
|
|
407
|
+
* @param {Int32Array} values
|
|
408
|
+
* @param {TypedArray} boxes
|
|
343
409
|
* @param {Uint16Array | Uint32Array} indices
|
|
344
410
|
* @param {number} left
|
|
345
411
|
* @param {number} right
|
|
@@ -372,8 +438,8 @@ function sort(values, boxes, indices, left, right, nodeSize) {
|
|
|
372
438
|
}
|
|
373
439
|
/**
|
|
374
440
|
* Swap two values and two corresponding boxes.
|
|
375
|
-
* @param {
|
|
376
|
-
* @param {
|
|
441
|
+
* @param {Int32Array} values
|
|
442
|
+
* @param {TypedArray} boxes
|
|
377
443
|
* @param {Uint16Array | Uint32Array} indices
|
|
378
444
|
* @param {number} i
|
|
379
445
|
* @param {number} j
|
|
@@ -413,43 +479,31 @@ function hilbert(x, y) {
|
|
|
413
479
|
let d = x & (y ^ 65535);
|
|
414
480
|
let A = a | b >> 1;
|
|
415
481
|
let B = a >> 1 ^ a;
|
|
416
|
-
let C = c >> 1 ^ b & d >> 1
|
|
417
|
-
let D = a & c >> 1 ^ d >> 1
|
|
418
|
-
a = A;
|
|
419
|
-
b = B;
|
|
420
|
-
c = C;
|
|
421
|
-
d = D;
|
|
422
|
-
A = a & a >> 2 ^ b & b >> 2;
|
|
423
|
-
B = a & b >> 2 ^ b & (a ^ b) >> 2;
|
|
424
|
-
C ^= a & c >> 2 ^ b & d >> 2;
|
|
425
|
-
D ^= b & c >> 2 ^ (a ^ b) & d >> 2;
|
|
426
|
-
a = A;
|
|
427
|
-
b = B;
|
|
428
|
-
c = C;
|
|
429
|
-
d = D;
|
|
482
|
+
let C = c ^ (c >> 1 ^ b & d >> 1);
|
|
483
|
+
let D = d ^ (a & c >> 1 ^ d >> 1);
|
|
484
|
+
a = A & A >> 2 ^ B & B >> 2;
|
|
485
|
+
b = A & B >> 2 ^ B & (A ^ B) >> 2;
|
|
486
|
+
c = C ^ (A & C >> 2 ^ B & D >> 2);
|
|
487
|
+
d = D ^ (B & C >> 2 ^ (A ^ B) & D >> 2);
|
|
430
488
|
A = a & a >> 4 ^ b & b >> 4;
|
|
431
489
|
B = a & b >> 4 ^ b & (a ^ b) >> 4;
|
|
432
|
-
C
|
|
433
|
-
D
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
c
|
|
437
|
-
d
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
a =
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
i1 = (i1 | i1 << 4) & 252645135;
|
|
450
|
-
i1 = (i1 | i1 << 2) & 858993459;
|
|
451
|
-
i1 = (i1 | i1 << 1) & 1431655765;
|
|
452
|
-
return (i1 << 1 | i0) >>> 0;
|
|
490
|
+
C = c ^ (a & c >> 4 ^ b & d >> 4);
|
|
491
|
+
D = d ^ (b & c >> 4 ^ (a ^ b) & d >> 4);
|
|
492
|
+
c = C ^ (A & C >> 8 ^ B & D >> 8);
|
|
493
|
+
d = D ^ (B & C >> 8 ^ (A ^ B) & D >> 8);
|
|
494
|
+
c ^= c >> 1;
|
|
495
|
+
d ^= d >> 1;
|
|
496
|
+
a = x ^ y;
|
|
497
|
+
b = d | 65535 ^ (a | c);
|
|
498
|
+
a = (a | a << 8) & 16711935;
|
|
499
|
+
a = (a | a << 4) & 252645135;
|
|
500
|
+
a = (a | a << 2) & 858993459;
|
|
501
|
+
a = (a | a << 1) & 1431655765;
|
|
502
|
+
b = (b | b << 8) & 16711935;
|
|
503
|
+
b = (b | b << 4) & 252645135;
|
|
504
|
+
b = (b | b << 2) & 858993459;
|
|
505
|
+
b = (b | b << 1) & 1431655765;
|
|
506
|
+
return ((b << 1 | a) >>> 0) - 2147483648;
|
|
453
507
|
}
|
|
454
508
|
//#endregion
|
|
455
509
|
//#region src/2d/lib/intersections.ts
|