@jscad/web 2.5.3 → 2.5.4

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/data/themes.js +40 -40
  3. package/dist/jscad-web.min.js +46 -46
  4. package/examples/core/colors/basicColors.js +0 -1
  5. package/examples/core/colors/colorCube.js +10 -12
  6. package/examples/core/curves/bezier/extrudeAlongPath.js +20 -22
  7. package/examples/core/curves/bezier/simpleExtrude.js +4 -6
  8. package/examples/core/extrusions/basicExtrusions.js +3 -3
  9. package/examples/core/hulls/hull2D.js +3 -5
  10. package/examples/core/hulls/hull3D.js +3 -5
  11. package/examples/core/measurements/measureAggregateBounds.js +5 -7
  12. package/examples/core/measurements/measureAreaAndVolume.js +6 -8
  13. package/examples/core/measurements/measureBounds.js +5 -7
  14. package/examples/core/other/orientation.js +2 -3
  15. package/examples/core/primitives/dodecahedron.js +1 -3
  16. package/examples/core/primitives/polyhedron.js +12 -14
  17. package/examples/core/primitives/primitives2D.js +1 -3
  18. package/examples/core/primitives/primitives3D.js +2 -4
  19. package/examples/core/primitives/roundedCuboid.js +7 -9
  20. package/examples/core/primitives/sphere.js +10 -12
  21. package/examples/core/primitives/torus.js +20 -22
  22. package/examples/core/text/text.js +5 -8
  23. package/examples/core/transforms/align.js +5 -7
  24. package/examples/core/transforms/center.js +6 -8
  25. package/examples/import/AMFImport/index.js +1 -3
  26. package/examples/import/STLImport/index.js +4 -6
  27. package/examples/import/SVGImport/index.js +0 -1
  28. package/examples/module-design/mountPlate.js +5 -9
  29. package/examples/module-design/subFolder/sphereShape.js +1 -3
  30. package/examples/parameters/allParamTypes.js +19 -21
  31. package/examples/parameters/balloons.js +15 -26
  32. package/examples/parameters/gear.js +9 -11
  33. package/package.json +7 -7
  34. package/postInstall.js +3 -3
  35. package/src/index.js +0 -1
  36. package/src/most-gestures/drags.js +15 -0
  37. package/src/most-gestures/zooms.js +20 -1
  38. package/src/sideEffects/dat/index.js +0 -6
  39. package/src/sideEffects/dom/index.js +0 -2
  40. package/src/sideEffects/fileDialog/index.js +0 -2
  41. package/src/sideEffects/i18n/index.js +0 -1
  42. package/src/sideEffects/localFs/index.js +1 -4
  43. package/src/sideEffects/localFs/walkFileTree.js +1 -7
  44. package/src/sideEffects/localStorage/index.js +0 -1
  45. package/src/sideEffects/state/index.js +0 -11
  46. package/src/ui/flow/design.js +5 -26
  47. package/src/ui/flow/dom.js +0 -1
  48. package/src/ui/flow/flowOut.js +0 -24
  49. package/src/ui/flow/languages.js +0 -1
  50. package/src/ui/flow/shortcuts.js +0 -1
  51. package/src/ui/flow/themes.js +1 -1
  52. package/src/ui/flow/tools.js +0 -6
  53. package/src/ui/views/editor.js +0 -6
  54. package/src/ui/views/parameterControls.js +0 -1
  55. package/src/ui/views/status.js +4 -2
  56. package/src/utils/keys.js +0 -1
@@ -8,7 +8,6 @@
8
8
  * @licence MIT License
9
9
  */
10
10
 
11
-
12
11
  const jscad = require('@jscad/modeling')
13
12
  const { colorize, hslToRgb, colorNameToRgb, hexToRgb, hsvToRgb } = jscad.colors
14
13
  const { cuboid, sphere } = jscad.primitives
@@ -48,17 +48,15 @@ const main = (params) => {
48
48
  return o
49
49
  }
50
50
 
51
- const getParameterDefinitions = () => {
52
- return [
53
- {
54
- name: 'method',
55
- type: 'choice',
56
- caption: 'Colorize Method',
57
- values: ['rgb', 'hsv', 'hsl'],
58
- captions: ['(r,g,b) = (x,y,z)', '(h,s,v) = (x,y,z)', '(h,s,l) = (x,y,z)'],
59
- initial: 'hsl'
60
- }
61
- ]
62
- }
51
+ const getParameterDefinitions = () => [
52
+ {
53
+ name: 'method',
54
+ type: 'choice',
55
+ caption: 'Colorize Method',
56
+ values: ['rgb', 'hsv', 'hsl'],
57
+ captions: ['(r,g,b) = (x,y,z)', '(h,s,v) = (x,y,z)', '(h,s,l) = (x,y,z)'],
58
+ initial: 'hsl'
59
+ }
60
+ ]
63
61
 
64
62
  module.exports = { main, getParameterDefinitions }
@@ -16,27 +16,25 @@ const { translate } = jscad.transforms
16
16
  const { slice } = jscad.extrusions
17
17
  const { bezier } = jscad.curves
18
18
 
19
- const main = () => {
20
- return [
21
- box4x4([-8, -4, 2], [1, 0, 0]),
22
- box4x4([8, 4, 12], [0, 1, 0]),
23
- tube([
24
- [6, 4, 12],
25
- [-3, 4, 12],
26
- [4, -4, 2],
27
- [-6, -4, 2]
28
- ]),
29
- tube([
30
- [8, 2, 12],
31
- [8, -6, 12],
32
- [8, 0, 0],
33
- [-8, 4, 2],
34
- [-8, -2, 2]
35
- ])
36
- ]
37
- }
19
+ const main = () => [
20
+ box4x4([-8, -4, 2], [1, 0, 0]),
21
+ box4x4([8, 4, 12], [0, 1, 0]),
22
+ tube([
23
+ [6, 4, 12],
24
+ [-3, 4, 12],
25
+ [4, -4, 2],
26
+ [-6, -4, 2]
27
+ ]),
28
+ tube([
29
+ [8, 2, 12],
30
+ [8, -6, 12],
31
+ [8, 0, 0],
32
+ [-8, 4, 2],
33
+ [-8, -2, 2]
34
+ ])
35
+ ]
38
36
 
39
- function tube (bezierControlPoints) {
37
+ const tube = (bezierControlPoints) => {
40
38
  // Create the initial slice
41
39
  const circ = circle({ radius: 1, segments: 32 })
42
40
  const l = bezierControlPoints.length - 1
@@ -69,7 +67,7 @@ function tube (bezierControlPoints) {
69
67
  }, tubeSlice)
70
68
  }
71
69
 
72
- function rotationMatrixFromVectors (srcVector, targetVector) {
70
+ const rotationMatrixFromVectors = (srcVector, targetVector) => {
73
71
  // From https://gist.github.com/kevinmoran/b45980723e53edeb8a5a43c49f134724
74
72
  srcVector = maths.vec3.normalize(maths.vec3.create(), srcVector)
75
73
  targetVector = maths.vec3.normalize(maths.vec3.create(), targetVector)
@@ -86,7 +84,7 @@ function rotationMatrixFromVectors (srcVector, targetVector) {
86
84
  )
87
85
  }
88
86
 
89
- function box4x4 (translation, color) {
87
+ const box4x4 = (translation, color) => {
90
88
  const b = cuboid({ size: [4, 4, 4] })
91
89
  return colors.colorize(color, translate(translation, b))
92
90
  }
@@ -13,13 +13,11 @@ const { maths, extrusions } = jscad
13
13
  const { bezier } = jscad.curves
14
14
  const { slice } = extrusions
15
15
 
16
- const main = () => {
17
- return [
18
- extrudeWobble(30)
19
- ]
20
- }
16
+ const main = () => [
17
+ extrudeWobble(30)
18
+ ]
21
19
 
22
- function extrudeWobble (height) {
20
+ const extrudeWobble = (height) => {
23
21
  const squareSlice = slice.fromPoints([[10, 10], [-10, 10], [-10, -10], [10, -10]])
24
22
 
25
23
  const xCurve = bezier.create([1, 2, 0.4, 1])
@@ -14,7 +14,7 @@ const { extrudeRectangular, extrudeLinear, extrudeRotate } = jscad.extrusions
14
14
  const { translate } = jscad.transforms
15
15
  const { expand } = jscad.expansions
16
16
 
17
- function main () {
17
+ const main = () => {
18
18
  const shapes = []
19
19
  const aLine = line([[0, 0], [0, 5], [2, 8], [5, 9]])
20
20
  shapes.push(translate([-17, 0, 0], aLine))
@@ -29,8 +29,8 @@ function main () {
29
29
  const extrudedPoly = extrudeLinear({ height: 5, twistAngle: Math.PI / 4, twistSteps: 10 }, poly)
30
30
  shapes.push(translate([-1, 0, 0], extrudedPoly))
31
31
 
32
- const starPoly = translate([3,0,0], star())
33
- const extrudedStar = extrudeRotate({segments: 32, startAngle: 0, angle: (Math.PI * 0.75), overflow: 'cap'}, starPoly)
32
+ const starPoly = translate([3, 0, 0], star())
33
+ const extrudedStar = extrudeRotate({ segments: 32, startAngle: 0, angle: (Math.PI * 0.75), overflow: 'cap' }, starPoly)
34
34
  shapes.push(translate([9, 0, 0], extrudedStar))
35
35
 
36
36
  return shapes
@@ -13,11 +13,9 @@ const { circle, rectangle } = jscad.primitives
13
13
  const { translate } = jscad.transforms
14
14
  const { hull, hullChain } = jscad.hulls
15
15
 
16
- const getParameterDefinitions = () => {
17
- return [
18
- { name: 'doHull', type: 'radio', caption: 'Show:', values: ['shapes', 'hull', 'chain'], captions: ['Original Shapes', 'Hull', 'Hull Chain'], initial: 'shapes' }
19
- ]
20
- }
16
+ const getParameterDefinitions = () => [
17
+ { name: 'doHull', type: 'radio', caption: 'Show:', values: ['shapes', 'hull', 'chain'], captions: ['Original Shapes', 'Hull', 'Hull Chain'], initial: 'shapes' }
18
+ ]
21
19
 
22
20
  const main = (params) => {
23
21
  const shapes = [
@@ -13,11 +13,9 @@ const { cuboid, sphere } = jscad.primitives
13
13
  const { translate } = jscad.transforms
14
14
  const { hull, hullChain } = jscad.hulls
15
15
 
16
- const getParameterDefinitions = () => {
17
- return [
18
- { name: 'doHull', type: 'radio', caption: 'Show:', values: ['shapes', 'hull', 'chain'], captions: ['Original Shapes', 'Hull', 'Hull Chain'], initial: 'shapes' }
19
- ]
20
- }
16
+ const getParameterDefinitions = () => [
17
+ { name: 'doHull', type: 'radio', caption: 'Show:', values: ['shapes', 'hull', 'chain'], captions: ['Original Shapes', 'Hull', 'Hull Chain'], initial: 'shapes' }
18
+ ]
21
19
 
22
20
  const main = (params) => {
23
21
  const shapes = [
@@ -14,13 +14,11 @@ const { measureAggregateBoundingBox } = require('@jscad/modeling').measurements
14
14
  const { colorize } = require('@jscad/modeling').colors
15
15
  const { subtract } = require('@jscad/modeling').booleans
16
16
 
17
- const getParameterDefinitions = () => {
18
- return [
19
- { name: 'rotatex', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'X Rotation:' },
20
- { name: 'rotatey', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Y Rotation:' },
21
- { name: 'rotatez', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Z Rotation:' }
22
- ]
23
- }
17
+ const getParameterDefinitions = () => [
18
+ { name: 'rotatex', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'X Rotation:' },
19
+ { name: 'rotatey', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Y Rotation:' },
20
+ { name: 'rotatez', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Z Rotation:' }
21
+ ]
24
22
 
25
23
  const buildBoundingBox = (bounds) => {
26
24
  // Bounding box format is an array of arrays of values, eg:
@@ -14,17 +14,15 @@ const { measureArea, measureVolume } = require('@jscad/modeling').measurements
14
14
  const { vectorText } = require('@jscad/modeling').text
15
15
  const { path2 } = require('@jscad/modeling').geometries
16
16
 
17
- const getParameterDefinitions = () => {
18
- return [
19
- { name: 'shape', type: 'choice', caption: 'Shape:', values: ['circle', 'square', 'star', 'sphere', 'cube'], initial: 'circle' },
20
- { name: 'size', type: 'number', initial: 10.0, min: 0.1, max: 10.0, step: 0.01, caption: 'Size:' },
21
- { name: 'segments', type: 'choice', values: [8, 16, 32, 64, 128], initial: 16, caption: 'Segments:' }
22
- ]
23
- }
17
+ const getParameterDefinitions = () => [
18
+ { name: 'shape', type: 'choice', caption: 'Shape:', values: ['circle', 'square', 'star', 'sphere', 'cube'], initial: 'circle' },
19
+ { name: 'size', type: 'number', initial: 10.0, min: 0.1, max: 10.0, step: 0.01, caption: 'Size:' },
20
+ { name: 'segments', type: 'choice', values: [8, 16, 32, 64, 128], initial: 16, caption: 'Segments:' }
21
+ ]
24
22
 
25
23
  const textPaths = (text, y) => {
26
24
  const lineSegmentPointArrays = vectorText({ x: -20, y: -10, input: text })
27
- let textSegments = lineSegmentPointArrays.map((points) => { return path2.fromPoints({ closed: false }, points) })
25
+ let textSegments = lineSegmentPointArrays.map((points) => path2.fromPoints({ closed: false }, points))
28
26
  textSegments = scale([0.2, 0.2, 0.2], textSegments)
29
27
  return translate([-25, y - 10, 0], textSegments)
30
28
  }
@@ -14,13 +14,11 @@ const { measureBoundingBox } = require('@jscad/modeling').measurements
14
14
  const { colorize } = require('@jscad/modeling').colors
15
15
  const { subtract } = require('@jscad/modeling').booleans
16
16
 
17
- const getParameterDefinitions = () => {
18
- return [
19
- { name: 'rotatex', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'X Rotation:' },
20
- { name: 'rotatey', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Y Rotation:' },
21
- { name: 'rotatez', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Z Rotation:' }
22
- ]
23
- }
17
+ const getParameterDefinitions = () => [
18
+ { name: 'rotatex', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'X Rotation:' },
19
+ { name: 'rotatey', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Y Rotation:' },
20
+ { name: 'rotatez', type: 'slider', initial: 0, min: -3.14, max: 3.14, step: 0.01, caption: 'Z Rotation:' }
21
+ ]
24
22
 
25
23
  const buildBoundingBox = (bounds) => {
26
24
  // Bounding box format is an array of arrays of values, eg:
@@ -20,7 +20,6 @@ const getParameterDefinitions = () => {
20
20
  // UG... only integer steps can be performed reliably
21
21
  const max = 360
22
22
  const min = -max
23
- const step = max / 360
24
23
  return [
25
24
  { name: 'rotations', type: 'group', caption: 'Rotations (Degrees)' },
26
25
  { name: 'rotateX', type: 'float', caption: 'About X axis', title: 'Rotation from Y to Z', initial: 0, min, max },
@@ -38,7 +37,7 @@ const getParameterDefinitions = () => {
38
37
  */
39
38
  const main = (params) => {
40
39
  const dimension = 20
41
- const coordinateSystem = colorize([0, 0, 0, 0.5], cuboidFrame({size: [20, 20, 20]}))
40
+ const coordinateSystem = colorize([0, 0, 0, 0.5], cuboidFrame({ size: [20, 20, 20] }))
42
41
 
43
42
  const axisX = colorize([1, 0, 0], axisDirection(dimension, 'X'))
44
43
  const axisY = colorize([0, 1, 0], axisDirection(dimension, 'Y'))
@@ -46,7 +45,7 @@ const main = (params) => {
46
45
 
47
46
  // apply the rotations
48
47
  const rotations = [degToRad(params.rotateX), degToRad(params.rotateY), degToRad(params.rotateZ)]
49
- let rotated = rotate(rotations, coordinateSystem)
48
+ const rotated = rotate(rotations, coordinateSystem)
50
49
 
51
50
  return [coordinateSystem, rotated, axisX, axisY, axisZ]
52
51
  }
@@ -32,8 +32,6 @@ const dodecahedron = (h) => {
32
32
  return scale([h, h, h], cuboid1) // scale by height parameter
33
33
  }
34
34
 
35
- const main = () => {
36
- return dodecahedron(10)
37
- }
35
+ const main = () => dodecahedron(10)
38
36
 
39
37
  module.exports = { main }
@@ -10,19 +10,17 @@
10
10
 
11
11
  const { polyhedron } = require('@jscad/modeling').primitives
12
12
 
13
- const main = () => {
14
- return polyhedron({
15
- points: [
16
- [0, -10, 60], [0, 10, 60], [0, 10, 0], [0, -10, 0], [60, -10, 60], [60, 10, 60],
17
- [10, -10, 50], [10, 10, 50], [10, 10, 30], [10, -10, 30], [30, -10, 50], [30, 10, 50]
18
- ],
19
- faces: [
20
- [0, 2, 3], [0, 1, 2], [4, 5, 0], [5, 1, 0], [5, 4, 2], [4, 3, 2],
21
- [6, 9, 8], [6, 8, 7], [6, 11, 10], [6, 7, 11], [10, 11, 8], [10, 8, 9],
22
- [3, 9, 0], [9, 6, 0], [10, 0, 6], [0, 10, 4], [3, 10, 9], [3, 4, 10],
23
- [1, 11, 7], [1, 5, 11], [1, 7, 8], [2, 1, 8], [8, 11, 2], [5, 2, 11]
24
- ]
25
- })
26
- }
13
+ const main = () => polyhedron({
14
+ points: [
15
+ [0, -10, 60], [0, 10, 60], [0, 10, 0], [0, -10, 0], [60, -10, 60], [60, 10, 60],
16
+ [10, -10, 50], [10, 10, 50], [10, 10, 30], [10, -10, 30], [30, -10, 50], [30, 10, 50]
17
+ ],
18
+ faces: [
19
+ [0, 2, 3], [0, 1, 2], [4, 5, 0], [5, 1, 0], [5, 4, 2], [4, 3, 2],
20
+ [6, 9, 8], [6, 8, 7], [6, 11, 10], [6, 7, 11], [10, 11, 8], [10, 8, 9],
21
+ [3, 9, 0], [9, 6, 0], [10, 0, 6], [0, 10, 4], [3, 10, 9], [3, 4, 10],
22
+ [1, 11, 7], [1, 5, 11], [1, 7, 8], [2, 1, 8], [8, 11, 2], [5, 2, 11]
23
+ ]
24
+ })
27
25
 
28
26
  module.exports = { main }
@@ -25,9 +25,7 @@ const main = () => {
25
25
  star({ vertices: 9, outerRadius: 2, innerRadius: 0.8, density: 2, startAngle: Math.PI / 18 })
26
26
  ]
27
27
 
28
- return allPrimitives.map((primitive, index) => {
29
- return translate([(index % 4 - 2) * 6, Math.floor(index / 4 - 2) * 6, 0], primitive)
30
- })
28
+ return allPrimitives.map((primitive, index) => translate([(index % 4 - 2) * 6, Math.floor(index / 4 - 2) * 6, 0], primitive))
31
29
  }
32
30
 
33
31
  module.exports = { main }
@@ -20,7 +20,7 @@ const main = () => {
20
20
  roundedCuboid({ size: [1, 2, 3], roundRadius: 0.4, segments: 16 }),
21
21
  sphere({ radius: 2, segments: 16 }),
22
22
  geodesicSphere({ radius: 1.5, segments: 16 }),
23
- ellipsoid({ radius: [2, 1, 1.5], segments: 64, axes: [[1, 1, 0], [0, -1, 1], [-1, 0, 1]]}),
23
+ ellipsoid({ radius: [2, 1, 1.5], segments: 64, axes: [[1, 1, 0], [0, -1, 1], [-1, 0, 1]] }),
24
24
  cylinder({ radius: 1, height: 5 }),
25
25
  roundedCylinder({ radius: 1, height: 8, roundRadius: 0.8 }),
26
26
  cylinderElliptic({ height: 8, startRadius: [1, 2], startAngle: 0, endRadius: [1, 2], endAngle: (Math.PI / 8), segments: 32 }),
@@ -29,9 +29,7 @@ const main = () => {
29
29
  torus({ innerRadius: 1, outerRadius: 1.5, innerSegments: 4, outerSegments: 6, innerRotation: 0 })
30
30
  ]
31
31
 
32
- return allPrimitives.map((primitive, index) => {
33
- return translate([(index % 4 - 2) * 6, Math.floor(index / 4 - 2) * 6, 0], primitive)
34
- })
32
+ return allPrimitives.map((primitive, index) => translate([(index % 4 - 2) * 6, Math.floor(index / 4 - 2) * 6, 0], primitive))
35
33
  }
36
34
 
37
35
  module.exports = { main }
@@ -10,15 +10,13 @@
10
10
 
11
11
  const { cuboid, roundedCuboid } = require('@jscad/modeling').primitives
12
12
 
13
- const getParameterDefinitions = () => {
14
- return [
15
- { name: 'width', type: 'float', default: 10, caption: 'Width:' },
16
- { name: 'height', type: 'float', default: 14, caption: 'Height:' },
17
- { name: 'depth', type: 'float', default: 7, caption: 'Depth:' },
18
- { name: 'rounded', type: 'choice', caption: 'Round the corners', values: [0, 1], captions: ['No', 'Yes'], default: 1 },
19
- { name: 'radius', type: 'float', default: 2, caption: 'Corner Radius:' }
20
- ]
21
- }
13
+ const getParameterDefinitions = () => [
14
+ { name: 'width', type: 'float', default: 10, caption: 'Width:' },
15
+ { name: 'height', type: 'float', default: 14, caption: 'Height:' },
16
+ { name: 'depth', type: 'float', default: 7, caption: 'Depth:' },
17
+ { name: 'rounded', type: 'choice', caption: 'Round the corners', values: [0, 1], captions: ['No', 'Yes'], default: 1 },
18
+ { name: 'radius', type: 'float', default: 2, caption: 'Corner Radius:' }
19
+ ]
22
20
 
23
21
  /**
24
22
  * Create a rounded cuboid with the supplied parameters
@@ -11,19 +11,17 @@
11
11
  const { sphere, geodesicSphere } = require('@jscad/modeling').primitives
12
12
  const { translate, scale } = require('@jscad/modeling').transforms
13
13
 
14
- const main = () => {
15
- return [
16
- translate([15, -25, 0], sphere({ radius: 10, segments: 12 })),
17
- translate([-15, -25, 0], geodesicSphere({ radius: 10, frequency: 6 })),
14
+ const main = () => [
15
+ translate([15, -25, 0], sphere({ radius: 10, segments: 12 })),
16
+ translate([-15, -25, 0], geodesicSphere({ radius: 10, frequency: 6 })),
18
17
 
19
- translate([15, 0, 0], sphere({ radius: 10, segments: 32 })),
20
- translate([-15, 0, 0], geodesicSphere({ radius: 10, frequency: 24 })),
18
+ translate([15, 0, 0], sphere({ radius: 10, segments: 32 })),
19
+ translate([-15, 0, 0], geodesicSphere({ radius: 10, frequency: 24 })),
21
20
 
22
- scale([0.5, 1, 2], translate([15, 25, 0], sphere({ radius: 10, segments: 32 }))),
23
- scale([0.5, 2, 1], translate([30, 25, 0], sphere({ radius: 10, segments: 32 }))),
24
- scale([0.5, 1, 2], translate([-15, 25, 0], geodesicSphere({ radius: 10, frequency: 18 }))),
25
- scale([0.5, 2, 1], translate([-30, 25, 0], geodesicSphere({ radius: 10, frequency: 18 })))
26
- ]
27
- }
21
+ scale([0.5, 1, 2], translate([15, 25, 0], sphere({ radius: 10, segments: 32 }))),
22
+ scale([0.5, 2, 1], translate([30, 25, 0], sphere({ radius: 10, segments: 32 }))),
23
+ scale([0.5, 1, 2], translate([-15, 25, 0], geodesicSphere({ radius: 10, frequency: 18 }))),
24
+ scale([0.5, 2, 1], translate([-30, 25, 0], geodesicSphere({ radius: 10, frequency: 18 })))
25
+ ]
28
26
 
29
27
  module.exports = { main }
@@ -12,30 +12,28 @@ const { torus } = require('@jscad/modeling').primitives
12
12
  const { translate } = require('@jscad/modeling').transforms
13
13
  const { degToRad } = require('@jscad/modeling').utils
14
14
 
15
- const main = () => {
16
- return [
17
- // Top Row - Simple Torii
18
- translate([-10, 20, 0], torus({ innerRadius: 1, innerSegments: 32, outerRadius: 4, outerSegments: 32, innerRotation: 0, startAngle: 0, outerRotation: Math.PI * 2 })),
19
- translate([0, 20, 0], torus({ innerRadius: 2, outerRadius: 3 })),
20
- translate([10, 20, 0], torus({ innerRadius: 0.5 })),
15
+ const main = () => [
16
+ // Top Row - Simple Torii
17
+ translate([-10, 20, 0], torus({ innerRadius: 1, innerSegments: 32, outerRadius: 4, outerSegments: 32, innerRotation: 0, startAngle: 0, outerRotation: Math.PI * 2 })),
18
+ translate([0, 20, 0], torus({ innerRadius: 2, outerRadius: 3 })),
19
+ translate([10, 20, 0], torus({ innerRadius: 0.5 })),
21
20
 
22
- // Second row - Square Torii
23
- translate([-10, 10, 0], torus({ innerSegments: 4, outerSegments: 4 })),
24
- translate([0, 10, 0], torus({ innerSegments: 4, outerSegments: 4, innerRotation: degToRad(45) })),
25
- translate([10, 10, 0], torus({ outerSegments: 4 })),
26
- translate([20, 10, 0], torus({ innerSegments: 5, outerSegments: 4, innerRotation: degToRad(0) })),
21
+ // Second row - Square Torii
22
+ translate([-10, 10, 0], torus({ innerSegments: 4, outerSegments: 4 })),
23
+ translate([0, 10, 0], torus({ innerSegments: 4, outerSegments: 4, innerRotation: degToRad(45) })),
24
+ translate([10, 10, 0], torus({ outerSegments: 4 })),
25
+ translate([20, 10, 0], torus({ innerSegments: 5, outerSegments: 4, innerRotation: degToRad(0) })),
27
26
 
28
- // Third Row - Pentagonal Torii
29
- translate([-10, 0, 0], torus({ innerSegments: 4, outerSegments: 5 })),
30
- translate([0, 0, 0], torus({ innerSegments: 4, innerRotation: degToRad(45), outerSegments: 5 })),
31
- translate([10, 0, 0], torus({ innerSegments: 32, outerSegments: 5 })),
27
+ // Third Row - Pentagonal Torii
28
+ translate([-10, 0, 0], torus({ innerSegments: 4, outerSegments: 5 })),
29
+ translate([0, 0, 0], torus({ innerSegments: 4, innerRotation: degToRad(45), outerSegments: 5 })),
30
+ translate([10, 0, 0], torus({ innerSegments: 32, outerSegments: 5 })),
32
31
 
33
- // Fourth Row - Other Variations
34
- translate([-10, -10, 0], torus({ innerSegments: 4 })),
35
- translate([0, -10, 0], torus({ innerSegments: 4, innerRotation: 45 })),
36
- translate([10, -10, 0], torus({ outerSegments: 8 })),
37
- translate([20, -10, 0], torus({ outerSegments: 3 }))
38
- ]
39
- }
32
+ // Fourth Row - Other Variations
33
+ translate([-10, -10, 0], torus({ innerSegments: 4 })),
34
+ translate([0, -10, 0], torus({ innerSegments: 4, innerRotation: 45 })),
35
+ translate([10, -10, 0], torus({ outerSegments: 8 })),
36
+ translate([20, -10, 0], torus({ outerSegments: 3 }))
37
+ ]
40
38
 
41
39
  module.exports = { main }
@@ -16,13 +16,11 @@ const { circle, sphere } = jscad.primitives
16
16
  const { vectorText } = jscad.text
17
17
  const { translate } = jscad.transforms
18
18
 
19
- const getParameterDefinitions = () => {
20
- return [
21
- { name: 'outline_string', initial: 'Outline', type: 'text', caption: 'Outline Text', size: 30 },
22
- { name: 'flat_string', initial: 'Flat', type: 'text', caption: 'Flat Text', size: 30 },
23
- { name: 'round_string', initial: 'Round', type: 'text', caption: 'Round Text', size: 30 }
24
- ]
25
- }
19
+ const getParameterDefinitions = () => [
20
+ { name: 'outline_string', initial: 'Outline', type: 'text', caption: 'Outline Text', size: 30 },
21
+ { name: 'flat_string', initial: 'Flat', type: 'text', caption: 'Flat Text', size: 30 },
22
+ { name: 'round_string', initial: 'Round', type: 'text', caption: 'Round Text', size: 30 }
23
+ ]
26
24
 
27
25
  const main = (params) => {
28
26
  const outlineText = buildOutlineText(params.outline_string, 2)
@@ -39,7 +37,6 @@ const buildOutlineText = (message, characterLineWidth) => {
39
37
  const lineRadius = characterLineWidth / 2
40
38
  const lineCorner = circle({ radius: lineRadius })
41
39
 
42
- const lineSegments3D = []
43
40
  const lineSegmentPointArrays = vectorText({ x: 0, y: 0, input: message }) // line segments for each character
44
41
 
45
42
  const lineSegments = []
@@ -13,13 +13,11 @@ const { cuboid } = jscad.primitives
13
13
  const { subtract } = jscad.booleans
14
14
  const { align } = jscad.transforms
15
15
 
16
- const getParameterDefinitions = () => {
17
- return [
18
- { name: 'grouped', type: 'checkbox', checked: false, caption: 'Align as group' },
19
- { name: 'modes', type: 'choice', caption: 'modes:', values: ['["none","none","none"]', '["center","center","min"]', '["min","min","min"]', '["max","min","center"]'], initial: '["none","none","none"]' },
20
- { name: 'relativeTo', type: 'choice', caption: 'relativeTo:', values: ['[0,0,0]', '[null,null,null]', '[10,-10,0]'], initial: '[0,0,0]' }
21
- ]
22
- }
16
+ const getParameterDefinitions = () => [
17
+ { name: 'grouped', type: 'checkbox', checked: false, caption: 'Align as group' },
18
+ { name: 'modes', type: 'choice', caption: 'modes:', values: ['["none","none","none"]', '["center","center","min"]', '["min","min","min"]', '["max","min","center"]'], initial: '["none","none","none"]' },
19
+ { name: 'relativeTo', type: 'choice', caption: 'relativeTo:', values: ['[0,0,0]', '[null,null,null]', '[10,-10,0]'], initial: '[0,0,0]' }
20
+ ]
23
21
 
24
22
  /**
25
23
  * Generates a series of boxes of various sizes, and uses the align function to align them in different ways.
@@ -13,13 +13,11 @@ const { polygon } = jscad.primitives
13
13
  const { extrudeLinear } = jscad.extrusions
14
14
  const { center } = jscad.transforms
15
15
 
16
- const getParameterDefinitions = () => {
17
- return [
18
- { name: 'centerx', type: 'checkbox', checked: false, caption: 'Center on X:' },
19
- { name: 'centery', type: 'checkbox', checked: false, caption: 'Center on Y:' },
20
- { name: 'centerz', type: 'checkbox', checked: false, caption: 'Center on Z:' }
21
- ]
22
- }
16
+ const getParameterDefinitions = () => [
17
+ { name: 'centerx', type: 'checkbox', checked: false, caption: 'Center on X:' },
18
+ { name: 'centery', type: 'checkbox', checked: false, caption: 'Center on Y:' },
19
+ { name: 'centerz', type: 'checkbox', checked: false, caption: 'Center on Z:' }
20
+ ]
23
21
 
24
22
  /**
25
23
  * Creates a 3D crosshair, and centers it on various axes according to the parameters
@@ -36,7 +34,7 @@ const main = (params) => {
36
34
  return crossHair3D
37
35
  }
38
36
 
39
- function crosshair () {
37
+ const crosshair = () => {
40
38
  const poly = polygon({
41
39
  points: [
42
40
  [0, 0], [10, 0], [10, 4], [9, 4], [9, 1], [6, 1], [5, 3],
@@ -11,8 +11,6 @@
11
11
  // Load the AMF files using require
12
12
  const rook = require('./Rook.amf')
13
13
 
14
- const main = () => {
15
- return rook
16
- }
14
+ const main = () => rook
17
15
 
18
16
  module.exports = { main }
@@ -15,11 +15,9 @@ const { union } = require('@jscad/modeling').booleans
15
15
  const sculpture = require('./3d_sculpture-VernonBussler.stl')
16
16
  const frog = require('./frog-OwenCollins.stl')
17
17
 
18
- const main = () => {
19
- return union(
20
- translate([0, 0, 13], rotateZ(-Math.PI / 3, scale([0.25, 0.25, 0.25], frog))),
21
- translate([-5, 6, 0], sculpture)
22
- )
23
- }
18
+ const main = () => union(
19
+ translate([0, 0, 13], rotateZ(-Math.PI / 3, scale([0.25, 0.25, 0.25], frog))),
20
+ translate([-5, 6, 0], sculpture)
21
+ )
24
22
 
25
23
  module.exports = { main }
@@ -8,7 +8,6 @@
8
8
  * @licence MIT License
9
9
  */
10
10
 
11
-
12
11
  const { translate } = require('@jscad/modeling').transforms
13
12
  const { extrudeLinear } = require('@jscad/modeling').extrusions
14
13
  const { polygon } = require('@jscad/modeling').primitives
@@ -9,15 +9,11 @@
9
9
 
10
10
  const { cuboid } = require('@jscad/modeling').primitives
11
11
 
12
- const getParameterDefinitions = () => {
13
- return [
14
- { name: 'plate-group', type: 'group', initial: 'open', caption: 'Mounting Plate' },
15
- { name: 'plateLength', type: 'float', initial: 25, caption: 'length', min: 25, max: 200 }
16
- ]
17
- }
12
+ const getParameterDefinitions = () => [
13
+ { name: 'plate-group', type: 'group', initial: 'open', caption: 'Mounting Plate' },
14
+ { name: 'plateLength', type: 'float', initial: 25, caption: 'length', min: 25, max: 200 }
15
+ ]
18
16
 
19
- const create = (length) => {
20
- return cuboid({ size: [length, 10, 1] })
21
- }
17
+ const create = (length) => cuboid({ size: [length, 10, 1] })
22
18
 
23
19
  module.exports = { create, getParameterDefinitions }
@@ -11,8 +11,6 @@ const { sphere } = require('@jscad/modeling').primitives
11
11
  const { colorize } = require('@jscad/modeling').colors
12
12
  const { translateZ } = require('@jscad/modeling').transforms
13
13
 
14
- const sphereShape = (radius) => {
15
- return colorize([1, 0, 0, 1], translateZ(radius, sphere({ radius })))
16
- }
14
+ const sphereShape = (radius) => colorize([1, 0, 0, 1], translateZ(radius, sphere({ radius })))
17
15
 
18
16
  module.exports = sphereShape