compute-rhino3d

0.13.0-beta • Public • Published

compute.rhino3d.js

JavaScript client library for compute.rhino3d.com geometry service.

A quick sample (for node.js) to get you started...

rhino3dm = require('rhino3dm')
compute = require('compute-rhino3d')

compute.authToken = 'bearer ' + process.env.RHINO_COMPUTE_TOKEN

rhino3dm().then(async (rh) => {
  // create a world xy plane
  plane = {
    "Origin": { "X": 0.0, "Y": 0.0, "Z": 0.0 },
    "XAxis": { "X": 1.0, "Y": 0.0, "Z": 0.0 },
    "YAxis": { "X": 0.0, "Y": 1.0, "Z": 0.0 },
    "ZAxis": { "X": 0.0, "Y": 0.0, "Z": 1.0 },
    "Normal": { "X": 0.0, "Y": 0.0, "Z": 1.0 }
  }
  console.log(plane)

  // create a sphere at the origin and convert to brep
  brep = new rh.Sphere([0,0,0], 5).toBrep()
  console.log(brep)

  // call compute to intersect the sphere with the xy plane
  try {
    r = await compute.Intersection.brepPlane(brep, plane, 0.001)
  } catch(err) {
    console.error(err)
  }
  console.log(r)

  // deserialise the output
  out = rh.CommonObject.decode(r[1][0])
  console.log(out)
  console.log(out.radius) // out is an ArcCurve
})

Readme

Keywords

Package Sidebar

Install

npm i compute-rhino3d

Weekly Downloads

193

Version

0.13.0-beta

License

MIT

Unpacked Size

774 kB

Total Files

23

Last publish

Collaborators

  • pearswj
  • sbaer
  • lfraguada