jscad-electronics 0.0.206 → 0.0.208
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.d.ts +27 -5
- package/dist/index.js +1422 -1288
- package/dist/index.js.map +1 -1
- package/dist/vanilla.d.ts +27 -5
- package/dist/vanilla.js +498 -374
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.js
CHANGED
|
@@ -183,24 +183,24 @@ var FootprintPlatedHole = ({
|
|
|
183
183
|
import { buttonScrewModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
184
184
|
|
|
185
185
|
// lib/model-registry.ts
|
|
186
|
-
function defineModelRenderer(
|
|
187
|
-
return
|
|
186
|
+
function defineModelRenderer(model23) {
|
|
187
|
+
return model23;
|
|
188
188
|
}
|
|
189
189
|
var ModelRendererRegistry = class {
|
|
190
190
|
models = /* @__PURE__ */ new Map();
|
|
191
|
-
register(
|
|
192
|
-
if (typeof
|
|
191
|
+
register(model23) {
|
|
192
|
+
if (typeof model23.name !== "string" || !/^[a-z]+$/.test(model23.name)) {
|
|
193
193
|
throw new Error(
|
|
194
194
|
"Model renderer names must contain only lowercase letters"
|
|
195
195
|
);
|
|
196
196
|
}
|
|
197
|
-
if (this.models.has(
|
|
198
|
-
throw new Error(`Model renderer "${
|
|
197
|
+
if (this.models.has(model23.name)) {
|
|
198
|
+
throw new Error(`Model renderer "${model23.name}" is already registered`);
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
200
|
+
if (model23.pads !== "none" && model23.pads !== "footprinter") {
|
|
201
201
|
throw new Error('Model renderer pads must be "none" or "footprinter"');
|
|
202
202
|
}
|
|
203
|
-
const { name, schema, render: render2, pads } =
|
|
203
|
+
const { name, schema, render: render2, pads } = model23;
|
|
204
204
|
this.models.set(name, {
|
|
205
205
|
name,
|
|
206
206
|
schema,
|
|
@@ -454,6 +454,314 @@ function register2(registry) {
|
|
|
454
454
|
registry.register(model2);
|
|
455
455
|
}
|
|
456
456
|
|
|
457
|
+
// lib/models/clampingshaftcollar/register.tsx
|
|
458
|
+
import { clampingShaftCollarModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
459
|
+
|
|
460
|
+
// lib/models/clampingshaftcollar/mesh.ts
|
|
461
|
+
import jscad3 from "@jscad/modeling";
|
|
462
|
+
import {
|
|
463
|
+
clampingShaftCollarModelPropsSchema,
|
|
464
|
+
getClampingShaftCollarDimensions
|
|
465
|
+
} from "@tscircuit/modelprinter";
|
|
466
|
+
|
|
467
|
+
// lib/mechanical/shaft-mount-geometry.ts
|
|
468
|
+
import jscad2 from "@jscad/modeling";
|
|
469
|
+
var bodySegments = 64;
|
|
470
|
+
var threadSegments = 24;
|
|
471
|
+
var samplesPerTurn = 12;
|
|
472
|
+
function assertShaftMountResolution(holes) {
|
|
473
|
+
let triangles = 0;
|
|
474
|
+
for (const hole of holes) {
|
|
475
|
+
const steps = hole.threadPitch ? Math.ceil(hole.depth / hole.threadPitch * samplesPerTurn) : 1;
|
|
476
|
+
if (!Number.isFinite(steps) || steps > 768)
|
|
477
|
+
throw new Error(
|
|
478
|
+
"Shaft mount exceeds mesh resolution limit (64 thread turns per hole)"
|
|
479
|
+
);
|
|
480
|
+
triangles += (steps + 1) * threadSegments * 2;
|
|
481
|
+
}
|
|
482
|
+
if (triangles > 1e5)
|
|
483
|
+
throw new Error("Shaft mount exceeds total mesh resolution limit");
|
|
484
|
+
}
|
|
485
|
+
function createAnnularSleeve({
|
|
486
|
+
outerRadius,
|
|
487
|
+
boreARadius,
|
|
488
|
+
boreBRadius = boreARadius,
|
|
489
|
+
length,
|
|
490
|
+
chamfer,
|
|
491
|
+
stepZ = length / 2
|
|
492
|
+
}) {
|
|
493
|
+
const halfAngle = Math.PI / bodySegments;
|
|
494
|
+
const cosine = Math.cos(halfAngle);
|
|
495
|
+
if ((Math.max(boreARadius, boreBRadius) + chamfer) / cosine >= (outerRadius - chamfer) * cosine - 1e-6)
|
|
496
|
+
throw new Error(
|
|
497
|
+
"Shaft mount wall/chamfer ligament exceeds mesh resolution limit"
|
|
498
|
+
);
|
|
499
|
+
const raw = [
|
|
500
|
+
[0, outerRadius - chamfer, false],
|
|
501
|
+
[chamfer, outerRadius, false],
|
|
502
|
+
[length - chamfer, outerRadius, false],
|
|
503
|
+
[length, outerRadius - chamfer, false],
|
|
504
|
+
[length, boreBRadius + chamfer, true],
|
|
505
|
+
[length - chamfer, boreBRadius, true],
|
|
506
|
+
[stepZ, boreBRadius, true],
|
|
507
|
+
[stepZ, boreARadius, true],
|
|
508
|
+
[chamfer, boreARadius, true],
|
|
509
|
+
[0, boreARadius + chamfer, true]
|
|
510
|
+
];
|
|
511
|
+
const profile = raw.filter(
|
|
512
|
+
([z, r], i) => i === 0 || z !== raw[i - 1][0] || r !== raw[i - 1][1]
|
|
513
|
+
);
|
|
514
|
+
const positions = [];
|
|
515
|
+
const indices = [];
|
|
516
|
+
for (const [z, r, isBore] of profile)
|
|
517
|
+
for (let i = 0; i < bodySegments; i++) {
|
|
518
|
+
const angle = (i + (isBore ? 0.5 : 0)) * Math.PI * 2 / bodySegments;
|
|
519
|
+
const radius = isBore ? r / cosine : r;
|
|
520
|
+
positions.push(radius * Math.cos(angle), radius * Math.sin(angle), z);
|
|
521
|
+
}
|
|
522
|
+
for (let row = 0; row < profile.length; row++)
|
|
523
|
+
for (let i = 0; i < bodySegments; i++) {
|
|
524
|
+
const next = (i + 1) % bodySegments;
|
|
525
|
+
const a = row * bodySegments + i, b = row * bodySegments + next;
|
|
526
|
+
const c = (row + 1) % profile.length * bodySegments + next, d = (row + 1) % profile.length * bodySegments + i;
|
|
527
|
+
indices.push(a, b, c, a, c, d);
|
|
528
|
+
}
|
|
529
|
+
return indexedMeshToGeom3({ positions, indices });
|
|
530
|
+
}
|
|
531
|
+
function createMountingHoleCutter(hole) {
|
|
532
|
+
assertShaftMountResolution([hole]);
|
|
533
|
+
const pitch = hole.threadPitch;
|
|
534
|
+
const steps = pitch ? Math.max(2, Math.ceil(hole.depth / pitch * samplesPerTurn)) : 1;
|
|
535
|
+
const segments = pitch ? threadSegments : 48;
|
|
536
|
+
const extension = 1e-4;
|
|
537
|
+
const radius = hole.diameter / 2;
|
|
538
|
+
const threadDepth = pitch ? Math.min(pitch * 0.541266, radius * 0.8) : 0;
|
|
539
|
+
const hand = hole.threadHand === "left" ? -1 : 1;
|
|
540
|
+
const positions = [];
|
|
541
|
+
const indices = [];
|
|
542
|
+
const [dx, dy, dz] = hole.direction;
|
|
543
|
+
if (Math.abs(dz) > 1e-10 || Math.abs(Math.hypot(dx, dy) - 1) > 1e-10)
|
|
544
|
+
throw new Error("Expected a horizontal unit hole axis");
|
|
545
|
+
const push = (x, y, z) => {
|
|
546
|
+
positions.push(
|
|
547
|
+
hole.start[0] + y * dy + z * dx,
|
|
548
|
+
hole.start[1] - y * dx + z * dy,
|
|
549
|
+
hole.start[2] + x
|
|
550
|
+
);
|
|
551
|
+
};
|
|
552
|
+
for (let row = 0; row <= steps; row++) {
|
|
553
|
+
const z = -extension + (hole.depth + 2 * extension) * row / steps;
|
|
554
|
+
for (let i = 0; i < segments; i++) {
|
|
555
|
+
const angle = i * Math.PI * 2 / segments;
|
|
556
|
+
const phase = pitch ? ((z / pitch - hand * angle / (Math.PI * 2)) % 1 + 1) % 1 : 0;
|
|
557
|
+
const distance2 = Math.min(phase, 1 - phase);
|
|
558
|
+
const r = radius - Math.min(
|
|
559
|
+
threadDepth,
|
|
560
|
+
Math.max(0, (distance2 - 1 / 8) * (pitch ?? 0) * Math.sqrt(3))
|
|
561
|
+
);
|
|
562
|
+
push(r * Math.cos(angle), r * Math.sin(angle), z);
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
for (let row = 0; row < steps; row++)
|
|
566
|
+
for (let i = 0; i < segments; i++) {
|
|
567
|
+
const next = (i + 1) % segments;
|
|
568
|
+
const a = row * segments + i, b = row * segments + next, c = (row + 1) * segments + next, d = (row + 1) * segments + i;
|
|
569
|
+
indices.push(a, b, c, a, c, d);
|
|
570
|
+
}
|
|
571
|
+
for (const end of [0, steps]) {
|
|
572
|
+
const center = positions.length / 3;
|
|
573
|
+
push(0, 0, end === 0 ? -extension : hole.depth + extension);
|
|
574
|
+
for (let i = 0; i < segments; i++) {
|
|
575
|
+
const a = end * segments + i, b = end * segments + (i + 1) % segments;
|
|
576
|
+
indices.push(center, end === 0 ? b : a, end === 0 ? a : b);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
return indexedMeshToGeom3({ positions, indices });
|
|
580
|
+
}
|
|
581
|
+
function subtractShaftMountParts(body, ...cutters) {
|
|
582
|
+
const factor = 100;
|
|
583
|
+
const scaled = [body, ...cutters].map(
|
|
584
|
+
(geometry) => jscad2.transforms.scale([factor, factor, factor], geometry)
|
|
585
|
+
);
|
|
586
|
+
const result = jscad2.booleans.subtract(scaled[0], ...scaled.slice(1));
|
|
587
|
+
return jscad2.transforms.scale([1 / factor, 1 / factor, 1 / factor], result);
|
|
588
|
+
}
|
|
589
|
+
function finishShaftMountMesh(geometry) {
|
|
590
|
+
const positions = [];
|
|
591
|
+
const vertices = /* @__PURE__ */ new Map();
|
|
592
|
+
const tolerance = 1e-6;
|
|
593
|
+
const weld = (point) => {
|
|
594
|
+
const cell = point.map((v) => Math.floor(v / tolerance));
|
|
595
|
+
for (let x = -1; x <= 1; x++)
|
|
596
|
+
for (let y = -1; y <= 1; y++)
|
|
597
|
+
for (let z = -1; z <= 1; z++) {
|
|
598
|
+
const nearby = vertices.get(
|
|
599
|
+
[cell[0] + x, cell[1] + y, cell[2] + z].join(",")
|
|
600
|
+
) ?? [];
|
|
601
|
+
for (const index2 of nearby)
|
|
602
|
+
if (Math.hypot(
|
|
603
|
+
...point.map((v, axis) => v - positions[index2 * 3 + axis])
|
|
604
|
+
) < tolerance)
|
|
605
|
+
return index2;
|
|
606
|
+
}
|
|
607
|
+
const index = positions.length / 3;
|
|
608
|
+
positions.push(...point);
|
|
609
|
+
const key = cell.join(",");
|
|
610
|
+
vertices.set(key, [...vertices.get(key) ?? [], index]);
|
|
611
|
+
return index;
|
|
612
|
+
};
|
|
613
|
+
const polygons = jscad2.geometries.geom3.toPolygons(geometry).map(
|
|
614
|
+
(polygon) => polygon.vertices.map(weld).filter((id, i, ids) => id !== ids[(i + ids.length - 1) % ids.length])
|
|
615
|
+
).map((ids) => [...new Set(ids)]).filter((ids) => ids.length >= 3).filter((ids) => {
|
|
616
|
+
let longest = 0;
|
|
617
|
+
let origin = [];
|
|
618
|
+
let direction = [];
|
|
619
|
+
for (let i = 0; i < ids.length; i++)
|
|
620
|
+
for (let j = i + 1; j < ids.length; j++) {
|
|
621
|
+
const a = positions.slice(ids[i] * 3, ids[i] * 3 + 3);
|
|
622
|
+
const delta = positions.slice(ids[j] * 3, ids[j] * 3 + 3).map((v, axis) => v - a[axis]);
|
|
623
|
+
const squared = delta.reduce((sum, v) => sum + v * v, 0);
|
|
624
|
+
if (squared > longest) {
|
|
625
|
+
longest = squared;
|
|
626
|
+
origin = a;
|
|
627
|
+
direction = delta;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
return ids.some((id) => {
|
|
631
|
+
const delta = positions.slice(id * 3, id * 3 + 3).map((v, axis) => v - origin[axis]);
|
|
632
|
+
const t = delta.reduce((sum, v, axis) => sum + v * direction[axis], 0) / longest;
|
|
633
|
+
return Math.hypot(...delta.map((v, axis) => v - t * direction[axis])) >= tolerance;
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
const edgeKey = (a, b) => `${Math.min(a, b)},${Math.max(a, b)}`;
|
|
637
|
+
const edges = /* @__PURE__ */ new Map();
|
|
638
|
+
for (const polygon of polygons)
|
|
639
|
+
for (let i = 0; i < polygon.length; i++) {
|
|
640
|
+
const a = polygon[i], b = polygon[(i + 1) % polygon.length], key = edgeKey(a, b);
|
|
641
|
+
const edge = edges.get(key) ?? { a, b, count: 0 };
|
|
642
|
+
edge.count++;
|
|
643
|
+
edges.set(key, edge);
|
|
644
|
+
}
|
|
645
|
+
const unmatched = [...edges.values()].filter((edge) => edge.count === 1);
|
|
646
|
+
const candidates = [...new Set(unmatched.flatMap((edge) => [edge.a, edge.b]))];
|
|
647
|
+
const splits = /* @__PURE__ */ new Map();
|
|
648
|
+
for (const { a, b } of unmatched) {
|
|
649
|
+
const origin = positions.slice(a * 3, a * 3 + 3);
|
|
650
|
+
const direction = positions.slice(b * 3, b * 3 + 3).map((v, axis) => v - origin[axis]);
|
|
651
|
+
const squared = direction.reduce((sum, v) => sum + v * v, 0);
|
|
652
|
+
const points = [];
|
|
653
|
+
for (const id of candidates) {
|
|
654
|
+
if (id === a || id === b) continue;
|
|
655
|
+
const delta = positions.slice(id * 3, id * 3 + 3).map((v, axis) => v - origin[axis]);
|
|
656
|
+
const t = delta.reduce((sum, v, axis) => sum + v * direction[axis], 0) / squared;
|
|
657
|
+
if (t <= 0 || t >= 1) continue;
|
|
658
|
+
const distance2 = Math.hypot(
|
|
659
|
+
...delta.map((v, axis) => v - t * direction[axis])
|
|
660
|
+
);
|
|
661
|
+
if (distance2 < tolerance) points.push({ id, t });
|
|
662
|
+
}
|
|
663
|
+
points.sort((p, q) => p.t - q.t);
|
|
664
|
+
splits.set(
|
|
665
|
+
`${a},${b}`,
|
|
666
|
+
points.map((p) => p.id)
|
|
667
|
+
);
|
|
668
|
+
splits.set(`${b},${a}`, points.map((p) => p.id).reverse());
|
|
669
|
+
}
|
|
670
|
+
const indices = [];
|
|
671
|
+
for (const polygon of polygons) {
|
|
672
|
+
const perimeter = polygon.flatMap((a, i) => [
|
|
673
|
+
a,
|
|
674
|
+
...(splits.get(`${a},${polygon[(i + 1) % polygon.length]}`) ?? []).filter((id) => !polygon.includes(id))
|
|
675
|
+
]);
|
|
676
|
+
const unique = perimeter.filter(
|
|
677
|
+
(id, i) => id !== perimeter[(i + perimeter.length - 1) % perimeter.length]
|
|
678
|
+
);
|
|
679
|
+
if (unique.length === 3) {
|
|
680
|
+
indices.push(...unique);
|
|
681
|
+
continue;
|
|
682
|
+
}
|
|
683
|
+
const center = positions.length / 3;
|
|
684
|
+
positions.push(
|
|
685
|
+
...[0, 1, 2].map(
|
|
686
|
+
(axis) => unique.reduce((sum, id) => sum + positions[id * 3 + axis], 0) / unique.length
|
|
687
|
+
)
|
|
688
|
+
);
|
|
689
|
+
for (let i = 0; i < unique.length; i++)
|
|
690
|
+
indices.push(center, unique[i], unique[(i + 1) % unique.length]);
|
|
691
|
+
}
|
|
692
|
+
const compact = [];
|
|
693
|
+
const remap = /* @__PURE__ */ new Map();
|
|
694
|
+
return {
|
|
695
|
+
positions: compact,
|
|
696
|
+
indices: indices.map((index) => {
|
|
697
|
+
let next = remap.get(index);
|
|
698
|
+
if (next === void 0) {
|
|
699
|
+
next = compact.length / 3;
|
|
700
|
+
remap.set(index, next);
|
|
701
|
+
compact.push(...positions.slice(index * 3, index * 3 + 3));
|
|
702
|
+
}
|
|
703
|
+
return next;
|
|
704
|
+
})
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
// lib/models/clampingshaftcollar/mesh.ts
|
|
709
|
+
function createClampingShaftCollarMesh(input) {
|
|
710
|
+
const props = clampingShaftCollarModelPropsSchema.parse(input);
|
|
711
|
+
const dimensions = getClampingShaftCollarDimensions(props);
|
|
712
|
+
assertShaftMountResolution([dimensions.threadedHole]);
|
|
713
|
+
const body = createAnnularSleeve({
|
|
714
|
+
outerRadius: props.outerDiameter / 2,
|
|
715
|
+
boreARadius: props.boreDiameter / 2,
|
|
716
|
+
length: props.width,
|
|
717
|
+
chamfer: props.chamfer
|
|
718
|
+
});
|
|
719
|
+
const s = dimensions.split;
|
|
720
|
+
const epsilon = 1e-4;
|
|
721
|
+
const slit = jscad3.primitives.cuboid({
|
|
722
|
+
size: [
|
|
723
|
+
s.xMax - s.xMin + epsilon,
|
|
724
|
+
s.yMax - s.yMin,
|
|
725
|
+
s.zMax - s.zMin + 2 * epsilon
|
|
726
|
+
],
|
|
727
|
+
center: [
|
|
728
|
+
(s.xMax + s.xMin + epsilon) / 2,
|
|
729
|
+
(s.yMax + s.yMin) / 2,
|
|
730
|
+
(s.zMax + s.zMin) / 2
|
|
731
|
+
]
|
|
732
|
+
});
|
|
733
|
+
return finishShaftMountMesh(
|
|
734
|
+
subtractShaftMountParts(
|
|
735
|
+
body,
|
|
736
|
+
slit,
|
|
737
|
+
createMountingHoleCutter(dimensions.clearanceHole),
|
|
738
|
+
createMountingHoleCutter(dimensions.threadedHole)
|
|
739
|
+
)
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// lib/models/clampingshaftcollar/ClampingShaftCollar.tsx
|
|
744
|
+
function createClampingShaftCollarGeom(input) {
|
|
745
|
+
return indexedMeshToGeom3(createClampingShaftCollarMesh(input));
|
|
746
|
+
}
|
|
747
|
+
function ClampingShaftCollar({
|
|
748
|
+
color = "#737e8f",
|
|
749
|
+
...props
|
|
750
|
+
}) {
|
|
751
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createClampingShaftCollarGeom(props) }) });
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
// lib/models/clampingshaftcollar/register.tsx
|
|
755
|
+
var model3 = defineModelRenderer({
|
|
756
|
+
name: "clampingshaftcollar",
|
|
757
|
+
schema: clampingShaftCollarModelDefinitionSchema,
|
|
758
|
+
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(ClampingShaftCollar, { ...props }),
|
|
759
|
+
pads: "none"
|
|
760
|
+
});
|
|
761
|
+
function register3(registry) {
|
|
762
|
+
registry.register(model3);
|
|
763
|
+
}
|
|
764
|
+
|
|
457
765
|
// lib/models/compressionspring/register.tsx
|
|
458
766
|
import { compressionSpringModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
459
767
|
|
|
@@ -657,14 +965,14 @@ function CompressionSpring({
|
|
|
657
965
|
}
|
|
658
966
|
|
|
659
967
|
// lib/models/compressionspring/register.tsx
|
|
660
|
-
var
|
|
968
|
+
var model4 = defineModelRenderer({
|
|
661
969
|
name: "compressionspring",
|
|
662
970
|
schema: compressionSpringModelDefinitionSchema,
|
|
663
971
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(CompressionSpring, { ...props }),
|
|
664
972
|
pads: "none"
|
|
665
973
|
});
|
|
666
|
-
function
|
|
667
|
-
registry.register(
|
|
974
|
+
function register4(registry) {
|
|
975
|
+
registry.register(model4);
|
|
668
976
|
}
|
|
669
977
|
|
|
670
978
|
// lib/models/flangedbushing/register.tsx
|
|
@@ -720,14 +1028,14 @@ function FlangedBushing({
|
|
|
720
1028
|
}
|
|
721
1029
|
|
|
722
1030
|
// lib/models/flangedbushing/register.tsx
|
|
723
|
-
var
|
|
1031
|
+
var model5 = defineModelRenderer({
|
|
724
1032
|
name: "flangedbushing",
|
|
725
1033
|
schema: flangedBushingModelDefinitionSchema,
|
|
726
1034
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(FlangedBushing, { ...props }),
|
|
727
1035
|
pads: "none"
|
|
728
1036
|
});
|
|
729
|
-
function
|
|
730
|
-
registry.register(
|
|
1037
|
+
function register5(registry) {
|
|
1038
|
+
registry.register(model5);
|
|
731
1039
|
}
|
|
732
1040
|
|
|
733
1041
|
// lib/models/flatheadscrew/register.tsx
|
|
@@ -860,14 +1168,14 @@ function FlatHeadScrew({
|
|
|
860
1168
|
}
|
|
861
1169
|
|
|
862
1170
|
// lib/models/flatheadscrew/register.tsx
|
|
863
|
-
var
|
|
1171
|
+
var model6 = defineModelRenderer({
|
|
864
1172
|
name: "flatheadscrew",
|
|
865
1173
|
schema: flatHeadScrewModelDefinitionSchema,
|
|
866
1174
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(FlatHeadScrew, { ...props }),
|
|
867
1175
|
pads: "none"
|
|
868
1176
|
});
|
|
869
|
-
function
|
|
870
|
-
registry.register(
|
|
1177
|
+
function register6(registry) {
|
|
1178
|
+
registry.register(model6);
|
|
871
1179
|
}
|
|
872
1180
|
|
|
873
1181
|
// lib/models/flexscreen/register.tsx
|
|
@@ -1545,14 +1853,14 @@ var FlexScreen = (props) => {
|
|
|
1545
1853
|
};
|
|
1546
1854
|
|
|
1547
1855
|
// lib/models/flexscreen/register.tsx
|
|
1548
|
-
var
|
|
1856
|
+
var model7 = defineModelRenderer({
|
|
1549
1857
|
name: "flexscreen",
|
|
1550
1858
|
schema: flexScreenModelDefinitionSchema,
|
|
1551
1859
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(FlexScreen, { ...props }),
|
|
1552
1860
|
pads: "footprinter"
|
|
1553
1861
|
});
|
|
1554
|
-
function
|
|
1555
|
-
registry.register(
|
|
1862
|
+
function register7(registry) {
|
|
1863
|
+
registry.register(model7);
|
|
1556
1864
|
}
|
|
1557
1865
|
|
|
1558
1866
|
// lib/models/helicalgear/register.tsx
|
|
@@ -1758,14 +2066,14 @@ function HelicalGear({ color = "#737e8f", ...props }) {
|
|
|
1758
2066
|
}
|
|
1759
2067
|
|
|
1760
2068
|
// lib/models/helicalgear/register.tsx
|
|
1761
|
-
var
|
|
2069
|
+
var model8 = defineModelRenderer({
|
|
1762
2070
|
name: "helicalgear",
|
|
1763
2071
|
schema: helicalGearModelDefinitionSchema,
|
|
1764
2072
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HelicalGear, { ...props }),
|
|
1765
2073
|
pads: "none"
|
|
1766
2074
|
});
|
|
1767
|
-
function
|
|
1768
|
-
registry.register(
|
|
2075
|
+
function register8(registry) {
|
|
2076
|
+
registry.register(model8);
|
|
1769
2077
|
}
|
|
1770
2078
|
|
|
1771
2079
|
// lib/models/hexbolt/register.tsx
|
|
@@ -1906,14 +2214,14 @@ function HexBolt({ color = "#737e8f", ...props }) {
|
|
|
1906
2214
|
}
|
|
1907
2215
|
|
|
1908
2216
|
// lib/models/hexbolt/register.tsx
|
|
1909
|
-
var
|
|
2217
|
+
var model9 = defineModelRenderer({
|
|
1910
2218
|
name: "hexbolt",
|
|
1911
2219
|
schema: hexBoltModelDefinitionSchema,
|
|
1912
2220
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HexBolt, { ...props }),
|
|
1913
2221
|
pads: "none"
|
|
1914
2222
|
});
|
|
1915
|
-
function
|
|
1916
|
-
registry.register(
|
|
2223
|
+
function register9(registry) {
|
|
2224
|
+
registry.register(model9);
|
|
1917
2225
|
}
|
|
1918
2226
|
|
|
1919
2227
|
// lib/models/hexnut/register.tsx
|
|
@@ -2036,14 +2344,14 @@ function HexNut({ color = "#737e8f", ...props }) {
|
|
|
2036
2344
|
}
|
|
2037
2345
|
|
|
2038
2346
|
// lib/models/hexnut/register.tsx
|
|
2039
|
-
var
|
|
2347
|
+
var model10 = defineModelRenderer({
|
|
2040
2348
|
name: "hexnut",
|
|
2041
2349
|
schema: hexNutModelDefinitionSchema,
|
|
2042
2350
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HexNut, { ...props }),
|
|
2043
2351
|
pads: "none"
|
|
2044
2352
|
});
|
|
2045
|
-
function
|
|
2046
|
-
registry.register(
|
|
2353
|
+
function register10(registry) {
|
|
2354
|
+
registry.register(model10);
|
|
2047
2355
|
}
|
|
2048
2356
|
|
|
2049
2357
|
// lib/models/hexsocketbolt/register.tsx
|
|
@@ -2155,24 +2463,24 @@ function HexSocketBolt({
|
|
|
2155
2463
|
}
|
|
2156
2464
|
|
|
2157
2465
|
// lib/models/hexsocketbolt/register.tsx
|
|
2158
|
-
var
|
|
2466
|
+
var model11 = defineModelRenderer({
|
|
2159
2467
|
name: "hexsocketbolt",
|
|
2160
2468
|
schema: hexSocketBoltModelDefinitionSchema,
|
|
2161
2469
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HexSocketBolt, { ...props }),
|
|
2162
2470
|
pads: "none"
|
|
2163
2471
|
});
|
|
2164
|
-
function
|
|
2165
|
-
registry.register(
|
|
2472
|
+
function register11(registry) {
|
|
2473
|
+
registry.register(model11);
|
|
2166
2474
|
}
|
|
2167
2475
|
|
|
2168
2476
|
// lib/models/nema/register.tsx
|
|
2169
2477
|
import { nemaMotorModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
2170
2478
|
|
|
2171
2479
|
// lib/NemaMotor.tsx
|
|
2172
|
-
import
|
|
2480
|
+
import jscad5 from "@jscad/modeling";
|
|
2173
2481
|
|
|
2174
2482
|
// lib/utils/nemaMotorWireGeometry.ts
|
|
2175
|
-
import
|
|
2483
|
+
import jscad4 from "@jscad/modeling";
|
|
2176
2484
|
import {
|
|
2177
2485
|
getJstMotorConnector,
|
|
2178
2486
|
getNemaMotorReferencePoints
|
|
@@ -2190,9 +2498,9 @@ function createNemaMotorWireGeometry(input) {
|
|
|
2190
2498
|
if (p.wireConnection === "none") return [];
|
|
2191
2499
|
const { position } = getNemaMotorReferencePoints(p).wireside;
|
|
2192
2500
|
const angle = p.wireSideAngle * Math.PI / 180;
|
|
2193
|
-
const place = (geometry) =>
|
|
2501
|
+
const place = (geometry) => jscad4.transforms.translate(
|
|
2194
2502
|
[position.x, position.y, position.z],
|
|
2195
|
-
|
|
2503
|
+
jscad4.transforms.rotateZ(angle, geometry)
|
|
2196
2504
|
);
|
|
2197
2505
|
if (p.wireConnection === "stubs") {
|
|
2198
2506
|
const colors = [
|
|
@@ -2208,15 +2516,15 @@ function createNemaMotorWireGeometry(input) {
|
|
|
2208
2516
|
return Array.from({ length: p.wireCount }, (_, i) => ({
|
|
2209
2517
|
color: colors[i],
|
|
2210
2518
|
geometry: place(
|
|
2211
|
-
|
|
2519
|
+
jscad4.transforms.translate(
|
|
2212
2520
|
[
|
|
2213
2521
|
(p.wireLength - 0.15) / 2,
|
|
2214
2522
|
(i - (p.wireCount - 1) / 2) * p.wireDiameter * 1.5,
|
|
2215
2523
|
0
|
|
2216
2524
|
],
|
|
2217
|
-
|
|
2525
|
+
jscad4.transforms.rotateY(
|
|
2218
2526
|
Math.PI / 2,
|
|
2219
|
-
|
|
2527
|
+
jscad4.primitives.cylinder({
|
|
2220
2528
|
height: p.wireLength + 0.15,
|
|
2221
2529
|
radius: p.wireDiameter / 2,
|
|
2222
2530
|
segments: 24
|
|
@@ -2231,12 +2539,12 @@ function createNemaMotorWireGeometry(input) {
|
|
|
2231
2539
|
const wall = pitch === 2 ? 0.6 : 0.3;
|
|
2232
2540
|
const contactLength = pitch === 2 ? 3.4 : 2.4;
|
|
2233
2541
|
const contactSize = pitch === 2 ? 0.5 : 0.3;
|
|
2234
|
-
const shell =
|
|
2235
|
-
|
|
2542
|
+
const shell = jscad4.booleans.subtract(
|
|
2543
|
+
jscad4.primitives.cuboid({
|
|
2236
2544
|
size: [matingDepth + 0.1, bodyWidth, bodyHeight],
|
|
2237
2545
|
center: [(matingDepth - 0.1) / 2, 0, 0]
|
|
2238
2546
|
}),
|
|
2239
|
-
|
|
2547
|
+
jscad4.primitives.cuboid({
|
|
2240
2548
|
size: [matingDepth - 0.5, bodyWidth - 2 * wall, bodyHeight - 2 * wall],
|
|
2241
2549
|
center: [matingDepth / 2 + 0.55, 0, 0]
|
|
2242
2550
|
})
|
|
@@ -2246,7 +2554,7 @@ function createNemaMotorWireGeometry(input) {
|
|
|
2246
2554
|
...Array.from({ length: pinCount }, (_, i) => ({
|
|
2247
2555
|
color: "#b8bec6",
|
|
2248
2556
|
geometry: place(
|
|
2249
|
-
|
|
2557
|
+
jscad4.primitives.cuboid({
|
|
2250
2558
|
size: [contactLength, contactSize, contactSize],
|
|
2251
2559
|
center: [contactLength / 2, (i - (pinCount - 1) / 2) * pitch, 0]
|
|
2252
2560
|
})
|
|
@@ -2354,7 +2662,7 @@ function createNemaMotorSections(input) {
|
|
|
2354
2662
|
}
|
|
2355
2663
|
|
|
2356
2664
|
// lib/NemaMotor.tsx
|
|
2357
|
-
var generalize =
|
|
2665
|
+
var generalize = jscad5.modifiers.generalize;
|
|
2358
2666
|
function NemaMotor({
|
|
2359
2667
|
bodyColor = "#242830",
|
|
2360
2668
|
capColor = "#aeb5bd",
|
|
@@ -2363,7 +2671,7 @@ function NemaMotor({
|
|
|
2363
2671
|
...props
|
|
2364
2672
|
}) {
|
|
2365
2673
|
const p = resolveNemaMotorProps(props);
|
|
2366
|
-
const screw = p.backFace === "screws" ?
|
|
2674
|
+
const screw = p.backFace === "screws" ? jscad5.transforms.rotateX(
|
|
2367
2675
|
Math.PI,
|
|
2368
2676
|
createHexSocketBoltGeom({
|
|
2369
2677
|
metricSize: p.backFaceScrewSize,
|
|
@@ -2374,14 +2682,14 @@ function NemaMotor({
|
|
|
2374
2682
|
const halfPitch = p.backFaceHoleSpacing / 2;
|
|
2375
2683
|
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
2376
2684
|
createNemaMotorSections(p).map((section, index) => {
|
|
2377
|
-
const outline =
|
|
2378
|
-
const profile = section.holes.length ?
|
|
2685
|
+
const outline = jscad5.geometries.geom2.fromPoints(section.outline);
|
|
2686
|
+
const profile = section.holes.length ? jscad5.booleans.subtract(
|
|
2379
2687
|
outline,
|
|
2380
|
-
...section.holes.map((h2) =>
|
|
2688
|
+
...section.holes.map((h2) => jscad5.geometries.geom2.fromPoints(h2))
|
|
2381
2689
|
) : outline;
|
|
2382
|
-
const geometry =
|
|
2690
|
+
const geometry = jscad5.transforms.translate(
|
|
2383
2691
|
[0, 0, section.zMin],
|
|
2384
|
-
|
|
2692
|
+
jscad5.extrusions.extrudeLinear(
|
|
2385
2693
|
{ height: section.zMax - section.zMin },
|
|
2386
2694
|
profile
|
|
2387
2695
|
)
|
|
@@ -2414,7 +2722,7 @@ function NemaMotor({
|
|
|
2414
2722
|
children: /* @__PURE__ */ jsx(
|
|
2415
2723
|
Custom,
|
|
2416
2724
|
{
|
|
2417
|
-
geometry:
|
|
2725
|
+
geometry: jscad5.transforms.translate(
|
|
2418
2726
|
[x, y, -p.bodyLength],
|
|
2419
2727
|
generalize({ simplify: true }, screw)
|
|
2420
2728
|
)
|
|
@@ -2431,14 +2739,14 @@ var NEMA17 = (props) => /* @__PURE__ */ jsx(NemaMotor, { ...props, nemaSize: 17
|
|
|
2431
2739
|
var NEMA23 = (props) => /* @__PURE__ */ jsx(NemaMotor, { ...props, nemaSize: 23 });
|
|
2432
2740
|
|
|
2433
2741
|
// lib/models/nema/register.tsx
|
|
2434
|
-
var
|
|
2742
|
+
var model12 = defineModelRenderer({
|
|
2435
2743
|
name: "nema",
|
|
2436
2744
|
schema: nemaMotorModelDefinitionSchema,
|
|
2437
2745
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(NemaMotor, { ...props }),
|
|
2438
2746
|
pads: "none"
|
|
2439
2747
|
});
|
|
2440
|
-
function
|
|
2441
|
-
registry.register(
|
|
2748
|
+
function register12(registry) {
|
|
2749
|
+
registry.register(model12);
|
|
2442
2750
|
}
|
|
2443
2751
|
|
|
2444
2752
|
// lib/models/panscrew/register.tsx
|
|
@@ -2650,14 +2958,14 @@ function PanScrew({ color = "#737e8f", ...props }) {
|
|
|
2650
2958
|
}
|
|
2651
2959
|
|
|
2652
2960
|
// lib/models/panscrew/register.tsx
|
|
2653
|
-
var
|
|
2961
|
+
var model13 = defineModelRenderer({
|
|
2654
2962
|
name: "panscrew",
|
|
2655
2963
|
schema: panScrewModelDefinitionSchema,
|
|
2656
2964
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(PanScrew, { ...props }),
|
|
2657
2965
|
pads: "none"
|
|
2658
2966
|
});
|
|
2659
|
-
function
|
|
2660
|
-
registry.register(
|
|
2967
|
+
function register13(registry) {
|
|
2968
|
+
registry.register(model13);
|
|
2661
2969
|
}
|
|
2662
2970
|
|
|
2663
2971
|
// lib/models/plainbushing/register.tsx
|
|
@@ -2682,306 +2990,114 @@ function createPlainBushingMesh(input) {
|
|
|
2682
2990
|
[d.endInnerDiameter / 2, d.length],
|
|
2683
2991
|
[ri, d.length - c],
|
|
2684
2992
|
[ri, c],
|
|
2685
|
-
[d.endInnerDiameter / 2, 0]
|
|
2686
|
-
] : [
|
|
2687
|
-
[ro, 0],
|
|
2688
|
-
[ro, d.length],
|
|
2689
|
-
[ri, d.length],
|
|
2690
|
-
[ri, 0]
|
|
2691
|
-
];
|
|
2692
|
-
const segments = 96;
|
|
2693
|
-
const positions = [];
|
|
2694
|
-
const indices = [];
|
|
2695
|
-
for (const [radius, z] of profile)
|
|
2696
|
-
for (let i = 0; i < segments; i++) {
|
|
2697
|
-
const angle = i * Math.PI * 2 / segments;
|
|
2698
|
-
positions.push(radius * Math.cos(angle), radius * Math.sin(angle), z);
|
|
2699
|
-
}
|
|
2700
|
-
for (let ring = 0; ring < profile.length; ring++) {
|
|
2701
|
-
const a = ring * segments;
|
|
2702
|
-
const b = (ring + 1) % profile.length * segments;
|
|
2703
|
-
for (let i = 0; i < segments; i++) {
|
|
2704
|
-
const next = (i + 1) % segments;
|
|
2705
|
-
indices.push(a + i, a + next, b + next, a + i, b + next, b + i);
|
|
2706
|
-
}
|
|
2707
|
-
}
|
|
2708
|
-
return { positions, indices };
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
// lib/models/plainbushing/PlainBushing.tsx
|
|
2712
|
-
function createPlainBushingGeom(input) {
|
|
2713
|
-
return indexedMeshToGeom3(createPlainBushingMesh(input));
|
|
2714
|
-
}
|
|
2715
|
-
function PlainBushing({
|
|
2716
|
-
color = "#a18450",
|
|
2717
|
-
...props
|
|
2718
|
-
}) {
|
|
2719
|
-
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createPlainBushingGeom(props) }) });
|
|
2720
|
-
}
|
|
2721
|
-
|
|
2722
|
-
// lib/models/plainbushing/register.tsx
|
|
2723
|
-
var model13 = defineModelRenderer({
|
|
2724
|
-
name: "plainbushing",
|
|
2725
|
-
schema: plainBushingModelDefinitionSchema,
|
|
2726
|
-
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(PlainBushing, { ...props }),
|
|
2727
|
-
pads: "none"
|
|
2728
|
-
});
|
|
2729
|
-
function register13(registry) {
|
|
2730
|
-
registry.register(model13);
|
|
2731
|
-
}
|
|
2732
|
-
|
|
2733
|
-
// lib/models/shaftcollar/register.tsx
|
|
2734
|
-
import { shaftCollarModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
2735
|
-
|
|
2736
|
-
// lib/models/shaftcollar/mesh.ts
|
|
2737
|
-
import "@jscad/modeling";
|
|
2738
|
-
import {
|
|
2739
|
-
shaftCollarModelPropsSchema,
|
|
2740
|
-
getShaftCollarDimensions
|
|
2741
|
-
} from "@tscircuit/modelprinter";
|
|
2742
|
-
|
|
2743
|
-
// lib/mechanical/shaft-mount-geometry.ts
|
|
2744
|
-
import jscad4 from "@jscad/modeling";
|
|
2745
|
-
var bodySegments = 64;
|
|
2746
|
-
var threadSegments = 24;
|
|
2747
|
-
var samplesPerTurn = 12;
|
|
2748
|
-
function assertShaftMountResolution(holes) {
|
|
2749
|
-
let triangles = 0;
|
|
2750
|
-
for (const hole of holes) {
|
|
2751
|
-
const steps = hole.threadPitch ? Math.ceil(hole.depth / hole.threadPitch * samplesPerTurn) : 1;
|
|
2752
|
-
if (!Number.isFinite(steps) || steps > 768)
|
|
2753
|
-
throw new Error(
|
|
2754
|
-
"Shaft mount exceeds mesh resolution limit (64 thread turns per hole)"
|
|
2755
|
-
);
|
|
2756
|
-
triangles += (steps + 1) * threadSegments * 2;
|
|
2757
|
-
}
|
|
2758
|
-
if (triangles > 1e5)
|
|
2759
|
-
throw new Error("Shaft mount exceeds total mesh resolution limit");
|
|
2760
|
-
}
|
|
2761
|
-
function createAnnularSleeve({
|
|
2762
|
-
outerRadius,
|
|
2763
|
-
boreARadius,
|
|
2764
|
-
boreBRadius = boreARadius,
|
|
2765
|
-
length,
|
|
2766
|
-
chamfer,
|
|
2767
|
-
stepZ = length / 2
|
|
2768
|
-
}) {
|
|
2769
|
-
const halfAngle = Math.PI / bodySegments;
|
|
2770
|
-
const cosine = Math.cos(halfAngle);
|
|
2771
|
-
if ((Math.max(boreARadius, boreBRadius) + chamfer) / cosine >= (outerRadius - chamfer) * cosine - 1e-6)
|
|
2772
|
-
throw new Error(
|
|
2773
|
-
"Shaft mount wall/chamfer ligament exceeds mesh resolution limit"
|
|
2774
|
-
);
|
|
2775
|
-
const raw = [
|
|
2776
|
-
[0, outerRadius - chamfer, false],
|
|
2777
|
-
[chamfer, outerRadius, false],
|
|
2778
|
-
[length - chamfer, outerRadius, false],
|
|
2779
|
-
[length, outerRadius - chamfer, false],
|
|
2780
|
-
[length, boreBRadius + chamfer, true],
|
|
2781
|
-
[length - chamfer, boreBRadius, true],
|
|
2782
|
-
[stepZ, boreBRadius, true],
|
|
2783
|
-
[stepZ, boreARadius, true],
|
|
2784
|
-
[chamfer, boreARadius, true],
|
|
2785
|
-
[0, boreARadius + chamfer, true]
|
|
2786
|
-
];
|
|
2787
|
-
const profile = raw.filter(
|
|
2788
|
-
([z, r], i) => i === 0 || z !== raw[i - 1][0] || r !== raw[i - 1][1]
|
|
2789
|
-
);
|
|
2790
|
-
const positions = [];
|
|
2791
|
-
const indices = [];
|
|
2792
|
-
for (const [z, r, isBore] of profile)
|
|
2793
|
-
for (let i = 0; i < bodySegments; i++) {
|
|
2794
|
-
const angle = (i + (isBore ? 0.5 : 0)) * Math.PI * 2 / bodySegments;
|
|
2795
|
-
const radius = isBore ? r / cosine : r;
|
|
2796
|
-
positions.push(radius * Math.cos(angle), radius * Math.sin(angle), z);
|
|
2797
|
-
}
|
|
2798
|
-
for (let row = 0; row < profile.length; row++)
|
|
2799
|
-
for (let i = 0; i < bodySegments; i++) {
|
|
2800
|
-
const next = (i + 1) % bodySegments;
|
|
2801
|
-
const a = row * bodySegments + i, b = row * bodySegments + next;
|
|
2802
|
-
const c = (row + 1) % profile.length * bodySegments + next, d = (row + 1) % profile.length * bodySegments + i;
|
|
2803
|
-
indices.push(a, b, c, a, c, d);
|
|
2804
|
-
}
|
|
2805
|
-
return indexedMeshToGeom3({ positions, indices });
|
|
2806
|
-
}
|
|
2807
|
-
function createMountingHoleCutter(hole) {
|
|
2808
|
-
assertShaftMountResolution([hole]);
|
|
2809
|
-
const pitch = hole.threadPitch;
|
|
2810
|
-
const steps = pitch ? Math.max(2, Math.ceil(hole.depth / pitch * samplesPerTurn)) : 1;
|
|
2811
|
-
const segments = pitch ? threadSegments : 48;
|
|
2812
|
-
const extension = 1e-4;
|
|
2813
|
-
const radius = hole.diameter / 2;
|
|
2814
|
-
const threadDepth = pitch ? Math.min(pitch * 0.541266, radius * 0.8) : 0;
|
|
2815
|
-
const hand = hole.threadHand === "left" ? -1 : 1;
|
|
2993
|
+
[d.endInnerDiameter / 2, 0]
|
|
2994
|
+
] : [
|
|
2995
|
+
[ro, 0],
|
|
2996
|
+
[ro, d.length],
|
|
2997
|
+
[ri, d.length],
|
|
2998
|
+
[ri, 0]
|
|
2999
|
+
];
|
|
3000
|
+
const segments = 96;
|
|
2816
3001
|
const positions = [];
|
|
2817
3002
|
const indices = [];
|
|
2818
|
-
const [
|
|
2819
|
-
if (Math.abs(dz) > 1e-10 || Math.abs(Math.hypot(dx, dy) - 1) > 1e-10)
|
|
2820
|
-
throw new Error("Expected a horizontal unit hole axis");
|
|
2821
|
-
const push = (x, y, z) => {
|
|
2822
|
-
positions.push(
|
|
2823
|
-
hole.start[0] + y * dy + z * dx,
|
|
2824
|
-
hole.start[1] - y * dx + z * dy,
|
|
2825
|
-
hole.start[2] + x
|
|
2826
|
-
);
|
|
2827
|
-
};
|
|
2828
|
-
for (let row = 0; row <= steps; row++) {
|
|
2829
|
-
const z = -extension + (hole.depth + 2 * extension) * row / steps;
|
|
3003
|
+
for (const [radius, z] of profile)
|
|
2830
3004
|
for (let i = 0; i < segments; i++) {
|
|
2831
3005
|
const angle = i * Math.PI * 2 / segments;
|
|
2832
|
-
|
|
2833
|
-
const distance2 = Math.min(phase, 1 - phase);
|
|
2834
|
-
const r = radius - Math.min(
|
|
2835
|
-
threadDepth,
|
|
2836
|
-
Math.max(0, (distance2 - 1 / 8) * (pitch ?? 0) * Math.sqrt(3))
|
|
2837
|
-
);
|
|
2838
|
-
push(r * Math.cos(angle), r * Math.sin(angle), z);
|
|
3006
|
+
positions.push(radius * Math.cos(angle), radius * Math.sin(angle), z);
|
|
2839
3007
|
}
|
|
2840
|
-
|
|
2841
|
-
|
|
3008
|
+
for (let ring = 0; ring < profile.length; ring++) {
|
|
3009
|
+
const a = ring * segments;
|
|
3010
|
+
const b = (ring + 1) % profile.length * segments;
|
|
2842
3011
|
for (let i = 0; i < segments; i++) {
|
|
2843
3012
|
const next = (i + 1) % segments;
|
|
2844
|
-
|
|
2845
|
-
indices.push(a, b, c, a, c, d);
|
|
2846
|
-
}
|
|
2847
|
-
for (const end of [0, steps]) {
|
|
2848
|
-
const center = positions.length / 3;
|
|
2849
|
-
push(0, 0, end === 0 ? -extension : hole.depth + extension);
|
|
2850
|
-
for (let i = 0; i < segments; i++) {
|
|
2851
|
-
const a = end * segments + i, b = end * segments + (i + 1) % segments;
|
|
2852
|
-
indices.push(center, end === 0 ? b : a, end === 0 ? a : b);
|
|
3013
|
+
indices.push(a + i, a + next, b + next, a + i, b + next, b + i);
|
|
2853
3014
|
}
|
|
2854
3015
|
}
|
|
2855
|
-
return
|
|
3016
|
+
return { positions, indices };
|
|
2856
3017
|
}
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
);
|
|
2862
|
-
const result = jscad4.booleans.subtract(scaled[0], ...scaled.slice(1));
|
|
2863
|
-
return jscad4.transforms.scale([1 / factor, 1 / factor, 1 / factor], result);
|
|
3018
|
+
|
|
3019
|
+
// lib/models/plainbushing/PlainBushing.tsx
|
|
3020
|
+
function createPlainBushingGeom(input) {
|
|
3021
|
+
return indexedMeshToGeom3(createPlainBushingMesh(input));
|
|
2864
3022
|
}
|
|
2865
|
-
function
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
direction = delta;
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2906
|
-
return ids.some((id) => {
|
|
2907
|
-
const delta = positions.slice(id * 3, id * 3 + 3).map((v, axis) => v - origin[axis]);
|
|
2908
|
-
const t = delta.reduce((sum, v, axis) => sum + v * direction[axis], 0) / longest;
|
|
2909
|
-
return Math.hypot(...delta.map((v, axis) => v - t * direction[axis])) >= tolerance;
|
|
2910
|
-
});
|
|
3023
|
+
function PlainBushing({
|
|
3024
|
+
color = "#a18450",
|
|
3025
|
+
...props
|
|
3026
|
+
}) {
|
|
3027
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createPlainBushingGeom(props) }) });
|
|
3028
|
+
}
|
|
3029
|
+
|
|
3030
|
+
// lib/models/plainbushing/register.tsx
|
|
3031
|
+
var model14 = defineModelRenderer({
|
|
3032
|
+
name: "plainbushing",
|
|
3033
|
+
schema: plainBushingModelDefinitionSchema,
|
|
3034
|
+
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(PlainBushing, { ...props }),
|
|
3035
|
+
pads: "none"
|
|
3036
|
+
});
|
|
3037
|
+
function register14(registry) {
|
|
3038
|
+
registry.register(model14);
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
// lib/models/rigidcoupler/register.tsx
|
|
3042
|
+
import { rigidCouplerModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
3043
|
+
|
|
3044
|
+
// lib/models/rigidcoupler/mesh.ts
|
|
3045
|
+
import "@jscad/modeling";
|
|
3046
|
+
import {
|
|
3047
|
+
rigidCouplerModelPropsSchema,
|
|
3048
|
+
getRigidCouplerDimensions
|
|
3049
|
+
} from "@tscircuit/modelprinter";
|
|
3050
|
+
function createRigidCouplerMesh(input) {
|
|
3051
|
+
const props = rigidCouplerModelPropsSchema.parse(input);
|
|
3052
|
+
const dimensions = getRigidCouplerDimensions(props);
|
|
3053
|
+
assertShaftMountResolution(dimensions.screwHoles);
|
|
3054
|
+
const body = createAnnularSleeve({
|
|
3055
|
+
outerRadius: props.outerDiameter / 2,
|
|
3056
|
+
boreARadius: props.boreDiameter / 2,
|
|
3057
|
+
boreBRadius: props.boreBDiameter / 2,
|
|
3058
|
+
length: props.length,
|
|
3059
|
+
chamfer: props.chamfer,
|
|
3060
|
+
stepZ: dimensions.boreADepth
|
|
2911
3061
|
});
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
splits.set(
|
|
2941
|
-
`${a},${b}`,
|
|
2942
|
-
points.map((p) => p.id)
|
|
2943
|
-
);
|
|
2944
|
-
splits.set(`${b},${a}`, points.map((p) => p.id).reverse());
|
|
2945
|
-
}
|
|
2946
|
-
const indices = [];
|
|
2947
|
-
for (const polygon of polygons) {
|
|
2948
|
-
const perimeter = polygon.flatMap((a, i) => [
|
|
2949
|
-
a,
|
|
2950
|
-
...(splits.get(`${a},${polygon[(i + 1) % polygon.length]}`) ?? []).filter((id) => !polygon.includes(id))
|
|
2951
|
-
]);
|
|
2952
|
-
const unique = perimeter.filter(
|
|
2953
|
-
(id, i) => id !== perimeter[(i + perimeter.length - 1) % perimeter.length]
|
|
2954
|
-
);
|
|
2955
|
-
if (unique.length === 3) {
|
|
2956
|
-
indices.push(...unique);
|
|
2957
|
-
continue;
|
|
2958
|
-
}
|
|
2959
|
-
const center = positions.length / 3;
|
|
2960
|
-
positions.push(
|
|
2961
|
-
...[0, 1, 2].map(
|
|
2962
|
-
(axis) => unique.reduce((sum, id) => sum + positions[id * 3 + axis], 0) / unique.length
|
|
2963
|
-
)
|
|
2964
|
-
);
|
|
2965
|
-
for (let i = 0; i < unique.length; i++)
|
|
2966
|
-
indices.push(center, unique[i], unique[(i + 1) % unique.length]);
|
|
2967
|
-
}
|
|
2968
|
-
const compact = [];
|
|
2969
|
-
const remap = /* @__PURE__ */ new Map();
|
|
2970
|
-
return {
|
|
2971
|
-
positions: compact,
|
|
2972
|
-
indices: indices.map((index) => {
|
|
2973
|
-
let next = remap.get(index);
|
|
2974
|
-
if (next === void 0) {
|
|
2975
|
-
next = compact.length / 3;
|
|
2976
|
-
remap.set(index, next);
|
|
2977
|
-
compact.push(...positions.slice(index * 3, index * 3 + 3));
|
|
2978
|
-
}
|
|
2979
|
-
return next;
|
|
2980
|
-
})
|
|
2981
|
-
};
|
|
3062
|
+
return finishShaftMountMesh(
|
|
3063
|
+
subtractShaftMountParts(
|
|
3064
|
+
body,
|
|
3065
|
+
...dimensions.screwHoles.map(createMountingHoleCutter)
|
|
3066
|
+
)
|
|
3067
|
+
);
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
// lib/models/rigidcoupler/RigidCoupler.tsx
|
|
3071
|
+
function createRigidCouplerGeom(input) {
|
|
3072
|
+
return indexedMeshToGeom3(createRigidCouplerMesh(input));
|
|
3073
|
+
}
|
|
3074
|
+
function RigidCoupler({
|
|
3075
|
+
color = "#737e8f",
|
|
3076
|
+
...props
|
|
3077
|
+
}) {
|
|
3078
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createRigidCouplerGeom(props) }) });
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
// lib/models/rigidcoupler/register.tsx
|
|
3082
|
+
var model15 = defineModelRenderer({
|
|
3083
|
+
name: "rigidcoupler",
|
|
3084
|
+
schema: rigidCouplerModelDefinitionSchema,
|
|
3085
|
+
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(RigidCoupler, { ...props }),
|
|
3086
|
+
pads: "none"
|
|
3087
|
+
});
|
|
3088
|
+
function register15(registry) {
|
|
3089
|
+
registry.register(model15);
|
|
2982
3090
|
}
|
|
2983
3091
|
|
|
3092
|
+
// lib/models/shaftcollar/register.tsx
|
|
3093
|
+
import { shaftCollarModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
3094
|
+
|
|
2984
3095
|
// lib/models/shaftcollar/mesh.ts
|
|
3096
|
+
import "@jscad/modeling";
|
|
3097
|
+
import {
|
|
3098
|
+
shaftCollarModelPropsSchema,
|
|
3099
|
+
getShaftCollarDimensions
|
|
3100
|
+
} from "@tscircuit/modelprinter";
|
|
2985
3101
|
function createShaftCollarMesh(input) {
|
|
2986
3102
|
const props = shaftCollarModelPropsSchema.parse(input);
|
|
2987
3103
|
const dimensions = getShaftCollarDimensions(props);
|
|
@@ -3009,14 +3125,14 @@ function ShaftCollar({ color = "#737e8f", ...props }) {
|
|
|
3009
3125
|
}
|
|
3010
3126
|
|
|
3011
3127
|
// lib/models/shaftcollar/register.tsx
|
|
3012
|
-
var
|
|
3128
|
+
var model16 = defineModelRenderer({
|
|
3013
3129
|
name: "shaftcollar",
|
|
3014
3130
|
schema: shaftCollarModelDefinitionSchema,
|
|
3015
3131
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(ShaftCollar, { ...props }),
|
|
3016
3132
|
pads: "none"
|
|
3017
3133
|
});
|
|
3018
|
-
function
|
|
3019
|
-
registry.register(
|
|
3134
|
+
function register16(registry) {
|
|
3135
|
+
registry.register(model16);
|
|
3020
3136
|
}
|
|
3021
3137
|
|
|
3022
3138
|
// lib/models/sheetmetal/register.tsx
|
|
@@ -3176,14 +3292,14 @@ function SheetMetal({ color = "#737e8f", ...props }) {
|
|
|
3176
3292
|
}
|
|
3177
3293
|
|
|
3178
3294
|
// lib/models/sheetmetal/register.tsx
|
|
3179
|
-
var
|
|
3295
|
+
var model17 = defineModelRenderer({
|
|
3180
3296
|
name: "sheetmetal",
|
|
3181
3297
|
schema: sheetMetalModelDefinitionSchema,
|
|
3182
3298
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(SheetMetal, { ...props }),
|
|
3183
3299
|
pads: "none"
|
|
3184
3300
|
});
|
|
3185
|
-
function
|
|
3186
|
-
registry.register(
|
|
3301
|
+
function register17(registry) {
|
|
3302
|
+
registry.register(model17);
|
|
3187
3303
|
}
|
|
3188
3304
|
|
|
3189
3305
|
// lib/models/spurgear/register.tsx
|
|
@@ -3198,14 +3314,14 @@ function SpurGear({ color = "#737e8f", ...props }) {
|
|
|
3198
3314
|
}
|
|
3199
3315
|
|
|
3200
3316
|
// lib/models/spurgear/register.tsx
|
|
3201
|
-
var
|
|
3317
|
+
var model18 = defineModelRenderer({
|
|
3202
3318
|
name: "spurgear",
|
|
3203
3319
|
schema: spurGearModelDefinitionSchema,
|
|
3204
3320
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(SpurGear, { ...props }),
|
|
3205
3321
|
pads: "none"
|
|
3206
3322
|
});
|
|
3207
|
-
function
|
|
3208
|
-
registry.register(
|
|
3323
|
+
function register18(registry) {
|
|
3324
|
+
registry.register(model18);
|
|
3209
3325
|
}
|
|
3210
3326
|
|
|
3211
3327
|
// lib/models/tslotextrusion/register.tsx
|
|
@@ -3355,14 +3471,14 @@ function TSlotExtrusion({
|
|
|
3355
3471
|
}
|
|
3356
3472
|
|
|
3357
3473
|
// lib/models/tslotextrusion/register.tsx
|
|
3358
|
-
var
|
|
3474
|
+
var model19 = defineModelRenderer({
|
|
3359
3475
|
name: "tslotextrusion",
|
|
3360
3476
|
schema: tSlotExtrusionModelDefinitionSchema,
|
|
3361
3477
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(TSlotExtrusion, { ...props }),
|
|
3362
3478
|
pads: "none"
|
|
3363
3479
|
});
|
|
3364
|
-
function
|
|
3365
|
-
registry.register(
|
|
3480
|
+
function register19(registry) {
|
|
3481
|
+
registry.register(model19);
|
|
3366
3482
|
}
|
|
3367
3483
|
|
|
3368
3484
|
// lib/models/tslotgusset/register.tsx
|
|
@@ -3415,14 +3531,14 @@ function TSlotGusset({ color = "#8995a3", ...props }) {
|
|
|
3415
3531
|
}
|
|
3416
3532
|
|
|
3417
3533
|
// lib/models/tslotgusset/register.tsx
|
|
3418
|
-
var
|
|
3534
|
+
var model20 = defineModelRenderer({
|
|
3419
3535
|
name: "tslotgusset",
|
|
3420
3536
|
schema: tSlotGussetModelDefinitionSchema,
|
|
3421
3537
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(TSlotGusset, { ...props }),
|
|
3422
3538
|
pads: "none"
|
|
3423
3539
|
});
|
|
3424
|
-
function
|
|
3425
|
-
registry.register(
|
|
3540
|
+
function register20(registry) {
|
|
3541
|
+
registry.register(model20);
|
|
3426
3542
|
}
|
|
3427
3543
|
|
|
3428
3544
|
// lib/models/tslotinsidecorner/register.tsx
|
|
@@ -3502,14 +3618,14 @@ function TSlotInsideCorner({
|
|
|
3502
3618
|
}
|
|
3503
3619
|
|
|
3504
3620
|
// lib/models/tslotinsidecorner/register.tsx
|
|
3505
|
-
var
|
|
3621
|
+
var model21 = defineModelRenderer({
|
|
3506
3622
|
name: "tslotinsidecorner",
|
|
3507
3623
|
schema: tSlotInsideCornerModelDefinitionSchema,
|
|
3508
3624
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(TSlotInsideCorner, { ...props }),
|
|
3509
3625
|
pads: "none"
|
|
3510
3626
|
});
|
|
3511
|
-
function
|
|
3512
|
-
registry.register(
|
|
3627
|
+
function register21(registry) {
|
|
3628
|
+
registry.register(model21);
|
|
3513
3629
|
}
|
|
3514
3630
|
|
|
3515
3631
|
// lib/models/wormgear/register.tsx
|
|
@@ -3701,14 +3817,14 @@ function WormGear({ color = "#737e8f", ...props }) {
|
|
|
3701
3817
|
}
|
|
3702
3818
|
|
|
3703
3819
|
// lib/models/wormgear/register.tsx
|
|
3704
|
-
var
|
|
3820
|
+
var model22 = defineModelRenderer({
|
|
3705
3821
|
name: "wormgear",
|
|
3706
3822
|
schema: wormGearModelDefinitionSchema,
|
|
3707
3823
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(WormGear, { ...props }),
|
|
3708
3824
|
pads: "none"
|
|
3709
3825
|
});
|
|
3710
|
-
function
|
|
3711
|
-
registry.register(
|
|
3826
|
+
function register22(registry) {
|
|
3827
|
+
registry.register(model22);
|
|
3712
3828
|
}
|
|
3713
3829
|
|
|
3714
3830
|
// lib/generated/model-renderers.ts
|
|
@@ -3733,6 +3849,8 @@ function registerAllModelRenderers(registry) {
|
|
|
3733
3849
|
register18(registry);
|
|
3734
3850
|
register19(registry);
|
|
3735
3851
|
register20(registry);
|
|
3852
|
+
register21(registry);
|
|
3853
|
+
register22(registry);
|
|
3736
3854
|
}
|
|
3737
3855
|
|
|
3738
3856
|
// lib/default-model-registry.ts
|
|
@@ -11289,10 +11407,10 @@ var SOT143 = ({ footprint = "sot143" }) => {
|
|
|
11289
11407
|
var Footprinter3d = ({ footprint }) => {
|
|
11290
11408
|
const modelFn = mp3.string(footprint.split("_", 1)[0]).params().fn;
|
|
11291
11409
|
if (mp3.getModelNames().includes(modelFn)) {
|
|
11292
|
-
const
|
|
11293
|
-
const renderer = modelRendererRegistry.get(
|
|
11410
|
+
const model23 = mp3.string(footprint).json();
|
|
11411
|
+
const renderer = modelRendererRegistry.get(model23.fn);
|
|
11294
11412
|
if (renderer) {
|
|
11295
|
-
return renderer.render(
|
|
11413
|
+
return renderer.render(model23);
|
|
11296
11414
|
}
|
|
11297
11415
|
}
|
|
11298
11416
|
let normalizedFootprint = footprint;
|
|
@@ -12125,8 +12243,8 @@ function renderNode(node, colorCtx, renderCtx) {
|
|
|
12125
12243
|
}
|
|
12126
12244
|
return (children ?? []).flatMap((c) => renderNode(c, colorCtx, renderCtx));
|
|
12127
12245
|
}
|
|
12128
|
-
function render(root,
|
|
12129
|
-
const geometries = renderNode(root, void 0, { jscad:
|
|
12246
|
+
function render(root, jscad8) {
|
|
12247
|
+
const geometries = renderNode(root, void 0, { jscad: jscad8 });
|
|
12130
12248
|
return {
|
|
12131
12249
|
geometries: geometries.map(
|
|
12132
12250
|
(entry) => entry.material ? { ...entry, geom: { ...entry.geom, material: entry.material } } : entry
|
|
@@ -12218,24 +12336,24 @@ function convertCSGToThreeGeom(csg) {
|
|
|
12218
12336
|
}
|
|
12219
12337
|
|
|
12220
12338
|
// lib/vanilla/index.ts
|
|
12221
|
-
function getJscadModelForFootprint(footprint,
|
|
12339
|
+
function getJscadModelForFootprint(footprint, jscad8) {
|
|
12222
12340
|
const vnode = h(Footprinter3d, { footprint });
|
|
12223
|
-
return render(vnode,
|
|
12341
|
+
return render(vnode, jscad8);
|
|
12224
12342
|
}
|
|
12225
|
-
function getJscadModelForFootprintWithPads(footprint,
|
|
12343
|
+
function getJscadModelForFootprintWithPads(footprint, jscad8) {
|
|
12226
12344
|
const vnode = h(
|
|
12227
12345
|
Fragment,
|
|
12228
12346
|
{},
|
|
12229
12347
|
h(Footprinter3d, { footprint }),
|
|
12230
12348
|
h(ExtrudedPads, { footprint })
|
|
12231
12349
|
);
|
|
12232
|
-
return render(vnode,
|
|
12350
|
+
return render(vnode, jscad8);
|
|
12233
12351
|
}
|
|
12234
|
-
function createJSCADRenderer(
|
|
12352
|
+
function createJSCADRenderer(jscad8) {
|
|
12235
12353
|
function createJSCADRoot(container) {
|
|
12236
12354
|
return {
|
|
12237
12355
|
render(element) {
|
|
12238
|
-
const { geometries } = render(element,
|
|
12356
|
+
const { geometries } = render(element, jscad8);
|
|
12239
12357
|
container.splice(0, container.length, ...geometries);
|
|
12240
12358
|
}
|
|
12241
12359
|
};
|
|
@@ -12245,6 +12363,7 @@ function createJSCADRenderer(jscad6) {
|
|
|
12245
12363
|
export {
|
|
12246
12364
|
ButtonScrew,
|
|
12247
12365
|
CableGrommet,
|
|
12366
|
+
ClampingShaftCollar,
|
|
12248
12367
|
CompressionSpring,
|
|
12249
12368
|
FlangedBushing,
|
|
12250
12369
|
FlatHeadScrew,
|
|
@@ -12259,6 +12378,7 @@ export {
|
|
|
12259
12378
|
NemaMotor,
|
|
12260
12379
|
PanScrew,
|
|
12261
12380
|
PlainBushing,
|
|
12381
|
+
RigidCoupler,
|
|
12262
12382
|
ShaftCollar,
|
|
12263
12383
|
SheetMetal,
|
|
12264
12384
|
SpurGear,
|
|
@@ -12271,6 +12391,8 @@ export {
|
|
|
12271
12391
|
createButtonScrewMesh,
|
|
12272
12392
|
createCableGrommetGeom,
|
|
12273
12393
|
createCableGrommetMesh,
|
|
12394
|
+
createClampingShaftCollarGeom,
|
|
12395
|
+
createClampingShaftCollarMesh,
|
|
12274
12396
|
createCompressionSpringGeom,
|
|
12275
12397
|
createCompressionSpringMesh,
|
|
12276
12398
|
createFlangedBushingGeom,
|
|
@@ -12290,6 +12412,8 @@ export {
|
|
|
12290
12412
|
createPanScrewMesh,
|
|
12291
12413
|
createPlainBushingGeom,
|
|
12292
12414
|
createPlainBushingMesh,
|
|
12415
|
+
createRigidCouplerGeom,
|
|
12416
|
+
createRigidCouplerMesh,
|
|
12293
12417
|
createShaftCollarGeom,
|
|
12294
12418
|
createShaftCollarMesh,
|
|
12295
12419
|
createSheetMetalGeom,
|