Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* 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 : 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 }
)
}
const n = 6
for (let i = 0; i < n; i++) { // -- hexagon chain hulled
const x = sin(i / n * 360) * 10
/* 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]))
.translate([-20, 10, 0]),
extrudeRotate({ segments: 5 }, rectangle({ size: [1, 1], center: true }).translate([4, 0, 0]))
/* 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' },
{ name: 'motorCap_chamfer', type: 'float', initial: 2.5, step: 0.1, caption: 'Motor cap chamfer' },
{ name: 'shaft_len', type: 'float', initial: 22.0, step: 0.5, caption: 'Shaft length' },
/* 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
}
}, base
)