@jscad/web 2.5.10 → 2.6.0
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/CHANGELOG.md +35 -0
- package/README.md +1 -1
- package/dist/jscad-web.min.js +959 -2030
- package/examples/CHANGELOG.md +30 -0
- package/examples/README.md +1 -5
- package/examples/package.json +1 -1
- package/examples/parameters/gear.js +1 -1
- package/locales/README.md +23 -0
- package/locales/de.json +1 -0
- package/locales/en.json +2 -1
- package/locales/fr.json +1 -0
- package/locales/hr.json +1 -0
- package/locales/ja.json +1 -0
- package/locales/zh.json +62 -0
- package/package.json +7 -7
- package/postInstall.js +0 -1
- package/src/index.js +2 -1
- package/src/sideEffects/i18n/index.js +2 -1
- package/src/sideEffects/worker/index.js +7 -8
- package/src/ui/flow/design.js +10 -305
- package/src/ui/flow/reducers.js +304 -0
- package/examples/old/benchmark-cag.jscad +0 -27
- package/examples/old/benchmark-csg.jscad +0 -29
- package/examples/old/benchmark.jscad +0 -25
- package/examples/old/bunch-cubes.jscad +0 -17
- package/examples/old/complex/example001.jscad +0 -31
- package/examples/old/complex/example002.jscad +0 -25
- package/examples/old/complex/example003.jscad +0 -25
- package/examples/old/complex/example004.jscad +0 -16
- package/examples/old/complex/example005.jscad +0 -27
- package/examples/old/complex/globe.js +0 -235
- package/examples/old/complex/iphone4-case.js +0 -213
- package/examples/old/complex/umbilical_torus.js +0 -43
- package/examples/old/complex/umbilical_torus.scad +0 -37
- package/examples/old/core/cncCutout.js +0 -16
- package/examples/old/core/connectors/servo.js +0 -185
- package/examples/old/core/extrusions/extrudeLinear.js +0 -24
- package/examples/old/core/extrusions/extrudeRectangular.js +0 -21
- package/examples/old/core/extrusions/extrudeRotate.js +0 -43
- package/examples/old/core/extrusions/slices/four2three-round.js +0 -62
- package/examples/old/core/extrusions/slices/four2three.js +0 -53
- package/examples/old/core/extrusions/slices/jar-barrel.js +0 -60
- package/examples/old/core/extrusions/slices/jar.js +0 -69
- package/examples/old/core/extrusions/slices/non-aff.js +0 -72
- package/examples/old/core/extrusions/slices/rose.js +0 -52
- package/examples/old/core/extrusions/slices/screw.js +0 -34
- package/examples/old/core/extrusions/slices/screwDouble.js +0 -34
- package/examples/old/core/extrusions/slices/slices.js +0 -43
- package/examples/old/core/extrusions/slices/spring.js +0 -41
- package/examples/old/core/extrusions/slices/three2four.js +0 -42
- package/examples/old/core/extrusions/slices/tor.js +0 -30
- package/examples/old/core/hulls/hullChain.js +0 -58
- package/examples/old/core/lookup.js +0 -19
- package/examples/old/core/platonics/main.jscad +0 -42
- package/examples/old/core/platonics/maths_geodesic.jscad +0 -192
- package/examples/old/core/platonics/origv07/dualdodeca_difference.stl +0 -1962
- package/examples/old/core/platonics/origv07/dualdodeca_intersection.stl +0 -1374
- package/examples/old/core/platonics/origv07/dualdodeca_union.stl +0 -1822
- package/examples/old/core/platonics/origv07/maths_geodesic.scad +0 -162
- package/examples/old/core/platonics/origv07/platonic.scad +0 -483
- package/examples/old/core/platonics/origv07/test_platonic.scad +0 -616
- package/examples/old/core/platonics/platonic.jscad +0 -528
- package/examples/old/core/text/textSimplex.js +0 -625
- package/examples/old/core/transforms/transformations.js +0 -29
- package/examples/old/echo.jscad +0 -7
- package/examples/old/formats/scad/example001.scad +0 -26
- package/examples/old/formats/scad/example002.scad +0 -23
- package/examples/old/formats/scad/example003.scad +0 -20
- package/examples/old/formats/scad/example004.scad +0 -11
- package/examples/old/formats/scad/example005.scad +0 -20
- package/examples/old/json_logo.json +0 -1
- package/examples/old/parameters/axis-coupler.js +0 -149
- package/examples/old/parameters/celtic-knot-ring.js +0 -300
- package/examples/old/parameters/grille.js +0 -257
- package/examples/old/parameters/lamp-shade.js +0 -369
- package/examples/old/parameters/name-plate.js +0 -46
- package/examples/old/parameters/s-hook.js +0 -131
- package/examples/old/parameters/stepper-motor.js +0 -127
- package/examples/old/various/logo.js +0 -32
- package/examples/old/voxel.json +0 -1
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
// title : S Hook
|
|
2
|
-
// author : Joost Nieuwenhuijse
|
|
3
|
-
// license : MIT License
|
|
4
|
-
// description: a simple S-hook design
|
|
5
|
-
// file : s-hook.jscad
|
|
6
|
-
|
|
7
|
-
// Here we define the user editable parameters:
|
|
8
|
-
|
|
9
|
-
function getParameterDefinitions () {
|
|
10
|
-
return [
|
|
11
|
-
{ name: 'topdiameter', caption: 'Inner diameter of top hook:', type: 'float', initial: 16.7, step: 0.1 },
|
|
12
|
-
{ name: 'clampfactor', caption: 'Snugness of top hook (0 - 100):', type: 'float', initial: 25, min: 0, max: 100 },
|
|
13
|
-
{ name: 'cliplength', caption: 'Top hook clip length:', type: 'float', initial: 5 },
|
|
14
|
-
{ name: 'bottomdiameter', caption: 'Inner diameter of bottom hook:', type: 'float', initial: 20 },
|
|
15
|
-
{ name: 'height', caption: 'Outer height of the hook:', type: 'float', initial: 60 },
|
|
16
|
-
{ name: 'thickness', caption: 'Thickness:', type: 'float', initial: 5 },
|
|
17
|
-
{ name: 'width', caption: 'Width:', type: 'float', initial: 7 },
|
|
18
|
-
{ name: 'rounded', type: 'choice', caption: 'Rounded edges', values: [0, 1], captions: ['No', 'Yes (rendering will take a long time!)'], initial: 0 },
|
|
19
|
-
{ name: 'roundness', caption: 'Diameter of rounded edges (if enabled):', type: 'float', initial: 1.5, step: 0.1 },
|
|
20
|
-
{ name: 'buildwidth', caption: 'Width (x) of build area (to print multiple copies):', type: 'float', initial: 90 },
|
|
21
|
-
{ name: 'builddepth', caption: 'Depth (y) of build area (to print multiple copies):', type: 'float', initial: 90 }
|
|
22
|
-
];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function main (params) {
|
|
26
|
-
if (OpenJsCad.log) OpenJsCad.log('start');
|
|
27
|
-
|
|
28
|
-
var pathresolution = 16;
|
|
29
|
-
var expandresolution = 6;
|
|
30
|
-
|
|
31
|
-
// construct the 2D path:
|
|
32
|
-
var topradius = params.topdiameter / 2;
|
|
33
|
-
var bottomradius = params.bottomdiameter / 2;
|
|
34
|
-
var halfthickness = params.thickness / 2;
|
|
35
|
-
topradius += halfthickness;
|
|
36
|
-
bottomradius += halfthickness;
|
|
37
|
-
|
|
38
|
-
var roundness = params.roundness;
|
|
39
|
-
if (params.rounded !== 1) {
|
|
40
|
-
roundness = 0;
|
|
41
|
-
}
|
|
42
|
-
roundness = Math.min(roundness, halfthickness - 0.1, params.width / 2 - 0.1);
|
|
43
|
-
if (roundness < 0) roundness = 0;
|
|
44
|
-
|
|
45
|
-
var clampfactor = params.clampfactor / 100;
|
|
46
|
-
if (clampfactor < 0) clampfactor = 0;
|
|
47
|
-
if (clampfactor >= 1) clampfactor = 1;
|
|
48
|
-
clampfactor *= (topradius - halfthickness) / topradius;
|
|
49
|
-
|
|
50
|
-
var topstartangle = -180 * Math.acos(1 - 2 * clampfactor) / Math.PI;
|
|
51
|
-
var tophookcenter = new CSG.Vector2D(topradius, 0);
|
|
52
|
-
var tophookstart = tophookcenter.plus(CSG.Vector2D.fromAngleDegrees(topstartangle).times(topradius));
|
|
53
|
-
var circledistance = params.height - topradius - bottomradius - 2 * params.thickness;
|
|
54
|
-
if (circledistance < 0) circledistance = 0;
|
|
55
|
-
var bottomhookcenter = new CSG.Vector2D(-bottomradius, -circledistance);
|
|
56
|
-
var gravityangle = 90 - tophookcenter.minus(bottomhookcenter).angleDegrees();
|
|
57
|
-
|
|
58
|
-
var path = new CSG.Path2D();
|
|
59
|
-
|
|
60
|
-
// top hook curve:
|
|
61
|
-
if (params.cliplength > 0) {
|
|
62
|
-
var clipstart = new CSG.Vector2D([0, -1]).times(params.cliplength).plus(tophookstart);
|
|
63
|
-
path = path.appendPoint(clipstart);
|
|
64
|
-
}
|
|
65
|
-
var topcurvepath = CSG.Path2D.arc({
|
|
66
|
-
center: tophookcenter,
|
|
67
|
-
radius: topradius,
|
|
68
|
-
startangle: topstartangle,
|
|
69
|
-
endangle: 180,
|
|
70
|
-
resolution: pathresolution,
|
|
71
|
-
maketangent: true
|
|
72
|
-
});
|
|
73
|
-
path = path.concat(topcurvepath);
|
|
74
|
-
|
|
75
|
-
// straight middle part:
|
|
76
|
-
if (circledistance > 0) {
|
|
77
|
-
path = path.appendPoint([0, -circledistance]);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// bottom hook curve:
|
|
81
|
-
var bottomcurvepath = CSG.Path2D.arc({
|
|
82
|
-
center: bottomhookcenter,
|
|
83
|
-
radius: bottomradius,
|
|
84
|
-
startangle: 0,
|
|
85
|
-
endangle: -180 - gravityangle,
|
|
86
|
-
resolution: pathresolution,
|
|
87
|
-
maketangent: true
|
|
88
|
-
});
|
|
89
|
-
path = path.concat(bottomcurvepath);
|
|
90
|
-
|
|
91
|
-
// center around origin, and rotate as it would hang under gravity:
|
|
92
|
-
var centerpoint = tophookcenter.plus(bottomhookcenter).times(0.5);
|
|
93
|
-
var matrix = CSG.Matrix4x4.translation(centerpoint.negated().toVector3D(0));
|
|
94
|
-
matrix = matrix.multiply(CSG.Matrix4x4.rotationZ(gravityangle));
|
|
95
|
-
path = path.transform(matrix);
|
|
96
|
-
|
|
97
|
-
// extrude the path to create a 3D solid
|
|
98
|
-
var hook = path.rectangularExtrude(2 * (halfthickness - roundness), params.width - 2 * roundness, pathresolution, true);
|
|
99
|
-
hook = hook.translate([0, 0, -params.width / 2 + roundness]);
|
|
100
|
-
|
|
101
|
-
// expand to create rounded corners:
|
|
102
|
-
if (roundness > 0) {
|
|
103
|
-
hook = hook.expand(roundness, expandresolution);
|
|
104
|
-
}
|
|
105
|
-
// hook = hook.toPointCloud(0.1);
|
|
106
|
-
|
|
107
|
-
// determine how many objects will fit in the build area:
|
|
108
|
-
var bounds = hook.getBounds();
|
|
109
|
-
var objsize = bounds[1].minus(bounds[0]);
|
|
110
|
-
var margin = 5; // distance between the copies
|
|
111
|
-
var numx = Math.floor((params.buildwidth + margin) / (objsize.x + margin));
|
|
112
|
-
var numy = Math.floor((params.builddepth + margin) / (objsize.y + margin));
|
|
113
|
-
if (numx < 1) numx = 1;
|
|
114
|
-
if (numy < 1) numy = 1;
|
|
115
|
-
|
|
116
|
-
// and make the copies:
|
|
117
|
-
var result = new CSG();
|
|
118
|
-
for (var x = 0; x < numx; x++) {
|
|
119
|
-
var deltax = ((1 - numx) / 2 + x) * (objsize.x + margin);
|
|
120
|
-
var colresult = new CSG();
|
|
121
|
-
for (var y = 0; y < numy; y++) {
|
|
122
|
-
var deltay = ((1 - numy) / 2 + y) * (objsize.y + margin);
|
|
123
|
-
var translated = hook.translate(new CSG.Vector3D(deltax, deltay, 0));
|
|
124
|
-
colresult = colresult.union(translated);
|
|
125
|
-
}
|
|
126
|
-
result = result.union(colresult);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (OpenJsCad.log) OpenJsCad.log('finish');
|
|
130
|
-
return result;
|
|
131
|
-
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/* title : Stepper Motor
|
|
2
|
-
// author : Derrick Oswald
|
|
3
|
-
// license : MIT License
|
|
4
|
-
// description: a simple stepper motor design
|
|
5
|
-
// tags: extrusion, extrudeFromSlices, slices
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const { circle, cube, cylinder } = require('@jscad/modeling').primitives
|
|
9
|
-
const { color } = require('@jscad/modeling').color
|
|
10
|
-
const { translate, rotateX } = require('@jscad/modeling').transforms
|
|
11
|
-
const { extrudeFromSlices, slice } = require('@jscad/modeling').extrusions
|
|
12
|
-
const { mat4 } = require('@jscad/modeling').math
|
|
13
|
-
const { union, intersect } = require('@jscad/modeling').booleans
|
|
14
|
-
const { sqrt } = Math
|
|
15
|
-
const { degToRad } = require('@jscad/modeling').math
|
|
16
|
-
|
|
17
|
-
const getParameterDefinitions = () => {
|
|
18
|
-
return ([
|
|
19
|
-
{ name: 'motorBody_len', type: 'float', initial: 47.5, step: 0.5, caption: 'Motor length' },
|
|
20
|
-
{ name: 'motorBody_width', type: 'float', initial: 42.0, step: 0.5, caption: 'Motor width' },
|
|
21
|
-
{ name: 'motorBody_chamfer', type: 'float', initial: 5.0, step: 0.1, caption: 'Motor chamfer' },
|
|
22
|
-
|
|
23
|
-
{ name: 'motorCap_len', type: 'float', initial: 8.0, step: 0.1, caption: 'Motor cap length' },
|
|
24
|
-
{ name: 'motorCap_thickness', type: 'float', initial: 1.0, step: 0.1, caption: 'Motor cap thickness' },
|
|
25
|
-
{ name: 'motorCap_chamfer', type: 'float', initial: 2.5, step: 0.1, caption: 'Motor cap chamfer' },
|
|
26
|
-
|
|
27
|
-
{ name: 'shaft_len', type: 'float', initial: 22.0, step: 0.5, caption: 'Shaft length' },
|
|
28
|
-
{ name: 'shaft_radius', type: 'float', initial: 2.5, step: 0.1, caption: 'Shaft radius' },
|
|
29
|
-
|
|
30
|
-
{ name: 'motorRing_radius', type: 'float', initial: 11.0, step: 0.1, caption: 'Ring radius' },
|
|
31
|
-
{ name: 'motorRing_height', type: 'float', initial: 2.0, step: 0.1, caption: 'Ring height' },
|
|
32
|
-
|
|
33
|
-
{ name: 'mountingholes_fromcent', type: 'float', initial: 15.5, step: 0.1, caption: 'Mounting hole offset' },
|
|
34
|
-
{ name: 'mountingholes_radius', type: 'float', initial: 1.5, step: 0.1, caption: 'Mounting hole radius' },
|
|
35
|
-
{ name: 'mountingholes_depth', type: 'float', initial: 4.5, step: 0.1, caption: 'Mounting hole depth' }
|
|
36
|
-
])
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const main = (parameters) => {
|
|
40
|
-
const length = parameters.motorBody_len / 2
|
|
41
|
-
const width = parameters.motorBody_width / 2
|
|
42
|
-
const ch = sqrt(2.0) * width - sqrt(0.5) * parameters.motorBody_chamfer
|
|
43
|
-
const ch2 = sqrt(2.0) * width - sqrt(0.5) * parameters.motorCap_chamfer
|
|
44
|
-
const depth = parameters.mountingholes_depth
|
|
45
|
-
const offset = parameters.mountingholes_fromcent
|
|
46
|
-
|
|
47
|
-
const cubeColor = [0.67843137254901960784313725490196, 0.70588235294117647058823529411765, 0.70588235294117647058823529411765]
|
|
48
|
-
const fooColor = [0.87058823529411764705882352941176, 0.89803921568627450980392156862745, 0.90588235294117647058823529411765]
|
|
49
|
-
let body = CSG.roundedCube({
|
|
50
|
-
center: [0, 0, 0],
|
|
51
|
-
radius: [length - parameters.motorCap_len, width - parameters.motorCap_thickness, width - parameters.motorCap_thickness],
|
|
52
|
-
roundradius: 0.2,
|
|
53
|
-
resolution: 16
|
|
54
|
-
})
|
|
55
|
-
body = color(cubeColor, body)
|
|
56
|
-
let xcube = cube({
|
|
57
|
-
center: [0, 0, 0],
|
|
58
|
-
radius: [length, ch, ch]
|
|
59
|
-
})
|
|
60
|
-
xcube = color(cubeColor, xcube)
|
|
61
|
-
body = intersect(body, rotateX(degToRad(45), xcube))
|
|
62
|
-
|
|
63
|
-
var cube2 = CSG.roundedCube({
|
|
64
|
-
center: [length - (parameters.motorCap_len / 2.0), 0, 0],
|
|
65
|
-
radius: [(parameters.motorCap_len / 2.0), width, width],
|
|
66
|
-
roundradius: 0.2,
|
|
67
|
-
resolution: 16
|
|
68
|
-
})
|
|
69
|
-
cube2 = cube2.setColor(fooColor)
|
|
70
|
-
var cube3 = cube2.translate([-(parameters.motorBody_len - parameters.motorCap_len), 0, 0])
|
|
71
|
-
xcube = cube({
|
|
72
|
-
center: [0, 0, 0],
|
|
73
|
-
radius: [length, ch2, ch2]
|
|
74
|
-
})
|
|
75
|
-
xcube = color(fooColor, xcube)
|
|
76
|
-
xcube = rotateX(degToRad(45), xcube)
|
|
77
|
-
cube2 = intersect(cube2, xcube)
|
|
78
|
-
cube3 = intersect(cube3, xcube)
|
|
79
|
-
|
|
80
|
-
/* pipe(
|
|
81
|
-
cube({
|
|
82
|
-
center: [0, 0, 0],
|
|
83
|
-
radius: [length, ch2, ch2]
|
|
84
|
-
}),
|
|
85
|
-
color(fooColor),
|
|
86
|
-
rotateX(45)
|
|
87
|
-
) */
|
|
88
|
-
|
|
89
|
-
const ring = color([0.81176470588235294117647058823529, 0.84313725490196078431372549019608, 0.85098039215686274509803921568627],
|
|
90
|
-
cylinder({
|
|
91
|
-
start: [length, 0, 0],
|
|
92
|
-
end: [length + parameters.motorRing_height, 0, 0],
|
|
93
|
-
radius: parameters.motorRing_radius,
|
|
94
|
-
resolution: 100
|
|
95
|
-
})
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
const shaft = color([0.9, 0.91, 0.91],
|
|
99
|
-
cylinder({
|
|
100
|
-
start: [length + parameters.motorRing_height, 0, 0],
|
|
101
|
-
end: [length + parameters.motorRing_height + parameters.shaft_len, 0, 0],
|
|
102
|
-
radius: parameters.shaft_radius,
|
|
103
|
-
resolution: 50
|
|
104
|
-
})
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
const mountinghole = color([0.2, 0.2, 0.2],
|
|
108
|
-
cylinder({
|
|
109
|
-
start: [-depth, 0, 0],
|
|
110
|
-
end: [0, 0, 0],
|
|
111
|
-
radius: parameters.mountingholes_radius,
|
|
112
|
-
resolution: 20
|
|
113
|
-
})
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
let motor = union([cube, cube2, cube3, ring, shaft])
|
|
117
|
-
motor = motor.subtract(
|
|
118
|
-
translate([length, offset, offset], mountinghole),
|
|
119
|
-
translate([length, offset, -offset], mountinghole),
|
|
120
|
-
translate([length, -offset, offset], mountinghole),
|
|
121
|
-
translate([length, -offset, -offset], mountinghole)
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
return translate([0, 0, width], motor)
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
module.exports = { main, getParameterDefinitions }
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// title : OpenJSCAD.org Logo BIG
|
|
2
|
-
// author : Jeff Gay
|
|
3
|
-
// license : MIT License
|
|
4
|
-
// revision : 0.001
|
|
5
|
-
// tags : Logo,Intersection,Sphere,Cube,Big
|
|
6
|
-
// file : logo_big.jscad
|
|
7
|
-
|
|
8
|
-
function main () {
|
|
9
|
-
var small = union(
|
|
10
|
-
difference(
|
|
11
|
-
cube({size: 3, center: true}),
|
|
12
|
-
sphere({r: 2, center: true})
|
|
13
|
-
),
|
|
14
|
-
intersection(
|
|
15
|
-
sphere({r: 1.3, center: true}),
|
|
16
|
-
cube({size: 2.1, center: true})
|
|
17
|
-
)
|
|
18
|
-
).translate([0, 0, 1.5]).scale(10);
|
|
19
|
-
|
|
20
|
-
var large = union(
|
|
21
|
-
difference(
|
|
22
|
-
cube({size: 300, center: true}),
|
|
23
|
-
sphere({r: 200, center: true})
|
|
24
|
-
),
|
|
25
|
-
intersection(
|
|
26
|
-
sphere({r: 130, center: true}),
|
|
27
|
-
cube({size: 210, center: true})
|
|
28
|
-
)
|
|
29
|
-
).translate([0, 0, 150]);
|
|
30
|
-
|
|
31
|
-
return small.union(large);
|
|
32
|
-
}
|