jscad-electronics 0.0.187 → 0.0.188
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 +36 -2
- package/dist/index.js +1111 -890
- package/dist/index.js.map +1 -1
- package/dist/vanilla.d.ts +19 -2
- package/dist/vanilla.js +260 -50
- package/dist/vanilla.js.map +1 -1
- package/package.json +2 -2
package/dist/vanilla.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BufferGeometry } from 'three';
|
|
2
2
|
import * as jscadModeling from '@jscad/modeling';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
|
-
import { NemaMotorModelPropsInput, HexSocketBoltModelPropsInput, SheetMetalModelPropsInput, SpurGearModelPropsInput, HelicalGearModelPropsInput, WormGearModelPropsInput } from '@tscircuit/modelprinter';
|
|
4
|
+
import { NemaMotorModelPropsInput, HexSocketBoltModelPropsInput, SheetMetalModelPropsInput, SpurGearModelPropsInput, HelicalGearModelPropsInput, WormGearModelPropsInput, HexBoltModelPropsInput } from '@tscircuit/modelprinter';
|
|
5
5
|
import * as _jscad_modeling_src_geometries_types from '@jscad/modeling/src/geometries/types';
|
|
6
6
|
|
|
7
7
|
type VNode = {
|
|
@@ -134,6 +134,23 @@ type WormGearProps = WormGearModelPropsInput & {
|
|
|
134
134
|
declare function createWormGearGeom(input: WormGearModelPropsInput): _jscad_modeling_src_geometries_types.Geom3;
|
|
135
135
|
declare function WormGear({ color, ...props }: WormGearProps): react_jsx_runtime.JSX.Element;
|
|
136
136
|
|
|
137
|
+
interface HexBoltMeshOptions {
|
|
138
|
+
radialSegments?: number;
|
|
139
|
+
threadStepsPerTurn?: number;
|
|
140
|
+
}
|
|
141
|
+
/** Outward-oriented, welded indexed surface, in millimeters. */
|
|
142
|
+
interface HexBoltMesh {
|
|
143
|
+
positions: number[];
|
|
144
|
+
indices: number[];
|
|
145
|
+
}
|
|
146
|
+
declare function createHexBoltMesh(input: HexBoltModelPropsInput, options?: HexBoltMeshOptions): HexBoltMesh;
|
|
147
|
+
|
|
148
|
+
type HexBoltProps = HexBoltModelPropsInput & {
|
|
149
|
+
color?: string;
|
|
150
|
+
};
|
|
151
|
+
declare function createHexBoltGeom(input: HexBoltModelPropsInput, options?: HexBoltMeshOptions): _jscad_modeling_src_geometries_types.Geom3;
|
|
152
|
+
declare function HexBolt({ color, ...props }: HexBoltProps): react_jsx_runtime.JSX.Element;
|
|
153
|
+
|
|
137
154
|
declare function getJscadModelForFootprint(footprint: string, jscad: typeof jscadModeling): RenderResult;
|
|
138
155
|
declare function getJscadModelForFootprintWithPads(footprint: string, jscad: typeof jscadModeling): RenderResult;
|
|
139
156
|
declare function createJSCADRenderer(jscad: typeof jscadModeling): {
|
|
@@ -142,4 +159,4 @@ declare function createJSCADRenderer(jscad: typeof jscadModeling): {
|
|
|
142
159
|
};
|
|
143
160
|
};
|
|
144
161
|
|
|
145
|
-
export { type ColoredGeom, Fragment, HelicalGear, type HelicalGearMesh, type HelicalGearProps, HexSocketBolt, type HexSocketBoltMesh, type HexSocketBoltProps, NEMA17, NEMA23, NEMA8, type NemaFrameMotorProps, NemaMotor, type NemaMotorProps, type RenderResult, SheetMetal, type SheetMetalMesh, type SheetMetalProps, SpurGear, type SpurGearMesh, type SpurGearProps, type VNode, WormGear, type WormGearMesh, type WormGearProps, convertCSGToThreeGeom, createHelicalGearGeom, createHelicalGearMesh, createHexSocketBoltGeom, createHexSocketBoltMesh, createJSCADRenderer, createSheetMetalGeom, createSheetMetalMesh, createSpurGearGeom, createSpurGearMesh, createWormGearGeom, createWormGearMesh, getJscadModelForFootprint, getJscadModelForFootprintWithPads, h };
|
|
162
|
+
export { type ColoredGeom, Fragment, HelicalGear, type HelicalGearMesh, type HelicalGearProps, HexBolt, type HexBoltMesh, type HexBoltMeshOptions, type HexBoltProps, HexSocketBolt, type HexSocketBoltMesh, type HexSocketBoltProps, NEMA17, NEMA23, NEMA8, type NemaFrameMotorProps, NemaMotor, type NemaMotorProps, type RenderResult, SheetMetal, type SheetMetalMesh, type SheetMetalProps, SpurGear, type SpurGearMesh, type SpurGearProps, type VNode, WormGear, type WormGearMesh, type WormGearProps, convertCSGToThreeGeom, createHelicalGearGeom, createHelicalGearMesh, createHexBoltGeom, createHexBoltMesh, createHexSocketBoltGeom, createHexSocketBoltMesh, createJSCADRenderer, createSheetMetalGeom, createSheetMetalMesh, createSpurGearGeom, createSpurGearMesh, createWormGearGeom, createWormGearMesh, getJscadModelForFootprint, getJscadModelForFootprintWithPads, h };
|
package/dist/vanilla.js
CHANGED
|
@@ -175,6 +175,7 @@ var ExtrudedPads = ({
|
|
|
175
175
|
if (!circuitJson && footprint && [
|
|
176
176
|
"nema",
|
|
177
177
|
"hexsocketbolt",
|
|
178
|
+
"hexbolt",
|
|
178
179
|
"sheetmetal",
|
|
179
180
|
"spurgear",
|
|
180
181
|
"wormgear",
|
|
@@ -206,6 +207,132 @@ var ExtrudedPads = ({
|
|
|
206
207
|
] });
|
|
207
208
|
};
|
|
208
209
|
|
|
210
|
+
// lib/models/hexbolt/mesh.ts
|
|
211
|
+
import {
|
|
212
|
+
hexBoltModelPropsSchema
|
|
213
|
+
} from "@tscircuit/modelprinter";
|
|
214
|
+
function createHexBoltMesh(input, options = {}) {
|
|
215
|
+
const p = hexBoltModelPropsSchema.parse(input);
|
|
216
|
+
const segments = options.radialSegments ?? 96;
|
|
217
|
+
const axial = options.threadStepsPerTurn ?? 24;
|
|
218
|
+
if (!Number.isInteger(segments) || segments < 24 || segments > 192 || segments % 24 !== 0 || !Number.isInteger(axial) || axial < 24 || axial > 96)
|
|
219
|
+
throw new Error(
|
|
220
|
+
"Screw mesh resolution requires 24..192 radial segments divisible by 24 and 24..96 thread steps"
|
|
221
|
+
);
|
|
222
|
+
const positions = [], indices = [];
|
|
223
|
+
const welded = /* @__PURE__ */ new Map();
|
|
224
|
+
const vertex = (x, y, z) => {
|
|
225
|
+
const key = [x, y, z].map((v) => Math.round(v * 1e10)).join(":");
|
|
226
|
+
const existing = welded.get(key);
|
|
227
|
+
if (existing !== void 0) return existing;
|
|
228
|
+
const index = positions.length / 3;
|
|
229
|
+
positions.push(x, y, z);
|
|
230
|
+
welded.set(key, index);
|
|
231
|
+
return index;
|
|
232
|
+
};
|
|
233
|
+
const triangle = (a, b, c) => {
|
|
234
|
+
if (a === b || b === c || c === a) return;
|
|
235
|
+
const point = (i) => positions.slice(3 * i, 3 * i + 3);
|
|
236
|
+
const A = point(a), B = point(b), C = point(c);
|
|
237
|
+
const u = B.map((v2, i) => v2 - A[i]), v = C.map((w, i) => w - A[i]);
|
|
238
|
+
const area = Math.hypot(
|
|
239
|
+
u[1] * v[2] - u[2] * v[1],
|
|
240
|
+
u[2] * v[0] - u[0] * v[2],
|
|
241
|
+
u[0] * v[1] - u[1] * v[0]
|
|
242
|
+
);
|
|
243
|
+
if (area > 1e-12) indices.push(a, b, c);
|
|
244
|
+
};
|
|
245
|
+
const ring = (radiusAt, zAt) => Array.from({ length: segments }, (_, i) => {
|
|
246
|
+
const theta = i * 2 * Math.PI / segments, r = radiusAt(theta);
|
|
247
|
+
return vertex(
|
|
248
|
+
r * Math.cos(theta),
|
|
249
|
+
r * Math.sin(theta),
|
|
250
|
+
typeof zAt === "number" ? zAt : zAt(theta)
|
|
251
|
+
);
|
|
252
|
+
});
|
|
253
|
+
const connect = (a, b) => {
|
|
254
|
+
for (let i = 0; i < segments; i++) {
|
|
255
|
+
const n = (i + 1) % segments;
|
|
256
|
+
triangle(a[i], a[n], b[n]);
|
|
257
|
+
triangle(a[i], b[n], b[i]);
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
const cap = (a, z, up) => {
|
|
261
|
+
const c = vertex(0, 0, z);
|
|
262
|
+
for (let i = 0; i < segments; i++) {
|
|
263
|
+
const n = (i + 1) % segments;
|
|
264
|
+
up ? triangle(c, a[i], a[n]) : triangle(c, a[n], a[i]);
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
let previous = [];
|
|
268
|
+
const add = (radiusAt, zAt) => {
|
|
269
|
+
const r = ring(radiusAt, zAt);
|
|
270
|
+
if (previous.length) connect(previous, r);
|
|
271
|
+
previous = r;
|
|
272
|
+
return r;
|
|
273
|
+
};
|
|
274
|
+
const major = p.diameter / 2, minor = p.threadRootDiameter / 2, pitch = p.threadPitch;
|
|
275
|
+
const shaftEnd = -p.underHeadRadius;
|
|
276
|
+
const steps = p.showThreads ? Math.ceil((shaftEnd + p.length) / pitch * axial) : 1;
|
|
277
|
+
if ((steps + 100) * segments > 4e5)
|
|
278
|
+
throw new Error("Screw exceeds mesh resolution limit");
|
|
279
|
+
const levels = /* @__PURE__ */ new Set([
|
|
280
|
+
-p.length,
|
|
281
|
+
-p.length + p.tipChamfer,
|
|
282
|
+
shaftEnd
|
|
283
|
+
]);
|
|
284
|
+
if (p.showThreads)
|
|
285
|
+
for (let i = 0; i <= steps; i++)
|
|
286
|
+
levels.add(-p.length + (shaftEnd + p.length) * i / steps);
|
|
287
|
+
for (const z of [...levels].sort((a, b) => a - b)) {
|
|
288
|
+
const r = add((theta) => {
|
|
289
|
+
const phase = (((z + p.length) / pitch - (p.threadHand === "right" ? 1 : -1) * theta / (2 * Math.PI)) % 1 + 1) % 1;
|
|
290
|
+
const d = Math.min(phase, 1 - phase);
|
|
291
|
+
const groove = Math.min(
|
|
292
|
+
major - minor,
|
|
293
|
+
Math.max(0, (d - 1 / 16) * pitch * Math.sqrt(3))
|
|
294
|
+
);
|
|
295
|
+
const thread = p.showThreads ? major - groove : major;
|
|
296
|
+
return Math.min(
|
|
297
|
+
thread,
|
|
298
|
+
major - Math.max(0, p.tipChamfer - (z + p.length))
|
|
299
|
+
);
|
|
300
|
+
}, z);
|
|
301
|
+
if (z === -p.length) cap(r, z, false);
|
|
302
|
+
}
|
|
303
|
+
add(() => major, shaftEnd);
|
|
304
|
+
const filletCenterR = major + p.underHeadRadius;
|
|
305
|
+
const filletCenterZ = shaftEnd;
|
|
306
|
+
for (let i = 1; i <= 16; i++) {
|
|
307
|
+
const angle = Math.PI - (Math.PI - Math.PI / 2) * i / 16;
|
|
308
|
+
add(
|
|
309
|
+
() => filletCenterR + p.underHeadRadius * Math.cos(angle),
|
|
310
|
+
filletCenterZ + p.underHeadRadius * Math.sin(angle)
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
const hexRadius = (theta) => p.headAcrossFlats / 2 / Math.max(
|
|
314
|
+
Math.abs(Math.sin(theta)),
|
|
315
|
+
Math.abs(Math.sin(theta + 2 * Math.PI / 3)),
|
|
316
|
+
Math.abs(Math.sin(theta + 4 * Math.PI / 3))
|
|
317
|
+
);
|
|
318
|
+
add(hexRadius, 0);
|
|
319
|
+
const slope = Math.tan(p.headChamferAngle * Math.PI / 180);
|
|
320
|
+
const start = p.headHeight - (p.headCornerDiameter - p.headChamferDiameter) / 2 * slope;
|
|
321
|
+
add(hexRadius, start);
|
|
322
|
+
for (let i = 1; i <= 12; i++) {
|
|
323
|
+
const z = start + (p.headHeight - start) * i / 12;
|
|
324
|
+
add(
|
|
325
|
+
(theta) => Math.min(
|
|
326
|
+
hexRadius(theta),
|
|
327
|
+
p.headChamferDiameter / 2 + (p.headHeight - z) / slope
|
|
328
|
+
),
|
|
329
|
+
z
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
cap(previous, p.headHeight, true);
|
|
333
|
+
return { positions, indices };
|
|
334
|
+
}
|
|
335
|
+
|
|
209
336
|
// lib/mechanical/indexedMeshToGeom3.ts
|
|
210
337
|
import jscad from "@jscad/modeling";
|
|
211
338
|
function indexedMeshToGeom3(mesh) {
|
|
@@ -221,6 +348,14 @@ function indexedMeshToGeom3(mesh) {
|
|
|
221
348
|
return jscad.geometries.geom3.fromPoints(polygons);
|
|
222
349
|
}
|
|
223
350
|
|
|
351
|
+
// lib/models/hexbolt/HexBolt.tsx
|
|
352
|
+
function createHexBoltGeom(input, options) {
|
|
353
|
+
return indexedMeshToGeom3(createHexBoltMesh(input, options));
|
|
354
|
+
}
|
|
355
|
+
function HexBolt({ color = "#737e8f", ...props }) {
|
|
356
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createHexBoltGeom(props) }) });
|
|
357
|
+
}
|
|
358
|
+
|
|
224
359
|
// lib/mechanical/helical-gear-mesh.ts
|
|
225
360
|
import {
|
|
226
361
|
getHelicalGearDimensions,
|
|
@@ -8790,34 +8925,56 @@ var CableStrip = ({
|
|
|
8790
8925
|
color,
|
|
8791
8926
|
acrossOffset = 0,
|
|
8792
8927
|
normalOffset = 0,
|
|
8793
|
-
overlap = 0.03
|
|
8794
|
-
|
|
8795
|
-
|
|
8796
|
-
|
|
8797
|
-
const
|
|
8798
|
-
|
|
8799
|
-
|
|
8800
|
-
|
|
8801
|
-
|
|
8802
|
-
|
|
8803
|
-
|
|
8804
|
-
(
|
|
8805
|
-
|
|
8806
|
-
|
|
8807
|
-
|
|
8808
|
-
|
|
8809
|
-
|
|
8810
|
-
|
|
8811
|
-
|
|
8812
|
-
|
|
8813
|
-
|
|
8814
|
-
|
|
8815
|
-
|
|
8816
|
-
|
|
8817
|
-
|
|
8818
|
-
|
|
8819
|
-
|
|
8820
|
-
|
|
8928
|
+
overlap = 0.03,
|
|
8929
|
+
widthAtDistance,
|
|
8930
|
+
startDistance = 0
|
|
8931
|
+
}) => {
|
|
8932
|
+
const distances = getPathDistances(points);
|
|
8933
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: points.slice(1).map((point, index) => {
|
|
8934
|
+
const previous = points[index];
|
|
8935
|
+
const dx = point[0] - previous[0];
|
|
8936
|
+
const dy = point[1] - previous[1];
|
|
8937
|
+
const dz = point[2] - previous[2];
|
|
8938
|
+
const segmentLength = Math.hypot(dx, dy, dz);
|
|
8939
|
+
if (segmentLength < EPSILON) return null;
|
|
8940
|
+
const pitch = Math.asin(dz / segmentLength);
|
|
8941
|
+
const yaw = Math.atan2(-dx, dy);
|
|
8942
|
+
const midpoint = [
|
|
8943
|
+
(previous[0] + point[0]) / 2,
|
|
8944
|
+
(previous[1] + point[1]) / 2,
|
|
8945
|
+
(previous[2] + point[2]) / 2
|
|
8946
|
+
];
|
|
8947
|
+
const roundRadius = Math.max(
|
|
8948
|
+
1e-3,
|
|
8949
|
+
Math.min(width10, thickness, segmentLength) / 2 - 1e-3
|
|
8950
|
+
);
|
|
8951
|
+
const startWidth = widthAtDistance?.(startDistance + distances[index]) ?? width10;
|
|
8952
|
+
const endWidth = widthAtDistance?.(startDistance + distances[index + 1]) ?? width10;
|
|
8953
|
+
return /* @__PURE__ */ jsx(Translate, { offset: midpoint, children: /* @__PURE__ */ jsx(Rotate, { rotation: [pitch, 0, yaw], children: widthAtDistance ? /* @__PURE__ */ jsxs(Hull, { children: [
|
|
8954
|
+
/* @__PURE__ */ jsx(
|
|
8955
|
+
Cuboid,
|
|
8956
|
+
{
|
|
8957
|
+
size: [startWidth, overlap, thickness],
|
|
8958
|
+
center: [acrossOffset, -segmentLength / 2, normalOffset]
|
|
8959
|
+
}
|
|
8960
|
+
),
|
|
8961
|
+
/* @__PURE__ */ jsx(
|
|
8962
|
+
Cuboid,
|
|
8963
|
+
{
|
|
8964
|
+
size: [endWidth, overlap, thickness],
|
|
8965
|
+
center: [acrossOffset, segmentLength / 2, normalOffset]
|
|
8966
|
+
}
|
|
8967
|
+
)
|
|
8968
|
+
] }) : /* @__PURE__ */ jsx(
|
|
8969
|
+
RoundedCuboid,
|
|
8970
|
+
{
|
|
8971
|
+
size: [width10, segmentLength + overlap, thickness],
|
|
8972
|
+
center: [acrossOffset, 0, normalOffset],
|
|
8973
|
+
roundRadius
|
|
8974
|
+
}
|
|
8975
|
+
) }) }, `${index}:${midpoint.join(":")}`);
|
|
8976
|
+
}) });
|
|
8977
|
+
};
|
|
8821
8978
|
var FlexScreen = (props) => {
|
|
8822
8979
|
const {
|
|
8823
8980
|
width: width10,
|
|
@@ -8837,13 +8994,15 @@ var FlexScreen = (props) => {
|
|
|
8837
8994
|
flexCableLength = 28,
|
|
8838
8995
|
flexCableThickness = 0.18,
|
|
8839
8996
|
flexCableColor = "#d79528",
|
|
8840
|
-
conductorCount = 8,
|
|
8841
|
-
conductorPitch,
|
|
8842
|
-
conductorWidth,
|
|
8997
|
+
pinCount: conductorCount = props.conductorCount ?? 8,
|
|
8998
|
+
pitch: conductorPitch = props.conductorPitch,
|
|
8999
|
+
padWidth: conductorWidth = props.conductorWidth,
|
|
8843
9000
|
conductorThickness = 0.035,
|
|
8844
9001
|
conductorColor = "#8c4a18",
|
|
8845
9002
|
cableEdgeMargin = 0.6,
|
|
8846
|
-
exposedContactLength = 2.4,
|
|
9003
|
+
padLength: exposedContactLength = props.exposedContactLength ?? 2.4,
|
|
9004
|
+
tailLength,
|
|
9005
|
+
taperLength,
|
|
8847
9006
|
showConductors = true,
|
|
8848
9007
|
showFlexCable = true,
|
|
8849
9008
|
showStiffeners = true,
|
|
@@ -8891,8 +9050,11 @@ var FlexScreen = (props) => {
|
|
|
8891
9050
|
assertPositive("foldOutset", foldOutset);
|
|
8892
9051
|
assertPositive("boardThickness", boardThickness);
|
|
8893
9052
|
if (showStiffeners) assertPositive("stiffenerThickness", stiffenerThickness);
|
|
9053
|
+
if (!Number.isFinite(exposedContactLength) || exposedContactLength < 0) {
|
|
9054
|
+
throw new Error("padLength must be a finite nonnegative length");
|
|
9055
|
+
}
|
|
8894
9056
|
if (!Number.isInteger(conductorCount) || conductorCount < 1) {
|
|
8895
|
-
throw new Error("
|
|
9057
|
+
throw new Error("pinCount must be a positive integer");
|
|
8896
9058
|
}
|
|
8897
9059
|
if (!Number.isInteger(bendSegments) || bendSegments < 2) {
|
|
8898
9060
|
throw new Error("bendSegments must be an integer of at least 2");
|
|
@@ -8912,17 +9074,22 @@ var FlexScreen = (props) => {
|
|
|
8912
9074
|
throw new Error("cableEdgeMargin leaves no usable flex cable width");
|
|
8913
9075
|
}
|
|
8914
9076
|
const resolvedConductorPitch = conductorPitch ?? (conductorCount === 1 ? 0 : usableCableWidth / conductorCount);
|
|
8915
|
-
if (conductorCount > 1 && (!Number.isFinite(resolvedConductorPitch) || resolvedConductorPitch <= 0)) {
|
|
8916
|
-
throw new Error("
|
|
9077
|
+
if ((conductorPitch !== void 0 || conductorCount > 1) && (!Number.isFinite(resolvedConductorPitch) || resolvedConductorPitch <= 0)) {
|
|
9078
|
+
throw new Error("pitch must be greater than zero");
|
|
8917
9079
|
}
|
|
8918
9080
|
const resolvedConductorWidth = conductorWidth ?? (conductorCount === 1 ? Math.min(usableCableWidth, resolvedCableWidth * 0.45) : resolvedConductorPitch * 0.48);
|
|
8919
|
-
assertPositive("
|
|
9081
|
+
assertPositive("padWidth", resolvedConductorWidth);
|
|
8920
9082
|
const conductorSpan = (conductorCount - 1) * resolvedConductorPitch + resolvedConductorWidth;
|
|
8921
|
-
|
|
8922
|
-
|
|
8923
|
-
|
|
8924
|
-
|
|
8925
|
-
|
|
9083
|
+
const connectorWidth = Math.max(
|
|
9084
|
+
resolvedCableWidth,
|
|
9085
|
+
conductorSpan + cableEdgeMargin * 2
|
|
9086
|
+
);
|
|
9087
|
+
const widensAtConnector = connectorWidth > resolvedCableWidth + EPSILON;
|
|
9088
|
+
const screenConductorPitch = widensAtConnector ? conductorCount === 1 ? 0 : usableCableWidth / conductorCount : resolvedConductorPitch;
|
|
9089
|
+
const screenConductorWidth = widensAtConnector ? Math.min(
|
|
9090
|
+
resolvedConductorWidth,
|
|
9091
|
+
conductorCount === 1 ? usableCableWidth : screenConductorPitch * 0.48
|
|
9092
|
+
) : resolvedConductorWidth;
|
|
8926
9093
|
const cableStartsBelowBoard = belowBoard && !foldedFace;
|
|
8927
9094
|
const defaultCableZ = cableStartsBelowBoard ? boardTopZ - boardThickness - boardClearance - flexCableThickness / 2 : boardTopZ + boardClearance + flexCableThickness / 2;
|
|
8928
9095
|
const start = [
|
|
@@ -8949,23 +9116,56 @@ var FlexScreen = (props) => {
|
|
|
8949
9116
|
direction
|
|
8950
9117
|
}) : createFlatPath(start, flexCableLength);
|
|
8951
9118
|
const totalCableLength = getPathDistances(path).at(-1);
|
|
9119
|
+
if (tailLength !== void 0) {
|
|
9120
|
+
assertPositive("tailLength", tailLength);
|
|
9121
|
+
if (tailLength >= totalCableLength) {
|
|
9122
|
+
throw new Error("tailLength must be shorter than flexCableLength");
|
|
9123
|
+
}
|
|
9124
|
+
}
|
|
9125
|
+
if (taperLength !== void 0) assertPositive("taperLength", taperLength);
|
|
8952
9126
|
const contactLength = Math.min(
|
|
8953
9127
|
Math.max(0, exposedContactLength),
|
|
8954
|
-
totalCableLength / 2
|
|
9128
|
+
totalCableLength / 2,
|
|
9129
|
+
tailLength ?? Infinity
|
|
8955
9130
|
);
|
|
8956
9131
|
const resolvedStiffenerLength = Math.min(
|
|
8957
9132
|
Math.max(0, stiffenerLength),
|
|
8958
|
-
totalCableLength / 2
|
|
9133
|
+
totalCableLength / 2,
|
|
9134
|
+
tailLength ?? Infinity
|
|
8959
9135
|
);
|
|
9136
|
+
const connectorLeadLength = tailLength ?? Math.max(contactLength, resolvedStiffenerLength);
|
|
9137
|
+
if (taperLength !== void 0 && connectorLeadLength + taperLength > totalCableLength + EPSILON) {
|
|
9138
|
+
throw new Error(
|
|
9139
|
+
"tailLength and taperLength must fit within flexCableLength"
|
|
9140
|
+
);
|
|
9141
|
+
}
|
|
9142
|
+
const taperEndDistance = Math.min(
|
|
9143
|
+
totalCableLength,
|
|
9144
|
+
connectorLeadLength + (taperLength ?? Math.max(3, (connectorWidth - resolvedCableWidth) / 2))
|
|
9145
|
+
);
|
|
9146
|
+
const cableWidthAtDistance = (distance2) => {
|
|
9147
|
+
if (distance2 <= connectorLeadLength) return connectorWidth;
|
|
9148
|
+
const progress = Math.min(
|
|
9149
|
+
1,
|
|
9150
|
+
(distance2 - connectorLeadLength) / (taperEndDistance - connectorLeadLength)
|
|
9151
|
+
);
|
|
9152
|
+
return connectorWidth + (resolvedCableWidth - connectorWidth) * progress;
|
|
9153
|
+
};
|
|
9154
|
+
const cablePath = widensAtConnector ? [
|
|
9155
|
+
...slicePath(path, 0, connectorLeadLength),
|
|
9156
|
+
...slicePath(path, connectorLeadLength, taperEndDistance).slice(1),
|
|
9157
|
+
...slicePath(path, taperEndDistance, totalCableLength).slice(1)
|
|
9158
|
+
] : path;
|
|
9159
|
+
const widthProfile = widensAtConnector ? cableWidthAtDistance : void 0;
|
|
8960
9160
|
const startContacts = slicePath(path, 0, contactLength);
|
|
8961
9161
|
const endContacts = slicePath(
|
|
8962
9162
|
path,
|
|
8963
9163
|
totalCableLength - contactLength,
|
|
8964
9164
|
totalCableLength
|
|
8965
9165
|
);
|
|
8966
|
-
const startStiffener = slicePath(
|
|
9166
|
+
const startStiffener = slicePath(cablePath, 0, resolvedStiffenerLength);
|
|
8967
9167
|
const endStiffener = slicePath(
|
|
8968
|
-
|
|
9168
|
+
cablePath,
|
|
8969
9169
|
totalCableLength - resolvedStiffenerLength,
|
|
8970
9170
|
totalCableLength
|
|
8971
9171
|
);
|
|
@@ -9014,7 +9214,7 @@ var FlexScreen = (props) => {
|
|
|
9014
9214
|
];
|
|
9015
9215
|
const conductorOffsets = Array.from(
|
|
9016
9216
|
{ length: conductorCount },
|
|
9017
|
-
(_, index) =>
|
|
9217
|
+
(_, index) => (index - (conductorCount - 1) / 2) * resolvedConductorPitch
|
|
9018
9218
|
);
|
|
9019
9219
|
const conductorNormalOffset = (flexCableThickness + conductorThickness) / 2;
|
|
9020
9220
|
const stiffenerNormalOffset = -(flexCableThickness + stiffenerThickness) / 2;
|
|
@@ -9022,8 +9222,9 @@ var FlexScreen = (props) => {
|
|
|
9022
9222
|
showFlexCable && /* @__PURE__ */ jsx(
|
|
9023
9223
|
CableStrip,
|
|
9024
9224
|
{
|
|
9025
|
-
points:
|
|
9225
|
+
points: cablePath,
|
|
9026
9226
|
width: resolvedCableWidth,
|
|
9227
|
+
widthAtDistance: widthProfile,
|
|
9027
9228
|
thickness: flexCableThickness,
|
|
9028
9229
|
color: flexCableColor
|
|
9029
9230
|
}
|
|
@@ -9033,7 +9234,7 @@ var FlexScreen = (props) => {
|
|
|
9033
9234
|
CableStrip,
|
|
9034
9235
|
{
|
|
9035
9236
|
points: startStiffener,
|
|
9036
|
-
width:
|
|
9237
|
+
width: connectorWidth,
|
|
9037
9238
|
thickness: stiffenerThickness,
|
|
9038
9239
|
color: stiffenerColor,
|
|
9039
9240
|
normalOffset: stiffenerNormalOffset
|
|
@@ -9044,6 +9245,8 @@ var FlexScreen = (props) => {
|
|
|
9044
9245
|
{
|
|
9045
9246
|
points: endStiffener,
|
|
9046
9247
|
width: resolvedCableWidth,
|
|
9248
|
+
widthAtDistance: widthProfile,
|
|
9249
|
+
startDistance: totalCableLength - resolvedStiffenerLength,
|
|
9047
9250
|
thickness: stiffenerThickness,
|
|
9048
9251
|
color: stiffenerColor,
|
|
9049
9252
|
normalOffset: stiffenerNormalOffset
|
|
@@ -9066,10 +9269,10 @@ var FlexScreen = (props) => {
|
|
|
9066
9269
|
CableStrip,
|
|
9067
9270
|
{
|
|
9068
9271
|
points: endContacts,
|
|
9069
|
-
width:
|
|
9272
|
+
width: screenConductorWidth,
|
|
9070
9273
|
thickness: conductorThickness,
|
|
9071
9274
|
color: conductorColor,
|
|
9072
|
-
acrossOffset,
|
|
9275
|
+
acrossOffset: (index - (conductorCount - 1) / 2) * screenConductorPitch,
|
|
9073
9276
|
normalOffset: conductorNormalOffset
|
|
9074
9277
|
}
|
|
9075
9278
|
)
|
|
@@ -9108,6 +9311,10 @@ var Footprinter3d = ({ footprint }) => {
|
|
|
9108
9311
|
if (mp3.getModelNames().includes(modelFn)) {
|
|
9109
9312
|
const model = mp3.string(footprint).json();
|
|
9110
9313
|
switch (model.fn) {
|
|
9314
|
+
case "hexbolt": {
|
|
9315
|
+
const { fn, ...props } = model;
|
|
9316
|
+
return /* @__PURE__ */ jsx(HexBolt, { ...props });
|
|
9317
|
+
}
|
|
9111
9318
|
case "nema": {
|
|
9112
9319
|
const { fn, ...props } = model;
|
|
9113
9320
|
return /* @__PURE__ */ jsx(NemaMotor, { ...props });
|
|
@@ -10054,6 +10261,7 @@ function createJSCADRenderer(jscad4) {
|
|
|
10054
10261
|
export {
|
|
10055
10262
|
Fragment,
|
|
10056
10263
|
HelicalGear,
|
|
10264
|
+
HexBolt,
|
|
10057
10265
|
HexSocketBolt,
|
|
10058
10266
|
NEMA17,
|
|
10059
10267
|
NEMA23,
|
|
@@ -10065,6 +10273,8 @@ export {
|
|
|
10065
10273
|
convertCSGToThreeGeom,
|
|
10066
10274
|
createHelicalGearGeom,
|
|
10067
10275
|
createHelicalGearMesh,
|
|
10276
|
+
createHexBoltGeom,
|
|
10277
|
+
createHexBoltMesh,
|
|
10068
10278
|
createHexSocketBoltGeom,
|
|
10069
10279
|
createHexSocketBoltMesh,
|
|
10070
10280
|
createJSCADRenderer,
|