jscad-electronics 0.0.207 → 0.0.209
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 +32 -2
- package/dist/index.js +1056 -878
- package/dist/index.js.map +1 -1
- package/dist/vanilla.d.ts +32 -2
- package/dist/vanilla.js +212 -44
- package/dist/vanilla.js.map +1 -1
- package/package.json +1 -1
package/dist/vanilla.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BufferGeometry } from 'three';
|
|
|
3
3
|
import * as jscadModeling from '@jscad/modeling';
|
|
4
4
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
5
|
import * as _jscad_modeling_src_geometries_types from '@jscad/modeling/src/geometries/types';
|
|
6
|
-
import { ButtonScrewModelPropsInput, CableGrommetModelPropsInput, ClampingShaftCollarModelPropsInput, CompressionSpringModelPropsInput, FlangedBushingModelPropsInput, FlatHeadScrewModelPropsInput, SpurGearModelPropsInput, HelicalGearModelPropsInput, HexBoltModelPropsInput, HexNutModelPropsInput, HexSocketBoltModelPropsInput, NemaMotorModelPropsInput, PanScrewModelPropsInput, PlainBushingModelPropsInput, ShaftCollarModelPropsInput, SheetMetalModelPropsInput, TSlotExtrusionModelPropsInput, TSlotGussetModelPropsInput, TSlotInsideCornerModelPropsInput, WormGearModelPropsInput } from '@tscircuit/modelprinter';
|
|
6
|
+
import { ButtonScrewModelPropsInput, CableGrommetModelPropsInput, ClampingShaftCollarModelPropsInput, CompressionSpringModelPropsInput, FlangedBushingModelPropsInput, FlatHeadScrewModelPropsInput, SpurGearModelPropsInput, HelicalGearModelPropsInput, HexBoltModelPropsInput, HexNutModelPropsInput, HexSocketBoltModelPropsInput, NemaMotorModelPropsInput, PanScrewModelPropsInput, PlainBushingModelPropsInput, RigidCouplerModelPropsInput, ShaftCollarModelPropsInput, SheetMetalModelPropsInput, ThreadedRodModelPropsInput, TSlotExtrusionModelPropsInput, TSlotGussetModelPropsInput, TSlotInsideCornerModelPropsInput, WormGearModelPropsInput } from '@tscircuit/modelprinter';
|
|
7
7
|
|
|
8
8
|
type VNode = {
|
|
9
9
|
type: any;
|
|
@@ -259,6 +259,17 @@ type PlainBushingProps = PlainBushingModelPropsInput & {
|
|
|
259
259
|
declare function createPlainBushingGeom(input: PlainBushingModelPropsInput): _jscad_modeling_src_geometries_types.Geom3;
|
|
260
260
|
declare function PlainBushing({ color, ...props }: PlainBushingProps): react_jsx_runtime.JSX.Element;
|
|
261
261
|
|
|
262
|
+
type RigidCouplerMesh = ShaftMountMesh;
|
|
263
|
+
/** Geometry is driven by the corresponding modelprinter schema and hole layout. */
|
|
264
|
+
declare function createRigidCouplerMesh(input: RigidCouplerModelPropsInput): RigidCouplerMesh;
|
|
265
|
+
|
|
266
|
+
type RigidCouplerProps = RigidCouplerModelPropsInput & {
|
|
267
|
+
color?: string;
|
|
268
|
+
};
|
|
269
|
+
/** Datum and mounting-hole coordinates follow the modelprinter contract. */
|
|
270
|
+
declare function createRigidCouplerGeom(input: RigidCouplerModelPropsInput): _jscad_modeling_src_geometries_types.Geom3;
|
|
271
|
+
declare function RigidCoupler({ color, ...props }: RigidCouplerProps): react_jsx_runtime.JSX.Element;
|
|
272
|
+
|
|
262
273
|
type ShaftCollarMesh = ShaftMountMesh;
|
|
263
274
|
/** Geometry is driven by the corresponding modelprinter schema and hole layout. */
|
|
264
275
|
declare function createShaftCollarMesh(input: ShaftCollarModelPropsInput): ShaftCollarMesh;
|
|
@@ -296,6 +307,25 @@ type SpurGearProps = SpurGearModelPropsInput & {
|
|
|
296
307
|
declare function createSpurGearGeom(input: SpurGearModelPropsInput): _jscad_modeling_src_geometries_types.Geom3;
|
|
297
308
|
declare function SpurGear({ color, ...props }: SpurGearProps): react_jsx_runtime.JSX.Element;
|
|
298
309
|
|
|
310
|
+
/** Indexed counterclockwise triangles in millimeters. */
|
|
311
|
+
interface ThreadedRodMesh {
|
|
312
|
+
positions: number[];
|
|
313
|
+
indices: number[];
|
|
314
|
+
}
|
|
315
|
+
/** Renderer resolution affects tessellation only, never model specifications. */
|
|
316
|
+
interface ThreadedRodMeshOptions {
|
|
317
|
+
radialSegments?: number;
|
|
318
|
+
segmentsPerPitch?: number;
|
|
319
|
+
}
|
|
320
|
+
/** Full single-start external thread, phase +X at z=0, flat chamfered ends. */
|
|
321
|
+
declare function createThreadedRodMesh(input: ThreadedRodModelPropsInput, options?: ThreadedRodMeshOptions): ThreadedRodMesh;
|
|
322
|
+
|
|
323
|
+
type ThreadedRodProps = ThreadedRodModelPropsInput & {
|
|
324
|
+
color?: string;
|
|
325
|
+
};
|
|
326
|
+
declare function createThreadedRodGeom(input: ThreadedRodModelPropsInput, resolution?: ThreadedRodMeshOptions): _jscad_modeling_src_geometries_types.Geom3;
|
|
327
|
+
declare function ThreadedRod({ color, ...props }: ThreadedRodProps): react_jsx_runtime.JSX.Element;
|
|
328
|
+
|
|
299
329
|
interface TSlotExtrusionMesh {
|
|
300
330
|
positions: number[];
|
|
301
331
|
indices: number[];
|
|
@@ -369,4 +399,4 @@ declare function createJSCADRenderer(jscad: typeof jscadModeling): {
|
|
|
369
399
|
};
|
|
370
400
|
};
|
|
371
401
|
|
|
372
|
-
export { ButtonScrew, type ButtonScrewMesh, type ButtonScrewMeshOptions, type ButtonScrewProps, CableGrommet, type CableGrommetMesh, type CableGrommetMeshOptions, type CableGrommetProps, ClampingShaftCollar, type ClampingShaftCollarMesh, type ClampingShaftCollarProps, type ColoredGeom, CompressionSpring, type CompressionSpringMesh, type CompressionSpringMeshOptions, type CompressionSpringProps, FlangedBushing, type FlangedBushingMesh, type FlangedBushingProps, FlatHeadScrew, type FlatHeadScrewMesh, type FlatHeadScrewMeshOptions, type FlatHeadScrewProps, Fragment, HelicalGear, type HelicalGearMesh, type HelicalGearProps, HexBolt, type HexBoltMesh, type HexBoltMeshOptions, type HexBoltProps, HexNut, type HexNutMesh, type HexNutMeshOptions, type HexNutProps, HexSocketBolt, type HexSocketBoltMesh, type HexSocketBoltProps, NEMA17, NEMA23, NEMA8, type NemaFrameMotorProps, NemaMotor, type NemaMotorProps, PanScrew, type PanScrewMesh, type PanScrewMeshOptions, type PanScrewProps, PlainBushing, type PlainBushingMesh, type PlainBushingProps, type RenderResult, ShaftCollar, type ShaftCollarMesh, type ShaftCollarProps, SheetMetal, type SheetMetalMesh, type SheetMetalProps, SpurGear, type SpurGearMesh, type SpurGearProps, TSlotExtrusion, type TSlotExtrusionMesh, type TSlotExtrusionProps, TSlotGusset, type TSlotGussetMesh, type TSlotGussetProps, TSlotInsideCorner, type TSlotInsideCornerMesh, type TSlotInsideCornerProps, type VNode, WormGear, type WormGearMesh, type WormGearProps, convertCSGToThreeGeom, createButtonScrewGeom, createButtonScrewMesh, createCableGrommetGeom, createCableGrommetMesh, createClampingShaftCollarGeom, createClampingShaftCollarMesh, createCompressionSpringGeom, createCompressionSpringMesh, createFlangedBushingGeom, createFlangedBushingMesh, createFlatHeadScrewGeom, createFlatHeadScrewMesh, createHelicalGearGeom, createHelicalGearMesh, createHexBoltGeom, createHexBoltMesh, createHexNutGeom, createHexNutMesh, createHexSocketBoltGeom, createHexSocketBoltMesh, createJSCADRenderer, createPanScrewGeom, createPanScrewMesh, createPlainBushingGeom, createPlainBushingMesh, createShaftCollarGeom, createShaftCollarMesh, createSheetMetalGeom, createSheetMetalMesh, createSpurGearGeom, createSpurGearMesh, createTSlotExtrusionGeom, createTSlotExtrusionMesh, createTSlotGussetGeom, createTSlotGussetMesh, createTSlotInsideCornerGeom, createTSlotInsideCornerMesh, createWormGearGeom, createWormGearMesh, getJscadModelForFootprint, getJscadModelForFootprintWithPads, h };
|
|
402
|
+
export { ButtonScrew, type ButtonScrewMesh, type ButtonScrewMeshOptions, type ButtonScrewProps, CableGrommet, type CableGrommetMesh, type CableGrommetMeshOptions, type CableGrommetProps, ClampingShaftCollar, type ClampingShaftCollarMesh, type ClampingShaftCollarProps, type ColoredGeom, CompressionSpring, type CompressionSpringMesh, type CompressionSpringMeshOptions, type CompressionSpringProps, FlangedBushing, type FlangedBushingMesh, type FlangedBushingProps, FlatHeadScrew, type FlatHeadScrewMesh, type FlatHeadScrewMeshOptions, type FlatHeadScrewProps, Fragment, HelicalGear, type HelicalGearMesh, type HelicalGearProps, HexBolt, type HexBoltMesh, type HexBoltMeshOptions, type HexBoltProps, HexNut, type HexNutMesh, type HexNutMeshOptions, type HexNutProps, HexSocketBolt, type HexSocketBoltMesh, type HexSocketBoltProps, NEMA17, NEMA23, NEMA8, type NemaFrameMotorProps, NemaMotor, type NemaMotorProps, PanScrew, type PanScrewMesh, type PanScrewMeshOptions, type PanScrewProps, PlainBushing, type PlainBushingMesh, type PlainBushingProps, type RenderResult, RigidCoupler, type RigidCouplerMesh, type RigidCouplerProps, ShaftCollar, type ShaftCollarMesh, type ShaftCollarProps, SheetMetal, type SheetMetalMesh, type SheetMetalProps, SpurGear, type SpurGearMesh, type SpurGearProps, TSlotExtrusion, type TSlotExtrusionMesh, type TSlotExtrusionProps, TSlotGusset, type TSlotGussetMesh, type TSlotGussetProps, TSlotInsideCorner, type TSlotInsideCornerMesh, type TSlotInsideCornerProps, ThreadedRod, type ThreadedRodMesh, type ThreadedRodMeshOptions, type ThreadedRodProps, type VNode, WormGear, type WormGearMesh, type WormGearProps, convertCSGToThreeGeom, createButtonScrewGeom, createButtonScrewMesh, createCableGrommetGeom, createCableGrommetMesh, createClampingShaftCollarGeom, createClampingShaftCollarMesh, createCompressionSpringGeom, createCompressionSpringMesh, createFlangedBushingGeom, createFlangedBushingMesh, createFlatHeadScrewGeom, createFlatHeadScrewMesh, createHelicalGearGeom, createHelicalGearMesh, createHexBoltGeom, createHexBoltMesh, createHexNutGeom, createHexNutMesh, createHexSocketBoltGeom, createHexSocketBoltMesh, createJSCADRenderer, createPanScrewGeom, createPanScrewMesh, createPlainBushingGeom, createPlainBushingMesh, createRigidCouplerGeom, createRigidCouplerMesh, createShaftCollarGeom, createShaftCollarMesh, createSheetMetalGeom, createSheetMetalMesh, createSpurGearGeom, createSpurGearMesh, createTSlotExtrusionGeom, createTSlotExtrusionMesh, createTSlotGussetGeom, createTSlotGussetMesh, createTSlotInsideCornerGeom, createTSlotInsideCornerMesh, createThreadedRodGeom, createThreadedRodMesh, createWormGearGeom, createWormGearMesh, getJscadModelForFootprint, getJscadModelForFootprintWithPads, h };
|
package/dist/vanilla.js
CHANGED
|
@@ -183,24 +183,24 @@ var FootprintPlatedHole = ({
|
|
|
183
183
|
import { buttonScrewModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
184
184
|
|
|
185
185
|
// lib/model-registry.ts
|
|
186
|
-
function defineModelRenderer(
|
|
187
|
-
return
|
|
186
|
+
function defineModelRenderer(model24) {
|
|
187
|
+
return model24;
|
|
188
188
|
}
|
|
189
189
|
var ModelRendererRegistry = class {
|
|
190
190
|
models = /* @__PURE__ */ new Map();
|
|
191
|
-
register(
|
|
192
|
-
if (typeof
|
|
191
|
+
register(model24) {
|
|
192
|
+
if (typeof model24.name !== "string" || !/^[a-z]+$/.test(model24.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(model24.name)) {
|
|
198
|
+
throw new Error(`Model renderer "${model24.name}" is already registered`);
|
|
199
199
|
}
|
|
200
|
-
if (
|
|
200
|
+
if (model24.pads !== "none" && model24.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 } = model24;
|
|
204
204
|
this.models.set(name, {
|
|
205
205
|
name,
|
|
206
206
|
schema,
|
|
@@ -354,8 +354,8 @@ function indexedMeshToGeom3(mesh) {
|
|
|
354
354
|
}
|
|
355
355
|
|
|
356
356
|
// lib/models/buttonscrew/ButtonScrew.tsx
|
|
357
|
-
function createButtonScrewGeom(input,
|
|
358
|
-
return indexedMeshToGeom3(createButtonScrewMesh(input,
|
|
357
|
+
function createButtonScrewGeom(input, resolution4) {
|
|
358
|
+
return indexedMeshToGeom3(createButtonScrewMesh(input, resolution4));
|
|
359
359
|
}
|
|
360
360
|
function ButtonScrew({ color = "#737e8f", ...props }) {
|
|
361
361
|
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createButtonScrewGeom(props) }) });
|
|
@@ -2336,8 +2336,8 @@ function createHexNutMesh(input, options = {}) {
|
|
|
2336
2336
|
}
|
|
2337
2337
|
|
|
2338
2338
|
// lib/models/hexnut/HexNut.tsx
|
|
2339
|
-
function createHexNutGeom(input,
|
|
2340
|
-
return indexedMeshToGeom3(createHexNutMesh(input,
|
|
2339
|
+
function createHexNutGeom(input, resolution4) {
|
|
2340
|
+
return indexedMeshToGeom3(createHexNutMesh(input, resolution4));
|
|
2341
2341
|
}
|
|
2342
2342
|
function HexNut({ color = "#737e8f", ...props }) {
|
|
2343
2343
|
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createHexNutGeom(props) }) });
|
|
@@ -3038,6 +3038,57 @@ function register14(registry) {
|
|
|
3038
3038
|
registry.register(model14);
|
|
3039
3039
|
}
|
|
3040
3040
|
|
|
3041
|
+
// lib/models/rigidcoupler/register.tsx
|
|
3042
|
+
import { rigidCouplerModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
3043
|
+
|
|
3044
|
+
// lib/models/rigidcoupler/mesh.ts
|
|
3045
|
+
import "@jscad/modeling";
|
|
3046
|
+
import {
|
|
3047
|
+
rigidCouplerModelPropsSchema,
|
|
3048
|
+
getRigidCouplerDimensions
|
|
3049
|
+
} from "@tscircuit/modelprinter";
|
|
3050
|
+
function createRigidCouplerMesh(input) {
|
|
3051
|
+
const props = rigidCouplerModelPropsSchema.parse(input);
|
|
3052
|
+
const dimensions = getRigidCouplerDimensions(props);
|
|
3053
|
+
assertShaftMountResolution(dimensions.screwHoles);
|
|
3054
|
+
const body = createAnnularSleeve({
|
|
3055
|
+
outerRadius: props.outerDiameter / 2,
|
|
3056
|
+
boreARadius: props.boreDiameter / 2,
|
|
3057
|
+
boreBRadius: props.boreBDiameter / 2,
|
|
3058
|
+
length: props.length,
|
|
3059
|
+
chamfer: props.chamfer,
|
|
3060
|
+
stepZ: dimensions.boreADepth
|
|
3061
|
+
});
|
|
3062
|
+
return finishShaftMountMesh(
|
|
3063
|
+
subtractShaftMountParts(
|
|
3064
|
+
body,
|
|
3065
|
+
...dimensions.screwHoles.map(createMountingHoleCutter)
|
|
3066
|
+
)
|
|
3067
|
+
);
|
|
3068
|
+
}
|
|
3069
|
+
|
|
3070
|
+
// lib/models/rigidcoupler/RigidCoupler.tsx
|
|
3071
|
+
function createRigidCouplerGeom(input) {
|
|
3072
|
+
return indexedMeshToGeom3(createRigidCouplerMesh(input));
|
|
3073
|
+
}
|
|
3074
|
+
function RigidCoupler({
|
|
3075
|
+
color = "#737e8f",
|
|
3076
|
+
...props
|
|
3077
|
+
}) {
|
|
3078
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createRigidCouplerGeom(props) }) });
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
// lib/models/rigidcoupler/register.tsx
|
|
3082
|
+
var model15 = defineModelRenderer({
|
|
3083
|
+
name: "rigidcoupler",
|
|
3084
|
+
schema: rigidCouplerModelDefinitionSchema,
|
|
3085
|
+
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(RigidCoupler, { ...props }),
|
|
3086
|
+
pads: "none"
|
|
3087
|
+
});
|
|
3088
|
+
function register15(registry) {
|
|
3089
|
+
registry.register(model15);
|
|
3090
|
+
}
|
|
3091
|
+
|
|
3041
3092
|
// lib/models/shaftcollar/register.tsx
|
|
3042
3093
|
import { shaftCollarModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
3043
3094
|
|
|
@@ -3074,14 +3125,14 @@ function ShaftCollar({ color = "#737e8f", ...props }) {
|
|
|
3074
3125
|
}
|
|
3075
3126
|
|
|
3076
3127
|
// lib/models/shaftcollar/register.tsx
|
|
3077
|
-
var
|
|
3128
|
+
var model16 = defineModelRenderer({
|
|
3078
3129
|
name: "shaftcollar",
|
|
3079
3130
|
schema: shaftCollarModelDefinitionSchema,
|
|
3080
3131
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(ShaftCollar, { ...props }),
|
|
3081
3132
|
pads: "none"
|
|
3082
3133
|
});
|
|
3083
|
-
function
|
|
3084
|
-
registry.register(
|
|
3134
|
+
function register16(registry) {
|
|
3135
|
+
registry.register(model16);
|
|
3085
3136
|
}
|
|
3086
3137
|
|
|
3087
3138
|
// lib/models/sheetmetal/register.tsx
|
|
@@ -3241,14 +3292,14 @@ function SheetMetal({ color = "#737e8f", ...props }) {
|
|
|
3241
3292
|
}
|
|
3242
3293
|
|
|
3243
3294
|
// lib/models/sheetmetal/register.tsx
|
|
3244
|
-
var
|
|
3295
|
+
var model17 = defineModelRenderer({
|
|
3245
3296
|
name: "sheetmetal",
|
|
3246
3297
|
schema: sheetMetalModelDefinitionSchema,
|
|
3247
3298
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(SheetMetal, { ...props }),
|
|
3248
3299
|
pads: "none"
|
|
3249
3300
|
});
|
|
3250
|
-
function
|
|
3251
|
-
registry.register(
|
|
3301
|
+
function register17(registry) {
|
|
3302
|
+
registry.register(model17);
|
|
3252
3303
|
}
|
|
3253
3304
|
|
|
3254
3305
|
// lib/models/spurgear/register.tsx
|
|
@@ -3263,14 +3314,123 @@ function SpurGear({ color = "#737e8f", ...props }) {
|
|
|
3263
3314
|
}
|
|
3264
3315
|
|
|
3265
3316
|
// lib/models/spurgear/register.tsx
|
|
3266
|
-
var
|
|
3317
|
+
var model18 = defineModelRenderer({
|
|
3267
3318
|
name: "spurgear",
|
|
3268
3319
|
schema: spurGearModelDefinitionSchema,
|
|
3269
3320
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(SpurGear, { ...props }),
|
|
3270
3321
|
pads: "none"
|
|
3271
3322
|
});
|
|
3272
|
-
function
|
|
3273
|
-
registry.register(
|
|
3323
|
+
function register18(registry) {
|
|
3324
|
+
registry.register(model18);
|
|
3325
|
+
}
|
|
3326
|
+
|
|
3327
|
+
// lib/models/threadedrod/register.tsx
|
|
3328
|
+
import { threadedRodModelDefinitionSchema } from "@tscircuit/modelprinter";
|
|
3329
|
+
|
|
3330
|
+
// lib/models/threadedrod/mesh.ts
|
|
3331
|
+
import {
|
|
3332
|
+
threadedRodModelPropsSchema,
|
|
3333
|
+
getThreadedRodDimensions
|
|
3334
|
+
} from "@tscircuit/modelprinter";
|
|
3335
|
+
function resolution3(options) {
|
|
3336
|
+
const radial = options.radialSegments ?? 96;
|
|
3337
|
+
const axial = options.segmentsPerPitch ?? 32;
|
|
3338
|
+
if (!Number.isInteger(radial) || radial < 24 || radial > 192 || radial % 12 !== 0 || !Number.isInteger(axial) || axial < 8 || axial > 64)
|
|
3339
|
+
throw new Error(
|
|
3340
|
+
"Mesh resolution limit: radial segments must be a multiple of 12 in [24,192], pitch segments an integer in [8,64]"
|
|
3341
|
+
);
|
|
3342
|
+
return { radial, axial };
|
|
3343
|
+
}
|
|
3344
|
+
function surface3(segments) {
|
|
3345
|
+
const positions = [], indices = [];
|
|
3346
|
+
const ring = (z, radius) => {
|
|
3347
|
+
const start = positions.length / 3;
|
|
3348
|
+
for (let i = 0; i < segments; i++) {
|
|
3349
|
+
const angle = i * 2 * Math.PI / segments;
|
|
3350
|
+
const r = radius(angle);
|
|
3351
|
+
positions.push(r * Math.cos(angle), r * Math.sin(angle), z);
|
|
3352
|
+
}
|
|
3353
|
+
return start;
|
|
3354
|
+
};
|
|
3355
|
+
const connect = (a, b) => {
|
|
3356
|
+
for (let i = 0; i < segments; i++) {
|
|
3357
|
+
const n = (i + 1) % segments;
|
|
3358
|
+
indices.push(a + i, a + n, b + n, a + i, b + n, b + i);
|
|
3359
|
+
}
|
|
3360
|
+
};
|
|
3361
|
+
const cap = (start, z, up) => {
|
|
3362
|
+
const center = positions.length / 3;
|
|
3363
|
+
positions.push(0, 0, z);
|
|
3364
|
+
for (let i = 0; i < segments; i++) {
|
|
3365
|
+
const n = (i + 1) % segments;
|
|
3366
|
+
indices.push(center, start + (up ? i : n), start + (up ? n : i));
|
|
3367
|
+
}
|
|
3368
|
+
};
|
|
3369
|
+
return { positions, indices, ring, connect, cap };
|
|
3370
|
+
}
|
|
3371
|
+
function threadDistance3(z, angle, pitch, hand = 1) {
|
|
3372
|
+
const phase = ((z / pitch - hand * angle / (2 * Math.PI)) % 1 + 1) % 1;
|
|
3373
|
+
return Math.min(phase, 1 - phase);
|
|
3374
|
+
}
|
|
3375
|
+
function createThreadedRodMesh(input, options = {}) {
|
|
3376
|
+
const props = threadedRodModelPropsSchema.parse(input);
|
|
3377
|
+
const d = getThreadedRodDimensions(input);
|
|
3378
|
+
const { radial, axial } = resolution3(options);
|
|
3379
|
+
const steps = Math.max(2, Math.ceil(d.length / d.threadPitch * axial));
|
|
3380
|
+
if (steps > 24e3 || !Number.isFinite(steps) || Math.min(d.minorDiameter, d.endDiameter) < d.diameter * 1e-8)
|
|
3381
|
+
throw new Error(
|
|
3382
|
+
"Mesh resolution limit: excessive turns or vanishing end/root radius"
|
|
3383
|
+
);
|
|
3384
|
+
const m = surface3(radial);
|
|
3385
|
+
const levels = new Set(
|
|
3386
|
+
Array.from({ length: steps + 1 }, (_, i) => d.length * i / steps)
|
|
3387
|
+
);
|
|
3388
|
+
levels.add(props.chamfer);
|
|
3389
|
+
levels.add(d.length - props.chamfer);
|
|
3390
|
+
const radius = d.diameter / 2, depth = (d.diameter - d.minorDiameter) / 2;
|
|
3391
|
+
let previous = -1;
|
|
3392
|
+
for (const z of [...levels].sort((a, b) => a - b)) {
|
|
3393
|
+
const current = m.ring(z, (angle) => {
|
|
3394
|
+
const groove = Math.min(
|
|
3395
|
+
depth,
|
|
3396
|
+
Math.max(
|
|
3397
|
+
0,
|
|
3398
|
+
(threadDistance3(
|
|
3399
|
+
z,
|
|
3400
|
+
angle,
|
|
3401
|
+
d.threadPitch,
|
|
3402
|
+
props.threadHand === "right" ? 1 : -1
|
|
3403
|
+
) - 1 / 16) * d.threadPitch * Math.sqrt(3)
|
|
3404
|
+
)
|
|
3405
|
+
);
|
|
3406
|
+
const chamfer = radius - Math.max(0, props.chamfer - Math.min(z, d.length - z));
|
|
3407
|
+
return Math.min(radius - groove, chamfer);
|
|
3408
|
+
});
|
|
3409
|
+
if (previous < 0) m.cap(current, z, false);
|
|
3410
|
+
else m.connect(previous, current);
|
|
3411
|
+
previous = current;
|
|
3412
|
+
}
|
|
3413
|
+
m.cap(previous, d.length, true);
|
|
3414
|
+
return { positions: m.positions, indices: m.indices };
|
|
3415
|
+
}
|
|
3416
|
+
|
|
3417
|
+
// lib/models/threadedrod/ThreadedRod.tsx
|
|
3418
|
+
function createThreadedRodGeom(input, resolution4) {
|
|
3419
|
+
return indexedMeshToGeom3(createThreadedRodMesh(input, resolution4));
|
|
3420
|
+
}
|
|
3421
|
+
function ThreadedRod({ color = "#737e8f", ...props }) {
|
|
3422
|
+
return /* @__PURE__ */ jsx(Colorize, { color, children: /* @__PURE__ */ jsx(Custom, { geometry: createThreadedRodGeom(props) }) });
|
|
3423
|
+
}
|
|
3424
|
+
|
|
3425
|
+
// lib/models/threadedrod/register.tsx
|
|
3426
|
+
var model19 = defineModelRenderer({
|
|
3427
|
+
name: "threadedrod",
|
|
3428
|
+
schema: threadedRodModelDefinitionSchema,
|
|
3429
|
+
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(ThreadedRod, { ...props }),
|
|
3430
|
+
pads: "none"
|
|
3431
|
+
});
|
|
3432
|
+
function register19(registry) {
|
|
3433
|
+
registry.register(model19);
|
|
3274
3434
|
}
|
|
3275
3435
|
|
|
3276
3436
|
// lib/models/tslotextrusion/register.tsx
|
|
@@ -3420,14 +3580,14 @@ function TSlotExtrusion({
|
|
|
3420
3580
|
}
|
|
3421
3581
|
|
|
3422
3582
|
// lib/models/tslotextrusion/register.tsx
|
|
3423
|
-
var
|
|
3583
|
+
var model20 = defineModelRenderer({
|
|
3424
3584
|
name: "tslotextrusion",
|
|
3425
3585
|
schema: tSlotExtrusionModelDefinitionSchema,
|
|
3426
3586
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(TSlotExtrusion, { ...props }),
|
|
3427
3587
|
pads: "none"
|
|
3428
3588
|
});
|
|
3429
|
-
function
|
|
3430
|
-
registry.register(
|
|
3589
|
+
function register20(registry) {
|
|
3590
|
+
registry.register(model20);
|
|
3431
3591
|
}
|
|
3432
3592
|
|
|
3433
3593
|
// lib/models/tslotgusset/register.tsx
|
|
@@ -3480,14 +3640,14 @@ function TSlotGusset({ color = "#8995a3", ...props }) {
|
|
|
3480
3640
|
}
|
|
3481
3641
|
|
|
3482
3642
|
// lib/models/tslotgusset/register.tsx
|
|
3483
|
-
var
|
|
3643
|
+
var model21 = defineModelRenderer({
|
|
3484
3644
|
name: "tslotgusset",
|
|
3485
3645
|
schema: tSlotGussetModelDefinitionSchema,
|
|
3486
3646
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(TSlotGusset, { ...props }),
|
|
3487
3647
|
pads: "none"
|
|
3488
3648
|
});
|
|
3489
|
-
function
|
|
3490
|
-
registry.register(
|
|
3649
|
+
function register21(registry) {
|
|
3650
|
+
registry.register(model21);
|
|
3491
3651
|
}
|
|
3492
3652
|
|
|
3493
3653
|
// lib/models/tslotinsidecorner/register.tsx
|
|
@@ -3567,14 +3727,14 @@ function TSlotInsideCorner({
|
|
|
3567
3727
|
}
|
|
3568
3728
|
|
|
3569
3729
|
// lib/models/tslotinsidecorner/register.tsx
|
|
3570
|
-
var
|
|
3730
|
+
var model22 = defineModelRenderer({
|
|
3571
3731
|
name: "tslotinsidecorner",
|
|
3572
3732
|
schema: tSlotInsideCornerModelDefinitionSchema,
|
|
3573
3733
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(TSlotInsideCorner, { ...props }),
|
|
3574
3734
|
pads: "none"
|
|
3575
3735
|
});
|
|
3576
|
-
function
|
|
3577
|
-
registry.register(
|
|
3736
|
+
function register22(registry) {
|
|
3737
|
+
registry.register(model22);
|
|
3578
3738
|
}
|
|
3579
3739
|
|
|
3580
3740
|
// lib/models/wormgear/register.tsx
|
|
@@ -3766,14 +3926,14 @@ function WormGear({ color = "#737e8f", ...props }) {
|
|
|
3766
3926
|
}
|
|
3767
3927
|
|
|
3768
3928
|
// lib/models/wormgear/register.tsx
|
|
3769
|
-
var
|
|
3929
|
+
var model23 = defineModelRenderer({
|
|
3770
3930
|
name: "wormgear",
|
|
3771
3931
|
schema: wormGearModelDefinitionSchema,
|
|
3772
3932
|
render: ({ fn, ...props }) => /* @__PURE__ */ jsx(WormGear, { ...props }),
|
|
3773
3933
|
pads: "none"
|
|
3774
3934
|
});
|
|
3775
|
-
function
|
|
3776
|
-
registry.register(
|
|
3935
|
+
function register23(registry) {
|
|
3936
|
+
registry.register(model23);
|
|
3777
3937
|
}
|
|
3778
3938
|
|
|
3779
3939
|
// lib/generated/model-renderers.ts
|
|
@@ -3799,6 +3959,8 @@ function registerAllModelRenderers(registry) {
|
|
|
3799
3959
|
register19(registry);
|
|
3800
3960
|
register20(registry);
|
|
3801
3961
|
register21(registry);
|
|
3962
|
+
register22(registry);
|
|
3963
|
+
register23(registry);
|
|
3802
3964
|
}
|
|
3803
3965
|
|
|
3804
3966
|
// lib/default-model-registry.ts
|
|
@@ -11355,10 +11517,10 @@ var SOT143 = ({ footprint = "sot143" }) => {
|
|
|
11355
11517
|
var Footprinter3d = ({ footprint }) => {
|
|
11356
11518
|
const modelFn = mp3.string(footprint.split("_", 1)[0]).params().fn;
|
|
11357
11519
|
if (mp3.getModelNames().includes(modelFn)) {
|
|
11358
|
-
const
|
|
11359
|
-
const renderer = modelRendererRegistry.get(
|
|
11520
|
+
const model24 = mp3.string(footprint).json();
|
|
11521
|
+
const renderer = modelRendererRegistry.get(model24.fn);
|
|
11360
11522
|
if (renderer) {
|
|
11361
|
-
return renderer.render(
|
|
11523
|
+
return renderer.render(model24);
|
|
11362
11524
|
}
|
|
11363
11525
|
}
|
|
11364
11526
|
let normalizedFootprint = footprint;
|
|
@@ -12191,8 +12353,8 @@ function renderNode(node, colorCtx, renderCtx) {
|
|
|
12191
12353
|
}
|
|
12192
12354
|
return (children ?? []).flatMap((c) => renderNode(c, colorCtx, renderCtx));
|
|
12193
12355
|
}
|
|
12194
|
-
function render(root,
|
|
12195
|
-
const geometries = renderNode(root, void 0, { jscad:
|
|
12356
|
+
function render(root, jscad8) {
|
|
12357
|
+
const geometries = renderNode(root, void 0, { jscad: jscad8 });
|
|
12196
12358
|
return {
|
|
12197
12359
|
geometries: geometries.map(
|
|
12198
12360
|
(entry) => entry.material ? { ...entry, geom: { ...entry.geom, material: entry.material } } : entry
|
|
@@ -12284,24 +12446,24 @@ function convertCSGToThreeGeom(csg) {
|
|
|
12284
12446
|
}
|
|
12285
12447
|
|
|
12286
12448
|
// lib/vanilla/index.ts
|
|
12287
|
-
function getJscadModelForFootprint(footprint,
|
|
12449
|
+
function getJscadModelForFootprint(footprint, jscad8) {
|
|
12288
12450
|
const vnode = h(Footprinter3d, { footprint });
|
|
12289
|
-
return render(vnode,
|
|
12451
|
+
return render(vnode, jscad8);
|
|
12290
12452
|
}
|
|
12291
|
-
function getJscadModelForFootprintWithPads(footprint,
|
|
12453
|
+
function getJscadModelForFootprintWithPads(footprint, jscad8) {
|
|
12292
12454
|
const vnode = h(
|
|
12293
12455
|
Fragment,
|
|
12294
12456
|
{},
|
|
12295
12457
|
h(Footprinter3d, { footprint }),
|
|
12296
12458
|
h(ExtrudedPads, { footprint })
|
|
12297
12459
|
);
|
|
12298
|
-
return render(vnode,
|
|
12460
|
+
return render(vnode, jscad8);
|
|
12299
12461
|
}
|
|
12300
|
-
function createJSCADRenderer(
|
|
12462
|
+
function createJSCADRenderer(jscad8) {
|
|
12301
12463
|
function createJSCADRoot(container) {
|
|
12302
12464
|
return {
|
|
12303
12465
|
render(element) {
|
|
12304
|
-
const { geometries } = render(element,
|
|
12466
|
+
const { geometries } = render(element, jscad8);
|
|
12305
12467
|
container.splice(0, container.length, ...geometries);
|
|
12306
12468
|
}
|
|
12307
12469
|
};
|
|
@@ -12326,12 +12488,14 @@ export {
|
|
|
12326
12488
|
NemaMotor,
|
|
12327
12489
|
PanScrew,
|
|
12328
12490
|
PlainBushing,
|
|
12491
|
+
RigidCoupler,
|
|
12329
12492
|
ShaftCollar,
|
|
12330
12493
|
SheetMetal,
|
|
12331
12494
|
SpurGear,
|
|
12332
12495
|
TSlotExtrusion,
|
|
12333
12496
|
TSlotGusset,
|
|
12334
12497
|
TSlotInsideCorner,
|
|
12498
|
+
ThreadedRod,
|
|
12335
12499
|
WormGear,
|
|
12336
12500
|
convertCSGToThreeGeom,
|
|
12337
12501
|
createButtonScrewGeom,
|
|
@@ -12359,6 +12523,8 @@ export {
|
|
|
12359
12523
|
createPanScrewMesh,
|
|
12360
12524
|
createPlainBushingGeom,
|
|
12361
12525
|
createPlainBushingMesh,
|
|
12526
|
+
createRigidCouplerGeom,
|
|
12527
|
+
createRigidCouplerMesh,
|
|
12362
12528
|
createShaftCollarGeom,
|
|
12363
12529
|
createShaftCollarMesh,
|
|
12364
12530
|
createSheetMetalGeom,
|
|
@@ -12371,6 +12537,8 @@ export {
|
|
|
12371
12537
|
createTSlotGussetMesh,
|
|
12372
12538
|
createTSlotInsideCornerGeom,
|
|
12373
12539
|
createTSlotInsideCornerMesh,
|
|
12540
|
+
createThreadedRodGeom,
|
|
12541
|
+
createThreadedRodMesh,
|
|
12374
12542
|
createWormGearGeom,
|
|
12375
12543
|
createWormGearMesh,
|
|
12376
12544
|
getJscadModelForFootprint,
|