@tscircuit/3d-viewer 0.0.389 → 0.0.391
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 +433 -230
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1129,13 +1129,13 @@ var require_squaredLength = __commonJS({
|
|
|
1129
1129
|
var require_subtract = __commonJS({
|
|
1130
1130
|
"node_modules/@jscad/modeling/src/maths/vec3/subtract.js"(exports, module) {
|
|
1131
1131
|
"use strict";
|
|
1132
|
-
var
|
|
1132
|
+
var subtract4 = (out, a, b) => {
|
|
1133
1133
|
out[0] = a[0] - b[0];
|
|
1134
1134
|
out[1] = a[1] - b[1];
|
|
1135
1135
|
out[2] = a[2] - b[2];
|
|
1136
1136
|
return out;
|
|
1137
1137
|
};
|
|
1138
|
-
module.exports =
|
|
1138
|
+
module.exports = subtract4;
|
|
1139
1139
|
}
|
|
1140
1140
|
});
|
|
1141
1141
|
|
|
@@ -1676,7 +1676,7 @@ var require_scale2 = __commonJS({
|
|
|
1676
1676
|
var require_subtract2 = __commonJS({
|
|
1677
1677
|
"node_modules/@jscad/modeling/src/maths/mat4/subtract.js"(exports, module) {
|
|
1678
1678
|
"use strict";
|
|
1679
|
-
var
|
|
1679
|
+
var subtract4 = (out, a, b) => {
|
|
1680
1680
|
out[0] = a[0] - b[0];
|
|
1681
1681
|
out[1] = a[1] - b[1];
|
|
1682
1682
|
out[2] = a[2] - b[2];
|
|
@@ -1695,7 +1695,7 @@ var require_subtract2 = __commonJS({
|
|
|
1695
1695
|
out[15] = a[15] - b[15];
|
|
1696
1696
|
return out;
|
|
1697
1697
|
};
|
|
1698
|
-
module.exports =
|
|
1698
|
+
module.exports = subtract4;
|
|
1699
1699
|
}
|
|
1700
1700
|
});
|
|
1701
1701
|
|
|
@@ -2205,12 +2205,12 @@ var require_squaredLength2 = __commonJS({
|
|
|
2205
2205
|
var require_subtract3 = __commonJS({
|
|
2206
2206
|
"node_modules/@jscad/modeling/src/maths/vec2/subtract.js"(exports, module) {
|
|
2207
2207
|
"use strict";
|
|
2208
|
-
var
|
|
2208
|
+
var subtract4 = (out, a, b) => {
|
|
2209
2209
|
out[0] = a[0] - b[0];
|
|
2210
2210
|
out[1] = a[1] - b[1];
|
|
2211
2211
|
return out;
|
|
2212
2212
|
};
|
|
2213
|
-
module.exports =
|
|
2213
|
+
module.exports = subtract4;
|
|
2214
2214
|
}
|
|
2215
2215
|
});
|
|
2216
2216
|
|
|
@@ -2671,14 +2671,14 @@ var require_point_line_distance = __commonJS({
|
|
|
2671
2671
|
"node_modules/@jscad/modeling/src/operations/hulls/quickhull/point-line-distance.js"(exports, module) {
|
|
2672
2672
|
"use strict";
|
|
2673
2673
|
var cross = require_cross();
|
|
2674
|
-
var
|
|
2674
|
+
var subtract4 = require_subtract();
|
|
2675
2675
|
var squaredLength = require_squaredLength();
|
|
2676
2676
|
var distanceSquared = (p, a, b) => {
|
|
2677
2677
|
const ab = [];
|
|
2678
2678
|
const ap = [];
|
|
2679
2679
|
const cr = [];
|
|
2680
|
-
|
|
2681
|
-
|
|
2680
|
+
subtract4(ab, b, a);
|
|
2681
|
+
subtract4(ap, p, a);
|
|
2682
2682
|
const area = squaredLength(cross(cr, ap, ab));
|
|
2683
2683
|
const s = squaredLength(ab);
|
|
2684
2684
|
if (s === 0) {
|
|
@@ -2697,11 +2697,11 @@ var require_get_plane_normal = __commonJS({
|
|
|
2697
2697
|
"use strict";
|
|
2698
2698
|
var cross = require_cross();
|
|
2699
2699
|
var normalize = require_normalize();
|
|
2700
|
-
var
|
|
2700
|
+
var subtract4 = require_subtract();
|
|
2701
2701
|
var planeNormal = (out, point1, point2, point32) => {
|
|
2702
2702
|
const tmp = [0, 0, 0];
|
|
2703
|
-
|
|
2704
|
-
|
|
2703
|
+
subtract4(out, point1, point2);
|
|
2704
|
+
subtract4(tmp, point2, point32);
|
|
2705
2705
|
cross(out, out, tmp);
|
|
2706
2706
|
return normalize(out, out);
|
|
2707
2707
|
};
|
|
@@ -2915,7 +2915,7 @@ var require_Face = __commonJS({
|
|
|
2915
2915
|
var length2 = require_length();
|
|
2916
2916
|
var normalize = require_normalize();
|
|
2917
2917
|
var scale2 = require_scale();
|
|
2918
|
-
var
|
|
2918
|
+
var subtract4 = require_subtract();
|
|
2919
2919
|
var HalfEdge = require_HalfEdge();
|
|
2920
2920
|
var VISIBLE = 0;
|
|
2921
2921
|
var NON_CONVEX = 1;
|
|
@@ -2949,14 +2949,14 @@ var require_Face = __commonJS({
|
|
|
2949
2949
|
const e0 = this.edge;
|
|
2950
2950
|
const e1 = e0.next;
|
|
2951
2951
|
let e2 = e1.next;
|
|
2952
|
-
const v2 =
|
|
2952
|
+
const v2 = subtract4([], e1.head().point, e0.head().point);
|
|
2953
2953
|
const t = [];
|
|
2954
2954
|
const v1 = [];
|
|
2955
2955
|
this.nVertices = 2;
|
|
2956
2956
|
this.normal = [0, 0, 0];
|
|
2957
2957
|
while (e2 !== e0) {
|
|
2958
2958
|
copy(v1, v2);
|
|
2959
|
-
|
|
2959
|
+
subtract4(v2, e2.head().point, e0.head().point);
|
|
2960
2960
|
add(this.normal, this.normal, cross(t, v1, v2));
|
|
2961
2961
|
e2 = e2.next;
|
|
2962
2962
|
this.nVertices += 1;
|
|
@@ -2980,7 +2980,7 @@ var require_Face = __commonJS({
|
|
|
2980
2980
|
} while (edge !== this.edge);
|
|
2981
2981
|
const p1 = maxEdge.tail().point;
|
|
2982
2982
|
const p2 = maxEdge.head().point;
|
|
2983
|
-
const maxVector =
|
|
2983
|
+
const maxVector = subtract4([], p2, p1);
|
|
2984
2984
|
const maxLength = Math.sqrt(maxSquaredLength);
|
|
2985
2985
|
scale2(maxVector, maxVector, 1 / maxLength);
|
|
2986
2986
|
const maxProjection = dot(this.normal, maxVector);
|
|
@@ -4102,11 +4102,11 @@ var require_invert2 = __commonJS({
|
|
|
4102
4102
|
"use strict";
|
|
4103
4103
|
var plane = require_plane();
|
|
4104
4104
|
var create = require_create6();
|
|
4105
|
-
var invert = (
|
|
4106
|
-
const vertices =
|
|
4105
|
+
var invert = (polygon3) => {
|
|
4106
|
+
const vertices = polygon3.vertices.slice().reverse();
|
|
4107
4107
|
const inverted = create(vertices);
|
|
4108
|
-
if (
|
|
4109
|
-
inverted.plane = plane.flip(plane.create(),
|
|
4108
|
+
if (polygon3.plane) {
|
|
4109
|
+
inverted.plane = plane.flip(plane.create(), polygon3.plane);
|
|
4110
4110
|
}
|
|
4111
4111
|
return inverted;
|
|
4112
4112
|
};
|
|
@@ -4138,7 +4138,7 @@ var require_isConvex = __commonJS({
|
|
|
4138
4138
|
"use strict";
|
|
4139
4139
|
var plane = require_plane();
|
|
4140
4140
|
var vec3 = require_vec3();
|
|
4141
|
-
var isConvex = (
|
|
4141
|
+
var isConvex = (polygon3) => areVerticesConvex(polygon3.vertices);
|
|
4142
4142
|
var areVerticesConvex = (vertices) => {
|
|
4143
4143
|
const numvertices = vertices.length;
|
|
4144
4144
|
if (numvertices > 2) {
|
|
@@ -4174,11 +4174,11 @@ var require_plane2 = __commonJS({
|
|
|
4174
4174
|
"node_modules/@jscad/modeling/src/geometries/poly3/plane.js"(exports, module) {
|
|
4175
4175
|
"use strict";
|
|
4176
4176
|
var mplane = require_plane();
|
|
4177
|
-
var plane = (
|
|
4178
|
-
if (!
|
|
4179
|
-
|
|
4177
|
+
var plane = (polygon3) => {
|
|
4178
|
+
if (!polygon3.plane) {
|
|
4179
|
+
polygon3.plane = mplane.fromPoints(mplane.create(), ...polygon3.vertices);
|
|
4180
4180
|
}
|
|
4181
|
-
return
|
|
4181
|
+
return polygon3.plane;
|
|
4182
4182
|
};
|
|
4183
4183
|
module.exports = plane;
|
|
4184
4184
|
}
|
|
@@ -4189,13 +4189,13 @@ var require_measureArea = __commonJS({
|
|
|
4189
4189
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureArea.js"(exports, module) {
|
|
4190
4190
|
"use strict";
|
|
4191
4191
|
var plane = require_plane2();
|
|
4192
|
-
var measureArea = (
|
|
4193
|
-
const n =
|
|
4192
|
+
var measureArea = (polygon3) => {
|
|
4193
|
+
const n = polygon3.vertices.length;
|
|
4194
4194
|
if (n < 3) {
|
|
4195
4195
|
return 0;
|
|
4196
4196
|
}
|
|
4197
|
-
const vertices =
|
|
4198
|
-
const normal = plane(
|
|
4197
|
+
const vertices = polygon3.vertices;
|
|
4198
|
+
const normal = plane(polygon3);
|
|
4199
4199
|
const ax = Math.abs(normal[0]);
|
|
4200
4200
|
const ay = Math.abs(normal[1]);
|
|
4201
4201
|
const az = Math.abs(normal[2]);
|
|
@@ -4254,8 +4254,8 @@ var require_measureBoundingBox = __commonJS({
|
|
|
4254
4254
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureBoundingBox.js"(exports, module) {
|
|
4255
4255
|
"use strict";
|
|
4256
4256
|
var vec3 = require_vec3();
|
|
4257
|
-
var measureBoundingBox = (
|
|
4258
|
-
const vertices =
|
|
4257
|
+
var measureBoundingBox = (polygon3) => {
|
|
4258
|
+
const vertices = polygon3.vertices;
|
|
4259
4259
|
const numvertices = vertices.length;
|
|
4260
4260
|
const min = numvertices === 0 ? vec3.create() : vec3.clone(vertices[0]);
|
|
4261
4261
|
const max = vec3.clone(min);
|
|
@@ -4333,10 +4333,10 @@ var require_measureBoundingSphere = __commonJS({
|
|
|
4333
4333
|
"use strict";
|
|
4334
4334
|
var vec4 = require_vec4();
|
|
4335
4335
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
4336
|
-
var measureBoundingSphere = (
|
|
4337
|
-
const boundingSphere = cache.get(
|
|
4336
|
+
var measureBoundingSphere = (polygon3) => {
|
|
4337
|
+
const boundingSphere = cache.get(polygon3);
|
|
4338
4338
|
if (boundingSphere) return boundingSphere;
|
|
4339
|
-
const vertices =
|
|
4339
|
+
const vertices = polygon3.vertices;
|
|
4340
4340
|
const out = vec4.create();
|
|
4341
4341
|
if (vertices.length === 0) {
|
|
4342
4342
|
out[0] = 0;
|
|
@@ -4366,7 +4366,7 @@ var require_measureBoundingSphere = __commonJS({
|
|
|
4366
4366
|
const y = out[1] - maxy[1];
|
|
4367
4367
|
const z105 = out[2] - maxz[2];
|
|
4368
4368
|
out[3] = Math.sqrt(x * x + y * y + z105 * z105);
|
|
4369
|
-
cache.set(
|
|
4369
|
+
cache.set(polygon3, out);
|
|
4370
4370
|
return out;
|
|
4371
4371
|
};
|
|
4372
4372
|
module.exports = measureBoundingSphere;
|
|
@@ -4378,9 +4378,9 @@ var require_measureSignedVolume = __commonJS({
|
|
|
4378
4378
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureSignedVolume.js"(exports, module) {
|
|
4379
4379
|
"use strict";
|
|
4380
4380
|
var vec3 = require_vec3();
|
|
4381
|
-
var measureSignedVolume = (
|
|
4381
|
+
var measureSignedVolume = (polygon3) => {
|
|
4382
4382
|
let signedVolume = 0;
|
|
4383
|
-
const vertices =
|
|
4383
|
+
const vertices = polygon3.vertices;
|
|
4384
4384
|
const cross = vec3.create();
|
|
4385
4385
|
for (let i = 0; i < vertices.length - 2; i++) {
|
|
4386
4386
|
vec3.cross(cross, vertices[i + 1], vertices[i + 2]);
|
|
@@ -4397,7 +4397,7 @@ var require_measureSignedVolume = __commonJS({
|
|
|
4397
4397
|
var require_toPoints2 = __commonJS({
|
|
4398
4398
|
"node_modules/@jscad/modeling/src/geometries/poly3/toPoints.js"(exports, module) {
|
|
4399
4399
|
"use strict";
|
|
4400
|
-
var toPoints = (
|
|
4400
|
+
var toPoints = (polygon3) => polygon3.vertices;
|
|
4401
4401
|
module.exports = toPoints;
|
|
4402
4402
|
}
|
|
4403
4403
|
});
|
|
@@ -4407,9 +4407,9 @@ var require_toString6 = __commonJS({
|
|
|
4407
4407
|
"node_modules/@jscad/modeling/src/geometries/poly3/toString.js"(exports, module) {
|
|
4408
4408
|
"use strict";
|
|
4409
4409
|
var vec3 = require_vec3();
|
|
4410
|
-
var toString = (
|
|
4410
|
+
var toString = (polygon3) => {
|
|
4411
4411
|
let result = "poly3: vertices: [";
|
|
4412
|
-
|
|
4412
|
+
polygon3.vertices.forEach((vertex) => {
|
|
4413
4413
|
result += `${vec3.toString(vertex)}, `;
|
|
4414
4414
|
});
|
|
4415
4415
|
result += "]";
|
|
@@ -4426,8 +4426,8 @@ var require_transform6 = __commonJS({
|
|
|
4426
4426
|
var mat4 = require_mat4();
|
|
4427
4427
|
var vec3 = require_vec3();
|
|
4428
4428
|
var create = require_create6();
|
|
4429
|
-
var transform2 = (matrix,
|
|
4430
|
-
const vertices =
|
|
4429
|
+
var transform2 = (matrix, polygon3) => {
|
|
4430
|
+
const vertices = polygon3.vertices.map((vertex) => vec3.transform(vec3.create(), vertex, matrix));
|
|
4431
4431
|
if (mat4.isMirroring(matrix)) {
|
|
4432
4432
|
vertices.reverse();
|
|
4433
4433
|
}
|
|
@@ -4543,8 +4543,8 @@ var require_fromPoints4 = __commonJS({
|
|
|
4543
4543
|
throw new Error("the given points must be an array");
|
|
4544
4544
|
}
|
|
4545
4545
|
const polygons = listofpoints.map((points, index) => {
|
|
4546
|
-
const
|
|
4547
|
-
return
|
|
4546
|
+
const polygon3 = poly3.create(points);
|
|
4547
|
+
return polygon3;
|
|
4548
4548
|
});
|
|
4549
4549
|
const result = create(polygons);
|
|
4550
4550
|
return result;
|
|
@@ -4595,7 +4595,7 @@ var require_applyTransforms2 = __commonJS({
|
|
|
4595
4595
|
var poly3 = require_poly3();
|
|
4596
4596
|
var applyTransforms = (geometry) => {
|
|
4597
4597
|
if (mat4.isIdentity(geometry.transforms)) return geometry;
|
|
4598
|
-
geometry.polygons = geometry.polygons.map((
|
|
4598
|
+
geometry.polygons = geometry.polygons.map((polygon3) => poly3.transform(geometry.transforms, polygon3));
|
|
4599
4599
|
geometry.transforms = mat4.create();
|
|
4600
4600
|
return geometry;
|
|
4601
4601
|
};
|
|
@@ -4622,7 +4622,7 @@ var require_invert3 = __commonJS({
|
|
|
4622
4622
|
var toPolygons = require_toPolygons();
|
|
4623
4623
|
var invert = (geometry) => {
|
|
4624
4624
|
const polygons = toPolygons(geometry);
|
|
4625
|
-
const newpolygons = polygons.map((
|
|
4625
|
+
const newpolygons = polygons.map((polygon3) => poly3.invert(polygon3));
|
|
4626
4626
|
return create(newpolygons);
|
|
4627
4627
|
};
|
|
4628
4628
|
module.exports = invert;
|
|
@@ -4655,7 +4655,7 @@ var require_toPoints3 = __commonJS({
|
|
|
4655
4655
|
var toPolygons = require_toPolygons();
|
|
4656
4656
|
var toPoints = (geometry) => {
|
|
4657
4657
|
const polygons = toPolygons(geometry);
|
|
4658
|
-
const listofpoints = polygons.map((
|
|
4658
|
+
const listofpoints = polygons.map((polygon3) => poly3.toPoints(polygon3));
|
|
4659
4659
|
return listofpoints;
|
|
4660
4660
|
};
|
|
4661
4661
|
module.exports = toPoints;
|
|
@@ -4671,8 +4671,8 @@ var require_toString7 = __commonJS({
|
|
|
4671
4671
|
var toString = (geometry) => {
|
|
4672
4672
|
const polygons = toPolygons(geometry);
|
|
4673
4673
|
let result = "geom3 (" + polygons.length + " polygons):\n";
|
|
4674
|
-
polygons.forEach((
|
|
4675
|
-
result += " " + poly3.toString(
|
|
4674
|
+
polygons.forEach((polygon3) => {
|
|
4675
|
+
result += " " + poly3.toString(polygon3) + "\n";
|
|
4676
4676
|
});
|
|
4677
4677
|
return result;
|
|
4678
4678
|
};
|
|
@@ -4689,7 +4689,7 @@ var require_toCompactBinary2 = __commonJS({
|
|
|
4689
4689
|
const polygons = geometry.polygons;
|
|
4690
4690
|
const transforms2 = geometry.transforms;
|
|
4691
4691
|
const numberOfPolygons = polygons.length;
|
|
4692
|
-
const numberOfVertices = polygons.reduce((count,
|
|
4692
|
+
const numberOfVertices = polygons.reduce((count, polygon3) => count + polygon3.vertices.length, 0);
|
|
4693
4693
|
let color = [-1, -1, -1, -1];
|
|
4694
4694
|
if (geometry.color) color = geometry.color;
|
|
4695
4695
|
const compacted = new Float32Array(1 + 16 + 4 + 1 + numberOfPolygons + numberOfVertices * 3);
|
|
@@ -4717,8 +4717,8 @@ var require_toCompactBinary2 = __commonJS({
|
|
|
4717
4717
|
compacted[21] = numberOfVertices;
|
|
4718
4718
|
let ci = 22;
|
|
4719
4719
|
let vi = ci + numberOfPolygons;
|
|
4720
|
-
polygons.forEach((
|
|
4721
|
-
const points = poly3.toPoints(
|
|
4720
|
+
polygons.forEach((polygon3) => {
|
|
4721
|
+
const points = poly3.toPoints(polygon3);
|
|
4722
4722
|
compacted[ci] = points.length;
|
|
4723
4723
|
ci++;
|
|
4724
4724
|
for (let i = 0; i < points.length; i++) {
|
|
@@ -6146,7 +6146,7 @@ var require_measureArea2 = __commonJS({
|
|
|
6146
6146
|
"node_modules/@jscad/modeling/src/geometries/poly2/measureArea.js"(exports, module) {
|
|
6147
6147
|
"use strict";
|
|
6148
6148
|
var area = require_area();
|
|
6149
|
-
var measureArea = (
|
|
6149
|
+
var measureArea = (polygon3) => area(polygon3.vertices);
|
|
6150
6150
|
module.exports = measureArea;
|
|
6151
6151
|
}
|
|
6152
6152
|
});
|
|
@@ -6170,8 +6170,8 @@ var require_flip2 = __commonJS({
|
|
|
6170
6170
|
"node_modules/@jscad/modeling/src/geometries/poly2/flip.js"(exports, module) {
|
|
6171
6171
|
"use strict";
|
|
6172
6172
|
var create = require_create10();
|
|
6173
|
-
var flip = (
|
|
6174
|
-
const vertices =
|
|
6173
|
+
var flip = (polygon3) => {
|
|
6174
|
+
const vertices = polygon3.vertices.slice().reverse();
|
|
6175
6175
|
return create(vertices);
|
|
6176
6176
|
};
|
|
6177
6177
|
module.exports = flip;
|
|
@@ -6184,22 +6184,22 @@ var require_arePointsInside = __commonJS({
|
|
|
6184
6184
|
"use strict";
|
|
6185
6185
|
var measureArea = require_measureArea2();
|
|
6186
6186
|
var flip = require_flip2();
|
|
6187
|
-
var arePointsInside = (points,
|
|
6187
|
+
var arePointsInside = (points, polygon3) => {
|
|
6188
6188
|
if (points.length === 0) return 0;
|
|
6189
|
-
const vertices =
|
|
6189
|
+
const vertices = polygon3.vertices;
|
|
6190
6190
|
if (vertices.length < 3) return 0;
|
|
6191
|
-
if (measureArea(
|
|
6192
|
-
|
|
6191
|
+
if (measureArea(polygon3) < 0) {
|
|
6192
|
+
polygon3 = flip(polygon3);
|
|
6193
6193
|
}
|
|
6194
6194
|
const sum = points.reduce((acc, point2) => acc + isPointInside(point2, vertices), 0);
|
|
6195
6195
|
return sum === points.length ? 1 : 0;
|
|
6196
6196
|
};
|
|
6197
|
-
var isPointInside = (point2,
|
|
6198
|
-
const numverts =
|
|
6197
|
+
var isPointInside = (point2, polygon3) => {
|
|
6198
|
+
const numverts = polygon3.length;
|
|
6199
6199
|
const tx = point2[0];
|
|
6200
6200
|
const ty = point2[1];
|
|
6201
|
-
let vtx0 =
|
|
6202
|
-
let vtx1 =
|
|
6201
|
+
let vtx0 = polygon3[numverts - 1];
|
|
6202
|
+
let vtx1 = polygon3[0];
|
|
6203
6203
|
let yflag0 = vtx0[1] > ty;
|
|
6204
6204
|
let insideFlag = 0;
|
|
6205
6205
|
let i = 0;
|
|
@@ -6218,7 +6218,7 @@ var require_arePointsInside = __commonJS({
|
|
|
6218
6218
|
}
|
|
6219
6219
|
yflag0 = yflag1;
|
|
6220
6220
|
vtx0 = vtx1;
|
|
6221
|
-
vtx1 =
|
|
6221
|
+
vtx1 = polygon3[++i];
|
|
6222
6222
|
}
|
|
6223
6223
|
return insideFlag;
|
|
6224
6224
|
};
|
|
@@ -6897,7 +6897,7 @@ var require_measureArea3 = __commonJS({
|
|
|
6897
6897
|
let area = cache.get(geometry);
|
|
6898
6898
|
if (area) return area;
|
|
6899
6899
|
const polygons = geom3.toPolygons(geometry);
|
|
6900
|
-
area = polygons.reduce((area2,
|
|
6900
|
+
area = polygons.reduce((area2, polygon3) => area2 + poly3.measureArea(polygon3), 0);
|
|
6901
6901
|
cache.set(geometry, area);
|
|
6902
6902
|
return area;
|
|
6903
6903
|
};
|
|
@@ -7000,8 +7000,8 @@ var require_measureBoundingBox2 = __commonJS({
|
|
|
7000
7000
|
vec3.copy(minpoint, points[0]);
|
|
7001
7001
|
}
|
|
7002
7002
|
let maxpoint = vec3.clone(minpoint);
|
|
7003
|
-
polygons.forEach((
|
|
7004
|
-
poly3.toPoints(
|
|
7003
|
+
polygons.forEach((polygon3) => {
|
|
7004
|
+
poly3.toPoints(polygon3).forEach((point2) => {
|
|
7005
7005
|
vec3.min(minpoint, minpoint, point2);
|
|
7006
7006
|
vec3.max(maxpoint, maxpoint, point2);
|
|
7007
7007
|
});
|
|
@@ -7108,7 +7108,7 @@ var require_measureVolume = __commonJS({
|
|
|
7108
7108
|
let volume = cache.get(geometry);
|
|
7109
7109
|
if (volume) return volume;
|
|
7110
7110
|
const polygons = geom3.toPolygons(geometry);
|
|
7111
|
-
volume = polygons.reduce((volume2,
|
|
7111
|
+
volume = polygons.reduce((volume2, polygon3) => volume2 + poly3.measureSignedVolume(polygon3), 0);
|
|
7112
7112
|
cache.set(geometry, volume);
|
|
7113
7113
|
return volume;
|
|
7114
7114
|
};
|
|
@@ -7213,15 +7213,15 @@ var require_measureBoundingSphere2 = __commonJS({
|
|
|
7213
7213
|
const polygons = geom3.toPolygons(geometry);
|
|
7214
7214
|
if (polygons.length > 0) {
|
|
7215
7215
|
let numPoints = 0;
|
|
7216
|
-
polygons.forEach((
|
|
7217
|
-
poly3.toPoints(
|
|
7216
|
+
polygons.forEach((polygon3) => {
|
|
7217
|
+
poly3.toPoints(polygon3).forEach((point2) => {
|
|
7218
7218
|
vec3.add(centroid, centroid, point2);
|
|
7219
7219
|
numPoints++;
|
|
7220
7220
|
});
|
|
7221
7221
|
});
|
|
7222
7222
|
vec3.scale(centroid, centroid, 1 / numPoints);
|
|
7223
|
-
polygons.forEach((
|
|
7224
|
-
poly3.toPoints(
|
|
7223
|
+
polygons.forEach((polygon3) => {
|
|
7224
|
+
poly3.toPoints(polygon3).forEach((point2) => {
|
|
7225
7225
|
radius = Math.max(radius, vec3.squaredDistance(centroid, point2));
|
|
7226
7226
|
});
|
|
7227
7227
|
});
|
|
@@ -7309,8 +7309,8 @@ var require_measureCenterOfMass = __commonJS({
|
|
|
7309
7309
|
if (polygons.length === 0) return centerOfMass;
|
|
7310
7310
|
let totalVolume = 0;
|
|
7311
7311
|
const vector = vec3.create();
|
|
7312
|
-
polygons.forEach((
|
|
7313
|
-
const vertices =
|
|
7312
|
+
polygons.forEach((polygon3) => {
|
|
7313
|
+
const vertices = polygon3.vertices;
|
|
7314
7314
|
for (let i = 0; i < vertices.length - 2; i++) {
|
|
7315
7315
|
vec3.cross(vector, vertices[i + 1], vertices[i + 2]);
|
|
7316
7316
|
const volume = vec3.dot(vertices[0], vector) / 6;
|
|
@@ -7891,9 +7891,9 @@ var require_polyhedron = __commonJS({
|
|
|
7891
7891
|
faces.forEach((face) => face.reverse());
|
|
7892
7892
|
}
|
|
7893
7893
|
const polygons = faces.map((face, findex) => {
|
|
7894
|
-
const
|
|
7895
|
-
if (colors2 && colors2[findex])
|
|
7896
|
-
return
|
|
7894
|
+
const polygon3 = poly3.create(face.map((pindex) => points[pindex]));
|
|
7895
|
+
if (colors2 && colors2[findex]) polygon3.color = colors2[findex];
|
|
7896
|
+
return polygon3;
|
|
7897
7897
|
});
|
|
7898
7898
|
return geom3.create(polygons);
|
|
7899
7899
|
};
|
|
@@ -8046,7 +8046,7 @@ var require_polygon = __commonJS({
|
|
|
8046
8046
|
"node_modules/@jscad/modeling/src/primitives/polygon.js"(exports, module) {
|
|
8047
8047
|
"use strict";
|
|
8048
8048
|
var geom2 = require_geom2();
|
|
8049
|
-
var
|
|
8049
|
+
var polygon3 = (options) => {
|
|
8050
8050
|
const defaults = {
|
|
8051
8051
|
points: [],
|
|
8052
8052
|
paths: [],
|
|
@@ -8087,7 +8087,7 @@ var require_polygon = __commonJS({
|
|
|
8087
8087
|
}
|
|
8088
8088
|
return geometry;
|
|
8089
8089
|
};
|
|
8090
|
-
module.exports =
|
|
8090
|
+
module.exports = polygon3;
|
|
8091
8091
|
}
|
|
8092
8092
|
});
|
|
8093
8093
|
|
|
@@ -10343,12 +10343,12 @@ var require_fromFakePolygons = __commonJS({
|
|
|
10343
10343
|
"use strict";
|
|
10344
10344
|
var vec2 = require_vec2();
|
|
10345
10345
|
var geom2 = require_geom2();
|
|
10346
|
-
var fromFakePolygon = (epsilon,
|
|
10347
|
-
if (
|
|
10346
|
+
var fromFakePolygon = (epsilon, polygon3) => {
|
|
10347
|
+
if (polygon3.vertices.length < 4) {
|
|
10348
10348
|
return null;
|
|
10349
10349
|
}
|
|
10350
10350
|
const vert1Indices = [];
|
|
10351
|
-
const points3D =
|
|
10351
|
+
const points3D = polygon3.vertices.filter((vertex, i) => {
|
|
10352
10352
|
if (vertex[2] > 0) {
|
|
10353
10353
|
vert1Indices.push(i);
|
|
10354
10354
|
return true;
|
|
@@ -10375,7 +10375,7 @@ var require_fromFakePolygons = __commonJS({
|
|
|
10375
10375
|
return points2D;
|
|
10376
10376
|
};
|
|
10377
10377
|
var fromFakePolygons = (epsilon, polygons) => {
|
|
10378
|
-
const sides = polygons.map((
|
|
10378
|
+
const sides = polygons.map((polygon3) => fromFakePolygon(epsilon, polygon3)).filter((polygon3) => polygon3 !== null);
|
|
10379
10379
|
return geom2.create(sides);
|
|
10380
10380
|
};
|
|
10381
10381
|
module.exports = fromFakePolygons;
|
|
@@ -10732,8 +10732,8 @@ var require_reTesselateCoplanarPolygons = __commonJS({
|
|
|
10732
10732
|
prevpolygon.outpolygon.leftpoints.reverse();
|
|
10733
10733
|
const points2d = prevpolygon.outpolygon.rightpoints.concat(prevpolygon.outpolygon.leftpoints);
|
|
10734
10734
|
const vertices3d = points2d.map((point2d) => orthobasis.to3D(point2d));
|
|
10735
|
-
const
|
|
10736
|
-
if (
|
|
10735
|
+
const polygon3 = poly3.fromPointsAndPlane(vertices3d, plane);
|
|
10736
|
+
if (polygon3.vertices.length) destpolygons.push(polygon3);
|
|
10737
10737
|
}
|
|
10738
10738
|
}
|
|
10739
10739
|
}
|
|
@@ -10777,7 +10777,7 @@ var require_retessellate = __commonJS({
|
|
|
10777
10777
|
if (geometry.isRetesselated) {
|
|
10778
10778
|
return geometry;
|
|
10779
10779
|
}
|
|
10780
|
-
const polygons = geom3.toPolygons(geometry).map((
|
|
10780
|
+
const polygons = geom3.toPolygons(geometry).map((polygon3, index) => ({ vertices: polygon3.vertices, plane: poly3.plane(polygon3), index }));
|
|
10781
10781
|
const classified = classifyPolygons(polygons);
|
|
10782
10782
|
const destPolygons = [];
|
|
10783
10783
|
classified.forEach((group) => {
|
|
@@ -10823,8 +10823,8 @@ var require_retessellate = __commonJS({
|
|
|
10823
10823
|
clusters.forEach((cluster) => {
|
|
10824
10824
|
if (cluster[0]) result[cluster[0].index] = cluster;
|
|
10825
10825
|
});
|
|
10826
|
-
nonCoplanar.forEach((
|
|
10827
|
-
result[
|
|
10826
|
+
nonCoplanar.forEach((polygon3) => {
|
|
10827
|
+
result[polygon3.index] = polygon3;
|
|
10828
10828
|
});
|
|
10829
10829
|
return result;
|
|
10830
10830
|
};
|
|
@@ -11016,15 +11016,15 @@ var require_splitPolygonByPlane = __commonJS({
|
|
|
11016
11016
|
var vec3 = require_vec3();
|
|
11017
11017
|
var poly3 = require_poly3();
|
|
11018
11018
|
var splitLineSegmentByPlane = require_splitLineSegmentByPlane();
|
|
11019
|
-
var splitPolygonByPlane = (splane,
|
|
11019
|
+
var splitPolygonByPlane = (splane, polygon3) => {
|
|
11020
11020
|
const result = {
|
|
11021
11021
|
type: null,
|
|
11022
11022
|
front: null,
|
|
11023
11023
|
back: null
|
|
11024
11024
|
};
|
|
11025
|
-
const vertices =
|
|
11025
|
+
const vertices = polygon3.vertices;
|
|
11026
11026
|
const numvertices = vertices.length;
|
|
11027
|
-
const pplane = poly3.plane(
|
|
11027
|
+
const pplane = poly3.plane(polygon3);
|
|
11028
11028
|
if (plane.equals(pplane, splane)) {
|
|
11029
11029
|
result.type = 0;
|
|
11030
11030
|
} else {
|
|
@@ -11124,10 +11124,10 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11124
11124
|
var splitPolygonByPlane = require_splitPolygonByPlane();
|
|
11125
11125
|
var PolygonTreeNode = class _PolygonTreeNode {
|
|
11126
11126
|
// constructor creates the root node
|
|
11127
|
-
constructor(parent,
|
|
11127
|
+
constructor(parent, polygon3) {
|
|
11128
11128
|
this.parent = parent;
|
|
11129
11129
|
this.children = [];
|
|
11130
|
-
this.polygon =
|
|
11130
|
+
this.polygon = polygon3;
|
|
11131
11131
|
this.removed = false;
|
|
11132
11132
|
}
|
|
11133
11133
|
// fill the tree with polygons. Should be called on the root node only; child nodes must
|
|
@@ -11137,8 +11137,8 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11137
11137
|
throw new Error("Assertion failed");
|
|
11138
11138
|
}
|
|
11139
11139
|
const _this = this;
|
|
11140
|
-
polygons.forEach((
|
|
11141
|
-
_this.addChild(
|
|
11140
|
+
polygons.forEach((polygon3) => {
|
|
11141
|
+
_this.addChild(polygon3);
|
|
11142
11142
|
});
|
|
11143
11143
|
}
|
|
11144
11144
|
// remove a node
|
|
@@ -11215,9 +11215,9 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11215
11215
|
}
|
|
11216
11216
|
// only to be called for nodes with no children
|
|
11217
11217
|
_splitByPlane(splane, coplanarfrontnodes, coplanarbacknodes, frontnodes, backnodes) {
|
|
11218
|
-
const
|
|
11219
|
-
if (
|
|
11220
|
-
const bound = poly3.measureBoundingSphere(
|
|
11218
|
+
const polygon3 = this.polygon;
|
|
11219
|
+
if (polygon3) {
|
|
11220
|
+
const bound = poly3.measureBoundingSphere(polygon3);
|
|
11221
11221
|
const sphereradius = bound[3] + EPS;
|
|
11222
11222
|
const spherecenter = bound;
|
|
11223
11223
|
const d = vec3.dot(splane, spherecenter) - splane[3];
|
|
@@ -11226,7 +11226,7 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11226
11226
|
} else if (d < -sphereradius) {
|
|
11227
11227
|
backnodes.push(this);
|
|
11228
11228
|
} else {
|
|
11229
|
-
const splitresult = splitPolygonByPlane(splane,
|
|
11229
|
+
const splitresult = splitPolygonByPlane(splane, polygon3);
|
|
11230
11230
|
switch (splitresult.type) {
|
|
11231
11231
|
case 0:
|
|
11232
11232
|
coplanarfrontnodes.push(this);
|
|
@@ -11259,8 +11259,8 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11259
11259
|
// this should be called whenever the polygon is split
|
|
11260
11260
|
// a child should be created for every fragment of the split polygon
|
|
11261
11261
|
// returns the newly created child
|
|
11262
|
-
addChild(
|
|
11263
|
-
const newchild = new _PolygonTreeNode(this,
|
|
11262
|
+
addChild(polygon3) {
|
|
11263
|
+
const newchild = new _PolygonTreeNode(this, polygon3);
|
|
11264
11264
|
this.children.push(newchild);
|
|
11265
11265
|
return newchild;
|
|
11266
11266
|
}
|
|
@@ -11510,14 +11510,14 @@ var require_scissionGeom3 = __commonJS({
|
|
|
11510
11510
|
const pl = polygons.length;
|
|
11511
11511
|
const indexesPerPoint = /* @__PURE__ */ new Map();
|
|
11512
11512
|
const temp = vec3.create();
|
|
11513
|
-
polygons.forEach((
|
|
11514
|
-
|
|
11513
|
+
polygons.forEach((polygon3, index) => {
|
|
11514
|
+
polygon3.vertices.forEach((point2) => {
|
|
11515
11515
|
insertMapping(indexesPerPoint, vec3.snap(temp, point2, eps), index);
|
|
11516
11516
|
});
|
|
11517
11517
|
});
|
|
11518
|
-
const indexesPerPolygon = polygons.map((
|
|
11518
|
+
const indexesPerPolygon = polygons.map((polygon3) => {
|
|
11519
11519
|
let indexes = [];
|
|
11520
|
-
|
|
11520
|
+
polygon3.vertices.forEach((point2) => {
|
|
11521
11521
|
indexes = indexes.concat(findMapping(indexesPerPoint, vec3.snap(temp, point2, eps)));
|
|
11522
11522
|
});
|
|
11523
11523
|
return { e: 1, d: sortNb(indexes) };
|
|
@@ -11612,7 +11612,7 @@ var require_subtractGeom3 = __commonJS({
|
|
|
11612
11612
|
var flatten = require_flatten();
|
|
11613
11613
|
var retessellate = require_retessellate();
|
|
11614
11614
|
var subtractSub = require_subtractGeom3Sub();
|
|
11615
|
-
var
|
|
11615
|
+
var subtract4 = (...geometries2) => {
|
|
11616
11616
|
geometries2 = flatten(geometries2);
|
|
11617
11617
|
let newgeometry = geometries2.shift();
|
|
11618
11618
|
geometries2.forEach((geometry) => {
|
|
@@ -11621,7 +11621,7 @@ var require_subtractGeom3 = __commonJS({
|
|
|
11621
11621
|
newgeometry = retessellate(newgeometry);
|
|
11622
11622
|
return newgeometry;
|
|
11623
11623
|
};
|
|
11624
|
-
module.exports =
|
|
11624
|
+
module.exports = subtract4;
|
|
11625
11625
|
}
|
|
11626
11626
|
});
|
|
11627
11627
|
|
|
@@ -11635,14 +11635,14 @@ var require_subtractGeom2 = __commonJS({
|
|
|
11635
11635
|
var fromFakePolygons = require_fromFakePolygons();
|
|
11636
11636
|
var to3DWalls = require_to3DWalls();
|
|
11637
11637
|
var subtractGeom3 = require_subtractGeom3();
|
|
11638
|
-
var
|
|
11638
|
+
var subtract4 = (...geometries2) => {
|
|
11639
11639
|
geometries2 = flatten(geometries2);
|
|
11640
11640
|
const newgeometries = geometries2.map((geometry) => to3DWalls({ z0: -1, z1: 1 }, geometry));
|
|
11641
11641
|
const newgeom3 = subtractGeom3(newgeometries);
|
|
11642
11642
|
const epsilon = measureEpsilon(newgeom3);
|
|
11643
11643
|
return fromFakePolygons(epsilon, geom3.toPolygons(newgeom3));
|
|
11644
11644
|
};
|
|
11645
|
-
module.exports =
|
|
11645
|
+
module.exports = subtract4;
|
|
11646
11646
|
}
|
|
11647
11647
|
});
|
|
11648
11648
|
|
|
@@ -11656,7 +11656,7 @@ var require_subtract4 = __commonJS({
|
|
|
11656
11656
|
var geom3 = require_geom3();
|
|
11657
11657
|
var subtractGeom2 = require_subtractGeom2();
|
|
11658
11658
|
var subtractGeom3 = require_subtractGeom3();
|
|
11659
|
-
var
|
|
11659
|
+
var subtract4 = (...geometries2) => {
|
|
11660
11660
|
geometries2 = flatten(geometries2);
|
|
11661
11661
|
if (geometries2.length === 0) throw new Error("wrong number of arguments");
|
|
11662
11662
|
if (!areAllShapesTheSameType(geometries2)) {
|
|
@@ -11667,7 +11667,7 @@ var require_subtract4 = __commonJS({
|
|
|
11667
11667
|
if (geom3.isA(geometry)) return subtractGeom3(geometries2);
|
|
11668
11668
|
return geometry;
|
|
11669
11669
|
};
|
|
11670
|
-
module.exports =
|
|
11670
|
+
module.exports = subtract4;
|
|
11671
11671
|
}
|
|
11672
11672
|
});
|
|
11673
11673
|
|
|
@@ -11963,19 +11963,19 @@ var require_extrudePolygon = __commonJS({
|
|
|
11963
11963
|
polygon1 = poly3.invert(polygon1);
|
|
11964
11964
|
}
|
|
11965
11965
|
const newpolygons = [polygon1];
|
|
11966
|
-
const
|
|
11966
|
+
const polygon22 = poly3.transform(mat4.fromTranslation(mat4.create(), offsetvector), polygon1);
|
|
11967
11967
|
const numvertices = polygon1.vertices.length;
|
|
11968
11968
|
for (let i = 0; i < numvertices; i++) {
|
|
11969
11969
|
const nexti = i < numvertices - 1 ? i + 1 : 0;
|
|
11970
11970
|
const sideFacePolygon = poly3.create([
|
|
11971
11971
|
polygon1.vertices[i],
|
|
11972
|
-
|
|
11973
|
-
|
|
11972
|
+
polygon22.vertices[i],
|
|
11973
|
+
polygon22.vertices[nexti],
|
|
11974
11974
|
polygon1.vertices[nexti]
|
|
11975
11975
|
]);
|
|
11976
11976
|
newpolygons.push(sideFacePolygon);
|
|
11977
11977
|
}
|
|
11978
|
-
newpolygons.push(poly3.invert(
|
|
11978
|
+
newpolygons.push(poly3.invert(polygon22));
|
|
11979
11979
|
return geom3.create(newpolygons);
|
|
11980
11980
|
};
|
|
11981
11981
|
module.exports = extrudePolygon;
|
|
@@ -12036,17 +12036,17 @@ var require_expandShell = __commonJS({
|
|
|
12036
12036
|
const v1 = vec3.create();
|
|
12037
12037
|
const v2 = vec3.create();
|
|
12038
12038
|
const polygons = geom3.toPolygons(geometry);
|
|
12039
|
-
polygons.forEach((
|
|
12040
|
-
const extrudevector = vec3.scale(vec3.create(), poly3.plane(
|
|
12041
|
-
const translatedpolygon = poly3.transform(mat4.fromTranslation(mat4.create(), vec3.scale(vec3.create(), extrudevector, -0.5)),
|
|
12039
|
+
polygons.forEach((polygon3, index) => {
|
|
12040
|
+
const extrudevector = vec3.scale(vec3.create(), poly3.plane(polygon3), 2 * delta);
|
|
12041
|
+
const translatedpolygon = poly3.transform(mat4.fromTranslation(mat4.create(), vec3.scale(vec3.create(), extrudevector, -0.5)), polygon3);
|
|
12042
12042
|
const extrudedface = extrudePolygon(extrudevector, translatedpolygon);
|
|
12043
12043
|
result = unionGeom3Sub(result, extrudedface);
|
|
12044
|
-
const vertices =
|
|
12044
|
+
const vertices = polygon3.vertices;
|
|
12045
12045
|
for (let i = 0; i < vertices.length; i++) {
|
|
12046
|
-
mapPlaneToVertex(vertices2planes, vertices[i], poly3.plane(
|
|
12046
|
+
mapPlaneToVertex(vertices2planes, vertices[i], poly3.plane(polygon3));
|
|
12047
12047
|
const j = (i + 1) % vertices.length;
|
|
12048
12048
|
const edge = [vertices[i], vertices[j]];
|
|
12049
|
-
mapPlaneToEdge(edges2planes, edge, poly3.plane(
|
|
12049
|
+
mapPlaneToEdge(edges2planes, edge, poly3.plane(polygon3));
|
|
12050
12050
|
}
|
|
12051
12051
|
});
|
|
12052
12052
|
edges2planes.forEach((item) => {
|
|
@@ -12100,8 +12100,8 @@ var require_expandShell = __commonJS({
|
|
|
12100
12100
|
startfacevertices.push(p1);
|
|
12101
12101
|
endfacevertices.push(p2);
|
|
12102
12102
|
const points = [prevp2, p2, p1, prevp1];
|
|
12103
|
-
const
|
|
12104
|
-
polygons2.push(
|
|
12103
|
+
const polygon3 = poly3.create(points);
|
|
12104
|
+
polygons2.push(polygon3);
|
|
12105
12105
|
}
|
|
12106
12106
|
prevp1 = p1;
|
|
12107
12107
|
prevp2 = p2;
|
|
@@ -12303,7 +12303,7 @@ var require_offsetGeom2 = __commonJS({
|
|
|
12303
12303
|
}
|
|
12304
12304
|
const outlines = geom2.toOutlines(geometry);
|
|
12305
12305
|
const newoutlines = outlines.map((outline) => {
|
|
12306
|
-
const level = outlines.reduce((acc,
|
|
12306
|
+
const level = outlines.reduce((acc, polygon3) => acc + poly2.arePointsInside(outline, poly2.create(polygon3)), 0);
|
|
12307
12307
|
const outside = level % 2 === 0;
|
|
12308
12308
|
options = {
|
|
12309
12309
|
delta: outside ? delta : -delta,
|
|
@@ -12920,24 +12920,24 @@ var require_snapPolygons = __commonJS({
|
|
|
12920
12920
|
"use strict";
|
|
12921
12921
|
var vec3 = require_vec3();
|
|
12922
12922
|
var poly3 = require_poly3();
|
|
12923
|
-
var isValidPoly3 = (epsilon,
|
|
12924
|
-
const area = Math.abs(poly3.measureArea(
|
|
12923
|
+
var isValidPoly3 = (epsilon, polygon3) => {
|
|
12924
|
+
const area = Math.abs(poly3.measureArea(polygon3));
|
|
12925
12925
|
return Number.isFinite(area) && area > epsilon;
|
|
12926
12926
|
};
|
|
12927
12927
|
var snapPolygons = (epsilon, polygons) => {
|
|
12928
|
-
let newpolygons = polygons.map((
|
|
12929
|
-
const snapvertices =
|
|
12928
|
+
let newpolygons = polygons.map((polygon3) => {
|
|
12929
|
+
const snapvertices = polygon3.vertices.map((vertice) => vec3.snap(vec3.create(), vertice, epsilon));
|
|
12930
12930
|
const newvertices = [];
|
|
12931
12931
|
for (let i = 0; i < snapvertices.length; i++) {
|
|
12932
12932
|
const j = (i + 1) % snapvertices.length;
|
|
12933
12933
|
if (!vec3.equals(snapvertices[i], snapvertices[j])) newvertices.push(snapvertices[i]);
|
|
12934
12934
|
}
|
|
12935
12935
|
const newpolygon = poly3.create(newvertices);
|
|
12936
|
-
if (
|
|
12936
|
+
if (polygon3.color) newpolygon.color = polygon3.color;
|
|
12937
12937
|
return newpolygon;
|
|
12938
12938
|
});
|
|
12939
12939
|
const epsilonArea = epsilon * epsilon * Math.sqrt(3) / 4;
|
|
12940
|
-
newpolygons = newpolygons.filter((
|
|
12940
|
+
newpolygons = newpolygons.filter((polygon3) => isValidPoly3(epsilonArea, polygon3));
|
|
12941
12941
|
return newpolygons;
|
|
12942
12942
|
};
|
|
12943
12943
|
module.exports = snapPolygons;
|
|
@@ -12951,8 +12951,8 @@ var require_mergePolygons = __commonJS({
|
|
|
12951
12951
|
var aboutEqualNormals = require_aboutEqualNormals();
|
|
12952
12952
|
var vec3 = require_vec3();
|
|
12953
12953
|
var poly3 = require_poly3();
|
|
12954
|
-
var createEdges = (
|
|
12955
|
-
const points = poly3.toPoints(
|
|
12954
|
+
var createEdges = (polygon3) => {
|
|
12955
|
+
const points = poly3.toPoints(polygon3);
|
|
12956
12956
|
const edges = [];
|
|
12957
12957
|
for (let i = 0; i < points.length; i++) {
|
|
12958
12958
|
const j = (i + 1) % points.length;
|
|
@@ -13001,7 +13001,7 @@ var require_mergePolygons = __commonJS({
|
|
|
13001
13001
|
return vec3.dot(d0, normal);
|
|
13002
13002
|
};
|
|
13003
13003
|
var createPolygonAnd = (edge) => {
|
|
13004
|
-
let
|
|
13004
|
+
let polygon3;
|
|
13005
13005
|
const points = [];
|
|
13006
13006
|
while (edge.next) {
|
|
13007
13007
|
const next = edge.next;
|
|
@@ -13012,8 +13012,8 @@ var require_mergePolygons = __commonJS({
|
|
|
13012
13012
|
edge.prev = null;
|
|
13013
13013
|
edge = next;
|
|
13014
13014
|
}
|
|
13015
|
-
if (points.length > 0)
|
|
13016
|
-
return
|
|
13015
|
+
if (points.length > 0) polygon3 = poly3.create(points);
|
|
13016
|
+
return polygon3;
|
|
13017
13017
|
};
|
|
13018
13018
|
var mergeCoplanarPolygons = (sourcepolygons) => {
|
|
13019
13019
|
if (sourcepolygons.length < 2) return sourcepolygons;
|
|
@@ -13021,8 +13021,8 @@ var require_mergePolygons = __commonJS({
|
|
|
13021
13021
|
const polygons = sourcepolygons.slice();
|
|
13022
13022
|
const edgeList = /* @__PURE__ */ new Map();
|
|
13023
13023
|
while (polygons.length > 0) {
|
|
13024
|
-
const
|
|
13025
|
-
const edges = createEdges(
|
|
13024
|
+
const polygon3 = polygons.shift();
|
|
13025
|
+
const edges = createEdges(polygon3);
|
|
13026
13026
|
for (let i = 0; i < edges.length; i++) {
|
|
13027
13027
|
const current2 = edges[i];
|
|
13028
13028
|
const opposite = findOppositeEdge(edgeList, current2);
|
|
@@ -13078,8 +13078,8 @@ var require_mergePolygons = __commonJS({
|
|
|
13078
13078
|
}
|
|
13079
13079
|
const destpolygons = [];
|
|
13080
13080
|
edgeList.forEach((edge) => {
|
|
13081
|
-
const
|
|
13082
|
-
if (
|
|
13081
|
+
const polygon3 = createPolygonAnd(edge);
|
|
13082
|
+
if (polygon3) destpolygons.push(polygon3);
|
|
13083
13083
|
});
|
|
13084
13084
|
edgeList.clear();
|
|
13085
13085
|
return destpolygons;
|
|
@@ -13092,13 +13092,13 @@ var require_mergePolygons = __commonJS({
|
|
|
13092
13092
|
};
|
|
13093
13093
|
var mergePolygons = (epsilon, polygons) => {
|
|
13094
13094
|
const polygonsPerPlane = [];
|
|
13095
|
-
polygons.forEach((
|
|
13096
|
-
const mapping = polygonsPerPlane.find((element) => coplanar(element[0], poly3.plane(
|
|
13095
|
+
polygons.forEach((polygon3) => {
|
|
13096
|
+
const mapping = polygonsPerPlane.find((element) => coplanar(element[0], poly3.plane(polygon3)));
|
|
13097
13097
|
if (mapping) {
|
|
13098
13098
|
const polygons2 = mapping[1];
|
|
13099
|
-
polygons2.push(
|
|
13099
|
+
polygons2.push(polygon3);
|
|
13100
13100
|
} else {
|
|
13101
|
-
polygonsPerPlane.push([poly3.plane(
|
|
13101
|
+
polygonsPerPlane.push([poly3.plane(polygon3), [polygon3]]);
|
|
13102
13102
|
}
|
|
13103
13103
|
});
|
|
13104
13104
|
let destpolygons = [];
|
|
@@ -13194,15 +13194,15 @@ var require_insertTjunctions = __commonJS({
|
|
|
13194
13194
|
var insertTjunctions = (polygons) => {
|
|
13195
13195
|
const sidemap = /* @__PURE__ */ new Map();
|
|
13196
13196
|
for (let polygonindex = 0; polygonindex < polygons.length; polygonindex++) {
|
|
13197
|
-
const
|
|
13198
|
-
const numvertices =
|
|
13197
|
+
const polygon3 = polygons[polygonindex];
|
|
13198
|
+
const numvertices = polygon3.vertices.length;
|
|
13199
13199
|
if (numvertices >= 3) {
|
|
13200
|
-
let vertex =
|
|
13200
|
+
let vertex = polygon3.vertices[0];
|
|
13201
13201
|
let vertextag = getTag(vertex);
|
|
13202
13202
|
for (let vertexindex = 0; vertexindex < numvertices; vertexindex++) {
|
|
13203
13203
|
let nextvertexindex = vertexindex + 1;
|
|
13204
13204
|
if (nextvertexindex === numvertices) nextvertexindex = 0;
|
|
13205
|
-
const nextvertex =
|
|
13205
|
+
const nextvertex = polygon3.vertices[nextvertexindex];
|
|
13206
13206
|
const nextvertextag = getTag(nextvertex);
|
|
13207
13207
|
const sidetag = `${vertextag}/${nextvertextag}`;
|
|
13208
13208
|
const reversesidetag = `${nextvertextag}/${vertextag}`;
|
|
@@ -13310,17 +13310,17 @@ var require_insertTjunctions = __commonJS({
|
|
|
13310
13310
|
const distancesquared = vec3.squaredDistance(closestpoint, endpos);
|
|
13311
13311
|
if (distancesquared < constants.EPS * constants.EPS) {
|
|
13312
13312
|
const polygonindex = matchingside.polygonindex;
|
|
13313
|
-
const
|
|
13313
|
+
const polygon3 = newpolygons[polygonindex];
|
|
13314
13314
|
const insertionvertextag = getTag(matchingside.vertex1);
|
|
13315
13315
|
let insertionvertextagindex = -1;
|
|
13316
|
-
for (let i = 0; i <
|
|
13317
|
-
if (getTag(
|
|
13316
|
+
for (let i = 0; i < polygon3.vertices.length; i++) {
|
|
13317
|
+
if (getTag(polygon3.vertices[i]) === insertionvertextag) {
|
|
13318
13318
|
insertionvertextagindex = i;
|
|
13319
13319
|
break;
|
|
13320
13320
|
}
|
|
13321
13321
|
}
|
|
13322
13322
|
if (assert && insertionvertextagindex < 0) throw new Error("assert failed");
|
|
13323
|
-
const newvertices =
|
|
13323
|
+
const newvertices = polygon3.vertices.slice(0);
|
|
13324
13324
|
newvertices.splice(insertionvertextagindex, 0, endvertex);
|
|
13325
13325
|
const newpolygon = poly3.create(newvertices);
|
|
13326
13326
|
newpolygons[polygonindex] = newpolygon;
|
|
@@ -13360,35 +13360,35 @@ var require_triangulatePolygons = __commonJS({
|
|
|
13360
13360
|
"use strict";
|
|
13361
13361
|
var vec3 = require_vec3();
|
|
13362
13362
|
var poly3 = require_poly3();
|
|
13363
|
-
var triangulatePolygon = (epsilon,
|
|
13364
|
-
const nv =
|
|
13363
|
+
var triangulatePolygon = (epsilon, polygon3, triangles) => {
|
|
13364
|
+
const nv = polygon3.vertices.length;
|
|
13365
13365
|
if (nv > 3) {
|
|
13366
13366
|
if (nv > 4) {
|
|
13367
13367
|
const midpoint = [0, 0, 0];
|
|
13368
|
-
|
|
13368
|
+
polygon3.vertices.forEach((vertice) => vec3.add(midpoint, midpoint, vertice));
|
|
13369
13369
|
vec3.snap(midpoint, vec3.divide(midpoint, midpoint, [nv, nv, nv]), epsilon);
|
|
13370
13370
|
for (let i = 0; i < nv; i++) {
|
|
13371
|
-
const poly = poly3.create([midpoint,
|
|
13372
|
-
if (
|
|
13371
|
+
const poly = poly3.create([midpoint, polygon3.vertices[i], polygon3.vertices[(i + 1) % nv]]);
|
|
13372
|
+
if (polygon3.color) poly.color = polygon3.color;
|
|
13373
13373
|
triangles.push(poly);
|
|
13374
13374
|
}
|
|
13375
13375
|
return;
|
|
13376
13376
|
}
|
|
13377
|
-
const poly0 = poly3.create([
|
|
13378
|
-
const poly1 = poly3.create([
|
|
13379
|
-
if (
|
|
13380
|
-
poly0.color =
|
|
13381
|
-
poly1.color =
|
|
13377
|
+
const poly0 = poly3.create([polygon3.vertices[0], polygon3.vertices[1], polygon3.vertices[2]]);
|
|
13378
|
+
const poly1 = poly3.create([polygon3.vertices[0], polygon3.vertices[2], polygon3.vertices[3]]);
|
|
13379
|
+
if (polygon3.color) {
|
|
13380
|
+
poly0.color = polygon3.color;
|
|
13381
|
+
poly1.color = polygon3.color;
|
|
13382
13382
|
}
|
|
13383
13383
|
triangles.push(poly0, poly1);
|
|
13384
13384
|
return;
|
|
13385
13385
|
}
|
|
13386
|
-
triangles.push(
|
|
13386
|
+
triangles.push(polygon3);
|
|
13387
13387
|
};
|
|
13388
13388
|
var triangulatePolygons = (epsilon, polygons) => {
|
|
13389
13389
|
const triangles = [];
|
|
13390
|
-
polygons.forEach((
|
|
13391
|
-
triangulatePolygon(epsilon,
|
|
13390
|
+
polygons.forEach((polygon3) => {
|
|
13391
|
+
triangulatePolygon(epsilon, polygon3, triangles);
|
|
13392
13392
|
});
|
|
13393
13393
|
return triangles;
|
|
13394
13394
|
};
|
|
@@ -15372,6 +15372,7 @@ var source_group = z38.object({
|
|
|
15372
15372
|
parent_subcircuit_id: z38.string().optional(),
|
|
15373
15373
|
parent_source_group_id: z38.string().optional(),
|
|
15374
15374
|
is_subcircuit: z38.boolean().optional(),
|
|
15375
|
+
show_as_schematic_box: z38.boolean().optional(),
|
|
15375
15376
|
name: z38.string().optional()
|
|
15376
15377
|
});
|
|
15377
15378
|
expectTypesMatch(true);
|
|
@@ -15496,7 +15497,7 @@ var schematic_component = z45.object({
|
|
|
15496
15497
|
type: z45.literal("schematic_component"),
|
|
15497
15498
|
size,
|
|
15498
15499
|
center: point,
|
|
15499
|
-
source_component_id: z45.string(),
|
|
15500
|
+
source_component_id: z45.string().optional(),
|
|
15500
15501
|
schematic_component_id: z45.string(),
|
|
15501
15502
|
pin_spacing: length.optional(),
|
|
15502
15503
|
pin_styles: schematic_pin_styles.optional(),
|
|
@@ -15506,7 +15507,9 @@ var schematic_component = z45.object({
|
|
|
15506
15507
|
port_labels: z45.record(z45.string()).optional(),
|
|
15507
15508
|
symbol_display_value: z45.string().optional(),
|
|
15508
15509
|
subcircuit_id: z45.string().optional(),
|
|
15509
|
-
schematic_group_id: z45.string().optional()
|
|
15510
|
+
schematic_group_id: z45.string().optional(),
|
|
15511
|
+
is_schematic_group: z45.boolean().optional(),
|
|
15512
|
+
source_group_id: z45.string().optional()
|
|
15510
15513
|
});
|
|
15511
15514
|
expectTypesMatch(true);
|
|
15512
15515
|
var schematic_line = z46.object({
|
|
@@ -15686,6 +15689,7 @@ var schematic_group = z57.object({
|
|
|
15686
15689
|
height: length,
|
|
15687
15690
|
center: point,
|
|
15688
15691
|
schematic_component_ids: z57.array(z57.string()),
|
|
15692
|
+
show_as_schematic_box: z57.boolean().optional(),
|
|
15689
15693
|
name: z57.string().optional(),
|
|
15690
15694
|
description: z57.string().optional()
|
|
15691
15695
|
}).describe("Defines a group of components on the schematic");
|
|
@@ -15824,6 +15828,7 @@ var pcb_plated_hole_oval = z65.object({
|
|
|
15824
15828
|
hole_height: z65.number(),
|
|
15825
15829
|
x: distance,
|
|
15826
15830
|
y: distance,
|
|
15831
|
+
ccw_rotation: rotation,
|
|
15827
15832
|
layers: z65.array(layer_ref),
|
|
15828
15833
|
port_hints: z65.array(z65.string()).optional(),
|
|
15829
15834
|
pcb_component_id: z65.string().optional(),
|
|
@@ -15916,7 +15921,8 @@ var pcb_port = z66.object({
|
|
|
15916
15921
|
pcb_component_id: z66.string(),
|
|
15917
15922
|
x: distance,
|
|
15918
15923
|
y: distance,
|
|
15919
|
-
layers: z66.array(layer_ref)
|
|
15924
|
+
layers: z66.array(layer_ref),
|
|
15925
|
+
is_board_pinout: z66.boolean().optional()
|
|
15920
15926
|
}).describe("Defines a port on the PCB");
|
|
15921
15927
|
expectTypesMatch(true);
|
|
15922
15928
|
var pcb_smtpad_circle = z67.object({
|
|
@@ -15931,7 +15937,8 @@ var pcb_smtpad_circle = z67.object({
|
|
|
15931
15937
|
layer: layer_ref,
|
|
15932
15938
|
port_hints: z67.array(z67.string()).optional(),
|
|
15933
15939
|
pcb_component_id: z67.string().optional(),
|
|
15934
|
-
pcb_port_id: z67.string().optional()
|
|
15940
|
+
pcb_port_id: z67.string().optional(),
|
|
15941
|
+
is_covered_with_solder_mask: z67.boolean().optional()
|
|
15935
15942
|
});
|
|
15936
15943
|
var pcb_smtpad_rect = z67.object({
|
|
15937
15944
|
type: z67.literal("pcb_smtpad"),
|
|
@@ -15947,7 +15954,8 @@ var pcb_smtpad_rect = z67.object({
|
|
|
15947
15954
|
layer: layer_ref,
|
|
15948
15955
|
port_hints: z67.array(z67.string()).optional(),
|
|
15949
15956
|
pcb_component_id: z67.string().optional(),
|
|
15950
|
-
pcb_port_id: z67.string().optional()
|
|
15957
|
+
pcb_port_id: z67.string().optional(),
|
|
15958
|
+
is_covered_with_solder_mask: z67.boolean().optional()
|
|
15951
15959
|
});
|
|
15952
15960
|
var pcb_smtpad_rotated_rect = z67.object({
|
|
15953
15961
|
type: z67.literal("pcb_smtpad"),
|
|
@@ -15964,7 +15972,8 @@ var pcb_smtpad_rotated_rect = z67.object({
|
|
|
15964
15972
|
layer: layer_ref,
|
|
15965
15973
|
port_hints: z67.array(z67.string()).optional(),
|
|
15966
15974
|
pcb_component_id: z67.string().optional(),
|
|
15967
|
-
pcb_port_id: z67.string().optional()
|
|
15975
|
+
pcb_port_id: z67.string().optional(),
|
|
15976
|
+
is_covered_with_solder_mask: z67.boolean().optional()
|
|
15968
15977
|
});
|
|
15969
15978
|
var pcb_smtpad_pill = z67.object({
|
|
15970
15979
|
type: z67.literal("pcb_smtpad"),
|
|
@@ -15980,7 +15989,8 @@ var pcb_smtpad_pill = z67.object({
|
|
|
15980
15989
|
layer: layer_ref,
|
|
15981
15990
|
port_hints: z67.array(z67.string()).optional(),
|
|
15982
15991
|
pcb_component_id: z67.string().optional(),
|
|
15983
|
-
pcb_port_id: z67.string().optional()
|
|
15992
|
+
pcb_port_id: z67.string().optional(),
|
|
15993
|
+
is_covered_with_solder_mask: z67.boolean().optional()
|
|
15984
15994
|
});
|
|
15985
15995
|
var pcb_smtpad_rotated_pill = z67.object({
|
|
15986
15996
|
type: z67.literal("pcb_smtpad"),
|
|
@@ -15997,7 +16007,8 @@ var pcb_smtpad_rotated_pill = z67.object({
|
|
|
15997
16007
|
layer: layer_ref,
|
|
15998
16008
|
port_hints: z67.array(z67.string()).optional(),
|
|
15999
16009
|
pcb_component_id: z67.string().optional(),
|
|
16000
|
-
pcb_port_id: z67.string().optional()
|
|
16010
|
+
pcb_port_id: z67.string().optional(),
|
|
16011
|
+
is_covered_with_solder_mask: z67.boolean().optional()
|
|
16001
16012
|
});
|
|
16002
16013
|
var pcb_smtpad_polygon = z67.object({
|
|
16003
16014
|
type: z67.literal("pcb_smtpad"),
|
|
@@ -16009,7 +16020,8 @@ var pcb_smtpad_polygon = z67.object({
|
|
|
16009
16020
|
layer: layer_ref,
|
|
16010
16021
|
port_hints: z67.array(z67.string()).optional(),
|
|
16011
16022
|
pcb_component_id: z67.string().optional(),
|
|
16012
|
-
pcb_port_id: z67.string().optional()
|
|
16023
|
+
pcb_port_id: z67.string().optional(),
|
|
16024
|
+
is_covered_with_solder_mask: z67.boolean().optional()
|
|
16013
16025
|
});
|
|
16014
16026
|
var pcb_smtpad = z67.discriminatedUnion("shape", [
|
|
16015
16027
|
pcb_smtpad_circle,
|
|
@@ -24148,8 +24160,8 @@ var SmdChipLead = (props) => {
|
|
|
24148
24160
|
const { thickness, width: width10, padContactLength, bodyDistance, height: height10, rotation: rotation2 } = props;
|
|
24149
24161
|
const N = 15;
|
|
24150
24162
|
const points = Array.from({ length: N }).map((_, i) => i / (N - 1) * bodyDistance).map((x) => [x, calculateSCurve(x, props)]);
|
|
24151
|
-
const
|
|
24152
|
-
return /* @__PURE__ */ jsx5(Colorize, { color: "#fff", children: /* @__PURE__ */ jsx5(Translate, { offset: { z: 0, y: 0, x: 0, ...props.position }, children: /* @__PURE__ */ jsx5(Rotate, { rotation: ["90deg", 0, rotation2 ?? 0], children: /* @__PURE__ */ jsx5(Translate, { offset: { x: 0, y: 0, z: -width10 / 2 }, children: /* @__PURE__ */ jsx5(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx5(Polygon, { points:
|
|
24163
|
+
const polygon3 = getExpandedStroke(points, thickness);
|
|
24164
|
+
return /* @__PURE__ */ jsx5(Colorize, { color: "#fff", children: /* @__PURE__ */ jsx5(Translate, { offset: { z: 0, y: 0, x: 0, ...props.position }, children: /* @__PURE__ */ jsx5(Rotate, { rotation: ["90deg", 0, rotation2 ?? 0], children: /* @__PURE__ */ jsx5(Translate, { offset: { x: 0, y: 0, z: -width10 / 2 }, children: /* @__PURE__ */ jsx5(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx5(Polygon, { points: polygon3.map((p) => [p.x, p.y]) }) }) }) }) }) });
|
|
24153
24165
|
};
|
|
24154
24166
|
var Tssop = ({
|
|
24155
24167
|
pinCount,
|
|
@@ -25206,7 +25218,7 @@ var PushButtonLeg = (props) => {
|
|
|
25206
25218
|
[-verticalLength / 5, horizontalLength / 4],
|
|
25207
25219
|
[0, 0]
|
|
25208
25220
|
];
|
|
25209
|
-
const
|
|
25221
|
+
const polygon3 = getExpandedStroke(points, thickness);
|
|
25210
25222
|
return /* @__PURE__ */ jsx5(Colorize, { color: "#f2f2f2", children: /* @__PURE__ */ jsx5(
|
|
25211
25223
|
Translate,
|
|
25212
25224
|
{
|
|
@@ -25215,7 +25227,7 @@ var PushButtonLeg = (props) => {
|
|
|
25215
25227
|
y: position?.y || 0,
|
|
25216
25228
|
z: position?.z || 0
|
|
25217
25229
|
},
|
|
25218
|
-
children: /* @__PURE__ */ jsx5(Rotate, { rotation: [0, 55, rotation2], children: /* @__PURE__ */ jsx5(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx5(Polygon, { points:
|
|
25230
|
+
children: /* @__PURE__ */ jsx5(Rotate, { rotation: [0, 55, rotation2], children: /* @__PURE__ */ jsx5(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx5(Polygon, { points: polygon3.map((p) => [p.y, p.x]) }) }) })
|
|
25219
25231
|
}
|
|
25220
25232
|
) });
|
|
25221
25233
|
};
|
|
@@ -25607,8 +25619,8 @@ function convertCSGToThreeGeom(csg) {
|
|
|
25607
25619
|
const indices = [];
|
|
25608
25620
|
const colors2 = [];
|
|
25609
25621
|
let idx = 0;
|
|
25610
|
-
for (const
|
|
25611
|
-
for (const vertex of
|
|
25622
|
+
for (const polygon3 of csg.polygons) {
|
|
25623
|
+
for (const vertex of polygon3.vertices) {
|
|
25612
25624
|
vertex.index = idx;
|
|
25613
25625
|
vertices.push(vertex[0], vertex[1], vertex[2]);
|
|
25614
25626
|
if (csg.color && csg.color.length >= 3) {
|
|
@@ -25618,10 +25630,10 @@ function convertCSGToThreeGeom(csg) {
|
|
|
25618
25630
|
}
|
|
25619
25631
|
idx++;
|
|
25620
25632
|
}
|
|
25621
|
-
const first =
|
|
25622
|
-
for (let i = 2; i <
|
|
25623
|
-
const second =
|
|
25624
|
-
const third =
|
|
25633
|
+
const first = polygon3.vertices[0].index;
|
|
25634
|
+
for (let i = 2; i < polygon3.vertices.length; i++) {
|
|
25635
|
+
const second = polygon3.vertices[i - 1].index;
|
|
25636
|
+
const third = polygon3.vertices[i].index;
|
|
25625
25637
|
indices.push(first, second, third);
|
|
25626
25638
|
}
|
|
25627
25639
|
}
|
|
@@ -26021,7 +26033,7 @@ import * as THREE11 from "three";
|
|
|
26021
26033
|
// package.json
|
|
26022
26034
|
var package_default = {
|
|
26023
26035
|
name: "@tscircuit/3d-viewer",
|
|
26024
|
-
version: "0.0.
|
|
26036
|
+
version: "0.0.390",
|
|
26025
26037
|
main: "./dist/index.js",
|
|
26026
26038
|
module: "./dist/index.js",
|
|
26027
26039
|
type: "module",
|
|
@@ -26077,7 +26089,7 @@ var package_default = {
|
|
|
26077
26089
|
"@vitejs/plugin-react": "^4.3.4",
|
|
26078
26090
|
"bun-match-svg": "^0.0.9",
|
|
26079
26091
|
"bun-types": "1.2.1",
|
|
26080
|
-
"circuit-json": "0.0.
|
|
26092
|
+
"circuit-json": "0.0.256",
|
|
26081
26093
|
"circuit-to-svg": "^0.0.179",
|
|
26082
26094
|
debug: "^4.4.0",
|
|
26083
26095
|
"jscad-electronics": "^0.0.38",
|
|
@@ -26087,7 +26099,7 @@ var package_default = {
|
|
|
26087
26099
|
"react-use-gesture": "^9.1.3",
|
|
26088
26100
|
semver: "^7.7.0",
|
|
26089
26101
|
"strip-ansi": "^7.1.0",
|
|
26090
|
-
tscircuit: "^0.0.
|
|
26102
|
+
tscircuit: "^0.0.649",
|
|
26091
26103
|
tsup: "^8.3.6",
|
|
26092
26104
|
typescript: "^5.7.3",
|
|
26093
26105
|
vite: "^7.1.5",
|
|
@@ -26871,9 +26883,9 @@ var createBoardGeomFromCircuitJson = (circuitJson, opts = {}) => {
|
|
|
26871
26883
|
|
|
26872
26884
|
// src/BoardGeomBuilder.ts
|
|
26873
26885
|
var import_transforms3 = __toESM(require_transforms(), 1);
|
|
26874
|
-
var
|
|
26886
|
+
var import_primitives6 = __toESM(require_primitives(), 1);
|
|
26875
26887
|
var import_colors4 = __toESM(require_colors(), 1);
|
|
26876
|
-
var
|
|
26888
|
+
var import_booleans3 = __toESM(require_booleans(), 1);
|
|
26877
26889
|
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
26878
26890
|
|
|
26879
26891
|
// src/geoms/plated-hole.ts
|
|
@@ -27420,6 +27432,91 @@ function createSilkscreenPathGeom(sp, ctx) {
|
|
|
27420
27432
|
return pathGeom;
|
|
27421
27433
|
}
|
|
27422
27434
|
|
|
27435
|
+
// src/geoms/brep-converter.ts
|
|
27436
|
+
var import_primitives5 = __toESM(require_primitives(), 1);
|
|
27437
|
+
var import_booleans2 = __toESM(require_booleans(), 1);
|
|
27438
|
+
function segmentToPoints(p1, p2, bulge, arcSegments) {
|
|
27439
|
+
if (!bulge || Math.abs(bulge) < 1e-9) {
|
|
27440
|
+
return [];
|
|
27441
|
+
}
|
|
27442
|
+
const theta = 4 * Math.atan(bulge);
|
|
27443
|
+
const dx = p2[0] - p1[0];
|
|
27444
|
+
const dy = p2[1] - p1[1];
|
|
27445
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
27446
|
+
if (dist < 1e-9) return [];
|
|
27447
|
+
const radius = Math.abs(dist / (2 * Math.sin(theta / 2)));
|
|
27448
|
+
const m = Math.sqrt(Math.max(0, radius * radius - dist / 2 * (dist / 2)));
|
|
27449
|
+
const midPoint = [(p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2];
|
|
27450
|
+
const ux = dx / dist;
|
|
27451
|
+
const uy = dy / dist;
|
|
27452
|
+
const nx = -uy;
|
|
27453
|
+
const ny = ux;
|
|
27454
|
+
const centerX = midPoint[0] + nx * m * Math.sign(bulge);
|
|
27455
|
+
const centerY = midPoint[1] + ny * m * Math.sign(bulge);
|
|
27456
|
+
const startAngle = Math.atan2(p1[1] - centerY, p1[0] - centerX);
|
|
27457
|
+
const points = [];
|
|
27458
|
+
const numSteps = Math.max(
|
|
27459
|
+
2,
|
|
27460
|
+
Math.ceil(arcSegments * Math.abs(theta) / (Math.PI * 2) * 4)
|
|
27461
|
+
);
|
|
27462
|
+
const angleStep = theta / numSteps;
|
|
27463
|
+
for (let i = 1; i < numSteps; i++) {
|
|
27464
|
+
const angle = startAngle + angleStep * i;
|
|
27465
|
+
points.push([
|
|
27466
|
+
centerX + radius * Math.cos(angle),
|
|
27467
|
+
centerY + radius * Math.sin(angle)
|
|
27468
|
+
]);
|
|
27469
|
+
}
|
|
27470
|
+
return points;
|
|
27471
|
+
}
|
|
27472
|
+
function ringToPoints(ring2, arcSegments) {
|
|
27473
|
+
const allPoints = [];
|
|
27474
|
+
const vertices = ring2.vertices;
|
|
27475
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
27476
|
+
const p1 = vertices[i];
|
|
27477
|
+
const p2 = vertices[(i + 1) % vertices.length];
|
|
27478
|
+
allPoints.push([p1.x, p1.y]);
|
|
27479
|
+
if (p1.bulge) {
|
|
27480
|
+
const arcPoints = segmentToPoints(
|
|
27481
|
+
[p1.x, p1.y],
|
|
27482
|
+
[p2.x, p2.y],
|
|
27483
|
+
p1.bulge,
|
|
27484
|
+
arcSegments
|
|
27485
|
+
);
|
|
27486
|
+
allPoints.push(...arcPoints);
|
|
27487
|
+
}
|
|
27488
|
+
}
|
|
27489
|
+
return allPoints;
|
|
27490
|
+
}
|
|
27491
|
+
function arePointsClockwise2(points) {
|
|
27492
|
+
let area = 0;
|
|
27493
|
+
for (let i = 0; i < points.length; i++) {
|
|
27494
|
+
const j = (i + 1) % points.length;
|
|
27495
|
+
area += points[i][0] * points[j][1];
|
|
27496
|
+
area -= points[j][0] * points[i][1];
|
|
27497
|
+
}
|
|
27498
|
+
return area / 2 <= 0;
|
|
27499
|
+
}
|
|
27500
|
+
function createGeom2FromBRep(brep, arcSegments = 16) {
|
|
27501
|
+
let outerPoints = ringToPoints(brep.outer_ring, arcSegments);
|
|
27502
|
+
if (arePointsClockwise2(outerPoints)) {
|
|
27503
|
+
outerPoints.reverse();
|
|
27504
|
+
}
|
|
27505
|
+
const outerGeom = (0, import_primitives5.polygon)({ points: outerPoints });
|
|
27506
|
+
if (!brep.inner_rings || brep.inner_rings.length === 0) {
|
|
27507
|
+
return outerGeom;
|
|
27508
|
+
}
|
|
27509
|
+
const innerGeoms = brep.inner_rings.map((ring2) => {
|
|
27510
|
+
let innerPoints = ringToPoints(ring2, arcSegments);
|
|
27511
|
+
if (arePointsClockwise2(innerPoints)) {
|
|
27512
|
+
innerPoints.reverse();
|
|
27513
|
+
}
|
|
27514
|
+
return (0, import_primitives5.polygon)({ points: innerPoints });
|
|
27515
|
+
});
|
|
27516
|
+
if (innerGeoms.length === 0) return outerGeom;
|
|
27517
|
+
return (0, import_booleans2.subtract)(outerGeom, innerGeoms);
|
|
27518
|
+
}
|
|
27519
|
+
|
|
27423
27520
|
// src/BoardGeomBuilder.ts
|
|
27424
27521
|
var buildStateOrder = [
|
|
27425
27522
|
"initializing",
|
|
@@ -27505,7 +27602,7 @@ var BoardGeomBuilder = class {
|
|
|
27505
27602
|
this.ctx.pcbThickness
|
|
27506
27603
|
);
|
|
27507
27604
|
} else {
|
|
27508
|
-
this.boardGeom = (0,
|
|
27605
|
+
this.boardGeom = (0, import_primitives6.cuboid)({
|
|
27509
27606
|
size: [this.board.width, this.board.height, this.ctx.pcbThickness],
|
|
27510
27607
|
center: [this.board.center.x, this.board.center.y, 0]
|
|
27511
27608
|
});
|
|
@@ -27611,7 +27708,7 @@ var BoardGeomBuilder = class {
|
|
|
27611
27708
|
const cutoutHeight = this.ctx.pcbThickness * 1.5;
|
|
27612
27709
|
switch (cutout.shape) {
|
|
27613
27710
|
case "rect":
|
|
27614
|
-
cutoutGeom = (0,
|
|
27711
|
+
cutoutGeom = (0, import_primitives6.cuboid)({
|
|
27615
27712
|
center: [cutout.center.x, cutout.center.y, 0],
|
|
27616
27713
|
size: [cutout.width, cutout.height, cutoutHeight]
|
|
27617
27714
|
});
|
|
@@ -27621,7 +27718,7 @@ var BoardGeomBuilder = class {
|
|
|
27621
27718
|
}
|
|
27622
27719
|
break;
|
|
27623
27720
|
case "circle":
|
|
27624
|
-
cutoutGeom = (0,
|
|
27721
|
+
cutoutGeom = (0, import_primitives6.cylinder)({
|
|
27625
27722
|
center: [cutout.center.x, cutout.center.y, 0],
|
|
27626
27723
|
radius: cutout.radius,
|
|
27627
27724
|
height: cutoutHeight
|
|
@@ -27638,13 +27735,13 @@ var BoardGeomBuilder = class {
|
|
|
27638
27735
|
if (arePointsClockwise(pointsVec2)) {
|
|
27639
27736
|
pointsVec2 = pointsVec2.reverse();
|
|
27640
27737
|
}
|
|
27641
|
-
const polygon2d = (0,
|
|
27738
|
+
const polygon2d = (0, import_primitives6.polygon)({ points: pointsVec2 });
|
|
27642
27739
|
cutoutGeom = (0, import_extrusions3.extrudeLinear)({ height: cutoutHeight }, polygon2d);
|
|
27643
27740
|
cutoutGeom = (0, import_transforms3.translate)([0, 0, -cutoutHeight / 2], cutoutGeom);
|
|
27644
27741
|
break;
|
|
27645
27742
|
}
|
|
27646
27743
|
if (cutoutGeom) {
|
|
27647
|
-
this.boardGeom = (0,
|
|
27744
|
+
this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, cutoutGeom);
|
|
27648
27745
|
}
|
|
27649
27746
|
}
|
|
27650
27747
|
processCopperPour(pour) {
|
|
@@ -27652,7 +27749,7 @@ var BoardGeomBuilder = class {
|
|
|
27652
27749
|
const zPos = layerSign * this.ctx.pcbThickness / 2 + layerSign * M;
|
|
27653
27750
|
let pourGeom = null;
|
|
27654
27751
|
if (pour.shape === "rect") {
|
|
27655
|
-
let baseGeom = (0,
|
|
27752
|
+
let baseGeom = (0, import_primitives6.cuboid)({
|
|
27656
27753
|
center: [0, 0, 0],
|
|
27657
27754
|
// Create at origin for rotation
|
|
27658
27755
|
size: [pour.width, pour.height, M]
|
|
@@ -27662,6 +27759,13 @@ var BoardGeomBuilder = class {
|
|
|
27662
27759
|
baseGeom = (0, import_transforms3.rotateZ)(rotationRadians, baseGeom);
|
|
27663
27760
|
}
|
|
27664
27761
|
pourGeom = (0, import_transforms3.translate)([pour.center.x, pour.center.y, zPos], baseGeom);
|
|
27762
|
+
} else if (pour.shape === "brep") {
|
|
27763
|
+
const brepShape = pour.brep_shape;
|
|
27764
|
+
if (brepShape && brepShape.outer_ring) {
|
|
27765
|
+
const pourGeom2 = createGeom2FromBRep(brepShape);
|
|
27766
|
+
pourGeom = (0, import_extrusions3.extrudeLinear)({ height: M }, pourGeom2);
|
|
27767
|
+
pourGeom = (0, import_transforms3.translate)([0, 0, zPos], pourGeom);
|
|
27768
|
+
}
|
|
27665
27769
|
} else if (pour.shape === "polygon") {
|
|
27666
27770
|
let pointsVec2 = pour.points.map((p) => [p.x, p.y]);
|
|
27667
27771
|
if (pointsVec2.length < 3) {
|
|
@@ -27673,7 +27777,7 @@ var BoardGeomBuilder = class {
|
|
|
27673
27777
|
if (arePointsClockwise(pointsVec2)) {
|
|
27674
27778
|
pointsVec2 = pointsVec2.reverse();
|
|
27675
27779
|
}
|
|
27676
|
-
const polygon2d = (0,
|
|
27780
|
+
const polygon2d = (0, import_primitives6.polygon)({ points: pointsVec2 });
|
|
27677
27781
|
pourGeom = (0, import_extrusions3.extrudeLinear)({ height: M }, polygon2d);
|
|
27678
27782
|
pourGeom = (0, import_transforms3.translate)([0, 0, zPos], pourGeom);
|
|
27679
27783
|
}
|
|
@@ -27685,7 +27789,7 @@ var BoardGeomBuilder = class {
|
|
|
27685
27789
|
processPlatedHole(ph, opts = {}) {
|
|
27686
27790
|
if (!this.boardGeom) return;
|
|
27687
27791
|
if (ph.shape === "circle" || ph.shape === "circular_hole_with_rect_pad") {
|
|
27688
|
-
const cyGeom = (0,
|
|
27792
|
+
const cyGeom = (0, import_primitives6.cylinder)({
|
|
27689
27793
|
center: [ph.x, ph.y, 0],
|
|
27690
27794
|
radius: ph.hole_diameter / 2 + M,
|
|
27691
27795
|
// Add margin for subtraction
|
|
@@ -27693,10 +27797,10 @@ var BoardGeomBuilder = class {
|
|
|
27693
27797
|
// Ensure it cuts through
|
|
27694
27798
|
});
|
|
27695
27799
|
if (!opts.dontCutBoard) {
|
|
27696
|
-
this.boardGeom = (0,
|
|
27800
|
+
this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, cyGeom);
|
|
27697
27801
|
}
|
|
27698
27802
|
this.padGeoms = this.padGeoms.map(
|
|
27699
|
-
(pg) => (0, import_colors4.colorize)(colors.copper, (0,
|
|
27803
|
+
(pg) => (0, import_colors4.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, cyGeom))
|
|
27700
27804
|
);
|
|
27701
27805
|
const platedHoleGeom = platedHole(ph, this.ctx);
|
|
27702
27806
|
this.platedHoleGeoms.push(platedHoleGeom);
|
|
@@ -27706,27 +27810,27 @@ var BoardGeomBuilder = class {
|
|
|
27706
27810
|
const holeHeight = shouldRotate ? ph.hole_width : ph.hole_height;
|
|
27707
27811
|
const holeRadius = holeHeight / 2;
|
|
27708
27812
|
const rectLength = Math.abs(holeWidth - holeHeight);
|
|
27709
|
-
const pillHole = (0,
|
|
27710
|
-
(0,
|
|
27813
|
+
const pillHole = (0, import_booleans3.union)(
|
|
27814
|
+
(0, import_primitives6.cuboid)({
|
|
27711
27815
|
center: [ph.x, ph.y, 0],
|
|
27712
27816
|
size: shouldRotate ? [holeHeight, rectLength, this.ctx.pcbThickness * 1.5] : [rectLength, holeHeight, this.ctx.pcbThickness * 1.5]
|
|
27713
27817
|
}),
|
|
27714
|
-
(0,
|
|
27818
|
+
(0, import_primitives6.cylinder)({
|
|
27715
27819
|
center: shouldRotate ? [ph.x, ph.y - rectLength / 2, 0] : [ph.x - rectLength / 2, ph.y, 0],
|
|
27716
27820
|
radius: holeRadius,
|
|
27717
27821
|
height: this.ctx.pcbThickness * 1.5
|
|
27718
27822
|
}),
|
|
27719
|
-
(0,
|
|
27823
|
+
(0, import_primitives6.cylinder)({
|
|
27720
27824
|
center: shouldRotate ? [ph.x, ph.y + rectLength / 2, 0] : [ph.x + rectLength / 2, ph.y, 0],
|
|
27721
27825
|
radius: holeRadius,
|
|
27722
27826
|
height: this.ctx.pcbThickness * 1.5
|
|
27723
27827
|
})
|
|
27724
27828
|
);
|
|
27725
27829
|
if (!opts.dontCutBoard) {
|
|
27726
|
-
this.boardGeom = (0,
|
|
27830
|
+
this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, pillHole);
|
|
27727
27831
|
}
|
|
27728
27832
|
this.padGeoms = this.padGeoms.map(
|
|
27729
|
-
(pg) => (0, import_colors4.colorize)(colors.copper, (0,
|
|
27833
|
+
(pg) => (0, import_colors4.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, pillHole))
|
|
27730
27834
|
);
|
|
27731
27835
|
const platedHoleGeom = platedHole(ph, this.ctx);
|
|
27732
27836
|
this.platedHoleGeoms.push(platedHoleGeom);
|
|
@@ -27735,16 +27839,16 @@ var BoardGeomBuilder = class {
|
|
|
27735
27839
|
processHole(hole) {
|
|
27736
27840
|
if (!this.boardGeom) return;
|
|
27737
27841
|
if (hole.hole_shape === "round" || hole.hole_shape === "circle") {
|
|
27738
|
-
const cyGeom = (0,
|
|
27842
|
+
const cyGeom = (0, import_primitives6.cylinder)({
|
|
27739
27843
|
center: [hole.x, hole.y, 0],
|
|
27740
27844
|
radius: hole.hole_diameter / 2 + M,
|
|
27741
27845
|
// Add margin for subtraction
|
|
27742
27846
|
height: this.ctx.pcbThickness * 1.5
|
|
27743
27847
|
// Ensure it cuts through
|
|
27744
27848
|
});
|
|
27745
|
-
this.boardGeom = (0,
|
|
27849
|
+
this.boardGeom = (0, import_booleans3.subtract)(this.boardGeom, cyGeom);
|
|
27746
27850
|
this.padGeoms = this.padGeoms.map(
|
|
27747
|
-
(pg) => (0, import_colors4.colorize)(colors.copper, (0,
|
|
27851
|
+
(pg) => (0, import_colors4.colorize)(colors.copper, (0, import_booleans3.subtract)(pg, cyGeom))
|
|
27748
27852
|
);
|
|
27749
27853
|
}
|
|
27750
27854
|
}
|
|
@@ -27754,14 +27858,14 @@ var BoardGeomBuilder = class {
|
|
|
27754
27858
|
if (pad2.shape === "rect") {
|
|
27755
27859
|
const padGeom = (0, import_colors4.colorize)(
|
|
27756
27860
|
colors.copper,
|
|
27757
|
-
(0,
|
|
27861
|
+
(0, import_primitives6.cuboid)({
|
|
27758
27862
|
center: [pad2.x, pad2.y, zPos],
|
|
27759
27863
|
size: [pad2.width, pad2.height, M]
|
|
27760
27864
|
})
|
|
27761
27865
|
);
|
|
27762
27866
|
this.padGeoms.push(padGeom);
|
|
27763
27867
|
} else if (pad2.shape === "rotated_rect") {
|
|
27764
|
-
let basePadGeom = (0,
|
|
27868
|
+
let basePadGeom = (0, import_primitives6.cuboid)({
|
|
27765
27869
|
// Create at origin for rotation, then translate
|
|
27766
27870
|
center: [0, 0, 0],
|
|
27767
27871
|
size: [pad2.width, pad2.height, M]
|
|
@@ -27774,7 +27878,7 @@ var BoardGeomBuilder = class {
|
|
|
27774
27878
|
} else if (pad2.shape === "circle") {
|
|
27775
27879
|
const padGeom = (0, import_colors4.colorize)(
|
|
27776
27880
|
colors.copper,
|
|
27777
|
-
(0,
|
|
27881
|
+
(0, import_primitives6.cylinder)({
|
|
27778
27882
|
center: [pad2.x, pad2.y, zPos],
|
|
27779
27883
|
radius: pad2.radius,
|
|
27780
27884
|
height: M
|
|
@@ -27793,7 +27897,7 @@ var BoardGeomBuilder = class {
|
|
|
27793
27897
|
if (currentSegmentPoints.length >= 2 && currentLayer) {
|
|
27794
27898
|
const layerSign = currentLayer === "bottom" ? -1 : 1;
|
|
27795
27899
|
const zPos = layerSign * this.ctx.pcbThickness / 2 + layerSign * M;
|
|
27796
|
-
const linePath = (0,
|
|
27900
|
+
const linePath = (0, import_primitives6.line)(currentSegmentPoints);
|
|
27797
27901
|
const expandedPath = (0, import_expansions2.expand)(
|
|
27798
27902
|
{ delta: currentWidth / 2, corners: "round" },
|
|
27799
27903
|
linePath
|
|
@@ -27809,21 +27913,21 @@ var BoardGeomBuilder = class {
|
|
|
27809
27913
|
startPointCoords[1]
|
|
27810
27914
|
);
|
|
27811
27915
|
if (startHole) {
|
|
27812
|
-
const cuttingCylinder = (0,
|
|
27916
|
+
const cuttingCylinder = (0, import_primitives6.cylinder)({
|
|
27813
27917
|
center: [startPointCoords[0], startPointCoords[1], zPos + M / 2],
|
|
27814
27918
|
radius: startHole.diameter / 2 + M,
|
|
27815
27919
|
height: M
|
|
27816
27920
|
});
|
|
27817
|
-
traceGeom = (0,
|
|
27921
|
+
traceGeom = (0, import_booleans3.subtract)(traceGeom, cuttingCylinder);
|
|
27818
27922
|
}
|
|
27819
27923
|
const endHole = this.getHoleToCut(endPointCoords[0], endPointCoords[1]);
|
|
27820
27924
|
if (endHole) {
|
|
27821
|
-
const cuttingCylinder = (0,
|
|
27925
|
+
const cuttingCylinder = (0, import_primitives6.cylinder)({
|
|
27822
27926
|
center: [endPointCoords[0], endPointCoords[1], zPos + M / 2],
|
|
27823
27927
|
radius: endHole.diameter / 2 + M,
|
|
27824
27928
|
height: M
|
|
27825
27929
|
});
|
|
27826
|
-
traceGeom = (0,
|
|
27930
|
+
traceGeom = (0, import_booleans3.subtract)(traceGeom, cuttingCylinder);
|
|
27827
27931
|
}
|
|
27828
27932
|
const tracesMaterialColor = tracesMaterialColors[this.board.material] ?? colors.fr4GreenSolderWithMask;
|
|
27829
27933
|
traceGeom = (0, import_colors4.colorize)(tracesMaterialColor, traceGeom);
|
|
@@ -27893,7 +27997,7 @@ var BoardGeomBuilder = class {
|
|
|
27893
27997
|
point2[0] + xOffset + st.anchor_position.x,
|
|
27894
27998
|
point2[1] + yOffset + st.anchor_position.y
|
|
27895
27999
|
]);
|
|
27896
|
-
const textPath = (0,
|
|
28000
|
+
const textPath = (0, import_primitives6.line)(alignedOutline);
|
|
27897
28001
|
const fontSize = st.font_size || 0.25;
|
|
27898
28002
|
const expansionDelta = Math.min(
|
|
27899
28003
|
Math.max(0.01, fontSize * 0.1),
|
|
@@ -28724,6 +28828,11 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
|
|
|
28724
28828
|
manifoldInstancesForCleanup.push(rotatedOp);
|
|
28725
28829
|
boardPillDrillOp = rotatedOp;
|
|
28726
28830
|
}
|
|
28831
|
+
if (ph.ccw_rotation) {
|
|
28832
|
+
const rotatedOp = boardPillDrillOp.rotate([0, 0, ph.ccw_rotation]);
|
|
28833
|
+
manifoldInstancesForCleanup.push(rotatedOp);
|
|
28834
|
+
boardPillDrillOp = rotatedOp;
|
|
28835
|
+
}
|
|
28727
28836
|
const translatedBoardPillDrill = boardPillDrillOp.translate([
|
|
28728
28837
|
ph.x,
|
|
28729
28838
|
ph.y,
|
|
@@ -28752,6 +28861,11 @@ function processPlatedHolesForManifold(Manifold, circuitJson, pcbThickness, mani
|
|
|
28752
28861
|
manifoldInstancesForCleanup.push(rotatedOp);
|
|
28753
28862
|
finalPlatedPartOp = rotatedOp;
|
|
28754
28863
|
}
|
|
28864
|
+
if (ph.ccw_rotation) {
|
|
28865
|
+
const rotatedOp = finalPlatedPartOp.rotate([0, 0, ph.ccw_rotation]);
|
|
28866
|
+
manifoldInstancesForCleanup.push(rotatedOp);
|
|
28867
|
+
finalPlatedPartOp = rotatedOp;
|
|
28868
|
+
}
|
|
28755
28869
|
const translatedPlatedPart = finalPlatedPartOp.translate([ph.x, ph.y, 0]);
|
|
28756
28870
|
manifoldInstancesForCleanup.push(translatedPlatedPart);
|
|
28757
28871
|
const threeGeom = manifoldMeshToThreeGeometry(
|
|
@@ -28964,7 +29078,7 @@ function processSmtPadsForManifold(Manifold, circuitJson, pcbThickness, manifold
|
|
|
28964
29078
|
}
|
|
28965
29079
|
|
|
28966
29080
|
// src/utils/manifold/create-manifold-board.ts
|
|
28967
|
-
var
|
|
29081
|
+
var arePointsClockwise3 = (points) => {
|
|
28968
29082
|
let area = 0;
|
|
28969
29083
|
for (let i = 0; i < points.length; i++) {
|
|
28970
29084
|
const j = (i + 1) % points.length;
|
|
@@ -28983,7 +29097,7 @@ function createManifoldBoard(Manifold, CrossSection, boardData, pcbThickness, ma
|
|
|
28983
29097
|
p.x,
|
|
28984
29098
|
p.y
|
|
28985
29099
|
]);
|
|
28986
|
-
if (
|
|
29100
|
+
if (arePointsClockwise3(outlineVec2)) {
|
|
28987
29101
|
outlineVec2 = outlineVec2.reverse();
|
|
28988
29102
|
}
|
|
28989
29103
|
const crossSection = CrossSection.ofPolygons([outlineVec2]);
|
|
@@ -29022,7 +29136,7 @@ function createManifoldBoard(Manifold, CrossSection, boardData, pcbThickness, ma
|
|
|
29022
29136
|
// src/utils/manifold/process-copper-pours.ts
|
|
29023
29137
|
import * as THREE20 from "three";
|
|
29024
29138
|
var COPPER_COLOR4 = new THREE20.Color(...colors.copper);
|
|
29025
|
-
var
|
|
29139
|
+
var arePointsClockwise4 = (points) => {
|
|
29026
29140
|
let area = 0;
|
|
29027
29141
|
for (let i = 0; i < points.length; i++) {
|
|
29028
29142
|
const j = (i + 1) % points.length;
|
|
@@ -29034,6 +29148,59 @@ var arePointsClockwise3 = (points) => {
|
|
|
29034
29148
|
const signedArea = area / 2;
|
|
29035
29149
|
return signedArea <= 0;
|
|
29036
29150
|
};
|
|
29151
|
+
function segmentToPoints2(p1, p2, bulge, arcSegments) {
|
|
29152
|
+
if (!bulge || Math.abs(bulge) < 1e-9) {
|
|
29153
|
+
return [];
|
|
29154
|
+
}
|
|
29155
|
+
const theta = 4 * Math.atan(bulge);
|
|
29156
|
+
const dx = p2[0] - p1[0];
|
|
29157
|
+
const dy = p2[1] - p1[1];
|
|
29158
|
+
const dist = Math.sqrt(dx * dx + dy * dy);
|
|
29159
|
+
if (dist < 1e-9) return [];
|
|
29160
|
+
const radius = Math.abs(dist / (2 * Math.sin(theta / 2)));
|
|
29161
|
+
const m = Math.sqrt(Math.max(0, radius * radius - dist / 2 * (dist / 2)));
|
|
29162
|
+
const midPoint = [(p1[0] + p2[0]) / 2, (p1[1] + p2[1]) / 2];
|
|
29163
|
+
const ux = dx / dist;
|
|
29164
|
+
const uy = dy / dist;
|
|
29165
|
+
const nx = -uy;
|
|
29166
|
+
const ny = ux;
|
|
29167
|
+
const centerX = midPoint[0] + nx * m * Math.sign(bulge);
|
|
29168
|
+
const centerY = midPoint[1] + ny * m * Math.sign(bulge);
|
|
29169
|
+
const startAngle = Math.atan2(p1[1] - centerY, p1[0] - centerX);
|
|
29170
|
+
const points = [];
|
|
29171
|
+
const numSteps = Math.max(
|
|
29172
|
+
2,
|
|
29173
|
+
Math.ceil(arcSegments * Math.abs(theta) / (Math.PI * 2) * 4)
|
|
29174
|
+
);
|
|
29175
|
+
const angleStep = theta / numSteps;
|
|
29176
|
+
for (let i = 1; i < numSteps; i++) {
|
|
29177
|
+
const angle = startAngle + angleStep * i;
|
|
29178
|
+
points.push([
|
|
29179
|
+
centerX + radius * Math.cos(angle),
|
|
29180
|
+
centerY + radius * Math.sin(angle)
|
|
29181
|
+
]);
|
|
29182
|
+
}
|
|
29183
|
+
return points;
|
|
29184
|
+
}
|
|
29185
|
+
function ringToPoints2(ring2, arcSegments) {
|
|
29186
|
+
const allPoints = [];
|
|
29187
|
+
const vertices = ring2.vertices;
|
|
29188
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
29189
|
+
const p1 = vertices[i];
|
|
29190
|
+
const p2 = vertices[(i + 1) % vertices.length];
|
|
29191
|
+
allPoints.push([p1.x, p1.y]);
|
|
29192
|
+
if (p1.bulge) {
|
|
29193
|
+
const arcPoints = segmentToPoints2(
|
|
29194
|
+
[p1.x, p1.y],
|
|
29195
|
+
[p2.x, p2.y],
|
|
29196
|
+
p1.bulge,
|
|
29197
|
+
arcSegments
|
|
29198
|
+
);
|
|
29199
|
+
allPoints.push(...arcPoints);
|
|
29200
|
+
}
|
|
29201
|
+
}
|
|
29202
|
+
return allPoints;
|
|
29203
|
+
}
|
|
29037
29204
|
function processCopperPoursForManifold(Manifold, CrossSection, circuitJson, pcbThickness, manifoldInstancesForCleanup, holeUnion) {
|
|
29038
29205
|
const copperPourGeoms = [];
|
|
29039
29206
|
const copperPours = circuitJson.filter(
|
|
@@ -29060,7 +29227,7 @@ function processCopperPoursForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
29060
29227
|
p.x,
|
|
29061
29228
|
p.y
|
|
29062
29229
|
]);
|
|
29063
|
-
if (
|
|
29230
|
+
if (arePointsClockwise4(pointsVec2)) {
|
|
29064
29231
|
pointsVec2 = pointsVec2.reverse();
|
|
29065
29232
|
}
|
|
29066
29233
|
const crossSection = CrossSection.ofPolygons([pointsVec2]);
|
|
@@ -29078,6 +29245,42 @@ function processCopperPoursForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
29078
29245
|
// center extrusion
|
|
29079
29246
|
).translate([0, 0, zPos]);
|
|
29080
29247
|
manifoldInstancesForCleanup.push(pourOp);
|
|
29248
|
+
} else if (pour.shape === "brep") {
|
|
29249
|
+
const brepShape = pour.brep_shape;
|
|
29250
|
+
if (!brepShape || !brepShape.outer_ring) continue;
|
|
29251
|
+
let outerRingPoints = ringToPoints2(
|
|
29252
|
+
brepShape.outer_ring,
|
|
29253
|
+
SMOOTH_CIRCLE_SEGMENTS
|
|
29254
|
+
);
|
|
29255
|
+
if (arePointsClockwise4(outerRingPoints)) {
|
|
29256
|
+
outerRingPoints = outerRingPoints.reverse();
|
|
29257
|
+
}
|
|
29258
|
+
const polygons = [outerRingPoints];
|
|
29259
|
+
if (brepShape.inner_rings) {
|
|
29260
|
+
const innerRingsPoints = brepShape.inner_rings.map((ring2) => {
|
|
29261
|
+
let points = ringToPoints2(ring2, SMOOTH_CIRCLE_SEGMENTS);
|
|
29262
|
+
if (!arePointsClockwise4(points)) {
|
|
29263
|
+
points = points.reverse();
|
|
29264
|
+
}
|
|
29265
|
+
return points;
|
|
29266
|
+
});
|
|
29267
|
+
polygons.push(...innerRingsPoints);
|
|
29268
|
+
}
|
|
29269
|
+
const crossSection = CrossSection.ofPolygons(polygons);
|
|
29270
|
+
manifoldInstancesForCleanup.push(crossSection);
|
|
29271
|
+
pourOp = Manifold.extrude(
|
|
29272
|
+
crossSection,
|
|
29273
|
+
pourThickness,
|
|
29274
|
+
0,
|
|
29275
|
+
// nDivisions
|
|
29276
|
+
0,
|
|
29277
|
+
// twistDegrees
|
|
29278
|
+
[1, 1],
|
|
29279
|
+
// scaleTop
|
|
29280
|
+
true
|
|
29281
|
+
// center extrusion
|
|
29282
|
+
).translate([0, 0, zPos]);
|
|
29283
|
+
manifoldInstancesForCleanup.push(pourOp);
|
|
29081
29284
|
}
|
|
29082
29285
|
if (pourOp) {
|
|
29083
29286
|
if (holeUnion) {
|
|
@@ -29098,7 +29301,7 @@ function processCopperPoursForManifold(Manifold, CrossSection, circuitJson, pcbT
|
|
|
29098
29301
|
|
|
29099
29302
|
// src/utils/manifold/process-cutouts.ts
|
|
29100
29303
|
import { su as su11 } from "@tscircuit/circuit-json-util";
|
|
29101
|
-
var
|
|
29304
|
+
var arePointsClockwise5 = (points) => {
|
|
29102
29305
|
let area = 0;
|
|
29103
29306
|
for (let i = 0; i < points.length; i++) {
|
|
29104
29307
|
const j = (i + 1) % points.length;
|
|
@@ -29163,7 +29366,7 @@ function processCutoutsForManifold(Manifold, CrossSection, circuitJson, pcbThick
|
|
|
29163
29366
|
p.x,
|
|
29164
29367
|
p.y
|
|
29165
29368
|
]);
|
|
29166
|
-
if (
|
|
29369
|
+
if (arePointsClockwise5(pointsVec2)) {
|
|
29167
29370
|
pointsVec2 = pointsVec2.reverse();
|
|
29168
29371
|
}
|
|
29169
29372
|
const crossSection = CrossSection.ofPolygons([pointsVec2]);
|
|
@@ -30096,17 +30299,17 @@ function createGeometryFromPolygons(polygons) {
|
|
|
30096
30299
|
const geometry = new BufferGeometry3();
|
|
30097
30300
|
const vertices = [];
|
|
30098
30301
|
const normals = [];
|
|
30099
|
-
for (const
|
|
30100
|
-
for (let i = 1; i <
|
|
30302
|
+
for (const polygon3 of polygons) {
|
|
30303
|
+
for (let i = 1; i < polygon3.vertices.length - 1; i++) {
|
|
30101
30304
|
vertices.push(
|
|
30102
|
-
...
|
|
30103
|
-
...
|
|
30104
|
-
...
|
|
30305
|
+
...polygon3.vertices[0],
|
|
30306
|
+
...polygon3.vertices[i],
|
|
30307
|
+
...polygon3.vertices[i + 1]
|
|
30105
30308
|
// Third vertex
|
|
30106
30309
|
);
|
|
30107
|
-
const v1 = new THREE24.Vector3(...
|
|
30108
|
-
const v2 = new THREE24.Vector3(...
|
|
30109
|
-
const v3 = new THREE24.Vector3(...
|
|
30310
|
+
const v1 = new THREE24.Vector3(...polygon3.vertices[0]);
|
|
30311
|
+
const v2 = new THREE24.Vector3(...polygon3.vertices[i]);
|
|
30312
|
+
const v3 = new THREE24.Vector3(...polygon3.vertices[i + 1]);
|
|
30110
30313
|
const normal = new THREE24.Vector3().crossVectors(
|
|
30111
30314
|
new THREE24.Vector3().subVectors(v2, v1),
|
|
30112
30315
|
new THREE24.Vector3().subVectors(v3, v1)
|