@code3d/screws 0.0.1-alpha.4 → 0.0.1-alpha.6
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/README.md +228 -40
- package/bld/chunks/chunk-2DGVQRQ5.js +78 -0
- package/bld/chunks/chunk-2DGVQRQ5.js.map +7 -0
- package/bld/chunks/chunk-4FMUSJBB.js +27 -0
- package/bld/chunks/chunk-4FMUSJBB.js.map +7 -0
- package/bld/chunks/chunk-7UGU5EFV.js +87 -0
- package/bld/chunks/chunk-7UGU5EFV.js.map +7 -0
- package/bld/chunks/chunk-DKS4VANI.js +27 -0
- package/bld/chunks/chunk-DKS4VANI.js.map +7 -0
- package/bld/chunks/chunk-ES62SR3Q.js +21 -0
- package/bld/chunks/chunk-ES62SR3Q.js.map +7 -0
- package/bld/chunks/chunk-ESLSQKZW.js +25 -0
- package/bld/chunks/chunk-ESLSQKZW.js.map +7 -0
- package/bld/chunks/chunk-GAX6375G.js +25 -0
- package/bld/chunks/chunk-GAX6375G.js.map +7 -0
- package/bld/chunks/chunk-GIIOR3XJ.js +49 -0
- package/bld/chunks/chunk-GIIOR3XJ.js.map +7 -0
- package/bld/chunks/chunk-HPPYZYCK.js +23 -0
- package/bld/chunks/chunk-HPPYZYCK.js.map +7 -0
- package/bld/chunks/chunk-IXFHRZSY.js +121 -0
- package/bld/chunks/chunk-IXFHRZSY.js.map +7 -0
- package/bld/chunks/chunk-MEIKYZ23.js +84 -0
- package/bld/chunks/chunk-MEIKYZ23.js.map +7 -0
- package/bld/chunks/chunk-O34BMYJV.js +84 -0
- package/bld/chunks/chunk-O34BMYJV.js.map +7 -0
- package/bld/chunks/chunk-P3M5KQ5U.js +46 -0
- package/bld/chunks/chunk-P3M5KQ5U.js.map +7 -0
- package/bld/chunks/chunk-PFFNLWWR.js +25 -0
- package/bld/chunks/chunk-PFFNLWWR.js.map +7 -0
- package/bld/chunks/chunk-SDUJLXOE.js +46 -0
- package/bld/chunks/chunk-SDUJLXOE.js.map +7 -0
- package/bld/chunks/chunk-SDYJF2XK.js +25 -0
- package/bld/chunks/chunk-SDYJF2XK.js.map +7 -0
- package/bld/chunks/chunk-SGDNOA44.js +92 -0
- package/bld/chunks/chunk-SGDNOA44.js.map +7 -0
- package/bld/chunks/chunk-SPFHOFBC.js +125 -0
- package/bld/chunks/chunk-SPFHOFBC.js.map +7 -0
- package/bld/chunks/chunk-VVX3WOBG.js +160 -0
- package/bld/chunks/chunk-VVX3WOBG.js.map +7 -0
- package/bld/chunks/chunk-W62ASGIP.js +25 -0
- package/bld/chunks/chunk-W62ASGIP.js.map +7 -0
- package/bld/chunks/chunk-Z5LEGL77.js +464 -0
- package/bld/chunks/chunk-Z5LEGL77.js.map +7 -0
- package/bld/chunks/chunk-ZNWKI54A.js +25 -0
- package/bld/chunks/chunk-ZNWKI54A.js.map +7 -0
- package/bld/library/common.d.ts +104 -0
- package/bld/library/common.d.ts.map +1 -0
- package/bld/library/gb-2672.d.ts +8 -0
- package/bld/library/gb-2672.d.ts.map +1 -0
- package/bld/library/gb-2672.js +17 -0
- package/bld/library/gb-2672.js.map +7 -0
- package/bld/library/gb-5281.d.ts +8 -0
- package/bld/library/gb-5281.d.ts.map +1 -0
- package/bld/library/gb-5281.js +15 -0
- package/bld/library/gb-5281.js.map +7 -0
- package/bld/library/gb-5782.d.ts +8 -0
- package/bld/library/gb-5782.d.ts.map +1 -0
- package/bld/library/gb-5782.js +19 -0
- package/bld/library/gb-5782.js.map +7 -0
- package/bld/library/gb-5783.d.ts +8 -0
- package/bld/library/gb-5783.d.ts.map +1 -0
- package/bld/library/gb-5783.js +19 -0
- package/bld/library/gb-5783.js.map +7 -0
- package/bld/library/gb-70-1.d.ts +8 -0
- package/bld/library/gb-70-1.d.ts.map +1 -0
- package/bld/library/gb-70-1.js +17 -0
- package/bld/library/gb-70-1.js.map +7 -0
- package/bld/library/gb-70-2.d.ts +8 -0
- package/bld/library/gb-70-2.d.ts.map +1 -0
- package/bld/library/gb-70-2.js +17 -0
- package/bld/library/gb-70-2.js.map +7 -0
- package/bld/library/gb-70-3.d.ts +8 -0
- package/bld/library/gb-70-3.d.ts.map +1 -0
- package/bld/library/gb-70-3.js +17 -0
- package/bld/library/gb-70-3.js.map +7 -0
- package/bld/library/gb-70-4.d.ts +8 -0
- package/bld/library/gb-70-4.d.ts.map +1 -0
- package/bld/library/gb-70-4.js +17 -0
- package/bld/library/gb-70-4.js.map +7 -0
- package/bld/library/gb-80.d.ts +8 -0
- package/bld/library/gb-80.d.ts.map +1 -0
- package/bld/library/gb-80.js +13 -0
- package/bld/library/gb-80.js.map +7 -0
- package/bld/library/gb-818.d.ts +8 -0
- package/bld/library/gb-818.d.ts.map +1 -0
- package/bld/library/gb-818.js +17 -0
- package/bld/library/gb-818.js.map +7 -0
- package/bld/library/hex-head.d.ts +18 -0
- package/bld/library/hex-head.d.ts.map +1 -0
- package/bld/library/index.d.ts +19 -0
- package/bld/library/index.d.ts.map +1 -1
- package/bld/library/index.js +80 -455
- package/bld/library/index.js.map +3 -3
- package/bld/library/iso-10642.d.ts +51 -0
- package/bld/library/iso-10642.d.ts.map +1 -0
- package/bld/library/iso-10642.js +16 -0
- package/bld/library/iso-10642.js.map +7 -0
- package/bld/library/iso-14583.d.ts +35 -0
- package/bld/library/iso-14583.d.ts.map +1 -0
- package/bld/library/iso-14583.js +16 -0
- package/bld/library/iso-14583.js.map +7 -0
- package/bld/library/iso-4014.d.ts +20 -0
- package/bld/library/iso-4014.d.ts.map +1 -0
- package/bld/library/iso-4014.js +18 -0
- package/bld/library/iso-4014.js.map +7 -0
- package/bld/library/iso-4017.d.ts +20 -0
- package/bld/library/iso-4017.d.ts.map +1 -0
- package/bld/library/iso-4017.js +18 -0
- package/bld/library/iso-4017.js.map +7 -0
- package/bld/library/iso-4029.d.ts +32 -0
- package/bld/library/iso-4029.d.ts.map +1 -0
- package/bld/library/iso-4029.js +12 -0
- package/bld/library/iso-4029.js.map +7 -0
- package/bld/library/iso-4762.d.ts +10 -152
- package/bld/library/iso-4762.d.ts.map +1 -1
- package/bld/library/iso-4762.js +16 -0
- package/bld/library/iso-4762.js.map +7 -0
- package/bld/library/iso-7045.d.ts +33 -0
- package/bld/library/iso-7045.d.ts.map +1 -0
- package/bld/library/iso-7045.js +16 -0
- package/bld/library/iso-7045.js.map +7 -0
- package/bld/library/iso-7379.d.ts +56 -0
- package/bld/library/iso-7379.d.ts.map +1 -0
- package/bld/library/iso-7379.js +14 -0
- package/bld/library/iso-7379.js.map +7 -0
- package/bld/library/iso-7380-1.d.ts +31 -0
- package/bld/library/iso-7380-1.d.ts.map +1 -0
- package/bld/library/iso-7380-1.js +16 -0
- package/bld/library/iso-7380-1.js.map +7 -0
- package/bld/library/iso-7380-2.d.ts +33 -0
- package/bld/library/iso-7380-2.d.ts.map +1 -0
- package/bld/library/iso-7380-2.js +16 -0
- package/bld/library/iso-7380-2.js.map +7 -0
- package/package.json +82 -2
- package/src/library/common.ts +367 -0
- package/src/library/gb-2672.ts +7 -0
- package/src/library/gb-5281.ts +7 -0
- package/src/library/gb-5782.ts +7 -0
- package/src/library/gb-5783.ts +7 -0
- package/src/library/gb-70-1.ts +7 -0
- package/src/library/gb-70-2.ts +7 -0
- package/src/library/gb-70-3.ts +7 -0
- package/src/library/gb-70-4.ts +7 -0
- package/src/library/gb-80.ts +7 -0
- package/src/library/gb-818.ts +7 -0
- package/src/library/hex-head.ts +53 -0
- package/src/library/index.ts +20 -0
- package/src/library/iso-10642.ts +173 -0
- package/src/library/iso-14583.ts +181 -0
- package/src/library/iso-4014.ts +64 -0
- package/src/library/iso-4017.ts +62 -0
- package/src/library/iso-4029.ts +101 -0
- package/src/library/iso-4762.ts +70 -300
- package/src/library/iso-7045.ts +134 -0
- package/src/library/iso-7379.ts +230 -0
- package/src/library/iso-7380-1.ts +110 -0
- package/src/library/iso-7380-2.ts +135 -0
- package/src/library/thread.ts +7 -1
package/bld/library/index.js
CHANGED
|
@@ -1,460 +1,85 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
var __export = (target, all) => {
|
|
4
|
-
for (var name in all)
|
|
5
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
// packages/screws/src/library/iso-4762.ts
|
|
9
|
-
var iso_4762_exports = {};
|
|
10
|
-
__export(iso_4762_exports, {
|
|
11
|
-
clearanceHole: () => clearanceHole,
|
|
12
|
-
resolveSpecification: () => resolveSpecification,
|
|
13
|
-
screw: () => screw,
|
|
14
|
-
specifications: () => specifications,
|
|
15
|
-
threadLength: () => threadLength
|
|
16
|
-
});
|
|
17
1
|
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
frustum,
|
|
21
|
-
regularPrism,
|
|
22
|
-
union
|
|
23
|
-
} from "@code3d/core";
|
|
24
|
-
|
|
25
|
-
// packages/screws/src/library/thread.ts
|
|
2
|
+
gb_5783_exports
|
|
3
|
+
} from "../chunks/chunk-DKS4VANI.js";
|
|
26
4
|
import {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const toothHeight = majorRadius - minorRadius;
|
|
86
|
-
const profile = threadProfile(rootWidth, crestWidth, toothHeight);
|
|
87
|
-
const teeth = fadedThread(pitch, minorRadius, y, profile, leftHanded);
|
|
88
|
-
const core = makeCylinder(minorRadius + 0.05, y);
|
|
89
|
-
const threaded = core.fuse(teeth);
|
|
90
|
-
core.delete();
|
|
91
|
-
teeth.delete();
|
|
92
|
-
return threaded.rotate(-90, [0, 0, 0], [1, 0, 0]).translate([0, -y / 2, 0]);
|
|
93
|
-
}
|
|
94
|
-
__name(makeHelicalThreadShape, "makeHelicalThreadShape");
|
|
95
|
-
function threadProfile(rootWidth, crestWidth, toothHeight) {
|
|
96
|
-
const rootHalf = rootWidth / 2;
|
|
97
|
-
const crestHalf = crestWidth / 2;
|
|
98
|
-
return draw([rootHalf, -0.05]).vLine(0.05).lineTo([crestHalf, toothHeight]).hLineTo(-crestHalf).lineTo([-rootHalf, 0]).vLine(-0.05).close();
|
|
99
|
-
}
|
|
100
|
-
__name(threadProfile, "threadProfile");
|
|
101
|
-
function fadedThread(pitch, radius, length, profile, leftHanded) {
|
|
102
|
-
const bottomEnd = fadedEnd(pitch, radius, profile, true, leftHanded);
|
|
103
|
-
const totalLoops = length / pitch - 0.5;
|
|
104
|
-
const fullLoops = Math.floor(totalLoops);
|
|
105
|
-
const leftover = totalLoops - fullLoops;
|
|
106
|
-
const singleLoop = basicThreadLoop(
|
|
107
|
-
pitch,
|
|
108
|
-
radius,
|
|
109
|
-
profile,
|
|
110
|
-
1,
|
|
111
|
-
"none",
|
|
112
|
-
leftHanded
|
|
113
|
-
);
|
|
114
|
-
const shells = Array.from(
|
|
115
|
-
{ length: fullLoops },
|
|
116
|
-
(_, index) => singleLoop.clone().translate([0, 0, index * pitch])
|
|
117
|
-
);
|
|
118
|
-
singleLoop.delete();
|
|
119
|
-
if (leftover > 1e-9) {
|
|
120
|
-
shells.push(
|
|
121
|
-
basicThreadLoop(
|
|
122
|
-
pitch,
|
|
123
|
-
radius,
|
|
124
|
-
profile,
|
|
125
|
-
leftover,
|
|
126
|
-
"none",
|
|
127
|
-
leftHanded
|
|
128
|
-
).translate([0, 0, fullLoops * pitch])
|
|
129
|
-
);
|
|
130
|
-
}
|
|
131
|
-
const topEnd = fadedEnd(pitch, radius, profile, false, leftHanded).translate([0, 0, totalLoops * pitch]).rotate(360 * leftover, [0, 0, 0], [0, 0, 1]);
|
|
132
|
-
const thread = makeSolid([bottomEnd, ...shells, topEnd]).translate([
|
|
133
|
-
0,
|
|
134
|
-
0,
|
|
135
|
-
pitch / 4
|
|
136
|
-
]);
|
|
137
|
-
bottomEnd.delete();
|
|
138
|
-
shells.forEach((shell) => shell.delete());
|
|
139
|
-
topEnd.delete();
|
|
140
|
-
return thread;
|
|
141
|
-
}
|
|
142
|
-
__name(fadedThread, "fadedThread");
|
|
143
|
-
function basicThreadLoop(pitch, radius, profile, loopFraction, includeEnd, leftHanded) {
|
|
144
|
-
const helix = makeHelix(
|
|
145
|
-
pitch,
|
|
146
|
-
pitch * clamp(loopFraction, 0, 1),
|
|
147
|
-
radius,
|
|
148
|
-
[0, 0, 0],
|
|
149
|
-
[0, 0, 1],
|
|
150
|
-
leftHanded
|
|
151
|
-
);
|
|
152
|
-
const profiles = loopSteps.map((step) => {
|
|
153
|
-
const position = helix.pointAt(step);
|
|
154
|
-
const tangent = helix.tangentAt(step);
|
|
155
|
-
const plane = new Plane(position, [0, 0, 1], tangent);
|
|
156
|
-
const sketch = profile.sketchOnPlane(plane);
|
|
157
|
-
plane.delete();
|
|
158
|
-
return sketch;
|
|
159
|
-
});
|
|
160
|
-
helix.delete();
|
|
161
|
-
const ends = [];
|
|
162
|
-
if (includeEnd === "first" || includeEnd === "both") {
|
|
163
|
-
ends.push(profiles[0].faces());
|
|
164
|
-
}
|
|
165
|
-
if (includeEnd === "last" || includeEnd === "both") {
|
|
166
|
-
const face = profiles.at(-1).faces();
|
|
167
|
-
face.wrapped.Reverse();
|
|
168
|
-
ends.push(face);
|
|
169
|
-
}
|
|
170
|
-
const shell = profiles[0].loftWith(profiles.slice(1), { ruled: false }, true);
|
|
171
|
-
if (ends.length === 0) return shell;
|
|
172
|
-
const closed = weldShellsAndFaces([shell, ...ends]);
|
|
173
|
-
shell.delete();
|
|
174
|
-
ends.forEach((face) => face.delete());
|
|
175
|
-
return closed;
|
|
176
|
-
}
|
|
177
|
-
__name(basicThreadLoop, "basicThreadLoop");
|
|
178
|
-
function fadedEnd(pitch, radius, profile, bottom, leftHanded) {
|
|
179
|
-
const length = pitch / 4;
|
|
180
|
-
const helix = makeHelix(
|
|
181
|
-
pitch,
|
|
182
|
-
length,
|
|
183
|
-
radius,
|
|
184
|
-
[0, 0, 0],
|
|
185
|
-
[0, 0, bottom ? -1 : 1],
|
|
186
|
-
leftHanded
|
|
187
|
-
);
|
|
188
|
-
const profiles = loopSteps.map((step, index) => {
|
|
189
|
-
const position = helix.pointAt(step);
|
|
190
|
-
let tangent = helix.tangentAt(step);
|
|
191
|
-
if (bottom) tangent = tangent.multiply(-1);
|
|
192
|
-
const plane = new Plane(position, [0, 0, 1], tangent);
|
|
193
|
-
const sketch = profile.scale((loopSteps.length - index) / loopSteps.length, [0, 0]).sketchOnPlane(plane);
|
|
194
|
-
plane.delete();
|
|
195
|
-
return sketch;
|
|
196
|
-
});
|
|
197
|
-
helix.delete();
|
|
198
|
-
const endFace = profiles.at(-1).faces();
|
|
199
|
-
const shell = profiles[0].loftWith(profiles.slice(1), { ruled: false }, true);
|
|
200
|
-
const closed = weldShellsAndFaces([shell, endFace]);
|
|
201
|
-
shell.delete();
|
|
202
|
-
endFace.delete();
|
|
203
|
-
return bottom ? closed.rotate(180, [0, 0, 0], [0, 0, 1]) : closed;
|
|
204
|
-
}
|
|
205
|
-
__name(fadedEnd, "fadedEnd");
|
|
206
|
-
function assertPositive(name, value) {
|
|
207
|
-
if (!Number.isFinite(value) || value <= 0) {
|
|
208
|
-
throw new Error(`${name} must be a positive finite number.`);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
__name(assertPositive, "assertPositive");
|
|
212
|
-
function clamp(value, minimum, maximum) {
|
|
213
|
-
return Math.min(Math.max(value, minimum), maximum);
|
|
214
|
-
}
|
|
215
|
-
__name(clamp, "clamp");
|
|
216
|
-
|
|
217
|
-
// packages/screws/src/library/iso-4762.ts
|
|
218
|
-
var specifications = {
|
|
219
|
-
M3: {
|
|
220
|
-
designation: "M3",
|
|
221
|
-
nominalDiameter: 3,
|
|
222
|
-
pitch: 0.5,
|
|
223
|
-
headDiameter: 5.5,
|
|
224
|
-
headHeight: 3,
|
|
225
|
-
hexSocketWidth: 2.5,
|
|
226
|
-
hexSocketDepth: 1.3,
|
|
227
|
-
underHeadRadius: 0.1,
|
|
228
|
-
clearance: { close: 3.2, normal: 3.4, loose: 3.6 },
|
|
229
|
-
counterboreDiameter: 6
|
|
230
|
-
},
|
|
231
|
-
M4: {
|
|
232
|
-
designation: "M4",
|
|
233
|
-
nominalDiameter: 4,
|
|
234
|
-
pitch: 0.7,
|
|
235
|
-
headDiameter: 7,
|
|
236
|
-
headHeight: 4,
|
|
237
|
-
hexSocketWidth: 3,
|
|
238
|
-
hexSocketDepth: 2,
|
|
239
|
-
underHeadRadius: 0.2,
|
|
240
|
-
clearance: { close: 4.3, normal: 4.5, loose: 4.8 },
|
|
241
|
-
counterboreDiameter: 8
|
|
242
|
-
},
|
|
243
|
-
M5: {
|
|
244
|
-
designation: "M5",
|
|
245
|
-
nominalDiameter: 5,
|
|
246
|
-
pitch: 0.8,
|
|
247
|
-
headDiameter: 8.5,
|
|
248
|
-
headHeight: 5,
|
|
249
|
-
hexSocketWidth: 4,
|
|
250
|
-
hexSocketDepth: 2.5,
|
|
251
|
-
underHeadRadius: 0.2,
|
|
252
|
-
clearance: { close: 5.3, normal: 5.5, loose: 5.8 },
|
|
253
|
-
counterboreDiameter: 10
|
|
254
|
-
},
|
|
255
|
-
M6: {
|
|
256
|
-
designation: "M6",
|
|
257
|
-
nominalDiameter: 6,
|
|
258
|
-
pitch: 1,
|
|
259
|
-
headDiameter: 10,
|
|
260
|
-
headHeight: 6,
|
|
261
|
-
hexSocketWidth: 5,
|
|
262
|
-
hexSocketDepth: 3,
|
|
263
|
-
underHeadRadius: 0.25,
|
|
264
|
-
clearance: { close: 6.4, normal: 6.6, loose: 7 },
|
|
265
|
-
counterboreDiameter: 11
|
|
266
|
-
},
|
|
267
|
-
M8: {
|
|
268
|
-
designation: "M8",
|
|
269
|
-
nominalDiameter: 8,
|
|
270
|
-
pitch: 1.25,
|
|
271
|
-
headDiameter: 13,
|
|
272
|
-
headHeight: 8,
|
|
273
|
-
hexSocketWidth: 6,
|
|
274
|
-
hexSocketDepth: 4,
|
|
275
|
-
underHeadRadius: 0.4,
|
|
276
|
-
clearance: { close: 8.4, normal: 9, loose: 10 },
|
|
277
|
-
counterboreDiameter: 15
|
|
278
|
-
},
|
|
279
|
-
M10: {
|
|
280
|
-
designation: "M10",
|
|
281
|
-
nominalDiameter: 10,
|
|
282
|
-
pitch: 1.5,
|
|
283
|
-
headDiameter: 16,
|
|
284
|
-
headHeight: 10,
|
|
285
|
-
hexSocketWidth: 8,
|
|
286
|
-
hexSocketDepth: 5,
|
|
287
|
-
underHeadRadius: 0.4,
|
|
288
|
-
clearance: { close: 10.5, normal: 11, loose: 12 },
|
|
289
|
-
counterboreDiameter: 18
|
|
290
|
-
},
|
|
291
|
-
M12: {
|
|
292
|
-
designation: "M12",
|
|
293
|
-
nominalDiameter: 12,
|
|
294
|
-
pitch: 1.75,
|
|
295
|
-
headDiameter: 18,
|
|
296
|
-
headHeight: 12,
|
|
297
|
-
hexSocketWidth: 10,
|
|
298
|
-
hexSocketDepth: 6,
|
|
299
|
-
underHeadRadius: 0.6,
|
|
300
|
-
clearance: { close: 13, normal: 13.5, loose: 14.5 },
|
|
301
|
-
counterboreDiameter: 20
|
|
302
|
-
}
|
|
303
|
-
};
|
|
304
|
-
function screw(input, length) {
|
|
305
|
-
const spec = resolveSpecification(input);
|
|
306
|
-
validateSpec(spec);
|
|
307
|
-
if (!Number.isFinite(length) || length <= spec.pitch + spec.underHeadRadius) {
|
|
308
|
-
throw new Error(
|
|
309
|
-
"Screw length must leave room for at least one full thread pitch."
|
|
310
|
-
);
|
|
311
|
-
}
|
|
312
|
-
const headChamfer = Math.min(spec.pitch / 2, spec.headHeight * 0.12);
|
|
313
|
-
const headBarrel = cylinder(
|
|
314
|
-
spec.headDiameter / 2,
|
|
315
|
-
spec.headHeight - headChamfer
|
|
316
|
-
);
|
|
317
|
-
const headTop = frustum(
|
|
318
|
-
spec.headDiameter / 2,
|
|
319
|
-
spec.headDiameter / 2 - headChamfer,
|
|
320
|
-
headChamfer
|
|
321
|
-
).relate((top) => top.on(headBarrel.up));
|
|
322
|
-
const headBlank = union([headBarrel, headTop]);
|
|
323
|
-
const socketToolY = spec.hexSocketDepth + 0.2;
|
|
324
|
-
const socketTool = regularPrism(
|
|
325
|
-
spec.hexSocketWidth / Math.sqrt(3),
|
|
326
|
-
socketToolY,
|
|
327
|
-
6,
|
|
328
|
-
30
|
|
329
|
-
).relate(
|
|
330
|
-
(tool) => tool.center.on(headBlank.up).offset(0, -spec.hexSocketDepth / 2 + 0.1, 0)
|
|
331
|
-
);
|
|
332
|
-
const head = cut(headBlank, [socketTool]);
|
|
333
|
-
const transition = frustum(
|
|
334
|
-
spec.nominalDiameter / 2,
|
|
335
|
-
spec.nominalDiameter / 2 + spec.underHeadRadius,
|
|
336
|
-
spec.underHeadRadius
|
|
337
|
-
).relate((part) => part.on(head.down));
|
|
338
|
-
const bodyLength = length - spec.underHeadRadius;
|
|
339
|
-
const threadedLength = Math.min(bodyLength, threadLength(spec, length));
|
|
340
|
-
const plainLength = bodyLength - threadedLength;
|
|
341
|
-
const overlap = Math.min(0.08, spec.pitch / 10);
|
|
342
|
-
const parts = [head, transition];
|
|
343
|
-
let previous = transition;
|
|
344
|
-
if (plainLength > overlap) {
|
|
345
|
-
const shank = cylinder(
|
|
346
|
-
spec.nominalDiameter / 2,
|
|
347
|
-
plainLength + overlap
|
|
348
|
-
).relate((part) => part.on(previous.down).offset(0, -overlap, 0));
|
|
349
|
-
parts.push(shank);
|
|
350
|
-
previous = shank;
|
|
351
|
-
}
|
|
352
|
-
const fundamentalHeight = Math.sqrt(3) / 2 * spec.pitch;
|
|
353
|
-
const minorDiameter = spec.nominalDiameter - 2 * (5 / 8 * fundamentalHeight);
|
|
354
|
-
const thread = helicalThread({
|
|
355
|
-
pitch: spec.pitch,
|
|
356
|
-
y: threadedLength + overlap,
|
|
357
|
-
majorDiameter: spec.nominalDiameter,
|
|
358
|
-
minorDiameter,
|
|
359
|
-
rootWidth: 3 / 4 * spec.pitch,
|
|
360
|
-
crestWidth: 1 / 8 * spec.pitch
|
|
361
|
-
}).relate((part) => part.on(previous.down).offset(0, -overlap, 0));
|
|
362
|
-
parts.push(thread);
|
|
363
|
-
return union(parts).expose({
|
|
364
|
-
headTop: head.up,
|
|
365
|
-
headBottom: head.down,
|
|
366
|
-
shankTop: transition.up,
|
|
367
|
-
shankBottom: thread.down,
|
|
368
|
-
shankAxis: thread.axis
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
__name(screw, "screw");
|
|
372
|
-
function clearanceHole(input, optionsOrDepth) {
|
|
373
|
-
const options = typeof optionsOrDepth === "number" ? { depth: optionsOrDepth } : optionsOrDepth;
|
|
374
|
-
const spec = resolveSpecification(input);
|
|
375
|
-
validateSpec(spec);
|
|
376
|
-
if (!Number.isFinite(options.depth) || options.depth <= 0) {
|
|
377
|
-
throw new Error("Hole depth must be a positive finite number.");
|
|
378
|
-
}
|
|
379
|
-
const fit = options.fit ?? "normal";
|
|
380
|
-
const diameter = options.diameter ?? spec.clearance[fit];
|
|
381
|
-
if (!Number.isFinite(diameter) || diameter <= spec.nominalDiameter) {
|
|
382
|
-
throw new Error(
|
|
383
|
-
"Clearance-hole diameter must exceed the nominal screw diameter."
|
|
384
|
-
);
|
|
385
|
-
}
|
|
386
|
-
const shaft = cylinder(diameter / 2, options.depth);
|
|
387
|
-
const counterboreOption = options.counterbore ?? true;
|
|
388
|
-
if (counterboreOption === false) {
|
|
389
|
-
return shaft.expose({
|
|
390
|
-
shaftTop: shaft.up,
|
|
391
|
-
shaftBottom: shaft.down,
|
|
392
|
-
shaftAxis: shaft.axis
|
|
393
|
-
});
|
|
394
|
-
}
|
|
395
|
-
const counterbore = counterboreOption === true ? {} : counterboreOption;
|
|
396
|
-
const axialClearance = counterbore.axialClearance ?? 0.5;
|
|
397
|
-
const counterboreDepth = counterbore.depth ?? spec.headHeight + axialClearance;
|
|
398
|
-
const counterboreDiameter = counterbore.diameter ?? spec.counterboreDiameter;
|
|
399
|
-
if (!Number.isFinite(counterboreDepth) || counterboreDepth <= 0 || counterboreDepth > options.depth) {
|
|
400
|
-
throw new Error("Counterbore depth must be within the total hole depth.");
|
|
401
|
-
}
|
|
402
|
-
if (!Number.isFinite(counterboreDiameter) || counterboreDiameter < spec.headDiameter) {
|
|
403
|
-
throw new Error("Counterbore diameter must accommodate the screw head.");
|
|
404
|
-
}
|
|
405
|
-
const recess = cylinder(
|
|
406
|
-
counterboreDiameter / 2,
|
|
407
|
-
counterboreDepth + 0.2
|
|
408
|
-
).relate(
|
|
409
|
-
(tool) => tool.center.on(shaft.up).offset(0, -counterboreDepth / 2 + 0.1, 0)
|
|
410
|
-
);
|
|
411
|
-
return union([shaft, recess]).expose({
|
|
412
|
-
shaftTop: shaft.up,
|
|
413
|
-
shaftBottom: shaft.down,
|
|
414
|
-
shaftAxis: shaft.axis,
|
|
415
|
-
counterboreTop: recess.up,
|
|
416
|
-
counterboreBottom: recess.down
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
__name(clearanceHole, "clearanceHole");
|
|
420
|
-
function resolveSpecification(input) {
|
|
421
|
-
return typeof input === "string" ? specifications[input] : input;
|
|
422
|
-
}
|
|
423
|
-
__name(resolveSpecification, "resolveSpecification");
|
|
424
|
-
function threadLength(spec, length) {
|
|
425
|
-
if (length <= 125) return 2 * spec.nominalDiameter + 12;
|
|
426
|
-
if (length <= 200) return 2 * spec.nominalDiameter + 18;
|
|
427
|
-
return 2 * spec.nominalDiameter + 31;
|
|
428
|
-
}
|
|
429
|
-
__name(threadLength, "threadLength");
|
|
430
|
-
function validateSpec(spec) {
|
|
431
|
-
const values = [
|
|
432
|
-
spec.nominalDiameter,
|
|
433
|
-
spec.pitch,
|
|
434
|
-
spec.headDiameter,
|
|
435
|
-
spec.headHeight,
|
|
436
|
-
spec.hexSocketWidth,
|
|
437
|
-
spec.hexSocketDepth,
|
|
438
|
-
spec.underHeadRadius,
|
|
439
|
-
spec.clearance.close,
|
|
440
|
-
spec.clearance.normal,
|
|
441
|
-
spec.clearance.loose,
|
|
442
|
-
spec.counterboreDiameter
|
|
443
|
-
];
|
|
444
|
-
if (values.some((value) => !Number.isFinite(value) || value <= 0)) {
|
|
445
|
-
throw new Error(
|
|
446
|
-
"Fastener specifications must contain positive finite dimensions."
|
|
447
|
-
);
|
|
448
|
-
}
|
|
449
|
-
if (spec.headDiameter <= spec.nominalDiameter) {
|
|
450
|
-
throw new Error("Head diameter must exceed the nominal thread diameter.");
|
|
451
|
-
}
|
|
452
|
-
if (spec.hexSocketDepth >= spec.headHeight) {
|
|
453
|
-
throw new Error("Hex socket depth must be smaller than the head height.");
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
__name(validateSpec, "validateSpec");
|
|
5
|
+
gb_818_exports
|
|
6
|
+
} from "../chunks/chunk-ESLSQKZW.js";
|
|
7
|
+
import {
|
|
8
|
+
gb_2672_exports
|
|
9
|
+
} from "../chunks/chunk-GAX6375G.js";
|
|
10
|
+
import {
|
|
11
|
+
gb_80_exports
|
|
12
|
+
} from "../chunks/chunk-ES62SR3Q.js";
|
|
13
|
+
import {
|
|
14
|
+
gb_5281_exports
|
|
15
|
+
} from "../chunks/chunk-HPPYZYCK.js";
|
|
16
|
+
import {
|
|
17
|
+
iso_7045_exports
|
|
18
|
+
} from "../chunks/chunk-7UGU5EFV.js";
|
|
19
|
+
import {
|
|
20
|
+
iso_14583_exports
|
|
21
|
+
} from "../chunks/chunk-SPFHOFBC.js";
|
|
22
|
+
import {
|
|
23
|
+
iso_7379_exports
|
|
24
|
+
} from "../chunks/chunk-VVX3WOBG.js";
|
|
25
|
+
import {
|
|
26
|
+
gb_70_1_exports
|
|
27
|
+
} from "../chunks/chunk-PFFNLWWR.js";
|
|
28
|
+
import {
|
|
29
|
+
gb_70_2_exports
|
|
30
|
+
} from "../chunks/chunk-W62ASGIP.js";
|
|
31
|
+
import {
|
|
32
|
+
gb_70_3_exports
|
|
33
|
+
} from "../chunks/chunk-ZNWKI54A.js";
|
|
34
|
+
import {
|
|
35
|
+
gb_70_4_exports
|
|
36
|
+
} from "../chunks/chunk-SDYJF2XK.js";
|
|
37
|
+
import {
|
|
38
|
+
gb_5782_exports
|
|
39
|
+
} from "../chunks/chunk-4FMUSJBB.js";
|
|
40
|
+
import {
|
|
41
|
+
iso_4762_exports
|
|
42
|
+
} from "../chunks/chunk-MEIKYZ23.js";
|
|
43
|
+
import {
|
|
44
|
+
iso_10642_exports
|
|
45
|
+
} from "../chunks/chunk-IXFHRZSY.js";
|
|
46
|
+
import {
|
|
47
|
+
iso_7380_1_exports
|
|
48
|
+
} from "../chunks/chunk-2DGVQRQ5.js";
|
|
49
|
+
import {
|
|
50
|
+
iso_4017_exports
|
|
51
|
+
} from "../chunks/chunk-P3M5KQ5U.js";
|
|
52
|
+
import {
|
|
53
|
+
iso_4014_exports
|
|
54
|
+
} from "../chunks/chunk-SDUJLXOE.js";
|
|
55
|
+
import "../chunks/chunk-GIIOR3XJ.js";
|
|
56
|
+
import {
|
|
57
|
+
iso_7380_2_exports
|
|
58
|
+
} from "../chunks/chunk-SGDNOA44.js";
|
|
59
|
+
import {
|
|
60
|
+
iso_4029_exports
|
|
61
|
+
} from "../chunks/chunk-O34BMYJV.js";
|
|
62
|
+
import "../chunks/chunk-Z5LEGL77.js";
|
|
457
63
|
export {
|
|
458
|
-
|
|
64
|
+
gb_2672_exports as GB2672,
|
|
65
|
+
gb_5281_exports as GB5281,
|
|
66
|
+
gb_5782_exports as GB5782,
|
|
67
|
+
gb_5783_exports as GB5783,
|
|
68
|
+
gb_70_1_exports as GB70_1,
|
|
69
|
+
gb_70_2_exports as GB70_2,
|
|
70
|
+
gb_70_3_exports as GB70_3,
|
|
71
|
+
gb_70_4_exports as GB70_4,
|
|
72
|
+
gb_80_exports as GB80,
|
|
73
|
+
gb_818_exports as GB818,
|
|
74
|
+
iso_10642_exports as ISO10642,
|
|
75
|
+
iso_14583_exports as ISO14583,
|
|
76
|
+
iso_4014_exports as ISO4014,
|
|
77
|
+
iso_4017_exports as ISO4017,
|
|
78
|
+
iso_4029_exports as ISO4029,
|
|
79
|
+
iso_4762_exports as ISO4762,
|
|
80
|
+
iso_7045_exports as ISO7045,
|
|
81
|
+
iso_7379_exports as ISO7379,
|
|
82
|
+
iso_7380_1_exports as ISO7380_1,
|
|
83
|
+
iso_7380_2_exports as ISO7380_2
|
|
459
84
|
};
|
|
460
85
|
//# sourceMappingURL=index.js.map
|
package/bld/library/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [
|
|
4
|
-
"sourcesContent": ["import {\n cylinder,\n cut,\n frustum,\n regularPrism,\n union,\n type CanonicalElements,\n type Bound,\n type LineAnchor,\n type SolidModel,\n} from '@code3d/core';\nimport {helicalThread} from './thread.js';\n\nexport type ClearanceFit = 'close' | 'normal' | 'loose';\n\nexport type Specification = Readonly<{\n designation: string;\n nominalDiameter: number;\n pitch: number;\n headDiameter: number;\n headHeight: number;\n hexSocketWidth: number;\n hexSocketDepth: number;\n underHeadRadius: number;\n clearance: Readonly<Record<ClearanceFit, number>>;\n counterboreDiameter: number;\n}>;\n\n// ISO 4762 coarse-thread socket-head cap screws; millimetres.\n// Clearance series follow ISO 273. Counterbores follow DIN 974-1 normal series.\nexport const specifications = {\n M3: {\n designation: 'M3',\n nominalDiameter: 3,\n pitch: 0.5,\n headDiameter: 5.5,\n headHeight: 3,\n hexSocketWidth: 2.5,\n hexSocketDepth: 1.3,\n underHeadRadius: 0.1,\n clearance: {close: 3.2, normal: 3.4, loose: 3.6},\n counterboreDiameter: 6,\n },\n M4: {\n designation: 'M4',\n nominalDiameter: 4,\n pitch: 0.7,\n headDiameter: 7,\n headHeight: 4,\n hexSocketWidth: 3,\n hexSocketDepth: 2,\n underHeadRadius: 0.2,\n clearance: {close: 4.3, normal: 4.5, loose: 4.8},\n counterboreDiameter: 8,\n },\n M5: {\n designation: 'M5',\n nominalDiameter: 5,\n pitch: 0.8,\n headDiameter: 8.5,\n headHeight: 5,\n hexSocketWidth: 4,\n hexSocketDepth: 2.5,\n underHeadRadius: 0.2,\n clearance: {close: 5.3, normal: 5.5, loose: 5.8},\n counterboreDiameter: 10,\n },\n M6: {\n designation: 'M6',\n nominalDiameter: 6,\n pitch: 1,\n headDiameter: 10,\n headHeight: 6,\n hexSocketWidth: 5,\n hexSocketDepth: 3,\n underHeadRadius: 0.25,\n clearance: {close: 6.4, normal: 6.6, loose: 7},\n counterboreDiameter: 11,\n },\n M8: {\n designation: 'M8',\n nominalDiameter: 8,\n pitch: 1.25,\n headDiameter: 13,\n headHeight: 8,\n hexSocketWidth: 6,\n hexSocketDepth: 4,\n underHeadRadius: 0.4,\n clearance: {close: 8.4, normal: 9, loose: 10},\n counterboreDiameter: 15,\n },\n M10: {\n designation: 'M10',\n nominalDiameter: 10,\n pitch: 1.5,\n headDiameter: 16,\n headHeight: 10,\n hexSocketWidth: 8,\n hexSocketDepth: 5,\n underHeadRadius: 0.4,\n clearance: {close: 10.5, normal: 11, loose: 12},\n counterboreDiameter: 18,\n },\n M12: {\n designation: 'M12',\n nominalDiameter: 12,\n pitch: 1.75,\n headDiameter: 18,\n headHeight: 12,\n hexSocketWidth: 10,\n hexSocketDepth: 6,\n underHeadRadius: 0.6,\n clearance: {close: 13, normal: 13.5, loose: 14.5},\n counterboreDiameter: 20,\n },\n} as const satisfies Readonly<Record<string, Specification>>;\n\nexport type Size = keyof typeof specifications;\nexport type ScrewInput = Size | Specification;\n\nexport type CounterboreOptions = Readonly<{\n diameter?: number;\n depth?: number;\n axialClearance?: number;\n}>;\n\nexport type ClearanceHoleOptions = Readonly<{\n depth: number;\n fit?: ClearanceFit;\n diameter?: number;\n counterbore?: boolean | CounterboreOptions;\n}>;\n\nexport type PlainClearanceHoleOptions = ClearanceHoleOptions &\n Readonly<{\n counterbore: false;\n }>;\n\nexport type CounterboredHoleOptions = Omit<\n ClearanceHoleOptions,\n 'counterbore'\n> &\n Readonly<{\n counterbore?: true | CounterboreOptions;\n }>;\n\nexport type SocketCapScrewElements = CanonicalElements &\n Readonly<{\n headTop: Bound;\n headBottom: Bound;\n shankTop: Bound;\n shankBottom: Bound;\n shankAxis: LineAnchor;\n }>;\n\nexport type SocketCapHoleElements = CanonicalElements &\n Readonly<{\n shaftTop: Bound;\n shaftBottom: Bound;\n shaftAxis: LineAnchor;\n }>;\n\nexport type CounterboredSocketCapHoleElements = SocketCapHoleElements &\n Readonly<{\n counterboreTop: Bound;\n counterboreBottom: Bound;\n }>;\n\nexport type Screw = SolidModel<SocketCapScrewElements>;\nexport type ClearanceHole = SolidModel<SocketCapHoleElements>;\nexport type CounterboredHole = SolidModel<CounterboredSocketCapHoleElements>;\n\n/**\n * @code3d.arguments ['M6', 18]\n * @code3d.arguments ['M8', 30]\n * @code3d.param length {kind: 'length'}\n */\nexport function screw(input: ScrewInput, length: number): Screw {\n const spec = resolveSpecification(input);\n validateSpec(spec);\n if (!Number.isFinite(length) || length <= spec.pitch + spec.underHeadRadius) {\n throw new Error(\n 'Screw length must leave room for at least one full thread pitch.',\n );\n }\n\n const headChamfer = Math.min(spec.pitch / 2, spec.headHeight * 0.12);\n const headBarrel = cylinder(\n spec.headDiameter / 2,\n spec.headHeight - headChamfer,\n );\n const headTop = frustum(\n spec.headDiameter / 2,\n spec.headDiameter / 2 - headChamfer,\n headChamfer,\n ).relate(top => top.on(headBarrel.up));\n const headBlank = union([headBarrel, headTop]);\n\n const socketToolY = spec.hexSocketDepth + 0.2;\n const socketTool = regularPrism(\n spec.hexSocketWidth / Math.sqrt(3),\n socketToolY,\n 6,\n 30,\n ).relate(tool =>\n tool.center.on(headBlank.up).offset(0, -spec.hexSocketDepth / 2 + 0.1, 0),\n );\n const head = cut(headBlank, [socketTool]);\n\n const transition = frustum(\n spec.nominalDiameter / 2,\n spec.nominalDiameter / 2 + spec.underHeadRadius,\n spec.underHeadRadius,\n ).relate(part => part.on(head.down));\n const bodyLength = length - spec.underHeadRadius;\n const threadedLength = Math.min(bodyLength, threadLength(spec, length));\n const plainLength = bodyLength - threadedLength;\n const overlap = Math.min(0.08, spec.pitch / 10);\n const parts = [head, transition];\n let previous = transition;\n\n if (plainLength > overlap) {\n const shank = cylinder(\n spec.nominalDiameter / 2,\n plainLength + overlap,\n ).relate(part => part.on(previous.down).offset(0, -overlap, 0));\n parts.push(shank);\n previous = shank;\n }\n\n const fundamentalHeight = (Math.sqrt(3) / 2) * spec.pitch;\n const minorDiameter =\n spec.nominalDiameter - 2 * ((5 / 8) * fundamentalHeight);\n const thread = helicalThread({\n pitch: spec.pitch,\n y: threadedLength + overlap,\n majorDiameter: spec.nominalDiameter,\n minorDiameter,\n rootWidth: (3 / 4) * spec.pitch,\n crestWidth: (1 / 8) * spec.pitch,\n }).relate(part => part.on(previous.down).offset(0, -overlap, 0));\n parts.push(thread);\n\n return union(parts).expose({\n headTop: head.up,\n headBottom: head.down,\n shankTop: transition.up,\n shankBottom: thread.down,\n shankAxis: thread.axis,\n });\n}\n\n/**\n * @code3d.arguments ['M6', 10]\n * @code3d.arguments ['M6', {depth: 10, counterbore: false}]\n * @code3d.param depth {kind: 'length', constraints: {exclusiveMin: 0}}\n */\nexport function clearanceHole(\n input: ScrewInput,\n depth: number,\n): CounterboredHole;\nexport function clearanceHole(\n input: ScrewInput,\n options: PlainClearanceHoleOptions,\n): ClearanceHole;\nexport function clearanceHole(\n input: ScrewInput,\n options: CounterboredHoleOptions,\n): CounterboredHole;\nexport function clearanceHole(\n input: ScrewInput,\n options: ClearanceHoleOptions,\n): ClearanceHole | CounterboredHole;\nexport function clearanceHole(\n input: ScrewInput,\n optionsOrDepth: ClearanceHoleOptions | number,\n): ClearanceHole | CounterboredHole {\n const options: ClearanceHoleOptions =\n typeof optionsOrDepth === 'number'\n ? {depth: optionsOrDepth}\n : optionsOrDepth;\n const spec = resolveSpecification(input);\n validateSpec(spec);\n if (!Number.isFinite(options.depth) || options.depth <= 0) {\n throw new Error('Hole depth must be a positive finite number.');\n }\n const fit = options.fit ?? 'normal';\n const diameter = options.diameter ?? spec.clearance[fit];\n if (!Number.isFinite(diameter) || diameter <= spec.nominalDiameter) {\n throw new Error(\n 'Clearance-hole diameter must exceed the nominal screw diameter.',\n );\n }\n const shaft = cylinder(diameter / 2, options.depth);\n const counterboreOption = options.counterbore ?? true;\n if (counterboreOption === false) {\n return shaft.expose({\n shaftTop: shaft.up,\n shaftBottom: shaft.down,\n shaftAxis: shaft.axis,\n });\n }\n\n const counterbore = counterboreOption === true ? {} : counterboreOption;\n const axialClearance = counterbore.axialClearance ?? 0.5;\n const counterboreDepth =\n counterbore.depth ?? spec.headHeight + axialClearance;\n const counterboreDiameter = counterbore.diameter ?? spec.counterboreDiameter;\n if (\n !Number.isFinite(counterboreDepth) ||\n counterboreDepth <= 0 ||\n counterboreDepth > options.depth\n ) {\n throw new Error('Counterbore depth must be within the total hole depth.');\n }\n if (\n !Number.isFinite(counterboreDiameter) ||\n counterboreDiameter < spec.headDiameter\n ) {\n throw new Error('Counterbore diameter must accommodate the screw head.');\n }\n const recess = cylinder(\n counterboreDiameter / 2,\n counterboreDepth + 0.2,\n ).relate(tool =>\n tool.center.on(shaft.up).offset(0, -counterboreDepth / 2 + 0.1, 0),\n );\n return union([shaft, recess]).expose({\n shaftTop: shaft.up,\n shaftBottom: shaft.down,\n shaftAxis: shaft.axis,\n counterboreTop: recess.up,\n counterboreBottom: recess.down,\n });\n}\n\nexport function resolveSpecification(input: ScrewInput): Specification {\n return typeof input === 'string' ? specifications[input] : input;\n}\n\nexport function threadLength(spec: Specification, length: number): number {\n if (length <= 125) return 2 * spec.nominalDiameter + 12;\n if (length <= 200) return 2 * spec.nominalDiameter + 18;\n return 2 * spec.nominalDiameter + 31;\n}\n\nfunction validateSpec(spec: Specification): void {\n const values = [\n spec.nominalDiameter,\n spec.pitch,\n spec.headDiameter,\n spec.headHeight,\n spec.hexSocketWidth,\n spec.hexSocketDepth,\n spec.underHeadRadius,\n spec.clearance.close,\n spec.clearance.normal,\n spec.clearance.loose,\n spec.counterboreDiameter,\n ];\n if (values.some(value => !Number.isFinite(value) || value <= 0)) {\n throw new Error(\n 'Fastener specifications must contain positive finite dimensions.',\n );\n }\n if (spec.headDiameter <= spec.nominalDiameter) {\n throw new Error('Head diameter must exceed the nominal thread diameter.');\n }\n if (spec.hexSocketDepth >= spec.headHeight) {\n throw new Error('Hex socket depth must be smaller than the head height.');\n }\n}\n", "import {\n definePrimitive,\n replicad,\n type Drawing,\n type Face,\n type Shape3D,\n type Sketch,\n} from '@code3d/core/replicad';\n\nconst {Plane, draw, makeCylinder, makeHelix, makeSolid, weldShellsAndFaces} =\n replicad;\n\ntype HelicalThreadOptions = Readonly<{\n pitch: number;\n y: number;\n majorDiameter: number;\n minorDiameter: number;\n rootWidth: number;\n crestWidth: number;\n leftHanded?: boolean;\n}>;\n\nconst loopSteps = Array.from({length: 21}, (_, index) => index / 20);\n\nexport const helicalThread = definePrimitive(\n (options: HelicalThreadOptions) => {\n validateHelicalThread(options);\n const {\n majorDiameter,\n minorDiameter,\n leftHanded = false,\n ...dimensions\n } = options;\n return makeHelicalThreadShape({\n ...dimensions,\n majorRadius: majorDiameter / 2,\n minorRadius: minorDiameter / 2,\n leftHanded,\n });\n },\n);\n\nfunction validateHelicalThread({\n pitch,\n y,\n majorDiameter,\n minorDiameter,\n rootWidth,\n crestWidth,\n}: HelicalThreadOptions): void {\n assertPositive('pitch', pitch);\n assertPositive('y', y);\n assertPositive('majorDiameter', majorDiameter);\n assertPositive('minorDiameter', minorDiameter);\n assertPositive('rootWidth', rootWidth);\n assertPositive('crestWidth', crestWidth);\n if (y < pitch) {\n throw new Error('y must be at least one thread pitch.');\n }\n if (minorDiameter >= majorDiameter) {\n throw new Error('minorDiameter must be smaller than majorDiameter.');\n }\n if (crestWidth >= rootWidth || rootWidth > pitch) {\n throw new Error(\n 'The thread profile requires crestWidth < rootWidth <= pitch.',\n );\n }\n}\n\ntype HelicalThreadShapeOptions = Readonly<{\n pitch: number;\n y: number;\n majorRadius: number;\n minorRadius: number;\n rootWidth: number;\n crestWidth: number;\n leftHanded: boolean;\n}>;\n\n/**\n * Builds a closed external thread around its minor-diameter core. The lofted\n * end treatment follows the MIT-licensed replicad-threads construction by\n * Steve Genoud, adapted here to code3d's Y-axis and geometry ownership model.\n */\nfunction makeHelicalThreadShape({\n pitch,\n y,\n majorRadius,\n minorRadius,\n rootWidth,\n crestWidth,\n leftHanded,\n}: HelicalThreadShapeOptions): Shape3D {\n const toothHeight = majorRadius - minorRadius;\n const profile = threadProfile(rootWidth, crestWidth, toothHeight);\n const teeth = fadedThread(pitch, minorRadius, y, profile, leftHanded);\n const core = makeCylinder(minorRadius + 0.05, y);\n const threaded = core.fuse(teeth);\n core.delete();\n teeth.delete();\n return threaded.rotate(-90, [0, 0, 0], [1, 0, 0]).translate([0, -y / 2, 0]);\n}\n\nfunction threadProfile(\n rootWidth: number,\n crestWidth: number,\n toothHeight: number,\n): Drawing {\n const rootHalf = rootWidth / 2;\n const crestHalf = crestWidth / 2;\n return draw([rootHalf, -0.05])\n .vLine(0.05)\n .lineTo([crestHalf, toothHeight])\n .hLineTo(-crestHalf)\n .lineTo([-rootHalf, 0])\n .vLine(-0.05)\n .close();\n}\n\nfunction fadedThread(\n pitch: number,\n radius: number,\n length: number,\n profile: Drawing,\n leftHanded: boolean,\n): Shape3D {\n const bottomEnd = fadedEnd(pitch, radius, profile, true, leftHanded);\n const totalLoops = length / pitch - 0.5;\n const fullLoops = Math.floor(totalLoops);\n const leftover = totalLoops - fullLoops;\n const singleLoop = basicThreadLoop(\n pitch,\n radius,\n profile,\n 1,\n 'none',\n leftHanded,\n );\n const shells = Array.from({length: fullLoops}, (_, index) =>\n singleLoop.clone().translate([0, 0, index * pitch]),\n );\n singleLoop.delete();\n if (leftover > 1e-9) {\n shells.push(\n basicThreadLoop(\n pitch,\n radius,\n profile,\n leftover,\n 'none',\n leftHanded,\n ).translate([0, 0, fullLoops * pitch]),\n );\n }\n const topEnd = fadedEnd(pitch, radius, profile, false, leftHanded)\n .translate([0, 0, totalLoops * pitch])\n .rotate(360 * leftover, [0, 0, 0], [0, 0, 1]);\n const thread = makeSolid([bottomEnd, ...shells, topEnd]).translate([\n 0,\n 0,\n pitch / 4,\n ]);\n bottomEnd.delete();\n shells.forEach(shell => shell.delete());\n topEnd.delete();\n return thread;\n}\n\nfunction basicThreadLoop(\n pitch: number,\n radius: number,\n profile: Drawing,\n loopFraction: number,\n includeEnd: 'none' | 'first' | 'last' | 'both',\n leftHanded: boolean,\n) {\n const helix = makeHelix(\n pitch,\n pitch * clamp(loopFraction, 0, 1),\n radius,\n [0, 0, 0],\n [0, 0, 1],\n leftHanded,\n );\n const profiles = loopSteps.map(step => {\n const position = helix.pointAt(step);\n const tangent = helix.tangentAt(step);\n const plane = new Plane(position, [0, 0, 1], tangent);\n const sketch = profile.sketchOnPlane(plane) as Sketch;\n plane.delete();\n return sketch;\n });\n helix.delete();\n\n const ends: Face[] = [];\n if (includeEnd === 'first' || includeEnd === 'both') {\n ends.push(profiles[0].faces());\n }\n if (includeEnd === 'last' || includeEnd === 'both') {\n const face = profiles.at(-1)!.faces();\n face.wrapped.Reverse();\n ends.push(face);\n }\n const shell = profiles[0].loftWith(profiles.slice(1), {ruled: false}, true);\n if (ends.length === 0) return shell;\n const closed = weldShellsAndFaces([shell, ...ends]);\n shell.delete();\n ends.forEach(face => face.delete());\n return closed;\n}\n\nfunction fadedEnd(\n pitch: number,\n radius: number,\n profile: Drawing,\n bottom: boolean,\n leftHanded: boolean,\n) {\n const length = pitch / 4;\n const helix = makeHelix(\n pitch,\n length,\n radius,\n [0, 0, 0],\n [0, 0, bottom ? -1 : 1],\n leftHanded,\n );\n const profiles = loopSteps.map((step, index) => {\n const position = helix.pointAt(step);\n let tangent = helix.tangentAt(step);\n if (bottom) tangent = tangent.multiply(-1);\n const plane = new Plane(position, [0, 0, 1], tangent);\n const sketch = profile\n .scale((loopSteps.length - index) / loopSteps.length, [0, 0])\n .sketchOnPlane(plane) as Sketch;\n plane.delete();\n return sketch;\n });\n helix.delete();\n const endFace = profiles.at(-1)!.faces();\n const shell = profiles[0].loftWith(profiles.slice(1), {ruled: false}, true);\n const closed = weldShellsAndFaces([shell, endFace]);\n shell.delete();\n endFace.delete();\n return bottom ? closed.rotate(180, [0, 0, 0], [0, 0, 1]) : closed;\n}\n\nfunction assertPositive(name: string, value: number): void {\n if (!Number.isFinite(value) || value <= 0) {\n throw new Error(`${name} must be a positive finite number.`);\n }\n}\n\nfunction clamp(value: number, minimum: number, maximum: number): number {\n return Math.min(Math.max(value, minimum), maximum);\n}\n"],
|
|
5
|
-
"mappings": "
|
|
3
|
+
"sources": [],
|
|
4
|
+
"sourcesContent": [],
|
|
5
|
+
"mappings": "",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type SolidModel } from '@code3d/core';
|
|
2
|
+
import { type HeadSpecification, type Screw, type ClearanceHole, type HoleElements, type ClearanceHoleOptions as CommonHoleOptions } from './common.js';
|
|
3
|
+
export type { ClearanceFit, Screw, ScrewElements, ClearanceHole, HoleElements, } from './common.js';
|
|
4
|
+
import type { Bound } from '@code3d/core';
|
|
5
|
+
export type Specification = HeadSpecification & Readonly<{
|
|
6
|
+
hexSocketWidth: number;
|
|
7
|
+
hexSocketDepth: number;
|
|
8
|
+
headAngle: 90;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const specifications: {
|
|
11
|
+
readonly M3: Specification;
|
|
12
|
+
readonly M4: Specification;
|
|
13
|
+
readonly M5: Specification;
|
|
14
|
+
readonly M6: Specification;
|
|
15
|
+
readonly M8: Specification;
|
|
16
|
+
readonly M10: Specification;
|
|
17
|
+
readonly M12: Specification;
|
|
18
|
+
};
|
|
19
|
+
export type Size = keyof typeof specifications;
|
|
20
|
+
export type ScrewInput = Size | Specification;
|
|
21
|
+
export type CountersinkOptions = Readonly<{
|
|
22
|
+
diameter?: number;
|
|
23
|
+
}>;
|
|
24
|
+
export type ClearanceHoleOptions = Omit<CommonHoleOptions, 'counterbore'> & Readonly<{
|
|
25
|
+
countersink?: boolean | CountersinkOptions;
|
|
26
|
+
}>;
|
|
27
|
+
export type PlainHoleOptions = ClearanceHoleOptions & Readonly<{
|
|
28
|
+
countersink: false;
|
|
29
|
+
}>;
|
|
30
|
+
export type CountersunkHoleOptions = ClearanceHoleOptions & Readonly<{
|
|
31
|
+
countersink?: true | CountersinkOptions;
|
|
32
|
+
}>;
|
|
33
|
+
export type CountersunkHoleElements = HoleElements & Readonly<{
|
|
34
|
+
countersinkTop: Bound;
|
|
35
|
+
countersinkBottom: Bound;
|
|
36
|
+
}>;
|
|
37
|
+
export type CountersunkHole = SolidModel<CountersunkHoleElements>;
|
|
38
|
+
export declare function resolveSpecification(input: ScrewInput): Specification;
|
|
39
|
+
export declare function threadLength(spec: Specification, length: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Length includes the countersunk head.
|
|
42
|
+
* @code3d.arguments ['M6', 20]
|
|
43
|
+
* @code3d.param length {kind: 'length'}
|
|
44
|
+
*/
|
|
45
|
+
export declare function screw(input: ScrewInput, length: number): Screw;
|
|
46
|
+
/** @code3d.arguments ['M6', 10] */
|
|
47
|
+
export declare function clearanceHole(input: ScrewInput, depth: number): CountersunkHole;
|
|
48
|
+
export declare function clearanceHole(input: ScrewInput, options: PlainHoleOptions): ClearanceHole;
|
|
49
|
+
export declare function clearanceHole(input: ScrewInput, options: CountersunkHoleOptions): CountersunkHole;
|
|
50
|
+
export declare function clearanceHole(input: ScrewInput, options: ClearanceHoleOptions): ClearanceHole | CountersunkHole;
|
|
51
|
+
//# sourceMappingURL=iso-10642.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iso-10642.d.ts","sourceRoot":"","sources":["../../src/library/iso-10642.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,UAAU,EAAC,MAAM,cAAc,CAAC;AAC7D,OAAO,EASL,KAAK,iBAAiB,EACtB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,oBAAoB,IAAI,iBAAiB,EAC/C,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,YAAY,EACZ,KAAK,EACL,aAAa,EACb,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AAExC,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAC3C,QAAQ,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,EAAE,CAAA;CAAC,CAAC,CAAC;AAqB5E,eAAO,MAAM,cAAc;aACzB,EAAE;aACF,EAAE;aACF,EAAE;aACF,EAAE;aACF,EAAE;aACF,GAAG;aACH,GAAG;CACK,CAAC;AACX,MAAM,MAAM,IAAI,GAAG,MAAM,OAAO,cAAc,CAAC;AAC/C,MAAM,MAAM,UAAU,GAAG,IAAI,GAAG,aAAa,CAAC;AAC9C,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAC,CAAC,CAAC;AAC/D,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC,GACvE,QAAQ,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,GAAG,kBAAkB,CAAA;CAAC,CAAC,CAAC;AACzD,MAAM,MAAM,gBAAgB,GAAG,oBAAoB,GACjD,QAAQ,CAAC;IAAC,WAAW,EAAE,KAAK,CAAA;CAAC,CAAC,CAAC;AACjC,MAAM,MAAM,sBAAsB,GAAG,oBAAoB,GACvD,QAAQ,CAAC;IAAC,WAAW,CAAC,EAAE,IAAI,GAAG,kBAAkB,CAAA;CAAC,CAAC,CAAC;AACtD,MAAM,MAAM,uBAAuB,GAAG,YAAY,GAChD,QAAQ,CAAC;IAAC,cAAc,EAAE,KAAK,CAAC;IAAC,iBAAiB,EAAE,KAAK,CAAA;CAAC,CAAC,CAAC;AAC9D,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAElE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,aAAa,CAErE;AAWD,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAIxE;AACD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,KAAK,CAqB9D;AAED,mCAAmC;AACnC,wBAAgB,aAAa,CAC3B,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,MAAM,GACZ,eAAe,CAAC;AACnB,wBAAgB,aAAa,CAC3B,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,gBAAgB,GACxB,aAAa,CAAC;AACjB,wBAAgB,aAAa,CAC3B,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,sBAAsB,GAC9B,eAAe,CAAC;AACnB,wBAAgB,aAAa,CAC3B,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE,oBAAoB,GAC5B,aAAa,GAAG,eAAe,CAAC"}
|