@jbroll/jscad-anchors
v0.2.1
Published
Named frames (anchors) on JSCAD geometry
Readme
jscad-anchors
Named frames (anchors) on JSCAD geometry, so parts are placed by attaching one
part's frame to another's instead of by hand-computed translate/rotate
numbers. Works with @jscad/modeling
models through the @jbroll/jscad-modeling fork, and is intended for jscad-fluent
and the OpenSCAD transpiler in jscadui,
neither of which is integrated yet.
Version 0.2.1.
Example
const { primitives, booleans, transforms, anchors } = require('@jbroll/jscad-anchors')
const plate = transforms.translate([3, 4, 0], primitives.cuboid({ size: [20, 20, 2] }))
const cutter = transforms.translate([5, 0, 0], anchors.withAnchors(
primitives.cylinder({ radius: 1, height: 4 }),
{ axis: anchors.frame([0, 0, 0], [0, 0, 1]) }))
const holed = booleans.subtract(plate, cutter, { carry: { bolt1: cutter } })
const bolt = anchors.withAnchors(primitives.cylinder({ radius: 0.9, height: 10 }), { tip: anchors.frame([0, 0, -5], [0, 0, -1]) })
const placed = anchors.attach(bolt, 'tip', holed, 'bolt1.axis', { flip: false })
console.log(anchors(placed).tip)
// { origin: [ 5, 0, 0 ], z: [ 0, 0, 1 ], x: [ 1, 0, 0 ] }The cylinder that cuts the hole carries its axis anchor into the plate as
bolt1.axis. The bolt then attaches to that anchor and lands exactly on the
hole.
Install
npm install @jbroll/jscad-anchors@jscad/modeling is a peer dependency, aliased to
@jbroll/jscad-modeling
^2.13.4, so npm installs that fork under the name this package loads.
Docs
docs/quickstart.md— shortest path to one resultdocs/user-manual.md— every export and behaviordocs/install.md— requirements and setupdocs/architecture.md— module map and design decisionsdocs/development.md— repo layout, tests, conventionsdocs/backlog.md— outstanding work
