@tscircuit/3d-viewer 0.0.613 → 0.0.614
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.js +428 -202
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -13389,7 +13389,7 @@ var require_generalize = __commonJS({
|
|
|
13389
13389
|
clone.polygons = polygons;
|
|
13390
13390
|
return clone;
|
|
13391
13391
|
};
|
|
13392
|
-
var
|
|
13392
|
+
var generalize2 = (options, ...geometries) => {
|
|
13393
13393
|
geometries = flatten(geometries);
|
|
13394
13394
|
if (geometries.length === 0) throw new Error("wrong number of arguments");
|
|
13395
13395
|
const results = geometries.map((geometry) => {
|
|
@@ -13400,7 +13400,7 @@ var require_generalize = __commonJS({
|
|
|
13400
13400
|
});
|
|
13401
13401
|
return results.length === 1 ? results[0] : results;
|
|
13402
13402
|
};
|
|
13403
|
-
module.exports =
|
|
13403
|
+
module.exports = generalize2;
|
|
13404
13404
|
}
|
|
13405
13405
|
});
|
|
13406
13406
|
|
|
@@ -13880,77 +13880,77 @@ var require_dist = __commonJS({
|
|
|
13880
13880
|
radToDeg: (radians) => radians * 180 / Math.PI
|
|
13881
13881
|
}
|
|
13882
13882
|
};
|
|
13883
|
-
var executeJscadOperations3 = (
|
|
13883
|
+
var executeJscadOperations3 = (jscad6, operation) => {
|
|
13884
13884
|
if (Array.isArray(operation) && operation.length === 1) {
|
|
13885
|
-
return executeJscadOperations3(
|
|
13885
|
+
return executeJscadOperations3(jscad6, operation[0]);
|
|
13886
13886
|
}
|
|
13887
13887
|
if (Array.isArray(operation)) {
|
|
13888
13888
|
throw new Error(
|
|
13889
13889
|
`executeJscadOperations currently doesn't support Array<JscadOperation>, try adding a root union or or executing each element individually`
|
|
13890
13890
|
);
|
|
13891
13891
|
}
|
|
13892
|
-
const recurse = (op) => executeJscadOperations3(
|
|
13892
|
+
const recurse = (op) => executeJscadOperations3(jscad6, op);
|
|
13893
13893
|
const { type, ...params } = operation;
|
|
13894
13894
|
switch (type) {
|
|
13895
13895
|
case "intersect":
|
|
13896
|
-
return
|
|
13896
|
+
return jscad6.booleans.intersect(...operation.shapes.map(recurse));
|
|
13897
13897
|
case "subtract":
|
|
13898
|
-
return
|
|
13898
|
+
return jscad6.booleans.subtract(...operation.shapes.map(recurse));
|
|
13899
13899
|
case "union":
|
|
13900
|
-
return
|
|
13900
|
+
return jscad6.booleans.union(...operation.shapes.map(recurse));
|
|
13901
13901
|
case "hull":
|
|
13902
|
-
return
|
|
13902
|
+
return jscad6.hulls.hull(...operation.shapes.map(recurse));
|
|
13903
13903
|
case "hullChain":
|
|
13904
|
-
return
|
|
13904
|
+
return jscad6.hulls.hullChain(...operation.shapes.map(recurse));
|
|
13905
13905
|
case "colorize":
|
|
13906
|
-
return
|
|
13906
|
+
return jscad6.colors.colorize(operation.color, recurse(operation.shape));
|
|
13907
13907
|
case "cube":
|
|
13908
|
-
return
|
|
13908
|
+
return jscad6.primitives.cube(params);
|
|
13909
13909
|
case "sphere":
|
|
13910
|
-
return
|
|
13910
|
+
return jscad6.primitives.sphere(params);
|
|
13911
13911
|
case "cylinder":
|
|
13912
|
-
return
|
|
13912
|
+
return jscad6.primitives.cylinder(params);
|
|
13913
13913
|
case "polygon":
|
|
13914
|
-
return
|
|
13914
|
+
return jscad6.primitives.polygon(params);
|
|
13915
13915
|
case "cuboid":
|
|
13916
|
-
return
|
|
13916
|
+
return jscad6.primitives.cuboid(params);
|
|
13917
13917
|
case "roundedCuboid":
|
|
13918
|
-
return
|
|
13918
|
+
return jscad6.primitives.roundedCuboid(params);
|
|
13919
13919
|
case "rotate":
|
|
13920
|
-
return
|
|
13920
|
+
return jscad6.transforms.rotate(operation.angles, recurse(operation.shape));
|
|
13921
13921
|
case "scale":
|
|
13922
|
-
return
|
|
13922
|
+
return jscad6.transforms.scale(operation.factors, recurse(operation.shape));
|
|
13923
13923
|
case "translate":
|
|
13924
|
-
return
|
|
13924
|
+
return jscad6.transforms.translate(
|
|
13925
13925
|
operation.vector,
|
|
13926
13926
|
recurse(operation.shape)
|
|
13927
13927
|
);
|
|
13928
13928
|
case "extrudeLinear":
|
|
13929
|
-
return
|
|
13929
|
+
return jscad6.extrusions.extrudeLinear(
|
|
13930
13930
|
operation.options,
|
|
13931
13931
|
recurse(operation.shape)
|
|
13932
13932
|
);
|
|
13933
13933
|
case "extrudeRotate":
|
|
13934
|
-
return
|
|
13934
|
+
return jscad6.extrusions.extrudeRotate(
|
|
13935
13935
|
operation.options,
|
|
13936
13936
|
recurse(operation.shape)
|
|
13937
13937
|
);
|
|
13938
13938
|
case "createGeom2":
|
|
13939
|
-
return
|
|
13939
|
+
return jscad6.geometries.geom2.create(operation.points);
|
|
13940
13940
|
case "createGeom3":
|
|
13941
|
-
return
|
|
13941
|
+
return jscad6.geometries.geom3.create(operation.polygons);
|
|
13942
13942
|
case "createPath2":
|
|
13943
|
-
return
|
|
13943
|
+
return jscad6.geometries.path2.create(operation.points);
|
|
13944
13944
|
case "measureBoundingBox":
|
|
13945
|
-
return
|
|
13945
|
+
return jscad6.measurements.measureBoundingBox(recurse(operation.shape));
|
|
13946
13946
|
case "measureArea":
|
|
13947
|
-
return
|
|
13947
|
+
return jscad6.measurements.measureArea(recurse(operation.shape));
|
|
13948
13948
|
case "measureVolume":
|
|
13949
|
-
return
|
|
13949
|
+
return jscad6.measurements.measureVolume(recurse(operation.shape));
|
|
13950
13950
|
case "degToRad":
|
|
13951
|
-
return
|
|
13951
|
+
return jscad6.utils.degToRad(operation.degrees);
|
|
13952
13952
|
case "radToDeg":
|
|
13953
|
-
return
|
|
13953
|
+
return jscad6.utils.radToDeg(operation.radians);
|
|
13954
13954
|
default:
|
|
13955
13955
|
if (operation.type === void 0) {
|
|
13956
13956
|
throw new Error(
|
|
@@ -14789,10 +14789,11 @@ var Html = ({ children, position, style }) => {
|
|
|
14789
14789
|
return portal;
|
|
14790
14790
|
};
|
|
14791
14791
|
|
|
14792
|
-
// node_modules/@tscircuit/modelprinter/index.js
|
|
14792
|
+
// node_modules/jscad-electronics/node_modules/@tscircuit/modelprinter/index.js
|
|
14793
|
+
import { z as z3 } from "zod";
|
|
14793
14794
|
import { z as z2 } from "zod";
|
|
14794
14795
|
|
|
14795
|
-
// node_modules/@tscircuit/mm/dist/index.js
|
|
14796
|
+
// node_modules/jscad-electronics/node_modules/@tscircuit/modelprinter/node_modules/@tscircuit/mm/dist/index.js
|
|
14796
14797
|
var unitToMm = {
|
|
14797
14798
|
in: 25.4,
|
|
14798
14799
|
inch: 25.4,
|
|
@@ -14819,11 +14820,10 @@ var mm = (n) => {
|
|
|
14819
14820
|
throw new Error(`Unsupported unit: ${unit}`);
|
|
14820
14821
|
};
|
|
14821
14822
|
|
|
14822
|
-
// node_modules/@tscircuit/modelprinter/index.js
|
|
14823
|
+
// node_modules/jscad-electronics/node_modules/@tscircuit/modelprinter/index.js
|
|
14823
14824
|
import { z } from "zod";
|
|
14824
|
-
import { z as z3 } from "zod";
|
|
14825
|
-
import { z as z5 } from "zod";
|
|
14826
14825
|
import { z as z4 } from "zod";
|
|
14826
|
+
import { z as z5 } from "zod";
|
|
14827
14827
|
var modelLengthSchema = z.union([z.number(), z.string()]).transform((value, context) => {
|
|
14828
14828
|
try {
|
|
14829
14829
|
const parsed = mm(value);
|
|
@@ -14845,13 +14845,111 @@ var nonnegativeModelLengthSchema = modelLengthSchema.refine(
|
|
|
14845
14845
|
(value) => value >= 0,
|
|
14846
14846
|
"Length cannot be negative"
|
|
14847
14847
|
);
|
|
14848
|
-
var
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14848
|
+
var hexSocketBoltDimensions = {
|
|
14849
|
+
M2: {
|
|
14850
|
+
diameter: 2,
|
|
14851
|
+
threadPitch: 0.4,
|
|
14852
|
+
headDiameter: 3.8,
|
|
14853
|
+
headHeight: 2,
|
|
14854
|
+
socketWidth: 1.5,
|
|
14855
|
+
socketDepth: 1
|
|
14856
|
+
},
|
|
14857
|
+
"M2.5": {
|
|
14858
|
+
diameter: 2.5,
|
|
14859
|
+
threadPitch: 0.45,
|
|
14860
|
+
headDiameter: 4.5,
|
|
14861
|
+
headHeight: 2.5,
|
|
14862
|
+
socketWidth: 2,
|
|
14863
|
+
socketDepth: 1.1
|
|
14864
|
+
},
|
|
14865
|
+
M3: {
|
|
14866
|
+
diameter: 3,
|
|
14867
|
+
threadPitch: 0.5,
|
|
14868
|
+
headDiameter: 5.5,
|
|
14869
|
+
headHeight: 3,
|
|
14870
|
+
socketWidth: 2.5,
|
|
14871
|
+
socketDepth: 1.3
|
|
14872
|
+
},
|
|
14873
|
+
M4: {
|
|
14874
|
+
diameter: 4,
|
|
14875
|
+
threadPitch: 0.7,
|
|
14876
|
+
headDiameter: 7,
|
|
14877
|
+
headHeight: 4,
|
|
14878
|
+
socketWidth: 3,
|
|
14879
|
+
socketDepth: 2
|
|
14880
|
+
},
|
|
14881
|
+
M5: {
|
|
14882
|
+
diameter: 5,
|
|
14883
|
+
threadPitch: 0.8,
|
|
14884
|
+
headDiameter: 8.5,
|
|
14885
|
+
headHeight: 5,
|
|
14886
|
+
socketWidth: 4,
|
|
14887
|
+
socketDepth: 2.5
|
|
14888
|
+
},
|
|
14889
|
+
M6: {
|
|
14890
|
+
diameter: 6,
|
|
14891
|
+
threadPitch: 1,
|
|
14892
|
+
headDiameter: 10,
|
|
14893
|
+
headHeight: 6,
|
|
14894
|
+
socketWidth: 5,
|
|
14895
|
+
socketDepth: 3
|
|
14896
|
+
},
|
|
14897
|
+
M8: {
|
|
14898
|
+
diameter: 8,
|
|
14899
|
+
threadPitch: 1.25,
|
|
14900
|
+
headDiameter: 13,
|
|
14901
|
+
headHeight: 8,
|
|
14902
|
+
socketWidth: 6,
|
|
14903
|
+
socketDepth: 4
|
|
14904
|
+
},
|
|
14905
|
+
M10: {
|
|
14906
|
+
diameter: 10,
|
|
14907
|
+
threadPitch: 1.5,
|
|
14908
|
+
headDiameter: 16,
|
|
14909
|
+
headHeight: 10,
|
|
14910
|
+
socketWidth: 8,
|
|
14911
|
+
socketDepth: 5
|
|
14912
|
+
},
|
|
14913
|
+
M12: {
|
|
14914
|
+
diameter: 12,
|
|
14915
|
+
threadPitch: 1.75,
|
|
14916
|
+
headDiameter: 18,
|
|
14917
|
+
headHeight: 12,
|
|
14918
|
+
socketWidth: 10,
|
|
14919
|
+
socketDepth: 6
|
|
14920
|
+
}
|
|
14921
|
+
};
|
|
14922
|
+
var metricBoltSizeSchema = z2.enum([
|
|
14923
|
+
"M2",
|
|
14924
|
+
"M2.5",
|
|
14925
|
+
"M3",
|
|
14926
|
+
"M4",
|
|
14927
|
+
"M5",
|
|
14928
|
+
"M6",
|
|
14929
|
+
"M8",
|
|
14930
|
+
"M10",
|
|
14931
|
+
"M12"
|
|
14932
|
+
]);
|
|
14933
|
+
var hexSocketBoltModelPropsShape = {
|
|
14934
|
+
metricSize: metricBoltSizeSchema,
|
|
14935
|
+
/** Length under the head, excluding the head itself. */
|
|
14936
|
+
length: positiveModelLengthSchema,
|
|
14937
|
+
showThreads: z2.boolean().default(true)
|
|
14938
|
+
};
|
|
14939
|
+
var hexSocketBoltModelPropsSchema = z2.object(hexSocketBoltModelPropsShape).strict();
|
|
14940
|
+
var hexSocketBoltModelDefinitionSchema = z2.object({
|
|
14941
|
+
fn: z2.literal("hexsocketbolt"),
|
|
14942
|
+
...hexSocketBoltModelPropsShape
|
|
14943
|
+
}).strict();
|
|
14944
|
+
var nemaSizeSchema = z3.union([
|
|
14945
|
+
z3.literal(8),
|
|
14946
|
+
z3.literal(17),
|
|
14947
|
+
z3.literal(23)
|
|
14852
14948
|
]);
|
|
14853
14949
|
var nemaMotorDimensions = {
|
|
14854
14950
|
8: {
|
|
14951
|
+
backFaceScrewSize: "M2",
|
|
14952
|
+
backFaceHoleDepth: 2,
|
|
14855
14953
|
bodyWidth: 20.3,
|
|
14856
14954
|
bodyLength: 33,
|
|
14857
14955
|
mountingHoleSpacing: 16,
|
|
@@ -14872,6 +14970,8 @@ var nemaMotorDimensions = {
|
|
|
14872
14970
|
bodyCornerChamfer: 3
|
|
14873
14971
|
},
|
|
14874
14972
|
17: {
|
|
14973
|
+
backFaceScrewSize: "M3",
|
|
14974
|
+
backFaceHoleDepth: 4.5,
|
|
14875
14975
|
bodyWidth: 42.3,
|
|
14876
14976
|
bodyLength: 38,
|
|
14877
14977
|
mountingHoleSpacing: 31,
|
|
@@ -14892,6 +14992,8 @@ var nemaMotorDimensions = {
|
|
|
14892
14992
|
bodyCornerChamfer: 6
|
|
14893
14993
|
},
|
|
14894
14994
|
23: {
|
|
14995
|
+
backFaceScrewSize: "M4",
|
|
14996
|
+
backFaceHoleDepth: 4.5,
|
|
14895
14997
|
bodyWidth: 56.4,
|
|
14896
14998
|
bodyLength: 51,
|
|
14897
14999
|
mountingHoleSpacing: 47.14,
|
|
@@ -14914,24 +15016,37 @@ var nemaMotorDimensions = {
|
|
|
14914
15016
|
};
|
|
14915
15017
|
var shape = {
|
|
14916
15018
|
nemaSize: nemaSizeSchema,
|
|
15019
|
+
/** Rear cap at Z=-bodyLength: bare, open bores or installed cap screws. */
|
|
15020
|
+
backFace: z3.enum(["plain", "holes", "screws"]).optional(),
|
|
15021
|
+
backFaceHoleSpacing: positiveModelLengthSchema.optional(),
|
|
15022
|
+
backFaceHoleDiameter: positiveModelLengthSchema.optional(),
|
|
15023
|
+
backFaceHoleDepth: positiveModelLengthSchema.optional(),
|
|
15024
|
+
backFaceScrewSize: metricBoltSizeSchema.optional(),
|
|
15025
|
+
/** Visual termination; the wireside reference exists even when hidden. */
|
|
15026
|
+
wireConnection: z3.enum(["none", "stubs", "jst-ph-6"]).optional(),
|
|
15027
|
+
/** Counterclockwise angle about local +Z; 0 is the +X side. */
|
|
15028
|
+
wireSideAngle: z3.number().finite().optional(),
|
|
15029
|
+
wireLength: positiveModelLengthSchema.optional(),
|
|
15030
|
+
wireDiameter: positiveModelLengthSchema.optional(),
|
|
15031
|
+
wireCount: z3.number().int().min(2).max(8).optional(),
|
|
14917
15032
|
bodyWidth: positiveModelLengthSchema.optional(),
|
|
14918
15033
|
bodyLength: positiveModelLengthSchema.optional(),
|
|
14919
15034
|
mountingHoleSpacing: positiveModelLengthSchema.optional(),
|
|
14920
15035
|
mountingHoleDiameter: positiveModelLengthSchema.optional(),
|
|
14921
15036
|
mountingHoleDepth: positiveModelLengthSchema.optional(),
|
|
14922
|
-
mountingHoleThrough:
|
|
15037
|
+
mountingHoleThrough: z3.boolean().optional(),
|
|
14923
15038
|
pilotDiameter: positiveModelLengthSchema.optional(),
|
|
14924
15039
|
pilotLength: positiveModelLengthSchema.optional(),
|
|
14925
15040
|
/** Distance from mounting face Z=0 to shaft tip, including pilot height. */
|
|
14926
15041
|
shaftLength: positiveModelLengthSchema.optional(),
|
|
14927
15042
|
shaftDiameter: positiveModelLengthSchema.optional(),
|
|
14928
|
-
shaftShape:
|
|
15043
|
+
shaftShape: z3.enum(["round", "d"]).optional(),
|
|
14929
15044
|
/** Radial material removed from the +X side before rotation. */
|
|
14930
15045
|
shaftFlatDepth: nonnegativeModelLengthSchema.optional(),
|
|
14931
15046
|
/** Flat extends back from the tip; leaves a round shoulder above the pilot. */
|
|
14932
15047
|
shaftFlatLength: nonnegativeModelLengthSchema.optional(),
|
|
14933
15048
|
/** Degrees around +Z, counterclockwise; zero puts the flat on +X. */
|
|
14934
|
-
shaftFlatAngle:
|
|
15049
|
+
shaftFlatAngle: z3.number().finite().optional(),
|
|
14935
15050
|
frontCapLength: positiveModelLengthSchema.optional(),
|
|
14936
15051
|
rearCapLength: positiveModelLengthSchema.optional(),
|
|
14937
15052
|
faceCornerChamfer: nonnegativeModelLengthSchema.optional(),
|
|
@@ -14939,8 +15054,20 @@ var shape = {
|
|
|
14939
15054
|
};
|
|
14940
15055
|
var resolve = (p) => {
|
|
14941
15056
|
const d = nemaMotorDimensions[p.nemaSize];
|
|
15057
|
+
const backFaceScrewSize = p.backFaceScrewSize ?? d.backFaceScrewSize;
|
|
15058
|
+
const screw = hexSocketBoltDimensions[backFaceScrewSize];
|
|
14942
15059
|
return {
|
|
14943
15060
|
nemaSize: p.nemaSize,
|
|
15061
|
+
wireConnection: p.wireConnection ?? "stubs",
|
|
15062
|
+
wireSideAngle: ((p.wireSideAngle ?? 0) % 360 + 360) % 360,
|
|
15063
|
+
wireLength: p.wireLength ?? 6,
|
|
15064
|
+
wireDiameter: p.wireDiameter ?? 1.2,
|
|
15065
|
+
wireCount: p.wireCount ?? 4,
|
|
15066
|
+
backFace: p.backFace ?? "screws",
|
|
15067
|
+
backFaceHoleSpacing: p.backFaceHoleSpacing ?? p.mountingHoleSpacing ?? d.mountingHoleSpacing,
|
|
15068
|
+
backFaceHoleDiameter: p.backFaceHoleDiameter ?? screw.diameter,
|
|
15069
|
+
backFaceHoleDepth: p.backFaceHoleDepth ?? d.backFaceHoleDepth,
|
|
15070
|
+
backFaceScrewSize,
|
|
14944
15071
|
bodyWidth: p.bodyWidth ?? d.bodyWidth,
|
|
14945
15072
|
bodyLength: p.bodyLength ?? d.bodyLength,
|
|
14946
15073
|
mountingHoleSpacing: p.mountingHoleSpacing ?? d.mountingHoleSpacing,
|
|
@@ -14963,6 +15090,26 @@ var resolve = (p) => {
|
|
|
14963
15090
|
};
|
|
14964
15091
|
var validate = (p, ctx) => {
|
|
14965
15092
|
const issue = (message) => ctx.addIssue({ code: "custom", message });
|
|
15093
|
+
if (p.backFace !== "plain") {
|
|
15094
|
+
const screw = hexSocketBoltDimensions[p.backFaceScrewSize];
|
|
15095
|
+
const radius = (p.backFace === "screws" ? Math.max(p.backFaceHoleDiameter, screw.headDiameter) : p.backFaceHoleDiameter) / 2;
|
|
15096
|
+
if (p.backFaceHoleSpacing <= 2 * radius)
|
|
15097
|
+
issue("Rear holes and screw heads must not overlap each other");
|
|
15098
|
+
if (p.backFaceHoleSpacing + 2 * radius >= p.bodyWidth || p.bodyWidth - p.faceCornerChamfer - p.backFaceHoleSpacing <= radius * Math.SQRT2)
|
|
15099
|
+
issue("Rear holes and screw heads must fit entirely inside the rear face");
|
|
15100
|
+
if (p.backFaceHoleDepth >= p.rearCapLength)
|
|
15101
|
+
issue("Rear hole depth must be less than the rear cap length");
|
|
15102
|
+
if (p.backFace === "screws" && p.backFaceHoleDiameter < screw.diameter)
|
|
15103
|
+
issue("Rear holes must accommodate the screw diameter");
|
|
15104
|
+
}
|
|
15105
|
+
if (p.wireConnection === "stubs") {
|
|
15106
|
+
if (p.wireDiameter * p.wireCount * 1.5 > p.bodyWidth - 2 * p.faceCornerChamfer)
|
|
15107
|
+
issue("Wire bundle must fit on the cap side");
|
|
15108
|
+
if (p.wireDiameter >= p.rearCapLength)
|
|
15109
|
+
issue("Wire diameter must fit within the rear cap");
|
|
15110
|
+
}
|
|
15111
|
+
if (p.wireConnection === "jst-ph-6" && p.bodyWidth - 2 * p.faceCornerChamfer < 13.9)
|
|
15112
|
+
issue("Six-position JST-PH header must fit on the motor side");
|
|
14966
15113
|
const r = p.mountingHoleDiameter / 2;
|
|
14967
15114
|
if (p.frontCapLength + p.rearCapLength >= p.bodyLength)
|
|
14968
15115
|
issue("End caps must leave a positive body length");
|
|
@@ -14979,7 +15126,7 @@ var validate = (p, ctx) => {
|
|
|
14979
15126
|
if (!p.mountingHoleThrough && p.mountingHoleDepth >= p.frontCapLength)
|
|
14980
15127
|
issue("Blind mounting hole depth must be less than the front cap length");
|
|
14981
15128
|
if (p.mountingHoleThrough && p.bodyWidth - p.bodyCornerChamfer - p.mountingHoleSpacing >= -r * Math.SQRT2)
|
|
14982
|
-
issue("Body
|
|
15129
|
+
issue("Body must clear through front mounting holes");
|
|
14983
15130
|
if (p.shaftLength <= p.pilotLength)
|
|
14984
15131
|
issue("Shaft tip must extend beyond the pilot");
|
|
14985
15132
|
if (p.shaftShape === "d" && (p.shaftFlatDepth <= 0 || p.shaftFlatDepth >= p.shaftDiameter / 2 || p.shaftFlatLength <= 0 || p.shaftFlatLength > p.shaftLength - p.pilotLength))
|
|
@@ -14987,31 +15134,31 @@ var validate = (p, ctx) => {
|
|
|
14987
15134
|
"D flat must have positive depth less than the shaft radius and fit above the pilot"
|
|
14988
15135
|
);
|
|
14989
15136
|
};
|
|
14990
|
-
var nemaMotorModelPropsSchema =
|
|
14991
|
-
var nemaMotorModelDefinitionSchema =
|
|
15137
|
+
var nemaMotorModelPropsSchema = z3.object(shape).strict().transform(resolve).superRefine(validate);
|
|
15138
|
+
var nemaMotorModelDefinitionSchema = z3.object({ fn: z3.literal("nema"), ...shape }).strict().transform(({ fn, ...props }) => ({ fn, ...resolve(props) })).superRefine(validate);
|
|
14992
15139
|
var holePosition = {
|
|
14993
|
-
panel:
|
|
15140
|
+
panel: z4.enum(["base", "left", "right"]),
|
|
14994
15141
|
/** Panel-local mm, centered on its straight section: u along its length,
|
|
14995
15142
|
* v along the sheet width. Side-panel u increases upward. */
|
|
14996
15143
|
u: modelLengthSchema,
|
|
14997
15144
|
v: modelLengthSchema
|
|
14998
15145
|
};
|
|
14999
|
-
var sheetMetalHoleSchema =
|
|
15000
|
-
|
|
15146
|
+
var sheetMetalHoleSchema = z4.discriminatedUnion("shape", [
|
|
15147
|
+
z4.object({
|
|
15001
15148
|
...holePosition,
|
|
15002
|
-
shape:
|
|
15149
|
+
shape: z4.literal("round"),
|
|
15003
15150
|
diameter: positiveModelLengthSchema
|
|
15004
15151
|
}).strict(),
|
|
15005
|
-
|
|
15152
|
+
z4.object({
|
|
15006
15153
|
...holePosition,
|
|
15007
|
-
shape:
|
|
15154
|
+
shape: z4.literal("slot"),
|
|
15008
15155
|
length: positiveModelLengthSchema,
|
|
15009
15156
|
width: positiveModelLengthSchema,
|
|
15010
|
-
axis:
|
|
15157
|
+
axis: z4.enum(["u", "v"]).default("v")
|
|
15011
15158
|
}).strict()
|
|
15012
15159
|
]);
|
|
15013
15160
|
var sheetMetalShape = {
|
|
15014
|
-
profile:
|
|
15161
|
+
profile: z4.enum(["plate", "angle", "channel"]).default("plate"),
|
|
15015
15162
|
width: positiveModelLengthSchema,
|
|
15016
15163
|
/** Straight base length between bend tangencies, not overall width. */
|
|
15017
15164
|
baseLength: positiveModelLengthSchema,
|
|
@@ -15019,106 +15166,10 @@ var sheetMetalShape = {
|
|
|
15019
15166
|
flangeHeight: positiveModelLengthSchema.default(12),
|
|
15020
15167
|
thickness: positiveModelLengthSchema.default(1),
|
|
15021
15168
|
insideBendRadius: positiveModelLengthSchema.default(1),
|
|
15022
|
-
holes:
|
|
15169
|
+
holes: z4.array(sheetMetalHoleSchema).max(100).default([])
|
|
15023
15170
|
};
|
|
15024
|
-
var sheetMetalModelPropsSchema =
|
|
15025
|
-
var sheetMetalModelDefinitionSchema =
|
|
15026
|
-
var hexSocketBoltDimensions = {
|
|
15027
|
-
M2: {
|
|
15028
|
-
diameter: 2,
|
|
15029
|
-
threadPitch: 0.4,
|
|
15030
|
-
headDiameter: 3.8,
|
|
15031
|
-
headHeight: 2,
|
|
15032
|
-
socketWidth: 1.5,
|
|
15033
|
-
socketDepth: 1
|
|
15034
|
-
},
|
|
15035
|
-
"M2.5": {
|
|
15036
|
-
diameter: 2.5,
|
|
15037
|
-
threadPitch: 0.45,
|
|
15038
|
-
headDiameter: 4.5,
|
|
15039
|
-
headHeight: 2.5,
|
|
15040
|
-
socketWidth: 2,
|
|
15041
|
-
socketDepth: 1.1
|
|
15042
|
-
},
|
|
15043
|
-
M3: {
|
|
15044
|
-
diameter: 3,
|
|
15045
|
-
threadPitch: 0.5,
|
|
15046
|
-
headDiameter: 5.5,
|
|
15047
|
-
headHeight: 3,
|
|
15048
|
-
socketWidth: 2.5,
|
|
15049
|
-
socketDepth: 1.3
|
|
15050
|
-
},
|
|
15051
|
-
M4: {
|
|
15052
|
-
diameter: 4,
|
|
15053
|
-
threadPitch: 0.7,
|
|
15054
|
-
headDiameter: 7,
|
|
15055
|
-
headHeight: 4,
|
|
15056
|
-
socketWidth: 3,
|
|
15057
|
-
socketDepth: 2
|
|
15058
|
-
},
|
|
15059
|
-
M5: {
|
|
15060
|
-
diameter: 5,
|
|
15061
|
-
threadPitch: 0.8,
|
|
15062
|
-
headDiameter: 8.5,
|
|
15063
|
-
headHeight: 5,
|
|
15064
|
-
socketWidth: 4,
|
|
15065
|
-
socketDepth: 2.5
|
|
15066
|
-
},
|
|
15067
|
-
M6: {
|
|
15068
|
-
diameter: 6,
|
|
15069
|
-
threadPitch: 1,
|
|
15070
|
-
headDiameter: 10,
|
|
15071
|
-
headHeight: 6,
|
|
15072
|
-
socketWidth: 5,
|
|
15073
|
-
socketDepth: 3
|
|
15074
|
-
},
|
|
15075
|
-
M8: {
|
|
15076
|
-
diameter: 8,
|
|
15077
|
-
threadPitch: 1.25,
|
|
15078
|
-
headDiameter: 13,
|
|
15079
|
-
headHeight: 8,
|
|
15080
|
-
socketWidth: 6,
|
|
15081
|
-
socketDepth: 4
|
|
15082
|
-
},
|
|
15083
|
-
M10: {
|
|
15084
|
-
diameter: 10,
|
|
15085
|
-
threadPitch: 1.5,
|
|
15086
|
-
headDiameter: 16,
|
|
15087
|
-
headHeight: 10,
|
|
15088
|
-
socketWidth: 8,
|
|
15089
|
-
socketDepth: 5
|
|
15090
|
-
},
|
|
15091
|
-
M12: {
|
|
15092
|
-
diameter: 12,
|
|
15093
|
-
threadPitch: 1.75,
|
|
15094
|
-
headDiameter: 18,
|
|
15095
|
-
headHeight: 12,
|
|
15096
|
-
socketWidth: 10,
|
|
15097
|
-
socketDepth: 6
|
|
15098
|
-
}
|
|
15099
|
-
};
|
|
15100
|
-
var metricBoltSizeSchema = z4.enum([
|
|
15101
|
-
"M2",
|
|
15102
|
-
"M2.5",
|
|
15103
|
-
"M3",
|
|
15104
|
-
"M4",
|
|
15105
|
-
"M5",
|
|
15106
|
-
"M6",
|
|
15107
|
-
"M8",
|
|
15108
|
-
"M10",
|
|
15109
|
-
"M12"
|
|
15110
|
-
]);
|
|
15111
|
-
var hexSocketBoltModelPropsShape = {
|
|
15112
|
-
metricSize: metricBoltSizeSchema,
|
|
15113
|
-
/** Length under the head, excluding the head itself. */
|
|
15114
|
-
length: positiveModelLengthSchema,
|
|
15115
|
-
showThreads: z4.boolean().default(true)
|
|
15116
|
-
};
|
|
15117
|
-
var hexSocketBoltModelPropsSchema = z4.object(hexSocketBoltModelPropsShape).strict();
|
|
15118
|
-
var hexSocketBoltModelDefinitionSchema = z4.object({
|
|
15119
|
-
fn: z4.literal("hexsocketbolt"),
|
|
15120
|
-
...hexSocketBoltModelPropsShape
|
|
15121
|
-
}).strict();
|
|
15171
|
+
var sheetMetalModelPropsSchema = z4.object(sheetMetalShape).strict();
|
|
15172
|
+
var sheetMetalModelDefinitionSchema = z4.object({ fn: z4.literal("sheetmetal"), ...sheetMetalShape }).strict();
|
|
15122
15173
|
var flexScreenOrientationSchema = z5.enum([
|
|
15123
15174
|
"sitsFlat",
|
|
15124
15175
|
"sitsFlatBelowBoard",
|
|
@@ -15308,10 +15359,15 @@ var parseModelStringParams = (definition) => {
|
|
|
15308
15359
|
return params;
|
|
15309
15360
|
};
|
|
15310
15361
|
var lengths = {
|
|
15362
|
+
wirelength: "wireLength",
|
|
15363
|
+
wirediameter: "wireDiameter",
|
|
15311
15364
|
l: "bodyLength",
|
|
15312
15365
|
length: "bodyLength",
|
|
15313
15366
|
bodylength: "bodyLength",
|
|
15314
15367
|
bodywidth: "bodyWidth",
|
|
15368
|
+
backholespacing: "backFaceHoleSpacing",
|
|
15369
|
+
backholediameter: "backFaceHoleDiameter",
|
|
15370
|
+
backholedepth: "backFaceHoleDepth",
|
|
15315
15371
|
shaftlength: "shaftLength",
|
|
15316
15372
|
shaftdiameter: "shaftDiameter",
|
|
15317
15373
|
flatdepth: "shaftFlatDepth",
|
|
@@ -15342,10 +15398,26 @@ function parseNemaMotorModelParams(raw) {
|
|
|
15342
15398
|
if (name in lengths) {
|
|
15343
15399
|
property = lengths[name];
|
|
15344
15400
|
parsed = value;
|
|
15345
|
-
} else if (
|
|
15346
|
-
|
|
15401
|
+
} else if (["backfaceholes", "backfacescrews", "plainbackface"].includes(name)) {
|
|
15402
|
+
if (value) throw new Error(`NEMA flag "${name}" does not accept a value`);
|
|
15403
|
+
property = "backFace";
|
|
15404
|
+
parsed = name === "backfaceholes" ? "holes" : name === "backfacescrews" ? "screws" : "plain";
|
|
15405
|
+
} else if (["wirestubs", "nowires"].includes(name) || name === "jstph") {
|
|
15406
|
+
if (name === "jstph" && value !== "6" || name !== "jstph" && value)
|
|
15407
|
+
throw new Error(`Invalid wire connection token "${token}"`);
|
|
15408
|
+
property = "wireConnection";
|
|
15409
|
+
parsed = name === "jstph" ? "jst-ph-6" : name === "nowires" ? "none" : "stubs";
|
|
15410
|
+
} else if (name === "wirecount") {
|
|
15411
|
+
property = "wireCount";
|
|
15412
|
+
if (!/^\d+$/.test(value)) throw new Error("wirecount requires an integer");
|
|
15413
|
+
parsed = Number(value);
|
|
15414
|
+
} else if (name === "backscrewm") {
|
|
15415
|
+
property = "backFaceScrewSize";
|
|
15416
|
+
parsed = `M${value}`;
|
|
15417
|
+
} else if (name === "flatangle" || name === "wireangle") {
|
|
15418
|
+
property = name === "flatangle" ? "shaftFlatAngle" : "wireSideAngle";
|
|
15347
15419
|
if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?$/i.test(value))
|
|
15348
|
-
throw new Error(
|
|
15420
|
+
throw new Error(`${name} requires a numeric angle in degrees`);
|
|
15349
15421
|
parsed = Number(value.replace(/deg$/i, ""));
|
|
15350
15422
|
} else if (["round", "dshaft", "throughholes", "blindholes"].includes(name)) {
|
|
15351
15423
|
if (value) throw new Error(`NEMA flag "${name}" does not accept a value`);
|
|
@@ -15729,6 +15801,50 @@ var modelprinter = {
|
|
|
15729
15801
|
getModelNames: () => Object.keys(modelFunctions)
|
|
15730
15802
|
};
|
|
15731
15803
|
var mp = modelprinter;
|
|
15804
|
+
function getNemaMotorReferencePoints(input) {
|
|
15805
|
+
const p = nemaMotorModelPropsSchema.parse(input);
|
|
15806
|
+
const radians = p.wireSideAngle * Math.PI / 180;
|
|
15807
|
+
const x = Math.cos(radians), y = Math.sin(radians);
|
|
15808
|
+
const radius = Math.min(
|
|
15809
|
+
p.bodyWidth / 2 / Math.max(Math.abs(x), Math.abs(y)),
|
|
15810
|
+
(p.bodyWidth - p.faceCornerChamfer) / (Math.abs(x) + Math.abs(y))
|
|
15811
|
+
);
|
|
15812
|
+
const flatRadians = p.shaftFlatAngle * Math.PI / 180;
|
|
15813
|
+
return {
|
|
15814
|
+
frontface: {
|
|
15815
|
+
position: { x: 0, y: 0, z: 0 },
|
|
15816
|
+
direction: { x: 0, y: 0, z: 1 }
|
|
15817
|
+
},
|
|
15818
|
+
backface: {
|
|
15819
|
+
position: { x: 0, y: 0, z: -p.bodyLength },
|
|
15820
|
+
direction: { x: 0, y: 0, z: -1 }
|
|
15821
|
+
},
|
|
15822
|
+
shafttip: {
|
|
15823
|
+
position: { x: 0, y: 0, z: p.shaftLength },
|
|
15824
|
+
direction: { x: 0, y: 0, z: 1 }
|
|
15825
|
+
},
|
|
15826
|
+
wireside: {
|
|
15827
|
+
position: {
|
|
15828
|
+
x: radius * x,
|
|
15829
|
+
y: radius * y,
|
|
15830
|
+
z: -p.bodyLength + p.rearCapLength / 2
|
|
15831
|
+
},
|
|
15832
|
+
direction: { x, y, z: 0 }
|
|
15833
|
+
},
|
|
15834
|
+
shaftflat: p.shaftShape === "d" ? {
|
|
15835
|
+
position: {
|
|
15836
|
+
x: (p.shaftDiameter / 2 - p.shaftFlatDepth) * Math.cos(flatRadians),
|
|
15837
|
+
y: (p.shaftDiameter / 2 - p.shaftFlatDepth) * Math.sin(flatRadians),
|
|
15838
|
+
z: p.shaftLength - p.shaftFlatLength / 2
|
|
15839
|
+
},
|
|
15840
|
+
direction: {
|
|
15841
|
+
x: Math.cos(flatRadians),
|
|
15842
|
+
y: Math.sin(flatRadians),
|
|
15843
|
+
z: 0
|
|
15844
|
+
}
|
|
15845
|
+
} : void 0
|
|
15846
|
+
};
|
|
15847
|
+
}
|
|
15732
15848
|
|
|
15733
15849
|
// node_modules/@tscircuit/footprinter/dist/index.js
|
|
15734
15850
|
import {
|
|
@@ -29901,6 +30017,7 @@ function signedArea(data, start, end, dim) {
|
|
|
29901
30017
|
|
|
29902
30018
|
// node_modules/jscad-electronics/dist/vanilla.js
|
|
29903
30019
|
var import_modeling2 = __toESM(require_src(), 1);
|
|
30020
|
+
var import_modeling3 = __toESM(require_src(), 1);
|
|
29904
30021
|
|
|
29905
30022
|
// node_modules/jscad-electronics/node_modules/@tscircuit/mm/dist/index.js
|
|
29906
30023
|
var unitToMm3 = {
|
|
@@ -30065,7 +30182,7 @@ var createHexSocketBoltMesh = (input) => {
|
|
|
30065
30182
|
} = hexSocketBoltDimensions[props.metricSize];
|
|
30066
30183
|
const { length: length83, showThreads } = props;
|
|
30067
30184
|
const segments = 96;
|
|
30068
|
-
const steps = Math.max(2, Math.ceil(length83 / pitch * 24));
|
|
30185
|
+
const steps = showThreads ? Math.max(2, Math.ceil(length83 / pitch * 24)) : 2;
|
|
30069
30186
|
if (steps > 24e3)
|
|
30070
30187
|
throw new Error(
|
|
30071
30188
|
"Bolt length exceeds mesh resolution limit (1000 thread turns)"
|
|
@@ -30101,8 +30218,11 @@ var createHexSocketBoltMesh = (input) => {
|
|
|
30101
30218
|
}
|
|
30102
30219
|
};
|
|
30103
30220
|
let previous = -1;
|
|
30104
|
-
|
|
30105
|
-
|
|
30221
|
+
const shaftLevels = showThreads ? Array.from(
|
|
30222
|
+
{ length: steps + 1 },
|
|
30223
|
+
(_, step) => -length83 + length83 * step / steps
|
|
30224
|
+
) : [-length83, -length83 + tipBevel, 0];
|
|
30225
|
+
for (const z27 of shaftLevels) {
|
|
30106
30226
|
const current = ring(z27, (angle) => {
|
|
30107
30227
|
const phase = ((z27 / pitch - angle / (2 * Math.PI)) % 1 + 1) % 1;
|
|
30108
30228
|
const distance22 = Math.min(phase, 1 - phase);
|
|
@@ -30307,6 +30427,64 @@ function SheetMetal({ color = "#737e8f", ...props }) {
|
|
|
30307
30427
|
var resolveNemaMotorProps = nemaMotorModelPropsSchema.parse.bind(
|
|
30308
30428
|
nemaMotorModelPropsSchema
|
|
30309
30429
|
);
|
|
30430
|
+
function createNemaMotorWireGeometry(input) {
|
|
30431
|
+
const p = resolveNemaMotorProps(input);
|
|
30432
|
+
if (p.wireConnection === "none") return [];
|
|
30433
|
+
const { position } = getNemaMotorReferencePoints(p).wireside;
|
|
30434
|
+
const angle = p.wireSideAngle * Math.PI / 180;
|
|
30435
|
+
const place = (geometry) => import_modeling3.default.transforms.translate(
|
|
30436
|
+
[position.x, position.y, position.z],
|
|
30437
|
+
import_modeling3.default.transforms.rotateZ(angle, geometry)
|
|
30438
|
+
);
|
|
30439
|
+
if (p.wireConnection === "stubs") {
|
|
30440
|
+
const colors2 = [
|
|
30441
|
+
"#d53f3f",
|
|
30442
|
+
"#2463af",
|
|
30443
|
+
"#3b934b",
|
|
30444
|
+
"#252830",
|
|
30445
|
+
"#e5d049",
|
|
30446
|
+
"#eeeeee",
|
|
30447
|
+
"#ce7432",
|
|
30448
|
+
"#803e91"
|
|
30449
|
+
];
|
|
30450
|
+
return Array.from({ length: p.wireCount }, (_, i) => ({
|
|
30451
|
+
color: colors2[i],
|
|
30452
|
+
geometry: place(
|
|
30453
|
+
import_modeling3.default.transforms.translate(
|
|
30454
|
+
[
|
|
30455
|
+
(p.wireLength - 0.15) / 2,
|
|
30456
|
+
(i - (p.wireCount - 1) / 2) * p.wireDiameter * 1.5,
|
|
30457
|
+
0
|
|
30458
|
+
],
|
|
30459
|
+
import_modeling3.default.transforms.rotateY(
|
|
30460
|
+
Math.PI / 2,
|
|
30461
|
+
import_modeling3.default.primitives.cylinder({
|
|
30462
|
+
height: p.wireLength + 0.15,
|
|
30463
|
+
radius: p.wireDiameter / 2,
|
|
30464
|
+
segments: 24
|
|
30465
|
+
})
|
|
30466
|
+
)
|
|
30467
|
+
)
|
|
30468
|
+
)
|
|
30469
|
+
}));
|
|
30470
|
+
}
|
|
30471
|
+
const shell = import_modeling3.default.booleans.subtract(
|
|
30472
|
+
import_modeling3.default.primitives.cuboid({ size: [6.1, 13.9, 4.5], center: [2.95, 0, 0] }),
|
|
30473
|
+
import_modeling3.default.primitives.cuboid({ size: [5.5, 12.7, 3.3], center: [3.55, 0, 0] })
|
|
30474
|
+
);
|
|
30475
|
+
return [
|
|
30476
|
+
{ color: "#eeeeea", geometry: place(shell) },
|
|
30477
|
+
...Array.from({ length: 6 }, (_, i) => ({
|
|
30478
|
+
color: "#b8bec6",
|
|
30479
|
+
geometry: place(
|
|
30480
|
+
import_modeling3.default.primitives.cuboid({
|
|
30481
|
+
size: [3.4, 0.5, 0.5],
|
|
30482
|
+
center: [1.7, (i - 2.5) * 2, 0]
|
|
30483
|
+
})
|
|
30484
|
+
)
|
|
30485
|
+
}))
|
|
30486
|
+
];
|
|
30487
|
+
}
|
|
30310
30488
|
var circle = (radius, x = 0, y = 0) => Array.from({ length: 96 }, (_, i) => [
|
|
30311
30489
|
x + radius * Math.cos(i * Math.PI / 48),
|
|
30312
30490
|
y + radius * Math.sin(i * Math.PI / 48)
|
|
@@ -30353,12 +30531,34 @@ function createNemaMotorSections(input) {
|
|
|
30353
30531
|
add("frontCap", front, -holeDepth, 0, holes);
|
|
30354
30532
|
add("frontCap", front, -p.frontCapLength, -holeDepth);
|
|
30355
30533
|
add("body", core, -p.bodyLength + p.rearCapLength, -p.frontCapLength);
|
|
30356
|
-
|
|
30357
|
-
|
|
30358
|
-
|
|
30359
|
-
|
|
30360
|
-
|
|
30361
|
-
|
|
30534
|
+
if (p.backFace === "plain") {
|
|
30535
|
+
add(
|
|
30536
|
+
"rearCap",
|
|
30537
|
+
p.mountingHoleThrough ? core : front,
|
|
30538
|
+
-p.bodyLength,
|
|
30539
|
+
-p.bodyLength + p.rearCapLength
|
|
30540
|
+
);
|
|
30541
|
+
} else {
|
|
30542
|
+
const halfPitch = p.backFaceHoleSpacing / 2;
|
|
30543
|
+
const rearHoles = [-halfPitch, halfPitch].flatMap(
|
|
30544
|
+
(x) => [-halfPitch, halfPitch].map(
|
|
30545
|
+
(y) => circle(p.backFaceHoleDiameter / 2, x, y)
|
|
30546
|
+
)
|
|
30547
|
+
);
|
|
30548
|
+
add(
|
|
30549
|
+
"rearCap",
|
|
30550
|
+
front,
|
|
30551
|
+
-p.bodyLength,
|
|
30552
|
+
-p.bodyLength + p.backFaceHoleDepth,
|
|
30553
|
+
rearHoles
|
|
30554
|
+
);
|
|
30555
|
+
add(
|
|
30556
|
+
"rearCap",
|
|
30557
|
+
front,
|
|
30558
|
+
-p.bodyLength + p.backFaceHoleDepth,
|
|
30559
|
+
-p.bodyLength + p.rearCapLength
|
|
30560
|
+
);
|
|
30561
|
+
}
|
|
30362
30562
|
add("pilot", circle(p.pilotDiameter / 2), 0, p.pilotLength);
|
|
30363
30563
|
const r = p.shaftDiameter / 2;
|
|
30364
30564
|
const round2 = circle(r);
|
|
@@ -30381,34 +30581,60 @@ function createNemaMotorSections(input) {
|
|
|
30381
30581
|
}
|
|
30382
30582
|
return sections;
|
|
30383
30583
|
}
|
|
30584
|
+
var generalize = import_modeling2.default.modifiers.generalize;
|
|
30384
30585
|
function NemaMotor({
|
|
30385
30586
|
bodyColor = "#242830",
|
|
30386
30587
|
capColor = "#aeb5bd",
|
|
30387
30588
|
shaftColor = "#b8bec6",
|
|
30589
|
+
screwColor = "#626b78",
|
|
30388
30590
|
...props
|
|
30389
30591
|
}) {
|
|
30390
|
-
|
|
30391
|
-
|
|
30392
|
-
|
|
30393
|
-
|
|
30394
|
-
|
|
30395
|
-
|
|
30396
|
-
|
|
30397
|
-
|
|
30398
|
-
|
|
30399
|
-
|
|
30400
|
-
|
|
30401
|
-
|
|
30402
|
-
|
|
30403
|
-
|
|
30404
|
-
|
|
30405
|
-
|
|
30406
|
-
|
|
30407
|
-
|
|
30408
|
-
|
|
30409
|
-
|
|
30410
|
-
|
|
30411
|
-
|
|
30592
|
+
const p = resolveNemaMotorProps(props);
|
|
30593
|
+
const screw = p.backFace === "screws" ? import_modeling2.default.transforms.rotateX(
|
|
30594
|
+
Math.PI,
|
|
30595
|
+
createHexSocketBoltGeom({
|
|
30596
|
+
metricSize: p.backFaceScrewSize,
|
|
30597
|
+
length: p.backFaceHoleDepth,
|
|
30598
|
+
showThreads: false
|
|
30599
|
+
})
|
|
30600
|
+
) : void 0;
|
|
30601
|
+
const halfPitch = p.backFaceHoleSpacing / 2;
|
|
30602
|
+
return /* @__PURE__ */ jsxs(Fragment2, { children: [
|
|
30603
|
+
createNemaMotorSections(p).map((section, index2) => {
|
|
30604
|
+
const outline = import_modeling2.default.geometries.geom2.fromPoints(section.outline);
|
|
30605
|
+
const profile = section.holes.length ? import_modeling2.default.booleans.subtract(
|
|
30606
|
+
outline,
|
|
30607
|
+
...section.holes.map((h2) => import_modeling2.default.geometries.geom2.fromPoints(h2))
|
|
30608
|
+
) : outline;
|
|
30609
|
+
const geometry = import_modeling2.default.transforms.translate(
|
|
30610
|
+
[0, 0, section.zMin],
|
|
30611
|
+
import_modeling2.default.extrusions.extrudeLinear(
|
|
30612
|
+
{ height: section.zMax - section.zMin },
|
|
30613
|
+
profile
|
|
30614
|
+
)
|
|
30615
|
+
);
|
|
30616
|
+
return /* @__PURE__ */ jsx3(
|
|
30617
|
+
Colorize,
|
|
30618
|
+
{
|
|
30619
|
+
color: section.name === "body" ? bodyColor : section.name === "shaft" ? shaftColor : capColor,
|
|
30620
|
+
children: /* @__PURE__ */ jsx3(Custom, { geometry: generalize({ simplify: true }, geometry) })
|
|
30621
|
+
},
|
|
30622
|
+
`${section.name}-${index2}`
|
|
30623
|
+
);
|
|
30624
|
+
}),
|
|
30625
|
+
createNemaMotorWireGeometry(p).map(({ geometry, color }, index2) => /* @__PURE__ */ jsx3(Colorize, { color, children: /* @__PURE__ */ jsx3(Custom, { geometry: generalize({ simplify: true }, geometry) }) }, `wire-${index2}`)),
|
|
30626
|
+
screw && [-halfPitch, halfPitch].flatMap(
|
|
30627
|
+
(x) => [-halfPitch, halfPitch].map((y) => /* @__PURE__ */ jsx3(Colorize, { color: screwColor, children: /* @__PURE__ */ jsx3(
|
|
30628
|
+
Custom,
|
|
30629
|
+
{
|
|
30630
|
+
geometry: import_modeling2.default.transforms.translate(
|
|
30631
|
+
[x, y, -p.bodyLength],
|
|
30632
|
+
generalize({ simplify: true }, screw)
|
|
30633
|
+
)
|
|
30634
|
+
}
|
|
30635
|
+
) }, `rear-screw-${x}-${y}`))
|
|
30636
|
+
)
|
|
30637
|
+
] });
|
|
30412
30638
|
}
|
|
30413
30639
|
function LGA(p) {
|
|
30414
30640
|
for (const k of [
|
|
@@ -39017,8 +39243,8 @@ function renderNode(node, colorCtx, renderCtx) {
|
|
|
39017
39243
|
}
|
|
39018
39244
|
return (children ?? []).flatMap((c) => renderNode(c, colorCtx, renderCtx));
|
|
39019
39245
|
}
|
|
39020
|
-
function render(root,
|
|
39021
|
-
const geometries = renderNode(root, void 0, { jscad:
|
|
39246
|
+
function render(root, jscad42) {
|
|
39247
|
+
const geometries = renderNode(root, void 0, { jscad: jscad42 });
|
|
39022
39248
|
return { geometries };
|
|
39023
39249
|
}
|
|
39024
39250
|
function convertCSGToThreeGeom(csg) {
|
|
@@ -39097,9 +39323,9 @@ function convertCSGToThreeGeom(csg) {
|
|
|
39097
39323
|
console.error("Invalid CSG object: neither polygons nor sides found");
|
|
39098
39324
|
return new BufferGeometry();
|
|
39099
39325
|
}
|
|
39100
|
-
function getJscadModelForFootprint(footprint,
|
|
39326
|
+
function getJscadModelForFootprint(footprint, jscad42) {
|
|
39101
39327
|
const vnode = h(Footprinter3d, { footprint });
|
|
39102
|
-
return render(vnode,
|
|
39328
|
+
return render(vnode, jscad42);
|
|
39103
39329
|
}
|
|
39104
39330
|
|
|
39105
39331
|
// src/three-components/FootprinterModel.tsx
|
|
@@ -39702,7 +39928,7 @@ function GltfModel({
|
|
|
39702
39928
|
|
|
39703
39929
|
// src/three-components/JscadModel.tsx
|
|
39704
39930
|
var import_jscad_planner = __toESM(require_dist(), 1);
|
|
39705
|
-
var
|
|
39931
|
+
var import_modeling4 = __toESM(require_src(), 1);
|
|
39706
39932
|
import * as THREE11 from "three";
|
|
39707
39933
|
import { useState as useState6, useEffect as useEffect9 } from "react";
|
|
39708
39934
|
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
@@ -39723,7 +39949,7 @@ var JscadModel = ({
|
|
|
39723
39949
|
}) => {
|
|
39724
39950
|
const [mesh, setMesh] = useState6(null);
|
|
39725
39951
|
useEffect9(() => {
|
|
39726
|
-
const jscadObject = (0, import_jscad_planner.executeJscadOperations)(
|
|
39952
|
+
const jscadObject = (0, import_jscad_planner.executeJscadOperations)(import_modeling4.default, jscadPlan);
|
|
39727
39953
|
if (!jscadObject || !jscadObject.polygons && !jscadObject.sides) {
|
|
39728
39954
|
setMesh(null);
|
|
39729
39955
|
return;
|
|
@@ -40888,7 +41114,7 @@ import * as THREE25 from "three";
|
|
|
40888
41114
|
// package.json
|
|
40889
41115
|
var package_default = {
|
|
40890
41116
|
name: "@tscircuit/3d-viewer",
|
|
40891
|
-
version: "0.0.
|
|
41117
|
+
version: "0.0.613",
|
|
40892
41118
|
repository: {
|
|
40893
41119
|
type: "git",
|
|
40894
41120
|
url: "https://github.com/tscircuit/3d-viewer"
|
|
@@ -40926,7 +41152,7 @@ var package_default = {
|
|
|
40926
41152
|
dependencies: {
|
|
40927
41153
|
"@jscad/regl-renderer": "^2.6.12",
|
|
40928
41154
|
"@jscad/stl-serializer": "^2.1.20",
|
|
40929
|
-
"circuit-json": "^0.0.
|
|
41155
|
+
"circuit-json": "^0.0.514",
|
|
40930
41156
|
"circuit-to-canvas": "^0.0.131",
|
|
40931
41157
|
"react-hot-toast": "^2.6.0",
|
|
40932
41158
|
three: "^0.165.0",
|
|
@@ -40951,10 +41177,10 @@ var package_default = {
|
|
|
40951
41177
|
"@storybook/blocks": "9.0.0-alpha.17",
|
|
40952
41178
|
"@storybook/react-vite": "^9.1.5",
|
|
40953
41179
|
"@tscircuit/alphabet": "^0.0.25",
|
|
40954
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
41180
|
+
"@tscircuit/circuit-json-util": "^0.0.119",
|
|
40955
41181
|
"@tscircuit/copper-pour-solver": "^0.0.29",
|
|
40956
|
-
"@tscircuit/core": "^0.0.
|
|
40957
|
-
"@tscircuit/props": "^0.0.
|
|
41182
|
+
"@tscircuit/core": "^0.0.2075",
|
|
41183
|
+
"@tscircuit/props": "^0.0.684",
|
|
40958
41184
|
"@tscircuit/solver-utils": "^0.0.4",
|
|
40959
41185
|
"@types/debug": "^4.1.13",
|
|
40960
41186
|
"@types/jsdom": "^21.1.7",
|
|
@@ -40965,7 +41191,7 @@ var package_default = {
|
|
|
40965
41191
|
"bun-match-svg": "^0.0.9",
|
|
40966
41192
|
"bun-types": "1.2.1",
|
|
40967
41193
|
debug: "^4.4.0",
|
|
40968
|
-
"jscad-electronics": "^0.0.
|
|
41194
|
+
"jscad-electronics": "^0.0.184",
|
|
40969
41195
|
"jscad-planner": "^0.0.13",
|
|
40970
41196
|
jsdom: "^26.0.0",
|
|
40971
41197
|
"manifold-3d": "^3.2.1",
|
|
@@ -40977,9 +41203,9 @@ var package_default = {
|
|
|
40977
41203
|
typescript: "^5.7.3",
|
|
40978
41204
|
vite: "^7.1.5",
|
|
40979
41205
|
"vite-tsconfig-paths": "^4.3.2",
|
|
40980
|
-
"circuit-json-to-gltf": "0.0.
|
|
41206
|
+
"circuit-json-to-gltf": "0.0.143",
|
|
40981
41207
|
zod: "^3.25.67",
|
|
40982
|
-
"@tscircuit/modelprinter": "^0.0.
|
|
41208
|
+
"@tscircuit/modelprinter": "^0.0.6"
|
|
40983
41209
|
},
|
|
40984
41210
|
engines: {
|
|
40985
41211
|
node: "24.x"
|
|
@@ -57699,7 +57925,7 @@ function createGeometryFromPolygons(polygons) {
|
|
|
57699
57925
|
}
|
|
57700
57926
|
|
|
57701
57927
|
// src/utils/render-component.tsx
|
|
57702
|
-
var
|
|
57928
|
+
var import_modeling5 = __toESM(require_src(), 1);
|
|
57703
57929
|
var import_jscad_planner2 = __toESM(require_dist(), 1);
|
|
57704
57930
|
var jscadModeling2 = __toESM(require_src(), 1);
|
|
57705
57931
|
import * as THREE57 from "three";
|
|
@@ -57762,7 +57988,7 @@ async function renderComponent(component, scene) {
|
|
|
57762
57988
|
}
|
|
57763
57989
|
if (component.model_jscad) {
|
|
57764
57990
|
const jscadObject = (0, import_jscad_planner2.executeJscadOperations)(
|
|
57765
|
-
|
|
57991
|
+
import_modeling5.default,
|
|
57766
57992
|
component.model_jscad
|
|
57767
57993
|
);
|
|
57768
57994
|
if (jscadObject && (jscadObject.polygons || jscadObject.sides)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/3d-viewer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.614",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/tscircuit/3d-viewer"
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@jscad/regl-renderer": "^2.6.12",
|
|
40
40
|
"@jscad/stl-serializer": "^2.1.20",
|
|
41
|
-
"circuit-json": "^0.0.
|
|
41
|
+
"circuit-json": "^0.0.514",
|
|
42
42
|
"circuit-to-canvas": "^0.0.131",
|
|
43
43
|
"react-hot-toast": "^2.6.0",
|
|
44
44
|
"three": "^0.165.0",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"@storybook/blocks": "9.0.0-alpha.17",
|
|
64
64
|
"@storybook/react-vite": "^9.1.5",
|
|
65
65
|
"@tscircuit/alphabet": "^0.0.25",
|
|
66
|
-
"@tscircuit/circuit-json-util": "^0.0.
|
|
66
|
+
"@tscircuit/circuit-json-util": "^0.0.119",
|
|
67
67
|
"@tscircuit/copper-pour-solver": "^0.0.29",
|
|
68
|
-
"@tscircuit/core": "^0.0.
|
|
69
|
-
"@tscircuit/props": "^0.0.
|
|
68
|
+
"@tscircuit/core": "^0.0.2075",
|
|
69
|
+
"@tscircuit/props": "^0.0.684",
|
|
70
70
|
"@tscircuit/solver-utils": "^0.0.4",
|
|
71
71
|
"@types/debug": "^4.1.13",
|
|
72
72
|
"@types/jsdom": "^21.1.7",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"bun-match-svg": "^0.0.9",
|
|
78
78
|
"bun-types": "1.2.1",
|
|
79
79
|
"debug": "^4.4.0",
|
|
80
|
-
"jscad-electronics": "^0.0.
|
|
80
|
+
"jscad-electronics": "^0.0.184",
|
|
81
81
|
"jscad-planner": "^0.0.13",
|
|
82
82
|
"jsdom": "^26.0.0",
|
|
83
83
|
"manifold-3d": "^3.2.1",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"typescript": "^5.7.3",
|
|
90
90
|
"vite": "^7.1.5",
|
|
91
91
|
"vite-tsconfig-paths": "^4.3.2",
|
|
92
|
-
"circuit-json-to-gltf": "0.0.
|
|
92
|
+
"circuit-json-to-gltf": "0.0.143",
|
|
93
93
|
"zod": "^3.25.67",
|
|
94
|
-
"@tscircuit/modelprinter": "^0.0.
|
|
94
|
+
"@tscircuit/modelprinter": "^0.0.6"
|
|
95
95
|
},
|
|
96
96
|
"engines": {
|
|
97
97
|
"node": "24.x"
|