jscad-electronics 0.0.198 → 0.0.200
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 +40 -2
- package/dist/index.js +1240 -958
- package/dist/index.js.map +1 -1
- package/dist/vanilla.d.ts +40 -2
- package/dist/vanilla.js +332 -60
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.js
CHANGED
|
@@ -179,28 +179,28 @@ var FootprintPlatedHole = ({
|
|
|
179
179
|
throw new Error("Shape not supported: " + hole.shape);
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
-
// lib/models/
|
|
183
|
-
import {
|
|
182
|
+
// lib/models/buttonscrew/register.tsx
|
|
183
|
+
import { buttonScrewModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
184
184
|
|
|
185
185
|
// lib/model-registry.ts
|
|
186
|
-
function defineModelRenderer(
|
|
187
|
-
return
|
|
186
|
+
function defineModelRenderer(model15) {
|
|
187
|
+
return model15;
|
|
188
188
|
}
|
|
189
189
|
var ModelRendererRegistry = class {
|
|
190
190
|
models = /* @__PURE__ */ new Map();
|
|
191
|
-
register(
|
|
192
|
-
if (typeof
|
|
191
|
+
register(model15) {
|
|
192
|
+
if (typeof model15.name !== "string" || !/^[a-z]+$/.test(model15.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(model15.name)) {
|
|
198
|
+
throw new Error(`Model renderer "${model15.name}" is already registered`);
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
200
|
+
if (model15.pads !== "none" && model15.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 } = model15;
|
|
204
204
|
this.models.set(name, {
|
|
205
205
|
name,
|
|
206
206
|
schema,
|
|
@@ -226,6 +226,118 @@ var ModelRendererRegistry = class {
|
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
|
|
229
|
+
// lib/models/buttonscrew/mesh.ts
|
|
230
|
+
import {
|
|
231
|
+
buttonScrewModelPropsSchema,
|
|
232
|
+
getButtonScrewDimensions
|
|
233
|
+
} from "@tscircuit/modelprinter";
|
|
234
|
+
function resolution(options) {
|
|
235
|
+
const radial = options.radialSegments ?? 96;
|
|
236
|
+
const axial = options.segmentsPerPitch ?? 32;
|
|
237
|
+
if (!Number.isInteger(radial) || radial < 24 || radial > 192 || radial % 12 !== 0 || !Number.isInteger(axial) || axial < 8 || axial > 64)
|
|
238
|
+
throw new Error(
|
|
239
|
+
"Mesh resolution limit: radial segments must be a multiple of 12 in [24,192], pitch segments an integer in [8,64]"
|
|
240
|
+
);
|
|
241
|
+
return { radial, axial };
|
|
242
|
+
}
|
|
243
|
+
function surface(segments) {
|
|
244
|
+
const positions = [], indices = [];
|
|
245
|
+
const ring = (z, radius) => {
|
|
246
|
+
const start = positions.length / 3;
|
|
247
|
+
for (let i = 0; i < segments; i++) {
|
|
248
|
+
const angle = i * 2 * Math.PI / segments;
|
|
249
|
+
const r = radius(angle);
|
|
250
|
+
positions.push(r * Math.cos(angle), r * Math.sin(angle), z);
|
|
251
|
+
}
|
|
252
|
+
return start;
|
|
253
|
+
};
|
|
254
|
+
const connect = (a, b) => {
|
|
255
|
+
for (let i = 0; i < segments; i++) {
|
|
256
|
+
const n = (i + 1) % segments;
|
|
257
|
+
indices.push(a + i, a + n, b + n, a + i, b + n, b + i);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const cap = (start, z, up) => {
|
|
261
|
+
const center = positions.length / 3;
|
|
262
|
+
positions.push(0, 0, z);
|
|
263
|
+
for (let i = 0; i < segments; i++) {
|
|
264
|
+
const n = (i + 1) % segments;
|
|
265
|
+
indices.push(center, start + (up ? i : n), start + (up ? n : i));
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
return { positions, indices, ring, connect, cap };
|
|
269
|
+
}
|
|
270
|
+
function hexRadius(angle, acrossFlats) {
|
|
271
|
+
const period = Math.PI / 3;
|
|
272
|
+
const distance2 = ((angle - Math.PI / 2 + period / 2) % period + period) % period - period / 2;
|
|
273
|
+
return acrossFlats / 2 / Math.cos(distance2);
|
|
274
|
+
}
|
|
275
|
+
function threadDistance(z, angle, pitch, hand = 1) {
|
|
276
|
+
const phase = ((z / pitch - hand * angle / (2 * Math.PI)) % 1 + 1) % 1;
|
|
277
|
+
return Math.min(phase, 1 - phase);
|
|
278
|
+
}
|
|
279
|
+
function createButtonScrewMesh(input, options = {}) {
|
|
280
|
+
const props = buttonScrewModelPropsSchema.parse(input);
|
|
281
|
+
const d = getButtonScrewDimensions(input);
|
|
282
|
+
const { radial, axial } = resolution(options);
|
|
283
|
+
const steps = Math.max(2, Math.ceil(props.length / d.threadPitch * axial));
|
|
284
|
+
if (steps > 24e3 || !Number.isFinite(steps))
|
|
285
|
+
throw new Error("Mesh resolution limit: too many thread turns");
|
|
286
|
+
const m = surface(radial);
|
|
287
|
+
const radius = d.diameter / 2;
|
|
288
|
+
const depth = (d.diameter - d.threadMinorDiameter) / 2;
|
|
289
|
+
const fillet = d.underHeadRadius;
|
|
290
|
+
const levels = new Set(
|
|
291
|
+
props.showThreads ? Array.from(
|
|
292
|
+
{ length: steps + 1 },
|
|
293
|
+
(_, i) => -props.length + props.length * i / steps
|
|
294
|
+
) : [-props.length, 0]
|
|
295
|
+
);
|
|
296
|
+
levels.add(-props.length + d.tipChamfer);
|
|
297
|
+
levels.add(-d.threadPitch);
|
|
298
|
+
for (let i = 0; i <= 16; i++)
|
|
299
|
+
levels.add(-fillet + fillet * Math.sin(i * Math.PI / 32));
|
|
300
|
+
let previous = -1;
|
|
301
|
+
const shaftLevels = [...levels].sort((a, b) => a - b).filter((z, index, sorted) => index === 0 || z - sorted[index - 1] > 1e-10);
|
|
302
|
+
for (const z of shaftLevels) {
|
|
303
|
+
const current = m.ring(z, (angle) => {
|
|
304
|
+
const envelope = z >= -fillet ? radius + fillet - Math.sqrt(Math.max(0, fillet ** 2 - (z + fillet) ** 2)) : radius;
|
|
305
|
+
const groove = Math.min(
|
|
306
|
+
depth,
|
|
307
|
+
Math.max(
|
|
308
|
+
0,
|
|
309
|
+
(threadDistance(z + props.length, angle, d.threadPitch) - 1 / 16) * d.threadPitch * Math.sqrt(3)
|
|
310
|
+
)
|
|
311
|
+
);
|
|
312
|
+
const threaded = envelope - (props.showThreads ? groove * Math.min(1, -z / d.threadPitch) : 0);
|
|
313
|
+
const tip = z + props.length < d.tipChamfer ? radius - (d.tipChamfer - (z + props.length)) : Infinity;
|
|
314
|
+
return Math.min(threaded, tip);
|
|
315
|
+
});
|
|
316
|
+
if (previous < 0) m.cap(current, z, false);
|
|
317
|
+
else m.connect(previous, current);
|
|
318
|
+
previous = current;
|
|
319
|
+
}
|
|
320
|
+
const add = (z, radiusAt) => {
|
|
321
|
+
const current = m.ring(z, radiusAt);
|
|
322
|
+
m.connect(previous, current);
|
|
323
|
+
previous = current;
|
|
324
|
+
};
|
|
325
|
+
add(0, () => d.headDiameter / 2);
|
|
326
|
+
for (let i = 1; i <= 24; i++) {
|
|
327
|
+
const z = d.headHeight * i / 24;
|
|
328
|
+
add(
|
|
329
|
+
z,
|
|
330
|
+
() => d.crownArcCenterR + Math.sqrt(
|
|
331
|
+
Math.max(0, d.crownRadius ** 2 - (z - d.crownArcCenterZ) ** 2)
|
|
332
|
+
)
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
add(d.topZ, (angle) => hexRadius(angle, d.socketWidth));
|
|
336
|
+
add(d.topZ - d.socketDepth, (angle) => hexRadius(angle, d.socketWidth));
|
|
337
|
+
m.cap(previous, d.topZ - d.socketDepth, true);
|
|
338
|
+
return { positions: m.positions, indices: m.indices };
|
|
339
|
+
}
|
|
340
|
+
|
|
229
341
|
// lib/mechanical/indexedMeshToGeom3.ts
|
|
230
342
|
import jscad from "@jscad/modeling";
|
|
231
343
|
function indexedMeshToGeom3(mesh) {
|
|
@@ -241,6 +353,28 @@ function indexedMeshToGeom3(mesh) {
|
|
|
241
353
|
return jscad.geometries.geom3.fromPoints(polygons);
|
|
242
354
|
}
|
|
243
355
|
|
|
356
|
+
// lib/models/buttonscrew/ButtonScrew.tsx
|
|
357
|
+
function createButtonScrewGeom(input, resolution3) {
|
|
358
|
+
return indexedMeshToGeom3(createButtonScrewMesh(input, resolution3));
|
|
359
|
+
}
|
|
360
|
+
function ButtonScrew({ color = "#737e8f", ...props }) {
|
|
361
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createButtonScrewGeom(props) }) });
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// lib/models/buttonscrew/register.tsx
|
|
365
|
+
var model = defineModelRenderer({
|
|
366
|
+
name: "buttonscrew",
|
|
367
|
+
schema: buttonScrewModelDefinitionSchema,
|
|
368
|
+
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(ButtonScrew, { ...props }),
|
|
369
|
+
pads: "none"
|
|
370
|
+
});
|
|
371
|
+
function register(registry) {
|
|
372
|
+
registry.register(model);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// lib/models/flangedbushing/register.tsx
|
|
376
|
+
import { flangedBushingModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
377
|
+
|
|
244
378
|
// lib/models/flangedbushing/mesh.ts
|
|
245
379
|
import {
|
|
246
380
|
flangedBushingModelPropsSchema,
|
|
@@ -291,14 +425,14 @@ function FlangedBushing({
|
|
|
291
425
|
}
|
|
292
426
|
|
|
293
427
|
// lib/models/flangedbushing/register.tsx
|
|
294
|
-
var
|
|
428
|
+
var model2 = defineModelRenderer({
|
|
295
429
|
name: "flangedbushing",
|
|
296
430
|
schema: flangedBushingModelDefinitionSchema,
|
|
297
431
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(FlangedBushing, { ...props }),
|
|
298
432
|
pads: "none"
|
|
299
433
|
});
|
|
300
|
-
function
|
|
301
|
-
registry.register(
|
|
434
|
+
function register2(registry) {
|
|
435
|
+
registry.register(model2);
|
|
302
436
|
}
|
|
303
437
|
|
|
304
438
|
// lib/models/flatheadscrew/register.tsx
|
|
@@ -407,14 +541,14 @@ function createFlatHeadScrewMesh(input, options = {}) {
|
|
|
407
541
|
filletCenterZ + p.underHeadRadius * Math.sin(angle)
|
|
408
542
|
);
|
|
409
543
|
}
|
|
410
|
-
const
|
|
544
|
+
const hexRadius3 = (theta) => p.socketAcrossFlats / 2 / Math.max(
|
|
411
545
|
Math.abs(Math.sin(theta)),
|
|
412
546
|
Math.abs(Math.sin(theta + 2 * Math.PI / 3)),
|
|
413
547
|
Math.abs(Math.sin(theta + 4 * Math.PI / 3))
|
|
414
548
|
);
|
|
415
549
|
add(() => p.headDiameter / 2, 0);
|
|
416
|
-
add(
|
|
417
|
-
add(
|
|
550
|
+
add(hexRadius3, 0);
|
|
551
|
+
add(hexRadius3, -p.socketDepth);
|
|
418
552
|
cap(previous, -p.socketDepth, true);
|
|
419
553
|
return { positions, indices };
|
|
420
554
|
}
|
|
@@ -431,14 +565,14 @@ function FlatHeadScrew({
|
|
|
431
565
|
}
|
|
432
566
|
|
|
433
567
|
// lib/models/flatheadscrew/register.tsx
|
|
434
|
-
var
|
|
568
|
+
var model3 = defineModelRenderer({
|
|
435
569
|
name: "flatheadscrew",
|
|
436
570
|
schema: flatHeadScrewModelDefinitionSchema,
|
|
437
571
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(FlatHeadScrew, { ...props }),
|
|
438
572
|
pads: "none"
|
|
439
573
|
});
|
|
440
|
-
function
|
|
441
|
-
registry.register(
|
|
574
|
+
function register3(registry) {
|
|
575
|
+
registry.register(model3);
|
|
442
576
|
}
|
|
443
577
|
|
|
444
578
|
// lib/models/flexscreen/register.tsx
|
|
@@ -1116,14 +1250,14 @@ var FlexScreen = (props) => {
|
|
|
1116
1250
|
};
|
|
1117
1251
|
|
|
1118
1252
|
// lib/models/flexscreen/register.tsx
|
|
1119
|
-
var
|
|
1253
|
+
var model4 = defineModelRenderer({
|
|
1120
1254
|
name: "flexscreen",
|
|
1121
1255
|
schema: flexScreenModelDefinitionSchema,
|
|
1122
1256
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(FlexScreen, { ...props }),
|
|
1123
1257
|
pads: "footprinter"
|
|
1124
1258
|
});
|
|
1125
|
-
function
|
|
1126
|
-
registry.register(
|
|
1259
|
+
function register4(registry) {
|
|
1260
|
+
registry.register(model4);
|
|
1127
1261
|
}
|
|
1128
1262
|
|
|
1129
1263
|
// lib/models/helicalgear/register.tsx
|
|
@@ -1329,14 +1463,14 @@ function HelicalGear({ color = "#737e8f", ...props }) {
|
|
|
1329
1463
|
}
|
|
1330
1464
|
|
|
1331
1465
|
// lib/models/helicalgear/register.tsx
|
|
1332
|
-
var
|
|
1466
|
+
var model5 = defineModelRenderer({
|
|
1333
1467
|
name: "helicalgear",
|
|
1334
1468
|
schema: helicalGearModelDefinitionSchema,
|
|
1335
1469
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HelicalGear, { ...props }),
|
|
1336
1470
|
pads: "none"
|
|
1337
1471
|
});
|
|
1338
|
-
function
|
|
1339
|
-
registry.register(
|
|
1472
|
+
function register5(registry) {
|
|
1473
|
+
registry.register(model5);
|
|
1340
1474
|
}
|
|
1341
1475
|
|
|
1342
1476
|
// lib/models/hexbolt/register.tsx
|
|
@@ -1445,20 +1579,20 @@ function createHexBoltMesh(input, options = {}) {
|
|
|
1445
1579
|
filletCenterZ + p.underHeadRadius * Math.sin(angle)
|
|
1446
1580
|
);
|
|
1447
1581
|
}
|
|
1448
|
-
const
|
|
1582
|
+
const hexRadius3 = (theta) => p.headAcrossFlats / 2 / Math.max(
|
|
1449
1583
|
Math.abs(Math.sin(theta)),
|
|
1450
1584
|
Math.abs(Math.sin(theta + 2 * Math.PI / 3)),
|
|
1451
1585
|
Math.abs(Math.sin(theta + 4 * Math.PI / 3))
|
|
1452
1586
|
);
|
|
1453
|
-
add(
|
|
1587
|
+
add(hexRadius3, 0);
|
|
1454
1588
|
const slope = Math.tan(p.headChamferAngle * Math.PI / 180);
|
|
1455
1589
|
const start = p.headHeight - (p.headCornerDiameter - p.headChamferDiameter) / 2 * slope;
|
|
1456
|
-
add(
|
|
1590
|
+
add(hexRadius3, start);
|
|
1457
1591
|
for (let i = 1; i <= 12; i++) {
|
|
1458
1592
|
const z = start + (p.headHeight - start) * i / 12;
|
|
1459
1593
|
add(
|
|
1460
1594
|
(theta) => Math.min(
|
|
1461
|
-
|
|
1595
|
+
hexRadius3(theta),
|
|
1462
1596
|
p.headChamferDiameter / 2 + (p.headHeight - z) / slope
|
|
1463
1597
|
),
|
|
1464
1598
|
z
|
|
@@ -1477,14 +1611,144 @@ function HexBolt({ color = "#737e8f", ...props }) {
|
|
|
1477
1611
|
}
|
|
1478
1612
|
|
|
1479
1613
|
// lib/models/hexbolt/register.tsx
|
|
1480
|
-
var
|
|
1614
|
+
var model6 = defineModelRenderer({
|
|
1481
1615
|
name: "hexbolt",
|
|
1482
1616
|
schema: hexBoltModelDefinitionSchema,
|
|
1483
1617
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HexBolt, { ...props }),
|
|
1484
1618
|
pads: "none"
|
|
1485
1619
|
});
|
|
1486
|
-
function
|
|
1487
|
-
registry.register(
|
|
1620
|
+
function register6(registry) {
|
|
1621
|
+
registry.register(model6);
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
// lib/models/hexnut/register.tsx
|
|
1625
|
+
import { hexNutModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
1626
|
+
|
|
1627
|
+
// lib/models/hexnut/mesh.ts
|
|
1628
|
+
import {
|
|
1629
|
+
hexNutModelPropsSchema,
|
|
1630
|
+
getHexNutDimensions
|
|
1631
|
+
} from "@tscircuit/modelprinter";
|
|
1632
|
+
function resolution2(options) {
|
|
1633
|
+
const radial = options.radialSegments ?? 96;
|
|
1634
|
+
const axial = options.segmentsPerPitch ?? 32;
|
|
1635
|
+
if (!Number.isInteger(radial) || radial < 24 || radial > 192 || radial % 12 !== 0 || !Number.isInteger(axial) || axial < 8 || axial > 64)
|
|
1636
|
+
throw new Error(
|
|
1637
|
+
"Mesh resolution limit: radial segments must be a multiple of 12 in [24,192], pitch segments an integer in [8,64]"
|
|
1638
|
+
);
|
|
1639
|
+
return { radial, axial };
|
|
1640
|
+
}
|
|
1641
|
+
function surface2(segments) {
|
|
1642
|
+
const positions = [], indices = [];
|
|
1643
|
+
const ring = (z, radius) => {
|
|
1644
|
+
const start = positions.length / 3;
|
|
1645
|
+
for (let i = 0; i < segments; i++) {
|
|
1646
|
+
const angle = i * 2 * Math.PI / segments;
|
|
1647
|
+
const r = radius(angle);
|
|
1648
|
+
positions.push(r * Math.cos(angle), r * Math.sin(angle), z);
|
|
1649
|
+
}
|
|
1650
|
+
return start;
|
|
1651
|
+
};
|
|
1652
|
+
const connect = (a, b) => {
|
|
1653
|
+
for (let i = 0; i < segments; i++) {
|
|
1654
|
+
const n = (i + 1) % segments;
|
|
1655
|
+
indices.push(a + i, a + n, b + n, a + i, b + n, b + i);
|
|
1656
|
+
}
|
|
1657
|
+
};
|
|
1658
|
+
const cap = (start, z, up) => {
|
|
1659
|
+
const center = positions.length / 3;
|
|
1660
|
+
positions.push(0, 0, z);
|
|
1661
|
+
for (let i = 0; i < segments; i++) {
|
|
1662
|
+
const n = (i + 1) % segments;
|
|
1663
|
+
indices.push(center, start + (up ? i : n), start + (up ? n : i));
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
return { positions, indices, ring, connect, cap };
|
|
1667
|
+
}
|
|
1668
|
+
function hexRadius2(angle, acrossFlats) {
|
|
1669
|
+
const period = Math.PI / 3;
|
|
1670
|
+
const distance2 = ((angle - Math.PI / 2 + period / 2) % period + period) % period - period / 2;
|
|
1671
|
+
return acrossFlats / 2 / Math.cos(distance2);
|
|
1672
|
+
}
|
|
1673
|
+
function threadDistance2(z, angle, pitch, hand = 1) {
|
|
1674
|
+
const phase = ((z / pitch - hand * angle / (2 * Math.PI)) % 1 + 1) % 1;
|
|
1675
|
+
return Math.min(phase, 1 - phase);
|
|
1676
|
+
}
|
|
1677
|
+
function createHexNutMesh(input, options = {}) {
|
|
1678
|
+
const props = hexNutModelPropsSchema.parse(input);
|
|
1679
|
+
const d = getHexNutDimensions(input);
|
|
1680
|
+
const { radial, axial } = resolution2(options);
|
|
1681
|
+
const steps = Math.max(2, Math.ceil(d.height / d.threadPitch * axial));
|
|
1682
|
+
if (steps > 24e3 || !Number.isFinite(steps))
|
|
1683
|
+
throw new Error("Mesh resolution limit: too many thread turns");
|
|
1684
|
+
const m = surface2(radial);
|
|
1685
|
+
const outer = (z, angle) => Math.min(
|
|
1686
|
+
hexRadius2(angle, d.acrossFlats),
|
|
1687
|
+
d.faceDiameter / 2 + Math.min(z, d.height - z) * Math.sqrt(3)
|
|
1688
|
+
);
|
|
1689
|
+
const outerLevels = [
|
|
1690
|
+
0,
|
|
1691
|
+
d.outerChamferDepth,
|
|
1692
|
+
d.height - d.outerChamferDepth,
|
|
1693
|
+
d.height
|
|
1694
|
+
];
|
|
1695
|
+
for (let index = 0; index < radial; index++) {
|
|
1696
|
+
const angle = index * 2 * Math.PI / radial;
|
|
1697
|
+
const height10 = (hexRadius2(angle, d.acrossFlats) - d.faceDiameter / 2) / Math.sqrt(3);
|
|
1698
|
+
if (height10 > 1e-9 && height10 < d.outerChamferDepth - 1e-9)
|
|
1699
|
+
outerLevels.push(height10, d.height - height10);
|
|
1700
|
+
}
|
|
1701
|
+
const outerZ = outerLevels.sort((a, b) => a - b).filter((z, index, sorted) => index === 0 || z - sorted[index - 1] > 1e-10);
|
|
1702
|
+
const first = m.ring(0, (angle) => outer(0, angle));
|
|
1703
|
+
let previous = first;
|
|
1704
|
+
for (const z of outerZ.slice(1)) {
|
|
1705
|
+
const current = m.ring(z, (angle) => outer(z, angle));
|
|
1706
|
+
m.connect(previous, current);
|
|
1707
|
+
previous = current;
|
|
1708
|
+
}
|
|
1709
|
+
const levels = new Set(
|
|
1710
|
+
props.showThreads ? Array.from({ length: steps + 1 }, (_, i) => d.height * i / steps) : [0, d.height]
|
|
1711
|
+
);
|
|
1712
|
+
levels.add(d.boreChamferDepth);
|
|
1713
|
+
levels.add(d.height - d.boreChamferDepth);
|
|
1714
|
+
const minor = d.boreMinorDiameter / 2;
|
|
1715
|
+
const depth = (d.diameter - d.boreMinorDiameter) / 2;
|
|
1716
|
+
for (const z of [...levels].sort((a, b) => b - a)) {
|
|
1717
|
+
const current = m.ring(z, (angle) => {
|
|
1718
|
+
const groove = Math.min(
|
|
1719
|
+
depth,
|
|
1720
|
+
Math.max(
|
|
1721
|
+
0,
|
|
1722
|
+
(threadDistance2(z, angle, d.threadPitch) - 1 / 8) * d.threadPitch * Math.sqrt(3)
|
|
1723
|
+
)
|
|
1724
|
+
);
|
|
1725
|
+
const threaded = minor + (props.showThreads ? groove : 0);
|
|
1726
|
+
return Math.max(threaded, d.mouthDiameter / 2 - Math.min(z, d.height - z));
|
|
1727
|
+
});
|
|
1728
|
+
m.connect(previous, current);
|
|
1729
|
+
previous = current;
|
|
1730
|
+
}
|
|
1731
|
+
m.connect(previous, first);
|
|
1732
|
+
return { positions: m.positions, indices: m.indices };
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
// lib/models/hexnut/HexNut.tsx
|
|
1736
|
+
function createHexNutGeom(input, resolution3) {
|
|
1737
|
+
return indexedMeshToGeom3(createHexNutMesh(input, resolution3));
|
|
1738
|
+
}
|
|
1739
|
+
function HexNut({ color = "#737e8f", ...props }) {
|
|
1740
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createHexNutGeom(props) }) });
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
// lib/models/hexnut/register.tsx
|
|
1744
|
+
var model7 = defineModelRenderer({
|
|
1745
|
+
name: "hexnut",
|
|
1746
|
+
schema: hexNutModelDefinitionSchema,
|
|
1747
|
+
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HexNut, { ...props }),
|
|
1748
|
+
pads: "none"
|
|
1749
|
+
});
|
|
1750
|
+
function register7(registry) {
|
|
1751
|
+
registry.register(model7);
|
|
1488
1752
|
}
|
|
1489
1753
|
|
|
1490
1754
|
// lib/models/hexsocketbolt/register.tsx
|
|
@@ -1576,10 +1840,10 @@ var createHexSocketBoltMesh = (input) => {
|
|
|
1576
1840
|
addRing(bevel, () => headDiameter / 2);
|
|
1577
1841
|
addRing(headHeight - bevel, () => headDiameter / 2);
|
|
1578
1842
|
addRing(headHeight, () => headDiameter / 2 - bevel);
|
|
1579
|
-
const
|
|
1580
|
-
addRing(headHeight, (angle) =>
|
|
1581
|
-
addRing(headHeight - bevel / 2, (angle) =>
|
|
1582
|
-
addRing(headHeight - socketDepth, (angle) =>
|
|
1843
|
+
const hexRadius3 = (angle, acrossFlats) => acrossFlats / 2 / Math.cos((angle + Math.PI / 6) % (Math.PI / 3) - Math.PI / 6);
|
|
1844
|
+
addRing(headHeight, (angle) => hexRadius3(angle, socketWidth + bevel));
|
|
1845
|
+
addRing(headHeight - bevel / 2, (angle) => hexRadius3(angle, socketWidth));
|
|
1846
|
+
addRing(headHeight - socketDepth, (angle) => hexRadius3(angle, socketWidth));
|
|
1583
1847
|
cap(previous, headHeight - socketDepth, true);
|
|
1584
1848
|
return { positions, indices };
|
|
1585
1849
|
};
|
|
@@ -1596,14 +1860,14 @@ function HexSocketBolt({
|
|
|
1596
1860
|
}
|
|
1597
1861
|
|
|
1598
1862
|
// lib/models/hexsocketbolt/register.tsx
|
|
1599
|
-
var
|
|
1863
|
+
var model8 = defineModelRenderer({
|
|
1600
1864
|
name: "hexsocketbolt",
|
|
1601
1865
|
schema: hexSocketBoltModelDefinitionSchema,
|
|
1602
1866
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(HexSocketBolt, { ...props }),
|
|
1603
1867
|
pads: "none"
|
|
1604
1868
|
});
|
|
1605
|
-
function
|
|
1606
|
-
registry.register(
|
|
1869
|
+
function register8(registry) {
|
|
1870
|
+
registry.register(model8);
|
|
1607
1871
|
}
|
|
1608
1872
|
|
|
1609
1873
|
// lib/models/nema/register.tsx
|
|
@@ -1872,14 +2136,14 @@ var NEMA17 = (props) => /* @__PURE__ */ jsx(NemaMotor, { ...props, nemaSize: 17
|
|
|
1872
2136
|
var NEMA23 = (props) => /* @__PURE__ */ jsx(NemaMotor, { ...props, nemaSize: 23 });
|
|
1873
2137
|
|
|
1874
2138
|
// lib/models/nema/register.tsx
|
|
1875
|
-
var
|
|
2139
|
+
var model9 = defineModelRenderer({
|
|
1876
2140
|
name: "nema",
|
|
1877
2141
|
schema: nemaMotorModelDefinitionSchema,
|
|
1878
2142
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(NemaMotor, { ...props }),
|
|
1879
2143
|
pads: "none"
|
|
1880
2144
|
});
|
|
1881
|
-
function
|
|
1882
|
-
registry.register(
|
|
2145
|
+
function register9(registry) {
|
|
2146
|
+
registry.register(model9);
|
|
1883
2147
|
}
|
|
1884
2148
|
|
|
1885
2149
|
// lib/models/panscrew/register.tsx
|
|
@@ -2091,14 +2355,14 @@ function PanScrew({ color = "#737e8f", ...props }) {
|
|
|
2091
2355
|
}
|
|
2092
2356
|
|
|
2093
2357
|
// lib/models/panscrew/register.tsx
|
|
2094
|
-
var
|
|
2358
|
+
var model10 = defineModelRenderer({
|
|
2095
2359
|
name: "panscrew",
|
|
2096
2360
|
schema: panScrewModelDefinitionSchema,
|
|
2097
2361
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(PanScrew, { ...props }),
|
|
2098
2362
|
pads: "none"
|
|
2099
2363
|
});
|
|
2100
|
-
function
|
|
2101
|
-
registry.register(
|
|
2364
|
+
function register10(registry) {
|
|
2365
|
+
registry.register(model10);
|
|
2102
2366
|
}
|
|
2103
2367
|
|
|
2104
2368
|
// lib/models/plainbushing/register.tsx
|
|
@@ -2161,14 +2425,14 @@ function PlainBushing({
|
|
|
2161
2425
|
}
|
|
2162
2426
|
|
|
2163
2427
|
// lib/models/plainbushing/register.tsx
|
|
2164
|
-
var
|
|
2428
|
+
var model11 = defineModelRenderer({
|
|
2165
2429
|
name: "plainbushing",
|
|
2166
2430
|
schema: plainBushingModelDefinitionSchema,
|
|
2167
2431
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(PlainBushing, { ...props }),
|
|
2168
2432
|
pads: "none"
|
|
2169
2433
|
});
|
|
2170
|
-
function
|
|
2171
|
-
registry.register(
|
|
2434
|
+
function register11(registry) {
|
|
2435
|
+
registry.register(model11);
|
|
2172
2436
|
}
|
|
2173
2437
|
|
|
2174
2438
|
// lib/models/sheetmetal/register.tsx
|
|
@@ -2328,14 +2592,14 @@ function SheetMetal({ color = "#737e8f", ...props }) {
|
|
|
2328
2592
|
}
|
|
2329
2593
|
|
|
2330
2594
|
// lib/models/sheetmetal/register.tsx
|
|
2331
|
-
var
|
|
2595
|
+
var model12 = defineModelRenderer({
|
|
2332
2596
|
name: "sheetmetal",
|
|
2333
2597
|
schema: sheetMetalModelDefinitionSchema,
|
|
2334
2598
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(SheetMetal, { ...props }),
|
|
2335
2599
|
pads: "none"
|
|
2336
2600
|
});
|
|
2337
|
-
function
|
|
2338
|
-
registry.register(
|
|
2601
|
+
function register12(registry) {
|
|
2602
|
+
registry.register(model12);
|
|
2339
2603
|
}
|
|
2340
2604
|
|
|
2341
2605
|
// lib/models/spurgear/register.tsx
|
|
@@ -2350,14 +2614,14 @@ function SpurGear({ color = "#737e8f", ...props }) {
|
|
|
2350
2614
|
}
|
|
2351
2615
|
|
|
2352
2616
|
// lib/models/spurgear/register.tsx
|
|
2353
|
-
var
|
|
2617
|
+
var model13 = defineModelRenderer({
|
|
2354
2618
|
name: "spurgear",
|
|
2355
2619
|
schema: spurGearModelDefinitionSchema,
|
|
2356
2620
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(SpurGear, { ...props }),
|
|
2357
2621
|
pads: "none"
|
|
2358
2622
|
});
|
|
2359
|
-
function
|
|
2360
|
-
registry.register(
|
|
2623
|
+
function register13(registry) {
|
|
2624
|
+
registry.register(model13);
|
|
2361
2625
|
}
|
|
2362
2626
|
|
|
2363
2627
|
// lib/models/wormgear/register.tsx
|
|
@@ -2549,14 +2813,14 @@ function WormGear({ color = "#737e8f", ...props }) {
|
|
|
2549
2813
|
}
|
|
2550
2814
|
|
|
2551
2815
|
// lib/models/wormgear/register.tsx
|
|
2552
|
-
var
|
|
2816
|
+
var model14 = defineModelRenderer({
|
|
2553
2817
|
name: "wormgear",
|
|
2554
2818
|
schema: wormGearModelDefinitionSchema,
|
|
2555
2819
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(WormGear, { ...props }),
|
|
2556
2820
|
pads: "none"
|
|
2557
2821
|
});
|
|
2558
|
-
function
|
|
2559
|
-
registry.register(
|
|
2822
|
+
function register14(registry) {
|
|
2823
|
+
registry.register(model14);
|
|
2560
2824
|
}
|
|
2561
2825
|
|
|
2562
2826
|
// lib/generated/model-renderers.ts
|
|
@@ -2573,6 +2837,8 @@ function registerAllModelRenderers(registry) {
|
|
|
2573
2837
|
register10(registry);
|
|
2574
2838
|
register11(registry);
|
|
2575
2839
|
register12(registry);
|
|
2840
|
+
register13(registry);
|
|
2841
|
+
register14(registry);
|
|
2576
2842
|
}
|
|
2577
2843
|
|
|
2578
2844
|
// lib/default-model-registry.ts
|
|
@@ -10129,10 +10395,10 @@ var SOT143 = ({ footprint = "sot143" }) => {
|
|
|
10129
10395
|
var Footprinter3d = ({ footprint }) => {
|
|
10130
10396
|
const modelFn = mp3.string(footprint.split("_", 1)[0]).params().fn;
|
|
10131
10397
|
if (mp3.getModelNames().includes(modelFn)) {
|
|
10132
|
-
const
|
|
10133
|
-
const renderer = modelRendererRegistry.get(
|
|
10398
|
+
const model15 = mp3.string(footprint).json();
|
|
10399
|
+
const renderer = modelRendererRegistry.get(model15.fn);
|
|
10134
10400
|
if (renderer) {
|
|
10135
|
-
return renderer.render(
|
|
10401
|
+
return renderer.render(model15);
|
|
10136
10402
|
}
|
|
10137
10403
|
}
|
|
10138
10404
|
let normalizedFootprint = footprint;
|
|
@@ -11083,11 +11349,13 @@ function createJSCADRenderer(jscad4) {
|
|
|
11083
11349
|
return { createJSCADRoot };
|
|
11084
11350
|
}
|
|
11085
11351
|
export {
|
|
11352
|
+
ButtonScrew,
|
|
11086
11353
|
FlangedBushing,
|
|
11087
11354
|
FlatHeadScrew,
|
|
11088
11355
|
Fragment,
|
|
11089
11356
|
HelicalGear,
|
|
11090
11357
|
HexBolt,
|
|
11358
|
+
HexNut,
|
|
11091
11359
|
HexSocketBolt,
|
|
11092
11360
|
NEMA17,
|
|
11093
11361
|
NEMA23,
|
|
@@ -11099,6 +11367,8 @@ export {
|
|
|
11099
11367
|
SpurGear,
|
|
11100
11368
|
WormGear,
|
|
11101
11369
|
convertCSGToThreeGeom,
|
|
11370
|
+
createButtonScrewGeom,
|
|
11371
|
+
createButtonScrewMesh,
|
|
11102
11372
|
createFlangedBushingGeom,
|
|
11103
11373
|
createFlangedBushingMesh,
|
|
11104
11374
|
createFlatHeadScrewGeom,
|
|
@@ -11107,6 +11377,8 @@ export {
|
|
|
11107
11377
|
createHelicalGearMesh,
|
|
11108
11378
|
createHexBoltGeom,
|
|
11109
11379
|
createHexBoltMesh,
|
|
11380
|
+
createHexNutGeom,
|
|
11381
|
+
createHexNutMesh,
|
|
11110
11382
|
createHexSocketBoltGeom,
|
|
11111
11383
|
createHexSocketBoltMesh,
|
|
11112
11384
|
createJSCADRenderer,
|