How to use the @jscad/modeling.cube function in @jscad/modeling

To help you get started, we’ve selected a few @jscad/modeling examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jscad / OpenJSCAD.org / packages / examples / core / transforms / transformations.js View on Github external
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)
  ]
}
github jscad / OpenJSCAD.org / packages / examples / parameters / stepper-motor.js View on Github external
let xcube = cube({
    center: [0, 0, 0],
    radius: [length, ch, ch]
  })
  xcube = color(cubeColor, xcube)
  body = intersect(body, rotateX(degToRad(45), xcube))

  var cube2 = CSG.roundedCube({
    center: [length - (parameters.motorCap_len / 2.0), 0, 0],
    radius: [(parameters.motorCap_len / 2.0), width, width],
    roundradius: 0.2,
    resolution: 16
  })
  cube2 = cube2.setColor(fooColor)
  var cube3 = cube2.translate([-(parameters.motorBody_len - parameters.motorCap_len), 0, 0])
  xcube = cube({
    center: [0, 0, 0],
    radius: [length, ch2, ch2]
  })
  xcube = color(fooColor, xcube)
  xcube = rotateX(degToRad(45), xcube)
  cube2 = intersect(cube2, xcube)
  cube3 = intersect(cube3, xcube)

  /* pipe(
    cube({
      center: [0, 0, 0],
      radius: [length, ch2, ch2]
    }),
    color(fooColor),
    rotateX(45)
  ) */
github jscad / OpenJSCAD.org / packages / examples / parameters / stepper-motor.js View on Github external
const width = parameters.motorBody_width / 2
  const ch = sqrt(2.0) * width - sqrt(0.5) * parameters.motorBody_chamfer
  const ch2 = sqrt(2.0) * width - sqrt(0.5) * parameters.motorCap_chamfer
  const depth = parameters.mountingholes_depth
  const offset = parameters.mountingholes_fromcent

  const cubeColor = [0.67843137254901960784313725490196, 0.70588235294117647058823529411765, 0.70588235294117647058823529411765]
  const fooColor = [0.87058823529411764705882352941176, 0.89803921568627450980392156862745, 0.90588235294117647058823529411765]
  let body = CSG.roundedCube({
    center: [0, 0, 0],
    radius: [length - parameters.motorCap_len, width - parameters.motorCap_thickness, width - parameters.motorCap_thickness],
    roundradius: 0.2,
    resolution: 16
  })
  body = color(cubeColor, body)
  let xcube = cube({
    center: [0, 0, 0],
    radius: [length, ch, ch]
  })
  xcube = color(cubeColor, xcube)
  body = intersect(body, rotateX(degToRad(45), xcube))

  var cube2 = CSG.roundedCube({
    center: [length - (parameters.motorCap_len / 2.0), 0, 0],
    radius: [(parameters.motorCap_len / 2.0), width, width],
    roundradius: 0.2,
    resolution: 16
  })
  cube2 = cube2.setColor(fooColor)
  var cube3 = cube2.translate([-(parameters.motorBody_len - parameters.motorCap_len), 0, 0])
  xcube = cube({
    center: [0, 0, 0],