How to use the @jscad/modeling.geometry 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 / expansions / expand.js View on Github external
/* title      : Expand
// author     : OpenSCAD.org, adapted by Rene K. Mueller
// license    : MIT License
// description: expand() function
*/

const { geom2, geom3, line2, path2 } = require('@jscad/modeling').geometry
const { cuboid, cylinder } = require('@jscad/modeling').primitives
const { translate, scale } = require('@jscad/modeling').transforms
const { union, difference } = require('@jscad/modeling').booleans
const { expand } = require('@jscad/modeling').expansions
const { color } = require('@jscad/modeling').color

const main = () => {
  // you can expand 2d paths
  const points = [
    [10, 0],
    [9.510565162951535, 3.090169943749474],
    [8.090169943749475, 5.877852522924732],
    [5.877852522924732, 8.090169943749475],
    [3.0901699437494745, 9.510565162951535],
    [6.123233995736766e-16, 10]
  ]
github jscad / OpenJSCAD.org / packages / examples / core / extrusions / extrudeFromSlices.js View on Github external
/* 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
github jscad / OpenJSCAD.org / packages / web / src / core / io / exportUtils.js View on Github external
const path = require('path')
const { head } = require('../../utils/utils')
const { formats } = require('@jscad/core/io/formats')
const isGeom2 = require('@jscad/modeling').geometry.geom2.isA
const isGeom3 = require('@jscad/modeling').geometry.geom3.isA

const supportedFormatsForObjects = objects => {
  let objectFormats = []
  let foundGeom3 = false
  let foundGeom2 = false
  for (let i = 0; i < objects.length; i++) {
    if (isGeom3(objects[i])) { foundGeom3 = true }
    if (isGeom2(objects[i])) { foundGeom2 = true }
  }
  for (let format in formats) {
    if (foundGeom3 && formats[format].convertGeom3 === true) {
      objectFormats[objectFormats.length] = format
      continue // only add once
    }
    if (foundGeom2 && formats[format].convertGeom2 === true) {
      objectFormats[objectFormats.length] = format
github jscad / OpenJSCAD.org / packages / web / src / core / io / exportUtils.js View on Github external
const path = require('path')
const { head } = require('../../utils/utils')
const { formats } = require('@jscad/core/io/formats')
const isGeom2 = require('@jscad/modeling').geometry.geom2.isA
const isGeom3 = require('@jscad/modeling').geometry.geom3.isA

const supportedFormatsForObjects = objects => {
  let objectFormats = []
  let foundGeom3 = false
  let foundGeom2 = false
  for (let i = 0; i < objects.length; i++) {
    if (isGeom3(objects[i])) { foundGeom3 = true }
    if (isGeom2(objects[i])) { foundGeom2 = true }
  }
  for (let format in formats) {
    if (foundGeom3 && formats[format].convertGeom3 === true) {
      objectFormats[objectFormats.length] = format
      continue // only add once
    }
    if (foundGeom2 && formats[format].convertGeom2 === true) {