@tscircuit/3d-viewer 0.0.200 → 0.0.201
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/index.js +139 -126
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -5478,7 +5478,7 @@ var require_cylinder = __commonJS({
|
|
|
5478
5478
|
var geom3 = require_geom3();
|
|
5479
5479
|
var cylinderElliptic = require_cylinderElliptic();
|
|
5480
5480
|
var { isGTE } = require_commonChecks();
|
|
5481
|
-
var
|
|
5481
|
+
var cylinder3 = (options) => {
|
|
5482
5482
|
const defaults = {
|
|
5483
5483
|
center: [0, 0, 0],
|
|
5484
5484
|
height: 2,
|
|
@@ -5497,7 +5497,7 @@ var require_cylinder = __commonJS({
|
|
|
5497
5497
|
};
|
|
5498
5498
|
return cylinderElliptic(newoptions);
|
|
5499
5499
|
};
|
|
5500
|
-
module.exports =
|
|
5500
|
+
module.exports = cylinder3;
|
|
5501
5501
|
}
|
|
5502
5502
|
});
|
|
5503
5503
|
|
|
@@ -5766,11 +5766,11 @@ var require_line = __commonJS({
|
|
|
5766
5766
|
"node_modules/@jscad/modeling/src/primitives/line.js"(exports, module) {
|
|
5767
5767
|
"use strict";
|
|
5768
5768
|
var path2 = require_path2();
|
|
5769
|
-
var
|
|
5769
|
+
var line2 = (points) => {
|
|
5770
5770
|
if (!Array.isArray(points)) throw new Error("points must be an array");
|
|
5771
5771
|
return path2.fromPoints({}, points);
|
|
5772
5772
|
};
|
|
5773
|
-
module.exports =
|
|
5773
|
+
module.exports = line2;
|
|
5774
5774
|
}
|
|
5775
5775
|
});
|
|
5776
5776
|
|
|
@@ -6018,7 +6018,7 @@ var require_roundedCylinder = __commonJS({
|
|
|
6018
6018
|
var poly3 = require_poly3();
|
|
6019
6019
|
var { sin, cos } = require_trigonometry();
|
|
6020
6020
|
var { isGTE, isNumberArray } = require_commonChecks();
|
|
6021
|
-
var
|
|
6021
|
+
var cylinder3 = require_cylinder();
|
|
6022
6022
|
var roundedCylinder = (options) => {
|
|
6023
6023
|
const defaults = {
|
|
6024
6024
|
center: [0, 0, 0],
|
|
@@ -6035,7 +6035,7 @@ var require_roundedCylinder = __commonJS({
|
|
|
6035
6035
|
if (roundRadius > radius) throw new Error("roundRadius must be smaller than the radius");
|
|
6036
6036
|
if (!isGTE(segments, 4)) throw new Error("segments must be four or more");
|
|
6037
6037
|
if (height === 0 || radius === 0) return geom3.create();
|
|
6038
|
-
if (roundRadius === 0) return
|
|
6038
|
+
if (roundRadius === 0) return cylinder3({ center, height, radius });
|
|
6039
6039
|
const start = [0, 0, -(height / 2)];
|
|
6040
6040
|
const end = [0, 0, height / 2];
|
|
6041
6041
|
const direction = vec3.subtract(vec3.create(), end, start);
|
|
@@ -8513,11 +8513,11 @@ var require_clone10 = __commonJS({
|
|
|
8513
8513
|
"node_modules/@jscad/modeling/src/maths/line2/clone.js"(exports, module) {
|
|
8514
8514
|
"use strict";
|
|
8515
8515
|
var create = require_create11();
|
|
8516
|
-
var clone = (
|
|
8516
|
+
var clone = (line2) => {
|
|
8517
8517
|
const out = create();
|
|
8518
|
-
out[0] =
|
|
8519
|
-
out[1] =
|
|
8520
|
-
out[2] =
|
|
8518
|
+
out[0] = line2[0];
|
|
8519
|
+
out[1] = line2[1];
|
|
8520
|
+
out[2] = line2[2];
|
|
8521
8521
|
return out;
|
|
8522
8522
|
};
|
|
8523
8523
|
module.exports = clone;
|
|
@@ -8529,8 +8529,8 @@ var require_direction = __commonJS({
|
|
|
8529
8529
|
"node_modules/@jscad/modeling/src/maths/line2/direction.js"(exports, module) {
|
|
8530
8530
|
"use strict";
|
|
8531
8531
|
var vec2 = require_vec2();
|
|
8532
|
-
var direction = (
|
|
8533
|
-
const vector = vec2.normal(vec2.create(),
|
|
8532
|
+
var direction = (line2) => {
|
|
8533
|
+
const vector = vec2.normal(vec2.create(), line2);
|
|
8534
8534
|
vec2.negate(vector, vector);
|
|
8535
8535
|
return vector;
|
|
8536
8536
|
};
|
|
@@ -8543,7 +8543,7 @@ var require_origin = __commonJS({
|
|
|
8543
8543
|
"node_modules/@jscad/modeling/src/maths/line2/origin.js"(exports, module) {
|
|
8544
8544
|
"use strict";
|
|
8545
8545
|
var vec2 = require_vec2();
|
|
8546
|
-
var origin = (
|
|
8546
|
+
var origin = (line2) => vec2.scale(vec2.create(), line2, line2[2]);
|
|
8547
8547
|
module.exports = origin;
|
|
8548
8548
|
}
|
|
8549
8549
|
});
|
|
@@ -8555,9 +8555,9 @@ var require_closestPoint = __commonJS({
|
|
|
8555
8555
|
var vec2 = require_vec2();
|
|
8556
8556
|
var direction = require_direction();
|
|
8557
8557
|
var origin = require_origin();
|
|
8558
|
-
var closestPoint = (
|
|
8559
|
-
const orig = origin(
|
|
8560
|
-
const dir = direction(
|
|
8558
|
+
var closestPoint = (line2, point) => {
|
|
8559
|
+
const orig = origin(line2);
|
|
8560
|
+
const dir = direction(line2);
|
|
8561
8561
|
const v = vec2.subtract(vec2.create(), point, orig);
|
|
8562
8562
|
const dist = vec2.dot(v, dir);
|
|
8563
8563
|
vec2.scale(v, dir, dist);
|
|
@@ -8572,10 +8572,10 @@ var require_closestPoint = __commonJS({
|
|
|
8572
8572
|
var require_copy5 = __commonJS({
|
|
8573
8573
|
"node_modules/@jscad/modeling/src/maths/line2/copy.js"(exports, module) {
|
|
8574
8574
|
"use strict";
|
|
8575
|
-
var copy = (out,
|
|
8576
|
-
out[0] =
|
|
8577
|
-
out[1] =
|
|
8578
|
-
out[2] =
|
|
8575
|
+
var copy = (out, line2) => {
|
|
8576
|
+
out[0] = line2[0];
|
|
8577
|
+
out[1] = line2[1];
|
|
8578
|
+
out[2] = line2[2];
|
|
8579
8579
|
return out;
|
|
8580
8580
|
};
|
|
8581
8581
|
module.exports = copy;
|
|
@@ -8587,9 +8587,9 @@ var require_distanceToPoint = __commonJS({
|
|
|
8587
8587
|
"node_modules/@jscad/modeling/src/maths/line2/distanceToPoint.js"(exports, module) {
|
|
8588
8588
|
"use strict";
|
|
8589
8589
|
var vec2 = require_vec2();
|
|
8590
|
-
var distanceToPoint = (
|
|
8591
|
-
let distance = vec2.dot(point,
|
|
8592
|
-
distance = Math.abs(distance -
|
|
8590
|
+
var distanceToPoint = (line2, point) => {
|
|
8591
|
+
let distance = vec2.dot(point, line2);
|
|
8592
|
+
distance = Math.abs(distance - line2[2]);
|
|
8593
8593
|
return distance;
|
|
8594
8594
|
};
|
|
8595
8595
|
module.exports = distanceToPoint;
|
|
@@ -8600,7 +8600,7 @@ var require_distanceToPoint = __commonJS({
|
|
|
8600
8600
|
var require_equals7 = __commonJS({
|
|
8601
8601
|
"node_modules/@jscad/modeling/src/maths/line2/equals.js"(exports, module) {
|
|
8602
8602
|
"use strict";
|
|
8603
|
-
var equals = (line1,
|
|
8603
|
+
var equals = (line1, line2) => line1[0] === line2[0] && (line1[1] === line2[1] && line1[2] === line2[2]);
|
|
8604
8604
|
module.exports = equals;
|
|
8605
8605
|
}
|
|
8606
8606
|
});
|
|
@@ -8646,8 +8646,8 @@ var require_intersectPointOfLines = __commonJS({
|
|
|
8646
8646
|
"use strict";
|
|
8647
8647
|
var vec2 = require_vec2();
|
|
8648
8648
|
var { solve2Linear } = require_utils();
|
|
8649
|
-
var intersectToLine = (line1,
|
|
8650
|
-
const point = solve2Linear(line1[0], line1[1],
|
|
8649
|
+
var intersectToLine = (line1, line2) => {
|
|
8650
|
+
const point = solve2Linear(line1[0], line1[1], line2[0], line2[1], line1[2], line2[2]);
|
|
8651
8651
|
return vec2.clone(point);
|
|
8652
8652
|
};
|
|
8653
8653
|
module.exports = intersectToLine;
|
|
@@ -8661,9 +8661,9 @@ var require_reverse4 = __commonJS({
|
|
|
8661
8661
|
var vec2 = require_vec2();
|
|
8662
8662
|
var copy = require_copy5();
|
|
8663
8663
|
var fromValues = require_fromValues5();
|
|
8664
|
-
var reverse = (out,
|
|
8665
|
-
const normal = vec2.negate(vec2.create(),
|
|
8666
|
-
const distance = -
|
|
8664
|
+
var reverse = (out, line2) => {
|
|
8665
|
+
const normal = vec2.negate(vec2.create(), line2);
|
|
8666
|
+
const distance = -line2[2];
|
|
8667
8667
|
return copy(out, fromValues(normal[0], normal[1], distance));
|
|
8668
8668
|
};
|
|
8669
8669
|
module.exports = reverse;
|
|
@@ -8674,7 +8674,7 @@ var require_reverse4 = __commonJS({
|
|
|
8674
8674
|
var require_toString10 = __commonJS({
|
|
8675
8675
|
"node_modules/@jscad/modeling/src/maths/line2/toString.js"(exports, module) {
|
|
8676
8676
|
"use strict";
|
|
8677
|
-
var toString = (
|
|
8677
|
+
var toString = (line2) => `line2: (${line2[0].toFixed(7)}, ${line2[1].toFixed(7)}, ${line2[2].toFixed(7)})`;
|
|
8678
8678
|
module.exports = toString;
|
|
8679
8679
|
}
|
|
8680
8680
|
});
|
|
@@ -8687,9 +8687,9 @@ var require_transform10 = __commonJS({
|
|
|
8687
8687
|
var fromPoints = require_fromPoints7();
|
|
8688
8688
|
var origin = require_origin();
|
|
8689
8689
|
var direction = require_direction();
|
|
8690
|
-
var transform = (out,
|
|
8691
|
-
const org = origin(
|
|
8692
|
-
const dir = direction(
|
|
8690
|
+
var transform = (out, line2, matrix) => {
|
|
8691
|
+
const org = origin(line2);
|
|
8692
|
+
const dir = direction(line2);
|
|
8693
8693
|
vec2.transform(org, org, matrix);
|
|
8694
8694
|
vec2.transform(dir, dir, matrix);
|
|
8695
8695
|
return fromPoints(out, org, dir);
|
|
@@ -8703,10 +8703,10 @@ var require_xAtY = __commonJS({
|
|
|
8703
8703
|
"node_modules/@jscad/modeling/src/maths/line2/xAtY.js"(exports, module) {
|
|
8704
8704
|
"use strict";
|
|
8705
8705
|
var origin = require_origin();
|
|
8706
|
-
var xAtY = (
|
|
8707
|
-
let x = (
|
|
8706
|
+
var xAtY = (line2, y) => {
|
|
8707
|
+
let x = (line2[2] - line2[1] * y) / line2[0];
|
|
8708
8708
|
if (Number.isNaN(x)) {
|
|
8709
|
-
const org = origin(
|
|
8709
|
+
const org = origin(line2);
|
|
8710
8710
|
x = org[0];
|
|
8711
8711
|
}
|
|
8712
8712
|
return x;
|
|
@@ -8745,7 +8745,7 @@ var require_offsetFromPoints = __commonJS({
|
|
|
8745
8745
|
"use strict";
|
|
8746
8746
|
var { EPS, TAU } = require_constants();
|
|
8747
8747
|
var intersect = require_intersect();
|
|
8748
|
-
var
|
|
8748
|
+
var line2 = require_line2();
|
|
8749
8749
|
var vec2 = require_vec2();
|
|
8750
8750
|
var area = require_area();
|
|
8751
8751
|
var offsetFromPoints = (options, points) => {
|
|
@@ -8809,12 +8809,12 @@ var require_offsetFromPoints = __commonJS({
|
|
|
8809
8809
|
if (corners === "edge") {
|
|
8810
8810
|
const pointIndex = /* @__PURE__ */ new Map();
|
|
8811
8811
|
newPoints.forEach((point, index) => pointIndex.set(point, index));
|
|
8812
|
-
const line0 =
|
|
8813
|
-
const line1 =
|
|
8812
|
+
const line0 = line2.create();
|
|
8813
|
+
const line1 = line2.create();
|
|
8814
8814
|
newCorners.forEach((corner) => {
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
const ip =
|
|
8815
|
+
line2.fromPoints(line0, corner.s0[0], corner.s0[1]);
|
|
8816
|
+
line2.fromPoints(line1, corner.s1[0], corner.s1[1]);
|
|
8817
|
+
const ip = line2.intersectPointOfLines(line0, line1);
|
|
8818
8818
|
if (Number.isFinite(ip[0]) && Number.isFinite(ip[1])) {
|
|
8819
8819
|
const p0 = corner.s0[1];
|
|
8820
8820
|
const i = pointIndex.get(p0);
|
|
@@ -9306,7 +9306,7 @@ var require_reTesselateCoplanarPolygons = __commonJS({
|
|
|
9306
9306
|
"node_modules/@jscad/modeling/src/operations/modifiers/reTesselateCoplanarPolygons.js"(exports, module) {
|
|
9307
9307
|
"use strict";
|
|
9308
9308
|
var { EPS } = require_constants();
|
|
9309
|
-
var
|
|
9309
|
+
var line2 = require_line2();
|
|
9310
9310
|
var vec2 = require_vec2();
|
|
9311
9311
|
var OrthoNormalBasis = require_OrthoNormalBasis();
|
|
9312
9312
|
var interpolateBetween2DPointsForY = require_interpolateBetween2DPointsForY();
|
|
@@ -9492,8 +9492,8 @@ var require_reTesselateCoplanarPolygons = __commonJS({
|
|
|
9492
9492
|
topright,
|
|
9493
9493
|
bottomleft,
|
|
9494
9494
|
bottomright,
|
|
9495
|
-
leftline:
|
|
9496
|
-
rightline:
|
|
9495
|
+
leftline: line2.fromPoints(line2.create(), topleft, bottomleft),
|
|
9496
|
+
rightline: line2.fromPoints(line2.create(), bottomright, topright)
|
|
9497
9497
|
};
|
|
9498
9498
|
if (newoutpolygonrow.length > 0) {
|
|
9499
9499
|
const prevoutpolygon = newoutpolygonrow[newoutpolygonrow.length - 1];
|
|
@@ -9519,11 +9519,11 @@ var require_reTesselateCoplanarPolygons = __commonJS({
|
|
|
9519
9519
|
if (vec2.distance(prevpolygon.bottomleft, thispolygon.topleft) < EPS) {
|
|
9520
9520
|
if (vec2.distance(prevpolygon.bottomright, thispolygon.topright) < EPS) {
|
|
9521
9521
|
matchedindexes.add(ii);
|
|
9522
|
-
const v1 =
|
|
9523
|
-
const v2 =
|
|
9522
|
+
const v1 = line2.direction(thispolygon.leftline);
|
|
9523
|
+
const v2 = line2.direction(prevpolygon.leftline);
|
|
9524
9524
|
const d1 = v1[0] - v2[0];
|
|
9525
|
-
const v3 =
|
|
9526
|
-
const v4 =
|
|
9525
|
+
const v3 = line2.direction(thispolygon.rightline);
|
|
9526
|
+
const v4 = line2.direction(prevpolygon.rightline);
|
|
9527
9527
|
const d2 = v3[0] - v4[0];
|
|
9528
9528
|
const leftlinecontinues = Math.abs(d1) < EPS;
|
|
9529
9529
|
const rightlinecontinues = Math.abs(d2) < EPS;
|
|
@@ -10468,8 +10468,8 @@ var require_expandShell = __commonJS({
|
|
|
10468
10468
|
endfacevertices.reverse();
|
|
10469
10469
|
polygons2.push(poly3.create(startfacevertices));
|
|
10470
10470
|
polygons2.push(poly3.create(endfacevertices));
|
|
10471
|
-
const
|
|
10472
|
-
result = unionGeom3Sub(result,
|
|
10471
|
+
const cylinder3 = geom3.create(polygons2);
|
|
10472
|
+
result = unionGeom3Sub(result, cylinder3);
|
|
10473
10473
|
});
|
|
10474
10474
|
vertices2planes.forEach((item) => {
|
|
10475
10475
|
const vertex = item[0];
|
|
@@ -11707,9 +11707,9 @@ var require_vectorText = __commonJS({
|
|
|
11707
11707
|
"use strict";
|
|
11708
11708
|
var vectorChar = require_vectorChar();
|
|
11709
11709
|
var vectorParams = require_vectorParams();
|
|
11710
|
-
var translateLine = (options,
|
|
11710
|
+
var translateLine = (options, line2) => {
|
|
11711
11711
|
const { x, y } = Object.assign({ x: 0, y: 0 }, options || {});
|
|
11712
|
-
const segments =
|
|
11712
|
+
const segments = line2.segments;
|
|
11713
11713
|
let segment = null;
|
|
11714
11714
|
let point = null;
|
|
11715
11715
|
for (let i = 0, il = segments.length; i < il; i++) {
|
|
@@ -11719,7 +11719,7 @@ var require_vectorText = __commonJS({
|
|
|
11719
11719
|
segment[j] = [point[0] + x, point[1] + y];
|
|
11720
11720
|
}
|
|
11721
11721
|
}
|
|
11722
|
-
return
|
|
11722
|
+
return line2;
|
|
11723
11723
|
};
|
|
11724
11724
|
var vectorText2 = (options, text) => {
|
|
11725
11725
|
const {
|
|
@@ -11735,15 +11735,15 @@ var require_vectorText = __commonJS({
|
|
|
11735
11735
|
} = vectorParams(options, text);
|
|
11736
11736
|
let [x, y] = [xOffset, yOffset];
|
|
11737
11737
|
let i, il, char, vect, width, diff;
|
|
11738
|
-
let
|
|
11738
|
+
let line2 = { width: 0, segments: [] };
|
|
11739
11739
|
const lines = [];
|
|
11740
11740
|
let output = [];
|
|
11741
11741
|
let maxWidth = 0;
|
|
11742
11742
|
const lineStart = x;
|
|
11743
11743
|
const pushLine = () => {
|
|
11744
|
-
lines.push(
|
|
11745
|
-
maxWidth = Math.max(maxWidth,
|
|
11746
|
-
|
|
11744
|
+
lines.push(line2);
|
|
11745
|
+
maxWidth = Math.max(maxWidth, line2.width);
|
|
11746
|
+
line2 = { width: 0, segments: [] };
|
|
11747
11747
|
};
|
|
11748
11748
|
for (i = 0, il = input.length; i < il; i++) {
|
|
11749
11749
|
char = input[i];
|
|
@@ -11755,26 +11755,26 @@ var require_vectorText = __commonJS({
|
|
|
11755
11755
|
continue;
|
|
11756
11756
|
}
|
|
11757
11757
|
width = vect.width * letterSpacing;
|
|
11758
|
-
|
|
11758
|
+
line2.width += width;
|
|
11759
11759
|
x += width;
|
|
11760
11760
|
if (char !== " ") {
|
|
11761
|
-
|
|
11761
|
+
line2.segments = line2.segments.concat(vect.segments);
|
|
11762
11762
|
}
|
|
11763
11763
|
}
|
|
11764
|
-
if (
|
|
11764
|
+
if (line2.segments.length) {
|
|
11765
11765
|
pushLine();
|
|
11766
11766
|
}
|
|
11767
11767
|
for (i = 0, il = lines.length; i < il; i++) {
|
|
11768
|
-
|
|
11769
|
-
if (maxWidth >
|
|
11770
|
-
diff = maxWidth -
|
|
11768
|
+
line2 = lines[i];
|
|
11769
|
+
if (maxWidth > line2.width) {
|
|
11770
|
+
diff = maxWidth - line2.width;
|
|
11771
11771
|
if (align === "right") {
|
|
11772
|
-
|
|
11772
|
+
line2 = translateLine({ x: diff }, line2);
|
|
11773
11773
|
} else if (align === "center") {
|
|
11774
|
-
|
|
11774
|
+
line2 = translateLine({ x: diff / 2 }, line2);
|
|
11775
11775
|
}
|
|
11776
11776
|
}
|
|
11777
|
-
output = output.concat(
|
|
11777
|
+
output = output.concat(line2.segments);
|
|
11778
11778
|
}
|
|
11779
11779
|
return output;
|
|
11780
11780
|
};
|
|
@@ -12051,10 +12051,10 @@ var require_clone11 = __commonJS({
|
|
|
12051
12051
|
"use strict";
|
|
12052
12052
|
var vec3 = require_vec3();
|
|
12053
12053
|
var create = require_create13();
|
|
12054
|
-
var clone = (
|
|
12054
|
+
var clone = (line2) => {
|
|
12055
12055
|
const out = create();
|
|
12056
|
-
vec3.copy(out[0],
|
|
12057
|
-
vec3.copy(out[1],
|
|
12056
|
+
vec3.copy(out[0], line2[0]);
|
|
12057
|
+
vec3.copy(out[1], line2[1]);
|
|
12058
12058
|
return out;
|
|
12059
12059
|
};
|
|
12060
12060
|
module.exports = clone;
|
|
@@ -12066,9 +12066,9 @@ var require_closestPoint2 = __commonJS({
|
|
|
12066
12066
|
"node_modules/@jscad/modeling/src/maths/line3/closestPoint.js"(exports, module) {
|
|
12067
12067
|
"use strict";
|
|
12068
12068
|
var vec3 = require_vec3();
|
|
12069
|
-
var closestPoint = (
|
|
12070
|
-
const lpoint =
|
|
12071
|
-
const ldirection =
|
|
12069
|
+
var closestPoint = (line2, point) => {
|
|
12070
|
+
const lpoint = line2[0];
|
|
12071
|
+
const ldirection = line2[1];
|
|
12072
12072
|
const a = vec3.dot(vec3.subtract(vec3.create(), point, lpoint), ldirection);
|
|
12073
12073
|
const b = vec3.dot(ldirection, ldirection);
|
|
12074
12074
|
const t = a / b;
|
|
@@ -12085,9 +12085,9 @@ var require_copy6 = __commonJS({
|
|
|
12085
12085
|
"node_modules/@jscad/modeling/src/maths/line3/copy.js"(exports, module) {
|
|
12086
12086
|
"use strict";
|
|
12087
12087
|
var vec3 = require_vec3();
|
|
12088
|
-
var copy = (out,
|
|
12089
|
-
vec3.copy(out[0],
|
|
12090
|
-
vec3.copy(out[1],
|
|
12088
|
+
var copy = (out, line2) => {
|
|
12089
|
+
vec3.copy(out[0], line2[0]);
|
|
12090
|
+
vec3.copy(out[1], line2[1]);
|
|
12091
12091
|
return out;
|
|
12092
12092
|
};
|
|
12093
12093
|
module.exports = copy;
|
|
@@ -12098,7 +12098,7 @@ var require_copy6 = __commonJS({
|
|
|
12098
12098
|
var require_direction2 = __commonJS({
|
|
12099
12099
|
"node_modules/@jscad/modeling/src/maths/line3/direction.js"(exports, module) {
|
|
12100
12100
|
"use strict";
|
|
12101
|
-
var direction = (
|
|
12101
|
+
var direction = (line2) => line2[1];
|
|
12102
12102
|
module.exports = direction;
|
|
12103
12103
|
}
|
|
12104
12104
|
});
|
|
@@ -12109,8 +12109,8 @@ var require_distanceToPoint2 = __commonJS({
|
|
|
12109
12109
|
"use strict";
|
|
12110
12110
|
var vec3 = require_vec3();
|
|
12111
12111
|
var closestPoint = require_closestPoint2();
|
|
12112
|
-
var distanceToPoint = (
|
|
12113
|
-
const closest = closestPoint(
|
|
12112
|
+
var distanceToPoint = (line2, point) => {
|
|
12113
|
+
const closest = closestPoint(line2, point);
|
|
12114
12114
|
const distancevector = vec3.subtract(vec3.create(), point, closest);
|
|
12115
12115
|
return vec3.length(distancevector);
|
|
12116
12116
|
};
|
|
@@ -12123,9 +12123,9 @@ var require_equals8 = __commonJS({
|
|
|
12123
12123
|
"node_modules/@jscad/modeling/src/maths/line3/equals.js"(exports, module) {
|
|
12124
12124
|
"use strict";
|
|
12125
12125
|
var vec3 = require_vec3();
|
|
12126
|
-
var equals = (line1,
|
|
12127
|
-
if (!vec3.equals(line1[1],
|
|
12128
|
-
if (!vec3.equals(line1[0],
|
|
12126
|
+
var equals = (line1, line2) => {
|
|
12127
|
+
if (!vec3.equals(line1[1], line2[1])) return false;
|
|
12128
|
+
if (!vec3.equals(line1[0], line2[0])) return false;
|
|
12129
12129
|
return true;
|
|
12130
12130
|
};
|
|
12131
12131
|
module.exports = equals;
|
|
@@ -12203,11 +12203,11 @@ var require_intersectPointOfLineAndPlane = __commonJS({
|
|
|
12203
12203
|
"node_modules/@jscad/modeling/src/maths/line3/intersectPointOfLineAndPlane.js"(exports, module) {
|
|
12204
12204
|
"use strict";
|
|
12205
12205
|
var vec3 = require_vec3();
|
|
12206
|
-
var intersectToPlane = (
|
|
12206
|
+
var intersectToPlane = (line2, plane) => {
|
|
12207
12207
|
const pnormal = plane;
|
|
12208
12208
|
const pw = plane[3];
|
|
12209
|
-
const lpoint =
|
|
12210
|
-
const ldirection =
|
|
12209
|
+
const lpoint = line2[0];
|
|
12210
|
+
const ldirection = line2[1];
|
|
12211
12211
|
const labda = (pw - vec3.dot(pnormal, lpoint)) / vec3.dot(pnormal, ldirection);
|
|
12212
12212
|
const point = vec3.add(vec3.create(), lpoint, vec3.scale(vec3.create(), ldirection, labda));
|
|
12213
12213
|
return point;
|
|
@@ -12220,7 +12220,7 @@ var require_intersectPointOfLineAndPlane = __commonJS({
|
|
|
12220
12220
|
var require_origin2 = __commonJS({
|
|
12221
12221
|
"node_modules/@jscad/modeling/src/maths/line3/origin.js"(exports, module) {
|
|
12222
12222
|
"use strict";
|
|
12223
|
-
var origin = (
|
|
12223
|
+
var origin = (line2) => line2[0];
|
|
12224
12224
|
module.exports = origin;
|
|
12225
12225
|
}
|
|
12226
12226
|
});
|
|
@@ -12231,9 +12231,9 @@ var require_reverse5 = __commonJS({
|
|
|
12231
12231
|
"use strict";
|
|
12232
12232
|
var vec3 = require_vec3();
|
|
12233
12233
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
12234
|
-
var reverse = (out,
|
|
12235
|
-
const point = vec3.clone(
|
|
12236
|
-
const direction = vec3.negate(vec3.create(),
|
|
12234
|
+
var reverse = (out, line2) => {
|
|
12235
|
+
const point = vec3.clone(line2[0]);
|
|
12236
|
+
const direction = vec3.negate(vec3.create(), line2[1]);
|
|
12237
12237
|
return fromPointAndDirection(out, point, direction);
|
|
12238
12238
|
};
|
|
12239
12239
|
module.exports = reverse;
|
|
@@ -12244,9 +12244,9 @@ var require_reverse5 = __commonJS({
|
|
|
12244
12244
|
var require_toString11 = __commonJS({
|
|
12245
12245
|
"node_modules/@jscad/modeling/src/maths/line3/toString.js"(exports, module) {
|
|
12246
12246
|
"use strict";
|
|
12247
|
-
var toString = (
|
|
12248
|
-
const point =
|
|
12249
|
-
const direction =
|
|
12247
|
+
var toString = (line2) => {
|
|
12248
|
+
const point = line2[0];
|
|
12249
|
+
const direction = line2[1];
|
|
12250
12250
|
return `line3: point: (${point[0].toFixed(7)}, ${point[1].toFixed(7)}, ${point[2].toFixed(7)}) direction: (${direction[0].toFixed(7)}, ${direction[1].toFixed(7)}, ${direction[2].toFixed(7)})`;
|
|
12251
12251
|
};
|
|
12252
12252
|
module.exports = toString;
|
|
@@ -12259,9 +12259,9 @@ var require_transform12 = __commonJS({
|
|
|
12259
12259
|
"use strict";
|
|
12260
12260
|
var vec3 = require_vec3();
|
|
12261
12261
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
12262
|
-
var transform = (out,
|
|
12263
|
-
const point =
|
|
12264
|
-
const direction =
|
|
12262
|
+
var transform = (out, line2, matrix) => {
|
|
12263
|
+
const point = line2[0];
|
|
12264
|
+
const direction = line2[1];
|
|
12265
12265
|
const pointPlusDirection = vec3.add(vec3.create(), point, direction);
|
|
12266
12266
|
const newpoint = vec3.transform(vec3.create(), point, matrix);
|
|
12267
12267
|
const newPointPlusDirection = vec3.transform(pointPlusDirection, pointPlusDirection, matrix);
|
|
@@ -16232,15 +16232,15 @@ var MTLLoader = class extends Loader2 {
|
|
|
16232
16232
|
const delimiter_pattern = /\s+/;
|
|
16233
16233
|
const materialsInfo = {};
|
|
16234
16234
|
for (let i = 0; i < lines.length; i++) {
|
|
16235
|
-
let
|
|
16236
|
-
|
|
16237
|
-
if (
|
|
16235
|
+
let line2 = lines[i];
|
|
16236
|
+
line2 = line2.trim();
|
|
16237
|
+
if (line2.length === 0 || line2.charAt(0) === "#") {
|
|
16238
16238
|
continue;
|
|
16239
16239
|
}
|
|
16240
|
-
const pos =
|
|
16241
|
-
let key = pos >= 0 ?
|
|
16240
|
+
const pos = line2.indexOf(" ");
|
|
16241
|
+
let key = pos >= 0 ? line2.substring(0, pos) : line2;
|
|
16242
16242
|
key = key.toLowerCase();
|
|
16243
|
-
let value = pos >= 0 ?
|
|
16243
|
+
let value = pos >= 0 ? line2.substring(pos + 1) : "";
|
|
16244
16244
|
value = value.trim();
|
|
16245
16245
|
if (key === "newmtl") {
|
|
16246
16246
|
info = { name: value };
|
|
@@ -16753,21 +16753,21 @@ var OBJLoader = class extends Loader3 {
|
|
|
16753
16753
|
text = text.replace(/\\\n/g, "");
|
|
16754
16754
|
}
|
|
16755
16755
|
const lines = text.split("\n");
|
|
16756
|
-
let
|
|
16756
|
+
let line2 = "", lineFirstChar = "";
|
|
16757
16757
|
let lineLength = 0;
|
|
16758
16758
|
let result = [];
|
|
16759
16759
|
const trimLeft = typeof "".trimLeft === "function";
|
|
16760
16760
|
for (let i = 0, l = lines.length; i < l; i++) {
|
|
16761
|
-
|
|
16762
|
-
|
|
16763
|
-
lineLength =
|
|
16761
|
+
line2 = lines[i];
|
|
16762
|
+
line2 = trimLeft ? line2.trimLeft() : line2.trim();
|
|
16763
|
+
lineLength = line2.length;
|
|
16764
16764
|
if (lineLength === 0)
|
|
16765
16765
|
continue;
|
|
16766
|
-
lineFirstChar =
|
|
16766
|
+
lineFirstChar = line2.charAt(0);
|
|
16767
16767
|
if (lineFirstChar === "#")
|
|
16768
16768
|
continue;
|
|
16769
16769
|
if (lineFirstChar === "v") {
|
|
16770
|
-
const data =
|
|
16770
|
+
const data = line2.split(/\s+/);
|
|
16771
16771
|
switch (data[0]) {
|
|
16772
16772
|
case "v":
|
|
16773
16773
|
state.vertices.push(parseFloat(data[1]), parseFloat(data[2]), parseFloat(data[3]));
|
|
@@ -16785,7 +16785,7 @@ var OBJLoader = class extends Loader3 {
|
|
|
16785
16785
|
break;
|
|
16786
16786
|
}
|
|
16787
16787
|
} else if (lineFirstChar === "f") {
|
|
16788
|
-
const lineData =
|
|
16788
|
+
const lineData = line2.substr(1).trim();
|
|
16789
16789
|
const vertexData = lineData.split(/\s+/);
|
|
16790
16790
|
const faceVertices = [];
|
|
16791
16791
|
for (let j = 0, jl = vertexData.length; j < jl; j++) {
|
|
@@ -16802,10 +16802,10 @@ var OBJLoader = class extends Loader3 {
|
|
|
16802
16802
|
state.addFace(v1[0], v2[0], v3[0], v1[1], v2[1], v3[1], v1[2], v2[2], v3[2]);
|
|
16803
16803
|
}
|
|
16804
16804
|
} else if (lineFirstChar === "l") {
|
|
16805
|
-
const lineParts =
|
|
16805
|
+
const lineParts = line2.substring(1).trim().split(" ");
|
|
16806
16806
|
let lineVertices = [];
|
|
16807
16807
|
const lineUVs = [];
|
|
16808
|
-
if (
|
|
16808
|
+
if (line2.indexOf("/") === -1) {
|
|
16809
16809
|
lineVertices = lineParts;
|
|
16810
16810
|
} else {
|
|
16811
16811
|
for (let li = 0, llen = lineParts.length; li < llen; li++) {
|
|
@@ -16818,22 +16818,22 @@ var OBJLoader = class extends Loader3 {
|
|
|
16818
16818
|
}
|
|
16819
16819
|
state.addLineGeometry(lineVertices, lineUVs);
|
|
16820
16820
|
} else if (lineFirstChar === "p") {
|
|
16821
|
-
const lineData =
|
|
16821
|
+
const lineData = line2.substr(1).trim();
|
|
16822
16822
|
const pointData = lineData.split(" ");
|
|
16823
16823
|
state.addPointGeometry(pointData);
|
|
16824
|
-
} else if ((result = _object_pattern.exec(
|
|
16824
|
+
} else if ((result = _object_pattern.exec(line2)) !== null) {
|
|
16825
16825
|
const name = (" " + result[0].substr(1).trim()).substr(1);
|
|
16826
16826
|
state.startObject(name);
|
|
16827
|
-
} else if (_material_use_pattern.test(
|
|
16828
|
-
state.object.startMaterial(
|
|
16829
|
-
} else if (_material_library_pattern.test(
|
|
16830
|
-
state.materialLibraries.push(
|
|
16831
|
-
} else if (_map_use_pattern.test(
|
|
16827
|
+
} else if (_material_use_pattern.test(line2)) {
|
|
16828
|
+
state.object.startMaterial(line2.substring(7).trim(), state.materialLibraries);
|
|
16829
|
+
} else if (_material_library_pattern.test(line2)) {
|
|
16830
|
+
state.materialLibraries.push(line2.substring(7).trim());
|
|
16831
|
+
} else if (_map_use_pattern.test(line2)) {
|
|
16832
16832
|
console.warn(
|
|
16833
16833
|
'THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.'
|
|
16834
16834
|
);
|
|
16835
16835
|
} else if (lineFirstChar === "s") {
|
|
16836
|
-
result =
|
|
16836
|
+
result = line2.split(" ");
|
|
16837
16837
|
if (result.length > 1) {
|
|
16838
16838
|
const value = result[1].trim().toLowerCase();
|
|
16839
16839
|
state.object.smooth = value !== "0" && value !== "off";
|
|
@@ -16844,9 +16844,9 @@ var OBJLoader = class extends Loader3 {
|
|
|
16844
16844
|
if (material)
|
|
16845
16845
|
material.smooth = state.object.smooth;
|
|
16846
16846
|
} else {
|
|
16847
|
-
if (
|
|
16847
|
+
if (line2 === "\0")
|
|
16848
16848
|
continue;
|
|
16849
|
-
console.warn('THREE.OBJLoader: Unexpected line: "' +
|
|
16849
|
+
console.warn('THREE.OBJLoader: Unexpected line: "' + line2 + '"');
|
|
16850
16850
|
}
|
|
16851
16851
|
}
|
|
16852
16852
|
state.finalize();
|
|
@@ -16982,7 +16982,7 @@ import { Canvas, useFrame as useFrame2 } from "@react-three/fiber";
|
|
|
16982
16982
|
// package.json
|
|
16983
16983
|
var package_default = {
|
|
16984
16984
|
name: "@tscircuit/3d-viewer",
|
|
16985
|
-
version: "0.0.
|
|
16985
|
+
version: "0.0.200",
|
|
16986
16986
|
main: "./dist/index.js",
|
|
16987
16987
|
module: "./dist/index.js",
|
|
16988
16988
|
type: "module",
|
|
@@ -17046,7 +17046,7 @@ var package_default = {
|
|
|
17046
17046
|
"@vitejs/plugin-react": "^4.3.4",
|
|
17047
17047
|
"bun-match-svg": "^0.0.9",
|
|
17048
17048
|
"bun-types": "^1.2.1",
|
|
17049
|
-
"circuit-json": "^0.0.
|
|
17049
|
+
"circuit-json": "^0.0.154",
|
|
17050
17050
|
"circuit-to-svg": "^0.0.91",
|
|
17051
17051
|
debug: "^4.4.0",
|
|
17052
17052
|
jsdom: "^26.0.0",
|
|
@@ -17302,7 +17302,17 @@ var M = 0.01;
|
|
|
17302
17302
|
var colors = {
|
|
17303
17303
|
copper: [0.9, 0.6, 0.2],
|
|
17304
17304
|
fr4Green: [5 / 255, 163 / 255, 46 / 255],
|
|
17305
|
-
fr4GreenSolderWithMask: [0 / 255, 152 / 255, 19 / 255]
|
|
17305
|
+
fr4GreenSolderWithMask: [0 / 255, 152 / 255, 19 / 255],
|
|
17306
|
+
fr1Copper: [0.8, 0.4, 0.2],
|
|
17307
|
+
fr1CopperSolderWithMask: [0.9, 0.6, 0.2]
|
|
17308
|
+
};
|
|
17309
|
+
var boardMaterialColors = {
|
|
17310
|
+
fr1: colors.fr1Copper,
|
|
17311
|
+
fr4: colors.fr4Green
|
|
17312
|
+
};
|
|
17313
|
+
var tracesMaterialColors = {
|
|
17314
|
+
fr1: colors.fr1CopperSolderWithMask,
|
|
17315
|
+
fr4: colors.fr4GreenSolderWithMask
|
|
17306
17316
|
};
|
|
17307
17317
|
|
|
17308
17318
|
// src/geoms/create-board-with-outline.ts
|
|
@@ -17354,7 +17364,8 @@ var createSimplifiedBoardGeom = (circuitJson) => {
|
|
|
17354
17364
|
center: [board.center.x, board.center.y, 0]
|
|
17355
17365
|
});
|
|
17356
17366
|
}
|
|
17357
|
-
|
|
17367
|
+
const material = boardMaterialColors[board.material] ?? colors.fr4Green;
|
|
17368
|
+
return [(0, import_colors.colorize)(material, boardGeom)];
|
|
17358
17369
|
};
|
|
17359
17370
|
var createBoardGeomFromCircuitJson = (circuitJson, opts = {}) => {
|
|
17360
17371
|
console.warn(
|
|
@@ -17789,7 +17800,8 @@ var BoardGeomBuilder = class {
|
|
|
17789
17800
|
[0, 0, zPos],
|
|
17790
17801
|
(0, import_extrusions2.extrudeLinear)({ height: M }, expandedPath)
|
|
17791
17802
|
);
|
|
17792
|
-
|
|
17803
|
+
const tracesMaterialColor = tracesMaterialColors[this.board.material] ?? colors.fr4GreenSolderWithMask;
|
|
17804
|
+
traceGeom = (0, import_colors3.colorize)(tracesMaterialColor, traceGeom);
|
|
17793
17805
|
this.traceGeoms.push(traceGeom);
|
|
17794
17806
|
}
|
|
17795
17807
|
currentSegmentPoints = [];
|
|
@@ -17877,7 +17889,8 @@ var BoardGeomBuilder = class {
|
|
|
17877
17889
|
}
|
|
17878
17890
|
finalize() {
|
|
17879
17891
|
if (!this.boardGeom) return;
|
|
17880
|
-
this.
|
|
17892
|
+
const boardMaterialColor = boardMaterialColors[this.board.material] ?? colors.fr4Green;
|
|
17893
|
+
this.boardGeom = (0, import_colors3.colorize)(boardMaterialColor, this.boardGeom);
|
|
17881
17894
|
this.finalGeoms = [
|
|
17882
17895
|
this.boardGeom,
|
|
17883
17896
|
...this.platedHoleGeoms,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.201",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@vitejs/plugin-react": "^4.3.4",
|
|
65
65
|
"bun-match-svg": "^0.0.9",
|
|
66
66
|
"bun-types": "^1.2.1",
|
|
67
|
-
"circuit-json": "^0.0.
|
|
67
|
+
"circuit-json": "^0.0.154",
|
|
68
68
|
"circuit-to-svg": "^0.0.91",
|
|
69
69
|
"debug": "^4.4.0",
|
|
70
70
|
"jsdom": "^26.0.0",
|