circuit-json-to-gltf 0.0.142 → 0.0.144
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 +950 -683
- package/package.json +6 -5
package/dist/index.js
CHANGED
|
@@ -263,29 +263,29 @@ var require_fromRotation = __commonJS({
|
|
|
263
263
|
var { sin, cos } = require_trigonometry();
|
|
264
264
|
var identity = require_identity();
|
|
265
265
|
var fromRotation = (out, rad, axis) => {
|
|
266
|
-
let [x, y,
|
|
267
|
-
const lengthSquared = x * x + y * y +
|
|
266
|
+
let [x, y, z3] = axis;
|
|
267
|
+
const lengthSquared = x * x + y * y + z3 * z3;
|
|
268
268
|
if (Math.abs(lengthSquared) < EPS4) {
|
|
269
269
|
return identity(out);
|
|
270
270
|
}
|
|
271
271
|
const len = 1 / Math.sqrt(lengthSquared);
|
|
272
272
|
x *= len;
|
|
273
273
|
y *= len;
|
|
274
|
-
|
|
274
|
+
z3 *= len;
|
|
275
275
|
const s = sin(rad);
|
|
276
276
|
const c = cos(rad);
|
|
277
277
|
const t = 1 - c;
|
|
278
278
|
out[0] = x * x * t + c;
|
|
279
|
-
out[1] = y * x * t +
|
|
280
|
-
out[2] =
|
|
279
|
+
out[1] = y * x * t + z3 * s;
|
|
280
|
+
out[2] = z3 * x * t - y * s;
|
|
281
281
|
out[3] = 0;
|
|
282
|
-
out[4] = x * y * t -
|
|
282
|
+
out[4] = x * y * t - z3 * s;
|
|
283
283
|
out[5] = y * y * t + c;
|
|
284
|
-
out[6] =
|
|
284
|
+
out[6] = z3 * y * t + x * s;
|
|
285
285
|
out[7] = 0;
|
|
286
|
-
out[8] = x *
|
|
287
|
-
out[9] = y *
|
|
288
|
-
out[10] =
|
|
286
|
+
out[8] = x * z3 * t + y * s;
|
|
287
|
+
out[9] = y * z3 * t - x * s;
|
|
288
|
+
out[10] = z3 * z3 * t + c;
|
|
289
289
|
out[11] = 0;
|
|
290
290
|
out[12] = 0;
|
|
291
291
|
out[13] = 0;
|
|
@@ -539,8 +539,8 @@ var require_distance = __commonJS({
|
|
|
539
539
|
var distance = (a, b) => {
|
|
540
540
|
const x = b[0] - a[0];
|
|
541
541
|
const y = b[1] - a[1];
|
|
542
|
-
const
|
|
543
|
-
return Math.sqrt(x * x + y * y +
|
|
542
|
+
const z3 = b[2] - a[2];
|
|
543
|
+
return Math.sqrt(x * x + y * y + z3 * z3);
|
|
544
544
|
};
|
|
545
545
|
module.exports = distance;
|
|
546
546
|
}
|
|
@@ -588,11 +588,11 @@ var require_fromValues2 = __commonJS({
|
|
|
588
588
|
"node_modules/@jscad/modeling/src/maths/vec3/fromValues.js"(exports, module) {
|
|
589
589
|
"use strict";
|
|
590
590
|
var create = require_create2();
|
|
591
|
-
var fromValues = (x, y,
|
|
591
|
+
var fromValues = (x, y, z3) => {
|
|
592
592
|
const out = create();
|
|
593
593
|
out[0] = x;
|
|
594
594
|
out[1] = y;
|
|
595
|
-
out[2] =
|
|
595
|
+
out[2] = z3;
|
|
596
596
|
return out;
|
|
597
597
|
};
|
|
598
598
|
module.exports = fromValues;
|
|
@@ -603,10 +603,10 @@ var require_fromValues2 = __commonJS({
|
|
|
603
603
|
var require_fromVec2 = __commonJS({
|
|
604
604
|
"node_modules/@jscad/modeling/src/maths/vec3/fromVec2.js"(exports, module) {
|
|
605
605
|
"use strict";
|
|
606
|
-
var fromVector2 = (out, vector,
|
|
606
|
+
var fromVector2 = (out, vector, z3 = 0) => {
|
|
607
607
|
out[0] = vector[0];
|
|
608
608
|
out[1] = vector[1];
|
|
609
|
-
out[2] =
|
|
609
|
+
out[2] = z3;
|
|
610
610
|
return out;
|
|
611
611
|
};
|
|
612
612
|
module.exports = fromVector2;
|
|
@@ -620,8 +620,8 @@ var require_length = __commonJS({
|
|
|
620
620
|
var length = (vector) => {
|
|
621
621
|
const x = vector[0];
|
|
622
622
|
const y = vector[1];
|
|
623
|
-
const
|
|
624
|
-
return Math.sqrt(x * x + y * y +
|
|
623
|
+
const z3 = vector[2];
|
|
624
|
+
return Math.sqrt(x * x + y * y + z3 * z3);
|
|
625
625
|
};
|
|
626
626
|
module.exports = length;
|
|
627
627
|
}
|
|
@@ -704,14 +704,14 @@ var require_normalize = __commonJS({
|
|
|
704
704
|
var normalize = (out, vector) => {
|
|
705
705
|
const x = vector[0];
|
|
706
706
|
const y = vector[1];
|
|
707
|
-
const
|
|
708
|
-
let len = x * x + y * y +
|
|
707
|
+
const z3 = vector[2];
|
|
708
|
+
let len = x * x + y * y + z3 * z3;
|
|
709
709
|
if (len > 0) {
|
|
710
710
|
len = 1 / Math.sqrt(len);
|
|
711
711
|
}
|
|
712
712
|
out[0] = x * len;
|
|
713
713
|
out[1] = y * len;
|
|
714
|
-
out[2] =
|
|
714
|
+
out[2] = z3 * len;
|
|
715
715
|
return out;
|
|
716
716
|
};
|
|
717
717
|
module.exports = normalize;
|
|
@@ -835,8 +835,8 @@ var require_squaredDistance = __commonJS({
|
|
|
835
835
|
var squaredDistance = (a, b) => {
|
|
836
836
|
const x = b[0] - a[0];
|
|
837
837
|
const y = b[1] - a[1];
|
|
838
|
-
const
|
|
839
|
-
return x * x + y * y +
|
|
838
|
+
const z3 = b[2] - a[2];
|
|
839
|
+
return x * x + y * y + z3 * z3;
|
|
840
840
|
};
|
|
841
841
|
module.exports = squaredDistance;
|
|
842
842
|
}
|
|
@@ -849,8 +849,8 @@ var require_squaredLength = __commonJS({
|
|
|
849
849
|
var squaredLength = (vector) => {
|
|
850
850
|
const x = vector[0];
|
|
851
851
|
const y = vector[1];
|
|
852
|
-
const
|
|
853
|
-
return x * x + y * y +
|
|
852
|
+
const z3 = vector[2];
|
|
853
|
+
return x * x + y * y + z3 * z3;
|
|
854
854
|
};
|
|
855
855
|
module.exports = squaredLength;
|
|
856
856
|
}
|
|
@@ -886,12 +886,12 @@ var require_transform = __commonJS({
|
|
|
886
886
|
var transform = (out, vector, matrix) => {
|
|
887
887
|
const x = vector[0];
|
|
888
888
|
const y = vector[1];
|
|
889
|
-
const
|
|
890
|
-
let w = matrix[3] * x + matrix[7] * y + matrix[11] *
|
|
889
|
+
const z3 = vector[2];
|
|
890
|
+
let w = matrix[3] * x + matrix[7] * y + matrix[11] * z3 + matrix[15];
|
|
891
891
|
w = w || 1;
|
|
892
|
-
out[0] = (matrix[0] * x + matrix[4] * y + matrix[8] *
|
|
893
|
-
out[1] = (matrix[1] * x + matrix[5] * y + matrix[9] *
|
|
894
|
-
out[2] = (matrix[2] * x + matrix[6] * y + matrix[10] *
|
|
892
|
+
out[0] = (matrix[0] * x + matrix[4] * y + matrix[8] * z3 + matrix[12]) / w;
|
|
893
|
+
out[1] = (matrix[1] * x + matrix[5] * y + matrix[9] * z3 + matrix[13]) / w;
|
|
894
|
+
out[2] = (matrix[2] * x + matrix[6] * y + matrix[10] * z3 + matrix[14]) / w;
|
|
895
895
|
return out;
|
|
896
896
|
};
|
|
897
897
|
module.exports = transform;
|
|
@@ -943,14 +943,14 @@ var require_vec3 = __commonJS({
|
|
|
943
943
|
var require_fromVectorRotation = __commonJS({
|
|
944
944
|
"node_modules/@jscad/modeling/src/maths/mat4/fromVectorRotation.js"(exports, module) {
|
|
945
945
|
"use strict";
|
|
946
|
-
var
|
|
946
|
+
var vec32 = require_vec3();
|
|
947
947
|
var fromRotation = require_fromRotation();
|
|
948
948
|
var fromVectorRotation = (out, source, target) => {
|
|
949
|
-
const sourceNormal =
|
|
950
|
-
const targetNormal =
|
|
951
|
-
const axis =
|
|
952
|
-
const cosA =
|
|
953
|
-
if (cosA === -1) return fromRotation(out, Math.PI,
|
|
949
|
+
const sourceNormal = vec32.normalize(vec32.create(), source);
|
|
950
|
+
const targetNormal = vec32.normalize(vec32.create(), target);
|
|
951
|
+
const axis = vec32.cross(vec32.create(), targetNormal, sourceNormal);
|
|
952
|
+
const cosA = vec32.dot(targetNormal, sourceNormal);
|
|
953
|
+
if (cosA === -1) return fromRotation(out, Math.PI, vec32.orthogonal(axis, sourceNormal));
|
|
954
954
|
const k = 1 / (1 + cosA);
|
|
955
955
|
out[0] = axis[0] * axis[0] * k + cosA;
|
|
956
956
|
out[1] = axis[1] * axis[0] * k - axis[2];
|
|
@@ -1093,8 +1093,8 @@ var require_isMirroring = __commonJS({
|
|
|
1093
1093
|
var isMirroring = (matrix) => {
|
|
1094
1094
|
const x = matrix[4] * matrix[9] - matrix[8] * matrix[5];
|
|
1095
1095
|
const y = matrix[8] * matrix[1] - matrix[0] * matrix[9];
|
|
1096
|
-
const
|
|
1097
|
-
const d = x * matrix[2] + y * matrix[6] +
|
|
1096
|
+
const z3 = matrix[0] * matrix[5] - matrix[4] * matrix[1];
|
|
1097
|
+
const d = x * matrix[2] + y * matrix[6] + z3 * matrix[10];
|
|
1098
1098
|
return d < 0;
|
|
1099
1099
|
};
|
|
1100
1100
|
module.exports = isMirroring;
|
|
@@ -1196,15 +1196,15 @@ var require_rotate = __commonJS({
|
|
|
1196
1196
|
var { sin, cos } = require_trigonometry();
|
|
1197
1197
|
var copy = require_copy();
|
|
1198
1198
|
var rotate = (out, matrix, radians, axis) => {
|
|
1199
|
-
let [x, y,
|
|
1200
|
-
const lengthSquared = x * x + y * y +
|
|
1199
|
+
let [x, y, z3] = axis;
|
|
1200
|
+
const lengthSquared = x * x + y * y + z3 * z3;
|
|
1201
1201
|
if (Math.abs(lengthSquared) < EPS4) {
|
|
1202
1202
|
return copy(out, matrix);
|
|
1203
1203
|
}
|
|
1204
1204
|
const len = 1 / Math.sqrt(lengthSquared);
|
|
1205
1205
|
x *= len;
|
|
1206
1206
|
y *= len;
|
|
1207
|
-
|
|
1207
|
+
z3 *= len;
|
|
1208
1208
|
const s = sin(radians);
|
|
1209
1209
|
const c = cos(radians);
|
|
1210
1210
|
const t = 1 - c;
|
|
@@ -1221,14 +1221,14 @@ var require_rotate = __commonJS({
|
|
|
1221
1221
|
const a22 = matrix[10];
|
|
1222
1222
|
const a23 = matrix[11];
|
|
1223
1223
|
const b00 = x * x * t + c;
|
|
1224
|
-
const b01 = y * x * t +
|
|
1225
|
-
const b02 =
|
|
1226
|
-
const b10 = x * y * t -
|
|
1224
|
+
const b01 = y * x * t + z3 * s;
|
|
1225
|
+
const b02 = z3 * x * t - y * s;
|
|
1226
|
+
const b10 = x * y * t - z3 * s;
|
|
1227
1227
|
const b11 = y * y * t + c;
|
|
1228
|
-
const b12 =
|
|
1229
|
-
const b20 = x *
|
|
1230
|
-
const b21 = y *
|
|
1231
|
-
const b22 =
|
|
1228
|
+
const b12 = z3 * y * t + x * s;
|
|
1229
|
+
const b20 = x * z3 * t + y * s;
|
|
1230
|
+
const b21 = y * z3 * t - x * s;
|
|
1231
|
+
const b22 = z3 * z3 * t + c;
|
|
1232
1232
|
out[0] = a00 * b00 + a10 * b01 + a20 * b02;
|
|
1233
1233
|
out[1] = a01 * b00 + a11 * b01 + a21 * b02;
|
|
1234
1234
|
out[2] = a02 * b00 + a12 * b01 + a22 * b02;
|
|
@@ -1380,7 +1380,7 @@ var require_scale2 = __commonJS({
|
|
|
1380
1380
|
var scale = (out, matrix, dimensions) => {
|
|
1381
1381
|
const x = dimensions[0];
|
|
1382
1382
|
const y = dimensions[1];
|
|
1383
|
-
const
|
|
1383
|
+
const z3 = dimensions[2];
|
|
1384
1384
|
out[0] = matrix[0] * x;
|
|
1385
1385
|
out[1] = matrix[1] * x;
|
|
1386
1386
|
out[2] = matrix[2] * x;
|
|
@@ -1389,10 +1389,10 @@ var require_scale2 = __commonJS({
|
|
|
1389
1389
|
out[5] = matrix[5] * y;
|
|
1390
1390
|
out[6] = matrix[6] * y;
|
|
1391
1391
|
out[7] = matrix[7] * y;
|
|
1392
|
-
out[8] = matrix[8] *
|
|
1393
|
-
out[9] = matrix[9] *
|
|
1394
|
-
out[10] = matrix[10] *
|
|
1395
|
-
out[11] = matrix[11] *
|
|
1392
|
+
out[8] = matrix[8] * z3;
|
|
1393
|
+
out[9] = matrix[9] * z3;
|
|
1394
|
+
out[10] = matrix[10] * z3;
|
|
1395
|
+
out[11] = matrix[11] * z3;
|
|
1396
1396
|
out[12] = matrix[12];
|
|
1397
1397
|
out[13] = matrix[13];
|
|
1398
1398
|
out[14] = matrix[14];
|
|
@@ -1446,7 +1446,7 @@ var require_translate = __commonJS({
|
|
|
1446
1446
|
var translate3 = (out, matrix, offsets) => {
|
|
1447
1447
|
const x = offsets[0];
|
|
1448
1448
|
const y = offsets[1];
|
|
1449
|
-
const
|
|
1449
|
+
const z3 = offsets[2];
|
|
1450
1450
|
let a00;
|
|
1451
1451
|
let a01;
|
|
1452
1452
|
let a02;
|
|
@@ -1460,10 +1460,10 @@ var require_translate = __commonJS({
|
|
|
1460
1460
|
let a22;
|
|
1461
1461
|
let a23;
|
|
1462
1462
|
if (matrix === out) {
|
|
1463
|
-
out[12] = matrix[0] * x + matrix[4] * y + matrix[8] *
|
|
1464
|
-
out[13] = matrix[1] * x + matrix[5] * y + matrix[9] *
|
|
1465
|
-
out[14] = matrix[2] * x + matrix[6] * y + matrix[10] *
|
|
1466
|
-
out[15] = matrix[3] * x + matrix[7] * y + matrix[11] *
|
|
1463
|
+
out[12] = matrix[0] * x + matrix[4] * y + matrix[8] * z3 + matrix[12];
|
|
1464
|
+
out[13] = matrix[1] * x + matrix[5] * y + matrix[9] * z3 + matrix[13];
|
|
1465
|
+
out[14] = matrix[2] * x + matrix[6] * y + matrix[10] * z3 + matrix[14];
|
|
1466
|
+
out[15] = matrix[3] * x + matrix[7] * y + matrix[11] * z3 + matrix[15];
|
|
1467
1467
|
} else {
|
|
1468
1468
|
a00 = matrix[0];
|
|
1469
1469
|
a01 = matrix[1];
|
|
@@ -1489,10 +1489,10 @@ var require_translate = __commonJS({
|
|
|
1489
1489
|
out[9] = a21;
|
|
1490
1490
|
out[10] = a22;
|
|
1491
1491
|
out[11] = a23;
|
|
1492
|
-
out[12] = a00 * x + a10 * y + a20 *
|
|
1493
|
-
out[13] = a01 * x + a11 * y + a21 *
|
|
1494
|
-
out[14] = a02 * x + a12 * y + a22 *
|
|
1495
|
-
out[15] = a03 * x + a13 * y + a23 *
|
|
1492
|
+
out[12] = a00 * x + a10 * y + a20 * z3 + matrix[12];
|
|
1493
|
+
out[13] = a01 * x + a11 * y + a21 * z3 + matrix[13];
|
|
1494
|
+
out[14] = a02 * x + a12 * y + a22 * z3 + matrix[14];
|
|
1495
|
+
out[15] = a03 * x + a13 * y + a23 * z3 + matrix[15];
|
|
1496
1496
|
}
|
|
1497
1497
|
return out;
|
|
1498
1498
|
};
|
|
@@ -2266,8 +2266,8 @@ var require_toCompactBinary = __commonJS({
|
|
|
2266
2266
|
var toCompactBinary = (geometry) => {
|
|
2267
2267
|
const sides = geometry.sides;
|
|
2268
2268
|
const transforms = geometry.transforms;
|
|
2269
|
-
let
|
|
2270
|
-
if (geometry.color)
|
|
2269
|
+
let color3 = [-1, -1, -1, -1];
|
|
2270
|
+
if (geometry.color) color3 = geometry.color;
|
|
2271
2271
|
const compacted = new Float32Array(1 + 16 + 4 + sides.length * 4);
|
|
2272
2272
|
compacted[0] = 0;
|
|
2273
2273
|
compacted[1] = transforms[0];
|
|
@@ -2286,10 +2286,10 @@ var require_toCompactBinary = __commonJS({
|
|
|
2286
2286
|
compacted[14] = transforms[13];
|
|
2287
2287
|
compacted[15] = transforms[14];
|
|
2288
2288
|
compacted[16] = transforms[15];
|
|
2289
|
-
compacted[17] =
|
|
2290
|
-
compacted[18] =
|
|
2291
|
-
compacted[19] =
|
|
2292
|
-
compacted[20] =
|
|
2289
|
+
compacted[17] = color3[0];
|
|
2290
|
+
compacted[18] = color3[1];
|
|
2291
|
+
compacted[19] = color3[2];
|
|
2292
|
+
compacted[20] = color3[3];
|
|
2293
2293
|
for (let i = 0; i < sides.length; i++) {
|
|
2294
2294
|
const ci = i * 4 + 21;
|
|
2295
2295
|
const point0 = sides[i][0];
|
|
@@ -3428,7 +3428,7 @@ var require_clone6 = __commonJS({
|
|
|
3428
3428
|
"node_modules/@jscad/modeling/src/geometries/poly3/clone.js"(exports, module) {
|
|
3429
3429
|
"use strict";
|
|
3430
3430
|
var create = require_create6();
|
|
3431
|
-
var
|
|
3431
|
+
var vec32 = require_vec3();
|
|
3432
3432
|
var clone = (...params) => {
|
|
3433
3433
|
let out;
|
|
3434
3434
|
let poly3;
|
|
@@ -3439,7 +3439,7 @@ var require_clone6 = __commonJS({
|
|
|
3439
3439
|
out = params[0];
|
|
3440
3440
|
poly3 = params[1];
|
|
3441
3441
|
}
|
|
3442
|
-
out.vertices = poly3.vertices.map((vec) =>
|
|
3442
|
+
out.vertices = poly3.vertices.map((vec) => vec32.clone(vec));
|
|
3443
3443
|
return out;
|
|
3444
3444
|
};
|
|
3445
3445
|
module.exports = clone;
|
|
@@ -3450,10 +3450,10 @@ var require_clone6 = __commonJS({
|
|
|
3450
3450
|
var require_fromPoints2 = __commonJS({
|
|
3451
3451
|
"node_modules/@jscad/modeling/src/geometries/poly3/fromPoints.js"(exports, module) {
|
|
3452
3452
|
"use strict";
|
|
3453
|
-
var
|
|
3453
|
+
var vec32 = require_vec3();
|
|
3454
3454
|
var create = require_create6();
|
|
3455
3455
|
var fromPoints = (points) => {
|
|
3456
|
-
const vertices = points.map((point) =>
|
|
3456
|
+
const vertices = points.map((point) => vec32.clone(point));
|
|
3457
3457
|
return create(vertices);
|
|
3458
3458
|
};
|
|
3459
3459
|
module.exports = fromPoints;
|
|
@@ -3543,10 +3543,10 @@ var require_flip = __commonJS({
|
|
|
3543
3543
|
var require_fromNormalAndPoint = __commonJS({
|
|
3544
3544
|
"node_modules/@jscad/modeling/src/maths/plane/fromNormalAndPoint.js"(exports, module) {
|
|
3545
3545
|
"use strict";
|
|
3546
|
-
var
|
|
3546
|
+
var vec32 = require_vec3();
|
|
3547
3547
|
var fromNormalAndPoint = (out, normal, point) => {
|
|
3548
|
-
const u =
|
|
3549
|
-
const w =
|
|
3548
|
+
const u = vec32.normalize(vec32.create(), normal);
|
|
3549
|
+
const w = vec32.dot(point, u);
|
|
3550
3550
|
out[0] = u[0];
|
|
3551
3551
|
out[1] = u[1];
|
|
3552
3552
|
out[2] = u[2];
|
|
@@ -3562,11 +3562,11 @@ var require_fromValues4 = __commonJS({
|
|
|
3562
3562
|
"node_modules/@jscad/modeling/src/maths/vec4/fromValues.js"(exports, module) {
|
|
3563
3563
|
"use strict";
|
|
3564
3564
|
var create = require_create7();
|
|
3565
|
-
var fromValues = (x, y,
|
|
3565
|
+
var fromValues = (x, y, z3, w) => {
|
|
3566
3566
|
const out = create();
|
|
3567
3567
|
out[0] = x;
|
|
3568
3568
|
out[1] = y;
|
|
3569
|
-
out[2] =
|
|
3569
|
+
out[2] = z3;
|
|
3570
3570
|
out[3] = w;
|
|
3571
3571
|
return out;
|
|
3572
3572
|
};
|
|
@@ -3578,7 +3578,7 @@ var require_fromValues4 = __commonJS({
|
|
|
3578
3578
|
var require_fromNoisyPoints = __commonJS({
|
|
3579
3579
|
"node_modules/@jscad/modeling/src/maths/plane/fromNoisyPoints.js"(exports, module) {
|
|
3580
3580
|
"use strict";
|
|
3581
|
-
var
|
|
3581
|
+
var vec32 = require_vec3();
|
|
3582
3582
|
var fromNormalAndPoint = require_fromNormalAndPoint();
|
|
3583
3583
|
var fromNoisyPoints = (out, ...vertices) => {
|
|
3584
3584
|
out[0] = 0;
|
|
@@ -3587,18 +3587,18 @@ var require_fromNoisyPoints = __commonJS({
|
|
|
3587
3587
|
out[3] = 0;
|
|
3588
3588
|
const n = vertices.length;
|
|
3589
3589
|
vertices.forEach((v) => {
|
|
3590
|
-
|
|
3590
|
+
vec32.add(out, out, v);
|
|
3591
3591
|
});
|
|
3592
|
-
|
|
3592
|
+
vec32.scale(out, out, 1 / n);
|
|
3593
3593
|
let xx = 0;
|
|
3594
3594
|
let xy = 0;
|
|
3595
3595
|
let xz = 0;
|
|
3596
3596
|
let yy = 0;
|
|
3597
3597
|
let yz = 0;
|
|
3598
3598
|
let zz = 0;
|
|
3599
|
-
const vn =
|
|
3599
|
+
const vn = vec32.create();
|
|
3600
3600
|
vertices.forEach((v) => {
|
|
3601
|
-
|
|
3601
|
+
vec32.subtract(vn, v, out);
|
|
3602
3602
|
xx += vn[0] * vn[0];
|
|
3603
3603
|
xy += vn[0] * vn[1];
|
|
3604
3604
|
xz += vn[0] * vn[2];
|
|
@@ -3615,31 +3615,31 @@ var require_fromNoisyPoints = __commonJS({
|
|
|
3615
3615
|
vn[0] = 0;
|
|
3616
3616
|
vn[1] = 0;
|
|
3617
3617
|
vn[2] = 0;
|
|
3618
|
-
const wdv =
|
|
3618
|
+
const wdv = vec32.create();
|
|
3619
3619
|
let det = yy * zz - yz * yz;
|
|
3620
3620
|
wdv[0] = det;
|
|
3621
3621
|
wdv[1] = xz * yz - xy * zz;
|
|
3622
3622
|
wdv[2] = xy * yz - xz * yy;
|
|
3623
3623
|
let weight = det * det;
|
|
3624
|
-
|
|
3624
|
+
vec32.add(vn, vn, vec32.scale(wdv, wdv, weight));
|
|
3625
3625
|
det = xx * zz - xz * xz;
|
|
3626
3626
|
wdv[0] = xz * yz - xy * zz;
|
|
3627
3627
|
wdv[1] = det;
|
|
3628
3628
|
wdv[2] = xy * xz - yz * xx;
|
|
3629
3629
|
weight = det * det;
|
|
3630
|
-
if (
|
|
3630
|
+
if (vec32.dot(vn, wdv) < 0) {
|
|
3631
3631
|
weight = -weight;
|
|
3632
3632
|
}
|
|
3633
|
-
|
|
3633
|
+
vec32.add(vn, vn, vec32.scale(wdv, wdv, weight));
|
|
3634
3634
|
det = xx * yy - xy * xy;
|
|
3635
3635
|
wdv[0] = xy * yz - xz * yy;
|
|
3636
3636
|
wdv[1] = xy * xz - yz * xx;
|
|
3637
3637
|
wdv[2] = det;
|
|
3638
3638
|
weight = det * det;
|
|
3639
|
-
if (
|
|
3639
|
+
if (vec32.dot(vn, wdv) < 0) {
|
|
3640
3640
|
weight = -weight;
|
|
3641
3641
|
}
|
|
3642
|
-
|
|
3642
|
+
vec32.add(vn, vn, vec32.scale(wdv, wdv, weight));
|
|
3643
3643
|
return fromNormalAndPoint(out, vn, out);
|
|
3644
3644
|
};
|
|
3645
3645
|
module.exports = fromNoisyPoints;
|
|
@@ -3650,33 +3650,33 @@ var require_fromNoisyPoints = __commonJS({
|
|
|
3650
3650
|
var require_fromPoints3 = __commonJS({
|
|
3651
3651
|
"node_modules/@jscad/modeling/src/maths/plane/fromPoints.js"(exports, module) {
|
|
3652
3652
|
"use strict";
|
|
3653
|
-
var
|
|
3653
|
+
var vec32 = require_vec3();
|
|
3654
3654
|
var fromPoints = (out, ...vertices) => {
|
|
3655
3655
|
const len = vertices.length;
|
|
3656
|
-
const ba =
|
|
3657
|
-
const ca =
|
|
3656
|
+
const ba = vec32.create();
|
|
3657
|
+
const ca = vec32.create();
|
|
3658
3658
|
const vertexNormal = (index) => {
|
|
3659
3659
|
const a = vertices[index];
|
|
3660
3660
|
const b = vertices[(index + 1) % len];
|
|
3661
3661
|
const c = vertices[(index + 2) % len];
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3662
|
+
vec32.subtract(ba, b, a);
|
|
3663
|
+
vec32.subtract(ca, c, a);
|
|
3664
|
+
vec32.cross(ba, ba, ca);
|
|
3665
|
+
vec32.normalize(ba, ba);
|
|
3666
3666
|
return ba;
|
|
3667
3667
|
};
|
|
3668
3668
|
out[0] = 0;
|
|
3669
3669
|
out[1] = 0;
|
|
3670
3670
|
out[2] = 0;
|
|
3671
3671
|
if (len === 3) {
|
|
3672
|
-
|
|
3672
|
+
vec32.copy(out, vertexNormal(0));
|
|
3673
3673
|
} else {
|
|
3674
3674
|
vertices.forEach((v, i) => {
|
|
3675
|
-
|
|
3675
|
+
vec32.add(out, out, vertexNormal(i));
|
|
3676
3676
|
});
|
|
3677
|
-
|
|
3677
|
+
vec32.normalize(out, out);
|
|
3678
3678
|
}
|
|
3679
|
-
out[3] =
|
|
3679
|
+
out[3] = vec32.dot(out, vertices[0]);
|
|
3680
3680
|
return out;
|
|
3681
3681
|
};
|
|
3682
3682
|
module.exports = fromPoints;
|
|
@@ -3688,23 +3688,23 @@ var require_fromPointsRandom = __commonJS({
|
|
|
3688
3688
|
"node_modules/@jscad/modeling/src/maths/plane/fromPointsRandom.js"(exports, module) {
|
|
3689
3689
|
"use strict";
|
|
3690
3690
|
var { EPS: EPS4 } = require_constants();
|
|
3691
|
-
var
|
|
3691
|
+
var vec32 = require_vec3();
|
|
3692
3692
|
var fromPointsRandom = (out, a, b, c) => {
|
|
3693
|
-
let ba =
|
|
3694
|
-
let ca =
|
|
3695
|
-
if (
|
|
3696
|
-
ba =
|
|
3693
|
+
let ba = vec32.subtract(vec32.create(), b, a);
|
|
3694
|
+
let ca = vec32.subtract(vec32.create(), c, a);
|
|
3695
|
+
if (vec32.length(ba) < EPS4) {
|
|
3696
|
+
ba = vec32.orthogonal(ba, ca);
|
|
3697
3697
|
}
|
|
3698
|
-
if (
|
|
3699
|
-
ca =
|
|
3698
|
+
if (vec32.length(ca) < EPS4) {
|
|
3699
|
+
ca = vec32.orthogonal(ca, ba);
|
|
3700
3700
|
}
|
|
3701
|
-
let normal =
|
|
3702
|
-
if (
|
|
3703
|
-
ca =
|
|
3704
|
-
normal =
|
|
3701
|
+
let normal = vec32.cross(vec32.create(), ba, ca);
|
|
3702
|
+
if (vec32.length(normal) < EPS4) {
|
|
3703
|
+
ca = vec32.orthogonal(ca, ba);
|
|
3704
|
+
normal = vec32.cross(normal, ba, ca);
|
|
3705
3705
|
}
|
|
3706
|
-
normal =
|
|
3707
|
-
const w =
|
|
3706
|
+
normal = vec32.normalize(normal, normal);
|
|
3707
|
+
const w = vec32.dot(normal, a);
|
|
3708
3708
|
out[0] = normal[0];
|
|
3709
3709
|
out[1] = normal[1];
|
|
3710
3710
|
out[2] = normal[2];
|
|
@@ -3719,13 +3719,13 @@ var require_fromPointsRandom = __commonJS({
|
|
|
3719
3719
|
var require_projectionOfPoint = __commonJS({
|
|
3720
3720
|
"node_modules/@jscad/modeling/src/maths/plane/projectionOfPoint.js"(exports, module) {
|
|
3721
3721
|
"use strict";
|
|
3722
|
-
var
|
|
3722
|
+
var vec32 = require_vec3();
|
|
3723
3723
|
var projectionOfPoint = (plane, point) => {
|
|
3724
3724
|
const a = point[0] * plane[0] + point[1] * plane[1] + point[2] * plane[2] - plane[3];
|
|
3725
3725
|
const x = point[0] - a * plane[0];
|
|
3726
3726
|
const y = point[1] - a * plane[1];
|
|
3727
|
-
const
|
|
3728
|
-
return
|
|
3727
|
+
const z3 = point[2] - a * plane[2];
|
|
3728
|
+
return vec32.fromValues(x, y, z3);
|
|
3729
3729
|
};
|
|
3730
3730
|
module.exports = projectionOfPoint;
|
|
3731
3731
|
}
|
|
@@ -3735,8 +3735,8 @@ var require_projectionOfPoint = __commonJS({
|
|
|
3735
3735
|
var require_signedDistanceToPoint = __commonJS({
|
|
3736
3736
|
"node_modules/@jscad/modeling/src/maths/plane/signedDistanceToPoint.js"(exports, module) {
|
|
3737
3737
|
"use strict";
|
|
3738
|
-
var
|
|
3739
|
-
var signedDistanceToPoint = (plane, point) =>
|
|
3738
|
+
var vec32 = require_vec3();
|
|
3739
|
+
var signedDistanceToPoint = (plane, point) => vec32.dot(plane, point) - plane[3];
|
|
3740
3740
|
module.exports = signedDistanceToPoint;
|
|
3741
3741
|
}
|
|
3742
3742
|
});
|
|
@@ -3755,21 +3755,21 @@ var require_transform4 = __commonJS({
|
|
|
3755
3755
|
"node_modules/@jscad/modeling/src/maths/plane/transform.js"(exports, module) {
|
|
3756
3756
|
"use strict";
|
|
3757
3757
|
var mat42 = require_mat4();
|
|
3758
|
-
var
|
|
3758
|
+
var vec32 = require_vec3();
|
|
3759
3759
|
var fromPoints = require_fromPoints3();
|
|
3760
3760
|
var flip = require_flip();
|
|
3761
3761
|
var transform = (out, plane, matrix) => {
|
|
3762
3762
|
const ismirror = mat42.isMirroring(matrix);
|
|
3763
|
-
const r =
|
|
3764
|
-
const u =
|
|
3765
|
-
const v =
|
|
3766
|
-
let point1 =
|
|
3767
|
-
|
|
3768
|
-
let point2 =
|
|
3769
|
-
let point3 =
|
|
3770
|
-
point1 =
|
|
3771
|
-
point2 =
|
|
3772
|
-
point3 =
|
|
3763
|
+
const r = vec32.orthogonal(vec32.create(), plane);
|
|
3764
|
+
const u = vec32.cross(r, plane, r);
|
|
3765
|
+
const v = vec32.cross(vec32.create(), plane, u);
|
|
3766
|
+
let point1 = vec32.fromScalar(vec32.create(), plane[3]);
|
|
3767
|
+
vec32.multiply(point1, point1, plane);
|
|
3768
|
+
let point2 = vec32.add(vec32.create(), point1, u);
|
|
3769
|
+
let point3 = vec32.add(vec32.create(), point1, v);
|
|
3770
|
+
point1 = vec32.transform(point1, point1, matrix);
|
|
3771
|
+
point2 = vec32.transform(point2, point2, matrix);
|
|
3772
|
+
point3 = vec32.transform(point3, point3, matrix);
|
|
3773
3773
|
fromPoints(out, point1, point2, point3);
|
|
3774
3774
|
if (ismirror) {
|
|
3775
3775
|
flip(out, out);
|
|
@@ -3868,7 +3868,7 @@ var require_isConvex = __commonJS({
|
|
|
3868
3868
|
"node_modules/@jscad/modeling/src/geometries/poly3/isConvex.js"(exports, module) {
|
|
3869
3869
|
"use strict";
|
|
3870
3870
|
var plane = require_plane();
|
|
3871
|
-
var
|
|
3871
|
+
var vec32 = require_vec3();
|
|
3872
3872
|
var isConvex = (polygon3) => areVerticesConvex(polygon3.vertices);
|
|
3873
3873
|
var areVerticesConvex = (vertices) => {
|
|
3874
3874
|
const numvertices = vertices.length;
|
|
@@ -3888,12 +3888,12 @@ var require_isConvex = __commonJS({
|
|
|
3888
3888
|
return true;
|
|
3889
3889
|
};
|
|
3890
3890
|
var isConvexPoint = (prevpoint, point, nextpoint, normal) => {
|
|
3891
|
-
const crossproduct =
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3891
|
+
const crossproduct = vec32.cross(
|
|
3892
|
+
vec32.create(),
|
|
3893
|
+
vec32.subtract(vec32.create(), point, prevpoint),
|
|
3894
|
+
vec32.subtract(vec32.create(), nextpoint, point)
|
|
3895
3895
|
);
|
|
3896
|
-
const crossdotnormal =
|
|
3896
|
+
const crossdotnormal = vec32.dot(crossproduct, normal);
|
|
3897
3897
|
return crossdotnormal >= 0;
|
|
3898
3898
|
};
|
|
3899
3899
|
module.exports = isConvex;
|
|
@@ -3984,15 +3984,15 @@ var require_measureArea = __commonJS({
|
|
|
3984
3984
|
var require_measureBoundingBox = __commonJS({
|
|
3985
3985
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureBoundingBox.js"(exports, module) {
|
|
3986
3986
|
"use strict";
|
|
3987
|
-
var
|
|
3987
|
+
var vec32 = require_vec3();
|
|
3988
3988
|
var measureBoundingBox3 = (polygon3) => {
|
|
3989
3989
|
const vertices = polygon3.vertices;
|
|
3990
3990
|
const numvertices = vertices.length;
|
|
3991
|
-
const min = numvertices === 0 ?
|
|
3992
|
-
const max =
|
|
3991
|
+
const min = numvertices === 0 ? vec32.create() : vec32.clone(vertices[0]);
|
|
3992
|
+
const max = vec32.clone(min);
|
|
3993
3993
|
for (let i = 1; i < numvertices; i++) {
|
|
3994
|
-
|
|
3995
|
-
|
|
3994
|
+
vec32.min(min, min, vertices[i]);
|
|
3995
|
+
vec32.max(max, max, vertices[i]);
|
|
3996
3996
|
}
|
|
3997
3997
|
return [min, max];
|
|
3998
3998
|
};
|
|
@@ -4029,11 +4029,11 @@ var require_transform5 = __commonJS({
|
|
|
4029
4029
|
"node_modules/@jscad/modeling/src/maths/vec4/transform.js"(exports, module) {
|
|
4030
4030
|
"use strict";
|
|
4031
4031
|
var transform = (out, vector, matrix) => {
|
|
4032
|
-
const [x, y,
|
|
4033
|
-
out[0] = matrix[0] * x + matrix[4] * y + matrix[8] *
|
|
4034
|
-
out[1] = matrix[1] * x + matrix[5] * y + matrix[9] *
|
|
4035
|
-
out[2] = matrix[2] * x + matrix[6] * y + matrix[10] *
|
|
4036
|
-
out[3] = matrix[3] * x + matrix[7] * y + matrix[11] *
|
|
4032
|
+
const [x, y, z3, w] = vector;
|
|
4033
|
+
out[0] = matrix[0] * x + matrix[4] * y + matrix[8] * z3 + matrix[12] * w;
|
|
4034
|
+
out[1] = matrix[1] * x + matrix[5] * y + matrix[9] * z3 + matrix[13] * w;
|
|
4035
|
+
out[2] = matrix[2] * x + matrix[6] * y + matrix[10] * z3 + matrix[14] * w;
|
|
4036
|
+
out[3] = matrix[3] * x + matrix[7] * y + matrix[11] * z3 + matrix[15] * w;
|
|
4037
4037
|
return out;
|
|
4038
4038
|
};
|
|
4039
4039
|
module.exports = transform;
|
|
@@ -4095,8 +4095,8 @@ var require_measureBoundingSphere = __commonJS({
|
|
|
4095
4095
|
out[2] = (minz[2] + maxz[2]) * 0.5;
|
|
4096
4096
|
const x = out[0] - maxx[0];
|
|
4097
4097
|
const y = out[1] - maxy[1];
|
|
4098
|
-
const
|
|
4099
|
-
out[3] = Math.sqrt(x * x + y * y +
|
|
4098
|
+
const z3 = out[2] - maxz[2];
|
|
4099
|
+
out[3] = Math.sqrt(x * x + y * y + z3 * z3);
|
|
4100
4100
|
cache.set(polygon3, out);
|
|
4101
4101
|
return out;
|
|
4102
4102
|
};
|
|
@@ -4108,14 +4108,14 @@ var require_measureBoundingSphere = __commonJS({
|
|
|
4108
4108
|
var require_measureSignedVolume = __commonJS({
|
|
4109
4109
|
"node_modules/@jscad/modeling/src/geometries/poly3/measureSignedVolume.js"(exports, module) {
|
|
4110
4110
|
"use strict";
|
|
4111
|
-
var
|
|
4111
|
+
var vec32 = require_vec3();
|
|
4112
4112
|
var measureSignedVolume = (polygon3) => {
|
|
4113
4113
|
let signedVolume = 0;
|
|
4114
4114
|
const vertices = polygon3.vertices;
|
|
4115
|
-
const cross2 =
|
|
4115
|
+
const cross2 = vec32.create();
|
|
4116
4116
|
for (let i = 0; i < vertices.length - 2; i++) {
|
|
4117
|
-
|
|
4118
|
-
signedVolume +=
|
|
4117
|
+
vec32.cross(cross2, vertices[i + 1], vertices[i + 2]);
|
|
4118
|
+
signedVolume += vec32.dot(vertices[0], cross2);
|
|
4119
4119
|
}
|
|
4120
4120
|
signedVolume /= 6;
|
|
4121
4121
|
return signedVolume;
|
|
@@ -4137,11 +4137,11 @@ var require_toPoints2 = __commonJS({
|
|
|
4137
4137
|
var require_toString6 = __commonJS({
|
|
4138
4138
|
"node_modules/@jscad/modeling/src/geometries/poly3/toString.js"(exports, module) {
|
|
4139
4139
|
"use strict";
|
|
4140
|
-
var
|
|
4140
|
+
var vec32 = require_vec3();
|
|
4141
4141
|
var toString = (polygon3) => {
|
|
4142
4142
|
let result = "poly3: vertices: [";
|
|
4143
4143
|
polygon3.vertices.forEach((vertex) => {
|
|
4144
|
-
result += `${
|
|
4144
|
+
result += `${vec32.toString(vertex)}, `;
|
|
4145
4145
|
});
|
|
4146
4146
|
result += "]";
|
|
4147
4147
|
return result;
|
|
@@ -4155,10 +4155,10 @@ var require_transform6 = __commonJS({
|
|
|
4155
4155
|
"node_modules/@jscad/modeling/src/geometries/poly3/transform.js"(exports, module) {
|
|
4156
4156
|
"use strict";
|
|
4157
4157
|
var mat42 = require_mat4();
|
|
4158
|
-
var
|
|
4158
|
+
var vec32 = require_vec3();
|
|
4159
4159
|
var create = require_create6();
|
|
4160
4160
|
var transform = (matrix, polygon3) => {
|
|
4161
|
-
const vertices = polygon3.vertices.map((vertex) =>
|
|
4161
|
+
const vertices = polygon3.vertices.map((vertex) => vec32.transform(vec32.create(), vertex, matrix));
|
|
4162
4162
|
if (mat42.isMirroring(matrix)) {
|
|
4163
4163
|
vertices.reverse();
|
|
4164
4164
|
}
|
|
@@ -4174,7 +4174,7 @@ var require_validate2 = __commonJS({
|
|
|
4174
4174
|
"use strict";
|
|
4175
4175
|
var signedDistanceToPoint = require_signedDistanceToPoint();
|
|
4176
4176
|
var { NEPS } = require_constants();
|
|
4177
|
-
var
|
|
4177
|
+
var vec32 = require_vec3();
|
|
4178
4178
|
var isA = require_isA2();
|
|
4179
4179
|
var isConvex = require_isConvex();
|
|
4180
4180
|
var measureArea = require_measureArea();
|
|
@@ -4190,7 +4190,7 @@ var require_validate2 = __commonJS({
|
|
|
4190
4190
|
throw new Error("poly3 area must be greater than zero");
|
|
4191
4191
|
}
|
|
4192
4192
|
for (let i = 0; i < object.vertices.length; i++) {
|
|
4193
|
-
if (
|
|
4193
|
+
if (vec32.equals(object.vertices[i], object.vertices[(i + 1) % object.vertices.length])) {
|
|
4194
4194
|
throw new Error(`poly3 duplicate vertex ${object.vertices[i]}`);
|
|
4195
4195
|
}
|
|
4196
4196
|
}
|
|
@@ -4288,7 +4288,7 @@ var require_fromPoints4 = __commonJS({
|
|
|
4288
4288
|
var require_fromCompactBinary2 = __commonJS({
|
|
4289
4289
|
"node_modules/@jscad/modeling/src/geometries/geom3/fromCompactBinary.js"(exports, module) {
|
|
4290
4290
|
"use strict";
|
|
4291
|
-
var
|
|
4291
|
+
var vec32 = require_vec3();
|
|
4292
4292
|
var mat42 = require_mat4();
|
|
4293
4293
|
var poly3 = require_poly3();
|
|
4294
4294
|
var create = require_create5();
|
|
@@ -4304,7 +4304,7 @@ var require_fromCompactBinary2 = __commonJS({
|
|
|
4304
4304
|
ci++;
|
|
4305
4305
|
const vertices = [];
|
|
4306
4306
|
for (let i = 0; i < verticesPerPolygon; i++) {
|
|
4307
|
-
vertices.push(
|
|
4307
|
+
vertices.push(vec32.fromValues(data[vi], data[vi + 1], data[vi + 2]));
|
|
4308
4308
|
vi += 3;
|
|
4309
4309
|
}
|
|
4310
4310
|
created.polygons.push(poly3.create(vertices));
|
|
@@ -4383,7 +4383,7 @@ var require_isConvex2 = __commonJS({
|
|
|
4383
4383
|
"node_modules/@jscad/modeling/src/geometries/geom3/isConvex.js"(exports, module) {
|
|
4384
4384
|
"use strict";
|
|
4385
4385
|
var { EPS: EPS4 } = require_constants();
|
|
4386
|
-
var
|
|
4386
|
+
var vec32 = require_vec3();
|
|
4387
4387
|
var geom35 = require_isA3();
|
|
4388
4388
|
var toPolygons5 = require_toPolygons();
|
|
4389
4389
|
var poly3 = require_poly3();
|
|
@@ -4412,7 +4412,7 @@ var require_isConvex2 = __commonJS({
|
|
|
4412
4412
|
const plane = poly3.plane(polygons[i]);
|
|
4413
4413
|
for (let j = 0; j < vertices.length; j++) {
|
|
4414
4414
|
const v = vertices[j];
|
|
4415
|
-
const distance =
|
|
4415
|
+
const distance = vec32.dot(plane, v) - plane[3];
|
|
4416
4416
|
if (distance > EPS4) {
|
|
4417
4417
|
return false;
|
|
4418
4418
|
}
|
|
@@ -4467,8 +4467,8 @@ var require_toCompactBinary2 = __commonJS({
|
|
|
4467
4467
|
const transforms = geometry.transforms;
|
|
4468
4468
|
const numberOfPolygons = polygons.length;
|
|
4469
4469
|
const numberOfVertices = polygons.reduce((count, polygon3) => count + polygon3.vertices.length, 0);
|
|
4470
|
-
let
|
|
4471
|
-
if (geometry.color)
|
|
4470
|
+
let color3 = [-1, -1, -1, -1];
|
|
4471
|
+
if (geometry.color) color3 = geometry.color;
|
|
4472
4472
|
const compacted = new Float32Array(1 + 16 + 4 + 1 + numberOfPolygons + numberOfVertices * 3);
|
|
4473
4473
|
compacted[0] = 1;
|
|
4474
4474
|
compacted[1] = transforms[0];
|
|
@@ -4487,10 +4487,10 @@ var require_toCompactBinary2 = __commonJS({
|
|
|
4487
4487
|
compacted[14] = transforms[13];
|
|
4488
4488
|
compacted[15] = transforms[14];
|
|
4489
4489
|
compacted[16] = transforms[15];
|
|
4490
|
-
compacted[17] =
|
|
4491
|
-
compacted[18] =
|
|
4492
|
-
compacted[19] =
|
|
4493
|
-
compacted[20] =
|
|
4490
|
+
compacted[17] = color3[0];
|
|
4491
|
+
compacted[18] = color3[1];
|
|
4492
|
+
compacted[19] = color3[2];
|
|
4493
|
+
compacted[20] = color3[3];
|
|
4494
4494
|
compacted[21] = numberOfVertices;
|
|
4495
4495
|
let ci = 22;
|
|
4496
4496
|
let vi = ci + numberOfPolygons;
|
|
@@ -4840,7 +4840,7 @@ var require_appendBezier = __commonJS({
|
|
|
4840
4840
|
"use strict";
|
|
4841
4841
|
var { TAU } = require_constants();
|
|
4842
4842
|
var vec2 = require_vec2();
|
|
4843
|
-
var
|
|
4843
|
+
var vec32 = require_vec2();
|
|
4844
4844
|
var appendPoints = require_appendPoints();
|
|
4845
4845
|
var toPoints = require_toPoints4();
|
|
4846
4846
|
var appendBezier = (options, geometry) => {
|
|
@@ -4890,7 +4890,7 @@ var require_appendBezier = __commonJS({
|
|
|
4890
4890
|
}
|
|
4891
4891
|
const v0 = vec2.create();
|
|
4892
4892
|
const v1 = vec2.create();
|
|
4893
|
-
const v3 =
|
|
4893
|
+
const v3 = vec32.create();
|
|
4894
4894
|
const getPointForT = (t) => {
|
|
4895
4895
|
let tk = 1;
|
|
4896
4896
|
let oneMinusTNMinusK = Math.pow(1 - t, bezierOrder);
|
|
@@ -5069,8 +5069,8 @@ var require_toCompactBinary3 = __commonJS({
|
|
|
5069
5069
|
var toCompactBinary = (geometry) => {
|
|
5070
5070
|
const points = geometry.points;
|
|
5071
5071
|
const transforms = geometry.transforms;
|
|
5072
|
-
let
|
|
5073
|
-
if (geometry.color)
|
|
5072
|
+
let color3 = [-1, -1, -1, -1];
|
|
5073
|
+
if (geometry.color) color3 = geometry.color;
|
|
5074
5074
|
const compacted = new Float32Array(1 + 16 + 1 + 4 + points.length * 2);
|
|
5075
5075
|
compacted[0] = 2;
|
|
5076
5076
|
compacted[1] = transforms[0];
|
|
@@ -5090,10 +5090,10 @@ var require_toCompactBinary3 = __commonJS({
|
|
|
5090
5090
|
compacted[15] = transforms[14];
|
|
5091
5091
|
compacted[16] = transforms[15];
|
|
5092
5092
|
compacted[17] = geometry.isClosed ? 1 : 0;
|
|
5093
|
-
compacted[18] =
|
|
5094
|
-
compacted[19] =
|
|
5095
|
-
compacted[20] =
|
|
5096
|
-
compacted[21] =
|
|
5093
|
+
compacted[18] = color3[0];
|
|
5094
|
+
compacted[19] = color3[1];
|
|
5095
|
+
compacted[20] = color3[2];
|
|
5096
|
+
compacted[21] = color3[3];
|
|
5097
5097
|
for (let j = 0; j < points.length; j++) {
|
|
5098
5098
|
const ci = j * 2 + 22;
|
|
5099
5099
|
const point = points[j];
|
|
@@ -5184,38 +5184,38 @@ var require_colorize = __commonJS({
|
|
|
5184
5184
|
var geom35 = require_geom3();
|
|
5185
5185
|
var path2 = require_path2();
|
|
5186
5186
|
var poly3 = require_poly3();
|
|
5187
|
-
var colorGeom2 = (
|
|
5187
|
+
var colorGeom2 = (color3, object) => {
|
|
5188
5188
|
const newgeom2 = geom2.clone(object);
|
|
5189
|
-
newgeom2.color =
|
|
5189
|
+
newgeom2.color = color3;
|
|
5190
5190
|
return newgeom2;
|
|
5191
5191
|
};
|
|
5192
|
-
var colorGeom3 = (
|
|
5192
|
+
var colorGeom3 = (color3, object) => {
|
|
5193
5193
|
const newgeom3 = geom35.clone(object);
|
|
5194
|
-
newgeom3.color =
|
|
5194
|
+
newgeom3.color = color3;
|
|
5195
5195
|
return newgeom3;
|
|
5196
5196
|
};
|
|
5197
|
-
var colorPath2 = (
|
|
5197
|
+
var colorPath2 = (color3, object) => {
|
|
5198
5198
|
const newpath2 = path2.clone(object);
|
|
5199
|
-
newpath2.color =
|
|
5199
|
+
newpath2.color = color3;
|
|
5200
5200
|
return newpath2;
|
|
5201
5201
|
};
|
|
5202
|
-
var colorPoly3 = (
|
|
5202
|
+
var colorPoly3 = (color3, object) => {
|
|
5203
5203
|
const newpoly = poly3.clone(object);
|
|
5204
|
-
newpoly.color =
|
|
5204
|
+
newpoly.color = color3;
|
|
5205
5205
|
return newpoly;
|
|
5206
5206
|
};
|
|
5207
|
-
var colorize = (
|
|
5208
|
-
if (!Array.isArray(
|
|
5209
|
-
if (
|
|
5210
|
-
if (
|
|
5207
|
+
var colorize = (color3, ...objects) => {
|
|
5208
|
+
if (!Array.isArray(color3)) throw new Error("color must be an array");
|
|
5209
|
+
if (color3.length < 3) throw new Error("color must contain R, G and B values");
|
|
5210
|
+
if (color3.length === 3) color3 = [color3[0], color3[1], color3[2], 1];
|
|
5211
5211
|
objects = flatten(objects);
|
|
5212
5212
|
if (objects.length === 0) throw new Error("wrong number of arguments");
|
|
5213
5213
|
const results = objects.map((object) => {
|
|
5214
|
-
if (geom2.isA(object)) return colorGeom2(
|
|
5215
|
-
if (geom35.isA(object)) return colorGeom3(
|
|
5216
|
-
if (path2.isA(object)) return colorPath2(
|
|
5217
|
-
if (poly3.isA(object)) return colorPoly3(
|
|
5218
|
-
object.color =
|
|
5214
|
+
if (geom2.isA(object)) return colorGeom2(color3, object);
|
|
5215
|
+
if (geom35.isA(object)) return colorGeom3(color3, object);
|
|
5216
|
+
if (path2.isA(object)) return colorPath2(color3, object);
|
|
5217
|
+
if (poly3.isA(object)) return colorPoly3(color3, object);
|
|
5218
|
+
object.color = color3;
|
|
5219
5219
|
return object;
|
|
5220
5220
|
});
|
|
5221
5221
|
return results.length === 1 ? results[0] : results;
|
|
@@ -6371,11 +6371,11 @@ var require_line2 = __commonJS({
|
|
|
6371
6371
|
var require_create12 = __commonJS({
|
|
6372
6372
|
"node_modules/@jscad/modeling/src/maths/line3/create.js"(exports, module) {
|
|
6373
6373
|
"use strict";
|
|
6374
|
-
var
|
|
6374
|
+
var vec32 = require_vec3();
|
|
6375
6375
|
var create = () => [
|
|
6376
|
-
|
|
6376
|
+
vec32.fromValues(0, 0, 0),
|
|
6377
6377
|
// origin
|
|
6378
|
-
|
|
6378
|
+
vec32.fromValues(0, 0, 1)
|
|
6379
6379
|
// direction
|
|
6380
6380
|
];
|
|
6381
6381
|
module.exports = create;
|
|
@@ -6386,12 +6386,12 @@ var require_create12 = __commonJS({
|
|
|
6386
6386
|
var require_clone10 = __commonJS({
|
|
6387
6387
|
"node_modules/@jscad/modeling/src/maths/line3/clone.js"(exports, module) {
|
|
6388
6388
|
"use strict";
|
|
6389
|
-
var
|
|
6389
|
+
var vec32 = require_vec3();
|
|
6390
6390
|
var create = require_create12();
|
|
6391
6391
|
var clone = (line) => {
|
|
6392
6392
|
const out = create();
|
|
6393
|
-
|
|
6394
|
-
|
|
6393
|
+
vec32.copy(out[0], line[0]);
|
|
6394
|
+
vec32.copy(out[1], line[1]);
|
|
6395
6395
|
return out;
|
|
6396
6396
|
};
|
|
6397
6397
|
module.exports = clone;
|
|
@@ -6402,15 +6402,15 @@ var require_clone10 = __commonJS({
|
|
|
6402
6402
|
var require_closestPoint2 = __commonJS({
|
|
6403
6403
|
"node_modules/@jscad/modeling/src/maths/line3/closestPoint.js"(exports, module) {
|
|
6404
6404
|
"use strict";
|
|
6405
|
-
var
|
|
6405
|
+
var vec32 = require_vec3();
|
|
6406
6406
|
var closestPoint = (line, point) => {
|
|
6407
6407
|
const lpoint = line[0];
|
|
6408
6408
|
const ldirection = line[1];
|
|
6409
|
-
const a =
|
|
6410
|
-
const b =
|
|
6409
|
+
const a = vec32.dot(vec32.subtract(vec32.create(), point, lpoint), ldirection);
|
|
6410
|
+
const b = vec32.dot(ldirection, ldirection);
|
|
6411
6411
|
const t = a / b;
|
|
6412
|
-
const closestpoint =
|
|
6413
|
-
|
|
6412
|
+
const closestpoint = vec32.scale(vec32.create(), ldirection, t);
|
|
6413
|
+
vec32.add(closestpoint, closestpoint, lpoint);
|
|
6414
6414
|
return closestpoint;
|
|
6415
6415
|
};
|
|
6416
6416
|
module.exports = closestPoint;
|
|
@@ -6421,10 +6421,10 @@ var require_closestPoint2 = __commonJS({
|
|
|
6421
6421
|
var require_copy6 = __commonJS({
|
|
6422
6422
|
"node_modules/@jscad/modeling/src/maths/line3/copy.js"(exports, module) {
|
|
6423
6423
|
"use strict";
|
|
6424
|
-
var
|
|
6424
|
+
var vec32 = require_vec3();
|
|
6425
6425
|
var copy = (out, line) => {
|
|
6426
|
-
|
|
6427
|
-
|
|
6426
|
+
vec32.copy(out[0], line[0]);
|
|
6427
|
+
vec32.copy(out[1], line[1]);
|
|
6428
6428
|
return out;
|
|
6429
6429
|
};
|
|
6430
6430
|
module.exports = copy;
|
|
@@ -6444,12 +6444,12 @@ var require_direction2 = __commonJS({
|
|
|
6444
6444
|
var require_distanceToPoint2 = __commonJS({
|
|
6445
6445
|
"node_modules/@jscad/modeling/src/maths/line3/distanceToPoint.js"(exports, module) {
|
|
6446
6446
|
"use strict";
|
|
6447
|
-
var
|
|
6447
|
+
var vec32 = require_vec3();
|
|
6448
6448
|
var closestPoint = require_closestPoint2();
|
|
6449
6449
|
var distanceToPoint = (line, point) => {
|
|
6450
6450
|
const closest = closestPoint(line, point);
|
|
6451
|
-
const distancevector =
|
|
6452
|
-
return
|
|
6451
|
+
const distancevector = vec32.subtract(vec32.create(), point, closest);
|
|
6452
|
+
return vec32.length(distancevector);
|
|
6453
6453
|
};
|
|
6454
6454
|
module.exports = distanceToPoint;
|
|
6455
6455
|
}
|
|
@@ -6459,10 +6459,10 @@ var require_distanceToPoint2 = __commonJS({
|
|
|
6459
6459
|
var require_equals7 = __commonJS({
|
|
6460
6460
|
"node_modules/@jscad/modeling/src/maths/line3/equals.js"(exports, module) {
|
|
6461
6461
|
"use strict";
|
|
6462
|
-
var
|
|
6462
|
+
var vec32 = require_vec3();
|
|
6463
6463
|
var equals = (line1, line2) => {
|
|
6464
|
-
if (!
|
|
6465
|
-
if (!
|
|
6464
|
+
if (!vec32.equals(line1[1], line2[1])) return false;
|
|
6465
|
+
if (!vec32.equals(line1[0], line2[0])) return false;
|
|
6466
6466
|
return true;
|
|
6467
6467
|
};
|
|
6468
6468
|
module.exports = equals;
|
|
@@ -6473,11 +6473,11 @@ var require_equals7 = __commonJS({
|
|
|
6473
6473
|
var require_fromPointAndDirection = __commonJS({
|
|
6474
6474
|
"node_modules/@jscad/modeling/src/maths/line3/fromPointAndDirection.js"(exports, module) {
|
|
6475
6475
|
"use strict";
|
|
6476
|
-
var
|
|
6476
|
+
var vec32 = require_vec3();
|
|
6477
6477
|
var fromPointAndDirection = (out, point, direction) => {
|
|
6478
|
-
const unit =
|
|
6479
|
-
|
|
6480
|
-
|
|
6478
|
+
const unit = vec32.normalize(vec32.create(), direction);
|
|
6479
|
+
vec32.copy(out[0], point);
|
|
6480
|
+
vec32.copy(out[1], unit);
|
|
6481
6481
|
return out;
|
|
6482
6482
|
};
|
|
6483
6483
|
module.exports = fromPointAndDirection;
|
|
@@ -6488,18 +6488,18 @@ var require_fromPointAndDirection = __commonJS({
|
|
|
6488
6488
|
var require_fromPlanes = __commonJS({
|
|
6489
6489
|
"node_modules/@jscad/modeling/src/maths/line3/fromPlanes.js"(exports, module) {
|
|
6490
6490
|
"use strict";
|
|
6491
|
-
var
|
|
6491
|
+
var vec32 = require_vec3();
|
|
6492
6492
|
var { solve2Linear } = require_utils();
|
|
6493
6493
|
var { EPS: EPS4 } = require_constants();
|
|
6494
6494
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
6495
6495
|
var fromPlanes = (out, plane1, plane2) => {
|
|
6496
|
-
let direction =
|
|
6497
|
-
let length =
|
|
6496
|
+
let direction = vec32.cross(vec32.create(), plane1, plane2);
|
|
6497
|
+
let length = vec32.length(direction);
|
|
6498
6498
|
if (length < EPS4) {
|
|
6499
6499
|
throw new Error("parallel planes do not intersect");
|
|
6500
6500
|
}
|
|
6501
6501
|
length = 1 / length;
|
|
6502
|
-
direction =
|
|
6502
|
+
direction = vec32.scale(direction, direction, length);
|
|
6503
6503
|
const absx = Math.abs(direction[0]);
|
|
6504
6504
|
const absy = Math.abs(direction[1]);
|
|
6505
6505
|
const absz = Math.abs(direction[2]);
|
|
@@ -6507,13 +6507,13 @@ var require_fromPlanes = __commonJS({
|
|
|
6507
6507
|
let r;
|
|
6508
6508
|
if (absx >= absy && absx >= absz) {
|
|
6509
6509
|
r = solve2Linear(plane1[1], plane1[2], plane2[1], plane2[2], plane1[3], plane2[3]);
|
|
6510
|
-
origin =
|
|
6510
|
+
origin = vec32.fromValues(0, r[0], r[1]);
|
|
6511
6511
|
} else if (absy >= absx && absy >= absz) {
|
|
6512
6512
|
r = solve2Linear(plane1[0], plane1[2], plane2[0], plane2[2], plane1[3], plane2[3]);
|
|
6513
|
-
origin =
|
|
6513
|
+
origin = vec32.fromValues(r[0], 0, r[1]);
|
|
6514
6514
|
} else {
|
|
6515
6515
|
r = solve2Linear(plane1[0], plane1[1], plane2[0], plane2[1], plane1[3], plane2[3]);
|
|
6516
|
-
origin =
|
|
6516
|
+
origin = vec32.fromValues(r[0], r[1], 0);
|
|
6517
6517
|
}
|
|
6518
6518
|
return fromPointAndDirection(out, origin, direction);
|
|
6519
6519
|
};
|
|
@@ -6525,10 +6525,10 @@ var require_fromPlanes = __commonJS({
|
|
|
6525
6525
|
var require_fromPoints7 = __commonJS({
|
|
6526
6526
|
"node_modules/@jscad/modeling/src/maths/line3/fromPoints.js"(exports, module) {
|
|
6527
6527
|
"use strict";
|
|
6528
|
-
var
|
|
6528
|
+
var vec32 = require_vec3();
|
|
6529
6529
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
6530
6530
|
var fromPoints = (out, point1, point2) => {
|
|
6531
|
-
const direction =
|
|
6531
|
+
const direction = vec32.subtract(vec32.create(), point2, point1);
|
|
6532
6532
|
return fromPointAndDirection(out, point1, direction);
|
|
6533
6533
|
};
|
|
6534
6534
|
module.exports = fromPoints;
|
|
@@ -6539,14 +6539,14 @@ var require_fromPoints7 = __commonJS({
|
|
|
6539
6539
|
var require_intersectPointOfLineAndPlane = __commonJS({
|
|
6540
6540
|
"node_modules/@jscad/modeling/src/maths/line3/intersectPointOfLineAndPlane.js"(exports, module) {
|
|
6541
6541
|
"use strict";
|
|
6542
|
-
var
|
|
6542
|
+
var vec32 = require_vec3();
|
|
6543
6543
|
var intersectToPlane = (line, plane) => {
|
|
6544
6544
|
const pnormal = plane;
|
|
6545
6545
|
const pw = plane[3];
|
|
6546
6546
|
const lpoint = line[0];
|
|
6547
6547
|
const ldirection = line[1];
|
|
6548
|
-
const labda = (pw -
|
|
6549
|
-
const point =
|
|
6548
|
+
const labda = (pw - vec32.dot(pnormal, lpoint)) / vec32.dot(pnormal, ldirection);
|
|
6549
|
+
const point = vec32.add(vec32.create(), lpoint, vec32.scale(vec32.create(), ldirection, labda));
|
|
6550
6550
|
return point;
|
|
6551
6551
|
};
|
|
6552
6552
|
module.exports = intersectToPlane;
|
|
@@ -6566,11 +6566,11 @@ var require_origin2 = __commonJS({
|
|
|
6566
6566
|
var require_reverse4 = __commonJS({
|
|
6567
6567
|
"node_modules/@jscad/modeling/src/maths/line3/reverse.js"(exports, module) {
|
|
6568
6568
|
"use strict";
|
|
6569
|
-
var
|
|
6569
|
+
var vec32 = require_vec3();
|
|
6570
6570
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
6571
6571
|
var reverse = (out, line) => {
|
|
6572
|
-
const point =
|
|
6573
|
-
const direction =
|
|
6572
|
+
const point = vec32.clone(line[0]);
|
|
6573
|
+
const direction = vec32.negate(vec32.create(), line[1]);
|
|
6574
6574
|
return fromPointAndDirection(out, point, direction);
|
|
6575
6575
|
};
|
|
6576
6576
|
module.exports = reverse;
|
|
@@ -6594,15 +6594,15 @@ var require_toString10 = __commonJS({
|
|
|
6594
6594
|
var require_transform10 = __commonJS({
|
|
6595
6595
|
"node_modules/@jscad/modeling/src/maths/line3/transform.js"(exports, module) {
|
|
6596
6596
|
"use strict";
|
|
6597
|
-
var
|
|
6597
|
+
var vec32 = require_vec3();
|
|
6598
6598
|
var fromPointAndDirection = require_fromPointAndDirection();
|
|
6599
6599
|
var transform = (out, line, matrix) => {
|
|
6600
6600
|
const point = line[0];
|
|
6601
6601
|
const direction = line[1];
|
|
6602
|
-
const pointPlusDirection =
|
|
6603
|
-
const newpoint =
|
|
6604
|
-
const newPointPlusDirection =
|
|
6605
|
-
const newdirection =
|
|
6602
|
+
const pointPlusDirection = vec32.add(vec32.create(), point, direction);
|
|
6603
|
+
const newpoint = vec32.transform(vec32.create(), point, matrix);
|
|
6604
|
+
const newPointPlusDirection = vec32.transform(pointPlusDirection, pointPlusDirection, matrix);
|
|
6605
|
+
const newdirection = vec32.subtract(newPointPlusDirection, newPointPlusDirection, newpoint);
|
|
6606
6606
|
return fromPointAndDirection(out, newpoint, newdirection);
|
|
6607
6607
|
};
|
|
6608
6608
|
module.exports = transform;
|
|
@@ -6720,7 +6720,7 @@ var require_measureBoundingBox2 = __commonJS({
|
|
|
6720
6720
|
"use strict";
|
|
6721
6721
|
var flatten = require_flatten();
|
|
6722
6722
|
var vec2 = require_vec2();
|
|
6723
|
-
var
|
|
6723
|
+
var vec32 = require_vec3();
|
|
6724
6724
|
var geom2 = require_geom2();
|
|
6725
6725
|
var geom35 = require_geom3();
|
|
6726
6726
|
var path2 = require_path2();
|
|
@@ -6772,16 +6772,16 @@ var require_measureBoundingBox2 = __commonJS({
|
|
|
6772
6772
|
let boundingBox = cache.get(geometry);
|
|
6773
6773
|
if (boundingBox) return boundingBox;
|
|
6774
6774
|
const polygons = geom35.toPolygons(geometry);
|
|
6775
|
-
let minpoint =
|
|
6775
|
+
let minpoint = vec32.create();
|
|
6776
6776
|
if (polygons.length > 0) {
|
|
6777
6777
|
const points = poly3.toPoints(polygons[0]);
|
|
6778
|
-
|
|
6778
|
+
vec32.copy(minpoint, points[0]);
|
|
6779
6779
|
}
|
|
6780
|
-
let maxpoint =
|
|
6780
|
+
let maxpoint = vec32.clone(minpoint);
|
|
6781
6781
|
polygons.forEach((polygon3) => {
|
|
6782
6782
|
poly3.toPoints(polygon3).forEach((point) => {
|
|
6783
|
-
|
|
6784
|
-
|
|
6783
|
+
vec32.min(minpoint, minpoint, point);
|
|
6784
|
+
vec32.max(maxpoint, maxpoint, point);
|
|
6785
6785
|
});
|
|
6786
6786
|
});
|
|
6787
6787
|
minpoint = [minpoint[0], minpoint[1], minpoint[2]];
|
|
@@ -6931,7 +6931,7 @@ var require_measureBoundingSphere2 = __commonJS({
|
|
|
6931
6931
|
"use strict";
|
|
6932
6932
|
var flatten = require_flatten();
|
|
6933
6933
|
var vec2 = require_vec2();
|
|
6934
|
-
var
|
|
6934
|
+
var vec32 = require_vec3();
|
|
6935
6935
|
var geom2 = require_geom2();
|
|
6936
6936
|
var geom35 = require_geom3();
|
|
6937
6937
|
var path2 = require_path2();
|
|
@@ -6940,17 +6940,17 @@ var require_measureBoundingSphere2 = __commonJS({
|
|
|
6940
6940
|
var measureBoundingSphereOfPath2 = (geometry) => {
|
|
6941
6941
|
let boundingSphere = cacheOfBoundingSpheres.get(geometry);
|
|
6942
6942
|
if (boundingSphere !== void 0) return boundingSphere;
|
|
6943
|
-
const centroid =
|
|
6943
|
+
const centroid = vec32.create();
|
|
6944
6944
|
let radius = 0;
|
|
6945
6945
|
const points = path2.toPoints(geometry);
|
|
6946
6946
|
if (points.length > 0) {
|
|
6947
6947
|
let numPoints = 0;
|
|
6948
|
-
const temp =
|
|
6948
|
+
const temp = vec32.create();
|
|
6949
6949
|
points.forEach((point) => {
|
|
6950
|
-
|
|
6950
|
+
vec32.add(centroid, centroid, vec32.fromVec2(temp, point, 0));
|
|
6951
6951
|
numPoints++;
|
|
6952
6952
|
});
|
|
6953
|
-
|
|
6953
|
+
vec32.scale(centroid, centroid, 1 / numPoints);
|
|
6954
6954
|
points.forEach((point) => {
|
|
6955
6955
|
radius = Math.max(radius, vec2.squaredDistance(centroid, point));
|
|
6956
6956
|
});
|
|
@@ -6963,17 +6963,17 @@ var require_measureBoundingSphere2 = __commonJS({
|
|
|
6963
6963
|
var measureBoundingSphereOfGeom2 = (geometry) => {
|
|
6964
6964
|
let boundingSphere = cacheOfBoundingSpheres.get(geometry);
|
|
6965
6965
|
if (boundingSphere !== void 0) return boundingSphere;
|
|
6966
|
-
const centroid =
|
|
6966
|
+
const centroid = vec32.create();
|
|
6967
6967
|
let radius = 0;
|
|
6968
6968
|
const sides = geom2.toSides(geometry);
|
|
6969
6969
|
if (sides.length > 0) {
|
|
6970
6970
|
let numPoints = 0;
|
|
6971
|
-
const temp =
|
|
6971
|
+
const temp = vec32.create();
|
|
6972
6972
|
sides.forEach((side) => {
|
|
6973
|
-
|
|
6973
|
+
vec32.add(centroid, centroid, vec32.fromVec2(temp, side[0], 0));
|
|
6974
6974
|
numPoints++;
|
|
6975
6975
|
});
|
|
6976
|
-
|
|
6976
|
+
vec32.scale(centroid, centroid, 1 / numPoints);
|
|
6977
6977
|
sides.forEach((side) => {
|
|
6978
6978
|
radius = Math.max(radius, vec2.squaredDistance(centroid, side[0]));
|
|
6979
6979
|
});
|
|
@@ -6986,21 +6986,21 @@ var require_measureBoundingSphere2 = __commonJS({
|
|
|
6986
6986
|
var measureBoundingSphereOfGeom3 = (geometry) => {
|
|
6987
6987
|
let boundingSphere = cacheOfBoundingSpheres.get(geometry);
|
|
6988
6988
|
if (boundingSphere !== void 0) return boundingSphere;
|
|
6989
|
-
const centroid =
|
|
6989
|
+
const centroid = vec32.create();
|
|
6990
6990
|
let radius = 0;
|
|
6991
6991
|
const polygons = geom35.toPolygons(geometry);
|
|
6992
6992
|
if (polygons.length > 0) {
|
|
6993
6993
|
let numPoints = 0;
|
|
6994
6994
|
polygons.forEach((polygon3) => {
|
|
6995
6995
|
poly3.toPoints(polygon3).forEach((point) => {
|
|
6996
|
-
|
|
6996
|
+
vec32.add(centroid, centroid, point);
|
|
6997
6997
|
numPoints++;
|
|
6998
6998
|
});
|
|
6999
6999
|
});
|
|
7000
|
-
|
|
7000
|
+
vec32.scale(centroid, centroid, 1 / numPoints);
|
|
7001
7001
|
polygons.forEach((polygon3) => {
|
|
7002
7002
|
poly3.toPoints(polygon3).forEach((point) => {
|
|
7003
|
-
radius = Math.max(radius,
|
|
7003
|
+
radius = Math.max(radius, vec32.squaredDistance(centroid, point));
|
|
7004
7004
|
});
|
|
7005
7005
|
});
|
|
7006
7006
|
radius = Math.sqrt(radius);
|
|
@@ -7050,7 +7050,7 @@ var require_measureCenterOfMass = __commonJS({
|
|
|
7050
7050
|
"node_modules/@jscad/modeling/src/measurements/measureCenterOfMass.js"(exports, module) {
|
|
7051
7051
|
"use strict";
|
|
7052
7052
|
var flatten = require_flatten();
|
|
7053
|
-
var
|
|
7053
|
+
var vec32 = require_vec3();
|
|
7054
7054
|
var geom2 = require_geom2();
|
|
7055
7055
|
var geom35 = require_geom3();
|
|
7056
7056
|
var cacheOfCenterOfMass = /* @__PURE__ */ new WeakMap();
|
|
@@ -7075,31 +7075,31 @@ var require_measureCenterOfMass = __commonJS({
|
|
|
7075
7075
|
x *= f;
|
|
7076
7076
|
y *= f;
|
|
7077
7077
|
}
|
|
7078
|
-
centerOfMass =
|
|
7078
|
+
centerOfMass = vec32.fromValues(x, y, 0);
|
|
7079
7079
|
cacheOfCenterOfMass.set(geometry, centerOfMass);
|
|
7080
7080
|
return centerOfMass;
|
|
7081
7081
|
};
|
|
7082
7082
|
var measureCenterOfMassGeom3 = (geometry) => {
|
|
7083
7083
|
let centerOfMass = cacheOfCenterOfMass.get(geometry);
|
|
7084
7084
|
if (centerOfMass !== void 0) return centerOfMass;
|
|
7085
|
-
centerOfMass =
|
|
7085
|
+
centerOfMass = vec32.create();
|
|
7086
7086
|
const polygons = geom35.toPolygons(geometry);
|
|
7087
7087
|
if (polygons.length === 0) return centerOfMass;
|
|
7088
7088
|
let totalVolume = 0;
|
|
7089
|
-
const vector =
|
|
7089
|
+
const vector = vec32.create();
|
|
7090
7090
|
polygons.forEach((polygon3) => {
|
|
7091
7091
|
const vertices = polygon3.vertices;
|
|
7092
7092
|
for (let i = 0; i < vertices.length - 2; i++) {
|
|
7093
|
-
|
|
7094
|
-
const volume =
|
|
7093
|
+
vec32.cross(vector, vertices[i + 1], vertices[i + 2]);
|
|
7094
|
+
const volume = vec32.dot(vertices[0], vector) / 6;
|
|
7095
7095
|
totalVolume += volume;
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
const weightedCenter =
|
|
7099
|
-
|
|
7096
|
+
vec32.add(vector, vertices[0], vertices[i + 1]);
|
|
7097
|
+
vec32.add(vector, vector, vertices[i + 2]);
|
|
7098
|
+
const weightedCenter = vec32.scale(vector, vector, 1 / 4 * volume);
|
|
7099
|
+
vec32.add(centerOfMass, centerOfMass, weightedCenter);
|
|
7100
7100
|
}
|
|
7101
7101
|
});
|
|
7102
|
-
|
|
7102
|
+
vec32.scale(centerOfMass, centerOfMass, 1 / totalVolume);
|
|
7103
7103
|
cacheOfCenterOfMass.set(geometry, centerOfMass);
|
|
7104
7104
|
return centerOfMass;
|
|
7105
7105
|
};
|
|
@@ -7189,8 +7189,8 @@ var require_measurements = __commonJS({
|
|
|
7189
7189
|
var require_commonChecks = __commonJS({
|
|
7190
7190
|
"node_modules/@jscad/modeling/src/primitives/commonChecks.js"(exports, module) {
|
|
7191
7191
|
"use strict";
|
|
7192
|
-
var isNumberArray = (array,
|
|
7193
|
-
if (Array.isArray(array) && array.length >=
|
|
7192
|
+
var isNumberArray = (array, dimension2) => {
|
|
7193
|
+
if (Array.isArray(array) && array.length >= dimension2) {
|
|
7194
7194
|
return array.every((n) => Number.isFinite(n));
|
|
7195
7195
|
}
|
|
7196
7196
|
return false;
|
|
@@ -7419,7 +7419,7 @@ var require_cylinderElliptic = __commonJS({
|
|
|
7419
7419
|
"node_modules/@jscad/modeling/src/primitives/cylinderElliptic.js"(exports, module) {
|
|
7420
7420
|
"use strict";
|
|
7421
7421
|
var { EPS: EPS4, TAU } = require_constants();
|
|
7422
|
-
var
|
|
7422
|
+
var vec32 = require_vec3();
|
|
7423
7423
|
var geom35 = require_geom3();
|
|
7424
7424
|
var poly3 = require_poly3();
|
|
7425
7425
|
var { sin, cos } = require_trigonometry();
|
|
@@ -7458,25 +7458,25 @@ var require_cylinderElliptic = __commonJS({
|
|
|
7458
7458
|
const minangle = Math.acos((minradius * minradius + minradius * minradius - EPS4 * EPS4) / (2 * minradius * minradius));
|
|
7459
7459
|
if (rotation < minangle) throw new Error("startAngle and endAngle do not define a significant rotation");
|
|
7460
7460
|
const slices = Math.floor(segments * (rotation / TAU));
|
|
7461
|
-
const start =
|
|
7462
|
-
const end =
|
|
7463
|
-
const ray =
|
|
7464
|
-
const axisX =
|
|
7465
|
-
const axisY =
|
|
7466
|
-
const v1 =
|
|
7467
|
-
const v2 =
|
|
7468
|
-
const v3 =
|
|
7461
|
+
const start = vec32.fromValues(0, 0, -(height / 2));
|
|
7462
|
+
const end = vec32.fromValues(0, 0, height / 2);
|
|
7463
|
+
const ray = vec32.subtract(vec32.create(), end, start);
|
|
7464
|
+
const axisX = vec32.fromValues(1, 0, 0);
|
|
7465
|
+
const axisY = vec32.fromValues(0, 1, 0);
|
|
7466
|
+
const v1 = vec32.create();
|
|
7467
|
+
const v2 = vec32.create();
|
|
7468
|
+
const v3 = vec32.create();
|
|
7469
7469
|
const point = (stack, slice, radius) => {
|
|
7470
7470
|
const angle = slice * rotation + startAngle;
|
|
7471
|
-
|
|
7472
|
-
|
|
7473
|
-
|
|
7474
|
-
|
|
7475
|
-
|
|
7476
|
-
return
|
|
7471
|
+
vec32.scale(v1, axisX, radius[0] * cos(angle));
|
|
7472
|
+
vec32.scale(v2, axisY, radius[1] * sin(angle));
|
|
7473
|
+
vec32.add(v1, v1, v2);
|
|
7474
|
+
vec32.scale(v3, ray, stack);
|
|
7475
|
+
vec32.add(v3, v3, start);
|
|
7476
|
+
return vec32.add(vec32.create(), v1, v3);
|
|
7477
7477
|
};
|
|
7478
7478
|
const fromPoints = (...points) => {
|
|
7479
|
-
const newpoints = points.map((point2) =>
|
|
7479
|
+
const newpoints = points.map((point2) => vec32.add(vec32.create(), point2, center));
|
|
7480
7480
|
return poly3.create(newpoints);
|
|
7481
7481
|
};
|
|
7482
7482
|
const polygons = [];
|
|
@@ -7551,7 +7551,7 @@ var require_ellipsoid = __commonJS({
|
|
|
7551
7551
|
"node_modules/@jscad/modeling/src/primitives/ellipsoid.js"(exports, module) {
|
|
7552
7552
|
"use strict";
|
|
7553
7553
|
var { TAU } = require_constants();
|
|
7554
|
-
var
|
|
7554
|
+
var vec32 = require_vec3();
|
|
7555
7555
|
var geom35 = require_geom3();
|
|
7556
7556
|
var poly3 = require_poly3();
|
|
7557
7557
|
var { sin, cos } = require_trigonometry();
|
|
@@ -7569,17 +7569,17 @@ var require_ellipsoid = __commonJS({
|
|
|
7569
7569
|
if (!radius.every((n) => n >= 0)) throw new Error("radius values must be positive");
|
|
7570
7570
|
if (!isGTE(segments, 4)) throw new Error("segments must be four or more");
|
|
7571
7571
|
if (radius[0] === 0 || radius[1] === 0 || radius[2] === 0) return geom35.create();
|
|
7572
|
-
const xvector =
|
|
7573
|
-
const yvector =
|
|
7574
|
-
const zvector =
|
|
7572
|
+
const xvector = vec32.scale(vec32.create(), vec32.normalize(vec32.create(), axes2[0]), radius[0]);
|
|
7573
|
+
const yvector = vec32.scale(vec32.create(), vec32.normalize(vec32.create(), axes2[1]), radius[1]);
|
|
7574
|
+
const zvector = vec32.scale(vec32.create(), vec32.normalize(vec32.create(), axes2[2]), radius[2]);
|
|
7575
7575
|
const qsegments = Math.round(segments / 4);
|
|
7576
7576
|
let prevcylinderpoint;
|
|
7577
7577
|
const polygons = [];
|
|
7578
|
-
const p1 =
|
|
7579
|
-
const p2 =
|
|
7578
|
+
const p1 = vec32.create();
|
|
7579
|
+
const p2 = vec32.create();
|
|
7580
7580
|
for (let slice1 = 0; slice1 <= segments; slice1++) {
|
|
7581
7581
|
const angle = TAU * slice1 / segments;
|
|
7582
|
-
const cylinderpoint =
|
|
7582
|
+
const cylinderpoint = vec32.add(vec32.create(), vec32.scale(p1, xvector, cos(angle)), vec32.scale(p2, yvector, sin(angle)));
|
|
7583
7583
|
if (slice1 > 0) {
|
|
7584
7584
|
let prevcospitch, prevsinpitch;
|
|
7585
7585
|
for (let slice2 = 0; slice2 <= qsegments; slice2++) {
|
|
@@ -7589,28 +7589,28 @@ var require_ellipsoid = __commonJS({
|
|
|
7589
7589
|
if (slice2 > 0) {
|
|
7590
7590
|
let points = [];
|
|
7591
7591
|
let point;
|
|
7592
|
-
point =
|
|
7593
|
-
points.push(
|
|
7594
|
-
point =
|
|
7595
|
-
points.push(
|
|
7592
|
+
point = vec32.subtract(vec32.create(), vec32.scale(p1, prevcylinderpoint, prevcospitch), vec32.scale(p2, zvector, prevsinpitch));
|
|
7593
|
+
points.push(vec32.add(point, point, center));
|
|
7594
|
+
point = vec32.subtract(vec32.create(), vec32.scale(p1, cylinderpoint, prevcospitch), vec32.scale(p2, zvector, prevsinpitch));
|
|
7595
|
+
points.push(vec32.add(point, point, center));
|
|
7596
7596
|
if (slice2 < qsegments) {
|
|
7597
|
-
point =
|
|
7598
|
-
points.push(
|
|
7597
|
+
point = vec32.subtract(vec32.create(), vec32.scale(p1, cylinderpoint, cospitch), vec32.scale(p2, zvector, sinpitch));
|
|
7598
|
+
points.push(vec32.add(point, point, center));
|
|
7599
7599
|
}
|
|
7600
|
-
point =
|
|
7601
|
-
points.push(
|
|
7600
|
+
point = vec32.subtract(vec32.create(), vec32.scale(p1, prevcylinderpoint, cospitch), vec32.scale(p2, zvector, sinpitch));
|
|
7601
|
+
points.push(vec32.add(point, point, center));
|
|
7602
7602
|
polygons.push(poly3.create(points));
|
|
7603
7603
|
points = [];
|
|
7604
|
-
point =
|
|
7605
|
-
points.push(
|
|
7606
|
-
point =
|
|
7607
|
-
points.push(
|
|
7604
|
+
point = vec32.add(vec32.create(), vec32.scale(p1, prevcylinderpoint, prevcospitch), vec32.scale(p2, zvector, prevsinpitch));
|
|
7605
|
+
points.push(vec32.add(vec32.create(), center, point));
|
|
7606
|
+
point = vec32.add(point, vec32.scale(p1, cylinderpoint, prevcospitch), vec32.scale(p2, zvector, prevsinpitch));
|
|
7607
|
+
points.push(vec32.add(vec32.create(), center, point));
|
|
7608
7608
|
if (slice2 < qsegments) {
|
|
7609
|
-
point =
|
|
7610
|
-
points.push(
|
|
7609
|
+
point = vec32.add(point, vec32.scale(p1, cylinderpoint, cospitch), vec32.scale(p2, zvector, sinpitch));
|
|
7610
|
+
points.push(vec32.add(vec32.create(), center, point));
|
|
7611
7611
|
}
|
|
7612
|
-
point =
|
|
7613
|
-
points.push(
|
|
7612
|
+
point = vec32.add(point, vec32.scale(p1, prevcylinderpoint, cospitch), vec32.scale(p2, zvector, sinpitch));
|
|
7613
|
+
points.push(vec32.add(vec32.create(), center, point));
|
|
7614
7614
|
points.reverse();
|
|
7615
7615
|
polygons.push(poly3.create(points));
|
|
7616
7616
|
}
|
|
@@ -7684,7 +7684,7 @@ var require_geodesicSphere = __commonJS({
|
|
|
7684
7684
|
"node_modules/@jscad/modeling/src/primitives/geodesicSphere.js"(exports, module) {
|
|
7685
7685
|
"use strict";
|
|
7686
7686
|
var mat42 = require_mat4();
|
|
7687
|
-
var
|
|
7687
|
+
var vec32 = require_vec3();
|
|
7688
7688
|
var geom35 = require_geom3();
|
|
7689
7689
|
var polyhedron = require_polyhedron();
|
|
7690
7690
|
var { isGTE } = require_commonChecks();
|
|
@@ -7754,7 +7754,7 @@ var require_geodesicSphere = __commonJS({
|
|
|
7754
7754
|
q[1] = mix3(mix3(p1, p2, s1), p3, t0);
|
|
7755
7755
|
q[2] = mix3(mix3(p1, p2, s2), p3, t1);
|
|
7756
7756
|
for (let k = 0; k < 3; k++) {
|
|
7757
|
-
const r =
|
|
7757
|
+
const r = vec32.length(q[k]);
|
|
7758
7758
|
for (let l = 0; l < 3; l++) {
|
|
7759
7759
|
q[k][l] /= r;
|
|
7760
7760
|
}
|
|
@@ -7768,7 +7768,7 @@ var require_geodesicSphere = __commonJS({
|
|
|
7768
7768
|
q[1] = mix3(mix3(p1, p2, s3), p3, t1);
|
|
7769
7769
|
q[2] = mix3(mix3(p1, p2, s2), p3, t1);
|
|
7770
7770
|
for (let k = 0; k < 3; k++) {
|
|
7771
|
-
const r =
|
|
7771
|
+
const r = vec32.length(q[k]);
|
|
7772
7772
|
for (let l = 0; l < 3; l++) {
|
|
7773
7773
|
q[k][l] /= r;
|
|
7774
7774
|
}
|
|
@@ -7906,7 +7906,7 @@ var require_roundedCuboid = __commonJS({
|
|
|
7906
7906
|
"use strict";
|
|
7907
7907
|
var { EPS: EPS4, TAU } = require_constants();
|
|
7908
7908
|
var vec2 = require_vec2();
|
|
7909
|
-
var
|
|
7909
|
+
var vec32 = require_vec3();
|
|
7910
7910
|
var geom35 = require_geom3();
|
|
7911
7911
|
var poly3 = require_poly3();
|
|
7912
7912
|
var { sin, cos } = require_trigonometry();
|
|
@@ -7921,10 +7921,10 @@ var require_roundedCuboid = __commonJS({
|
|
|
7921
7921
|
let layeroffset = size[2] - (radius - radius * sinpitch);
|
|
7922
7922
|
if (!positive) layeroffset = radius - radius * sinpitch - size[2];
|
|
7923
7923
|
layerradius = layerradius > EPS4 ? layerradius : 0;
|
|
7924
|
-
const corner0 =
|
|
7925
|
-
const corner1 =
|
|
7926
|
-
const corner2 =
|
|
7927
|
-
const corner3 =
|
|
7924
|
+
const corner0 = vec32.add(vec32.create(), center, [size[0] - radius, size[1] - radius, layeroffset]);
|
|
7925
|
+
const corner1 = vec32.add(vec32.create(), center, [radius - size[0], size[1] - radius, layeroffset]);
|
|
7926
|
+
const corner2 = vec32.add(vec32.create(), center, [radius - size[0], radius - size[1], layeroffset]);
|
|
7927
|
+
const corner3 = vec32.add(vec32.create(), center, [size[0] - radius, radius - size[1], layeroffset]);
|
|
7928
7928
|
const corner0Points = [];
|
|
7929
7929
|
const corner1Points = [];
|
|
7930
7930
|
const corner2Points = [];
|
|
@@ -7933,14 +7933,14 @@ var require_roundedCuboid = __commonJS({
|
|
|
7933
7933
|
const radians = layersegments > 0 ? TAU / 4 * i / layersegments : 0;
|
|
7934
7934
|
const point2d = vec2.fromAngleRadians(vec2.create(), radians);
|
|
7935
7935
|
vec2.scale(point2d, point2d, layerradius);
|
|
7936
|
-
const point3d =
|
|
7937
|
-
corner0Points.push(
|
|
7938
|
-
|
|
7939
|
-
corner1Points.push(
|
|
7940
|
-
|
|
7941
|
-
corner2Points.push(
|
|
7942
|
-
|
|
7943
|
-
corner3Points.push(
|
|
7936
|
+
const point3d = vec32.fromVec2(vec32.create(), point2d);
|
|
7937
|
+
corner0Points.push(vec32.add(vec32.create(), corner0, point3d));
|
|
7938
|
+
vec32.rotateZ(point3d, point3d, [0, 0, 0], TAU / 4);
|
|
7939
|
+
corner1Points.push(vec32.add(vec32.create(), corner1, point3d));
|
|
7940
|
+
vec32.rotateZ(point3d, point3d, [0, 0, 0], TAU / 4);
|
|
7941
|
+
corner2Points.push(vec32.add(vec32.create(), corner2, point3d));
|
|
7942
|
+
vec32.rotateZ(point3d, point3d, [0, 0, 0], TAU / 4);
|
|
7943
|
+
corner3Points.push(vec32.add(vec32.create(), corner3, point3d));
|
|
7944
7944
|
}
|
|
7945
7945
|
if (!positive) {
|
|
7946
7946
|
corner0Points.reverse();
|
|
@@ -8058,7 +8058,7 @@ var require_roundedCylinder = __commonJS({
|
|
|
8058
8058
|
"node_modules/@jscad/modeling/src/primitives/roundedCylinder.js"(exports, module) {
|
|
8059
8059
|
"use strict";
|
|
8060
8060
|
var { EPS: EPS4, TAU } = require_constants();
|
|
8061
|
-
var
|
|
8061
|
+
var vec32 = require_vec3();
|
|
8062
8062
|
var geom35 = require_geom3();
|
|
8063
8063
|
var poly3 = require_poly3();
|
|
8064
8064
|
var { sin, cos } = require_trigonometry();
|
|
@@ -8083,38 +8083,38 @@ var require_roundedCylinder = __commonJS({
|
|
|
8083
8083
|
if (roundRadius === 0) return cylinder2({ center, height, radius });
|
|
8084
8084
|
const start = [0, 0, -(height / 2)];
|
|
8085
8085
|
const end = [0, 0, height / 2];
|
|
8086
|
-
const direction =
|
|
8087
|
-
const length =
|
|
8086
|
+
const direction = vec32.subtract(vec32.create(), end, start);
|
|
8087
|
+
const length = vec32.length(direction);
|
|
8088
8088
|
if (2 * roundRadius > length - EPS4) throw new Error("height must be larger than twice roundRadius");
|
|
8089
8089
|
let defaultnormal;
|
|
8090
8090
|
if (Math.abs(direction[0]) > Math.abs(direction[1])) {
|
|
8091
|
-
defaultnormal =
|
|
8091
|
+
defaultnormal = vec32.fromValues(0, 1, 0);
|
|
8092
8092
|
} else {
|
|
8093
|
-
defaultnormal =
|
|
8093
|
+
defaultnormal = vec32.fromValues(1, 0, 0);
|
|
8094
8094
|
}
|
|
8095
|
-
const zvector =
|
|
8096
|
-
const xvector =
|
|
8097
|
-
const yvector =
|
|
8098
|
-
|
|
8099
|
-
|
|
8095
|
+
const zvector = vec32.scale(vec32.create(), vec32.normalize(vec32.create(), direction), roundRadius);
|
|
8096
|
+
const xvector = vec32.scale(vec32.create(), vec32.normalize(vec32.create(), vec32.cross(vec32.create(), zvector, defaultnormal)), radius);
|
|
8097
|
+
const yvector = vec32.scale(vec32.create(), vec32.normalize(vec32.create(), vec32.cross(vec32.create(), xvector, zvector)), radius);
|
|
8098
|
+
vec32.add(start, start, zvector);
|
|
8099
|
+
vec32.subtract(end, end, zvector);
|
|
8100
8100
|
const qsegments = Math.floor(0.25 * segments);
|
|
8101
8101
|
const fromPoints = (points) => {
|
|
8102
|
-
const newpoints = points.map((point) =>
|
|
8102
|
+
const newpoints = points.map((point) => vec32.add(point, point, center));
|
|
8103
8103
|
return poly3.create(newpoints);
|
|
8104
8104
|
};
|
|
8105
8105
|
const polygons = [];
|
|
8106
|
-
const v1 =
|
|
8107
|
-
const v2 =
|
|
8106
|
+
const v1 = vec32.create();
|
|
8107
|
+
const v2 = vec32.create();
|
|
8108
8108
|
let prevcylinderpoint;
|
|
8109
8109
|
for (let slice1 = 0; slice1 <= segments; slice1++) {
|
|
8110
8110
|
const angle = TAU * slice1 / segments;
|
|
8111
|
-
const cylinderpoint =
|
|
8111
|
+
const cylinderpoint = vec32.add(vec32.create(), vec32.scale(v1, xvector, cos(angle)), vec32.scale(v2, yvector, sin(angle)));
|
|
8112
8112
|
if (slice1 > 0) {
|
|
8113
8113
|
let points = [];
|
|
8114
|
-
points.push(
|
|
8115
|
-
points.push(
|
|
8116
|
-
points.push(
|
|
8117
|
-
points.push(
|
|
8114
|
+
points.push(vec32.add(vec32.create(), start, cylinderpoint));
|
|
8115
|
+
points.push(vec32.add(vec32.create(), start, prevcylinderpoint));
|
|
8116
|
+
points.push(vec32.add(vec32.create(), end, prevcylinderpoint));
|
|
8117
|
+
points.push(vec32.add(vec32.create(), end, cylinderpoint));
|
|
8118
8118
|
polygons.push(fromPoints(points));
|
|
8119
8119
|
let prevcospitch, prevsinpitch;
|
|
8120
8120
|
for (let slice2 = 0; slice2 <= qsegments; slice2++) {
|
|
@@ -8124,31 +8124,31 @@ var require_roundedCylinder = __commonJS({
|
|
|
8124
8124
|
if (slice2 > 0) {
|
|
8125
8125
|
points = [];
|
|
8126
8126
|
let point;
|
|
8127
|
-
point =
|
|
8127
|
+
point = vec32.add(vec32.create(), start, vec32.subtract(v1, vec32.scale(v1, prevcylinderpoint, prevcospitch), vec32.scale(v2, zvector, prevsinpitch)));
|
|
8128
8128
|
points.push(point);
|
|
8129
|
-
point =
|
|
8129
|
+
point = vec32.add(vec32.create(), start, vec32.subtract(v1, vec32.scale(v1, cylinderpoint, prevcospitch), vec32.scale(v2, zvector, prevsinpitch)));
|
|
8130
8130
|
points.push(point);
|
|
8131
8131
|
if (slice2 < qsegments) {
|
|
8132
|
-
point =
|
|
8132
|
+
point = vec32.add(vec32.create(), start, vec32.subtract(v1, vec32.scale(v1, cylinderpoint, cospitch), vec32.scale(v2, zvector, sinpitch)));
|
|
8133
8133
|
points.push(point);
|
|
8134
8134
|
}
|
|
8135
|
-
point =
|
|
8135
|
+
point = vec32.add(vec32.create(), start, vec32.subtract(v1, vec32.scale(v1, prevcylinderpoint, cospitch), vec32.scale(v2, zvector, sinpitch)));
|
|
8136
8136
|
points.push(point);
|
|
8137
8137
|
polygons.push(fromPoints(points));
|
|
8138
8138
|
points = [];
|
|
8139
|
-
point =
|
|
8140
|
-
|
|
8139
|
+
point = vec32.add(vec32.create(), vec32.scale(v1, prevcylinderpoint, prevcospitch), vec32.scale(v2, zvector, prevsinpitch));
|
|
8140
|
+
vec32.add(point, point, end);
|
|
8141
8141
|
points.push(point);
|
|
8142
|
-
point =
|
|
8143
|
-
|
|
8142
|
+
point = vec32.add(vec32.create(), vec32.scale(v1, cylinderpoint, prevcospitch), vec32.scale(v2, zvector, prevsinpitch));
|
|
8143
|
+
vec32.add(point, point, end);
|
|
8144
8144
|
points.push(point);
|
|
8145
8145
|
if (slice2 < qsegments) {
|
|
8146
|
-
point =
|
|
8147
|
-
|
|
8146
|
+
point = vec32.add(vec32.create(), vec32.scale(v1, cylinderpoint, cospitch), vec32.scale(v2, zvector, sinpitch));
|
|
8147
|
+
vec32.add(point, point, end);
|
|
8148
8148
|
points.push(point);
|
|
8149
8149
|
}
|
|
8150
|
-
point =
|
|
8151
|
-
|
|
8150
|
+
point = vec32.add(vec32.create(), vec32.scale(v1, prevcylinderpoint, cospitch), vec32.scale(v2, zvector, sinpitch));
|
|
8151
|
+
vec32.add(point, point, end);
|
|
8152
8152
|
points.push(point);
|
|
8153
8153
|
points.reverse();
|
|
8154
8154
|
polygons.push(fromPoints(points));
|
|
@@ -8371,24 +8371,24 @@ var require_calculatePlane = __commonJS({
|
|
|
8371
8371
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/calculatePlane.js"(exports, module) {
|
|
8372
8372
|
"use strict";
|
|
8373
8373
|
var plane = require_plane();
|
|
8374
|
-
var
|
|
8374
|
+
var vec32 = require_vec3();
|
|
8375
8375
|
var calculatePlane = (slice) => {
|
|
8376
8376
|
const edges = slice.edges;
|
|
8377
8377
|
if (edges.length < 3) throw new Error("slices must have 3 or more edges to calculate a plane");
|
|
8378
|
-
const midpoint = edges.reduce((point, edge) =>
|
|
8379
|
-
|
|
8378
|
+
const midpoint = edges.reduce((point, edge) => vec32.add(vec32.create(), point, edge[0]), vec32.create());
|
|
8379
|
+
vec32.scale(midpoint, midpoint, 1 / edges.length);
|
|
8380
8380
|
let farthestEdge;
|
|
8381
8381
|
let distance = 0;
|
|
8382
8382
|
edges.forEach((edge) => {
|
|
8383
|
-
if (!
|
|
8384
|
-
const d =
|
|
8383
|
+
if (!vec32.equals(edge[0], edge[1])) {
|
|
8384
|
+
const d = vec32.squaredDistance(midpoint, edge[0]);
|
|
8385
8385
|
if (d > distance) {
|
|
8386
8386
|
farthestEdge = edge;
|
|
8387
8387
|
distance = d;
|
|
8388
8388
|
}
|
|
8389
8389
|
}
|
|
8390
8390
|
});
|
|
8391
|
-
const beforeEdge = edges.find((edge) =>
|
|
8391
|
+
const beforeEdge = edges.find((edge) => vec32.equals(edge[1], farthestEdge[0]));
|
|
8392
8392
|
return plane.fromPoints(plane.create(), beforeEdge[0], farthestEdge[0], farthestEdge[1]);
|
|
8393
8393
|
};
|
|
8394
8394
|
module.exports = calculatePlane;
|
|
@@ -8414,7 +8414,7 @@ var require_clone11 = __commonJS({
|
|
|
8414
8414
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/clone.js"(exports, module) {
|
|
8415
8415
|
"use strict";
|
|
8416
8416
|
var create = require_create13();
|
|
8417
|
-
var
|
|
8417
|
+
var vec32 = require_vec3();
|
|
8418
8418
|
var clone = (...params) => {
|
|
8419
8419
|
let out;
|
|
8420
8420
|
let slice;
|
|
@@ -8425,7 +8425,7 @@ var require_clone11 = __commonJS({
|
|
|
8425
8425
|
out = params[0];
|
|
8426
8426
|
slice = params[1];
|
|
8427
8427
|
}
|
|
8428
|
-
out.edges = slice.edges.map((edge) => [
|
|
8428
|
+
out.edges = slice.edges.map((edge) => [vec32.clone(edge[0]), vec32.clone(edge[1])]);
|
|
8429
8429
|
return out;
|
|
8430
8430
|
};
|
|
8431
8431
|
module.exports = clone;
|
|
@@ -8436,7 +8436,7 @@ var require_clone11 = __commonJS({
|
|
|
8436
8436
|
var require_equals8 = __commonJS({
|
|
8437
8437
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/equals.js"(exports, module) {
|
|
8438
8438
|
"use strict";
|
|
8439
|
-
var
|
|
8439
|
+
var vec32 = require_vec3();
|
|
8440
8440
|
var equals = (a, b) => {
|
|
8441
8441
|
const aedges = a.edges;
|
|
8442
8442
|
const bedges = b.edges;
|
|
@@ -8445,7 +8445,7 @@ var require_equals8 = __commonJS({
|
|
|
8445
8445
|
}
|
|
8446
8446
|
const isEqual = aedges.reduce((acc, aedge, i) => {
|
|
8447
8447
|
const bedge = bedges[i];
|
|
8448
|
-
const d =
|
|
8448
|
+
const d = vec32.squaredDistance(aedge[0], bedge[0]);
|
|
8449
8449
|
return acc && d < Number.EPSILON;
|
|
8450
8450
|
}, true);
|
|
8451
8451
|
return isEqual;
|
|
@@ -8458,7 +8458,7 @@ var require_equals8 = __commonJS({
|
|
|
8458
8458
|
var require_fromPoints8 = __commonJS({
|
|
8459
8459
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/fromPoints.js"(exports, module) {
|
|
8460
8460
|
"use strict";
|
|
8461
|
-
var
|
|
8461
|
+
var vec32 = require_vec3();
|
|
8462
8462
|
var create = require_create13();
|
|
8463
8463
|
var fromPoints = (points) => {
|
|
8464
8464
|
if (!Array.isArray(points)) throw new Error("the given points must be an array");
|
|
@@ -8466,7 +8466,7 @@ var require_fromPoints8 = __commonJS({
|
|
|
8466
8466
|
const edges = [];
|
|
8467
8467
|
let prevpoint = points[points.length - 1];
|
|
8468
8468
|
points.forEach((point) => {
|
|
8469
|
-
if (point.length === 2) edges.push([
|
|
8469
|
+
if (point.length === 2) edges.push([vec32.fromVec2(vec32.create(), prevpoint), vec32.fromVec2(vec32.create(), point)]);
|
|
8470
8470
|
if (point.length === 3) edges.push([prevpoint, point]);
|
|
8471
8471
|
prevpoint = point;
|
|
8472
8472
|
});
|
|
@@ -8480,13 +8480,13 @@ var require_fromPoints8 = __commonJS({
|
|
|
8480
8480
|
var require_fromSides = __commonJS({
|
|
8481
8481
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/fromSides.js"(exports, module) {
|
|
8482
8482
|
"use strict";
|
|
8483
|
-
var
|
|
8483
|
+
var vec32 = require_vec3();
|
|
8484
8484
|
var create = require_create13();
|
|
8485
8485
|
var fromSides = (sides) => {
|
|
8486
8486
|
if (!Array.isArray(sides)) throw new Error("the given sides must be an array");
|
|
8487
8487
|
const edges = [];
|
|
8488
8488
|
sides.forEach((side) => {
|
|
8489
|
-
edges.push([
|
|
8489
|
+
edges.push([vec32.fromVec2(vec32.create(), side[0]), vec32.fromVec2(vec32.create(), side[1])]);
|
|
8490
8490
|
});
|
|
8491
8491
|
return create(edges);
|
|
8492
8492
|
};
|
|
@@ -9078,16 +9078,16 @@ var require_polygonHierarchy = __commonJS({
|
|
|
9078
9078
|
var geom2 = require_geom2();
|
|
9079
9079
|
var plane = require_plane();
|
|
9080
9080
|
var vec2 = require_vec2();
|
|
9081
|
-
var
|
|
9081
|
+
var vec32 = require_vec3();
|
|
9082
9082
|
var calculatePlane = require_calculatePlane();
|
|
9083
9083
|
var assignHoles = require_assignHoles();
|
|
9084
9084
|
var PolygonHierarchy = class {
|
|
9085
9085
|
constructor(slice) {
|
|
9086
9086
|
this.plane = calculatePlane(slice);
|
|
9087
|
-
const rightvector =
|
|
9088
|
-
const perp =
|
|
9089
|
-
this.v =
|
|
9090
|
-
this.u =
|
|
9087
|
+
const rightvector = vec32.orthogonal(vec32.create(), this.plane);
|
|
9088
|
+
const perp = vec32.cross(vec32.create(), this.plane, rightvector);
|
|
9089
|
+
this.v = vec32.normalize(perp, perp);
|
|
9090
|
+
this.u = vec32.cross(vec32.create(), this.v, this.plane);
|
|
9091
9091
|
this.basisMap = /* @__PURE__ */ new Map();
|
|
9092
9092
|
const projected = slice.edges.map((e) => e.map((v) => this.to2D(v)));
|
|
9093
9093
|
const geometry = geom2.create(projected);
|
|
@@ -9097,7 +9097,7 @@ var require_polygonHierarchy = __commonJS({
|
|
|
9097
9097
|
* project a 3D point onto the 2D plane
|
|
9098
9098
|
*/
|
|
9099
9099
|
to2D(vector3) {
|
|
9100
|
-
const vector2 = vec2.fromValues(
|
|
9100
|
+
const vector2 = vec2.fromValues(vec32.dot(vector3, this.u), vec32.dot(vector3, this.v));
|
|
9101
9101
|
this.basisMap.set(vector2, vector3);
|
|
9102
9102
|
return vector2;
|
|
9103
9103
|
}
|
|
@@ -9110,11 +9110,11 @@ var require_polygonHierarchy = __commonJS({
|
|
|
9110
9110
|
return original;
|
|
9111
9111
|
} else {
|
|
9112
9112
|
console.log("Warning: point not in original slice");
|
|
9113
|
-
const v1 =
|
|
9114
|
-
const v2 =
|
|
9115
|
-
const planeOrigin =
|
|
9116
|
-
const v3 =
|
|
9117
|
-
return
|
|
9113
|
+
const v1 = vec32.scale(vec32.create(), this.u, vector2[0]);
|
|
9114
|
+
const v2 = vec32.scale(vec32.create(), this.v, vector2[1]);
|
|
9115
|
+
const planeOrigin = vec32.scale(vec32.create(), plane, plane[3]);
|
|
9116
|
+
const v3 = vec32.add(v1, v1, planeOrigin);
|
|
9117
|
+
return vec32.add(v2, v2, v3);
|
|
9118
9118
|
}
|
|
9119
9119
|
}
|
|
9120
9120
|
};
|
|
@@ -9158,8 +9158,8 @@ var require_toPolygons2 = __commonJS({
|
|
|
9158
9158
|
var require_toString11 = __commonJS({
|
|
9159
9159
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/toString.js"(exports, module) {
|
|
9160
9160
|
"use strict";
|
|
9161
|
-
var
|
|
9162
|
-
var edgesToString = (edges) => edges.reduce((result, edge) => result += `[${
|
|
9161
|
+
var vec32 = require_vec3();
|
|
9162
|
+
var edgesToString = (edges) => edges.reduce((result, edge) => result += `[${vec32.toString(edge[0])}, ${vec32.toString(edge[1])}], `, "");
|
|
9163
9163
|
var toString = (slice) => `[${edgesToString(slice.edges)}]`;
|
|
9164
9164
|
module.exports = toString;
|
|
9165
9165
|
}
|
|
@@ -9169,10 +9169,10 @@ var require_toString11 = __commonJS({
|
|
|
9169
9169
|
var require_transform11 = __commonJS({
|
|
9170
9170
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/transform.js"(exports, module) {
|
|
9171
9171
|
"use strict";
|
|
9172
|
-
var
|
|
9172
|
+
var vec32 = require_vec3();
|
|
9173
9173
|
var create = require_create13();
|
|
9174
9174
|
var transform = (matrix, slice) => {
|
|
9175
|
-
const edges = slice.edges.map((edge) => [
|
|
9175
|
+
const edges = slice.edges.map((edge) => [vec32.transform(vec32.create(), edge[0], matrix), vec32.transform(vec32.create(), edge[1], matrix)]);
|
|
9176
9176
|
return create(edges);
|
|
9177
9177
|
};
|
|
9178
9178
|
module.exports = transform;
|
|
@@ -9204,14 +9204,14 @@ var require_slice = __commonJS({
|
|
|
9204
9204
|
var require_repair = __commonJS({
|
|
9205
9205
|
"node_modules/@jscad/modeling/src/operations/extrusions/slice/repair.js"(exports, module) {
|
|
9206
9206
|
"use strict";
|
|
9207
|
-
var
|
|
9207
|
+
var vec32 = require_vec3();
|
|
9208
9208
|
var create = require_create13();
|
|
9209
9209
|
var repair = (slice) => {
|
|
9210
9210
|
if (!slice.edges) return slice;
|
|
9211
9211
|
let edges = slice.edges;
|
|
9212
9212
|
const vertexMap = /* @__PURE__ */ new Map();
|
|
9213
9213
|
const edgeCount = /* @__PURE__ */ new Map();
|
|
9214
|
-
edges = edges.filter((e) => !
|
|
9214
|
+
edges = edges.filter((e) => !vec32.equals(e[0], e[1]));
|
|
9215
9215
|
edges.forEach((edge) => {
|
|
9216
9216
|
const inKey = edge[0].toString();
|
|
9217
9217
|
const outKey = edge[1].toString();
|
|
@@ -9232,7 +9232,7 @@ var require_repair = __commonJS({
|
|
|
9232
9232
|
let bestReplacement;
|
|
9233
9233
|
missingOut.forEach((key2) => {
|
|
9234
9234
|
const v2 = vertexMap.get(key2);
|
|
9235
|
-
const distance =
|
|
9235
|
+
const distance = vec32.distance(v1, v2);
|
|
9236
9236
|
if (distance < bestDistance) {
|
|
9237
9237
|
bestDistance = distance;
|
|
9238
9238
|
bestReplacement = v2;
|
|
@@ -9256,7 +9256,7 @@ var require_extrudeWalls = __commonJS({
|
|
|
9256
9256
|
"node_modules/@jscad/modeling/src/operations/extrusions/extrudeWalls.js"(exports, module) {
|
|
9257
9257
|
"use strict";
|
|
9258
9258
|
var { EPS: EPS4 } = require_constants();
|
|
9259
|
-
var
|
|
9259
|
+
var vec32 = require_vec3();
|
|
9260
9260
|
var poly3 = require_poly3();
|
|
9261
9261
|
var slice = require_slice();
|
|
9262
9262
|
var gcd = (a, b) => {
|
|
@@ -9280,15 +9280,15 @@ var require_extrudeWalls = __commonJS({
|
|
|
9280
9280
|
if (multiple === 1) {
|
|
9281
9281
|
return edges;
|
|
9282
9282
|
}
|
|
9283
|
-
const divisor =
|
|
9284
|
-
const increment =
|
|
9283
|
+
const divisor = vec32.fromValues(multiple, multiple, multiple);
|
|
9284
|
+
const increment = vec32.create();
|
|
9285
9285
|
const newEdges = [];
|
|
9286
9286
|
edges.forEach((edge) => {
|
|
9287
|
-
|
|
9288
|
-
|
|
9287
|
+
vec32.subtract(increment, edge[1], edge[0]);
|
|
9288
|
+
vec32.divide(increment, increment, divisor);
|
|
9289
9289
|
let prev = edge[0];
|
|
9290
9290
|
for (let i = 1; i <= multiple; ++i) {
|
|
9291
|
-
const next =
|
|
9291
|
+
const next = vec32.add(vec32.create(), prev, increment);
|
|
9292
9292
|
newEdges.push([prev, next]);
|
|
9293
9293
|
prev = next;
|
|
9294
9294
|
}
|
|
@@ -10178,16 +10178,16 @@ var require_fromFakePolygons = __commonJS({
|
|
|
10178
10178
|
var require_to3DWalls = __commonJS({
|
|
10179
10179
|
"node_modules/@jscad/modeling/src/operations/booleans/to3DWalls.js"(exports, module) {
|
|
10180
10180
|
"use strict";
|
|
10181
|
-
var
|
|
10181
|
+
var vec32 = require_vec3();
|
|
10182
10182
|
var geom2 = require_geom2();
|
|
10183
10183
|
var geom35 = require_geom3();
|
|
10184
10184
|
var poly3 = require_poly3();
|
|
10185
10185
|
var to3DWall = (z0, z1, side) => {
|
|
10186
10186
|
const points = [
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10187
|
+
vec32.fromVec2(vec32.create(), side[0], z0),
|
|
10188
|
+
vec32.fromVec2(vec32.create(), side[1], z0),
|
|
10189
|
+
vec32.fromVec2(vec32.create(), side[1], z1),
|
|
10190
|
+
vec32.fromVec2(vec32.create(), side[0], z1)
|
|
10191
10191
|
];
|
|
10192
10192
|
return poly3.create(points);
|
|
10193
10193
|
};
|
|
@@ -10207,15 +10207,15 @@ var require_OrthoNormalBasis = __commonJS({
|
|
|
10207
10207
|
"use strict";
|
|
10208
10208
|
var mat42 = require_mat4();
|
|
10209
10209
|
var vec2 = require_vec2();
|
|
10210
|
-
var
|
|
10210
|
+
var vec32 = require_vec3();
|
|
10211
10211
|
var OrthoNormalBasis = function(plane, rightvector) {
|
|
10212
10212
|
if (arguments.length < 2) {
|
|
10213
|
-
rightvector =
|
|
10213
|
+
rightvector = vec32.orthogonal(vec32.create(), plane);
|
|
10214
10214
|
}
|
|
10215
|
-
this.v =
|
|
10216
|
-
this.u =
|
|
10215
|
+
this.v = vec32.normalize(vec32.create(), vec32.cross(vec32.create(), plane, rightvector));
|
|
10216
|
+
this.u = vec32.cross(vec32.create(), this.v, plane);
|
|
10217
10217
|
this.plane = plane;
|
|
10218
|
-
this.planeorigin =
|
|
10218
|
+
this.planeorigin = vec32.scale(vec32.create(), plane, plane[3]);
|
|
10219
10219
|
};
|
|
10220
10220
|
OrthoNormalBasis.prototype = {
|
|
10221
10221
|
getProjectionMatrix: function() {
|
|
@@ -10239,7 +10239,7 @@ var require_OrthoNormalBasis = __commonJS({
|
|
|
10239
10239
|
);
|
|
10240
10240
|
},
|
|
10241
10241
|
getInverseProjectionMatrix: function() {
|
|
10242
|
-
const p =
|
|
10242
|
+
const p = vec32.scale(vec32.create(), this.plane, this.plane[3]);
|
|
10243
10243
|
return mat42.fromValues(
|
|
10244
10244
|
this.u[0],
|
|
10245
10245
|
this.u[1],
|
|
@@ -10260,13 +10260,13 @@ var require_OrthoNormalBasis = __commonJS({
|
|
|
10260
10260
|
);
|
|
10261
10261
|
},
|
|
10262
10262
|
to2D: function(point) {
|
|
10263
|
-
return vec2.fromValues(
|
|
10263
|
+
return vec2.fromValues(vec32.dot(point, this.u), vec32.dot(point, this.v));
|
|
10264
10264
|
},
|
|
10265
10265
|
to3D: function(point) {
|
|
10266
|
-
const v1 =
|
|
10267
|
-
const v2 =
|
|
10268
|
-
const v3 =
|
|
10269
|
-
const v4 =
|
|
10266
|
+
const v1 = vec32.scale(vec32.create(), this.u, point[0]);
|
|
10267
|
+
const v2 = vec32.scale(vec32.create(), this.v, point[1]);
|
|
10268
|
+
const v3 = vec32.add(v1, v1, this.planeorigin);
|
|
10269
|
+
const v4 = vec32.add(v2, v2, v3);
|
|
10270
10270
|
return v4;
|
|
10271
10271
|
}
|
|
10272
10272
|
};
|
|
@@ -10790,15 +10790,15 @@ var require_Node = __commonJS({
|
|
|
10790
10790
|
var require_splitLineSegmentByPlane = __commonJS({
|
|
10791
10791
|
"node_modules/@jscad/modeling/src/operations/booleans/trees/splitLineSegmentByPlane.js"(exports, module) {
|
|
10792
10792
|
"use strict";
|
|
10793
|
-
var
|
|
10793
|
+
var vec32 = require_vec3();
|
|
10794
10794
|
var splitLineSegmentByPlane = (plane, p1, p2) => {
|
|
10795
|
-
const direction =
|
|
10796
|
-
let lambda = (plane[3] -
|
|
10795
|
+
const direction = vec32.subtract(vec32.create(), p2, p1);
|
|
10796
|
+
let lambda = (plane[3] - vec32.dot(plane, p1)) / vec32.dot(plane, direction);
|
|
10797
10797
|
if (Number.isNaN(lambda)) lambda = 0;
|
|
10798
10798
|
if (lambda > 1) lambda = 1;
|
|
10799
10799
|
if (lambda < 0) lambda = 0;
|
|
10800
|
-
|
|
10801
|
-
|
|
10800
|
+
vec32.scale(direction, direction, lambda);
|
|
10801
|
+
vec32.add(direction, p1, direction);
|
|
10802
10802
|
return direction;
|
|
10803
10803
|
};
|
|
10804
10804
|
module.exports = splitLineSegmentByPlane;
|
|
@@ -10811,7 +10811,7 @@ var require_splitPolygonByPlane = __commonJS({
|
|
|
10811
10811
|
"use strict";
|
|
10812
10812
|
var { EPS: EPS4 } = require_constants();
|
|
10813
10813
|
var plane = require_plane();
|
|
10814
|
-
var
|
|
10814
|
+
var vec32 = require_vec3();
|
|
10815
10815
|
var poly3 = require_poly3();
|
|
10816
10816
|
var splitLineSegmentByPlane = require_splitLineSegmentByPlane();
|
|
10817
10817
|
var EPS_SQUARED = EPS4 * EPS4;
|
|
@@ -10820,7 +10820,7 @@ var require_splitPolygonByPlane = __commonJS({
|
|
|
10820
10820
|
let prevvertex = vertices[vertices.length - 1];
|
|
10821
10821
|
for (let i = 0; i < vertices.length; i++) {
|
|
10822
10822
|
const vertex = vertices[i];
|
|
10823
|
-
if (
|
|
10823
|
+
if (vec32.squaredDistance(vertex, prevvertex) >= EPS_SQUARED) {
|
|
10824
10824
|
result.push(vertex);
|
|
10825
10825
|
}
|
|
10826
10826
|
prevvertex = vertex;
|
|
@@ -10844,14 +10844,14 @@ var require_splitPolygonByPlane = __commonJS({
|
|
|
10844
10844
|
const vertexIsBack = [];
|
|
10845
10845
|
const MINEPS = -EPS4;
|
|
10846
10846
|
for (let i = 0; i < numvertices; i++) {
|
|
10847
|
-
const t =
|
|
10847
|
+
const t = vec32.dot(splane, vertices[i]) - splane[3];
|
|
10848
10848
|
const isback = t < MINEPS;
|
|
10849
10849
|
vertexIsBack.push(isback);
|
|
10850
10850
|
if (t > EPS4) hasfront = true;
|
|
10851
10851
|
if (t < MINEPS) hasback = true;
|
|
10852
10852
|
}
|
|
10853
10853
|
if (!hasfront && !hasback) {
|
|
10854
|
-
const t =
|
|
10854
|
+
const t = vec32.dot(splane, pplane);
|
|
10855
10855
|
result.type = t >= 0 ? 0 : 1;
|
|
10856
10856
|
} else if (!hasback) {
|
|
10857
10857
|
result.type = 2;
|
|
@@ -10913,7 +10913,7 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
10913
10913
|
"node_modules/@jscad/modeling/src/operations/booleans/trees/PolygonTreeNode.js"(exports, module) {
|
|
10914
10914
|
"use strict";
|
|
10915
10915
|
var { EPS: EPS4 } = require_constants();
|
|
10916
|
-
var
|
|
10916
|
+
var vec32 = require_vec3();
|
|
10917
10917
|
var poly3 = require_poly3();
|
|
10918
10918
|
var splitPolygonByPlane = require_splitPolygonByPlane();
|
|
10919
10919
|
var PolygonTreeNode = class _PolygonTreeNode {
|
|
@@ -11017,7 +11017,7 @@ var require_PolygonTreeNode = __commonJS({
|
|
|
11017
11017
|
const bound = poly3.measureBoundingSphere(polygon3);
|
|
11018
11018
|
const sphereradius = bound[3] + EPS4;
|
|
11019
11019
|
const spherecenter = bound;
|
|
11020
|
-
const d =
|
|
11020
|
+
const d = vec32.dot(splane, spherecenter) - splane[3];
|
|
11021
11021
|
if (d > sphereradius) {
|
|
11022
11022
|
frontnodes.push(this);
|
|
11023
11023
|
} else if (d < -sphereradius) {
|
|
@@ -11483,7 +11483,7 @@ var require_minkowskiSum = __commonJS({
|
|
|
11483
11483
|
var require_scissionGeom3 = __commonJS({
|
|
11484
11484
|
"node_modules/@jscad/modeling/src/operations/booleans/scissionGeom3.js"(exports, module) {
|
|
11485
11485
|
"use strict";
|
|
11486
|
-
var
|
|
11486
|
+
var vec32 = require_vec3();
|
|
11487
11487
|
var measureEpsilon = require_measureEpsilon();
|
|
11488
11488
|
var geom35 = require_geom3();
|
|
11489
11489
|
var sortNb = (array) => array.sort((a, b) => a - b).filter((item, pos, ary) => !pos || item !== ary[pos - 1]);
|
|
@@ -11505,16 +11505,16 @@ var require_scissionGeom3 = __commonJS({
|
|
|
11505
11505
|
const polygons = geom35.toPolygons(geometry);
|
|
11506
11506
|
const pl = polygons.length;
|
|
11507
11507
|
const indexesPerPoint = /* @__PURE__ */ new Map();
|
|
11508
|
-
const temp =
|
|
11508
|
+
const temp = vec32.create();
|
|
11509
11509
|
polygons.forEach((polygon3, index) => {
|
|
11510
11510
|
polygon3.vertices.forEach((point) => {
|
|
11511
|
-
insertMapping(indexesPerPoint,
|
|
11511
|
+
insertMapping(indexesPerPoint, vec32.snap(temp, point, eps), index);
|
|
11512
11512
|
});
|
|
11513
11513
|
});
|
|
11514
11514
|
const indexesPerPolygon = polygons.map((polygon3) => {
|
|
11515
11515
|
let indexes = [];
|
|
11516
11516
|
polygon3.vertices.forEach((point) => {
|
|
11517
|
-
indexes = indexes.concat(findMapping(indexesPerPoint,
|
|
11517
|
+
indexes = indexes.concat(findMapping(indexesPerPoint, vec32.snap(temp, point, eps)));
|
|
11518
11518
|
});
|
|
11519
11519
|
return { e: 1, d: sortNb(indexes) };
|
|
11520
11520
|
});
|
|
@@ -11899,11 +11899,11 @@ var require_extrudePolygon = __commonJS({
|
|
|
11899
11899
|
"node_modules/@jscad/modeling/src/operations/expansions/extrudePolygon.js"(exports, module) {
|
|
11900
11900
|
"use strict";
|
|
11901
11901
|
var mat42 = require_mat4();
|
|
11902
|
-
var
|
|
11902
|
+
var vec32 = require_vec3();
|
|
11903
11903
|
var geom35 = require_geom3();
|
|
11904
11904
|
var poly3 = require_poly3();
|
|
11905
11905
|
var extrudePolygon2 = (offsetvector, polygon1) => {
|
|
11906
|
-
const direction =
|
|
11906
|
+
const direction = vec32.dot(poly3.plane(polygon1), offsetvector);
|
|
11907
11907
|
if (direction > 0) {
|
|
11908
11908
|
polygon1 = poly3.invert(polygon1);
|
|
11909
11909
|
}
|
|
@@ -11933,7 +11933,7 @@ var require_expandShell = __commonJS({
|
|
|
11933
11933
|
"use strict";
|
|
11934
11934
|
var { EPS: EPS4, TAU } = require_constants();
|
|
11935
11935
|
var mat42 = require_mat4();
|
|
11936
|
-
var
|
|
11936
|
+
var vec32 = require_vec3();
|
|
11937
11937
|
var fnNumberSort = require_fnNumberSort();
|
|
11938
11938
|
var geom35 = require_geom3();
|
|
11939
11939
|
var poly3 = require_poly3();
|
|
@@ -11978,12 +11978,12 @@ var require_expandShell = __commonJS({
|
|
|
11978
11978
|
let result = geom35.create();
|
|
11979
11979
|
const vertices2planes = /* @__PURE__ */ new Map();
|
|
11980
11980
|
const edges2planes = /* @__PURE__ */ new Map();
|
|
11981
|
-
const v1 =
|
|
11982
|
-
const v2 =
|
|
11981
|
+
const v1 = vec32.create();
|
|
11982
|
+
const v2 = vec32.create();
|
|
11983
11983
|
const polygons = geom35.toPolygons(geometry);
|
|
11984
11984
|
polygons.forEach((polygon3, index) => {
|
|
11985
|
-
const extrudevector =
|
|
11986
|
-
const translatedpolygon = poly3.transform(mat42.fromTranslation(mat42.create(),
|
|
11985
|
+
const extrudevector = vec32.scale(vec32.create(), poly3.plane(polygon3), 2 * delta);
|
|
11986
|
+
const translatedpolygon = poly3.transform(mat42.fromTranslation(mat42.create(), vec32.scale(vec32.create(), extrudevector, -0.5)), polygon3);
|
|
11987
11987
|
const extrudedface = extrudePolygon2(extrudevector, translatedpolygon);
|
|
11988
11988
|
result = unionGeom3Sub(result, extrudedface);
|
|
11989
11989
|
const vertices = polygon3.vertices;
|
|
@@ -11999,18 +11999,18 @@ var require_expandShell = __commonJS({
|
|
|
11999
11999
|
const planes = item[1];
|
|
12000
12000
|
const startpoint = edge[0];
|
|
12001
12001
|
const endpoint = edge[1];
|
|
12002
|
-
const zbase =
|
|
12003
|
-
|
|
12002
|
+
const zbase = vec32.subtract(vec32.create(), endpoint, startpoint);
|
|
12003
|
+
vec32.normalize(zbase, zbase);
|
|
12004
12004
|
const xbase = planes[0];
|
|
12005
|
-
const ybase =
|
|
12005
|
+
const ybase = vec32.cross(vec32.create(), xbase, zbase);
|
|
12006
12006
|
let angles = [];
|
|
12007
12007
|
for (let i = 0; i < segments; i++) {
|
|
12008
12008
|
addUniqueAngle(angles, i * TAU / segments);
|
|
12009
12009
|
}
|
|
12010
12010
|
for (let i = 0, iMax = planes.length; i < iMax; i++) {
|
|
12011
12011
|
const planenormal = planes[i];
|
|
12012
|
-
const si =
|
|
12013
|
-
const co =
|
|
12012
|
+
const si = vec32.dot(ybase, planenormal);
|
|
12013
|
+
const co = vec32.dot(xbase, planenormal);
|
|
12014
12014
|
let angle = Math.atan2(si, co);
|
|
12015
12015
|
if (angle < 0) angle += TAU;
|
|
12016
12016
|
addUniqueAngle(angles, angle);
|
|
@@ -12029,14 +12029,14 @@ var require_expandShell = __commonJS({
|
|
|
12029
12029
|
const angle = angles[i < 0 ? i + numangles : i];
|
|
12030
12030
|
const si = Math.sin(angle);
|
|
12031
12031
|
const co = Math.cos(angle);
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
const p1 =
|
|
12036
|
-
const p2 =
|
|
12032
|
+
vec32.scale(v1, xbase, co * delta);
|
|
12033
|
+
vec32.scale(v2, ybase, si * delta);
|
|
12034
|
+
vec32.add(v1, v1, v2);
|
|
12035
|
+
const p1 = vec32.add(vec32.create(), startpoint, v1);
|
|
12036
|
+
const p2 = vec32.add(vec32.create(), endpoint, v1);
|
|
12037
12037
|
let skip = false;
|
|
12038
12038
|
if (i >= 0) {
|
|
12039
|
-
if (
|
|
12039
|
+
if (vec32.distance(p1, prevp1) < EPS4) {
|
|
12040
12040
|
skip = true;
|
|
12041
12041
|
}
|
|
12042
12042
|
}
|
|
@@ -12066,8 +12066,8 @@ var require_expandShell = __commonJS({
|
|
|
12066
12066
|
let bestzaxisorthogonality = 0;
|
|
12067
12067
|
for (let i = 1; i < planes.length; i++) {
|
|
12068
12068
|
const normal = planes[i];
|
|
12069
|
-
const cross2 =
|
|
12070
|
-
const crosslength =
|
|
12069
|
+
const cross2 = vec32.cross(v1, xaxis, normal);
|
|
12070
|
+
const crosslength = vec32.length(cross2);
|
|
12071
12071
|
if (crosslength > 0.05) {
|
|
12072
12072
|
if (crosslength > bestzaxisorthogonality) {
|
|
12073
12073
|
bestzaxisorthogonality = crosslength;
|
|
@@ -12076,11 +12076,11 @@ var require_expandShell = __commonJS({
|
|
|
12076
12076
|
}
|
|
12077
12077
|
}
|
|
12078
12078
|
if (!bestzaxis) {
|
|
12079
|
-
bestzaxis =
|
|
12079
|
+
bestzaxis = vec32.orthogonal(v1, xaxis);
|
|
12080
12080
|
}
|
|
12081
|
-
const yaxis =
|
|
12082
|
-
|
|
12083
|
-
const zaxis =
|
|
12081
|
+
const yaxis = vec32.cross(v1, xaxis, bestzaxis);
|
|
12082
|
+
vec32.normalize(yaxis, yaxis);
|
|
12083
|
+
const zaxis = vec32.cross(v2, yaxis, xaxis);
|
|
12084
12084
|
const corner = sphere({
|
|
12085
12085
|
center: [vertex[0], vertex[1], vertex[2]],
|
|
12086
12086
|
radius: delta,
|
|
@@ -12329,7 +12329,7 @@ var require_extrudeLinearGeom2 = __commonJS({
|
|
|
12329
12329
|
"node_modules/@jscad/modeling/src/operations/extrusions/extrudeLinearGeom2.js"(exports, module) {
|
|
12330
12330
|
"use strict";
|
|
12331
12331
|
var mat42 = require_mat4();
|
|
12332
|
-
var
|
|
12332
|
+
var vec32 = require_vec3();
|
|
12333
12333
|
var geom2 = require_geom2();
|
|
12334
12334
|
var slice = require_slice();
|
|
12335
12335
|
var extrudeFromSlices = require_extrudeFromSlices();
|
|
@@ -12345,7 +12345,7 @@ var require_extrudeLinearGeom2 = __commonJS({
|
|
|
12345
12345
|
if (twistAngle === 0) {
|
|
12346
12346
|
twistSteps = 1;
|
|
12347
12347
|
}
|
|
12348
|
-
const offsetv =
|
|
12348
|
+
const offsetv = vec32.clone(offset);
|
|
12349
12349
|
const baseSides = geom2.toSides(geometry);
|
|
12350
12350
|
if (baseSides.length === 0) throw new Error("the given geometry cannot be empty");
|
|
12351
12351
|
const baseSlice = slice.fromSides(baseSides);
|
|
@@ -12353,7 +12353,7 @@ var require_extrudeLinearGeom2 = __commonJS({
|
|
|
12353
12353
|
const matrix = mat42.create();
|
|
12354
12354
|
const createTwist = (progress, index, base) => {
|
|
12355
12355
|
const Zrotation = index / twistSteps * twistAngle;
|
|
12356
|
-
const Zoffset =
|
|
12356
|
+
const Zoffset = vec32.scale(vec32.create(), offsetv, index / twistSteps);
|
|
12357
12357
|
mat42.multiply(matrix, mat42.fromZRotation(matrix, Zrotation), mat42.fromTranslation(mat42.create(), Zoffset));
|
|
12358
12358
|
return slice.transform(matrix, base);
|
|
12359
12359
|
};
|
|
@@ -12852,7 +12852,7 @@ var require_minkowski = __commonJS({
|
|
|
12852
12852
|
var require_snapPolygons = __commonJS({
|
|
12853
12853
|
"node_modules/@jscad/modeling/src/operations/modifiers/snapPolygons.js"(exports, module) {
|
|
12854
12854
|
"use strict";
|
|
12855
|
-
var
|
|
12855
|
+
var vec32 = require_vec3();
|
|
12856
12856
|
var poly3 = require_poly3();
|
|
12857
12857
|
var isValidPoly3 = (epsilon, polygon3) => {
|
|
12858
12858
|
const area = Math.abs(poly3.measureArea(polygon3));
|
|
@@ -12860,11 +12860,11 @@ var require_snapPolygons = __commonJS({
|
|
|
12860
12860
|
};
|
|
12861
12861
|
var snapPolygons = (epsilon, polygons) => {
|
|
12862
12862
|
let newpolygons = polygons.map((polygon3) => {
|
|
12863
|
-
const snapvertices = polygon3.vertices.map((vertice) =>
|
|
12863
|
+
const snapvertices = polygon3.vertices.map((vertice) => vec32.snap(vec32.create(), vertice, epsilon));
|
|
12864
12864
|
const newvertices = [];
|
|
12865
12865
|
for (let i = 0; i < snapvertices.length; i++) {
|
|
12866
12866
|
const j = (i + 1) % snapvertices.length;
|
|
12867
|
-
if (!
|
|
12867
|
+
if (!vec32.equals(snapvertices[i], snapvertices[j])) newvertices.push(snapvertices[i]);
|
|
12868
12868
|
}
|
|
12869
12869
|
const newpolygon = poly3.create(newvertices);
|
|
12870
12870
|
if (polygon3.color) newpolygon.color = polygon3.color;
|
|
@@ -12883,7 +12883,7 @@ var require_mergePolygons = __commonJS({
|
|
|
12883
12883
|
"node_modules/@jscad/modeling/src/operations/modifiers/mergePolygons.js"(exports, module) {
|
|
12884
12884
|
"use strict";
|
|
12885
12885
|
var aboutEqualNormals = require_aboutEqualNormals();
|
|
12886
|
-
var
|
|
12886
|
+
var vec32 = require_vec3();
|
|
12887
12887
|
var poly3 = require_poly3();
|
|
12888
12888
|
var createEdges = (polygon3) => {
|
|
12889
12889
|
const points = poly3.toPoints(polygon3);
|
|
@@ -12926,13 +12926,13 @@ var require_mergePolygons = __commonJS({
|
|
|
12926
12926
|
const angle2 = calculateAngle(v0, v12, v22, normal);
|
|
12927
12927
|
return [angle1, angle2];
|
|
12928
12928
|
};
|
|
12929
|
-
var v1 =
|
|
12930
|
-
var v2 =
|
|
12929
|
+
var v1 = vec32.create();
|
|
12930
|
+
var v2 = vec32.create();
|
|
12931
12931
|
var calculateAngle = (prevpoint, point, nextpoint, normal) => {
|
|
12932
|
-
const d0 =
|
|
12933
|
-
const d1 =
|
|
12934
|
-
|
|
12935
|
-
return
|
|
12932
|
+
const d0 = vec32.subtract(v1, point, prevpoint);
|
|
12933
|
+
const d1 = vec32.subtract(v2, nextpoint, point);
|
|
12934
|
+
vec32.cross(d0, d0, d1);
|
|
12935
|
+
return vec32.dot(d0, normal);
|
|
12936
12936
|
};
|
|
12937
12937
|
var createPolygonAnd = (edge) => {
|
|
12938
12938
|
let polygon3;
|
|
@@ -13052,7 +13052,7 @@ var require_insertTjunctions = __commonJS({
|
|
|
13052
13052
|
"node_modules/@jscad/modeling/src/operations/modifiers/insertTjunctions.js"(exports, module) {
|
|
13053
13053
|
"use strict";
|
|
13054
13054
|
var constants = require_constants();
|
|
13055
|
-
var
|
|
13055
|
+
var vec32 = require_vec3();
|
|
13056
13056
|
var poly3 = require_poly3();
|
|
13057
13057
|
var assert = false;
|
|
13058
13058
|
var getTag = (vertex) => `${vertex}`;
|
|
@@ -13236,12 +13236,12 @@ var require_insertTjunctions = __commonJS({
|
|
|
13236
13236
|
const startpos = startvertex;
|
|
13237
13237
|
const endpos = endvertex;
|
|
13238
13238
|
const checkpos = matchingsidestartvertex;
|
|
13239
|
-
const direction =
|
|
13240
|
-
const t =
|
|
13239
|
+
const direction = vec32.subtract(vec32.create(), checkpos, startpos);
|
|
13240
|
+
const t = vec32.dot(vec32.subtract(vec32.create(), endpos, startpos), direction) / vec32.dot(direction, direction);
|
|
13241
13241
|
if (t > 0 && t < 1) {
|
|
13242
|
-
const closestpoint =
|
|
13243
|
-
|
|
13244
|
-
const distancesquared =
|
|
13242
|
+
const closestpoint = vec32.scale(vec32.create(), direction, t);
|
|
13243
|
+
vec32.add(closestpoint, closestpoint, startpos);
|
|
13244
|
+
const distancesquared = vec32.squaredDistance(closestpoint, endpos);
|
|
13245
13245
|
if (distancesquared < constants.EPS * constants.EPS) {
|
|
13246
13246
|
const polygonindex = matchingside.polygonindex;
|
|
13247
13247
|
const polygon3 = newpolygons[polygonindex];
|
|
@@ -13292,15 +13292,15 @@ var require_insertTjunctions = __commonJS({
|
|
|
13292
13292
|
var require_triangulatePolygons = __commonJS({
|
|
13293
13293
|
"node_modules/@jscad/modeling/src/operations/modifiers/triangulatePolygons.js"(exports, module) {
|
|
13294
13294
|
"use strict";
|
|
13295
|
-
var
|
|
13295
|
+
var vec32 = require_vec3();
|
|
13296
13296
|
var poly3 = require_poly3();
|
|
13297
13297
|
var triangulatePolygon = (epsilon, polygon3, triangles) => {
|
|
13298
13298
|
const nv = polygon3.vertices.length;
|
|
13299
13299
|
if (nv > 3) {
|
|
13300
13300
|
if (nv > 4) {
|
|
13301
13301
|
const midpoint = [0, 0, 0];
|
|
13302
|
-
polygon3.vertices.forEach((vertice) =>
|
|
13303
|
-
|
|
13302
|
+
polygon3.vertices.forEach((vertice) => vec32.add(midpoint, midpoint, vertice));
|
|
13303
|
+
vec32.snap(midpoint, vec32.divide(midpoint, midpoint, [nv, nv, nv]), epsilon);
|
|
13304
13304
|
for (let i = 0; i < nv; i++) {
|
|
13305
13305
|
const poly = poly3.create([midpoint, polygon3.vertices[i], polygon3.vertices[(i + 1) % nv]]);
|
|
13306
13306
|
if (polygon3.color) poly.color = polygon3.color;
|
|
@@ -14190,12 +14190,12 @@ var axes = [
|
|
|
14190
14190
|
{ x: 0, y: 0, z: 1 }
|
|
14191
14191
|
];
|
|
14192
14192
|
function rotateVector(v, degrees) {
|
|
14193
|
-
const [x, y,
|
|
14193
|
+
const [x, y, z3] = [degrees.x, degrees.y, degrees.z].map(
|
|
14194
14194
|
(a2) => a2 * Math.PI / 180
|
|
14195
14195
|
);
|
|
14196
14196
|
const a = {
|
|
14197
|
-
x: Math.cos(
|
|
14198
|
-
y: Math.sin(
|
|
14197
|
+
x: Math.cos(z3) * v.x - Math.sin(z3) * v.y,
|
|
14198
|
+
y: Math.sin(z3) * v.x + Math.cos(z3) * v.y,
|
|
14199
14199
|
z: v.z
|
|
14200
14200
|
};
|
|
14201
14201
|
const b = {
|
|
@@ -14494,17 +14494,17 @@ var createBoundsAccumulator = () => {
|
|
|
14494
14494
|
let maxZ = Number.NEGATIVE_INFINITY;
|
|
14495
14495
|
let isEmpty = true;
|
|
14496
14496
|
return {
|
|
14497
|
-
add(x, y,
|
|
14498
|
-
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(
|
|
14497
|
+
add(x, y, z3) {
|
|
14498
|
+
if (!Number.isFinite(x) || !Number.isFinite(y) || !Number.isFinite(z3)) {
|
|
14499
14499
|
return;
|
|
14500
14500
|
}
|
|
14501
14501
|
isEmpty = false;
|
|
14502
14502
|
if (x < minX) minX = x;
|
|
14503
14503
|
if (y < minY) minY = y;
|
|
14504
|
-
if (
|
|
14504
|
+
if (z3 < minZ) minZ = z3;
|
|
14505
14505
|
if (x > maxX) maxX = x;
|
|
14506
14506
|
if (y > maxY) maxY = y;
|
|
14507
|
-
if (
|
|
14507
|
+
if (z3 > maxZ) maxZ = z3;
|
|
14508
14508
|
},
|
|
14509
14509
|
result() {
|
|
14510
14510
|
if (isEmpty) return ZERO_BOX();
|
|
@@ -14848,35 +14848,35 @@ function transformMesh(mesh, translation, rotation, scale) {
|
|
|
14848
14848
|
for (let i = 0; i < result.positions.length; i += 3) {
|
|
14849
14849
|
let x = result.positions[i];
|
|
14850
14850
|
let y = result.positions[i + 1];
|
|
14851
|
-
let
|
|
14851
|
+
let z3 = result.positions[i + 2];
|
|
14852
14852
|
if (scale) {
|
|
14853
14853
|
x *= scale.x;
|
|
14854
14854
|
y *= scale.y;
|
|
14855
|
-
|
|
14855
|
+
z3 *= scale.z;
|
|
14856
14856
|
}
|
|
14857
14857
|
if (rotation) {
|
|
14858
14858
|
const cosY = Math.cos(rotation.y);
|
|
14859
14859
|
const sinY = Math.sin(rotation.y);
|
|
14860
|
-
const rx = x * cosY -
|
|
14861
|
-
const rz = x * sinY +
|
|
14860
|
+
const rx = x * cosY - z3 * sinY;
|
|
14861
|
+
const rz = x * sinY + z3 * cosY;
|
|
14862
14862
|
x = rx;
|
|
14863
|
-
|
|
14864
|
-
const cosX = Math.cos(rotation.x);
|
|
14865
|
-
const sinX = Math.sin(rotation.x);
|
|
14866
|
-
const ry = y * cosX + z * sinX;
|
|
14867
|
-
const rz2 = -y * sinX + z * cosX;
|
|
14868
|
-
y = ry;
|
|
14869
|
-
z = rz2;
|
|
14863
|
+
z3 = rz;
|
|
14870
14864
|
const cosZ = Math.cos(rotation.z);
|
|
14871
14865
|
const sinZ = Math.sin(rotation.z);
|
|
14872
14866
|
const rx2 = x * cosZ + y * sinZ;
|
|
14873
14867
|
const ry2 = -x * sinZ + y * cosZ;
|
|
14874
14868
|
x = rx2;
|
|
14875
14869
|
y = ry2;
|
|
14870
|
+
const cosX = Math.cos(rotation.x);
|
|
14871
|
+
const sinX = Math.sin(rotation.x);
|
|
14872
|
+
const ry = y * cosX + z3 * sinX;
|
|
14873
|
+
const rz2 = -y * sinX + z3 * cosX;
|
|
14874
|
+
y = ry;
|
|
14875
|
+
z3 = rz2;
|
|
14876
14876
|
}
|
|
14877
14877
|
result.positions[i] = x + translation.x;
|
|
14878
14878
|
result.positions[i + 1] = y + translation.y;
|
|
14879
|
-
result.positions[i + 2] =
|
|
14879
|
+
result.positions[i + 2] = z3 + translation.z;
|
|
14880
14880
|
}
|
|
14881
14881
|
if (rotation) {
|
|
14882
14882
|
for (let i = 0; i < result.normals.length; i += 3) {
|
|
@@ -14889,18 +14889,18 @@ function transformMesh(mesh, translation, rotation, scale) {
|
|
|
14889
14889
|
const rnz = nx * sinY + nz * cosY;
|
|
14890
14890
|
nx = rnx;
|
|
14891
14891
|
nz = rnz;
|
|
14892
|
-
const cosX = Math.cos(rotation.x);
|
|
14893
|
-
const sinX = Math.sin(rotation.x);
|
|
14894
|
-
const rny = ny * cosX + nz * sinX;
|
|
14895
|
-
const rnz2 = -ny * sinX + nz * cosX;
|
|
14896
|
-
ny = rny;
|
|
14897
|
-
nz = rnz2;
|
|
14898
14892
|
const cosZ = Math.cos(rotation.z);
|
|
14899
14893
|
const sinZ = Math.sin(rotation.z);
|
|
14900
14894
|
const rnx2 = nx * cosZ + ny * sinZ;
|
|
14901
14895
|
const rny2 = -nx * sinZ + ny * cosZ;
|
|
14902
14896
|
nx = rnx2;
|
|
14903
14897
|
ny = rny2;
|
|
14898
|
+
const cosX = Math.cos(rotation.x);
|
|
14899
|
+
const sinX = Math.sin(rotation.x);
|
|
14900
|
+
const rny = ny * cosX + nz * sinX;
|
|
14901
|
+
const rnz2 = -ny * sinX + nz * cosX;
|
|
14902
|
+
ny = rny;
|
|
14903
|
+
nz = rnz2;
|
|
14904
14904
|
result.normals[i] = nx;
|
|
14905
14905
|
result.normals[i + 1] = ny;
|
|
14906
14906
|
result.normals[i + 2] = nz;
|
|
@@ -15054,9 +15054,9 @@ import { convertJscadModelToGltf } from "jscad-to-gltf";
|
|
|
15054
15054
|
|
|
15055
15055
|
// lib/utils/coordinate-transform.ts
|
|
15056
15056
|
function applyCoordinateTransform(point, config) {
|
|
15057
|
-
let { x, y, z } = point;
|
|
15057
|
+
let { x, y, z: z3 } = point;
|
|
15058
15058
|
if (config.axisMapping) {
|
|
15059
|
-
const original = { x, y, z };
|
|
15059
|
+
const original = { x, y, z: z3 };
|
|
15060
15060
|
if (config.axisMapping.x) {
|
|
15061
15061
|
x = getAxisValue(original, config.axisMapping.x);
|
|
15062
15062
|
}
|
|
@@ -15064,30 +15064,30 @@ function applyCoordinateTransform(point, config) {
|
|
|
15064
15064
|
y = getAxisValue(original, config.axisMapping.y);
|
|
15065
15065
|
}
|
|
15066
15066
|
if (config.axisMapping.z) {
|
|
15067
|
-
|
|
15067
|
+
z3 = getAxisValue(original, config.axisMapping.z);
|
|
15068
15068
|
}
|
|
15069
15069
|
}
|
|
15070
15070
|
x *= config.flipX ?? 1;
|
|
15071
15071
|
y *= config.flipY ?? 1;
|
|
15072
|
-
|
|
15072
|
+
z3 *= config.flipZ ?? 1;
|
|
15073
15073
|
if (config.rotation) {
|
|
15074
15074
|
if (config.rotation.x) {
|
|
15075
15075
|
const rad = config.rotation.x * Math.PI / 180;
|
|
15076
15076
|
const cos = Math.cos(rad);
|
|
15077
15077
|
const sin = Math.sin(rad);
|
|
15078
|
-
const newY = y * cos -
|
|
15079
|
-
const newZ = y * sin +
|
|
15078
|
+
const newY = y * cos - z3 * sin;
|
|
15079
|
+
const newZ = y * sin + z3 * cos;
|
|
15080
15080
|
y = newY;
|
|
15081
|
-
|
|
15081
|
+
z3 = newZ;
|
|
15082
15082
|
}
|
|
15083
15083
|
if (config.rotation.y) {
|
|
15084
15084
|
const rad = config.rotation.y * Math.PI / 180;
|
|
15085
15085
|
const cos = Math.cos(rad);
|
|
15086
15086
|
const sin = Math.sin(rad);
|
|
15087
|
-
const newX = x * cos +
|
|
15088
|
-
const newZ = -x * sin +
|
|
15087
|
+
const newX = x * cos + z3 * sin;
|
|
15088
|
+
const newZ = -x * sin + z3 * cos;
|
|
15089
15089
|
x = newX;
|
|
15090
|
-
|
|
15090
|
+
z3 = newZ;
|
|
15091
15091
|
}
|
|
15092
15092
|
if (config.rotation.z) {
|
|
15093
15093
|
const rad = config.rotation.z * Math.PI / 180;
|
|
@@ -15099,7 +15099,7 @@ function applyCoordinateTransform(point, config) {
|
|
|
15099
15099
|
y = newY;
|
|
15100
15100
|
}
|
|
15101
15101
|
}
|
|
15102
|
-
return { x, y, z };
|
|
15102
|
+
return { x, y, z: z3 };
|
|
15103
15103
|
}
|
|
15104
15104
|
function getAxisValue(original, mapping) {
|
|
15105
15105
|
switch (mapping) {
|
|
@@ -15216,11 +15216,11 @@ var COORDINATE_TRANSFORMS = {
|
|
|
15216
15216
|
// lib/utils/gltf-node-transforms.ts
|
|
15217
15217
|
function applyQuaternion(p, q) {
|
|
15218
15218
|
const [qx, qy, qz, qw] = q;
|
|
15219
|
-
const { x, y, z } = p;
|
|
15220
|
-
const ix = qw * x + qy *
|
|
15221
|
-
const iy = qw * y + qz * x - qx *
|
|
15222
|
-
const iz = qw *
|
|
15223
|
-
const iw = -qx * x - qy * y - qz *
|
|
15219
|
+
const { x, y, z: z3 } = p;
|
|
15220
|
+
const ix = qw * x + qy * z3 - qz * y;
|
|
15221
|
+
const iy = qw * y + qz * x - qx * z3;
|
|
15222
|
+
const iz = qw * z3 + qx * y - qy * x;
|
|
15223
|
+
const iw = -qx * x - qy * y - qz * z3;
|
|
15224
15224
|
return {
|
|
15225
15225
|
x: ix * qw + iw * -qx + iy * -qz - iz * -qy,
|
|
15226
15226
|
y: iy * qw + iw * -qy + iz * -qx - ix * -qz,
|
|
@@ -15500,10 +15500,10 @@ function convertToOBJMesh(triangles) {
|
|
|
15500
15500
|
// 0.7 * 255 = 179
|
|
15501
15501
|
});
|
|
15502
15502
|
} else {
|
|
15503
|
-
const
|
|
15503
|
+
const color3 = JSON.parse(colorKey);
|
|
15504
15504
|
materials.set(materialName, {
|
|
15505
15505
|
name: materialName,
|
|
15506
|
-
color
|
|
15506
|
+
color: color3
|
|
15507
15507
|
});
|
|
15508
15508
|
}
|
|
15509
15509
|
for (const triangle of groupTriangles) {
|
|
@@ -15946,6 +15946,414 @@ async function loadGLTF({
|
|
|
15946
15946
|
return parseGLB(glb_buffer, transform);
|
|
15947
15947
|
}
|
|
15948
15948
|
|
|
15949
|
+
// node_modules/@tscircuit/cableprinter/dist/index.js
|
|
15950
|
+
import { z } from "zod";
|
|
15951
|
+
import { z as z2 } from "zod";
|
|
15952
|
+
var cableStandardSchema = z.enum([
|
|
15953
|
+
"usb_c",
|
|
15954
|
+
"jst_sh",
|
|
15955
|
+
"jst_ph",
|
|
15956
|
+
"us_mains"
|
|
15957
|
+
]);
|
|
15958
|
+
var color = z.string().regex(/^#[0-9a-fA-F]{6}$/);
|
|
15959
|
+
var jacket = {
|
|
15960
|
+
jacketDiameter: z.number().finite().positive().default(4),
|
|
15961
|
+
color: color.default("#263449")
|
|
15962
|
+
};
|
|
15963
|
+
var cableInputSchema = z.discriminatedUnion("standard", [
|
|
15964
|
+
z.object({ standard: z.literal("usb_c"), ...jacket }).strict(),
|
|
15965
|
+
z.object({
|
|
15966
|
+
standard: z.literal("jst_sh"),
|
|
15967
|
+
pinCount: z.number().int().min(2).max(15).default(4),
|
|
15968
|
+
wireDiameter: z.number().finite().min(0.4).max(0.8).default(0.6)
|
|
15969
|
+
}).strict(),
|
|
15970
|
+
z.object({
|
|
15971
|
+
standard: z.literal("jst_ph"),
|
|
15972
|
+
pinCount: z.number().int().min(2).max(16).default(2),
|
|
15973
|
+
wireDiameter: z.number().finite().min(0.8).max(1.5).default(1.2)
|
|
15974
|
+
}).strict(),
|
|
15975
|
+
z.object({
|
|
15976
|
+
standard: z.literal("us_mains"),
|
|
15977
|
+
...jacket,
|
|
15978
|
+
jacketDiameter: jacket.jacketDiameter.default(6.2)
|
|
15979
|
+
}).strict()
|
|
15980
|
+
]);
|
|
15981
|
+
var dimension = z2.number().finite().positive();
|
|
15982
|
+
var color2 = z2.string().regex(/^#[0-9a-fA-F]{6}$/);
|
|
15983
|
+
var body = {
|
|
15984
|
+
bodyWidth: dimension,
|
|
15985
|
+
bodyHeight: dimension,
|
|
15986
|
+
bodyDepth: dimension
|
|
15987
|
+
};
|
|
15988
|
+
var cableConnectorSchema = z2.discriminatedUnion("kind", [
|
|
15989
|
+
z2.object({
|
|
15990
|
+
kind: z2.literal("usb_c_plug"),
|
|
15991
|
+
...body,
|
|
15992
|
+
shellWidth: dimension,
|
|
15993
|
+
shellHeight: dimension,
|
|
15994
|
+
shellDepth: dimension
|
|
15995
|
+
}).strict(),
|
|
15996
|
+
z2.object({
|
|
15997
|
+
kind: z2.literal("jst_sh_housing"),
|
|
15998
|
+
...body,
|
|
15999
|
+
pinCount: z2.number().int().min(2).max(15),
|
|
16000
|
+
pitch: z2.literal(1)
|
|
16001
|
+
}).strict(),
|
|
16002
|
+
z2.object({
|
|
16003
|
+
kind: z2.literal("jst_ph_housing"),
|
|
16004
|
+
...body,
|
|
16005
|
+
pinCount: z2.number().int().min(2).max(16),
|
|
16006
|
+
pitch: z2.literal(2)
|
|
16007
|
+
}).strict(),
|
|
16008
|
+
z2.object({ kind: z2.literal("nema_5_15p"), ...body }).strict(),
|
|
16009
|
+
z2.object({ kind: z2.literal("iec_c13"), ...body }).strict()
|
|
16010
|
+
]);
|
|
16011
|
+
var cableCrossSectionSchema = z2.discriminatedUnion("kind", [
|
|
16012
|
+
z2.object({
|
|
16013
|
+
kind: z2.literal("round_jacket"),
|
|
16014
|
+
diameter: dimension,
|
|
16015
|
+
color: color2
|
|
16016
|
+
}).strict(),
|
|
16017
|
+
z2.object({
|
|
16018
|
+
kind: z2.literal("wire_bundle"),
|
|
16019
|
+
wires: z2.array(z2.object({ diameter: dimension, color: color2 }).strict()).min(2),
|
|
16020
|
+
wirePitch: dimension
|
|
16021
|
+
}).strict()
|
|
16022
|
+
]);
|
|
16023
|
+
var cableDefinitionSchema = z2.object({
|
|
16024
|
+
standard: cableStandardSchema,
|
|
16025
|
+
connectorA: cableConnectorSchema,
|
|
16026
|
+
connectorB: cableConnectorSchema,
|
|
16027
|
+
crossSection: cableCrossSectionSchema
|
|
16028
|
+
}).strict().superRefine((cable, ctx) => {
|
|
16029
|
+
const { connectorA, connectorB, crossSection } = cable;
|
|
16030
|
+
const expected = {
|
|
16031
|
+
usb_c: ["usb_c_plug", "usb_c_plug"],
|
|
16032
|
+
jst_sh: ["jst_sh_housing", "jst_sh_housing"],
|
|
16033
|
+
jst_ph: ["jst_ph_housing", "jst_ph_housing"],
|
|
16034
|
+
us_mains: ["nema_5_15p", "iec_c13"]
|
|
16035
|
+
}[cable.standard];
|
|
16036
|
+
if (connectorA.kind !== expected[0] || connectorB.kind !== expected[1]) {
|
|
16037
|
+
ctx.addIssue({
|
|
16038
|
+
code: z2.ZodIssueCode.custom,
|
|
16039
|
+
message: "Connector kinds must match the cable standard"
|
|
16040
|
+
});
|
|
16041
|
+
}
|
|
16042
|
+
if (crossSection.kind === "wire_bundle") {
|
|
16043
|
+
for (const connector of [connectorA, connectorB]) {
|
|
16044
|
+
if (!("pinCount" in connector) || connector.pinCount !== crossSection.wires.length) {
|
|
16045
|
+
ctx.addIssue({
|
|
16046
|
+
code: z2.ZodIssueCode.custom,
|
|
16047
|
+
message: "Bundle wire count must match each connector pin count"
|
|
16048
|
+
});
|
|
16049
|
+
}
|
|
16050
|
+
}
|
|
16051
|
+
if (crossSection.wires.some(
|
|
16052
|
+
(wire) => wire.diameter > crossSection.wirePitch
|
|
16053
|
+
)) {
|
|
16054
|
+
ctx.addIssue({
|
|
16055
|
+
code: z2.ZodIssueCode.custom,
|
|
16056
|
+
message: "Bundle wires must not overlap in the cross section"
|
|
16057
|
+
});
|
|
16058
|
+
}
|
|
16059
|
+
} else if (cable.standard === "jst_sh" || cable.standard === "jst_ph") {
|
|
16060
|
+
ctx.addIssue({
|
|
16061
|
+
code: z2.ZodIssueCode.custom,
|
|
16062
|
+
message: "JST cables require a wire bundle"
|
|
16063
|
+
});
|
|
16064
|
+
}
|
|
16065
|
+
});
|
|
16066
|
+
var wireColors = [
|
|
16067
|
+
"#df4049",
|
|
16068
|
+
"#263449",
|
|
16069
|
+
"#e1b13c",
|
|
16070
|
+
"#347dc9",
|
|
16071
|
+
"#27a782",
|
|
16072
|
+
"#af62bd"
|
|
16073
|
+
];
|
|
16074
|
+
function getCableDefinition(cableInput) {
|
|
16075
|
+
const cable = cableInputSchema.parse(cableInput);
|
|
16076
|
+
if (cable.standard === "usb_c") {
|
|
16077
|
+
const connector2 = {
|
|
16078
|
+
kind: "usb_c_plug",
|
|
16079
|
+
bodyWidth: 12,
|
|
16080
|
+
bodyHeight: 6,
|
|
16081
|
+
bodyDepth: 18,
|
|
16082
|
+
shellWidth: 8.25,
|
|
16083
|
+
shellHeight: 2.4,
|
|
16084
|
+
shellDepth: 6.5
|
|
16085
|
+
};
|
|
16086
|
+
return cableDefinitionSchema.parse({
|
|
16087
|
+
standard: cable.standard,
|
|
16088
|
+
connectorA: connector2,
|
|
16089
|
+
connectorB: { ...connector2 },
|
|
16090
|
+
crossSection: {
|
|
16091
|
+
kind: "round_jacket",
|
|
16092
|
+
diameter: cable.jacketDiameter,
|
|
16093
|
+
color: cable.color
|
|
16094
|
+
}
|
|
16095
|
+
});
|
|
16096
|
+
}
|
|
16097
|
+
if (cable.standard === "us_mains") {
|
|
16098
|
+
return cableDefinitionSchema.parse({
|
|
16099
|
+
standard: cable.standard,
|
|
16100
|
+
connectorA: {
|
|
16101
|
+
kind: "nema_5_15p",
|
|
16102
|
+
bodyWidth: 32,
|
|
16103
|
+
bodyHeight: 28,
|
|
16104
|
+
bodyDepth: 35
|
|
16105
|
+
},
|
|
16106
|
+
connectorB: {
|
|
16107
|
+
kind: "iec_c13",
|
|
16108
|
+
bodyWidth: 24,
|
|
16109
|
+
bodyHeight: 18,
|
|
16110
|
+
bodyDepth: 30
|
|
16111
|
+
},
|
|
16112
|
+
crossSection: {
|
|
16113
|
+
kind: "round_jacket",
|
|
16114
|
+
diameter: cable.jacketDiameter,
|
|
16115
|
+
color: cable.color
|
|
16116
|
+
}
|
|
16117
|
+
});
|
|
16118
|
+
}
|
|
16119
|
+
const isSh = cable.standard === "jst_sh";
|
|
16120
|
+
const connector = {
|
|
16121
|
+
kind: isSh ? "jst_sh_housing" : "jst_ph_housing",
|
|
16122
|
+
pinCount: cable.pinCount,
|
|
16123
|
+
pitch: isSh ? 1 : 2,
|
|
16124
|
+
bodyWidth: isSh ? cable.pinCount + 1 : (cable.pinCount - 1) * 2 + 3.8,
|
|
16125
|
+
bodyHeight: isSh ? 2.8 : 4.5,
|
|
16126
|
+
bodyDepth: isSh ? 5 : 6.85
|
|
16127
|
+
};
|
|
16128
|
+
return cableDefinitionSchema.parse({
|
|
16129
|
+
standard: cable.standard,
|
|
16130
|
+
connectorA: connector,
|
|
16131
|
+
connectorB: { ...connector },
|
|
16132
|
+
crossSection: {
|
|
16133
|
+
kind: "wire_bundle",
|
|
16134
|
+
wirePitch: connector.pitch,
|
|
16135
|
+
wires: Array.from({ length: cable.pinCount }, (_, index) => ({
|
|
16136
|
+
diameter: cable.wireDiameter,
|
|
16137
|
+
color: wireColors[index % wireColors.length]
|
|
16138
|
+
}))
|
|
16139
|
+
}
|
|
16140
|
+
});
|
|
16141
|
+
}
|
|
16142
|
+
function parseCableString(cableString) {
|
|
16143
|
+
const cableName = cableString.trim().toLowerCase();
|
|
16144
|
+
if (cableName === "usb_c" || cableName === "us_mains") {
|
|
16145
|
+
return getCableDefinition({ standard: cableName });
|
|
16146
|
+
}
|
|
16147
|
+
const jstMatch = /^(jst_sh|jst_ph)(?:_pins([0-9]+))?$/.exec(cableName);
|
|
16148
|
+
if (jstMatch) {
|
|
16149
|
+
return getCableDefinition({
|
|
16150
|
+
standard: jstMatch[1] === "jst_sh" ? "jst_sh" : "jst_ph",
|
|
16151
|
+
...jstMatch[2] ? { pinCount: Number(jstMatch[2]) } : {}
|
|
16152
|
+
});
|
|
16153
|
+
}
|
|
16154
|
+
throw new Error(
|
|
16155
|
+
`Unsupported cable string: "${cableString}". Expected usb_c, jst_sh[_pinsN], jst_ph[_pinsN], or us_mains.`
|
|
16156
|
+
);
|
|
16157
|
+
}
|
|
16158
|
+
|
|
16159
|
+
// lib/loaders/cable.ts
|
|
16160
|
+
import { createCableMeshes } from "jscad-electronics/cables";
|
|
16161
|
+
import { vec3 } from "gl-matrix";
|
|
16162
|
+
|
|
16163
|
+
// lib/utils/mesh-scale.ts
|
|
16164
|
+
function scalePoint(point, scale) {
|
|
16165
|
+
return {
|
|
16166
|
+
x: point.x * scale,
|
|
16167
|
+
y: point.y * scale,
|
|
16168
|
+
z: point.z * scale
|
|
16169
|
+
};
|
|
16170
|
+
}
|
|
16171
|
+
function scalePointByAxis(point, scale) {
|
|
16172
|
+
return {
|
|
16173
|
+
x: point.x * scale.x,
|
|
16174
|
+
y: point.y * scale.y,
|
|
16175
|
+
z: point.z * scale.z
|
|
16176
|
+
};
|
|
16177
|
+
}
|
|
16178
|
+
function rotatePoint(point, rotationDeg) {
|
|
16179
|
+
let { x, y, z: z3 } = point;
|
|
16180
|
+
if (rotationDeg.x !== 0) {
|
|
16181
|
+
const rad = rotationDeg.x * Math.PI / 180;
|
|
16182
|
+
const cos = Math.cos(rad);
|
|
16183
|
+
const sin = Math.sin(rad);
|
|
16184
|
+
const newY = y * cos - z3 * sin;
|
|
16185
|
+
const newZ = y * sin + z3 * cos;
|
|
16186
|
+
y = newY;
|
|
16187
|
+
z3 = newZ;
|
|
16188
|
+
}
|
|
16189
|
+
if (rotationDeg.y !== 0) {
|
|
16190
|
+
const rad = rotationDeg.y * Math.PI / 180;
|
|
16191
|
+
const cos = Math.cos(rad);
|
|
16192
|
+
const sin = Math.sin(rad);
|
|
16193
|
+
const newX = x * cos + z3 * sin;
|
|
16194
|
+
const newZ = -x * sin + z3 * cos;
|
|
16195
|
+
x = newX;
|
|
16196
|
+
z3 = newZ;
|
|
16197
|
+
}
|
|
16198
|
+
if (rotationDeg.z !== 0) {
|
|
16199
|
+
const rad = rotationDeg.z * Math.PI / 180;
|
|
16200
|
+
const cos = Math.cos(rad);
|
|
16201
|
+
const sin = Math.sin(rad);
|
|
16202
|
+
const newX = x * cos - y * sin;
|
|
16203
|
+
const newY = x * sin + y * cos;
|
|
16204
|
+
x = newX;
|
|
16205
|
+
y = newY;
|
|
16206
|
+
}
|
|
16207
|
+
return { x, y, z: z3 };
|
|
16208
|
+
}
|
|
16209
|
+
function scaleTriangle(triangle, scale) {
|
|
16210
|
+
return {
|
|
16211
|
+
...triangle,
|
|
16212
|
+
vertices: triangle.vertices.map((vertex) => scalePoint(vertex, scale))
|
|
16213
|
+
};
|
|
16214
|
+
}
|
|
16215
|
+
function scaleMesh(mesh, scale) {
|
|
16216
|
+
if (!Number.isFinite(scale) || scale === 1) {
|
|
16217
|
+
return mesh;
|
|
16218
|
+
}
|
|
16219
|
+
const scaledTriangles = mesh.triangles.map(
|
|
16220
|
+
(triangle) => scaleTriangle(triangle, scale)
|
|
16221
|
+
);
|
|
16222
|
+
const scaledBoundingBox = {
|
|
16223
|
+
min: scalePoint(mesh.boundingBox.min, scale),
|
|
16224
|
+
max: scalePoint(mesh.boundingBox.max, scale)
|
|
16225
|
+
};
|
|
16226
|
+
return {
|
|
16227
|
+
...mesh,
|
|
16228
|
+
triangles: scaledTriangles,
|
|
16229
|
+
boundingBox: scaledBoundingBox
|
|
16230
|
+
};
|
|
16231
|
+
}
|
|
16232
|
+
function scaleMeshByAxis(mesh, scale) {
|
|
16233
|
+
if (!Number.isFinite(scale.x) || !Number.isFinite(scale.y) || !Number.isFinite(scale.z) || scale.x === 1 && scale.y === 1 && scale.z === 1) {
|
|
16234
|
+
return mesh;
|
|
16235
|
+
}
|
|
16236
|
+
const scaledTriangles = mesh.triangles.map((triangle) => ({
|
|
16237
|
+
...triangle,
|
|
16238
|
+
vertices: triangle.vertices.map(
|
|
16239
|
+
(vertex) => scalePointByAxis(vertex, scale)
|
|
16240
|
+
)
|
|
16241
|
+
}));
|
|
16242
|
+
return {
|
|
16243
|
+
...mesh,
|
|
16244
|
+
triangles: scaledTriangles,
|
|
16245
|
+
boundingBox: boundsOfTriangles2(scaledTriangles)
|
|
16246
|
+
};
|
|
16247
|
+
}
|
|
16248
|
+
function translateMesh(mesh, offset) {
|
|
16249
|
+
if (offset.x === 0 && offset.y === 0 && offset.z === 0) {
|
|
16250
|
+
return mesh;
|
|
16251
|
+
}
|
|
16252
|
+
const translatedTriangles = mesh.triangles.map((triangle) => ({
|
|
16253
|
+
...triangle,
|
|
16254
|
+
vertices: triangle.vertices.map((vertex) => ({
|
|
16255
|
+
x: vertex.x + offset.x,
|
|
16256
|
+
y: vertex.y + offset.y,
|
|
16257
|
+
z: vertex.z + offset.z
|
|
16258
|
+
}))
|
|
16259
|
+
}));
|
|
16260
|
+
return {
|
|
16261
|
+
...mesh,
|
|
16262
|
+
triangles: translatedTriangles,
|
|
16263
|
+
boundingBox: {
|
|
16264
|
+
min: {
|
|
16265
|
+
x: mesh.boundingBox.min.x + offset.x,
|
|
16266
|
+
y: mesh.boundingBox.min.y + offset.y,
|
|
16267
|
+
z: mesh.boundingBox.min.z + offset.z
|
|
16268
|
+
},
|
|
16269
|
+
max: {
|
|
16270
|
+
x: mesh.boundingBox.max.x + offset.x,
|
|
16271
|
+
y: mesh.boundingBox.max.y + offset.y,
|
|
16272
|
+
z: mesh.boundingBox.max.z + offset.z
|
|
16273
|
+
}
|
|
16274
|
+
}
|
|
16275
|
+
};
|
|
16276
|
+
}
|
|
16277
|
+
function rotateMesh(mesh, rotationDeg) {
|
|
16278
|
+
if (rotationDeg.x === 0 && rotationDeg.y === 0 && rotationDeg.z === 0) {
|
|
16279
|
+
return mesh;
|
|
16280
|
+
}
|
|
16281
|
+
const rotatedTriangles = mesh.triangles.map((triangle) => ({
|
|
16282
|
+
...triangle,
|
|
16283
|
+
vertices: triangle.vertices.map(
|
|
16284
|
+
(vertex) => rotatePoint(vertex, rotationDeg)
|
|
16285
|
+
),
|
|
16286
|
+
normal: rotatePoint(triangle.normal, rotationDeg)
|
|
16287
|
+
}));
|
|
16288
|
+
return {
|
|
16289
|
+
...mesh,
|
|
16290
|
+
triangles: rotatedTriangles,
|
|
16291
|
+
boundingBox: boundsOfTriangles2(rotatedTriangles)
|
|
16292
|
+
};
|
|
16293
|
+
}
|
|
16294
|
+
function getBoundingBoxSize(bounds) {
|
|
16295
|
+
return {
|
|
16296
|
+
x: bounds.max.x - bounds.min.x,
|
|
16297
|
+
y: bounds.max.y - bounds.min.y,
|
|
16298
|
+
z: bounds.max.z - bounds.min.z
|
|
16299
|
+
};
|
|
16300
|
+
}
|
|
16301
|
+
function getBoundingBoxCenter(bounds) {
|
|
16302
|
+
return {
|
|
16303
|
+
x: (bounds.min.x + bounds.max.x) / 2,
|
|
16304
|
+
y: (bounds.min.y + bounds.max.y) / 2,
|
|
16305
|
+
z: (bounds.min.z + bounds.max.z) / 2
|
|
16306
|
+
};
|
|
16307
|
+
}
|
|
16308
|
+
|
|
16309
|
+
// lib/loaders/cable.ts
|
|
16310
|
+
function loadCable(cable) {
|
|
16311
|
+
const meshes = createCableMeshes({
|
|
16312
|
+
definition: parseCableString(cable.cableprinter_string),
|
|
16313
|
+
path: cable.path.map(({ x, y, z: z3 }) => [x, y, z3])
|
|
16314
|
+
});
|
|
16315
|
+
return meshes.map((mesh) => {
|
|
16316
|
+
const circuitTriangles = [];
|
|
16317
|
+
for (let i = 0; i < mesh.indices.length; i += 3) {
|
|
16318
|
+
const vertices = mesh.indices.slice(i, i + 3).map((vertex) => ({
|
|
16319
|
+
x: mesh.positions[vertex * 3],
|
|
16320
|
+
y: mesh.positions[vertex * 3 + 1],
|
|
16321
|
+
z: mesh.positions[vertex * 3 + 2]
|
|
16322
|
+
}));
|
|
16323
|
+
const [a, b, c] = vertices;
|
|
16324
|
+
const normal = vec3.normalize(
|
|
16325
|
+
vec3.create(),
|
|
16326
|
+
vec3.cross(
|
|
16327
|
+
vec3.create(),
|
|
16328
|
+
[b.x - a.x, b.y - a.y, b.z - a.z],
|
|
16329
|
+
[c.x - a.x, c.y - a.y, c.z - a.z]
|
|
16330
|
+
)
|
|
16331
|
+
);
|
|
16332
|
+
circuitTriangles.push({
|
|
16333
|
+
vertices,
|
|
16334
|
+
normal: { x: normal[0], y: normal[1], z: normal[2] }
|
|
16335
|
+
});
|
|
16336
|
+
}
|
|
16337
|
+
const triangles = transformTriangles(
|
|
16338
|
+
circuitTriangles,
|
|
16339
|
+
COORDINATE_TRANSFORMS.CIRCUIT_Z_UP_TO_SCENE_Y_UP
|
|
16340
|
+
);
|
|
16341
|
+
const meshData = { triangles, boundingBox: boundsOfTriangles2(triangles) };
|
|
16342
|
+
return {
|
|
16343
|
+
center: { x: 0, y: 0, z: 0 },
|
|
16344
|
+
size: getBoundingBoxSize(meshData.boundingBox),
|
|
16345
|
+
mesh: meshData,
|
|
16346
|
+
color: [
|
|
16347
|
+
mesh.color[0] * 255,
|
|
16348
|
+
mesh.color[1] * 255,
|
|
16349
|
+
mesh.color[2] * 255,
|
|
16350
|
+
mesh.color[3]
|
|
16351
|
+
],
|
|
16352
|
+
label: `${cable.name} / ${mesh.name}`
|
|
16353
|
+
};
|
|
16354
|
+
});
|
|
16355
|
+
}
|
|
16356
|
+
|
|
15949
16357
|
// lib/loaders/jscad-plan.ts
|
|
15950
16358
|
var jscadModeling2 = __toESM(require_src(), 1);
|
|
15951
16359
|
var geom33 = __toESM(require_geom3(), 1);
|
|
@@ -16629,10 +17037,10 @@ var pushLoop = (flattenedVertices, loop) => {
|
|
|
16629
17037
|
var toScenePoint = ({
|
|
16630
17038
|
x,
|
|
16631
17039
|
y,
|
|
16632
|
-
z
|
|
17040
|
+
z: z3
|
|
16633
17041
|
}) => ({
|
|
16634
17042
|
x,
|
|
16635
|
-
y:
|
|
17043
|
+
y: z3,
|
|
16636
17044
|
z: -y
|
|
16637
17045
|
});
|
|
16638
17046
|
var makeTriangle = ({
|
|
@@ -17040,8 +17448,8 @@ function parseOBJ(text, transform) {
|
|
|
17040
17448
|
const parts = trimmed.split(/\s+/);
|
|
17041
17449
|
const x = parts[1];
|
|
17042
17450
|
const y = parts[2];
|
|
17043
|
-
const
|
|
17044
|
-
vertices.push({ x: parseFloat(x), y: parseFloat(y), z: parseFloat(
|
|
17451
|
+
const z3 = parts[3];
|
|
17452
|
+
vertices.push({ x: parseFloat(x), y: parseFloat(y), z: parseFloat(z3) });
|
|
17045
17453
|
if (parts.length >= 7) {
|
|
17046
17454
|
const [rStr, gStr, bStr] = parts.slice(4, 7);
|
|
17047
17455
|
let r = Number(rStr);
|
|
@@ -17060,8 +17468,8 @@ function parseOBJ(text, transform) {
|
|
|
17060
17468
|
const parts = trimmed.split(/\s+/);
|
|
17061
17469
|
const x = parts[1];
|
|
17062
17470
|
const y = parts[2];
|
|
17063
|
-
const
|
|
17064
|
-
normals.push({ x: parseFloat(x), y: parseFloat(y), z: parseFloat(
|
|
17471
|
+
const z3 = parts[3];
|
|
17472
|
+
normals.push({ x: parseFloat(x), y: parseFloat(y), z: parseFloat(z3) });
|
|
17065
17473
|
} else if (trimmed.startsWith("newmtl ")) {
|
|
17066
17474
|
const name = trimmed.split(/\s+/)[1];
|
|
17067
17475
|
materials.set(name, { name });
|
|
@@ -17348,10 +17756,10 @@ function convertToOBJMesh2(triangles) {
|
|
|
17348
17756
|
color: [179, 179, 179, 1]
|
|
17349
17757
|
});
|
|
17350
17758
|
} else {
|
|
17351
|
-
const
|
|
17759
|
+
const color3 = JSON.parse(colorKey);
|
|
17352
17760
|
materials.set(materialName, {
|
|
17353
17761
|
name: materialName,
|
|
17354
|
-
color
|
|
17762
|
+
color: color3
|
|
17355
17763
|
});
|
|
17356
17764
|
}
|
|
17357
17765
|
for (const triangle of groupTriangles) {
|
|
@@ -17509,152 +17917,6 @@ function clearSTLCache() {
|
|
|
17509
17917
|
stlCache.clear();
|
|
17510
17918
|
}
|
|
17511
17919
|
|
|
17512
|
-
// lib/utils/mesh-scale.ts
|
|
17513
|
-
function scalePoint(point, scale) {
|
|
17514
|
-
return {
|
|
17515
|
-
x: point.x * scale,
|
|
17516
|
-
y: point.y * scale,
|
|
17517
|
-
z: point.z * scale
|
|
17518
|
-
};
|
|
17519
|
-
}
|
|
17520
|
-
function scalePointByAxis(point, scale) {
|
|
17521
|
-
return {
|
|
17522
|
-
x: point.x * scale.x,
|
|
17523
|
-
y: point.y * scale.y,
|
|
17524
|
-
z: point.z * scale.z
|
|
17525
|
-
};
|
|
17526
|
-
}
|
|
17527
|
-
function rotatePoint(point, rotationDeg) {
|
|
17528
|
-
let { x, y, z } = point;
|
|
17529
|
-
if (rotationDeg.x !== 0) {
|
|
17530
|
-
const rad = rotationDeg.x * Math.PI / 180;
|
|
17531
|
-
const cos = Math.cos(rad);
|
|
17532
|
-
const sin = Math.sin(rad);
|
|
17533
|
-
const newY = y * cos - z * sin;
|
|
17534
|
-
const newZ = y * sin + z * cos;
|
|
17535
|
-
y = newY;
|
|
17536
|
-
z = newZ;
|
|
17537
|
-
}
|
|
17538
|
-
if (rotationDeg.y !== 0) {
|
|
17539
|
-
const rad = rotationDeg.y * Math.PI / 180;
|
|
17540
|
-
const cos = Math.cos(rad);
|
|
17541
|
-
const sin = Math.sin(rad);
|
|
17542
|
-
const newX = x * cos + z * sin;
|
|
17543
|
-
const newZ = -x * sin + z * cos;
|
|
17544
|
-
x = newX;
|
|
17545
|
-
z = newZ;
|
|
17546
|
-
}
|
|
17547
|
-
if (rotationDeg.z !== 0) {
|
|
17548
|
-
const rad = rotationDeg.z * Math.PI / 180;
|
|
17549
|
-
const cos = Math.cos(rad);
|
|
17550
|
-
const sin = Math.sin(rad);
|
|
17551
|
-
const newX = x * cos - y * sin;
|
|
17552
|
-
const newY = x * sin + y * cos;
|
|
17553
|
-
x = newX;
|
|
17554
|
-
y = newY;
|
|
17555
|
-
}
|
|
17556
|
-
return { x, y, z };
|
|
17557
|
-
}
|
|
17558
|
-
function scaleTriangle(triangle, scale) {
|
|
17559
|
-
return {
|
|
17560
|
-
...triangle,
|
|
17561
|
-
vertices: triangle.vertices.map((vertex) => scalePoint(vertex, scale))
|
|
17562
|
-
};
|
|
17563
|
-
}
|
|
17564
|
-
function scaleMesh(mesh, scale) {
|
|
17565
|
-
if (!Number.isFinite(scale) || scale === 1) {
|
|
17566
|
-
return mesh;
|
|
17567
|
-
}
|
|
17568
|
-
const scaledTriangles = mesh.triangles.map(
|
|
17569
|
-
(triangle) => scaleTriangle(triangle, scale)
|
|
17570
|
-
);
|
|
17571
|
-
const scaledBoundingBox = {
|
|
17572
|
-
min: scalePoint(mesh.boundingBox.min, scale),
|
|
17573
|
-
max: scalePoint(mesh.boundingBox.max, scale)
|
|
17574
|
-
};
|
|
17575
|
-
return {
|
|
17576
|
-
...mesh,
|
|
17577
|
-
triangles: scaledTriangles,
|
|
17578
|
-
boundingBox: scaledBoundingBox
|
|
17579
|
-
};
|
|
17580
|
-
}
|
|
17581
|
-
function scaleMeshByAxis(mesh, scale) {
|
|
17582
|
-
if (!Number.isFinite(scale.x) || !Number.isFinite(scale.y) || !Number.isFinite(scale.z) || scale.x === 1 && scale.y === 1 && scale.z === 1) {
|
|
17583
|
-
return mesh;
|
|
17584
|
-
}
|
|
17585
|
-
const scaledTriangles = mesh.triangles.map((triangle) => ({
|
|
17586
|
-
...triangle,
|
|
17587
|
-
vertices: triangle.vertices.map(
|
|
17588
|
-
(vertex) => scalePointByAxis(vertex, scale)
|
|
17589
|
-
)
|
|
17590
|
-
}));
|
|
17591
|
-
return {
|
|
17592
|
-
...mesh,
|
|
17593
|
-
triangles: scaledTriangles,
|
|
17594
|
-
boundingBox: boundsOfTriangles2(scaledTriangles)
|
|
17595
|
-
};
|
|
17596
|
-
}
|
|
17597
|
-
function translateMesh(mesh, offset) {
|
|
17598
|
-
if (offset.x === 0 && offset.y === 0 && offset.z === 0) {
|
|
17599
|
-
return mesh;
|
|
17600
|
-
}
|
|
17601
|
-
const translatedTriangles = mesh.triangles.map((triangle) => ({
|
|
17602
|
-
...triangle,
|
|
17603
|
-
vertices: triangle.vertices.map((vertex) => ({
|
|
17604
|
-
x: vertex.x + offset.x,
|
|
17605
|
-
y: vertex.y + offset.y,
|
|
17606
|
-
z: vertex.z + offset.z
|
|
17607
|
-
}))
|
|
17608
|
-
}));
|
|
17609
|
-
return {
|
|
17610
|
-
...mesh,
|
|
17611
|
-
triangles: translatedTriangles,
|
|
17612
|
-
boundingBox: {
|
|
17613
|
-
min: {
|
|
17614
|
-
x: mesh.boundingBox.min.x + offset.x,
|
|
17615
|
-
y: mesh.boundingBox.min.y + offset.y,
|
|
17616
|
-
z: mesh.boundingBox.min.z + offset.z
|
|
17617
|
-
},
|
|
17618
|
-
max: {
|
|
17619
|
-
x: mesh.boundingBox.max.x + offset.x,
|
|
17620
|
-
y: mesh.boundingBox.max.y + offset.y,
|
|
17621
|
-
z: mesh.boundingBox.max.z + offset.z
|
|
17622
|
-
}
|
|
17623
|
-
}
|
|
17624
|
-
};
|
|
17625
|
-
}
|
|
17626
|
-
function rotateMesh(mesh, rotationDeg) {
|
|
17627
|
-
if (rotationDeg.x === 0 && rotationDeg.y === 0 && rotationDeg.z === 0) {
|
|
17628
|
-
return mesh;
|
|
17629
|
-
}
|
|
17630
|
-
const rotatedTriangles = mesh.triangles.map((triangle) => ({
|
|
17631
|
-
...triangle,
|
|
17632
|
-
vertices: triangle.vertices.map(
|
|
17633
|
-
(vertex) => rotatePoint(vertex, rotationDeg)
|
|
17634
|
-
),
|
|
17635
|
-
normal: rotatePoint(triangle.normal, rotationDeg)
|
|
17636
|
-
}));
|
|
17637
|
-
return {
|
|
17638
|
-
...mesh,
|
|
17639
|
-
triangles: rotatedTriangles,
|
|
17640
|
-
boundingBox: boundsOfTriangles2(rotatedTriangles)
|
|
17641
|
-
};
|
|
17642
|
-
}
|
|
17643
|
-
function getBoundingBoxSize(bounds) {
|
|
17644
|
-
return {
|
|
17645
|
-
x: bounds.max.x - bounds.min.x,
|
|
17646
|
-
y: bounds.max.y - bounds.min.y,
|
|
17647
|
-
z: bounds.max.z - bounds.min.z
|
|
17648
|
-
};
|
|
17649
|
-
}
|
|
17650
|
-
function getBoundingBoxCenter(bounds) {
|
|
17651
|
-
return {
|
|
17652
|
-
x: (bounds.min.x + bounds.max.x) / 2,
|
|
17653
|
-
y: (bounds.min.y + bounds.max.y) / 2,
|
|
17654
|
-
z: (bounds.min.z + bounds.max.z) / 2
|
|
17655
|
-
};
|
|
17656
|
-
}
|
|
17657
|
-
|
|
17658
17920
|
// lib/utils/cad-mesh-placement.ts
|
|
17659
17921
|
function getOrientationRotationForBoardNormal(modelBoardNormalDirection) {
|
|
17660
17922
|
if (!modelBoardNormalDirection || modelBoardNormalDirection === "z+") {
|
|
@@ -17878,13 +18140,13 @@ var normalizeColor = (value) => {
|
|
|
17878
18140
|
const parsed = parseColor(specified);
|
|
17879
18141
|
return parsed ? toHex(parsed) : specified.trim();
|
|
17880
18142
|
};
|
|
17881
|
-
var mix = (
|
|
18143
|
+
var mix = (color3, target, amount) => color3.map(
|
|
17882
18144
|
(channel, index) => clampByte(channel + (target[index] - channel) * amount)
|
|
17883
18145
|
);
|
|
17884
18146
|
var getPerceivedBrightness = ([red, green, blue]) => (red * 0.299 + green * 0.587 + blue * 0.114) / 255;
|
|
17885
|
-
var colorToCssString = (
|
|
17886
|
-
if (typeof
|
|
17887
|
-
return toHex([
|
|
18147
|
+
var colorToCssString = (color3) => {
|
|
18148
|
+
if (typeof color3 === "string") return color3;
|
|
18149
|
+
return toHex([color3[0], color3[1], color3[2]]);
|
|
17888
18150
|
};
|
|
17889
18151
|
function deriveBoardColorPalette(solderMaskColor, silkscreenColor) {
|
|
17890
18152
|
const backgroundColor = normalizeColor(solderMaskColor);
|
|
@@ -18579,6 +18841,11 @@ async function convertCircuitJsonTo3D(inputCircuitJson, options = {}) {
|
|
|
18579
18841
|
label: stiffener.pcb_stiffener_id
|
|
18580
18842
|
});
|
|
18581
18843
|
}
|
|
18844
|
+
for (const cable of circuitJson.filter(
|
|
18845
|
+
(element) => element.type === "cad_cable"
|
|
18846
|
+
)) {
|
|
18847
|
+
boxes.push(...loadCable(cable));
|
|
18848
|
+
}
|
|
18582
18849
|
let camera;
|
|
18583
18850
|
if (pcbBoard) {
|
|
18584
18851
|
const boardDiagonal = Math.sqrt(
|
|
@@ -18939,14 +19206,14 @@ var GLTFBuilder = class {
|
|
|
18939
19206
|
for (const [name, objMaterial] of objMesh.materials) {
|
|
18940
19207
|
let baseColor = [0.3, 0.3, 0.3, 1];
|
|
18941
19208
|
if (objMaterial.color) {
|
|
18942
|
-
const
|
|
19209
|
+
const color3 = typeof objMaterial.color === "string" ? this.parseColorString(objMaterial.color) : [
|
|
18943
19210
|
objMaterial.color[0] / 255,
|
|
18944
19211
|
objMaterial.color[1] / 255,
|
|
18945
19212
|
objMaterial.color[2] / 255,
|
|
18946
19213
|
objMaterial.color[3]
|
|
18947
19214
|
// Use the alpha from the color
|
|
18948
19215
|
];
|
|
18949
|
-
baseColor = [
|
|
19216
|
+
baseColor = [color3[0], color3[1], color3[2], color3[3]];
|
|
18950
19217
|
}
|
|
18951
19218
|
let alpha = baseColor[3];
|
|
18952
19219
|
if (objMaterial.dissolve !== void 0) {
|
|
@@ -19500,8 +19767,8 @@ var GLTFBuilder = class {
|
|
|
19500
19767
|
return index;
|
|
19501
19768
|
}
|
|
19502
19769
|
addMaterialFromColor(opts) {
|
|
19503
|
-
const { color, makeTransparent = false, isTranslucent = false } = opts;
|
|
19504
|
-
const baseColor = typeof
|
|
19770
|
+
const { color: color3, makeTransparent = false, isTranslucent = false } = opts;
|
|
19771
|
+
const baseColor = typeof color3 === "string" ? this.parseColorString(color3) : [color3[0] / 255, color3[1] / 255, color3[2] / 255, color3[3]];
|
|
19505
19772
|
if (makeTransparent) {
|
|
19506
19773
|
baseColor[3] = 0.5;
|
|
19507
19774
|
}
|
|
@@ -19516,16 +19783,16 @@ var GLTFBuilder = class {
|
|
|
19516
19783
|
doubleSided: isTranslucent ? true : void 0
|
|
19517
19784
|
});
|
|
19518
19785
|
}
|
|
19519
|
-
parseColorString(
|
|
19520
|
-
if (
|
|
19521
|
-
const hex =
|
|
19786
|
+
parseColorString(color3) {
|
|
19787
|
+
if (color3.startsWith("#")) {
|
|
19788
|
+
const hex = color3.slice(1);
|
|
19522
19789
|
const r = parseInt(hex.slice(0, 2), 16) / 255;
|
|
19523
19790
|
const g = parseInt(hex.slice(2, 4), 16) / 255;
|
|
19524
19791
|
const b = parseInt(hex.slice(4, 6), 16) / 255;
|
|
19525
19792
|
const a = hex.length > 6 ? parseInt(hex.slice(6, 8), 16) / 255 : 1;
|
|
19526
19793
|
return [r, g, b, a];
|
|
19527
|
-
} else if (
|
|
19528
|
-
const match =
|
|
19794
|
+
} else if (color3.startsWith("rgba(")) {
|
|
19795
|
+
const match = color3.match(/rgba\(([^)]+)\)/);
|
|
19529
19796
|
if (match) {
|
|
19530
19797
|
const parts = match[1].split(",").map((s) => s.trim());
|
|
19531
19798
|
return [
|
|
@@ -19535,8 +19802,8 @@ var GLTFBuilder = class {
|
|
|
19535
19802
|
parseFloat(parts[3])
|
|
19536
19803
|
];
|
|
19537
19804
|
}
|
|
19538
|
-
} else if (
|
|
19539
|
-
const match =
|
|
19805
|
+
} else if (color3.startsWith("rgb(")) {
|
|
19806
|
+
const match = color3.match(/rgb\(([^)]+)\)/);
|
|
19540
19807
|
if (match) {
|
|
19541
19808
|
const parts = match[1].split(",").map((s) => s.trim());
|
|
19542
19809
|
return [
|
|
@@ -19556,7 +19823,7 @@ var GLTFBuilder = class {
|
|
|
19556
19823
|
gray: [0.5, 0.5, 0.5, 1],
|
|
19557
19824
|
grey: [0.5, 0.5, 0.5, 1]
|
|
19558
19825
|
};
|
|
19559
|
-
return namedColors[
|
|
19826
|
+
return namedColors[color3.toLowerCase()] || [0.5, 0.5, 0.5, 1];
|
|
19560
19827
|
}
|
|
19561
19828
|
async addTextureFromDataUrl(dataUrl) {
|
|
19562
19829
|
try {
|
|
@@ -19833,12 +20100,12 @@ var CAMERA_PRESET_DIRECTIONS = {
|
|
|
19833
20100
|
front: [0, 0, 1],
|
|
19834
20101
|
back: [0, 0, -1]
|
|
19835
20102
|
};
|
|
19836
|
-
function normalizeVector([x, y,
|
|
19837
|
-
const length = Math.hypot(x, y,
|
|
20103
|
+
function normalizeVector([x, y, z3]) {
|
|
20104
|
+
const length = Math.hypot(x, y, z3);
|
|
19838
20105
|
if (length === 0) {
|
|
19839
20106
|
return [0, 1, 0];
|
|
19840
20107
|
}
|
|
19841
|
-
return [x / length, y / length,
|
|
20108
|
+
return [x / length, y / length, z3 / length];
|
|
19842
20109
|
}
|
|
19843
20110
|
function dot([ax, ay, az], [bx, by, bz]) {
|
|
19844
20111
|
return ax * bx + ay * by + az * bz;
|