@tscircuit/3d-viewer 0.0.539 → 0.0.540
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 +357 -240
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -881,13 +881,13 @@ var require_squaredLength = __commonJS({
|
|
|
881
881
|
var require_subtract = __commonJS({
|
|
882
882
|
"node_modules/@jscad/modeling/src/maths/vec3/subtract.js"(exports, module) {
|
|
883
883
|
"use strict";
|
|
884
|
-
var
|
|
884
|
+
var subtract4 = (out, a, b) => {
|
|
885
885
|
out[0] = a[0] - b[0];
|
|
886
886
|
out[1] = a[1] - b[1];
|
|
887
887
|
out[2] = a[2] - b[2];
|
|
888
888
|
return out;
|
|
889
889
|
};
|
|
890
|
-
module.exports =
|
|
890
|
+
module.exports = subtract4;
|
|
891
891
|
}
|
|
892
892
|
});
|
|
893
893
|
|
|
@@ -1428,7 +1428,7 @@ var require_scale2 = __commonJS({
|
|
|
1428
1428
|
var require_subtract2 = __commonJS({
|
|
1429
1429
|
"node_modules/@jscad/modeling/src/maths/mat4/subtract.js"(exports, module) {
|
|
1430
1430
|
"use strict";
|
|
1431
|
-
var
|
|
1431
|
+
var subtract4 = (out, a, b) => {
|
|
1432
1432
|
out[0] = a[0] - b[0];
|
|
1433
1433
|
out[1] = a[1] - b[1];
|
|
1434
1434
|
out[2] = a[2] - b[2];
|
|
@@ -1447,7 +1447,7 @@ var require_subtract2 = __commonJS({
|
|
|
1447
1447
|
out[15] = a[15] - b[15];
|
|
1448
1448
|
return out;
|
|
1449
1449
|
};
|
|
1450
|
-
module.exports =
|
|
1450
|
+
module.exports = subtract4;
|
|
1451
1451
|
}
|
|
1452
1452
|
});
|
|
1453
1453
|
|
|
@@ -1957,12 +1957,12 @@ var require_squaredLength2 = __commonJS({
|
|
|
1957
1957
|
var require_subtract3 = __commonJS({
|
|
1958
1958
|
"node_modules/@jscad/modeling/src/maths/vec2/subtract.js"(exports, module) {
|
|
1959
1959
|
"use strict";
|
|
1960
|
-
var
|
|
1960
|
+
var subtract4 = (out, a, b) => {
|
|
1961
1961
|
out[0] = a[0] - b[0];
|
|
1962
1962
|
out[1] = a[1] - b[1];
|
|
1963
1963
|
return out;
|
|
1964
1964
|
};
|
|
1965
|
-
module.exports =
|
|
1965
|
+
module.exports = subtract4;
|
|
1966
1966
|
}
|
|
1967
1967
|
});
|
|
1968
1968
|
|
|
@@ -2423,14 +2423,14 @@ var require_point_line_distance = __commonJS({
|
|
|
2423
2423
|
"node_modules/@jscad/modeling/src/operations/hulls/quickhull/point-line-distance.js"(exports, module) {
|
|
2424
2424
|
"use strict";
|
|
2425
2425
|
var cross = require_cross();
|
|
2426
|
-
var
|
|
2426
|
+
var subtract4 = require_subtract();
|
|
2427
2427
|
var squaredLength = require_squaredLength();
|
|
2428
2428
|
var distanceSquared = (p, a, b) => {
|
|
2429
2429
|
const ab = [];
|
|
2430
2430
|
const ap = [];
|
|
2431
2431
|
const cr = [];
|
|
2432
|
-
|
|
2433
|
-
|
|
2432
|
+
subtract4(ab, b, a);
|
|
2433
|
+
subtract4(ap, p, a);
|
|
2434
2434
|
const area = squaredLength(cross(cr, ap, ab));
|
|
2435
2435
|
const s = squaredLength(ab);
|
|
2436
2436
|
if (s === 0) {
|
|
@@ -2449,11 +2449,11 @@ var require_get_plane_normal = __commonJS({
|
|
|
2449
2449
|
"use strict";
|
|
2450
2450
|
var cross = require_cross();
|
|
2451
2451
|
var normalize = require_normalize();
|
|
2452
|
-
var
|
|
2452
|
+
var subtract4 = require_subtract();
|
|
2453
2453
|
var planeNormal = (out, point1, point2, point3) => {
|
|
2454
2454
|
const tmp = [0, 0, 0];
|
|
2455
|
-
|
|
2456
|
-
|
|
2455
|
+
subtract4(out, point1, point2);
|
|
2456
|
+
subtract4(tmp, point2, point3);
|
|
2457
2457
|
cross(out, out, tmp);
|
|
2458
2458
|
return normalize(out, out);
|
|
2459
2459
|
};
|
|
@@ -2667,7 +2667,7 @@ var require_Face = __commonJS({
|
|
|
2667
2667
|
var length62 = require_length();
|
|
2668
2668
|
var normalize = require_normalize();
|
|
2669
2669
|
var scale2 = require_scale();
|
|
2670
|
-
var
|
|
2670
|
+
var subtract4 = require_subtract();
|
|
2671
2671
|
var HalfEdge = require_HalfEdge();
|
|
2672
2672
|
var VISIBLE = 0;
|
|
2673
2673
|
var NON_CONVEX = 1;
|
|
@@ -2701,14 +2701,14 @@ var require_Face = __commonJS({
|
|
|
2701
2701
|
const e0 = this.edge;
|
|
2702
2702
|
const e1 = e0.next;
|
|
2703
2703
|
let e2 = e1.next;
|
|
2704
|
-
const v2 =
|
|
2704
|
+
const v2 = subtract4([], e1.head().point, e0.head().point);
|
|
2705
2705
|
const t = [];
|
|
2706
2706
|
const v1 = [];
|
|
2707
2707
|
this.nVertices = 2;
|
|
2708
2708
|
this.normal = [0, 0, 0];
|
|
2709
2709
|
while (e2 !== e0) {
|
|
2710
2710
|
copy(v1, v2);
|
|
2711
|
-
|
|
2711
|
+
subtract4(v2, e2.head().point, e0.head().point);
|
|
2712
2712
|
add(this.normal, this.normal, cross(t, v1, v2));
|
|
2713
2713
|
e2 = e2.next;
|
|
2714
2714
|
this.nVertices += 1;
|
|
@@ -2732,7 +2732,7 @@ var require_Face = __commonJS({
|
|
|
2732
2732
|
} while (edge !== this.edge);
|
|
2733
2733
|
const p1 = maxEdge.tail().point;
|
|
2734
2734
|
const p2 = maxEdge.head().point;
|
|
2735
|
-
const maxVector =
|
|
2735
|
+
const maxVector = subtract4([], p2, p1);
|
|
2736
2736
|
const maxLength = Math.sqrt(maxSquaredLength);
|
|
2737
2737
|
scale2(maxVector, maxVector, 1 / maxLength);
|
|
2738
2738
|
const maxProjection = dot(this.normal, maxVector);
|
|
@@ -3854,11 +3854,11 @@ var require_invert2 = __commonJS({
|
|
|
3854
3854
|
"use strict";
|
|
3855
3855
|
var plane = require_plane();
|
|
3856
3856
|
var create = require_create6();
|
|
3857
|
-
var invert = (
|
|
3858
|
-
const vertices =
|
|
3857
|
+
var invert = (polygon2) => {
|
|
3858
|
+
const vertices = polygon2.vertices.slice().reverse();
|
|
3859
3859
|
const inverted = create(vertices);
|
|
3860
|
-
if (
|
|
3861
|
-
inverted.plane = plane.flip(plane.create(),
|
|
3860
|
+
if (polygon2.plane) {
|
|
3861
|
+
inverted.plane = plane.flip(plane.create(), polygon2.plane);
|
|
3862
3862
|
}
|
|
3863
3863
|
return inverted;
|
|
3864
3864
|
};
|
|
@@ -3890,7 +3890,7 @@ var require_isConvex = __commonJS({
|
|
|
3890
3890
|
"use strict";
|
|
3891
3891
|
var plane = require_plane();
|
|
3892
3892
|
var vec3 = require_vec3();
|
|
3893
|
-
var isConvex = (
|
|
3893
|
+
var isConvex = (polygon2) => areVerticesConvex(polygon2.vertices);
|
|
3894
3894
|
var areVerticesConvex = (vertices) => {
|
|
3895
3895
|
const numvertices = vertices.length;
|
|
3896
3896
|
if (numvertices > 2) {
|
|
@@ -3926,11 +3926,11 @@ var require_plane2 = __commonJS({
|
|
|
3926
3926
|
"node_modules/@jscad/modeling/src/geometries/poly3/plane.js"(exports, module) {
|
|
3927
3927
|
"use strict";
|
|
3928
3928
|
var mplane = require_plane();
|
|
3929
|
-
var plane = (
|
|
3930
|
-
if (!
|
|
3931
|
-
|
|
3929
|
+
var plane = (polygon2) => {
|
|
3930
|
+
if (!polygon2.plane) {
|
|
3931
|
+
polygon2.plane = mplane.fromPoints(mplane.create(), ...polygon2.vertices);
|
|
3932
3932
|
}
|
|
3933
|
-
return
|
|
3933
|
+
return polygon2.plane;
|
|
3934
3934
|
};
|
|
3935
3935
|
module.exports = plane;
|
|
3936
3936
|
}
|
|
@@ -3941,13 +3941,13 @@ var require_measureArea = __commonJS({
|
|
|
3941
3941
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureArea.js"(exports, module) {
|
|
3942
3942
|
"use strict";
|
|
3943
3943
|
var plane = require_plane2();
|
|
3944
|
-
var measureArea = (
|
|
3945
|
-
const n =
|
|
3944
|
+
var measureArea = (polygon2) => {
|
|
3945
|
+
const n = polygon2.vertices.length;
|
|
3946
3946
|
if (n < 3) {
|
|
3947
3947
|
return 0;
|
|
3948
3948
|
}
|
|
3949
|
-
const vertices =
|
|
3950
|
-
const normal = plane(
|
|
3949
|
+
const vertices = polygon2.vertices;
|
|
3950
|
+
const normal = plane(polygon2);
|
|
3951
3951
|
const ax = Math.abs(normal[0]);
|
|
3952
3952
|
const ay = Math.abs(normal[1]);
|
|
3953
3953
|
const az = Math.abs(normal[2]);
|
|
@@ -4006,8 +4006,8 @@ var require_measureBoundingBox = __commonJS({
|
|
|
4006
4006
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureBoundingBox.js"(exports, module) {
|
|
4007
4007
|
"use strict";
|
|
4008
4008
|
var vec3 = require_vec3();
|
|
4009
|
-
var measureBoundingBox = (
|
|
4010
|
-
const vertices =
|
|
4009
|
+
var measureBoundingBox = (polygon2) => {
|
|
4010
|
+
const vertices = polygon2.vertices;
|
|
4011
4011
|
const numvertices = vertices.length;
|
|
4012
4012
|
const min2 = numvertices === 0 ? vec3.create() : vec3.clone(vertices[0]);
|
|
4013
4013
|
const max2 = vec3.clone(min2);
|
|
@@ -4085,10 +4085,10 @@ var require_measureBoundingSphere = __commonJS({
|
|
|
4085
4085
|
"use strict";
|
|
4086
4086
|
var vec4 = require_vec4();
|
|
4087
4087
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
4088
|
-
var measureBoundingSphere = (
|
|
4089
|
-
const boundingSphere = cache.get(
|
|
4088
|
+
var measureBoundingSphere = (polygon2) => {
|
|
4089
|
+
const boundingSphere = cache.get(polygon2);
|
|
4090
4090
|
if (boundingSphere) return boundingSphere;
|
|
4091
|
-
const vertices =
|
|
4091
|
+
const vertices = polygon2.vertices;
|
|
4092
4092
|
const out = vec4.create();
|
|
4093
4093
|
if (vertices.length === 0) {
|
|
4094
4094
|
out[0] = 0;
|
|
@@ -4118,7 +4118,7 @@ var require_measureBoundingSphere = __commonJS({
|
|
|
4118
4118
|
const y = out[1] - maxy[1];
|
|
4119
4119
|
const z21 = out[2] - maxz[2];
|
|
4120
4120
|
out[3] = Math.sqrt(x * x + y * y + z21 * z21);
|
|
4121
|
-
cache.set(
|
|
4121
|
+
cache.set(polygon2, out);
|
|
4122
4122
|
return out;
|
|
4123
4123
|
};
|
|
4124
4124
|
module.exports = measureBoundingSphere;
|
|
@@ -4130,9 +4130,9 @@ var require_measureSignedVolume = __commonJS({
|
|
|
4130
4130
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureSignedVolume.js"(exports, module) {
|
|
4131
4131
|
"use strict";
|
|
4132
4132
|
var vec3 = require_vec3();
|
|
4133
|
-
var measureSignedVolume = (
|
|
4133
|
+
var measureSignedVolume = (polygon2) => {
|
|
4134
4134
|
let signedVolume = 0;
|
|
4135
|
-
const vertices =
|
|
4135
|
+
const vertices = polygon2.vertices;
|
|
4136
4136
|
const cross = vec3.create();
|
|
4137
4137
|
for (let i = 0; i < vertices.length - 2; i++) {
|
|
4138
4138
|
vec3.cross(cross, vertices[i + 1], vertices[i + 2]);
|
|
@@ -4149,7 +4149,7 @@ var require_measureSignedVolume = __commonJS({
|
|
|
4149
4149
|
var require_toPoints2 = __commonJS({
|
|
4150
4150
|
"node_modules/@jscad/modeling/src/geometries/poly3/toPoints.js"(exports, module) {
|
|
4151
4151
|
"use strict";
|
|
4152
|
-
var toPoints = (
|
|
4152
|
+
var toPoints = (polygon2) => polygon2.vertices;
|
|
4153
4153
|
module.exports = toPoints;
|
|
4154
4154
|
}
|
|
4155
4155
|
});
|
|
@@ -4159,9 +4159,9 @@ var require_toString6 = __commonJS({
|
|
|
4159
4159
|
"node_modules/@jscad/modeling/src/geometries/poly3/toString.js"(exports, module) {
|
|
4160
4160
|
"use strict";
|
|
4161
4161
|
var vec3 = require_vec3();
|
|
4162
|
-
var toString = (
|
|
4162
|
+
var toString = (polygon2) => {
|
|
4163
4163
|
let result = "poly3: vertices: [";
|
|
4164
|
-
|
|
4164
|
+
polygon2.vertices.forEach((vertex) => {
|
|
4165
4165
|
result += `${vec3.toString(vertex)}, `;
|
|
4166
4166
|
});
|
|
4167
4167
|
result += "]";
|
|
@@ -4178,8 +4178,8 @@ var require_transform6 = __commonJS({
|
|
|
4178
4178
|
var mat4 = require_mat4();
|
|
4179
4179
|
var vec3 = require_vec3();
|
|
4180
4180
|
var create = require_create6();
|
|
4181
|
-
var transform = (matrix,
|
|
4182
|
-
const vertices =
|
|
4181
|
+
var transform = (matrix, polygon2) => {
|
|
4182
|
+
const vertices = polygon2.vertices.map((vertex) => vec3.transform(vec3.create(), vertex, matrix));
|
|
4183
4183
|
if (mat4.isMirroring(matrix)) {
|
|
4184
4184
|
vertices.reverse();
|
|
4185
4185
|
}
|
|
@@ -4295,8 +4295,8 @@ var require_fromPoints4 = __commonJS({
|
|
|
4295
4295
|
throw new Error("the given points must be an array");
|
|
4296
4296
|
}
|
|
4297
4297
|
const polygons = listofpoints.map((points, index2) => {
|
|
4298
|
-
const
|
|
4299
|
-
return
|
|
4298
|
+
const polygon2 = poly3.create(points);
|
|
4299
|
+
return polygon2;
|
|
4300
4300
|
});
|
|
4301
4301
|
const result = create(polygons);
|
|
4302
4302
|
return result;
|
|
@@ -4347,7 +4347,7 @@ var require_applyTransforms2 = __commonJS({
|
|
|
4347
4347
|
var poly3 = require_poly3();
|
|
4348
4348
|
var applyTransforms = (geometry) => {
|
|
4349
4349
|
if (mat4.isIdentity(geometry.transforms)) return geometry;
|
|
4350
|
-
geometry.polygons = geometry.polygons.map((
|
|
4350
|
+
geometry.polygons = geometry.polygons.map((polygon2) => poly3.transform(geometry.transforms, polygon2));
|
|
4351
4351
|
geometry.transforms = mat4.create();
|
|
4352
4352
|
return geometry;
|
|
4353
4353
|
};
|
|
@@ -4374,7 +4374,7 @@ var require_invert3 = __commonJS({
|
|
|
4374
4374
|
var toPolygons = require_toPolygons();
|
|
4375
4375
|
var invert = (geometry) => {
|
|
4376
4376
|
const polygons = toPolygons(geometry);
|
|
4377
|
-
const newpolygons = polygons.map((
|
|
4377
|
+
const newpolygons = polygons.map((polygon2) => poly3.invert(polygon2));
|
|
4378
4378
|
return create(newpolygons);
|
|
4379
4379
|
};
|
|
4380
4380
|
module.exports = invert;
|
|
@@ -4453,7 +4453,7 @@ var require_toPoints3 = __commonJS({
|
|
|
4453
4453
|
var toPolygons = require_toPolygons();
|
|
4454
4454
|
var toPoints = (geometry) => {
|
|
4455
4455
|
const polygons = toPolygons(geometry);
|
|
4456
|
-
const listofpoints = polygons.map((
|
|
4456
|
+
const listofpoints = polygons.map((polygon2) => poly3.toPoints(polygon2));
|
|
4457
4457
|
return listofpoints;
|
|
4458
4458
|
};
|
|
4459
4459
|
module.exports = toPoints;
|
|
@@ -4469,8 +4469,8 @@ var require_toString7 = __commonJS({
|
|
|
4469
4469
|
var toString = (geometry) => {
|
|
4470
4470
|
const polygons = toPolygons(geometry);
|
|
4471
4471
|
let result = "geom3 (" + polygons.length + " polygons):\n";
|
|
4472
|
-
polygons.forEach((
|
|
4473
|
-
result += " " + poly3.toString(
|
|
4472
|
+
polygons.forEach((polygon2) => {
|
|
4473
|
+
result += " " + poly3.toString(polygon2) + "\n";
|
|
4474
4474
|
});
|
|
4475
4475
|
return result;
|
|
4476
4476
|
};
|
|
@@ -4487,7 +4487,7 @@ var require_toCompactBinary2 = __commonJS({
|
|
|
4487
4487
|
const polygons = geometry.polygons;
|
|
4488
4488
|
const transforms = geometry.transforms;
|
|
4489
4489
|
const numberOfPolygons = polygons.length;
|
|
4490
|
-
const numberOfVertices = polygons.reduce((count3,
|
|
4490
|
+
const numberOfVertices = polygons.reduce((count3, polygon2) => count3 + polygon2.vertices.length, 0);
|
|
4491
4491
|
let color = [-1, -1, -1, -1];
|
|
4492
4492
|
if (geometry.color) color = geometry.color;
|
|
4493
4493
|
const compacted = new Float32Array(1 + 16 + 4 + 1 + numberOfPolygons + numberOfVertices * 3);
|
|
@@ -4515,8 +4515,8 @@ var require_toCompactBinary2 = __commonJS({
|
|
|
4515
4515
|
compacted[21] = numberOfVertices;
|
|
4516
4516
|
let ci = 22;
|
|
4517
4517
|
let vi = ci + numberOfPolygons;
|
|
4518
|
-
polygons.forEach((
|
|
4519
|
-
const points = poly3.toPoints(
|
|
4518
|
+
polygons.forEach((polygon2) => {
|
|
4519
|
+
const points = poly3.toPoints(polygon2);
|
|
4520
4520
|
compacted[ci] = points.length;
|
|
4521
4521
|
ci++;
|
|
4522
4522
|
for (let i = 0; i < points.length; i++) {
|
|
@@ -5945,7 +5945,7 @@ var require_measureArea2 = __commonJS({
|
|
|
5945
5945
|
"node_modules/@jscad/modeling/src/geometries/poly2/measureArea.js"(exports, module) {
|
|
5946
5946
|
"use strict";
|
|
5947
5947
|
var area = require_area();
|
|
5948
|
-
var measureArea = (
|
|
5948
|
+
var measureArea = (polygon2) => area(polygon2.vertices);
|
|
5949
5949
|
module.exports = measureArea;
|
|
5950
5950
|
}
|
|
5951
5951
|
});
|
|
@@ -5969,8 +5969,8 @@ var require_flip2 = __commonJS({
|
|
|
5969
5969
|
"node_modules/@jscad/modeling/src/geometries/poly2/flip.js"(exports, module) {
|
|
5970
5970
|
"use strict";
|
|
5971
5971
|
var create = require_create10();
|
|
5972
|
-
var flip4 = (
|
|
5973
|
-
const vertices =
|
|
5972
|
+
var flip4 = (polygon2) => {
|
|
5973
|
+
const vertices = polygon2.vertices.slice().reverse();
|
|
5974
5974
|
return create(vertices);
|
|
5975
5975
|
};
|
|
5976
5976
|
module.exports = flip4;
|
|
@@ -5983,22 +5983,22 @@ var require_arePointsInside = __commonJS({
|
|
|
5983
5983
|
"use strict";
|
|
5984
5984
|
var measureArea = require_measureArea2();
|
|
5985
5985
|
var flip4 = require_flip2();
|
|
5986
|
-
var arePointsInside = (points,
|
|
5986
|
+
var arePointsInside = (points, polygon2) => {
|
|
5987
5987
|
if (points.length === 0) return 0;
|
|
5988
|
-
const vertices =
|
|
5988
|
+
const vertices = polygon2.vertices;
|
|
5989
5989
|
if (vertices.length < 3) return 0;
|
|
5990
|
-
if (measureArea(
|
|
5991
|
-
|
|
5990
|
+
if (measureArea(polygon2) < 0) {
|
|
5991
|
+
polygon2 = flip4(polygon2);
|
|
5992
5992
|
}
|
|
5993
5993
|
const sum = points.reduce((acc, point) => acc + isPointInside(point, vertices), 0);
|
|
5994
5994
|
return sum === points.length ? 1 : 0;
|
|
5995
5995
|
};
|
|
5996
|
-
var isPointInside = (point,
|
|
5997
|
-
const numverts =
|
|
5996
|
+
var isPointInside = (point, polygon2) => {
|
|
5997
|
+
const numverts = polygon2.length;
|
|
5998
5998
|
const tx = point[0];
|
|
5999
5999
|
const ty = point[1];
|
|
6000
|
-
let vtx0 =
|
|
6001
|
-
let vtx1 =
|
|
6000
|
+
let vtx0 = polygon2[numverts - 1];
|
|
6001
|
+
let vtx1 = polygon2[0];
|
|
6002
6002
|
let yflag0 = vtx0[1] > ty;
|
|
6003
6003
|
let insideFlag = 0;
|
|
6004
6004
|
let i = 0;
|
|
@@ -6017,7 +6017,7 @@ var require_arePointsInside = __commonJS({
|
|
|
6017
6017
|
}
|
|
6018
6018
|
yflag0 = yflag1;
|
|
6019
6019
|
vtx0 = vtx1;
|
|
6020
|
-
vtx1 =
|
|
6020
|
+
vtx1 = polygon2[++i];
|
|
6021
6021
|
}
|
|
6022
6022
|
return insideFlag;
|
|
6023
6023
|
};
|
|
@@ -6696,7 +6696,7 @@ var require_measureArea3 = __commonJS({
|
|
|
6696
6696
|
let area = cache.get(geometry);
|
|
6697
6697
|
if (area) return area;
|
|
6698
6698
|
const polygons = geom3.toPolygons(geometry);
|
|
6699
|
-
area = polygons.reduce((area2,
|
|
6699
|
+
area = polygons.reduce((area2, polygon2) => area2 + poly3.measureArea(polygon2), 0);
|
|
6700
6700
|
cache.set(geometry, area);
|
|
6701
6701
|
return area;
|
|
6702
6702
|
};
|
|
@@ -6799,8 +6799,8 @@ var require_measureBoundingBox2 = __commonJS({
|
|
|
6799
6799
|
vec3.copy(minpoint, points[0]);
|
|
6800
6800
|
}
|
|
6801
6801
|
let maxpoint = vec3.clone(minpoint);
|
|
6802
|
-
polygons.forEach((
|
|
6803
|
-
poly3.toPoints(
|
|
6802
|
+
polygons.forEach((polygon2) => {
|
|
6803
|
+
poly3.toPoints(polygon2).forEach((point) => {
|
|
6804
6804
|
vec3.min(minpoint, minpoint, point);
|
|
6805
6805
|
vec3.max(maxpoint, maxpoint, point);
|
|
6806
6806
|
});
|
|
@@ -6907,7 +6907,7 @@ var require_measureVolume = __commonJS({
|
|
|
6907
6907
|
let volume = cache.get(geometry);
|
|
6908
6908
|
if (volume) return volume;
|
|
6909
6909
|
const polygons = geom3.toPolygons(geometry);
|
|
6910
|
-
volume = polygons.reduce((volume2,
|
|
6910
|
+
volume = polygons.reduce((volume2, polygon2) => volume2 + poly3.measureSignedVolume(polygon2), 0);
|
|
6911
6911
|
cache.set(geometry, volume);
|
|
6912
6912
|
return volume;
|
|
6913
6913
|
};
|
|
@@ -7012,15 +7012,15 @@ var require_measureBoundingSphere2 = __commonJS({
|
|
|
7012
7012
|
const polygons = geom3.toPolygons(geometry);
|
|
7013
7013
|
if (polygons.length > 0) {
|
|
7014
7014
|
let numPoints = 0;
|
|
7015
|
-
polygons.forEach((
|
|
7016
|
-
poly3.toPoints(
|
|
7015
|
+
polygons.forEach((polygon2) => {
|
|
7016
|
+
poly3.toPoints(polygon2).forEach((point) => {
|
|
7017
7017
|
vec3.add(centroid, centroid, point);
|
|
7018
7018
|
numPoints++;
|
|
7019
7019
|
});
|
|
7020
7020
|
});
|
|
7021
7021
|
vec3.scale(centroid, centroid, 1 / numPoints);
|
|
7022
|
-
polygons.forEach((
|
|
7023
|
-
poly3.toPoints(
|
|
7022
|
+
polygons.forEach((polygon2) => {
|
|
7023
|
+
poly3.toPoints(polygon2).forEach((point) => {
|
|
7024
7024
|
radius = Math.max(radius, vec3.squaredDistance(centroid, point));
|
|
7025
7025
|
});
|
|
7026
7026
|
});
|
|
@@ -7108,8 +7108,8 @@ var require_measureCenterOfMass = __commonJS({
|
|
|
7108
7108
|
if (polygons.length === 0) return centerOfMass;
|
|
7109
7109
|
let totalVolume = 0;
|
|
7110
7110
|
const vector = vec3.create();
|
|
7111
|
-
polygons.forEach((
|
|
7112
|
-
const vertices =
|
|
7111
|
+
polygons.forEach((polygon2) => {
|
|
7112
|
+
const vertices = polygon2.vertices;
|
|
7113
7113
|
for (let i = 0; i < vertices.length - 2; i++) {
|
|
7114
7114
|
vec3.cross(vector, vertices[i + 1], vertices[i + 2]);
|
|
7115
7115
|
const volume = vec3.dot(vertices[0], vector) / 6;
|
|
@@ -7690,9 +7690,9 @@ var require_polyhedron = __commonJS({
|
|
|
7690
7690
|
faces.forEach((face) => face.reverse());
|
|
7691
7691
|
}
|
|
7692
7692
|
const polygons = faces.map((face, findex) => {
|
|
7693
|
-
const
|
|
7694
|
-
if (colors2 && colors2[findex])
|
|
7695
|
-
return
|
|
7693
|
+
const polygon2 = poly3.create(face.map((pindex) => points[pindex]));
|
|
7694
|
+
if (colors2 && colors2[findex]) polygon2.color = colors2[findex];
|
|
7695
|
+
return polygon2;
|
|
7696
7696
|
});
|
|
7697
7697
|
return geom3.create(polygons);
|
|
7698
7698
|
};
|
|
@@ -7845,7 +7845,7 @@ var require_polygon = __commonJS({
|
|
|
7845
7845
|
"node_modules/@jscad/modeling/src/primitives/polygon.js"(exports, module) {
|
|
7846
7846
|
"use strict";
|
|
7847
7847
|
var geom2 = require_geom2();
|
|
7848
|
-
var
|
|
7848
|
+
var polygon2 = (options) => {
|
|
7849
7849
|
const defaults = {
|
|
7850
7850
|
points: [],
|
|
7851
7851
|
paths: [],
|
|
@@ -7886,7 +7886,7 @@ var require_polygon = __commonJS({
|
|
|
7886
7886
|
}
|
|
7887
7887
|
return geometry;
|
|
7888
7888
|
};
|
|
7889
|
-
module.exports =
|
|
7889
|
+
module.exports = polygon2;
|
|
7890
7890
|
}
|
|
7891
7891
|
});
|
|
7892
7892
|
|
|
@@ -10156,12 +10156,12 @@ var require_fromFakePolygons = __commonJS({
|
|
|
10156
10156
|
"use strict";
|
|
10157
10157
|
var vec2 = require_vec2();
|
|
10158
10158
|
var geom2 = require_geom2();
|
|
10159
|
-
var fromFakePolygon = (epsilon,
|
|
10160
|
-
if (
|
|
10159
|
+
var fromFakePolygon = (epsilon, polygon2) => {
|
|
10160
|
+
if (polygon2.vertices.length < 4) {
|
|
10161
10161
|
return null;
|
|
10162
10162
|
}
|
|
10163
10163
|
const vert1Indices = [];
|
|
10164
|
-
const points3D =
|
|
10164
|
+
const points3D = polygon2.vertices.filter((vertex, i) => {
|
|
10165
10165
|
if (vertex[2] > 0) {
|
|
10166
10166
|
vert1Indices.push(i);
|
|
10167
10167
|
return true;
|
|
@@ -10188,7 +10188,7 @@ var require_fromFakePolygons = __commonJS({
|
|
|
10188
10188
|
return points2D;
|
|
10189
10189
|
};
|
|
10190
10190
|
var fromFakePolygons = (epsilon, polygons) => {
|
|
10191
|
-
const sides2 = polygons.map((
|
|
10191
|
+
const sides2 = polygons.map((polygon2) => fromFakePolygon(epsilon, polygon2)).filter((polygon2) => polygon2 !== null);
|
|
10192
10192
|
return geom2.create(sides2);
|
|
10193
10193
|
};
|
|
10194
10194
|
module.exports = fromFakePolygons;
|
|
@@ -10549,8 +10549,8 @@ var require_reTesselateCoplanarPolygons = __commonJS({
|
|
|
10549
10549
|
prevpolygon.outpolygon.leftpoints.reverse();
|
|
10550
10550
|
const points2d = prevpolygon.outpolygon.rightpoints.concat(prevpolygon.outpolygon.leftpoints);
|
|
10551
10551
|
const vertices3d = points2d.map((point2d) => orthobasis.to3D(point2d));
|
|
10552
|
-
const
|
|
10553
|
-
if (
|
|
10552
|
+
const polygon2 = poly3.fromPointsAndPlane(vertices3d, plane);
|
|
10553
|
+
if (polygon2.vertices.length) destpolygons.push(polygon2);
|
|
10554
10554
|
}
|
|
10555
10555
|
}
|
|
10556
10556
|
}
|
|
@@ -10594,7 +10594,7 @@ var require_retessellate = __commonJS({
|
|
|
10594
10594
|
if (geometry.isRetesselated) {
|
|
10595
10595
|
return geometry;
|
|
10596
10596
|
}
|
|
10597
|
-
const polygons = geom3.toPolygons(geometry).map((
|
|
10597
|
+
const polygons = geom3.toPolygons(geometry).map((polygon2, index2) => ({ vertices: polygon2.vertices, plane: poly3.plane(polygon2), index: index2 }));
|
|
10598
10598
|
const classified = classifyPolygons(polygons);
|
|
10599
10599
|
const destPolygons = [];
|
|
10600
10600
|
classified.forEach((group) => {
|
|
@@ -10642,8 +10642,8 @@ var require_retessellate = __commonJS({
|
|
|
10642
10642
|
clusters.forEach((cluster) => {
|
|
10643
10643
|
if (cluster[0]) result[cluster[0].index] = cluster;
|
|
10644
10644
|
});
|
|
10645
|
-
nonCoplanar.forEach((
|
|
10646
|
-
result[
|
|
10645
|
+
nonCoplanar.forEach((polygon2) => {
|
|
10646
|
+
result[polygon2.index] = polygon2;
|
|
10647
10647
|
});
|
|
10648
10648
|
return result;
|
|
10649
10649
|
};
|
|
@@ -10848,15 +10848,15 @@ var require_splitPolygonByPlane = __commonJS({
|
|
|
10848
10848
|
}
|
|
10849
10849
|
return result;
|
|
10850
10850
|
};
|
|
10851
|
-
var splitPolygonByPlane = (splane,
|
|
10851
|
+
var splitPolygonByPlane = (splane, polygon2) => {
|
|
10852
10852
|
const result = {
|
|
10853
10853
|
type: null,
|
|
10854
10854
|
front: null,
|
|
10855
10855
|
back: null
|
|
10856
10856
|
};
|
|
10857
|
-
const vertices =
|
|
10857
|
+
const vertices = polygon2.vertices;
|
|
10858
10858
|
const numvertices = vertices.length;
|
|
10859
|
-
const pplane = poly3.plane(
|
|
10859
|
+
const pplane = poly3.plane(polygon2);
|
|
10860
10860
|
if (plane.equals(pplane, splane)) {
|
|
10861
10861
|
result.type = 0;
|
|
10862
10862
|
} else {
|
|
@@ -10939,10 +10939,10 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
10939
10939
|
var splitPolygonByPlane = require_splitPolygonByPlane();
|
|
10940
10940
|
var PolygonTreeNode = class _PolygonTreeNode {
|
|
10941
10941
|
// constructor creates the root node
|
|
10942
|
-
constructor(parent,
|
|
10942
|
+
constructor(parent, polygon2) {
|
|
10943
10943
|
this.parent = parent;
|
|
10944
10944
|
this.children = [];
|
|
10945
|
-
this.polygon =
|
|
10945
|
+
this.polygon = polygon2;
|
|
10946
10946
|
this.removed = false;
|
|
10947
10947
|
}
|
|
10948
10948
|
// fill the tree with polygons. Should be called on the root node only; child nodes must
|
|
@@ -10952,8 +10952,8 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
10952
10952
|
throw new Error("Assertion failed");
|
|
10953
10953
|
}
|
|
10954
10954
|
const _this = this;
|
|
10955
|
-
polygons.forEach((
|
|
10956
|
-
_this.addChild(
|
|
10955
|
+
polygons.forEach((polygon2) => {
|
|
10956
|
+
_this.addChild(polygon2);
|
|
10957
10957
|
});
|
|
10958
10958
|
}
|
|
10959
10959
|
// remove a node
|
|
@@ -11033,9 +11033,9 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11033
11033
|
}
|
|
11034
11034
|
// only to be called for nodes with no children
|
|
11035
11035
|
_splitByPlane(splane, coplanarfrontnodes, coplanarbacknodes, frontnodes, backnodes) {
|
|
11036
|
-
const
|
|
11037
|
-
if (
|
|
11038
|
-
const bound = poly3.measureBoundingSphere(
|
|
11036
|
+
const polygon2 = this.polygon;
|
|
11037
|
+
if (polygon2) {
|
|
11038
|
+
const bound = poly3.measureBoundingSphere(polygon2);
|
|
11039
11039
|
const sphereradius = bound[3] + EPS;
|
|
11040
11040
|
const spherecenter = bound;
|
|
11041
11041
|
const d = vec3.dot(splane, spherecenter) - splane[3];
|
|
@@ -11044,7 +11044,7 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11044
11044
|
} else if (d < -sphereradius) {
|
|
11045
11045
|
backnodes.push(this);
|
|
11046
11046
|
} else {
|
|
11047
|
-
const splitresult = splitPolygonByPlane(splane,
|
|
11047
|
+
const splitresult = splitPolygonByPlane(splane, polygon2);
|
|
11048
11048
|
switch (splitresult.type) {
|
|
11049
11049
|
case 0:
|
|
11050
11050
|
coplanarfrontnodes.push(this);
|
|
@@ -11077,8 +11077,8 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11077
11077
|
// this should be called whenever the polygon is split
|
|
11078
11078
|
// a child should be created for every fragment of the split polygon
|
|
11079
11079
|
// returns the newly created child
|
|
11080
|
-
addChild(
|
|
11081
|
-
const newchild = new _PolygonTreeNode(this,
|
|
11080
|
+
addChild(polygon2) {
|
|
11081
|
+
const newchild = new _PolygonTreeNode(this, polygon2);
|
|
11082
11082
|
this.children.push(newchild);
|
|
11083
11083
|
return newchild;
|
|
11084
11084
|
}
|
|
@@ -11420,8 +11420,8 @@ var require_minkowskiSum = __commonJS({
|
|
|
11420
11420
|
}
|
|
11421
11421
|
const tetrahedra = [];
|
|
11422
11422
|
for (let i = 0; i < polygons.length; i++) {
|
|
11423
|
-
const
|
|
11424
|
-
const vertices =
|
|
11423
|
+
const polygon2 = polygons[i];
|
|
11424
|
+
const vertices = polygon2.vertices;
|
|
11425
11425
|
let cx = 0, cy = 0, cz = 0;
|
|
11426
11426
|
for (let k = 0; k < vertices.length; k++) {
|
|
11427
11427
|
cx += vertices[k][0];
|
|
@@ -11431,7 +11431,7 @@ var require_minkowskiSum = __commonJS({
|
|
|
11431
11431
|
cx /= vertices.length;
|
|
11432
11432
|
cy /= vertices.length;
|
|
11433
11433
|
cz /= vertices.length;
|
|
11434
|
-
const plane = poly3.plane(
|
|
11434
|
+
const plane = poly3.plane(polygon2);
|
|
11435
11435
|
const nx = plane[0], ny = plane[1], nz = plane[2];
|
|
11436
11436
|
const offset4 = 0.1;
|
|
11437
11437
|
const apex = [
|
|
@@ -11527,14 +11527,14 @@ var require_scissionGeom3 = __commonJS({
|
|
|
11527
11527
|
const pl = polygons.length;
|
|
11528
11528
|
const indexesPerPoint = /* @__PURE__ */ new Map();
|
|
11529
11529
|
const temp = vec3.create();
|
|
11530
|
-
polygons.forEach((
|
|
11531
|
-
|
|
11530
|
+
polygons.forEach((polygon2, index2) => {
|
|
11531
|
+
polygon2.vertices.forEach((point) => {
|
|
11532
11532
|
insertMapping(indexesPerPoint, vec3.snap(temp, point, eps), index2);
|
|
11533
11533
|
});
|
|
11534
11534
|
});
|
|
11535
|
-
const indexesPerPolygon = polygons.map((
|
|
11535
|
+
const indexesPerPolygon = polygons.map((polygon2) => {
|
|
11536
11536
|
let indexes = [];
|
|
11537
|
-
|
|
11537
|
+
polygon2.vertices.forEach((point) => {
|
|
11538
11538
|
indexes = indexes.concat(findMapping(indexesPerPoint, vec3.snap(temp, point, eps)));
|
|
11539
11539
|
});
|
|
11540
11540
|
return { e: 1, d: sortNb(indexes) };
|
|
@@ -11629,7 +11629,7 @@ var require_subtractGeom3 = __commonJS({
|
|
|
11629
11629
|
var flatten = require_flatten();
|
|
11630
11630
|
var retessellate = require_retessellate();
|
|
11631
11631
|
var subtractSub = require_subtractGeom3Sub();
|
|
11632
|
-
var
|
|
11632
|
+
var subtract4 = (...geometries) => {
|
|
11633
11633
|
geometries = flatten(geometries);
|
|
11634
11634
|
let newgeometry = geometries.shift();
|
|
11635
11635
|
geometries.forEach((geometry) => {
|
|
@@ -11638,7 +11638,7 @@ var require_subtractGeom3 = __commonJS({
|
|
|
11638
11638
|
newgeometry = retessellate(newgeometry);
|
|
11639
11639
|
return newgeometry;
|
|
11640
11640
|
};
|
|
11641
|
-
module.exports =
|
|
11641
|
+
module.exports = subtract4;
|
|
11642
11642
|
}
|
|
11643
11643
|
});
|
|
11644
11644
|
|
|
@@ -11652,14 +11652,14 @@ var require_subtractGeom2 = __commonJS({
|
|
|
11652
11652
|
var fromFakePolygons = require_fromFakePolygons();
|
|
11653
11653
|
var to3DWalls = require_to3DWalls();
|
|
11654
11654
|
var subtractGeom3 = require_subtractGeom3();
|
|
11655
|
-
var
|
|
11655
|
+
var subtract4 = (...geometries) => {
|
|
11656
11656
|
geometries = flatten(geometries);
|
|
11657
11657
|
const newgeometries = geometries.map((geometry) => to3DWalls({ z0: -1, z1: 1 }, geometry));
|
|
11658
11658
|
const newgeom3 = subtractGeom3(newgeometries);
|
|
11659
11659
|
const epsilon = measureEpsilon(newgeom3);
|
|
11660
11660
|
return fromFakePolygons(epsilon, geom3.toPolygons(newgeom3));
|
|
11661
11661
|
};
|
|
11662
|
-
module.exports =
|
|
11662
|
+
module.exports = subtract4;
|
|
11663
11663
|
}
|
|
11664
11664
|
});
|
|
11665
11665
|
|
|
@@ -11673,7 +11673,7 @@ var require_subtract4 = __commonJS({
|
|
|
11673
11673
|
var geom3 = require_geom3();
|
|
11674
11674
|
var subtractGeom2 = require_subtractGeom2();
|
|
11675
11675
|
var subtractGeom3 = require_subtractGeom3();
|
|
11676
|
-
var
|
|
11676
|
+
var subtract4 = (...geometries) => {
|
|
11677
11677
|
geometries = flatten(geometries);
|
|
11678
11678
|
if (geometries.length === 0) throw new Error("wrong number of arguments");
|
|
11679
11679
|
if (!areAllShapesTheSameType(geometries)) {
|
|
@@ -11684,7 +11684,7 @@ var require_subtract4 = __commonJS({
|
|
|
11684
11684
|
if (geom3.isA(geometry)) return subtractGeom3(geometries);
|
|
11685
11685
|
return geometry;
|
|
11686
11686
|
};
|
|
11687
|
-
module.exports =
|
|
11687
|
+
module.exports = subtract4;
|
|
11688
11688
|
}
|
|
11689
11689
|
});
|
|
11690
11690
|
|
|
@@ -11929,19 +11929,19 @@ var require_extrudePolygon = __commonJS({
|
|
|
11929
11929
|
polygon1 = poly3.invert(polygon1);
|
|
11930
11930
|
}
|
|
11931
11931
|
const newpolygons = [polygon1];
|
|
11932
|
-
const
|
|
11932
|
+
const polygon2 = poly3.transform(mat4.fromTranslation(mat4.create(), offsetvector), polygon1);
|
|
11933
11933
|
const numvertices = polygon1.vertices.length;
|
|
11934
11934
|
for (let i = 0; i < numvertices; i++) {
|
|
11935
11935
|
const nexti = i < numvertices - 1 ? i + 1 : 0;
|
|
11936
11936
|
const sideFacePolygon = poly3.create([
|
|
11937
11937
|
polygon1.vertices[i],
|
|
11938
|
-
|
|
11939
|
-
|
|
11938
|
+
polygon2.vertices[i],
|
|
11939
|
+
polygon2.vertices[nexti],
|
|
11940
11940
|
polygon1.vertices[nexti]
|
|
11941
11941
|
]);
|
|
11942
11942
|
newpolygons.push(sideFacePolygon);
|
|
11943
11943
|
}
|
|
11944
|
-
newpolygons.push(poly3.invert(
|
|
11944
|
+
newpolygons.push(poly3.invert(polygon2));
|
|
11945
11945
|
return geom3.create(newpolygons);
|
|
11946
11946
|
};
|
|
11947
11947
|
module.exports = extrudePolygon;
|
|
@@ -12002,17 +12002,17 @@ var require_expandShell = __commonJS({
|
|
|
12002
12002
|
const v1 = vec3.create();
|
|
12003
12003
|
const v2 = vec3.create();
|
|
12004
12004
|
const polygons = geom3.toPolygons(geometry);
|
|
12005
|
-
polygons.forEach((
|
|
12006
|
-
const extrudevector = vec3.scale(vec3.create(), poly3.plane(
|
|
12007
|
-
const translatedpolygon = poly3.transform(mat4.fromTranslation(mat4.create(), vec3.scale(vec3.create(), extrudevector, -0.5)),
|
|
12005
|
+
polygons.forEach((polygon2, index2) => {
|
|
12006
|
+
const extrudevector = vec3.scale(vec3.create(), poly3.plane(polygon2), 2 * delta);
|
|
12007
|
+
const translatedpolygon = poly3.transform(mat4.fromTranslation(mat4.create(), vec3.scale(vec3.create(), extrudevector, -0.5)), polygon2);
|
|
12008
12008
|
const extrudedface = extrudePolygon(extrudevector, translatedpolygon);
|
|
12009
12009
|
result = unionGeom3Sub(result, extrudedface);
|
|
12010
|
-
const vertices =
|
|
12010
|
+
const vertices = polygon2.vertices;
|
|
12011
12011
|
for (let i = 0; i < vertices.length; i++) {
|
|
12012
|
-
mapPlaneToVertex(vertices2planes, vertices[i], poly3.plane(
|
|
12012
|
+
mapPlaneToVertex(vertices2planes, vertices[i], poly3.plane(polygon2));
|
|
12013
12013
|
const j = (i + 1) % vertices.length;
|
|
12014
12014
|
const edge = [vertices[i], vertices[j]];
|
|
12015
|
-
mapPlaneToEdge(edges2planes, edge, poly3.plane(
|
|
12015
|
+
mapPlaneToEdge(edges2planes, edge, poly3.plane(polygon2));
|
|
12016
12016
|
}
|
|
12017
12017
|
});
|
|
12018
12018
|
edges2planes.forEach((item) => {
|
|
@@ -12066,8 +12066,8 @@ var require_expandShell = __commonJS({
|
|
|
12066
12066
|
startfacevertices.push(p1);
|
|
12067
12067
|
endfacevertices.push(p2);
|
|
12068
12068
|
const points = [prevp2, p2, p1, prevp1];
|
|
12069
|
-
const
|
|
12070
|
-
polygons2.push(
|
|
12069
|
+
const polygon2 = poly3.create(points);
|
|
12070
|
+
polygons2.push(polygon2);
|
|
12071
12071
|
}
|
|
12072
12072
|
prevp1 = p1;
|
|
12073
12073
|
prevp2 = p2;
|
|
@@ -12269,7 +12269,7 @@ var require_offsetGeom2 = __commonJS({
|
|
|
12269
12269
|
}
|
|
12270
12270
|
const outlines = geom2.toOutlines(geometry);
|
|
12271
12271
|
const newoutlines = outlines.map((outline) => {
|
|
12272
|
-
const level = outlines.reduce((acc,
|
|
12272
|
+
const level = outlines.reduce((acc, polygon2) => acc + poly2.arePointsInside(outline, poly2.create(polygon2)), 0);
|
|
12273
12273
|
const outside = level % 2 === 0;
|
|
12274
12274
|
options = {
|
|
12275
12275
|
delta: outside ? delta : -delta,
|
|
@@ -12875,24 +12875,24 @@ var require_snapPolygons = __commonJS({
|
|
|
12875
12875
|
"use strict";
|
|
12876
12876
|
var vec3 = require_vec3();
|
|
12877
12877
|
var poly3 = require_poly3();
|
|
12878
|
-
var isValidPoly3 = (epsilon,
|
|
12879
|
-
const area = Math.abs(poly3.measureArea(
|
|
12878
|
+
var isValidPoly3 = (epsilon, polygon2) => {
|
|
12879
|
+
const area = Math.abs(poly3.measureArea(polygon2));
|
|
12880
12880
|
return Number.isFinite(area) && area > epsilon;
|
|
12881
12881
|
};
|
|
12882
12882
|
var snapPolygons = (epsilon, polygons) => {
|
|
12883
|
-
let newpolygons = polygons.map((
|
|
12884
|
-
const snapvertices =
|
|
12883
|
+
let newpolygons = polygons.map((polygon2) => {
|
|
12884
|
+
const snapvertices = polygon2.vertices.map((vertice) => vec3.snap(vec3.create(), vertice, epsilon));
|
|
12885
12885
|
const newvertices = [];
|
|
12886
12886
|
for (let i = 0; i < snapvertices.length; i++) {
|
|
12887
12887
|
const j = (i + 1) % snapvertices.length;
|
|
12888
12888
|
if (!vec3.equals(snapvertices[i], snapvertices[j])) newvertices.push(snapvertices[i]);
|
|
12889
12889
|
}
|
|
12890
12890
|
const newpolygon = poly3.create(newvertices);
|
|
12891
|
-
if (
|
|
12891
|
+
if (polygon2.color) newpolygon.color = polygon2.color;
|
|
12892
12892
|
return newpolygon;
|
|
12893
12893
|
});
|
|
12894
12894
|
const epsilonArea = epsilon * epsilon * Math.sqrt(3) / 4;
|
|
12895
|
-
newpolygons = newpolygons.filter((
|
|
12895
|
+
newpolygons = newpolygons.filter((polygon2) => isValidPoly3(epsilonArea, polygon2));
|
|
12896
12896
|
return newpolygons;
|
|
12897
12897
|
};
|
|
12898
12898
|
module.exports = snapPolygons;
|
|
@@ -12906,8 +12906,8 @@ var require_mergePolygons = __commonJS({
|
|
|
12906
12906
|
var aboutEqualNormals = require_aboutEqualNormals();
|
|
12907
12907
|
var vec3 = require_vec3();
|
|
12908
12908
|
var poly3 = require_poly3();
|
|
12909
|
-
var createEdges = (
|
|
12910
|
-
const points = poly3.toPoints(
|
|
12909
|
+
var createEdges = (polygon2) => {
|
|
12910
|
+
const points = poly3.toPoints(polygon2);
|
|
12911
12911
|
const edges = [];
|
|
12912
12912
|
for (let i = 0; i < points.length; i++) {
|
|
12913
12913
|
const j = (i + 1) % points.length;
|
|
@@ -12956,7 +12956,7 @@ var require_mergePolygons = __commonJS({
|
|
|
12956
12956
|
return vec3.dot(d0, normal);
|
|
12957
12957
|
};
|
|
12958
12958
|
var createPolygonAnd = (edge) => {
|
|
12959
|
-
let
|
|
12959
|
+
let polygon2;
|
|
12960
12960
|
const points = [];
|
|
12961
12961
|
while (edge.next) {
|
|
12962
12962
|
const next = edge.next;
|
|
@@ -12967,8 +12967,8 @@ var require_mergePolygons = __commonJS({
|
|
|
12967
12967
|
edge.prev = null;
|
|
12968
12968
|
edge = next;
|
|
12969
12969
|
}
|
|
12970
|
-
if (points.length > 0)
|
|
12971
|
-
return
|
|
12970
|
+
if (points.length > 0) polygon2 = poly3.create(points);
|
|
12971
|
+
return polygon2;
|
|
12972
12972
|
};
|
|
12973
12973
|
var mergeCoplanarPolygons = (sourcepolygons) => {
|
|
12974
12974
|
if (sourcepolygons.length < 2) return sourcepolygons;
|
|
@@ -12976,8 +12976,8 @@ var require_mergePolygons = __commonJS({
|
|
|
12976
12976
|
const polygons = sourcepolygons.slice();
|
|
12977
12977
|
const edgeList = /* @__PURE__ */ new Map();
|
|
12978
12978
|
while (polygons.length > 0) {
|
|
12979
|
-
const
|
|
12980
|
-
const edges = createEdges(
|
|
12979
|
+
const polygon2 = polygons.shift();
|
|
12980
|
+
const edges = createEdges(polygon2);
|
|
12981
12981
|
for (let i = 0; i < edges.length; i++) {
|
|
12982
12982
|
const current = edges[i];
|
|
12983
12983
|
const opposite = findOppositeEdge(edgeList, current);
|
|
@@ -13033,8 +13033,8 @@ var require_mergePolygons = __commonJS({
|
|
|
13033
13033
|
}
|
|
13034
13034
|
const destpolygons = [];
|
|
13035
13035
|
edgeList.forEach((edge) => {
|
|
13036
|
-
const
|
|
13037
|
-
if (
|
|
13036
|
+
const polygon2 = createPolygonAnd(edge);
|
|
13037
|
+
if (polygon2) destpolygons.push(polygon2);
|
|
13038
13038
|
});
|
|
13039
13039
|
edgeList.clear();
|
|
13040
13040
|
return destpolygons;
|
|
@@ -13047,13 +13047,13 @@ var require_mergePolygons = __commonJS({
|
|
|
13047
13047
|
};
|
|
13048
13048
|
var mergePolygons = (epsilon, polygons) => {
|
|
13049
13049
|
const polygonsPerPlane = [];
|
|
13050
|
-
polygons.forEach((
|
|
13051
|
-
const mapping = polygonsPerPlane.find((element) => coplanar(element[0], poly3.plane(
|
|
13050
|
+
polygons.forEach((polygon2) => {
|
|
13051
|
+
const mapping = polygonsPerPlane.find((element) => coplanar(element[0], poly3.plane(polygon2)));
|
|
13052
13052
|
if (mapping) {
|
|
13053
13053
|
const polygons2 = mapping[1];
|
|
13054
|
-
polygons2.push(
|
|
13054
|
+
polygons2.push(polygon2);
|
|
13055
13055
|
} else {
|
|
13056
|
-
polygonsPerPlane.push([poly3.plane(
|
|
13056
|
+
polygonsPerPlane.push([poly3.plane(polygon2), [polygon2]]);
|
|
13057
13057
|
}
|
|
13058
13058
|
});
|
|
13059
13059
|
let destpolygons = [];
|
|
@@ -13149,15 +13149,15 @@ var require_insertTjunctions = __commonJS({
|
|
|
13149
13149
|
var insertTjunctions = (polygons) => {
|
|
13150
13150
|
const sidemap = /* @__PURE__ */ new Map();
|
|
13151
13151
|
for (let polygonindex = 0; polygonindex < polygons.length; polygonindex++) {
|
|
13152
|
-
const
|
|
13153
|
-
const numvertices =
|
|
13152
|
+
const polygon2 = polygons[polygonindex];
|
|
13153
|
+
const numvertices = polygon2.vertices.length;
|
|
13154
13154
|
if (numvertices >= 3) {
|
|
13155
|
-
let vertex =
|
|
13155
|
+
let vertex = polygon2.vertices[0];
|
|
13156
13156
|
let vertextag = getTag(vertex);
|
|
13157
13157
|
for (let vertexindex = 0; vertexindex < numvertices; vertexindex++) {
|
|
13158
13158
|
let nextvertexindex = vertexindex + 1;
|
|
13159
13159
|
if (nextvertexindex === numvertices) nextvertexindex = 0;
|
|
13160
|
-
const nextvertex =
|
|
13160
|
+
const nextvertex = polygon2.vertices[nextvertexindex];
|
|
13161
13161
|
const nextvertextag = getTag(nextvertex);
|
|
13162
13162
|
const sidetag = `${vertextag}/${nextvertextag}`;
|
|
13163
13163
|
const reversesidetag = `${nextvertextag}/${vertextag}`;
|
|
@@ -13265,17 +13265,17 @@ var require_insertTjunctions = __commonJS({
|
|
|
13265
13265
|
const distancesquared = vec3.squaredDistance(closestpoint, endpos);
|
|
13266
13266
|
if (distancesquared < constants.EPS * constants.EPS) {
|
|
13267
13267
|
const polygonindex = matchingside.polygonindex;
|
|
13268
|
-
const
|
|
13268
|
+
const polygon2 = newpolygons[polygonindex];
|
|
13269
13269
|
const insertionvertextag = getTag(matchingside.vertex1);
|
|
13270
13270
|
let insertionvertextagindex = -1;
|
|
13271
|
-
for (let i = 0; i <
|
|
13272
|
-
if (getTag(
|
|
13271
|
+
for (let i = 0; i < polygon2.vertices.length; i++) {
|
|
13272
|
+
if (getTag(polygon2.vertices[i]) === insertionvertextag) {
|
|
13273
13273
|
insertionvertextagindex = i;
|
|
13274
13274
|
break;
|
|
13275
13275
|
}
|
|
13276
13276
|
}
|
|
13277
13277
|
if (assert && insertionvertextagindex < 0) throw new Error("assert failed");
|
|
13278
|
-
const newvertices =
|
|
13278
|
+
const newvertices = polygon2.vertices.slice(0);
|
|
13279
13279
|
newvertices.splice(insertionvertextagindex, 0, endvertex);
|
|
13280
13280
|
const newpolygon = poly3.create(newvertices);
|
|
13281
13281
|
newpolygons[polygonindex] = newpolygon;
|
|
@@ -13315,35 +13315,35 @@ var require_triangulatePolygons = __commonJS({
|
|
|
13315
13315
|
"use strict";
|
|
13316
13316
|
var vec3 = require_vec3();
|
|
13317
13317
|
var poly3 = require_poly3();
|
|
13318
|
-
var triangulatePolygon = (epsilon,
|
|
13319
|
-
const nv =
|
|
13318
|
+
var triangulatePolygon = (epsilon, polygon2, triangles) => {
|
|
13319
|
+
const nv = polygon2.vertices.length;
|
|
13320
13320
|
if (nv > 3) {
|
|
13321
13321
|
if (nv > 4) {
|
|
13322
13322
|
const midpoint2 = [0, 0, 0];
|
|
13323
|
-
|
|
13323
|
+
polygon2.vertices.forEach((vertice) => vec3.add(midpoint2, midpoint2, vertice));
|
|
13324
13324
|
vec3.snap(midpoint2, vec3.divide(midpoint2, midpoint2, [nv, nv, nv]), epsilon);
|
|
13325
13325
|
for (let i = 0; i < nv; i++) {
|
|
13326
|
-
const poly = poly3.create([midpoint2,
|
|
13327
|
-
if (
|
|
13326
|
+
const poly = poly3.create([midpoint2, polygon2.vertices[i], polygon2.vertices[(i + 1) % nv]]);
|
|
13327
|
+
if (polygon2.color) poly.color = polygon2.color;
|
|
13328
13328
|
triangles.push(poly);
|
|
13329
13329
|
}
|
|
13330
13330
|
return;
|
|
13331
13331
|
}
|
|
13332
|
-
const poly0 = poly3.create([
|
|
13333
|
-
const poly1 = poly3.create([
|
|
13334
|
-
if (
|
|
13335
|
-
poly0.color =
|
|
13336
|
-
poly1.color =
|
|
13332
|
+
const poly0 = poly3.create([polygon2.vertices[0], polygon2.vertices[1], polygon2.vertices[2]]);
|
|
13333
|
+
const poly1 = poly3.create([polygon2.vertices[0], polygon2.vertices[2], polygon2.vertices[3]]);
|
|
13334
|
+
if (polygon2.color) {
|
|
13335
|
+
poly0.color = polygon2.color;
|
|
13336
|
+
poly1.color = polygon2.color;
|
|
13337
13337
|
}
|
|
13338
13338
|
triangles.push(poly0, poly1);
|
|
13339
13339
|
return;
|
|
13340
13340
|
}
|
|
13341
|
-
triangles.push(
|
|
13341
|
+
triangles.push(polygon2);
|
|
13342
13342
|
};
|
|
13343
13343
|
var triangulatePolygons = (epsilon, polygons) => {
|
|
13344
13344
|
const triangles = [];
|
|
13345
|
-
polygons.forEach((
|
|
13346
|
-
triangulatePolygon(epsilon,
|
|
13345
|
+
polygons.forEach((polygon2) => {
|
|
13346
|
+
triangulatePolygon(epsilon, polygon2, triangles);
|
|
13347
13347
|
});
|
|
13348
13348
|
return triangles;
|
|
13349
13349
|
};
|
|
@@ -23981,8 +23981,8 @@ var SmdChipLead = (props) => {
|
|
|
23981
23981
|
const { thickness, width: width10, padContactLength, bodyDistance, height: height10, rotation } = props;
|
|
23982
23982
|
const N = 15;
|
|
23983
23983
|
const points = Array.from({ length: N }).map((_, i) => i / (N - 1) * bodyDistance).map((x) => [x, calculateSCurve(x, props)]);
|
|
23984
|
-
const
|
|
23985
|
-
return /* @__PURE__ */ jsx2(Colorize, { color: "#fff", children: /* @__PURE__ */ jsx2(Translate, { offset: { z: 0, y: 0, x: 0, ...props.position }, children: /* @__PURE__ */ jsx2(Rotate, { rotation: ["90deg", 0, rotation ?? 0], children: /* @__PURE__ */ jsx2(Translate, { offset: { x: 0, y: 0, z: -width10 / 2 }, children: /* @__PURE__ */ jsx2(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx2(Polygon, { points:
|
|
23984
|
+
const polygon2 = getExpandedStroke(points, thickness);
|
|
23985
|
+
return /* @__PURE__ */ jsx2(Colorize, { color: "#fff", children: /* @__PURE__ */ jsx2(Translate, { offset: { z: 0, y: 0, x: 0, ...props.position }, children: /* @__PURE__ */ jsx2(Rotate, { rotation: ["90deg", 0, rotation ?? 0], children: /* @__PURE__ */ jsx2(Translate, { offset: { x: 0, y: 0, z: -width10 / 2 }, children: /* @__PURE__ */ jsx2(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx2(Polygon, { points: polygon2.map((p) => [p.x, p.y]) }) }) }) }) }) });
|
|
23986
23986
|
};
|
|
23987
23987
|
var Tssop = ({
|
|
23988
23988
|
pinCount,
|
|
@@ -25262,7 +25262,7 @@ var PushButtonLeg = (props) => {
|
|
|
25262
25262
|
[-verticalLength / 5, horizontalLength / 4],
|
|
25263
25263
|
[0, 0]
|
|
25264
25264
|
];
|
|
25265
|
-
const
|
|
25265
|
+
const polygon2 = getExpandedStroke(points, thickness);
|
|
25266
25266
|
return /* @__PURE__ */ jsx2(Colorize, { color: "#f2f2f2", children: /* @__PURE__ */ jsx2(
|
|
25267
25267
|
Translate,
|
|
25268
25268
|
{
|
|
@@ -25271,7 +25271,7 @@ var PushButtonLeg = (props) => {
|
|
|
25271
25271
|
y: position?.y || 0,
|
|
25272
25272
|
z: position?.z || 0
|
|
25273
25273
|
},
|
|
25274
|
-
children: /* @__PURE__ */ jsx2(Rotate, { rotation: [0, 55, rotation], children: /* @__PURE__ */ jsx2(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx2(Polygon, { points:
|
|
25274
|
+
children: /* @__PURE__ */ jsx2(Rotate, { rotation: [0, 55, rotation], children: /* @__PURE__ */ jsx2(ExtrudeLinear, { height: width10, children: /* @__PURE__ */ jsx2(Polygon, { points: polygon2.map((p) => [p.y, p.x]) }) }) })
|
|
25275
25275
|
}
|
|
25276
25276
|
) });
|
|
25277
25277
|
};
|
|
@@ -28421,8 +28421,8 @@ function convertCSGToThreeGeom(csg) {
|
|
|
28421
28421
|
const indices = [];
|
|
28422
28422
|
const colors2 = [];
|
|
28423
28423
|
let idx = 0;
|
|
28424
|
-
for (const
|
|
28425
|
-
for (const vertex of
|
|
28424
|
+
for (const polygon2 of csg.polygons) {
|
|
28425
|
+
for (const vertex of polygon2.vertices) {
|
|
28426
28426
|
vertex.index = idx;
|
|
28427
28427
|
vertices.push(vertex[0], vertex[1], vertex[2]);
|
|
28428
28428
|
if (csg.color && csg.color.length >= 3) {
|
|
@@ -28432,10 +28432,10 @@ function convertCSGToThreeGeom(csg) {
|
|
|
28432
28432
|
}
|
|
28433
28433
|
idx++;
|
|
28434
28434
|
}
|
|
28435
|
-
const first =
|
|
28436
|
-
for (let i = 2; i <
|
|
28437
|
-
const second =
|
|
28438
|
-
const third =
|
|
28435
|
+
const first = polygon2.vertices[0].index;
|
|
28436
|
+
for (let i = 2; i < polygon2.vertices.length; i++) {
|
|
28437
|
+
const second = polygon2.vertices[i - 1].index;
|
|
28438
|
+
const third = polygon2.vertices[i].index;
|
|
28439
28439
|
indices.push(first, second, third);
|
|
28440
28440
|
}
|
|
28441
28441
|
}
|
|
@@ -29732,7 +29732,7 @@ import * as THREE16 from "three";
|
|
|
29732
29732
|
// package.json
|
|
29733
29733
|
var package_default = {
|
|
29734
29734
|
name: "@tscircuit/3d-viewer",
|
|
29735
|
-
version: "0.0.
|
|
29735
|
+
version: "0.0.539",
|
|
29736
29736
|
main: "./dist/index.js",
|
|
29737
29737
|
module: "./dist/index.js",
|
|
29738
29738
|
type: "module",
|
|
@@ -32594,7 +32594,7 @@ import { su as su8 } from "@tscircuit/circuit-json-util";
|
|
|
32594
32594
|
import { useEffect as useEffect24, useMemo as useMemo19 } from "react";
|
|
32595
32595
|
|
|
32596
32596
|
// src/textures/create-combined-board-textures.ts
|
|
32597
|
-
import * as
|
|
32597
|
+
import * as THREE29 from "three";
|
|
32598
32598
|
|
|
32599
32599
|
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
32600
32600
|
var getBoundsFromPoints = (points) => {
|
|
@@ -33058,11 +33058,128 @@ function createCopperTextTextureForLayer({
|
|
|
33058
33058
|
return texture;
|
|
33059
33059
|
}
|
|
33060
33060
|
|
|
33061
|
-
// src/textures/create-
|
|
33061
|
+
// src/textures/create-copper-pour-texture-for-layer.ts
|
|
33062
33062
|
import * as THREE23 from "three";
|
|
33063
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
|
|
33064
|
+
var toRgb = (colorArr) => {
|
|
33065
|
+
const [r = 0, g = 0, b = 0] = colorArr;
|
|
33066
|
+
return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
|
|
33067
|
+
b * 255
|
|
33068
|
+
)})`;
|
|
33069
|
+
};
|
|
33070
|
+
var COPPER_POUR_OPACITY_COMPENSATION_PASSES = 8;
|
|
33071
|
+
function createCopperPourTextureForLayer({
|
|
33072
|
+
layer,
|
|
33073
|
+
circuitJson,
|
|
33074
|
+
boardData,
|
|
33075
|
+
traceTextureResolution = TRACE_TEXTURE_RESOLUTION,
|
|
33076
|
+
copperColor = toRgb(colors.copper)
|
|
33077
|
+
}) {
|
|
33078
|
+
const copperPours = circuitJson.filter(
|
|
33079
|
+
(e) => e.type === "pcb_copper_pour"
|
|
33080
|
+
);
|
|
33081
|
+
const pcbRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
33082
|
+
const poursOnLayer = copperPours.filter((p) => p.layer === layer);
|
|
33083
|
+
if (poursOnLayer.length === 0) return null;
|
|
33084
|
+
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
33085
|
+
const canvas = document.createElement("canvas");
|
|
33086
|
+
const canvasWidth = Math.floor(
|
|
33087
|
+
boardOutlineBounds.width * traceTextureResolution
|
|
33088
|
+
);
|
|
33089
|
+
const canvasHeight = Math.floor(
|
|
33090
|
+
boardOutlineBounds.height * traceTextureResolution
|
|
33091
|
+
);
|
|
33092
|
+
canvas.width = canvasWidth;
|
|
33093
|
+
canvas.height = canvasHeight;
|
|
33094
|
+
const ctx = canvas.getContext("2d");
|
|
33095
|
+
if (!ctx) return null;
|
|
33096
|
+
if (layer === "bottom") {
|
|
33097
|
+
ctx.translate(0, canvasHeight);
|
|
33098
|
+
ctx.scale(1, -1);
|
|
33099
|
+
}
|
|
33100
|
+
const transparent = "rgba(0,0,0,0)";
|
|
33101
|
+
const coveredColor = copperColor;
|
|
33102
|
+
const uncoveredColor = copperColor;
|
|
33103
|
+
const setColorAndDraw = (pours, copperPourColor) => {
|
|
33104
|
+
if (pours.length === 0) return;
|
|
33105
|
+
const drawer = new CircuitToCanvasDrawer4(ctx);
|
|
33106
|
+
drawer.configure({
|
|
33107
|
+
colorOverrides: {
|
|
33108
|
+
copper: {
|
|
33109
|
+
top: copperPourColor,
|
|
33110
|
+
bottom: copperPourColor,
|
|
33111
|
+
inner1: copperPourColor,
|
|
33112
|
+
inner2: copperPourColor,
|
|
33113
|
+
inner3: copperPourColor,
|
|
33114
|
+
inner4: copperPourColor,
|
|
33115
|
+
inner5: copperPourColor,
|
|
33116
|
+
inner6: copperPourColor
|
|
33117
|
+
},
|
|
33118
|
+
copperPour: {
|
|
33119
|
+
top: transparent,
|
|
33120
|
+
bottom: transparent
|
|
33121
|
+
},
|
|
33122
|
+
drill: transparent,
|
|
33123
|
+
boardOutline: transparent,
|
|
33124
|
+
substrate: transparent,
|
|
33125
|
+
keepout: transparent,
|
|
33126
|
+
fabricationNote: transparent,
|
|
33127
|
+
courtyard: { top: transparent, bottom: transparent },
|
|
33128
|
+
silkscreen: { top: transparent, bottom: transparent },
|
|
33129
|
+
soldermask: { top: transparent, bottom: transparent },
|
|
33130
|
+
soldermaskWithCopperUnderneath: {
|
|
33131
|
+
top: transparent,
|
|
33132
|
+
bottom: transparent
|
|
33133
|
+
},
|
|
33134
|
+
soldermaskOverCopper: {
|
|
33135
|
+
top: transparent,
|
|
33136
|
+
bottom: transparent
|
|
33137
|
+
}
|
|
33138
|
+
}
|
|
33139
|
+
});
|
|
33140
|
+
drawer.setCameraBounds({
|
|
33141
|
+
minX: boardOutlineBounds.minX,
|
|
33142
|
+
maxX: boardOutlineBounds.maxX,
|
|
33143
|
+
minY: boardOutlineBounds.minY,
|
|
33144
|
+
maxY: boardOutlineBounds.maxY
|
|
33145
|
+
});
|
|
33146
|
+
drawer.drawElements(pours, {
|
|
33147
|
+
layers: [pcbRenderLayer],
|
|
33148
|
+
drawSoldermask: false,
|
|
33149
|
+
drawSoldermaskTop: false,
|
|
33150
|
+
drawSoldermaskBottom: false
|
|
33151
|
+
});
|
|
33152
|
+
for (let i = 1; i < COPPER_POUR_OPACITY_COMPENSATION_PASSES; i += 1) {
|
|
33153
|
+
drawer.drawElements(pours, {
|
|
33154
|
+
layers: [pcbRenderLayer],
|
|
33155
|
+
drawSoldermask: false,
|
|
33156
|
+
drawSoldermaskTop: false,
|
|
33157
|
+
drawSoldermaskBottom: false
|
|
33158
|
+
});
|
|
33159
|
+
}
|
|
33160
|
+
};
|
|
33161
|
+
const coveredPours = poursOnLayer.filter(
|
|
33162
|
+
(p) => p.covered_with_solder_mask !== false
|
|
33163
|
+
);
|
|
33164
|
+
const uncoveredPours = poursOnLayer.filter(
|
|
33165
|
+
(p) => p.covered_with_solder_mask === false
|
|
33166
|
+
);
|
|
33167
|
+
setColorAndDraw(coveredPours, coveredColor);
|
|
33168
|
+
setColorAndDraw(uncoveredPours, uncoveredColor);
|
|
33169
|
+
const texture = new THREE23.CanvasTexture(canvas);
|
|
33170
|
+
texture.generateMipmaps = true;
|
|
33171
|
+
texture.minFilter = THREE23.LinearMipmapLinearFilter;
|
|
33172
|
+
texture.magFilter = THREE23.LinearFilter;
|
|
33173
|
+
texture.anisotropy = 16;
|
|
33174
|
+
texture.needsUpdate = true;
|
|
33175
|
+
return texture;
|
|
33176
|
+
}
|
|
33177
|
+
|
|
33178
|
+
// src/textures/create-fabrication-note-texture-for-layer.ts
|
|
33179
|
+
import * as THREE24 from "three";
|
|
33063
33180
|
|
|
33064
33181
|
// src/textures/fabrication-note/fabrication-note-drawing.ts
|
|
33065
|
-
import { CircuitToCanvasDrawer as
|
|
33182
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer5 } from "circuit-to-canvas";
|
|
33066
33183
|
|
|
33067
33184
|
// src/utils/units.ts
|
|
33068
33185
|
var MM_PER_INCH = 25.4;
|
|
@@ -33160,7 +33277,7 @@ var drawFabricationNoteLayer = ({
|
|
|
33160
33277
|
}) => {
|
|
33161
33278
|
const renderLayer = `${layer}_fabrication_note`;
|
|
33162
33279
|
const normalizedElements = elements.map(normalizeFabricationElement);
|
|
33163
|
-
const drawer = new
|
|
33280
|
+
const drawer = new CircuitToCanvasDrawer5(ctx);
|
|
33164
33281
|
drawer.configure({
|
|
33165
33282
|
colorOverrides: {
|
|
33166
33283
|
copper: {
|
|
@@ -33286,20 +33403,20 @@ function createFabricationNoteTextureForLayer({
|
|
|
33286
33403
|
bounds,
|
|
33287
33404
|
elements
|
|
33288
33405
|
});
|
|
33289
|
-
const texture = new
|
|
33406
|
+
const texture = new THREE24.CanvasTexture(canvas);
|
|
33290
33407
|
texture.generateMipmaps = true;
|
|
33291
|
-
texture.minFilter =
|
|
33292
|
-
texture.magFilter =
|
|
33408
|
+
texture.minFilter = THREE24.LinearMipmapLinearFilter;
|
|
33409
|
+
texture.magFilter = THREE24.LinearFilter;
|
|
33293
33410
|
texture.anisotropy = 16;
|
|
33294
33411
|
texture.needsUpdate = true;
|
|
33295
33412
|
return texture;
|
|
33296
33413
|
}
|
|
33297
33414
|
|
|
33298
33415
|
// src/textures/create-pcb-note-texture-for-layer.ts
|
|
33299
|
-
import * as
|
|
33416
|
+
import * as THREE25 from "three";
|
|
33300
33417
|
|
|
33301
33418
|
// src/textures/pcb-note/pcb-note-drawing.ts
|
|
33302
|
-
import { CircuitToCanvasDrawer as
|
|
33419
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer6 } from "circuit-to-canvas";
|
|
33303
33420
|
var TRANSPARENT2 = "rgba(0,0,0,0)";
|
|
33304
33421
|
var setDrawerBounds3 = (drawer, bounds) => {
|
|
33305
33422
|
drawer.setCameraBounds({
|
|
@@ -33378,7 +33495,7 @@ var drawPcbNoteLayer = ({
|
|
|
33378
33495
|
elements
|
|
33379
33496
|
}) => {
|
|
33380
33497
|
const normalizedElements = elements.map(normalizePcbNoteElement);
|
|
33381
|
-
const drawer = new
|
|
33498
|
+
const drawer = new CircuitToCanvasDrawer6(ctx);
|
|
33382
33499
|
drawer.configure({
|
|
33383
33500
|
colorOverrides: {
|
|
33384
33501
|
copper: {
|
|
@@ -33447,20 +33564,20 @@ function createPcbNoteTextureForLayer({
|
|
|
33447
33564
|
bounds,
|
|
33448
33565
|
elements
|
|
33449
33566
|
});
|
|
33450
|
-
const texture = new
|
|
33567
|
+
const texture = new THREE25.CanvasTexture(canvas);
|
|
33451
33568
|
texture.generateMipmaps = true;
|
|
33452
|
-
texture.minFilter =
|
|
33453
|
-
texture.magFilter =
|
|
33569
|
+
texture.minFilter = THREE25.LinearMipmapLinearFilter;
|
|
33570
|
+
texture.magFilter = THREE25.LinearFilter;
|
|
33454
33571
|
texture.anisotropy = 16;
|
|
33455
33572
|
texture.needsUpdate = true;
|
|
33456
33573
|
return texture;
|
|
33457
33574
|
}
|
|
33458
33575
|
|
|
33459
33576
|
// src/textures/create-silkscreen-texture-for-layer.ts
|
|
33460
|
-
import * as
|
|
33577
|
+
import * as THREE26 from "three";
|
|
33461
33578
|
|
|
33462
33579
|
// src/textures/silkscreen/silkscreen-drawing.ts
|
|
33463
|
-
import { CircuitToCanvasDrawer as
|
|
33580
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer7 } from "circuit-to-canvas";
|
|
33464
33581
|
var FABRICATION_NOTE_COLOR2 = "rgb(255,243,204)";
|
|
33465
33582
|
var TRANSPARENT3 = "rgba(0,0,0,0)";
|
|
33466
33583
|
var setDrawerBounds4 = (drawer, bounds) => {
|
|
@@ -33479,7 +33596,7 @@ var drawSilkscreenLayer = ({
|
|
|
33479
33596
|
silkscreenColor
|
|
33480
33597
|
}) => {
|
|
33481
33598
|
const renderLayer = layer === "top" ? "top_silkscreen" : "bottom_silkscreen";
|
|
33482
|
-
const drawer = new
|
|
33599
|
+
const drawer = new CircuitToCanvasDrawer7(ctx);
|
|
33483
33600
|
drawer.configure({
|
|
33484
33601
|
colorOverrides: {
|
|
33485
33602
|
copper: {
|
|
@@ -33566,35 +33683,35 @@ function createSilkscreenTextureForLayer({
|
|
|
33566
33683
|
elements,
|
|
33567
33684
|
silkscreenColor
|
|
33568
33685
|
});
|
|
33569
|
-
const texture = new
|
|
33686
|
+
const texture = new THREE26.CanvasTexture(canvas);
|
|
33570
33687
|
texture.generateMipmaps = true;
|
|
33571
|
-
texture.minFilter =
|
|
33572
|
-
texture.magFilter =
|
|
33688
|
+
texture.minFilter = THREE26.LinearMipmapLinearFilter;
|
|
33689
|
+
texture.magFilter = THREE26.LinearFilter;
|
|
33573
33690
|
texture.anisotropy = 16;
|
|
33574
33691
|
texture.needsUpdate = true;
|
|
33575
33692
|
return texture;
|
|
33576
33693
|
}
|
|
33577
33694
|
|
|
33578
33695
|
// src/textures/create-soldermask-texture-for-layer.ts
|
|
33579
|
-
import * as
|
|
33696
|
+
import * as THREE27 from "three";
|
|
33580
33697
|
|
|
33581
33698
|
// src/textures/soldermask/soldermask-drawing.ts
|
|
33582
|
-
import { CircuitToCanvasDrawer as
|
|
33583
|
-
var
|
|
33699
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer8 } from "circuit-to-canvas";
|
|
33700
|
+
var toRgb2 = (colorArr) => {
|
|
33584
33701
|
const [r = 0, g = 0, b = 0] = colorArr;
|
|
33585
33702
|
return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
|
|
33586
33703
|
b * 255
|
|
33587
33704
|
)})`;
|
|
33588
33705
|
};
|
|
33589
33706
|
var getSoldermaskPalette = (material) => {
|
|
33590
|
-
const soldermask =
|
|
33707
|
+
const soldermask = toRgb2(
|
|
33591
33708
|
soldermaskColors[material] ?? colors.fr4SolderMaskGreen
|
|
33592
33709
|
);
|
|
33593
|
-
const soldermaskOverCopper = material === "fr1" ?
|
|
33710
|
+
const soldermaskOverCopper = material === "fr1" ? toRgb2(colors.fr1TracesWithMaskCopper) : toRgb2(colors.fr4TracesWithMaskGreen);
|
|
33594
33711
|
return {
|
|
33595
33712
|
soldermask,
|
|
33596
33713
|
soldermaskOverCopper,
|
|
33597
|
-
copper:
|
|
33714
|
+
copper: toRgb2(colors.copper),
|
|
33598
33715
|
transparent: "rgba(0,0,0,0)"
|
|
33599
33716
|
};
|
|
33600
33717
|
};
|
|
@@ -33615,7 +33732,7 @@ var drawSoldermaskLayer = ({
|
|
|
33615
33732
|
}) => {
|
|
33616
33733
|
const palette = getSoldermaskPalette(boardMaterial);
|
|
33617
33734
|
const copperRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
33618
|
-
const drawer = new
|
|
33735
|
+
const drawer = new CircuitToCanvasDrawer8(ctx);
|
|
33619
33736
|
drawer.configure({
|
|
33620
33737
|
colorOverrides: {
|
|
33621
33738
|
copper: {
|
|
@@ -33659,7 +33776,7 @@ var drawSoldermaskLayer = ({
|
|
|
33659
33776
|
if (uncoveredPours.length > 0) {
|
|
33660
33777
|
ctx.save();
|
|
33661
33778
|
ctx.globalCompositeOperation = "destination-out";
|
|
33662
|
-
const cutoutDrawer = new
|
|
33779
|
+
const cutoutDrawer = new CircuitToCanvasDrawer8(ctx);
|
|
33663
33780
|
cutoutDrawer.configure({
|
|
33664
33781
|
colorOverrides: {
|
|
33665
33782
|
copper: {
|
|
@@ -33708,20 +33825,20 @@ function createSoldermaskTextureForLayer({
|
|
|
33708
33825
|
elements,
|
|
33709
33826
|
boardMaterial: boardData.material
|
|
33710
33827
|
});
|
|
33711
|
-
const texture = new
|
|
33828
|
+
const texture = new THREE27.CanvasTexture(canvas);
|
|
33712
33829
|
texture.generateMipmaps = true;
|
|
33713
|
-
texture.minFilter =
|
|
33714
|
-
texture.magFilter =
|
|
33830
|
+
texture.minFilter = THREE27.LinearMipmapLinearFilter;
|
|
33831
|
+
texture.magFilter = THREE27.LinearFilter;
|
|
33715
33832
|
texture.anisotropy = 16;
|
|
33716
33833
|
texture.needsUpdate = true;
|
|
33717
33834
|
return texture;
|
|
33718
33835
|
}
|
|
33719
33836
|
|
|
33720
33837
|
// src/textures/create-through-hole-texture-for-layer.ts
|
|
33721
|
-
import * as
|
|
33838
|
+
import * as THREE28 from "three";
|
|
33722
33839
|
|
|
33723
33840
|
// src/textures/through-hole/through-hole-drawing.ts
|
|
33724
|
-
import { CircuitToCanvasDrawer as
|
|
33841
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer9 } from "circuit-to-canvas";
|
|
33725
33842
|
var setDrawerBounds6 = (drawer, bounds) => {
|
|
33726
33843
|
drawer.setCameraBounds({
|
|
33727
33844
|
minX: bounds.minX,
|
|
@@ -33739,7 +33856,7 @@ var drawThroughHoleLayer = ({
|
|
|
33739
33856
|
}) => {
|
|
33740
33857
|
const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
33741
33858
|
const transparent = "rgba(0,0,0,0)";
|
|
33742
|
-
const drawer = new
|
|
33859
|
+
const drawer = new CircuitToCanvasDrawer9(ctx);
|
|
33743
33860
|
drawer.configure({
|
|
33744
33861
|
colorOverrides: {
|
|
33745
33862
|
copper: {
|
|
@@ -33811,17 +33928,17 @@ function createThroughHoleTextureForLayer({
|
|
|
33811
33928
|
elements,
|
|
33812
33929
|
copperColor
|
|
33813
33930
|
});
|
|
33814
|
-
const texture = new
|
|
33931
|
+
const texture = new THREE28.CanvasTexture(canvas);
|
|
33815
33932
|
texture.generateMipmaps = true;
|
|
33816
|
-
texture.minFilter =
|
|
33817
|
-
texture.magFilter =
|
|
33933
|
+
texture.minFilter = THREE28.LinearMipmapLinearFilter;
|
|
33934
|
+
texture.magFilter = THREE28.LinearFilter;
|
|
33818
33935
|
texture.anisotropy = 16;
|
|
33819
33936
|
texture.needsUpdate = true;
|
|
33820
33937
|
return texture;
|
|
33821
33938
|
}
|
|
33822
33939
|
|
|
33823
33940
|
// src/textures/create-combined-board-textures.ts
|
|
33824
|
-
var
|
|
33941
|
+
var toRgb3 = (colorArr) => {
|
|
33825
33942
|
const [r = 0, g = 0, b = 0] = colorArr;
|
|
33826
33943
|
return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
|
|
33827
33944
|
b * 255
|
|
@@ -33852,10 +33969,10 @@ var createCombinedTexture = ({
|
|
|
33852
33969
|
const image = texture.image;
|
|
33853
33970
|
ctx.drawImage(image, 0, 0, canvasWidth, canvasHeight);
|
|
33854
33971
|
});
|
|
33855
|
-
const combinedTexture = new
|
|
33972
|
+
const combinedTexture = new THREE29.CanvasTexture(canvas);
|
|
33856
33973
|
combinedTexture.generateMipmaps = false;
|
|
33857
|
-
combinedTexture.minFilter =
|
|
33858
|
-
combinedTexture.magFilter =
|
|
33974
|
+
combinedTexture.minFilter = THREE29.LinearFilter;
|
|
33975
|
+
combinedTexture.magFilter = THREE29.LinearFilter;
|
|
33859
33976
|
combinedTexture.premultiplyAlpha = true;
|
|
33860
33977
|
combinedTexture.anisotropy = 16;
|
|
33861
33978
|
combinedTexture.needsUpdate = true;
|
|
@@ -33867,9 +33984,9 @@ function createCombinedBoardTextures({
|
|
|
33867
33984
|
traceTextureResolution,
|
|
33868
33985
|
visibility
|
|
33869
33986
|
}) {
|
|
33870
|
-
const traceColor =
|
|
33987
|
+
const traceColor = toRgb3(colors.copper);
|
|
33871
33988
|
const silkscreenColor = "rgb(255,255,255)";
|
|
33872
|
-
const copperColor =
|
|
33989
|
+
const copperColor = toRgb3(colors.copper);
|
|
33873
33990
|
const showBoardBody = visibility?.boardBody ?? true;
|
|
33874
33991
|
const buildForLayer = (layer) => {
|
|
33875
33992
|
const showMask = (layer === "top" ? visibility?.topMask : visibility?.bottomMask) ?? true;
|
|
@@ -33888,6 +34005,13 @@ function createCombinedBoardTextures({
|
|
|
33888
34005
|
traceColor,
|
|
33889
34006
|
traceTextureResolution
|
|
33890
34007
|
}) : null;
|
|
34008
|
+
const copperPourTexture = showCopper ? createCopperPourTextureForLayer({
|
|
34009
|
+
layer,
|
|
34010
|
+
circuitJson,
|
|
34011
|
+
boardData,
|
|
34012
|
+
traceTextureResolution,
|
|
34013
|
+
copperColor
|
|
34014
|
+
}) : null;
|
|
33891
34015
|
const copperTextTexture = showCopper ? createCopperTextTextureForLayer({
|
|
33892
34016
|
layer,
|
|
33893
34017
|
circuitJson,
|
|
@@ -33937,6 +34061,7 @@ function createCombinedBoardTextures({
|
|
|
33937
34061
|
}) : null;
|
|
33938
34062
|
return createCombinedTexture({
|
|
33939
34063
|
textures: [
|
|
34064
|
+
copperPourTexture,
|
|
33940
34065
|
traceTexture,
|
|
33941
34066
|
padTexture,
|
|
33942
34067
|
throughHoleTexture,
|
|
@@ -33958,14 +34083,6 @@ function createCombinedBoardTextures({
|
|
|
33958
34083
|
};
|
|
33959
34084
|
}
|
|
33960
34085
|
|
|
33961
|
-
// src/textures/create-copper-pour-texture-for-layer.ts
|
|
33962
|
-
import * as THREE29 from "three";
|
|
33963
|
-
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer9 } from "circuit-to-canvas";
|
|
33964
|
-
|
|
33965
|
-
// src/geoms/brep-converter.ts
|
|
33966
|
-
var import_primitives7 = __toESM(require_primitives(), 1);
|
|
33967
|
-
var import_booleans5 = __toESM(require_booleans(), 1);
|
|
33968
|
-
|
|
33969
34086
|
// src/textures/create-three-texture-meshes.ts
|
|
33970
34087
|
import * as THREE30 from "three";
|
|
33971
34088
|
function createTexturePlane(config, boardData) {
|
|
@@ -41652,12 +41769,12 @@ function getNextMatch(values, search, currentMatch) {
|
|
|
41652
41769
|
);
|
|
41653
41770
|
return nextMatch !== currentMatch ? nextMatch : void 0;
|
|
41654
41771
|
}
|
|
41655
|
-
function isPointInPolygon(point,
|
|
41772
|
+
function isPointInPolygon(point, polygon2) {
|
|
41656
41773
|
const { x, y } = point;
|
|
41657
41774
|
let inside = false;
|
|
41658
|
-
for (let i = 0, j =
|
|
41659
|
-
const ii =
|
|
41660
|
-
const jj =
|
|
41775
|
+
for (let i = 0, j = polygon2.length - 1; i < polygon2.length; j = i++) {
|
|
41776
|
+
const ii = polygon2[i];
|
|
41777
|
+
const jj = polygon2[j];
|
|
41661
41778
|
const xi = ii.x;
|
|
41662
41779
|
const yi = ii.y;
|
|
41663
41780
|
const xj = jj.x;
|
|
@@ -43124,17 +43241,17 @@ function createGeometryFromPolygons(polygons) {
|
|
|
43124
43241
|
const geometry = new BufferGeometry4();
|
|
43125
43242
|
const vertices = [];
|
|
43126
43243
|
const normals = [];
|
|
43127
|
-
for (const
|
|
43128
|
-
for (let i = 1; i <
|
|
43244
|
+
for (const polygon2 of polygons) {
|
|
43245
|
+
for (let i = 1; i < polygon2.vertices.length - 1; i++) {
|
|
43129
43246
|
vertices.push(
|
|
43130
|
-
...
|
|
43131
|
-
...
|
|
43132
|
-
...
|
|
43247
|
+
...polygon2.vertices[0],
|
|
43248
|
+
...polygon2.vertices[i],
|
|
43249
|
+
...polygon2.vertices[i + 1]
|
|
43133
43250
|
// Third vertex
|
|
43134
43251
|
);
|
|
43135
|
-
const v1 = new THREE40.Vector3(...
|
|
43136
|
-
const v2 = new THREE40.Vector3(...
|
|
43137
|
-
const v3 = new THREE40.Vector3(...
|
|
43252
|
+
const v1 = new THREE40.Vector3(...polygon2.vertices[0]);
|
|
43253
|
+
const v2 = new THREE40.Vector3(...polygon2.vertices[i]);
|
|
43254
|
+
const v3 = new THREE40.Vector3(...polygon2.vertices[i + 1]);
|
|
43138
43255
|
const normal = new THREE40.Vector3().crossVectors(
|
|
43139
43256
|
new THREE40.Vector3().subVectors(v2, v1),
|
|
43140
43257
|
new THREE40.Vector3().subVectors(v3, v1)
|