Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* title : Chain Hull
// author : Rene K. Mueller, Moissette Mark
// license : MIT License
// date : 2013/04/18
// description: Whosa whatsis suggested "Chain Hull" as described at
// https://plus.google.com/u/0/105535247347788377245/posts/aZGXKFX1ACN
*/
const { sin, cos } = Math
const { circle } = require('@jscad/modeling').primitives
const { translate, scale } = require('@jscad/modeling').transforms
const { union } = require('@jscad/modeling').booleans
const { hullChain } = require('@jscad/modeling').hulls
const { extrudeLinear } = require('@jscad/modeling').extrusions
const main = () => {
const shell = []
const hexagon = []
for (let i = 0; i < 12; i++) { // -- shell like
const x = sin(i / 12 * 180) * 10
const y = cos(i / 12 * 180) * 10
shell.push(
translate([x, y, 0], scale(6 - i / 2, circle())) // { center: true }
)
}
/* title : Rectangular Extrude
// authors : Rene K. Mueller
// license : MIT License
// description: testing extrudeRectangular() function
// tags: extrusion, rectangular, extrudeRectangular
*/
const { rectangle, circle, polygon } = require('@jscad/modeling').primitives
const { translate } = require('@jscad/modeling').transforms
const { extrudeRectangular } = require('@jscad/modeling').extrusions
const main = () => {
return [
extrudeRectangular([[0, 0], [10, 0], [5, 10], [0, 10]], { corners: 'chamfer' }),
translate([0, 15, 0],
extrudeRectangular([[0, 0], [10, 0], [5, 10], [0, 10]], { segments: 8, corners: 'round' })
)
]
}
module.exports = { main }
/* title : Linear Extrude
// author : Rene K. Mueller
// license : MIT License
// description: testing extrudeLinear() function
// tags: extrusion, linear, extrudeLinear
*/
const { rectangle, circle, polygon } = require('@jscad/modeling').primitives
const { translate, scale } = require('@jscad/modeling').transforms
const { extrudeLinear } = require('@jscad/modeling').extrusions
const main = () => {
return [
scale(3, extrudeLinear({ height: 10 }, circle({ r: 1, fn: 5, center: true }))),
scale(3, extrudeLinear({ height: 10, twist: 90 }, rectangle({ size: [1, 2], center: true }))
.translate([0, 5, 0])),
scale(3, extrudeLinear({ height: 10, twist: -500, slices: 50 }, translate([2, 0, 0], circle({ r: 1, fn: 8, center: true })))
.translate([0, -6, 0])),
scale(3, extrudeLinear({ height: 20, twist: -90, center: true }, polygon([[0, 0], [4, 1], [1, 1], [1, 4]]))
.translate([0, -13, 0]))
]
}
module.exports = { main }
/* title : extrudeFromSlices
// author : Jeff Gay, Moissette Mark
// license : MIT License
// description: testing extrudeRotate() function
// tags: extrusion, extrudeFromSlices, slices
*/
const { circle } = require('@jscad/modeling').primitives
const { geom2 } = require('@jscad/modeling').geometry
const { translate } = require('@jscad/modeling').transforms
const { extrudeFromSlices, slice } = require('@jscad/modeling').extrusions
const { mat4 } = require('@jscad/modeling').math
const main = () => {
const base = circle({ radius: 4, segments: 4 })
let geometry3 = extrudeFromSlices(
{
numberOfSlices: 5,
callback: (progress, count, base) => {
let newshape = circle({ radius: 5 + count, segments: 4 + count })
let newslice = slice.fromSides(geom2.toSides(newshape))
newslice = slice.transform(mat4.fromTranslation([0, 0, count * 10]), newslice)
return newslice
}
/* title : transformations
// author : Mark Moissette
// license : MIT License
// description: all the different transforms operations
// tags: transforms, translate, rotate, scale, transform matrix
*/
const { cube } = require('@jscad/modeling').primitives
const { translate, rotate, scale, transform } = require('@jscad/modeling').transforms
const { sin, cos } = Math
const main = () => {
const testCube = cube()
return [
translate([0, 10, 0], testCube), // simple translation
translate([10, 0, 0], rotate([10, 5, 0], testCube)), // translate + rotate
translate([-10, 0, 0], scale([0.5, 0.5, 5], testCube)), // translate + scale
transform([ // matrix transform
cos(15), -sin(15), 0, 0,
sin(15), cos(15), 0, 0,
0, 0, 1, 1,
0, 0, 0, 1
], testCube)
/* title : Stepper Motor
// author : Derrick Oswald
// license : MIT License
// description: a simple stepper motor design
// tags: extrusion, extrudeFromSlices, slices
*/
const { circle, cube, cylinder } = require('@jscad/modeling').primitives
const { color } = require('@jscad/modeling').color
const { translate, rotateX } = require('@jscad/modeling').transforms
const { extrudeFromSlices, slice } = require('@jscad/modeling').extrusions
const { mat4 } = require('@jscad/modeling').math
const { union, intersect } = require('@jscad/modeling').booleans
const { sqrt } = Math
const { degToRad } = require('@jscad/modeling').math
const getParameterDefinitions = () => {
return ([
{ name: 'motorBody_len', type: 'float', initial: 47.5, step: 0.5, caption: 'Motor length' },
{ name: 'motorBody_width', type: 'float', initial: 42.0, step: 0.5, caption: 'Motor width' },
{ name: 'motorBody_chamfer', type: 'float', initial: 5.0, step: 0.1, caption: 'Motor chamfer' },
{ name: 'motorCap_len', type: 'float', initial: 8.0, step: 0.1, caption: 'Motor cap length' },
{ name: 'motorCap_thickness', type: 'float', initial: 1.0, step: 0.1, caption: 'Motor cap thickness' },
/* title : Rotate Extrude
// author : Rene K. Mueller
// license : MIT License
// description: testing extrudeRotate() function
// tags: extrusion, rotate, extrudeRotate
*/
const { rectangle, circle, polygon } = require('@jscad/modeling').primitives
const { translate } = require('@jscad/modeling').transforms
const { extrudeRotate } = require('@jscad/modeling').extrusions
const main = () => {
return [
extrudeRotate(translate([4, 0, 0], circle({ r: 1, segments: 30, center: true }))),
extrudeRotate({ segments: 5 },
translate([4, 0, 0], circle({ r: 1, segments: 30, center: true }))).translate([0, 10, 0]),
extrudeRotate({ segments: 30 },
translate([4, 0, 0], circle({ r: 1, segments: 5, center: true }))).translate([0, 20, 0]),
extrudeRotate({ segments: 4 }, translate([4, 0, 0], rectangle({ size: [1, 1], center: true })))
.translate([-10, 0, 0]),
extrudeRotate({ segments: 4 }, rectangle({ size: [1, 3], center: true }).translate([4, 0, 0]))
.translate([-20, 0, 0]),
extrudeRotate({ segments: 3 }, rectangle({ size: [2, 0.5], center: true }).translate([4, 0, 0]))
const { color,
connectors,
geometry,
math,
primitives,
text,
utils,
booleans,
expansions,
extrusions,
hulls,
measurements,
transforms } = jscad
const { cuboid, sphere, cylinder, circle, star } = require('@jscad/modeling').primitives
const { translate, rotate, scale } = transforms
console.log('jscad', jscad)
const main = () => {
return [
//rotate([0, 0, 0], cylinder({ radius: 0.1 })),
cylinder({ radius: 0.5 }),
translate([0, 5, 0], cylinder({size: 2.5})),
circle({ diameter: 10, segments: 64 }),
circle({ radius: 10, segments: 64 }),
cuboid(),
sphere(),
translate([10, 5, 0], [jscad.primitives.cylinder({ radius: 0.5, segments: 64 })]),
rotate([0, 10, 2], cylinder({ radius: 0.1 })),
jscad.primitives.arc(),
jscad.primitives.ellipse(),
const main = () => {
return [
//rotate([0, 0, 0], cylinder({ radius: 0.1 })),
cylinder({ radius: 0.5 }),
translate([0, 5, 0], cylinder({size: 2.5})),
circle({ diameter: 10, segments: 64 }),
circle({ radius: 10, segments: 64 }),
cuboid(),
sphere(),
translate([10, 5, 0], [jscad.primitives.cylinder({ radius: 0.5, segments: 64 })]),
rotate([0, 10, 2], cylinder({ radius: 0.1 })),
jscad.primitives.arc(),
jscad.primitives.ellipse(),
rotate([0, 10, 2], star())
]
}
const { cube } = require('@jscad/modeling').primitives
const mountPlate = (length) => {
return cube({ size: [length, 1, 1] })
}
module.exports = mountPlate