JSCAD User Group

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    1. Home
    2. faithhack
    • Profile
    • Following 0
    • Followers 0
    • Topics 4
    • Posts 5
    • Best 0
    • Controversial 0
    • Groups 0

    faithhack

    @faithhack

    0
    Reputation
    210
    Profile views
    5
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    faithhack Unfollow Follow

    Latest posts made by faithhack

    • Some thoughts on center

      After stuggling a bit with using the new center() function vs. using center attributes, I have a few thoughts. It's is very possible that I'm just thinking about this all wrong as I am more a user than developer.

      My understanding of the current direction is that the center attribute in primatives is being removed in favor of center() or eventually centerAt(), centerAtX(), etc.
      centerAt takes a 'center' and 'axes' but first assumes the center of the object is it's 'natural' center - basically 1/2 the measureBounds().
      As I understand it, if I want to use a different center, I set that as centerAt({center:[0,0,15]) for example.

      So my question is why wouldn't I want to give each primitive or object a center attribute then have centerAt() use that guided by the 'axes'?

      example:
      c = cube({size:4, center:{-2,-2,0]})
      centerAt({axes:[true,true,true]}, c)

      initial placement of the object would still be to center the natural center of the object at the [0,0,0] point, but centerAt() would place the cube's redefined center point at [0,0,0] - in this case it would be placed like a V1 cube.

      This center-point could also inform rotate() so my cube would rotate round a point [-2,-2,0] from it natural center point.

      This also makes me think there should be a way to set a center-point for objects other than primitives like unions.

      I got to thinking about this all after trying to use Inkscape to make little people-shaped silhouettes that bend or rotate at the joints. Inkscape lets you move the point of rotation, but it messes them up when you 'union' several parts together.
      I could then imagine little jscad 3D people where I could articulate them at the joints by setting a center-point at an elbow, for example, then just rotate() it.

      I say all this knowing I'm not offering to code it, and recognizing there is tons to do on the current code base and few hands doing. So just an idea to mull over.

      posted in Development Discussions
      faithhack
      faithhack
    • RE: Is center() broken or am I?

      And the answer is... I'm broke 😌
      I was treating the center({axes:[true, true, false]}, object) like the old object({center:[true,true,false]}) which is not the case since primitives are now created centered at [0,0,0] by default.
      Since the primitive is created centered by default at [0,0,0], changing the axes on a new part doesn't really have an effect.
      Picking a consistent default is probably the 'right thing(tm)' to do since the old primitives where very inconsistent - round things like cylinders and sphere where centered on X/Y but not Z and cubes where created with a corner at [0,0,0].
      Hopefully new docs will have little warnings for those transitioning from V1 to V2 and maybe some helpful examples for porting old designs over.

      posted in General Discussions
      faithhack
      faithhack
    • Is center() broken or am I?

      Trying out V2 stuff...

      pin = center({axes:[true,true,false]}, cylinder({startRadius: 4.5, endRadius: 4.5, height: 38}))

      produces the same object in the same place as:

      pin = cylinder({startRadius: 4.5, endRadius: 4.5, height: 38})

      I would have expected the first one to be centered on X/Y and sitting on the Z plane. Am I missing something?

      Also, do I have to always define 'startRadius' and 'endRadius' for a cylinder? I would think there would be a 'radius'. Maybe I'm just lazy...

      posted in General Discussions
      faithhack
      faithhack
    • es2015-i18n-tag#1.6.2 packaging error tanks new V2 install

      Looks like a lot of useful stuff has been merged since I lasted updated ( 3D hulls, woot! ) my install of V2 so I cleaned everything out and re-installed, but got this error when I ran it:
      Error: Cannot find module 'es2015-i18n-tag' from './OpenJSCAD.org/packages/core/sideEffects/i18n'

      Turns out es2015-i18n-tag#1.6.2 has a package error that leaves out the useful bit. I pinned it to 1.6.1 and all seems well.
      packages/core asks for es2015-i18n-tag^1.3.1

      This isn't a bug I should report in the tracker, is it? Since the author note on the es2015-i18n-tag package recognizes the error is there I expect it will be resolved before core's package.json can be "fixed".

      posted in General Discussions
      faithhack
      faithhack
    • A design projects template

      How does everyone do their new project layouts?

      I use OpenJSCAD for 3D printing, mostly, and have been tracking V2 and able to make the things I needs without too much issue. I have a package.json with:
      "main": "index.js"

      Then an index.js like:

      //include your script here:
      var inc = require('./mypart')
      
      const getParameterDefinitions = () => {
          return inc.getParameterDefinitions()
      }
      
      const main = (params) => {
          return inc.main(params)
      }
      
      module.exports = { main, getParameterDefinitions }
      

      The do my parts like:

      /* All the csg API functions: */
      const { cube, sphere, cylinder, geodesicSphere, torus, polyhedron } = require('@jscad/csg/api').primitives3d
      const { circle, square, polygon, triangle  } = require('@jscad/csg/api').primitives2d
      const { difference, union, intersection } = require('@jscad/csg/api').booleanOps
      const { translate, center, scale, rotate, transform, mirror, expand, contract, minkowski, hull, chain_hull } = require('@jscad/csg/api').transformations
      const { extrudeInOrthonormalBasis, extrudeInPlane, extrude, linear_extrude, rotate_extrude, rotateExtrude, rectangular_extrude } = require('@jscad/csg/api').extrusions
      const { css2rgb, color, rgb2hsl, hsl2rgb, rgb2hsv, hsv2rgb, html2rgb, rgb2html } = require('@jscad/csg/api').color
      const { sin, cos, asin, acos, tan, atan, atan2, ceil, floor, abs, min, max, rands, log, lookup, pow, sign, sqrt, round } = require('@jscad/csg/api').maths
      const { vector_char, vector_text, vectorChar, vectorText } = require('@jscad/csg/api').text
      //const { echo } = require('@jscad/csg/api').echo
      const {CAG, CSG} = require('@jscad/csg/api').csg
      const { extrude_text } = require('./fonts/index.js')
      
      const paramDefaults = {size: 10}
      
      const getParameterDefinitions = () => {
        return [{ name: 'size', type: 'int', initial: 10, caption: 'Size?' }]
      }
      
      const main = (params) => {
      	params = Object.assign({}, paramDefaults, params)
      
      	let results = []
              // replace this
              myPart = cube(params.size)
      	results.push(myPart)
      	myText = extrude_text("Blank Project", 1, 1.5, {height:5, font:'camBamStick1Font'})
      	myText = translate([-45,-10,0], myText) 
      	results.push(myText)
      
      	//
      
      	return results 
      }
      module.exports = { main, getParameterDefinitions, paramDefaults }
      

      Then I just drag the folder to my browser running the web application.
      The "extrude_text" include is my integrating the single-line fonts from https://github.com/lautr3k/jscad-vector-fonts

      Now that a lot of the csg integration to packages/modeling has happened (Thanks kaosat-dev!) it works for me to replace stuff like:

      const { cube, sphere } = require('@jscad/csg/api').primitives3d
      

      with:

      const modeling = require('@jscad/modeling')
      const { cube, sphere } = require('@jscad/modeling').primitives
      

      Is there a "recommended" project layout out there on a wiki somewhere? Would it be helpful for others if I post my "blank project" to github?

      posted in General Discussions
      faithhack
      faithhack