@tscircuit/3d-viewer 0.0.521 → 0.0.522
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 +316 -657
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -243,9 +243,9 @@ var require_trigonometry = __commonJS({
|
|
|
243
243
|
"use strict";
|
|
244
244
|
var { NEPS } = require_constants();
|
|
245
245
|
var rezero = (n) => Math.abs(n) < NEPS ? 0 : n;
|
|
246
|
-
var
|
|
247
|
-
var
|
|
248
|
-
module.exports = { sin
|
|
246
|
+
var sin = (radians) => rezero(Math.sin(radians));
|
|
247
|
+
var cos = (radians) => rezero(Math.cos(radians));
|
|
248
|
+
module.exports = { sin, cos };
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
251
|
|
|
@@ -281,7 +281,7 @@ var require_fromRotation = __commonJS({
|
|
|
281
281
|
"node_modules/@jscad/modeling/src/maths/mat4/fromRotation.js"(exports, module) {
|
|
282
282
|
"use strict";
|
|
283
283
|
var { EPS } = require_constants();
|
|
284
|
-
var { sin
|
|
284
|
+
var { sin, cos } = require_trigonometry();
|
|
285
285
|
var identity = require_identity();
|
|
286
286
|
var fromRotation = (out, rad, axis) => {
|
|
287
287
|
let [x, y, z18] = axis;
|
|
@@ -293,8 +293,8 @@ var require_fromRotation = __commonJS({
|
|
|
293
293
|
x *= len;
|
|
294
294
|
y *= len;
|
|
295
295
|
z18 *= len;
|
|
296
|
-
const s =
|
|
297
|
-
const c =
|
|
296
|
+
const s = sin(rad);
|
|
297
|
+
const c = cos(rad);
|
|
298
298
|
const t = 1 - c;
|
|
299
299
|
out[0] = x * x * t + c;
|
|
300
300
|
out[1] = y * x * t + z18 * s;
|
|
@@ -349,14 +349,14 @@ var require_fromScaling = __commonJS({
|
|
|
349
349
|
var require_fromTaitBryanRotation = __commonJS({
|
|
350
350
|
"node_modules/@jscad/modeling/src/maths/mat4/fromTaitBryanRotation.js"(exports, module) {
|
|
351
351
|
"use strict";
|
|
352
|
-
var { sin
|
|
352
|
+
var { sin, cos } = require_trigonometry();
|
|
353
353
|
var fromTaitBryanRotation = (out, yaw, pitch, roll) => {
|
|
354
|
-
const sy =
|
|
355
|
-
const cy =
|
|
356
|
-
const sp =
|
|
357
|
-
const cp =
|
|
358
|
-
const sr =
|
|
359
|
-
const cr =
|
|
354
|
+
const sy = sin(yaw);
|
|
355
|
+
const cy = cos(yaw);
|
|
356
|
+
const sp = sin(pitch);
|
|
357
|
+
const cp = cos(pitch);
|
|
358
|
+
const sr = sin(roll);
|
|
359
|
+
const cr = cos(roll);
|
|
360
360
|
out[0] = cp * cy;
|
|
361
361
|
out[1] = cp * sy;
|
|
362
362
|
out[2] = -sp;
|
|
@@ -825,13 +825,13 @@ var require_rotateZ = __commonJS({
|
|
|
825
825
|
var require_scale = __commonJS({
|
|
826
826
|
"node_modules/@jscad/modeling/src/maths/vec3/scale.js"(exports, module) {
|
|
827
827
|
"use strict";
|
|
828
|
-
var
|
|
828
|
+
var scale2 = (out, vector, amount) => {
|
|
829
829
|
out[0] = vector[0] * amount;
|
|
830
830
|
out[1] = vector[1] * amount;
|
|
831
831
|
out[2] = vector[2] * amount;
|
|
832
832
|
return out;
|
|
833
833
|
};
|
|
834
|
-
module.exports =
|
|
834
|
+
module.exports = scale2;
|
|
835
835
|
}
|
|
836
836
|
});
|
|
837
837
|
|
|
@@ -904,7 +904,7 @@ var require_toString = __commonJS({
|
|
|
904
904
|
var require_transform = __commonJS({
|
|
905
905
|
"node_modules/@jscad/modeling/src/maths/vec3/transform.js"(exports, module) {
|
|
906
906
|
"use strict";
|
|
907
|
-
var
|
|
907
|
+
var transform = (out, vector, matrix) => {
|
|
908
908
|
const x = vector[0];
|
|
909
909
|
const y = vector[1];
|
|
910
910
|
const z18 = vector[2];
|
|
@@ -915,7 +915,7 @@ var require_transform = __commonJS({
|
|
|
915
915
|
out[2] = (matrix[2] * x + matrix[6] * y + matrix[10] * z18 + matrix[14]) / w;
|
|
916
916
|
return out;
|
|
917
917
|
};
|
|
918
|
-
module.exports =
|
|
918
|
+
module.exports = transform;
|
|
919
919
|
}
|
|
920
920
|
});
|
|
921
921
|
|
|
@@ -999,10 +999,10 @@ var require_fromVectorRotation = __commonJS({
|
|
|
999
999
|
var require_fromXRotation = __commonJS({
|
|
1000
1000
|
"node_modules/@jscad/modeling/src/maths/mat4/fromXRotation.js"(exports, module) {
|
|
1001
1001
|
"use strict";
|
|
1002
|
-
var { sin
|
|
1002
|
+
var { sin, cos } = require_trigonometry();
|
|
1003
1003
|
var fromXRotation = (out, radians) => {
|
|
1004
|
-
const s =
|
|
1005
|
-
const c =
|
|
1004
|
+
const s = sin(radians);
|
|
1005
|
+
const c = cos(radians);
|
|
1006
1006
|
out[0] = 1;
|
|
1007
1007
|
out[1] = 0;
|
|
1008
1008
|
out[2] = 0;
|
|
@@ -1029,10 +1029,10 @@ var require_fromXRotation = __commonJS({
|
|
|
1029
1029
|
var require_fromYRotation = __commonJS({
|
|
1030
1030
|
"node_modules/@jscad/modeling/src/maths/mat4/fromYRotation.js"(exports, module) {
|
|
1031
1031
|
"use strict";
|
|
1032
|
-
var { sin
|
|
1032
|
+
var { sin, cos } = require_trigonometry();
|
|
1033
1033
|
var fromYRotation = (out, radians) => {
|
|
1034
|
-
const s =
|
|
1035
|
-
const c =
|
|
1034
|
+
const s = sin(radians);
|
|
1035
|
+
const c = cos(radians);
|
|
1036
1036
|
out[0] = c;
|
|
1037
1037
|
out[1] = 0;
|
|
1038
1038
|
out[2] = -s;
|
|
@@ -1059,10 +1059,10 @@ var require_fromYRotation = __commonJS({
|
|
|
1059
1059
|
var require_fromZRotation = __commonJS({
|
|
1060
1060
|
"node_modules/@jscad/modeling/src/maths/mat4/fromZRotation.js"(exports, module) {
|
|
1061
1061
|
"use strict";
|
|
1062
|
-
var { sin
|
|
1062
|
+
var { sin, cos } = require_trigonometry();
|
|
1063
1063
|
var fromZRotation = (out, radians) => {
|
|
1064
|
-
const s =
|
|
1065
|
-
const c =
|
|
1064
|
+
const s = sin(radians);
|
|
1065
|
+
const c = cos(radians);
|
|
1066
1066
|
out[0] = c;
|
|
1067
1067
|
out[1] = s;
|
|
1068
1068
|
out[2] = 0;
|
|
@@ -1214,9 +1214,9 @@ var require_rotate = __commonJS({
|
|
|
1214
1214
|
"node_modules/@jscad/modeling/src/maths/mat4/rotate.js"(exports, module) {
|
|
1215
1215
|
"use strict";
|
|
1216
1216
|
var { EPS } = require_constants();
|
|
1217
|
-
var { sin
|
|
1217
|
+
var { sin, cos } = require_trigonometry();
|
|
1218
1218
|
var copy = require_copy();
|
|
1219
|
-
var
|
|
1219
|
+
var rotate2 = (out, matrix, radians, axis) => {
|
|
1220
1220
|
let [x, y, z18] = axis;
|
|
1221
1221
|
const lengthSquared = x * x + y * y + z18 * z18;
|
|
1222
1222
|
if (Math.abs(lengthSquared) < EPS) {
|
|
@@ -1226,8 +1226,8 @@ var require_rotate = __commonJS({
|
|
|
1226
1226
|
x *= len;
|
|
1227
1227
|
y *= len;
|
|
1228
1228
|
z18 *= len;
|
|
1229
|
-
const s =
|
|
1230
|
-
const c =
|
|
1229
|
+
const s = sin(radians);
|
|
1230
|
+
const c = cos(radians);
|
|
1231
1231
|
const t = 1 - c;
|
|
1232
1232
|
const a00 = matrix[0];
|
|
1233
1233
|
const a01 = matrix[1];
|
|
@@ -1270,7 +1270,7 @@ var require_rotate = __commonJS({
|
|
|
1270
1270
|
}
|
|
1271
1271
|
return out;
|
|
1272
1272
|
};
|
|
1273
|
-
module.exports =
|
|
1273
|
+
module.exports = rotate2;
|
|
1274
1274
|
}
|
|
1275
1275
|
});
|
|
1276
1276
|
|
|
@@ -1278,10 +1278,10 @@ var require_rotate = __commonJS({
|
|
|
1278
1278
|
var require_rotateX2 = __commonJS({
|
|
1279
1279
|
"node_modules/@jscad/modeling/src/maths/mat4/rotateX.js"(exports, module) {
|
|
1280
1280
|
"use strict";
|
|
1281
|
-
var { sin
|
|
1281
|
+
var { sin, cos } = require_trigonometry();
|
|
1282
1282
|
var rotateX = (out, matrix, radians) => {
|
|
1283
|
-
const s =
|
|
1284
|
-
const c =
|
|
1283
|
+
const s = sin(radians);
|
|
1284
|
+
const c = cos(radians);
|
|
1285
1285
|
const a10 = matrix[4];
|
|
1286
1286
|
const a11 = matrix[5];
|
|
1287
1287
|
const a12 = matrix[6];
|
|
@@ -1318,10 +1318,10 @@ var require_rotateX2 = __commonJS({
|
|
|
1318
1318
|
var require_rotateY2 = __commonJS({
|
|
1319
1319
|
"node_modules/@jscad/modeling/src/maths/mat4/rotateY.js"(exports, module) {
|
|
1320
1320
|
"use strict";
|
|
1321
|
-
var { sin
|
|
1321
|
+
var { sin, cos } = require_trigonometry();
|
|
1322
1322
|
var rotateY = (out, matrix, radians) => {
|
|
1323
|
-
const s =
|
|
1324
|
-
const c =
|
|
1323
|
+
const s = sin(radians);
|
|
1324
|
+
const c = cos(radians);
|
|
1325
1325
|
const a00 = matrix[0];
|
|
1326
1326
|
const a01 = matrix[1];
|
|
1327
1327
|
const a02 = matrix[2];
|
|
@@ -1358,10 +1358,10 @@ var require_rotateY2 = __commonJS({
|
|
|
1358
1358
|
var require_rotateZ2 = __commonJS({
|
|
1359
1359
|
"node_modules/@jscad/modeling/src/maths/mat4/rotateZ.js"(exports, module) {
|
|
1360
1360
|
"use strict";
|
|
1361
|
-
var { sin
|
|
1361
|
+
var { sin, cos } = require_trigonometry();
|
|
1362
1362
|
var rotateZ3 = (out, matrix, radians) => {
|
|
1363
|
-
const s =
|
|
1364
|
-
const c =
|
|
1363
|
+
const s = sin(radians);
|
|
1364
|
+
const c = cos(radians);
|
|
1365
1365
|
const a00 = matrix[0];
|
|
1366
1366
|
const a01 = matrix[1];
|
|
1367
1367
|
const a02 = matrix[2];
|
|
@@ -1398,7 +1398,7 @@ var require_rotateZ2 = __commonJS({
|
|
|
1398
1398
|
var require_scale2 = __commonJS({
|
|
1399
1399
|
"node_modules/@jscad/modeling/src/maths/mat4/scale.js"(exports, module) {
|
|
1400
1400
|
"use strict";
|
|
1401
|
-
var
|
|
1401
|
+
var scale2 = (out, matrix, dimensions) => {
|
|
1402
1402
|
const x = dimensions[0];
|
|
1403
1403
|
const y = dimensions[1];
|
|
1404
1404
|
const z18 = dimensions[2];
|
|
@@ -1420,7 +1420,7 @@ var require_scale2 = __commonJS({
|
|
|
1420
1420
|
out[15] = matrix[15];
|
|
1421
1421
|
return out;
|
|
1422
1422
|
};
|
|
1423
|
-
module.exports =
|
|
1423
|
+
module.exports = scale2;
|
|
1424
1424
|
}
|
|
1425
1425
|
});
|
|
1426
1426
|
|
|
@@ -1464,7 +1464,7 @@ var require_toString2 = __commonJS({
|
|
|
1464
1464
|
var require_translate = __commonJS({
|
|
1465
1465
|
"node_modules/@jscad/modeling/src/maths/mat4/translate.js"(exports, module) {
|
|
1466
1466
|
"use strict";
|
|
1467
|
-
var
|
|
1467
|
+
var translate6 = (out, matrix, offsets) => {
|
|
1468
1468
|
const x = offsets[0];
|
|
1469
1469
|
const y = offsets[1];
|
|
1470
1470
|
const z18 = offsets[2];
|
|
@@ -1517,7 +1517,7 @@ var require_translate = __commonJS({
|
|
|
1517
1517
|
}
|
|
1518
1518
|
return out;
|
|
1519
1519
|
};
|
|
1520
|
-
module.exports =
|
|
1520
|
+
module.exports = translate6;
|
|
1521
1521
|
}
|
|
1522
1522
|
});
|
|
1523
1523
|
|
|
@@ -1729,10 +1729,10 @@ var require_equals3 = __commonJS({
|
|
|
1729
1729
|
var require_fromAngleRadians = __commonJS({
|
|
1730
1730
|
"node_modules/@jscad/modeling/src/maths/vec2/fromAngleRadians.js"(exports, module) {
|
|
1731
1731
|
"use strict";
|
|
1732
|
-
var { sin
|
|
1732
|
+
var { sin, cos } = require_trigonometry();
|
|
1733
1733
|
var fromAngleRadians = (out, radians) => {
|
|
1734
|
-
out[0] =
|
|
1735
|
-
out[1] =
|
|
1734
|
+
out[0] = cos(radians);
|
|
1735
|
+
out[1] = sin(radians);
|
|
1736
1736
|
return out;
|
|
1737
1737
|
};
|
|
1738
1738
|
module.exports = fromAngleRadians;
|
|
@@ -1857,7 +1857,7 @@ var require_negate2 = __commonJS({
|
|
|
1857
1857
|
var require_rotate2 = __commonJS({
|
|
1858
1858
|
"node_modules/@jscad/modeling/src/maths/vec2/rotate.js"(exports, module) {
|
|
1859
1859
|
"use strict";
|
|
1860
|
-
var
|
|
1860
|
+
var rotate2 = (out, vector, origin, radians) => {
|
|
1861
1861
|
const x = vector[0] - origin[0];
|
|
1862
1862
|
const y = vector[1] - origin[1];
|
|
1863
1863
|
const c = Math.cos(radians);
|
|
@@ -1866,7 +1866,7 @@ var require_rotate2 = __commonJS({
|
|
|
1866
1866
|
out[1] = x * s + y * c + origin[1];
|
|
1867
1867
|
return out;
|
|
1868
1868
|
};
|
|
1869
|
-
module.exports =
|
|
1869
|
+
module.exports = rotate2;
|
|
1870
1870
|
}
|
|
1871
1871
|
});
|
|
1872
1872
|
|
|
@@ -1876,8 +1876,8 @@ var require_normal = __commonJS({
|
|
|
1876
1876
|
"use strict";
|
|
1877
1877
|
var { TAU } = require_constants();
|
|
1878
1878
|
var create = require_create4();
|
|
1879
|
-
var
|
|
1880
|
-
var normal = (out, vector) =>
|
|
1879
|
+
var rotate2 = require_rotate2();
|
|
1880
|
+
var normal = (out, vector) => rotate2(out, vector, create(), TAU / 4);
|
|
1881
1881
|
module.exports = normal;
|
|
1882
1882
|
}
|
|
1883
1883
|
});
|
|
@@ -1905,12 +1905,12 @@ var require_normalize2 = __commonJS({
|
|
|
1905
1905
|
var require_scale3 = __commonJS({
|
|
1906
1906
|
"node_modules/@jscad/modeling/src/maths/vec2/scale.js"(exports, module) {
|
|
1907
1907
|
"use strict";
|
|
1908
|
-
var
|
|
1908
|
+
var scale2 = (out, vector, amount) => {
|
|
1909
1909
|
out[0] = vector[0] * amount;
|
|
1910
1910
|
out[1] = vector[1] * amount;
|
|
1911
1911
|
return out;
|
|
1912
1912
|
};
|
|
1913
|
-
module.exports =
|
|
1913
|
+
module.exports = scale2;
|
|
1914
1914
|
}
|
|
1915
1915
|
});
|
|
1916
1916
|
|
|
@@ -1979,14 +1979,14 @@ var require_toString3 = __commonJS({
|
|
|
1979
1979
|
var require_transform2 = __commonJS({
|
|
1980
1980
|
"node_modules/@jscad/modeling/src/maths/vec2/transform.js"(exports, module) {
|
|
1981
1981
|
"use strict";
|
|
1982
|
-
var
|
|
1982
|
+
var transform = (out, vector, matrix) => {
|
|
1983
1983
|
const x = vector[0];
|
|
1984
1984
|
const y = vector[1];
|
|
1985
1985
|
out[0] = matrix[0] * x + matrix[4] * y + matrix[12];
|
|
1986
1986
|
out[1] = matrix[1] * x + matrix[5] * y + matrix[13];
|
|
1987
1987
|
return out;
|
|
1988
1988
|
};
|
|
1989
|
-
module.exports =
|
|
1989
|
+
module.exports = transform;
|
|
1990
1990
|
}
|
|
1991
1991
|
});
|
|
1992
1992
|
|
|
@@ -2332,7 +2332,7 @@ var require_transform3 = __commonJS({
|
|
|
2332
2332
|
"use strict";
|
|
2333
2333
|
var mat4 = require_mat4();
|
|
2334
2334
|
var reverse = require_reverse();
|
|
2335
|
-
var
|
|
2335
|
+
var transform = (matrix, geometry) => {
|
|
2336
2336
|
const transforms = mat4.multiply(mat4.create(), matrix, geometry.transforms);
|
|
2337
2337
|
const transformed = Object.assign({}, geometry, { transforms });
|
|
2338
2338
|
if (matrix[0] * matrix[5] - matrix[4] * matrix[1] < 0) {
|
|
@@ -2340,7 +2340,7 @@ var require_transform3 = __commonJS({
|
|
|
2340
2340
|
}
|
|
2341
2341
|
return transformed;
|
|
2342
2342
|
};
|
|
2343
|
-
module.exports =
|
|
2343
|
+
module.exports = transform;
|
|
2344
2344
|
}
|
|
2345
2345
|
});
|
|
2346
2346
|
|
|
@@ -2666,7 +2666,7 @@ var require_Face = __commonJS({
|
|
|
2666
2666
|
var dot = require_dot();
|
|
2667
2667
|
var length51 = require_length();
|
|
2668
2668
|
var normalize = require_normalize();
|
|
2669
|
-
var
|
|
2669
|
+
var scale2 = require_scale();
|
|
2670
2670
|
var subtract5 = require_subtract();
|
|
2671
2671
|
var HalfEdge = require_HalfEdge();
|
|
2672
2672
|
var VISIBLE = 0;
|
|
@@ -2714,7 +2714,7 @@ var require_Face = __commonJS({
|
|
|
2714
2714
|
this.nVertices += 1;
|
|
2715
2715
|
}
|
|
2716
2716
|
this.area = length51(this.normal);
|
|
2717
|
-
this.normal =
|
|
2717
|
+
this.normal = scale2(this.normal, this.normal, 1 / this.area);
|
|
2718
2718
|
}
|
|
2719
2719
|
computeNormalMinArea(minArea) {
|
|
2720
2720
|
this.computeNormal();
|
|
@@ -2734,9 +2734,9 @@ var require_Face = __commonJS({
|
|
|
2734
2734
|
const p2 = maxEdge.head().point;
|
|
2735
2735
|
const maxVector = subtract5([], p2, p1);
|
|
2736
2736
|
const maxLength = Math.sqrt(maxSquaredLength);
|
|
2737
|
-
|
|
2737
|
+
scale2(maxVector, maxVector, 1 / maxLength);
|
|
2738
2738
|
const maxProjection = dot(this.normal, maxVector);
|
|
2739
|
-
|
|
2739
|
+
scale2(maxVector, maxVector, -maxProjection);
|
|
2740
2740
|
add(this.normal, this.normal, maxVector);
|
|
2741
2741
|
normalize(this.normal, this.normal);
|
|
2742
2742
|
}
|
|
@@ -2748,7 +2748,7 @@ var require_Face = __commonJS({
|
|
|
2748
2748
|
add(this.centroid, this.centroid, edge.head().point);
|
|
2749
2749
|
edge = edge.next;
|
|
2750
2750
|
} while (edge !== this.edge);
|
|
2751
|
-
|
|
2751
|
+
scale2(this.centroid, this.centroid, 1 / this.nVertices);
|
|
2752
2752
|
}
|
|
2753
2753
|
computeNormalAndCentroid(minArea) {
|
|
2754
2754
|
if (typeof minArea !== "undefined") {
|
|
@@ -3779,7 +3779,7 @@ var require_transform4 = __commonJS({
|
|
|
3779
3779
|
var vec3 = require_vec3();
|
|
3780
3780
|
var fromPoints = require_fromPoints3();
|
|
3781
3781
|
var flip4 = require_flip();
|
|
3782
|
-
var
|
|
3782
|
+
var transform = (out, plane, matrix) => {
|
|
3783
3783
|
const ismirror = mat4.isMirroring(matrix);
|
|
3784
3784
|
const r = vec3.orthogonal(vec3.create(), plane);
|
|
3785
3785
|
const u = vec3.cross(r, plane, r);
|
|
@@ -3797,7 +3797,7 @@ var require_transform4 = __commonJS({
|
|
|
3797
3797
|
}
|
|
3798
3798
|
return out;
|
|
3799
3799
|
};
|
|
3800
|
-
module.exports =
|
|
3800
|
+
module.exports = transform;
|
|
3801
3801
|
}
|
|
3802
3802
|
});
|
|
3803
3803
|
|
|
@@ -4049,7 +4049,7 @@ var require_fromScalar3 = __commonJS({
|
|
|
4049
4049
|
var require_transform5 = __commonJS({
|
|
4050
4050
|
"node_modules/@jscad/modeling/src/maths/vec4/transform.js"(exports, module) {
|
|
4051
4051
|
"use strict";
|
|
4052
|
-
var
|
|
4052
|
+
var transform = (out, vector, matrix) => {
|
|
4053
4053
|
const [x, y, z18, w] = vector;
|
|
4054
4054
|
out[0] = matrix[0] * x + matrix[4] * y + matrix[8] * z18 + matrix[12] * w;
|
|
4055
4055
|
out[1] = matrix[1] * x + matrix[5] * y + matrix[9] * z18 + matrix[13] * w;
|
|
@@ -4057,7 +4057,7 @@ var require_transform5 = __commonJS({
|
|
|
4057
4057
|
out[3] = matrix[3] * x + matrix[7] * y + matrix[11] * z18 + matrix[15] * w;
|
|
4058
4058
|
return out;
|
|
4059
4059
|
};
|
|
4060
|
-
module.exports =
|
|
4060
|
+
module.exports = transform;
|
|
4061
4061
|
}
|
|
4062
4062
|
});
|
|
4063
4063
|
|
|
@@ -4178,14 +4178,14 @@ var require_transform6 = __commonJS({
|
|
|
4178
4178
|
var mat4 = require_mat4();
|
|
4179
4179
|
var vec3 = require_vec3();
|
|
4180
4180
|
var create = require_create6();
|
|
4181
|
-
var
|
|
4181
|
+
var transform = (matrix, polygon3) => {
|
|
4182
4182
|
const vertices = polygon3.vertices.map((vertex) => vec3.transform(vec3.create(), vertex, matrix));
|
|
4183
4183
|
if (mat4.isMirroring(matrix)) {
|
|
4184
4184
|
vertices.reverse();
|
|
4185
4185
|
}
|
|
4186
4186
|
return create(vertices);
|
|
4187
4187
|
};
|
|
4188
|
-
module.exports =
|
|
4188
|
+
module.exports = transform;
|
|
4189
4189
|
}
|
|
4190
4190
|
});
|
|
4191
4191
|
|
|
@@ -4492,11 +4492,11 @@ var require_transform7 = __commonJS({
|
|
|
4492
4492
|
"node_modules/@jscad/modeling/src/geometries/geom3/transform.js"(exports, module) {
|
|
4493
4493
|
"use strict";
|
|
4494
4494
|
var mat4 = require_mat4();
|
|
4495
|
-
var
|
|
4495
|
+
var transform = (matrix, geometry) => {
|
|
4496
4496
|
const transforms = mat4.multiply(mat4.create(), matrix, geometry.transforms);
|
|
4497
4497
|
return Object.assign({}, geometry, { transforms });
|
|
4498
4498
|
};
|
|
4499
|
-
module.exports =
|
|
4499
|
+
module.exports = transform;
|
|
4500
4500
|
}
|
|
4501
4501
|
});
|
|
4502
4502
|
|
|
@@ -5085,11 +5085,11 @@ var require_transform8 = __commonJS({
|
|
|
5085
5085
|
"node_modules/@jscad/modeling/src/geometries/path2/transform.js"(exports, module) {
|
|
5086
5086
|
"use strict";
|
|
5087
5087
|
var mat4 = require_mat4();
|
|
5088
|
-
var
|
|
5088
|
+
var transform = (matrix, geometry) => {
|
|
5089
5089
|
const transforms = mat4.multiply(mat4.create(), matrix, geometry.transforms);
|
|
5090
5090
|
return Object.assign({}, geometry, { transforms });
|
|
5091
5091
|
};
|
|
5092
|
-
module.exports =
|
|
5092
|
+
module.exports = transform;
|
|
5093
5093
|
}
|
|
5094
5094
|
});
|
|
5095
5095
|
|
|
@@ -6289,14 +6289,14 @@ var require_transform9 = __commonJS({
|
|
|
6289
6289
|
var fromPoints = require_fromPoints6();
|
|
6290
6290
|
var origin = require_origin();
|
|
6291
6291
|
var direction = require_direction();
|
|
6292
|
-
var
|
|
6292
|
+
var transform = (out, line, matrix) => {
|
|
6293
6293
|
const org = origin(line);
|
|
6294
6294
|
const dir = direction(line);
|
|
6295
6295
|
vec2.transform(org, org, matrix);
|
|
6296
6296
|
vec2.transform(dir, dir, matrix);
|
|
6297
6297
|
return fromPoints(out, org, dir);
|
|
6298
6298
|
};
|
|
6299
|
-
module.exports =
|
|
6299
|
+
module.exports = transform;
|
|
6300
6300
|
}
|
|
6301
6301
|
});
|
|
6302
6302
|
|
|
@@ -6570,7 +6570,7 @@ var require_transform10 = __commonJS({
|
|
|
6570
6570
|
"use strict";
|
|
6571
6571
|
var vec3 = require_vec3();
|
|
6572
6572
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
6573
|
-
var
|
|
6573
|
+
var transform = (out, line, matrix) => {
|
|
6574
6574
|
const point = line[0];
|
|
6575
6575
|
const direction = line[1];
|
|
6576
6576
|
const pointPlusDirection = vec3.add(vec3.create(), point, direction);
|
|
@@ -6579,7 +6579,7 @@ var require_transform10 = __commonJS({
|
|
|
6579
6579
|
const newdirection = vec3.subtract(newPointPlusDirection, newPointPlusDirection, newpoint);
|
|
6580
6580
|
return fromPointAndDirection(out, newpoint, newdirection);
|
|
6581
6581
|
};
|
|
6582
|
-
module.exports =
|
|
6582
|
+
module.exports = transform;
|
|
6583
6583
|
}
|
|
6584
6584
|
});
|
|
6585
6585
|
|
|
@@ -7252,7 +7252,7 @@ var require_ellipse = __commonJS({
|
|
|
7252
7252
|
var { EPS, TAU } = require_constants();
|
|
7253
7253
|
var vec2 = require_vec2();
|
|
7254
7254
|
var geom2 = require_geom2();
|
|
7255
|
-
var { sin
|
|
7255
|
+
var { sin, cos } = require_trigonometry();
|
|
7256
7256
|
var { isGTE, isNumberArray } = require_commonChecks();
|
|
7257
7257
|
var ellipse3 = (options) => {
|
|
7258
7258
|
const defaults = {
|
|
@@ -7289,7 +7289,7 @@ var require_ellipse = __commonJS({
|
|
|
7289
7289
|
segments = rotation < TAU ? segments + 1 : segments;
|
|
7290
7290
|
for (let i = 0; i < segments; i++) {
|
|
7291
7291
|
const angle = step * i + startAngle;
|
|
7292
|
-
const point = vec2.fromValues(radius[0] *
|
|
7292
|
+
const point = vec2.fromValues(radius[0] * cos(angle), radius[1] * sin(angle));
|
|
7293
7293
|
vec2.add(point, centerv, point);
|
|
7294
7294
|
points.push(point);
|
|
7295
7295
|
}
|
|
@@ -7396,7 +7396,7 @@ var require_cylinderElliptic = __commonJS({
|
|
|
7396
7396
|
var vec3 = require_vec3();
|
|
7397
7397
|
var geom3 = require_geom3();
|
|
7398
7398
|
var poly3 = require_poly3();
|
|
7399
|
-
var { sin
|
|
7399
|
+
var { sin, cos } = require_trigonometry();
|
|
7400
7400
|
var { isGT, isGTE, isNumberArray } = require_commonChecks();
|
|
7401
7401
|
var cylinderElliptic = (options) => {
|
|
7402
7402
|
const defaults = {
|
|
@@ -7442,8 +7442,8 @@ var require_cylinderElliptic = __commonJS({
|
|
|
7442
7442
|
const v3 = vec3.create();
|
|
7443
7443
|
const point = (stack, slice, radius) => {
|
|
7444
7444
|
const angle = slice * rotation + startAngle;
|
|
7445
|
-
vec3.scale(v1, axisX, radius[0] *
|
|
7446
|
-
vec3.scale(v2, axisY, radius[1] *
|
|
7445
|
+
vec3.scale(v1, axisX, radius[0] * cos(angle));
|
|
7446
|
+
vec3.scale(v2, axisY, radius[1] * sin(angle));
|
|
7447
7447
|
vec3.add(v1, v1, v2);
|
|
7448
7448
|
vec3.scale(v3, ray, stack);
|
|
7449
7449
|
vec3.add(v3, v3, start);
|
|
@@ -7528,7 +7528,7 @@ var require_ellipsoid = __commonJS({
|
|
|
7528
7528
|
var vec3 = require_vec3();
|
|
7529
7529
|
var geom3 = require_geom3();
|
|
7530
7530
|
var poly3 = require_poly3();
|
|
7531
|
-
var { sin
|
|
7531
|
+
var { sin, cos } = require_trigonometry();
|
|
7532
7532
|
var { isGTE, isNumberArray } = require_commonChecks();
|
|
7533
7533
|
var ellipsoid = (options) => {
|
|
7534
7534
|
const defaults = {
|
|
@@ -7553,13 +7553,13 @@ var require_ellipsoid = __commonJS({
|
|
|
7553
7553
|
const p2 = vec3.create();
|
|
7554
7554
|
for (let slice1 = 0; slice1 <= segments; slice1++) {
|
|
7555
7555
|
const angle = TAU * slice1 / segments;
|
|
7556
|
-
const cylinderpoint = vec3.add(vec3.create(), vec3.scale(p1, xvector,
|
|
7556
|
+
const cylinderpoint = vec3.add(vec3.create(), vec3.scale(p1, xvector, cos(angle)), vec3.scale(p2, yvector, sin(angle)));
|
|
7557
7557
|
if (slice1 > 0) {
|
|
7558
7558
|
let prevcospitch, prevsinpitch;
|
|
7559
7559
|
for (let slice2 = 0; slice2 <= qsegments; slice2++) {
|
|
7560
7560
|
const pitch = TAU / 4 * slice2 / qsegments;
|
|
7561
|
-
const cospitch =
|
|
7562
|
-
const sinpitch =
|
|
7561
|
+
const cospitch = cos(pitch);
|
|
7562
|
+
const sinpitch = sin(pitch);
|
|
7563
7563
|
if (slice2 > 0) {
|
|
7564
7564
|
let points = [];
|
|
7565
7565
|
let point;
|
|
@@ -7883,13 +7883,13 @@ var require_roundedCuboid = __commonJS({
|
|
|
7883
7883
|
var vec3 = require_vec3();
|
|
7884
7884
|
var geom3 = require_geom3();
|
|
7885
7885
|
var poly3 = require_poly3();
|
|
7886
|
-
var { sin
|
|
7886
|
+
var { sin, cos } = require_trigonometry();
|
|
7887
7887
|
var { isGTE, isNumberArray } = require_commonChecks();
|
|
7888
7888
|
var cuboid5 = require_cuboid();
|
|
7889
7889
|
var createCorners = (center, size4, radius, segments, slice, positive) => {
|
|
7890
7890
|
const pitch = TAU / 4 * slice / segments;
|
|
7891
|
-
const cospitch =
|
|
7892
|
-
const sinpitch =
|
|
7891
|
+
const cospitch = cos(pitch);
|
|
7892
|
+
const sinpitch = sin(pitch);
|
|
7893
7893
|
const layersegments = segments - slice;
|
|
7894
7894
|
let layerradius = radius * cospitch;
|
|
7895
7895
|
let layeroffset = size4[2] - (radius - radius * sinpitch);
|
|
@@ -8035,7 +8035,7 @@ var require_roundedCylinder = __commonJS({
|
|
|
8035
8035
|
var vec3 = require_vec3();
|
|
8036
8036
|
var geom3 = require_geom3();
|
|
8037
8037
|
var poly3 = require_poly3();
|
|
8038
|
-
var { sin
|
|
8038
|
+
var { sin, cos } = require_trigonometry();
|
|
8039
8039
|
var { isGTE, isNumberArray } = require_commonChecks();
|
|
8040
8040
|
var cylinder5 = require_cylinder();
|
|
8041
8041
|
var roundedCylinder = (options) => {
|
|
@@ -8082,7 +8082,7 @@ var require_roundedCylinder = __commonJS({
|
|
|
8082
8082
|
let prevcylinderpoint;
|
|
8083
8083
|
for (let slice1 = 0; slice1 <= segments; slice1++) {
|
|
8084
8084
|
const angle = TAU * slice1 / segments;
|
|
8085
|
-
const cylinderpoint = vec3.add(vec3.create(), vec3.scale(v1, xvector,
|
|
8085
|
+
const cylinderpoint = vec3.add(vec3.create(), vec3.scale(v1, xvector, cos(angle)), vec3.scale(v2, yvector, sin(angle)));
|
|
8086
8086
|
if (slice1 > 0) {
|
|
8087
8087
|
let points = [];
|
|
8088
8088
|
points.push(vec3.add(vec3.create(), start, cylinderpoint));
|
|
@@ -8093,8 +8093,8 @@ var require_roundedCylinder = __commonJS({
|
|
|
8093
8093
|
let prevcospitch, prevsinpitch;
|
|
8094
8094
|
for (let slice2 = 0; slice2 <= qsegments; slice2++) {
|
|
8095
8095
|
const pitch = TAU / 4 * slice2 / qsegments;
|
|
8096
|
-
const cospitch =
|
|
8097
|
-
const sinpitch =
|
|
8096
|
+
const cospitch = cos(pitch);
|
|
8097
|
+
const sinpitch = sin(pitch);
|
|
8098
8098
|
if (slice2 > 0) {
|
|
8099
8099
|
points = [];
|
|
8100
8100
|
let point;
|
|
@@ -8802,10 +8802,10 @@ var require_eliminateHoles = __commonJS({
|
|
|
8802
8802
|
p = m;
|
|
8803
8803
|
do {
|
|
8804
8804
|
if (hx >= p.x && p.x >= mx && hx !== p.x && pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {
|
|
8805
|
-
const
|
|
8806
|
-
if (locallyInside(p, hole) && (
|
|
8805
|
+
const tan = Math.abs(hy - p.y) / (hx - p.x);
|
|
8806
|
+
if (locallyInside(p, hole) && (tan < tanMin || tan === tanMin && (p.x > m.x || p.x === m.x && sectorContainsSector(m, p)))) {
|
|
8807
8807
|
m = p;
|
|
8808
|
-
tanMin =
|
|
8808
|
+
tanMin = tan;
|
|
8809
8809
|
}
|
|
8810
8810
|
}
|
|
8811
8811
|
p = p.next;
|
|
@@ -9145,11 +9145,11 @@ var require_transform11 = __commonJS({
|
|
|
9145
9145
|
"use strict";
|
|
9146
9146
|
var vec3 = require_vec3();
|
|
9147
9147
|
var create = require_create13();
|
|
9148
|
-
var
|
|
9148
|
+
var transform = (matrix, slice) => {
|
|
9149
9149
|
const edges = slice.edges.map((edge) => [vec3.transform(vec3.create(), edge[0], matrix), vec3.transform(vec3.create(), edge[1], matrix)]);
|
|
9150
9150
|
return create(edges);
|
|
9151
9151
|
};
|
|
9152
|
-
module.exports =
|
|
9152
|
+
module.exports = transform;
|
|
9153
9153
|
}
|
|
9154
9154
|
});
|
|
9155
9155
|
|
|
@@ -9473,7 +9473,7 @@ var require_rotate3 = __commonJS({
|
|
|
9473
9473
|
var geom2 = require_geom2();
|
|
9474
9474
|
var geom3 = require_geom3();
|
|
9475
9475
|
var path2 = require_path2();
|
|
9476
|
-
var
|
|
9476
|
+
var rotate2 = (angles, ...objects) => {
|
|
9477
9477
|
if (!Array.isArray(angles)) throw new Error("angles must be an array");
|
|
9478
9478
|
objects = flatten(objects);
|
|
9479
9479
|
if (objects.length === 0) throw new Error("wrong number of arguments");
|
|
@@ -9491,11 +9491,11 @@ var require_rotate3 = __commonJS({
|
|
|
9491
9491
|
});
|
|
9492
9492
|
return results.length === 1 ? results[0] : results;
|
|
9493
9493
|
};
|
|
9494
|
-
var rotateX = (angle, ...objects) =>
|
|
9495
|
-
var rotateY = (angle, ...objects) =>
|
|
9496
|
-
var rotateZ3 = (angle, ...objects) =>
|
|
9494
|
+
var rotateX = (angle, ...objects) => rotate2([angle, 0, 0], objects);
|
|
9495
|
+
var rotateY = (angle, ...objects) => rotate2([0, angle, 0], objects);
|
|
9496
|
+
var rotateZ3 = (angle, ...objects) => rotate2([0, 0, angle], objects);
|
|
9497
9497
|
module.exports = {
|
|
9498
|
-
rotate:
|
|
9498
|
+
rotate: rotate2,
|
|
9499
9499
|
rotateX,
|
|
9500
9500
|
rotateY,
|
|
9501
9501
|
rotateZ: rotateZ3
|
|
@@ -9512,7 +9512,7 @@ var require_translate2 = __commonJS({
|
|
|
9512
9512
|
var geom2 = require_geom2();
|
|
9513
9513
|
var geom3 = require_geom3();
|
|
9514
9514
|
var path2 = require_path2();
|
|
9515
|
-
var
|
|
9515
|
+
var translate6 = (offset4, ...objects) => {
|
|
9516
9516
|
if (!Array.isArray(offset4)) throw new Error("offset must be an array");
|
|
9517
9517
|
objects = flatten(objects);
|
|
9518
9518
|
if (objects.length === 0) throw new Error("wrong number of arguments");
|
|
@@ -9527,11 +9527,11 @@ var require_translate2 = __commonJS({
|
|
|
9527
9527
|
});
|
|
9528
9528
|
return results.length === 1 ? results[0] : results;
|
|
9529
9529
|
};
|
|
9530
|
-
var translateX = (offset4, ...objects) =>
|
|
9531
|
-
var translateY = (offset4, ...objects) =>
|
|
9532
|
-
var translateZ = (offset4, ...objects) =>
|
|
9530
|
+
var translateX = (offset4, ...objects) => translate6([offset4, 0, 0], objects);
|
|
9531
|
+
var translateY = (offset4, ...objects) => translate6([0, offset4, 0], objects);
|
|
9532
|
+
var translateZ = (offset4, ...objects) => translate6([0, 0, offset4], objects);
|
|
9533
9533
|
module.exports = {
|
|
9534
|
-
translate:
|
|
9534
|
+
translate: translate6,
|
|
9535
9535
|
translateX,
|
|
9536
9536
|
translateY,
|
|
9537
9537
|
translateZ
|
|
@@ -9545,8 +9545,8 @@ var require_torus = __commonJS({
|
|
|
9545
9545
|
"use strict";
|
|
9546
9546
|
var { TAU } = require_constants();
|
|
9547
9547
|
var extrudeRotate = require_extrudeRotate();
|
|
9548
|
-
var { rotate:
|
|
9549
|
-
var { translate:
|
|
9548
|
+
var { rotate: rotate2 } = require_rotate3();
|
|
9549
|
+
var { translate: translate6 } = require_translate2();
|
|
9550
9550
|
var circle = require_circle();
|
|
9551
9551
|
var { isGT, isGTE } = require_commonChecks();
|
|
9552
9552
|
var torus = (options) => {
|
|
@@ -9569,9 +9569,9 @@ var require_torus = __commonJS({
|
|
|
9569
9569
|
if (innerRadius >= outerRadius) throw new Error("inner circle is too large to rotate about the outer circle");
|
|
9570
9570
|
let innerCircle = circle({ radius: innerRadius, segments: innerSegments });
|
|
9571
9571
|
if (innerRotation !== 0) {
|
|
9572
|
-
innerCircle =
|
|
9572
|
+
innerCircle = rotate2([0, 0, innerRotation], innerCircle);
|
|
9573
9573
|
}
|
|
9574
|
-
innerCircle =
|
|
9574
|
+
innerCircle = translate6([outerRadius, 0], innerCircle);
|
|
9575
9575
|
const extrudeOptions = {
|
|
9576
9576
|
startAngle,
|
|
9577
9577
|
angle: outerRotation,
|
|
@@ -9928,7 +9928,7 @@ var require_vectorText = __commonJS({
|
|
|
9928
9928
|
}
|
|
9929
9929
|
return line;
|
|
9930
9930
|
};
|
|
9931
|
-
var
|
|
9931
|
+
var vectorText = (options, text) => {
|
|
9932
9932
|
const {
|
|
9933
9933
|
xOffset,
|
|
9934
9934
|
yOffset,
|
|
@@ -9985,7 +9985,7 @@ var require_vectorText = __commonJS({
|
|
|
9985
9985
|
}
|
|
9986
9986
|
return output;
|
|
9987
9987
|
};
|
|
9988
|
-
module.exports =
|
|
9988
|
+
module.exports = vectorText;
|
|
9989
9989
|
}
|
|
9990
9990
|
});
|
|
9991
9991
|
|
|
@@ -13296,7 +13296,7 @@ var require_align = __commonJS({
|
|
|
13296
13296
|
var flatten = require_flatten();
|
|
13297
13297
|
var padArrayToLength = require_padArrayToLength();
|
|
13298
13298
|
var measureAggregateBoundingBox = require_measureAggregateBoundingBox();
|
|
13299
|
-
var { translate:
|
|
13299
|
+
var { translate: translate6 } = require_translate2();
|
|
13300
13300
|
var validateOptions = (options) => {
|
|
13301
13301
|
if (!Array.isArray(options.modes) || options.modes.length > 3) throw new Error("align(): modes must be an array of length <= 3");
|
|
13302
13302
|
options.modes = padArrayToLength(options.modes, "none", 3);
|
|
@@ -13333,7 +13333,7 @@ var require_align = __commonJS({
|
|
|
13333
13333
|
translation[i] = relativeTo[i] - bounds[0][i];
|
|
13334
13334
|
}
|
|
13335
13335
|
}
|
|
13336
|
-
return
|
|
13336
|
+
return translate6(translation, geometry);
|
|
13337
13337
|
};
|
|
13338
13338
|
var align = (options, ...geometries) => {
|
|
13339
13339
|
const defaults = {
|
|
@@ -13370,7 +13370,7 @@ var require_center = __commonJS({
|
|
|
13370
13370
|
var geom3 = require_geom3();
|
|
13371
13371
|
var path2 = require_path2();
|
|
13372
13372
|
var measureBoundingBox = require_measureBoundingBox2();
|
|
13373
|
-
var { translate:
|
|
13373
|
+
var { translate: translate6 } = require_translate2();
|
|
13374
13374
|
var centerGeometry = (options, object) => {
|
|
13375
13375
|
const defaults = {
|
|
13376
13376
|
axes: [true, true, true],
|
|
@@ -13382,7 +13382,7 @@ var require_center = __commonJS({
|
|
|
13382
13382
|
if (axes[0]) offset4[0] = relativeTo[0] - (bounds[0][0] + (bounds[1][0] - bounds[0][0]) / 2);
|
|
13383
13383
|
if (axes[1]) offset4[1] = relativeTo[1] - (bounds[0][1] + (bounds[1][1] - bounds[0][1]) / 2);
|
|
13384
13384
|
if (axes[2]) offset4[2] = relativeTo[2] - (bounds[0][2] + (bounds[1][2] - bounds[0][2]) / 2);
|
|
13385
|
-
return
|
|
13385
|
+
return translate6(offset4, object);
|
|
13386
13386
|
};
|
|
13387
13387
|
var center = (options, ...objects) => {
|
|
13388
13388
|
const defaults = {
|
|
@@ -13424,7 +13424,7 @@ var require_scale4 = __commonJS({
|
|
|
13424
13424
|
var geom2 = require_geom2();
|
|
13425
13425
|
var geom3 = require_geom3();
|
|
13426
13426
|
var path2 = require_path2();
|
|
13427
|
-
var
|
|
13427
|
+
var scale2 = (factors, ...objects) => {
|
|
13428
13428
|
if (!Array.isArray(factors)) throw new Error("factors must be an array");
|
|
13429
13429
|
objects = flatten(objects);
|
|
13430
13430
|
if (objects.length === 0) throw new Error("wrong number of arguments");
|
|
@@ -13440,11 +13440,11 @@ var require_scale4 = __commonJS({
|
|
|
13440
13440
|
});
|
|
13441
13441
|
return results.length === 1 ? results[0] : results;
|
|
13442
13442
|
};
|
|
13443
|
-
var scaleX = (factor, ...objects) =>
|
|
13444
|
-
var scaleY = (factor, ...objects) =>
|
|
13445
|
-
var scaleZ = (factor, ...objects) =>
|
|
13443
|
+
var scaleX = (factor, ...objects) => scale2([factor, 1, 1], objects);
|
|
13444
|
+
var scaleY = (factor, ...objects) => scale2([1, factor, 1], objects);
|
|
13445
|
+
var scaleZ = (factor, ...objects) => scale2([1, 1, factor], objects);
|
|
13446
13446
|
module.exports = {
|
|
13447
|
-
scale:
|
|
13447
|
+
scale: scale2,
|
|
13448
13448
|
scaleX,
|
|
13449
13449
|
scaleY,
|
|
13450
13450
|
scaleZ
|
|
@@ -13460,7 +13460,7 @@ var require_transform12 = __commonJS({
|
|
|
13460
13460
|
var geom2 = require_geom2();
|
|
13461
13461
|
var geom3 = require_geom3();
|
|
13462
13462
|
var path2 = require_path2();
|
|
13463
|
-
var
|
|
13463
|
+
var transform = (matrix, ...objects) => {
|
|
13464
13464
|
objects = flatten(objects);
|
|
13465
13465
|
if (objects.length === 0) throw new Error("wrong number of arguments");
|
|
13466
13466
|
const results = objects.map((object) => {
|
|
@@ -13471,7 +13471,7 @@ var require_transform12 = __commonJS({
|
|
|
13471
13471
|
});
|
|
13472
13472
|
return results.length === 1 ? results[0] : results;
|
|
13473
13473
|
};
|
|
13474
|
-
module.exports =
|
|
13474
|
+
module.exports = transform;
|
|
13475
13475
|
}
|
|
13476
13476
|
});
|
|
13477
13477
|
|
|
@@ -22331,7 +22331,7 @@ var m2host = (raw_params) => {
|
|
|
22331
22331
|
}
|
|
22332
22332
|
const centerX = (minX + maxX) / 2;
|
|
22333
22333
|
const centerY = (minY + maxY) / 2;
|
|
22334
|
-
const
|
|
22334
|
+
const translate6 = (el) => {
|
|
22335
22335
|
if (typeof el.x === "number") el.x -= centerX;
|
|
22336
22336
|
if (typeof el.y === "number") el.y -= centerY;
|
|
22337
22337
|
if (el.center) {
|
|
@@ -22345,9 +22345,9 @@ var m2host = (raw_params) => {
|
|
|
22345
22345
|
}));
|
|
22346
22346
|
}
|
|
22347
22347
|
};
|
|
22348
|
-
for (const pad2 of pads)
|
|
22349
|
-
|
|
22350
|
-
|
|
22348
|
+
for (const pad2 of pads) translate6(pad2);
|
|
22349
|
+
translate6(cutout);
|
|
22350
|
+
translate6(pin1Marker);
|
|
22351
22351
|
return {
|
|
22352
22352
|
circuitJson: [
|
|
22353
22353
|
...pads,
|
|
@@ -22789,9 +22789,9 @@ function getExpandedStroke(strokeInput, width10) {
|
|
|
22789
22789
|
addPoint(current, normalPrev, -1);
|
|
22790
22790
|
addPoint(current, normalNext, -1);
|
|
22791
22791
|
} else {
|
|
22792
|
-
const
|
|
22793
|
-
addPoint(current, { x: miterX *
|
|
22794
|
-
addPoint(current, { x: miterX *
|
|
22792
|
+
const scale2 = 1 / miterLength;
|
|
22793
|
+
addPoint(current, { x: miterX * scale2, y: miterY * scale2 }, 1);
|
|
22794
|
+
addPoint(current, { x: miterX * scale2, y: miterY * scale2 }, -1);
|
|
22795
22795
|
}
|
|
22796
22796
|
}
|
|
22797
22797
|
const lastNormal = getNormal(
|
|
@@ -27509,7 +27509,7 @@ var FootprinterModel = ({
|
|
|
27509
27509
|
onHover,
|
|
27510
27510
|
onUnhover,
|
|
27511
27511
|
isHovered,
|
|
27512
|
-
scale:
|
|
27512
|
+
scale: scale2,
|
|
27513
27513
|
isTranslucent = false
|
|
27514
27514
|
}) => {
|
|
27515
27515
|
const { rootObject } = useThree();
|
|
@@ -27549,7 +27549,7 @@ var FootprinterModel = ({
|
|
|
27549
27549
|
if (!group) return;
|
|
27550
27550
|
if (positionOffset) group.position.fromArray(positionOffset);
|
|
27551
27551
|
if (rotationOffset) group.rotation.fromArray(rotationOffset);
|
|
27552
|
-
if (
|
|
27552
|
+
if (scale2 !== void 0) group.scale.setScalar(scale2);
|
|
27553
27553
|
}, [
|
|
27554
27554
|
group,
|
|
27555
27555
|
positionOffset?.[0],
|
|
@@ -27558,7 +27558,7 @@ var FootprinterModel = ({
|
|
|
27558
27558
|
rotationOffset?.[0],
|
|
27559
27559
|
rotationOffset?.[1],
|
|
27560
27560
|
rotationOffset?.[2],
|
|
27561
|
-
|
|
27561
|
+
scale2
|
|
27562
27562
|
]);
|
|
27563
27563
|
useEffect5(() => {
|
|
27564
27564
|
if (!group) return;
|
|
@@ -27627,7 +27627,7 @@ function GltfModel({
|
|
|
27627
27627
|
onHover,
|
|
27628
27628
|
onUnhover,
|
|
27629
27629
|
isHovered,
|
|
27630
|
-
scale:
|
|
27630
|
+
scale: scale2,
|
|
27631
27631
|
isTranslucent = false
|
|
27632
27632
|
}) {
|
|
27633
27633
|
const { renderer, rootObject } = useThree();
|
|
@@ -27675,7 +27675,7 @@ function GltfModel({
|
|
|
27675
27675
|
if (!model) return;
|
|
27676
27676
|
if (position) model.position.fromArray(position);
|
|
27677
27677
|
if (rotation) model.rotation.fromArray(rotation);
|
|
27678
|
-
if (
|
|
27678
|
+
if (scale2 !== void 0) model.scale.setScalar(scale2);
|
|
27679
27679
|
}, [
|
|
27680
27680
|
model,
|
|
27681
27681
|
position?.[0],
|
|
@@ -27684,7 +27684,7 @@ function GltfModel({
|
|
|
27684
27684
|
rotation?.[0],
|
|
27685
27685
|
rotation?.[1],
|
|
27686
27686
|
rotation?.[2],
|
|
27687
|
-
|
|
27687
|
+
scale2
|
|
27688
27688
|
]);
|
|
27689
27689
|
useEffect6(() => {
|
|
27690
27690
|
if (!rootObject || !model) return;
|
|
@@ -27769,7 +27769,7 @@ var JscadModel = ({
|
|
|
27769
27769
|
onHover,
|
|
27770
27770
|
onUnhover,
|
|
27771
27771
|
isHovered,
|
|
27772
|
-
scale:
|
|
27772
|
+
scale: scale2,
|
|
27773
27773
|
isTranslucent = false
|
|
27774
27774
|
}) => {
|
|
27775
27775
|
const { rootObject } = useThree();
|
|
@@ -27803,7 +27803,7 @@ var JscadModel = ({
|
|
|
27803
27803
|
if (!mesh) return;
|
|
27804
27804
|
if (positionOffset) mesh.position.fromArray(positionOffset);
|
|
27805
27805
|
if (rotationOffset) mesh.rotation.fromArray(rotationOffset);
|
|
27806
|
-
if (
|
|
27806
|
+
if (scale2 !== void 0) mesh.scale.setScalar(scale2);
|
|
27807
27807
|
}, [
|
|
27808
27808
|
mesh,
|
|
27809
27809
|
positionOffset?.[0],
|
|
@@ -27812,7 +27812,7 @@ var JscadModel = ({
|
|
|
27812
27812
|
rotationOffset?.[0],
|
|
27813
27813
|
rotationOffset?.[1],
|
|
27814
27814
|
rotationOffset?.[2],
|
|
27815
|
-
|
|
27815
|
+
scale2
|
|
27816
27816
|
]);
|
|
27817
27817
|
useMemo6(() => {
|
|
27818
27818
|
if (!material) return;
|
|
@@ -27952,7 +27952,7 @@ function MixedStlModel({
|
|
|
27952
27952
|
onHover,
|
|
27953
27953
|
onUnhover,
|
|
27954
27954
|
isHovered,
|
|
27955
|
-
scale:
|
|
27955
|
+
scale: scale2,
|
|
27956
27956
|
isTranslucent = false
|
|
27957
27957
|
}) {
|
|
27958
27958
|
const obj = useGlobalObjLoader(url);
|
|
@@ -28008,8 +28008,8 @@ function MixedStlModel({
|
|
|
28008
28008
|
model.rotation.copy(rotation);
|
|
28009
28009
|
}
|
|
28010
28010
|
}
|
|
28011
|
-
if (
|
|
28012
|
-
model.scale.setScalar(
|
|
28011
|
+
if (scale2 !== void 0) {
|
|
28012
|
+
model.scale.setScalar(scale2);
|
|
28013
28013
|
}
|
|
28014
28014
|
}, [
|
|
28015
28015
|
model,
|
|
@@ -28019,7 +28019,7 @@ function MixedStlModel({
|
|
|
28019
28019
|
Array.isArray(rotation) ? rotation[0] : rotation?.x,
|
|
28020
28020
|
Array.isArray(rotation) ? rotation[1] : rotation?.y,
|
|
28021
28021
|
Array.isArray(rotation) ? rotation[2] : rotation?.z,
|
|
28022
|
-
|
|
28022
|
+
scale2
|
|
28023
28023
|
]);
|
|
28024
28024
|
if (obj instanceof Error) {
|
|
28025
28025
|
throw obj;
|
|
@@ -28181,7 +28181,7 @@ var StepModel = ({
|
|
|
28181
28181
|
stepUrl,
|
|
28182
28182
|
position,
|
|
28183
28183
|
rotation,
|
|
28184
|
-
scale:
|
|
28184
|
+
scale: scale2,
|
|
28185
28185
|
onHover,
|
|
28186
28186
|
onUnhover,
|
|
28187
28187
|
isHovered,
|
|
@@ -28273,7 +28273,7 @@ var StepModel = ({
|
|
|
28273
28273
|
gltfUrl: stepGltfUrl,
|
|
28274
28274
|
position,
|
|
28275
28275
|
rotation,
|
|
28276
|
-
scale:
|
|
28276
|
+
scale: scale2,
|
|
28277
28277
|
onHover,
|
|
28278
28278
|
onUnhover,
|
|
28279
28279
|
isHovered,
|
|
@@ -28483,7 +28483,7 @@ import * as THREE16 from "three";
|
|
|
28483
28483
|
// package.json
|
|
28484
28484
|
var package_default = {
|
|
28485
28485
|
name: "@tscircuit/3d-viewer",
|
|
28486
|
-
version: "0.0.
|
|
28486
|
+
version: "0.0.521",
|
|
28487
28487
|
main: "./dist/index.js",
|
|
28488
28488
|
module: "./dist/index.js",
|
|
28489
28489
|
type: "module",
|
|
@@ -31169,7 +31169,7 @@ var Text = ({
|
|
|
31169
31169
|
parent,
|
|
31170
31170
|
position,
|
|
31171
31171
|
rotation,
|
|
31172
|
-
scale:
|
|
31172
|
+
scale: scale2,
|
|
31173
31173
|
color,
|
|
31174
31174
|
fontSize,
|
|
31175
31175
|
anchorX,
|
|
@@ -31182,7 +31182,7 @@ var Text = ({
|
|
|
31182
31182
|
textMesh.text = children;
|
|
31183
31183
|
if (position) textMesh.position.fromArray(position);
|
|
31184
31184
|
if (rotation) textMesh.rotation.fromArray(rotation);
|
|
31185
|
-
if (
|
|
31185
|
+
if (scale2) textMesh.scale.fromArray(scale2);
|
|
31186
31186
|
textMesh.color = color || "white";
|
|
31187
31187
|
textMesh.fontSize = fontSize || 1;
|
|
31188
31188
|
textMesh.anchorX = anchorX || "center";
|
|
@@ -31195,7 +31195,7 @@ var Text = ({
|
|
|
31195
31195
|
children,
|
|
31196
31196
|
position,
|
|
31197
31197
|
rotation,
|
|
31198
|
-
|
|
31198
|
+
scale2,
|
|
31199
31199
|
color,
|
|
31200
31200
|
fontSize,
|
|
31201
31201
|
anchorX,
|
|
@@ -31454,220 +31454,6 @@ import { useEffect as useEffect23, useMemo as useMemo19 } from "react";
|
|
|
31454
31454
|
// src/textures/create-combined-board-textures.ts
|
|
31455
31455
|
import * as THREE26 from "three";
|
|
31456
31456
|
|
|
31457
|
-
// src/utils/copper-text-texture.ts
|
|
31458
|
-
var import_text = __toESM(require_text(), 1);
|
|
31459
|
-
import * as THREE19 from "three";
|
|
31460
|
-
|
|
31461
|
-
// node_modules/transformation-matrix/src/applyToPoint.js
|
|
31462
|
-
function applyToPoint(matrix, point) {
|
|
31463
|
-
return Array.isArray(point) ? [
|
|
31464
|
-
matrix.a * point[0] + matrix.c * point[1] + matrix.e,
|
|
31465
|
-
matrix.b * point[0] + matrix.d * point[1] + matrix.f
|
|
31466
|
-
] : {
|
|
31467
|
-
x: matrix.a * point.x + matrix.c * point.y + matrix.e,
|
|
31468
|
-
y: matrix.b * point.x + matrix.d * point.y + matrix.f
|
|
31469
|
-
};
|
|
31470
|
-
}
|
|
31471
|
-
|
|
31472
|
-
// node_modules/transformation-matrix/src/utils.js
|
|
31473
|
-
function isUndefined(val) {
|
|
31474
|
-
return typeof val === "undefined";
|
|
31475
|
-
}
|
|
31476
|
-
|
|
31477
|
-
// node_modules/transformation-matrix/src/translate.js
|
|
31478
|
-
function translate6(tx, ty = 0) {
|
|
31479
|
-
return {
|
|
31480
|
-
a: 1,
|
|
31481
|
-
c: 0,
|
|
31482
|
-
e: tx,
|
|
31483
|
-
b: 0,
|
|
31484
|
-
d: 1,
|
|
31485
|
-
f: ty
|
|
31486
|
-
};
|
|
31487
|
-
}
|
|
31488
|
-
|
|
31489
|
-
// node_modules/transformation-matrix/src/transform.js
|
|
31490
|
-
function transform(...matrices) {
|
|
31491
|
-
matrices = Array.isArray(matrices[0]) ? matrices[0] : matrices;
|
|
31492
|
-
const multiply = (m1, m2) => {
|
|
31493
|
-
return {
|
|
31494
|
-
a: m1.a * m2.a + m1.c * m2.b,
|
|
31495
|
-
c: m1.a * m2.c + m1.c * m2.d,
|
|
31496
|
-
e: m1.a * m2.e + m1.c * m2.f + m1.e,
|
|
31497
|
-
b: m1.b * m2.a + m1.d * m2.b,
|
|
31498
|
-
d: m1.b * m2.c + m1.d * m2.d,
|
|
31499
|
-
f: m1.b * m2.e + m1.d * m2.f + m1.f
|
|
31500
|
-
};
|
|
31501
|
-
};
|
|
31502
|
-
switch (matrices.length) {
|
|
31503
|
-
case 0:
|
|
31504
|
-
throw new Error("no matrices provided");
|
|
31505
|
-
case 1:
|
|
31506
|
-
return matrices[0];
|
|
31507
|
-
case 2:
|
|
31508
|
-
return multiply(matrices[0], matrices[1]);
|
|
31509
|
-
default: {
|
|
31510
|
-
const [m1, m2, ...rest] = matrices;
|
|
31511
|
-
const m = multiply(m1, m2);
|
|
31512
|
-
return transform(m, ...rest);
|
|
31513
|
-
}
|
|
31514
|
-
}
|
|
31515
|
-
}
|
|
31516
|
-
function compose(...matrices) {
|
|
31517
|
-
return transform(...matrices);
|
|
31518
|
-
}
|
|
31519
|
-
|
|
31520
|
-
// node_modules/transformation-matrix/src/rotate.js
|
|
31521
|
-
var { cos, sin, PI } = Math;
|
|
31522
|
-
function rotate2(angle, cx, cy) {
|
|
31523
|
-
const cosAngle = cos(angle);
|
|
31524
|
-
const sinAngle = sin(angle);
|
|
31525
|
-
const rotationMatrix = {
|
|
31526
|
-
a: cosAngle,
|
|
31527
|
-
c: -sinAngle,
|
|
31528
|
-
e: 0,
|
|
31529
|
-
b: sinAngle,
|
|
31530
|
-
d: cosAngle,
|
|
31531
|
-
f: 0
|
|
31532
|
-
};
|
|
31533
|
-
if (isUndefined(cx) || isUndefined(cy)) {
|
|
31534
|
-
return rotationMatrix;
|
|
31535
|
-
}
|
|
31536
|
-
return transform([
|
|
31537
|
-
translate6(cx, cy),
|
|
31538
|
-
rotationMatrix,
|
|
31539
|
-
translate6(-cx, -cy)
|
|
31540
|
-
]);
|
|
31541
|
-
}
|
|
31542
|
-
|
|
31543
|
-
// node_modules/transformation-matrix/src/skew.js
|
|
31544
|
-
var { tan } = Math;
|
|
31545
|
-
|
|
31546
|
-
// node_modules/transformation-matrix/src/fromTransformAttribute.autogenerated.js
|
|
31547
|
-
function peg$subclass(child, parent) {
|
|
31548
|
-
function C() {
|
|
31549
|
-
this.constructor = child;
|
|
31550
|
-
}
|
|
31551
|
-
C.prototype = parent.prototype;
|
|
31552
|
-
child.prototype = new C();
|
|
31553
|
-
}
|
|
31554
|
-
function peg$SyntaxError(message, expected, found, location) {
|
|
31555
|
-
var self = Error.call(this, message);
|
|
31556
|
-
if (Object.setPrototypeOf) {
|
|
31557
|
-
Object.setPrototypeOf(self, peg$SyntaxError.prototype);
|
|
31558
|
-
}
|
|
31559
|
-
self.expected = expected;
|
|
31560
|
-
self.found = found;
|
|
31561
|
-
self.location = location;
|
|
31562
|
-
self.name = "SyntaxError";
|
|
31563
|
-
return self;
|
|
31564
|
-
}
|
|
31565
|
-
peg$subclass(peg$SyntaxError, Error);
|
|
31566
|
-
function peg$padEnd(str, targetLength, padString) {
|
|
31567
|
-
padString = padString || " ";
|
|
31568
|
-
if (str.length > targetLength) {
|
|
31569
|
-
return str;
|
|
31570
|
-
}
|
|
31571
|
-
targetLength -= str.length;
|
|
31572
|
-
padString += padString.repeat(targetLength);
|
|
31573
|
-
return str + padString.slice(0, targetLength);
|
|
31574
|
-
}
|
|
31575
|
-
peg$SyntaxError.prototype.format = function(sources) {
|
|
31576
|
-
var str = "Error: " + this.message;
|
|
31577
|
-
if (this.location) {
|
|
31578
|
-
var src = null;
|
|
31579
|
-
var k;
|
|
31580
|
-
for (k = 0; k < sources.length; k++) {
|
|
31581
|
-
if (sources[k].source === this.location.source) {
|
|
31582
|
-
src = sources[k].text.split(/\r\n|\n|\r/g);
|
|
31583
|
-
break;
|
|
31584
|
-
}
|
|
31585
|
-
}
|
|
31586
|
-
var s = this.location.start;
|
|
31587
|
-
var offset_s = this.location.source && typeof this.location.source.offset === "function" ? this.location.source.offset(s) : s;
|
|
31588
|
-
var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column;
|
|
31589
|
-
if (src) {
|
|
31590
|
-
var e = this.location.end;
|
|
31591
|
-
var filler = peg$padEnd("", offset_s.line.toString().length, " ");
|
|
31592
|
-
var line = src[s.line - 1];
|
|
31593
|
-
var last = s.line === e.line ? e.column : line.length + 1;
|
|
31594
|
-
var hatLen = last - s.column || 1;
|
|
31595
|
-
str += "\n --> " + loc + "\n" + filler + " |\n" + offset_s.line + " | " + line + "\n" + filler + " | " + peg$padEnd("", s.column - 1, " ") + peg$padEnd("", hatLen, "^");
|
|
31596
|
-
} else {
|
|
31597
|
-
str += "\n at " + loc;
|
|
31598
|
-
}
|
|
31599
|
-
}
|
|
31600
|
-
return str;
|
|
31601
|
-
};
|
|
31602
|
-
peg$SyntaxError.buildMessage = function(expected, found) {
|
|
31603
|
-
var DESCRIBE_EXPECTATION_FNS = {
|
|
31604
|
-
literal: function(expectation) {
|
|
31605
|
-
return '"' + literalEscape(expectation.text) + '"';
|
|
31606
|
-
},
|
|
31607
|
-
class: function(expectation) {
|
|
31608
|
-
var escapedParts = expectation.parts.map(function(part) {
|
|
31609
|
-
return Array.isArray(part) ? classEscape(part[0]) + "-" + classEscape(part[1]) : classEscape(part);
|
|
31610
|
-
});
|
|
31611
|
-
return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";
|
|
31612
|
-
},
|
|
31613
|
-
any: function() {
|
|
31614
|
-
return "any character";
|
|
31615
|
-
},
|
|
31616
|
-
end: function() {
|
|
31617
|
-
return "end of input";
|
|
31618
|
-
},
|
|
31619
|
-
other: function(expectation) {
|
|
31620
|
-
return expectation.description;
|
|
31621
|
-
}
|
|
31622
|
-
};
|
|
31623
|
-
function hex(ch) {
|
|
31624
|
-
return ch.charCodeAt(0).toString(16).toUpperCase();
|
|
31625
|
-
}
|
|
31626
|
-
function literalEscape(s) {
|
|
31627
|
-
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
31628
|
-
return "\\x0" + hex(ch);
|
|
31629
|
-
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
31630
|
-
return "\\x" + hex(ch);
|
|
31631
|
-
});
|
|
31632
|
-
}
|
|
31633
|
-
function classEscape(s) {
|
|
31634
|
-
return s.replace(/\\/g, "\\\\").replace(/\]/g, "\\]").replace(/\^/g, "\\^").replace(/-/g, "\\-").replace(/\0/g, "\\0").replace(/\t/g, "\\t").replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/[\x00-\x0F]/g, function(ch) {
|
|
31635
|
-
return "\\x0" + hex(ch);
|
|
31636
|
-
}).replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) {
|
|
31637
|
-
return "\\x" + hex(ch);
|
|
31638
|
-
});
|
|
31639
|
-
}
|
|
31640
|
-
function describeExpectation(expectation) {
|
|
31641
|
-
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
|
|
31642
|
-
}
|
|
31643
|
-
function describeExpected(expected2) {
|
|
31644
|
-
var descriptions = expected2.map(describeExpectation);
|
|
31645
|
-
var i, j;
|
|
31646
|
-
descriptions.sort();
|
|
31647
|
-
if (descriptions.length > 0) {
|
|
31648
|
-
for (i = 1, j = 1; i < descriptions.length; i++) {
|
|
31649
|
-
if (descriptions[i - 1] !== descriptions[i]) {
|
|
31650
|
-
descriptions[j] = descriptions[i];
|
|
31651
|
-
j++;
|
|
31652
|
-
}
|
|
31653
|
-
}
|
|
31654
|
-
descriptions.length = j;
|
|
31655
|
-
}
|
|
31656
|
-
switch (descriptions.length) {
|
|
31657
|
-
case 1:
|
|
31658
|
-
return descriptions[0];
|
|
31659
|
-
case 2:
|
|
31660
|
-
return descriptions[0] + " or " + descriptions[1];
|
|
31661
|
-
default:
|
|
31662
|
-
return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
|
|
31663
|
-
}
|
|
31664
|
-
}
|
|
31665
|
-
function describeFound(found2) {
|
|
31666
|
-
return found2 ? '"' + literalEscape(found2) + '"' : "end of input";
|
|
31667
|
-
}
|
|
31668
|
-
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
|
|
31669
|
-
};
|
|
31670
|
-
|
|
31671
31457
|
// node_modules/@tscircuit/math-utils/dist/chunk-5N7UJNVK.js
|
|
31672
31458
|
var getBoundsFromPoints = (points) => {
|
|
31673
31459
|
if (points.length === 0) {
|
|
@@ -31718,257 +31504,9 @@ function calculateOutlineBounds(boardData) {
|
|
|
31718
31504
|
};
|
|
31719
31505
|
}
|
|
31720
31506
|
|
|
31721
|
-
// src/utils/copper-text-texture.ts
|
|
31722
|
-
function parseDimension2(value, defaultValue) {
|
|
31723
|
-
if (value === void 0) return defaultValue;
|
|
31724
|
-
if (typeof value === "number") return value;
|
|
31725
|
-
const num = parseFloat(value.replace(/mm$/, ""));
|
|
31726
|
-
return isNaN(num) ? defaultValue : num;
|
|
31727
|
-
}
|
|
31728
|
-
function shouldMirrorText(text) {
|
|
31729
|
-
if (text.layer === "bottom") {
|
|
31730
|
-
return text.is_mirrored !== false;
|
|
31731
|
-
}
|
|
31732
|
-
return text.is_mirrored === true;
|
|
31733
|
-
}
|
|
31734
|
-
function getTextMetrics(outlines) {
|
|
31735
|
-
const points = outlines.flat();
|
|
31736
|
-
if (points.length === 0) {
|
|
31737
|
-
return {
|
|
31738
|
-
minX: 0,
|
|
31739
|
-
maxX: 0,
|
|
31740
|
-
minY: 0,
|
|
31741
|
-
maxY: 0,
|
|
31742
|
-
width: 0,
|
|
31743
|
-
height: 0,
|
|
31744
|
-
centerX: 0,
|
|
31745
|
-
centerY: 0
|
|
31746
|
-
};
|
|
31747
|
-
}
|
|
31748
|
-
const minX = Math.min(...points.map((p) => p[0]));
|
|
31749
|
-
const maxX = Math.max(...points.map((p) => p[0]));
|
|
31750
|
-
const minY = Math.min(...points.map((p) => p[1]));
|
|
31751
|
-
const maxY = Math.max(...points.map((p) => p[1]));
|
|
31752
|
-
return {
|
|
31753
|
-
minX,
|
|
31754
|
-
maxX,
|
|
31755
|
-
minY,
|
|
31756
|
-
maxY,
|
|
31757
|
-
width: maxX - minX,
|
|
31758
|
-
height: maxY - minY,
|
|
31759
|
-
centerX: (minX + maxX) / 2,
|
|
31760
|
-
centerY: (minY + maxY) / 2
|
|
31761
|
-
};
|
|
31762
|
-
}
|
|
31763
|
-
function processTextOutlines(rawOutlines) {
|
|
31764
|
-
const processed = [];
|
|
31765
|
-
rawOutlines.forEach((outline) => {
|
|
31766
|
-
if (outline.length === 29) {
|
|
31767
|
-
processed.push(outline.slice(0, 15));
|
|
31768
|
-
processed.push(outline.slice(14, 29));
|
|
31769
|
-
} else if (outline.length === 17) {
|
|
31770
|
-
processed.push(outline.slice(0, 10));
|
|
31771
|
-
processed.push(outline.slice(9, 17));
|
|
31772
|
-
} else {
|
|
31773
|
-
processed.push(outline);
|
|
31774
|
-
}
|
|
31775
|
-
});
|
|
31776
|
-
return processed;
|
|
31777
|
-
}
|
|
31778
|
-
function getAlignmentOffset(metrics, alignment) {
|
|
31779
|
-
let xOff = -metrics.centerX;
|
|
31780
|
-
let yOff = -metrics.centerY;
|
|
31781
|
-
if (alignment.includes("left")) {
|
|
31782
|
-
xOff = -metrics.minX;
|
|
31783
|
-
} else if (alignment.includes("right")) {
|
|
31784
|
-
xOff = -metrics.maxX;
|
|
31785
|
-
}
|
|
31786
|
-
if (alignment.includes("top")) {
|
|
31787
|
-
yOff = -metrics.maxY;
|
|
31788
|
-
} else if (alignment.includes("bottom")) {
|
|
31789
|
-
yOff = -metrics.minY;
|
|
31790
|
-
}
|
|
31791
|
-
return { x: xOff, y: yOff };
|
|
31792
|
-
}
|
|
31793
|
-
function buildTransformMatrix(text, metrics) {
|
|
31794
|
-
const transformMatrices = [];
|
|
31795
|
-
let rotationDeg = text.ccw_rotation ?? 0;
|
|
31796
|
-
const shouldMirror = shouldMirrorText(text);
|
|
31797
|
-
if (shouldMirror) {
|
|
31798
|
-
transformMatrices.push(
|
|
31799
|
-
translate6(metrics.centerX, metrics.centerY),
|
|
31800
|
-
{ a: -1, b: 0, c: 0, d: 1, e: 0, f: 0 },
|
|
31801
|
-
// horizontal flip
|
|
31802
|
-
translate6(-metrics.centerX, -metrics.centerY)
|
|
31803
|
-
);
|
|
31804
|
-
rotationDeg = -rotationDeg;
|
|
31805
|
-
}
|
|
31806
|
-
if (rotationDeg) {
|
|
31807
|
-
const rad = rotationDeg * Math.PI / 180;
|
|
31808
|
-
transformMatrices.push(
|
|
31809
|
-
translate6(metrics.centerX, metrics.centerY),
|
|
31810
|
-
rotate2(rad),
|
|
31811
|
-
translate6(-metrics.centerX, -metrics.centerY)
|
|
31812
|
-
);
|
|
31813
|
-
}
|
|
31814
|
-
const matrix = transformMatrices.length > 0 ? compose(...transformMatrices) : void 0;
|
|
31815
|
-
return { matrix, rotationDeg };
|
|
31816
|
-
}
|
|
31817
|
-
function drawTextStrokes(ctx, outlines, transform2, offset4, anchorPos, canvasXFromPcb, canvasYFromPcb) {
|
|
31818
|
-
outlines.forEach((segment) => {
|
|
31819
|
-
ctx.beginPath();
|
|
31820
|
-
segment.forEach((p, index2) => {
|
|
31821
|
-
let transformedP = { x: p[0], y: p[1] };
|
|
31822
|
-
if (transform2) {
|
|
31823
|
-
transformedP = applyToPoint(transform2, transformedP);
|
|
31824
|
-
}
|
|
31825
|
-
const pcbX = transformedP.x + offset4.x + anchorPos.x;
|
|
31826
|
-
const pcbY = transformedP.y + offset4.y + anchorPos.y;
|
|
31827
|
-
const canvasX = canvasXFromPcb(pcbX);
|
|
31828
|
-
const canvasY = canvasYFromPcb(pcbY);
|
|
31829
|
-
if (index2 === 0) ctx.moveTo(canvasX, canvasY);
|
|
31830
|
-
else ctx.lineTo(canvasX, canvasY);
|
|
31831
|
-
});
|
|
31832
|
-
ctx.stroke();
|
|
31833
|
-
});
|
|
31834
|
-
}
|
|
31835
|
-
function drawRotatedRect(ctx, centerX, centerY, width10, height10, rotationRad) {
|
|
31836
|
-
ctx.save();
|
|
31837
|
-
ctx.translate(centerX, centerY);
|
|
31838
|
-
ctx.rotate(-rotationRad);
|
|
31839
|
-
ctx.fillRect(-width10 / 2, -height10 / 2, width10, height10);
|
|
31840
|
-
ctx.restore();
|
|
31841
|
-
}
|
|
31842
|
-
function drawKnockoutText(ctx, text, outlines, metrics, transform2, rotationDeg, canvasXFromPcb, canvasYFromPcb, traceTextureResolution, copperColor) {
|
|
31843
|
-
const fontSize = typeof text.font_size === "number" ? text.font_size : 0.2;
|
|
31844
|
-
const padding = {
|
|
31845
|
-
left: parseDimension2(text.knockout_padding?.left, fontSize * 0.5),
|
|
31846
|
-
right: parseDimension2(text.knockout_padding?.right, fontSize * 0.5),
|
|
31847
|
-
top: parseDimension2(text.knockout_padding?.top, fontSize * 0.3),
|
|
31848
|
-
bottom: parseDimension2(text.knockout_padding?.bottom, fontSize * 0.3)
|
|
31849
|
-
};
|
|
31850
|
-
const rectWidth = metrics.width + padding.left + padding.right;
|
|
31851
|
-
const rectHeight = metrics.height + padding.top + padding.bottom;
|
|
31852
|
-
const rectCenterCanvasX = canvasXFromPcb(text.anchor_position.x);
|
|
31853
|
-
const rectCenterCanvasY = canvasYFromPcb(text.anchor_position.y);
|
|
31854
|
-
const rectWidthPx = rectWidth * traceTextureResolution;
|
|
31855
|
-
const rectHeightPx = rectHeight * traceTextureResolution;
|
|
31856
|
-
ctx.fillStyle = copperColor;
|
|
31857
|
-
const rotationRad = rotationDeg * Math.PI / 180;
|
|
31858
|
-
drawRotatedRect(
|
|
31859
|
-
ctx,
|
|
31860
|
-
rectCenterCanvasX,
|
|
31861
|
-
rectCenterCanvasY,
|
|
31862
|
-
rectWidthPx,
|
|
31863
|
-
rectHeightPx,
|
|
31864
|
-
rotationRad
|
|
31865
|
-
);
|
|
31866
|
-
const textOffset = {
|
|
31867
|
-
x: -metrics.centerX,
|
|
31868
|
-
y: -metrics.centerY
|
|
31869
|
-
};
|
|
31870
|
-
ctx.globalCompositeOperation = "destination-out";
|
|
31871
|
-
drawTextStrokes(
|
|
31872
|
-
ctx,
|
|
31873
|
-
outlines,
|
|
31874
|
-
transform2,
|
|
31875
|
-
textOffset,
|
|
31876
|
-
text.anchor_position,
|
|
31877
|
-
canvasXFromPcb,
|
|
31878
|
-
canvasYFromPcb
|
|
31879
|
-
);
|
|
31880
|
-
ctx.globalCompositeOperation = "source-over";
|
|
31881
|
-
}
|
|
31882
|
-
function createCopperTextTextureForLayer({
|
|
31883
|
-
layer,
|
|
31884
|
-
circuitJson,
|
|
31885
|
-
boardData,
|
|
31886
|
-
copperColor = "rgb(230, 153, 51)",
|
|
31887
|
-
// Same as colors.copper [0.9, 0.6, 0.2]
|
|
31888
|
-
traceTextureResolution
|
|
31889
|
-
}) {
|
|
31890
|
-
const copperTexts = circuitJson.filter(
|
|
31891
|
-
(e) => e.type === "pcb_copper_text"
|
|
31892
|
-
);
|
|
31893
|
-
const textsOnLayer = copperTexts.filter((t) => t.layer === layer);
|
|
31894
|
-
if (textsOnLayer.length === 0) {
|
|
31895
|
-
return null;
|
|
31896
|
-
}
|
|
31897
|
-
const boardOutlineBounds = calculateOutlineBounds(boardData);
|
|
31898
|
-
const canvas = document.createElement("canvas");
|
|
31899
|
-
const canvasWidth = Math.floor(
|
|
31900
|
-
boardOutlineBounds.width * traceTextureResolution
|
|
31901
|
-
);
|
|
31902
|
-
const canvasHeight = Math.floor(
|
|
31903
|
-
boardOutlineBounds.height * traceTextureResolution
|
|
31904
|
-
);
|
|
31905
|
-
canvas.width = canvasWidth;
|
|
31906
|
-
canvas.height = canvasHeight;
|
|
31907
|
-
const ctx = canvas.getContext("2d");
|
|
31908
|
-
if (!ctx) return null;
|
|
31909
|
-
if (layer === "bottom") {
|
|
31910
|
-
ctx.translate(0, canvasHeight);
|
|
31911
|
-
ctx.scale(1, -1);
|
|
31912
|
-
}
|
|
31913
|
-
ctx.strokeStyle = copperColor;
|
|
31914
|
-
ctx.fillStyle = copperColor;
|
|
31915
|
-
const canvasXFromPcb = (pcbX) => (pcbX - boardOutlineBounds.minX) * traceTextureResolution;
|
|
31916
|
-
const canvasYFromPcb = (pcbY) => (boardOutlineBounds.maxY - pcbY) * traceTextureResolution;
|
|
31917
|
-
textsOnLayer.forEach((textS) => {
|
|
31918
|
-
const fontSize = typeof textS.font_size === "number" ? textS.font_size : 0.2;
|
|
31919
|
-
const textStrokeWidth = Math.max(0.02, fontSize * 0.08) * traceTextureResolution;
|
|
31920
|
-
ctx.lineWidth = textStrokeWidth;
|
|
31921
|
-
ctx.lineCap = "round";
|
|
31922
|
-
ctx.lineJoin = "round";
|
|
31923
|
-
const rawTextOutlines = (0, import_text.vectorText)({
|
|
31924
|
-
height: fontSize * 0.45,
|
|
31925
|
-
input: textS.text
|
|
31926
|
-
});
|
|
31927
|
-
const processedOutlines = processTextOutlines(rawTextOutlines);
|
|
31928
|
-
const metrics = getTextMetrics(processedOutlines);
|
|
31929
|
-
const { matrix: transform2, rotationDeg } = buildTransformMatrix(
|
|
31930
|
-
textS,
|
|
31931
|
-
metrics
|
|
31932
|
-
);
|
|
31933
|
-
if (textS.is_knockout) {
|
|
31934
|
-
drawKnockoutText(
|
|
31935
|
-
ctx,
|
|
31936
|
-
textS,
|
|
31937
|
-
processedOutlines,
|
|
31938
|
-
metrics,
|
|
31939
|
-
transform2,
|
|
31940
|
-
rotationDeg,
|
|
31941
|
-
canvasXFromPcb,
|
|
31942
|
-
canvasYFromPcb,
|
|
31943
|
-
traceTextureResolution,
|
|
31944
|
-
copperColor
|
|
31945
|
-
);
|
|
31946
|
-
} else {
|
|
31947
|
-
const alignment = textS.anchor_alignment || "center";
|
|
31948
|
-
const offset4 = getAlignmentOffset(metrics, alignment);
|
|
31949
|
-
drawTextStrokes(
|
|
31950
|
-
ctx,
|
|
31951
|
-
processedOutlines,
|
|
31952
|
-
transform2,
|
|
31953
|
-
offset4,
|
|
31954
|
-
textS.anchor_position,
|
|
31955
|
-
canvasXFromPcb,
|
|
31956
|
-
canvasYFromPcb
|
|
31957
|
-
);
|
|
31958
|
-
}
|
|
31959
|
-
});
|
|
31960
|
-
const texture = new THREE19.CanvasTexture(canvas);
|
|
31961
|
-
texture.generateMipmaps = true;
|
|
31962
|
-
texture.minFilter = THREE19.LinearMipmapLinearFilter;
|
|
31963
|
-
texture.magFilter = THREE19.LinearFilter;
|
|
31964
|
-
texture.anisotropy = 16;
|
|
31965
|
-
texture.needsUpdate = true;
|
|
31966
|
-
return texture;
|
|
31967
|
-
}
|
|
31968
|
-
|
|
31969
31507
|
// src/utils/pad-texture.ts
|
|
31970
31508
|
import { su as su5 } from "@tscircuit/circuit-json-util";
|
|
31971
|
-
import * as
|
|
31509
|
+
import * as THREE19 from "three";
|
|
31972
31510
|
function createPadTextureForLayer({
|
|
31973
31511
|
layer,
|
|
31974
31512
|
circuitJson,
|
|
@@ -32091,17 +31629,17 @@ function createPadTextureForLayer({
|
|
|
32091
31629
|
ctx.restore();
|
|
32092
31630
|
}
|
|
32093
31631
|
});
|
|
32094
|
-
const texture = new
|
|
31632
|
+
const texture = new THREE19.CanvasTexture(canvas);
|
|
32095
31633
|
texture.generateMipmaps = true;
|
|
32096
|
-
texture.minFilter =
|
|
32097
|
-
texture.magFilter =
|
|
31634
|
+
texture.minFilter = THREE19.LinearMipmapLinearFilter;
|
|
31635
|
+
texture.magFilter = THREE19.LinearFilter;
|
|
32098
31636
|
texture.anisotropy = 16;
|
|
32099
31637
|
texture.needsUpdate = true;
|
|
32100
31638
|
return texture;
|
|
32101
31639
|
}
|
|
32102
31640
|
|
|
32103
31641
|
// src/utils/panel-outline-texture.ts
|
|
32104
|
-
import * as
|
|
31642
|
+
import * as THREE20 from "three";
|
|
32105
31643
|
import { su as su6 } from "@tscircuit/circuit-json-util";
|
|
32106
31644
|
function createPanelOutlineTextureForLayer({
|
|
32107
31645
|
layer,
|
|
@@ -32157,17 +31695,17 @@ function createPanelOutlineTextureForLayer({
|
|
|
32157
31695
|
);
|
|
32158
31696
|
}
|
|
32159
31697
|
});
|
|
32160
|
-
const texture = new
|
|
31698
|
+
const texture = new THREE20.CanvasTexture(canvas);
|
|
32161
31699
|
texture.generateMipmaps = true;
|
|
32162
|
-
texture.minFilter =
|
|
32163
|
-
texture.magFilter =
|
|
31700
|
+
texture.minFilter = THREE20.LinearMipmapLinearFilter;
|
|
31701
|
+
texture.magFilter = THREE20.LinearFilter;
|
|
32164
31702
|
texture.anisotropy = 16;
|
|
32165
31703
|
texture.needsUpdate = true;
|
|
32166
31704
|
return texture;
|
|
32167
31705
|
}
|
|
32168
31706
|
|
|
32169
31707
|
// src/utils/trace-texture.ts
|
|
32170
|
-
import * as
|
|
31708
|
+
import * as THREE21 from "three";
|
|
32171
31709
|
import { su as su7 } from "@tscircuit/circuit-json-util";
|
|
32172
31710
|
function isWireRoutePoint(point) {
|
|
32173
31711
|
return point && point.route_type === "wire" && typeof point.layer === "string" && typeof point.width === "number";
|
|
@@ -32280,6 +31818,127 @@ function createTraceTextureForLayer({
|
|
|
32280
31818
|
}
|
|
32281
31819
|
});
|
|
32282
31820
|
ctx.globalCompositeOperation = "source-over";
|
|
31821
|
+
const texture = new THREE21.CanvasTexture(canvas);
|
|
31822
|
+
texture.generateMipmaps = true;
|
|
31823
|
+
texture.minFilter = THREE21.LinearMipmapLinearFilter;
|
|
31824
|
+
texture.magFilter = THREE21.LinearFilter;
|
|
31825
|
+
texture.anisotropy = 16;
|
|
31826
|
+
texture.needsUpdate = true;
|
|
31827
|
+
return texture;
|
|
31828
|
+
}
|
|
31829
|
+
|
|
31830
|
+
// src/textures/create-copper-text-texture-for-layer.ts
|
|
31831
|
+
import * as THREE22 from "three";
|
|
31832
|
+
|
|
31833
|
+
// src/textures/copper-text/copper-text-drawing.ts
|
|
31834
|
+
import { CircuitToCanvasDrawer } from "circuit-to-canvas";
|
|
31835
|
+
var setDrawerBounds = (drawer, bounds) => {
|
|
31836
|
+
drawer.setCameraBounds({
|
|
31837
|
+
minX: bounds.minX,
|
|
31838
|
+
maxX: bounds.maxX,
|
|
31839
|
+
minY: bounds.minY,
|
|
31840
|
+
maxY: bounds.maxY
|
|
31841
|
+
});
|
|
31842
|
+
};
|
|
31843
|
+
var drawCopperTextLayer = ({
|
|
31844
|
+
ctx,
|
|
31845
|
+
layer,
|
|
31846
|
+
bounds,
|
|
31847
|
+
elements,
|
|
31848
|
+
copperColor
|
|
31849
|
+
}) => {
|
|
31850
|
+
const renderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
31851
|
+
const drawer = new CircuitToCanvasDrawer(ctx);
|
|
31852
|
+
drawer.configure({
|
|
31853
|
+
colorOverrides: {
|
|
31854
|
+
copper: {
|
|
31855
|
+
top: copperColor,
|
|
31856
|
+
bottom: copperColor,
|
|
31857
|
+
inner1: copperColor,
|
|
31858
|
+
inner2: copperColor,
|
|
31859
|
+
inner3: copperColor,
|
|
31860
|
+
inner4: copperColor,
|
|
31861
|
+
inner5: copperColor,
|
|
31862
|
+
inner6: copperColor
|
|
31863
|
+
}
|
|
31864
|
+
}
|
|
31865
|
+
});
|
|
31866
|
+
setDrawerBounds(drawer, bounds);
|
|
31867
|
+
drawer.drawElements(elements, {
|
|
31868
|
+
layers: [renderLayer]
|
|
31869
|
+
});
|
|
31870
|
+
const knockoutTexts = elements.filter(
|
|
31871
|
+
(element) => element.type === "pcb_copper_text" && element.is_knockout === true
|
|
31872
|
+
);
|
|
31873
|
+
if (knockoutTexts.length === 0) return;
|
|
31874
|
+
const maskCanvas = document.createElement("canvas");
|
|
31875
|
+
maskCanvas.width = ctx.canvas.width;
|
|
31876
|
+
maskCanvas.height = ctx.canvas.height;
|
|
31877
|
+
const maskCtx = maskCanvas.getContext("2d");
|
|
31878
|
+
if (!maskCtx) return;
|
|
31879
|
+
const knockoutCutoutDrawer = new CircuitToCanvasDrawer(maskCtx);
|
|
31880
|
+
knockoutCutoutDrawer.configure({
|
|
31881
|
+
colorOverrides: {
|
|
31882
|
+
copper: {
|
|
31883
|
+
top: "rgb(255,255,255)",
|
|
31884
|
+
bottom: "rgb(255,255,255)",
|
|
31885
|
+
inner1: "rgb(255,255,255)",
|
|
31886
|
+
inner2: "rgb(255,255,255)",
|
|
31887
|
+
inner3: "rgb(255,255,255)",
|
|
31888
|
+
inner4: "rgb(255,255,255)",
|
|
31889
|
+
inner5: "rgb(255,255,255)",
|
|
31890
|
+
inner6: "rgb(255,255,255)"
|
|
31891
|
+
}
|
|
31892
|
+
}
|
|
31893
|
+
});
|
|
31894
|
+
setDrawerBounds(knockoutCutoutDrawer, bounds);
|
|
31895
|
+
knockoutCutoutDrawer.drawElements(
|
|
31896
|
+
knockoutTexts.map((text) => ({
|
|
31897
|
+
...text,
|
|
31898
|
+
is_knockout: false
|
|
31899
|
+
})),
|
|
31900
|
+
{
|
|
31901
|
+
layers: [renderLayer]
|
|
31902
|
+
}
|
|
31903
|
+
);
|
|
31904
|
+
ctx.save();
|
|
31905
|
+
ctx.globalCompositeOperation = "destination-out";
|
|
31906
|
+
ctx.drawImage(maskCanvas, 0, 0);
|
|
31907
|
+
ctx.restore();
|
|
31908
|
+
};
|
|
31909
|
+
|
|
31910
|
+
// src/textures/create-copper-text-texture-for-layer.ts
|
|
31911
|
+
function createCopperTextTextureForLayer({
|
|
31912
|
+
layer,
|
|
31913
|
+
circuitJson,
|
|
31914
|
+
boardData,
|
|
31915
|
+
copperColor = "rgb(230, 153, 51)",
|
|
31916
|
+
traceTextureResolution = TRACE_TEXTURE_RESOLUTION
|
|
31917
|
+
}) {
|
|
31918
|
+
const elements = circuitJson.filter(
|
|
31919
|
+
(element) => element.type === "pcb_copper_text" && "layer" in element && element.layer === layer
|
|
31920
|
+
);
|
|
31921
|
+
if (elements.length === 0) return null;
|
|
31922
|
+
const bounds = calculateOutlineBounds(boardData);
|
|
31923
|
+
const canvasWidth = Math.floor(bounds.width * traceTextureResolution);
|
|
31924
|
+
const canvasHeight = Math.floor(bounds.height * traceTextureResolution);
|
|
31925
|
+
if (canvasWidth <= 0 || canvasHeight <= 0) return null;
|
|
31926
|
+
const canvas = document.createElement("canvas");
|
|
31927
|
+
canvas.width = canvasWidth;
|
|
31928
|
+
canvas.height = canvasHeight;
|
|
31929
|
+
const ctx = canvas.getContext("2d");
|
|
31930
|
+
if (!ctx) return null;
|
|
31931
|
+
if (layer === "bottom") {
|
|
31932
|
+
ctx.translate(0, canvasHeight);
|
|
31933
|
+
ctx.scale(1, -1);
|
|
31934
|
+
}
|
|
31935
|
+
drawCopperTextLayer({
|
|
31936
|
+
ctx,
|
|
31937
|
+
layer,
|
|
31938
|
+
bounds,
|
|
31939
|
+
elements,
|
|
31940
|
+
copperColor
|
|
31941
|
+
});
|
|
32283
31942
|
const texture = new THREE22.CanvasTexture(canvas);
|
|
32284
31943
|
texture.generateMipmaps = true;
|
|
32285
31944
|
texture.minFilter = THREE22.LinearMipmapLinearFilter;
|
|
@@ -32291,7 +31950,7 @@ function createTraceTextureForLayer({
|
|
|
32291
31950
|
|
|
32292
31951
|
// src/textures/create-copper-pour-texture-for-layer.ts
|
|
32293
31952
|
import * as THREE23 from "three";
|
|
32294
|
-
import { CircuitToCanvasDrawer } from "circuit-to-canvas";
|
|
31953
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer2 } from "circuit-to-canvas";
|
|
32295
31954
|
|
|
32296
31955
|
// src/geoms/brep-converter.ts
|
|
32297
31956
|
var import_primitives7 = __toESM(require_primitives(), 1);
|
|
@@ -32439,7 +32098,7 @@ function createCopperPourTextureForLayer({
|
|
|
32439
32098
|
);
|
|
32440
32099
|
const brepPours = poursOnLayer.filter((pour) => pour.shape === "brep");
|
|
32441
32100
|
if (rectAndPolygonPours.length > 0) {
|
|
32442
|
-
const drawer = new
|
|
32101
|
+
const drawer = new CircuitToCanvasDrawer2(ctx);
|
|
32443
32102
|
drawer.setCameraBounds({
|
|
32444
32103
|
minX: boardOutlineBounds.minX,
|
|
32445
32104
|
maxX: boardOutlineBounds.maxX,
|
|
@@ -32551,10 +32210,10 @@ var getSoldermaskRenderBounds = (circuitJson, boardData) => {
|
|
|
32551
32210
|
};
|
|
32552
32211
|
|
|
32553
32212
|
// src/textures/silkscreen/silkscreen-drawing.ts
|
|
32554
|
-
import { CircuitToCanvasDrawer as
|
|
32213
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer3 } from "circuit-to-canvas";
|
|
32555
32214
|
var FABRICATION_NOTE_COLOR = "rgb(255,243,204)";
|
|
32556
32215
|
var TRANSPARENT = "rgba(0,0,0,0)";
|
|
32557
|
-
var
|
|
32216
|
+
var setDrawerBounds2 = (drawer, bounds) => {
|
|
32558
32217
|
drawer.setCameraBounds({
|
|
32559
32218
|
minX: bounds.minX,
|
|
32560
32219
|
maxX: bounds.maxX,
|
|
@@ -32570,7 +32229,7 @@ var drawSilkscreenLayer = ({
|
|
|
32570
32229
|
silkscreenColor
|
|
32571
32230
|
}) => {
|
|
32572
32231
|
const renderLayer = layer === "top" ? "top_silkscreen" : "bottom_silkscreen";
|
|
32573
|
-
const drawer = new
|
|
32232
|
+
const drawer = new CircuitToCanvasDrawer3(ctx);
|
|
32574
32233
|
drawer.configure({
|
|
32575
32234
|
colorOverrides: {
|
|
32576
32235
|
copper: {
|
|
@@ -32614,7 +32273,7 @@ var drawSilkscreenLayer = ({
|
|
|
32614
32273
|
fabricationNote: FABRICATION_NOTE_COLOR
|
|
32615
32274
|
}
|
|
32616
32275
|
});
|
|
32617
|
-
|
|
32276
|
+
setDrawerBounds2(drawer, bounds);
|
|
32618
32277
|
drawer.drawElements(elements, {
|
|
32619
32278
|
layers: [renderLayer]
|
|
32620
32279
|
});
|
|
@@ -32670,7 +32329,7 @@ function createSilkscreenTextureForLayer({
|
|
|
32670
32329
|
import * as THREE25 from "three";
|
|
32671
32330
|
|
|
32672
32331
|
// src/textures/soldermask/soldermask-drawing.ts
|
|
32673
|
-
import { CircuitToCanvasDrawer as
|
|
32332
|
+
import { CircuitToCanvasDrawer as CircuitToCanvasDrawer4 } from "circuit-to-canvas";
|
|
32674
32333
|
var toRgb = (colorArr) => {
|
|
32675
32334
|
const [r = 0, g = 0, b = 0] = colorArr;
|
|
32676
32335
|
return `rgb(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(
|
|
@@ -32689,7 +32348,7 @@ var getSoldermaskPalette = (material) => {
|
|
|
32689
32348
|
transparent: "rgba(0,0,0,0)"
|
|
32690
32349
|
};
|
|
32691
32350
|
};
|
|
32692
|
-
var
|
|
32351
|
+
var setDrawerBounds3 = (drawer, bounds) => {
|
|
32693
32352
|
drawer.setCameraBounds({
|
|
32694
32353
|
minX: bounds.minX,
|
|
32695
32354
|
maxX: bounds.maxX,
|
|
@@ -32706,7 +32365,7 @@ var drawSoldermaskLayer = ({
|
|
|
32706
32365
|
}) => {
|
|
32707
32366
|
const palette = getSoldermaskPalette(boardMaterial);
|
|
32708
32367
|
const copperRenderLayer = layer === "top" ? "top_copper" : "bottom_copper";
|
|
32709
|
-
const drawer = new
|
|
32368
|
+
const drawer = new CircuitToCanvasDrawer4(ctx);
|
|
32710
32369
|
drawer.configure({
|
|
32711
32370
|
colorOverrides: {
|
|
32712
32371
|
copper: {
|
|
@@ -32737,7 +32396,7 @@ var drawSoldermaskLayer = ({
|
|
|
32737
32396
|
}
|
|
32738
32397
|
}
|
|
32739
32398
|
});
|
|
32740
|
-
|
|
32399
|
+
setDrawerBounds3(drawer, bounds);
|
|
32741
32400
|
drawer.drawElements(elements, {
|
|
32742
32401
|
layers: [copperRenderLayer],
|
|
32743
32402
|
drawSoldermask: true,
|
|
@@ -32750,7 +32409,7 @@ var drawSoldermaskLayer = ({
|
|
|
32750
32409
|
if (uncoveredPours.length > 0) {
|
|
32751
32410
|
ctx.save();
|
|
32752
32411
|
ctx.globalCompositeOperation = "destination-out";
|
|
32753
|
-
const cutoutDrawer = new
|
|
32412
|
+
const cutoutDrawer = new CircuitToCanvasDrawer4(ctx);
|
|
32754
32413
|
cutoutDrawer.configure({
|
|
32755
32414
|
colorOverrides: {
|
|
32756
32415
|
copper: {
|
|
@@ -32765,7 +32424,7 @@ var drawSoldermaskLayer = ({
|
|
|
32765
32424
|
}
|
|
32766
32425
|
}
|
|
32767
32426
|
});
|
|
32768
|
-
|
|
32427
|
+
setDrawerBounds3(cutoutDrawer, bounds);
|
|
32769
32428
|
cutoutDrawer.drawElements(uncoveredPours, { layers: [copperRenderLayer] });
|
|
32770
32429
|
ctx.restore();
|
|
32771
32430
|
}
|
|
@@ -32914,9 +32573,9 @@ function createCombinedBoardTextures({
|
|
|
32914
32573
|
textures: [
|
|
32915
32574
|
copperPourTexture,
|
|
32916
32575
|
traceTexture,
|
|
32917
|
-
copperTextTexture,
|
|
32918
32576
|
padTexture,
|
|
32919
32577
|
soldermaskTexture,
|
|
32578
|
+
copperTextTexture,
|
|
32920
32579
|
silkscreenTexture,
|
|
32921
32580
|
panelOutlineTexture
|
|
32922
32581
|
],
|
|
@@ -37592,21 +37251,21 @@ function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetPar
|
|
|
37592
37251
|
}
|
|
37593
37252
|
const clientRect = element.getBoundingClientRect();
|
|
37594
37253
|
const domElement = unwrapElement(element);
|
|
37595
|
-
let
|
|
37254
|
+
let scale2 = createCoords(1);
|
|
37596
37255
|
if (includeScale) {
|
|
37597
37256
|
if (offsetParent) {
|
|
37598
37257
|
if (isElement(offsetParent)) {
|
|
37599
|
-
|
|
37258
|
+
scale2 = getScale(offsetParent);
|
|
37600
37259
|
}
|
|
37601
37260
|
} else {
|
|
37602
|
-
|
|
37261
|
+
scale2 = getScale(element);
|
|
37603
37262
|
}
|
|
37604
37263
|
}
|
|
37605
37264
|
const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
|
|
37606
|
-
let x = (clientRect.left + visualOffsets.x) /
|
|
37607
|
-
let y = (clientRect.top + visualOffsets.y) /
|
|
37608
|
-
let width10 = clientRect.width /
|
|
37609
|
-
let height10 = clientRect.height /
|
|
37265
|
+
let x = (clientRect.left + visualOffsets.x) / scale2.x;
|
|
37266
|
+
let y = (clientRect.top + visualOffsets.y) / scale2.y;
|
|
37267
|
+
let width10 = clientRect.width / scale2.x;
|
|
37268
|
+
let height10 = clientRect.height / scale2.y;
|
|
37610
37269
|
if (domElement) {
|
|
37611
37270
|
const win = getWindow(domElement);
|
|
37612
37271
|
const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
|
|
@@ -37668,7 +37327,7 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
37668
37327
|
scrollLeft: 0,
|
|
37669
37328
|
scrollTop: 0
|
|
37670
37329
|
};
|
|
37671
|
-
let
|
|
37330
|
+
let scale2 = createCoords(1);
|
|
37672
37331
|
const offsets = createCoords(0);
|
|
37673
37332
|
const isOffsetParentAnElement = isHTMLElement(offsetParent);
|
|
37674
37333
|
if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
|
|
@@ -37677,17 +37336,17 @@ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
|
|
|
37677
37336
|
}
|
|
37678
37337
|
if (isHTMLElement(offsetParent)) {
|
|
37679
37338
|
const offsetRect = getBoundingClientRect(offsetParent);
|
|
37680
|
-
|
|
37339
|
+
scale2 = getScale(offsetParent);
|
|
37681
37340
|
offsets.x = offsetRect.x + offsetParent.clientLeft;
|
|
37682
37341
|
offsets.y = offsetRect.y + offsetParent.clientTop;
|
|
37683
37342
|
}
|
|
37684
37343
|
}
|
|
37685
37344
|
const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
|
|
37686
37345
|
return {
|
|
37687
|
-
width: rect.width *
|
|
37688
|
-
height: rect.height *
|
|
37689
|
-
x: rect.x *
|
|
37690
|
-
y: rect.y *
|
|
37346
|
+
width: rect.width * scale2.x,
|
|
37347
|
+
height: rect.height * scale2.y,
|
|
37348
|
+
x: rect.x * scale2.x - scroll.scrollLeft * scale2.x + offsets.x + htmlOffset.x,
|
|
37349
|
+
y: rect.y * scale2.y - scroll.scrollTop * scale2.y + offsets.y + htmlOffset.y
|
|
37691
37350
|
};
|
|
37692
37351
|
}
|
|
37693
37352
|
function getClientRects(element) {
|
|
@@ -37754,11 +37413,11 @@ function getInnerBoundingClientRect(element, strategy) {
|
|
|
37754
37413
|
const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
|
|
37755
37414
|
const top = clientRect.top + element.clientTop;
|
|
37756
37415
|
const left = clientRect.left + element.clientLeft;
|
|
37757
|
-
const
|
|
37758
|
-
const width10 = element.clientWidth *
|
|
37759
|
-
const height10 = element.clientHeight *
|
|
37760
|
-
const x = left *
|
|
37761
|
-
const y = top *
|
|
37416
|
+
const scale2 = isHTMLElement(element) ? getScale(element) : createCoords(1);
|
|
37417
|
+
const width10 = element.clientWidth * scale2.x;
|
|
37418
|
+
const height10 = element.clientHeight * scale2.y;
|
|
37419
|
+
const x = left * scale2.x;
|
|
37420
|
+
const y = top * scale2.y;
|
|
37762
37421
|
return {
|
|
37763
37422
|
width: width10,
|
|
37764
37423
|
height: height10,
|
|
@@ -38214,7 +37873,7 @@ function useFloating(options) {
|
|
|
38214
37873
|
reference: externalReference,
|
|
38215
37874
|
floating: externalFloating
|
|
38216
37875
|
} = {},
|
|
38217
|
-
transform
|
|
37876
|
+
transform = true,
|
|
38218
37877
|
whileElementsMounted,
|
|
38219
37878
|
open
|
|
38220
37879
|
} = options;
|
|
@@ -38329,7 +37988,7 @@ function useFloating(options) {
|
|
|
38329
37988
|
}
|
|
38330
37989
|
const x = roundByDPR(elements.floating, data.x);
|
|
38331
37990
|
const y = roundByDPR(elements.floating, data.y);
|
|
38332
|
-
if (
|
|
37991
|
+
if (transform) {
|
|
38333
37992
|
return {
|
|
38334
37993
|
...initialStyles,
|
|
38335
37994
|
transform: "translate(" + x + "px, " + y + "px)",
|
|
@@ -38343,7 +38002,7 @@ function useFloating(options) {
|
|
|
38343
38002
|
left: x,
|
|
38344
38003
|
top: y
|
|
38345
38004
|
};
|
|
38346
|
-
}, [strategy,
|
|
38005
|
+
}, [strategy, transform, elements.floating, data.x, data.y]);
|
|
38347
38006
|
return React28.useMemo(() => ({
|
|
38348
38007
|
...data,
|
|
38349
38008
|
update,
|
|
@@ -42425,8 +42084,8 @@ async function convertCircuitJsonTo3dSvg(circuitJson, options = {}) {
|
|
|
42425
42084
|
scene.position.sub(center);
|
|
42426
42085
|
const maxDim = Math.max(size4.x, size4.y, size4.z);
|
|
42427
42086
|
if (maxDim > 0) {
|
|
42428
|
-
const
|
|
42429
|
-
scene.scale.multiplyScalar(
|
|
42087
|
+
const scale2 = (1 - padding / 100) / maxDim;
|
|
42088
|
+
scene.scale.multiplyScalar(scale2 * 100);
|
|
42430
42089
|
}
|
|
42431
42090
|
camera.updateProjectionMatrix();
|
|
42432
42091
|
renderer.render(scene, camera);
|