jscad / OpenJSCAD.org

JSCAD is an open source set of modular, browser and command line tools for creating parametric 2D and 3D designs with JavaScript code. It provides a quick, precise and reproducible method for generating 3D models, and is especially useful for 3D printing applications.
https://openjscad.xyz/
MIT License
2.66k stars 515 forks source link

[Feature Request] Wire frame mode #890

Open ikeji opened 3 years ago

ikeji commented 3 years ago

I want to have Wire frame view in OpenJSCAD.

For example, when I have cube with hole. With current view, it's difficult to see how deep the hole.

Here is screenshots from FreeCAD.

Normal View 20210723120238

Wire frame View 20210723120300

hrgdavor commented 3 years ago

@ikeji the sample in your screenshot is actually not wireframe but outline. Wireframe would show all vertices.

This would be a nice feature to have, but may be a long time until available.

I have two alternatives that could help you with the visualisation.

subtractX transparency

paste this function into your script

function subtractX(first, ...rest){  
  return [  ...rest, colors.colorize([1,0,0,0.5],first) ]
}

for example if you take this test script

const jscad = require('@jscad/modeling')
const { connectors, geometry, geometries, maths, primitives, text, utils, booleans, expansions, extrusions, hulls, measurements, transforms, colors } = jscad
const { cylinder, cuboid, cube, sphere, circle, star,cylinderElliptic,  polyhedron, roundedRectangle, rectangle } = primitives
const { translate, scale } = transforms
const { union, subtract, intersect } = booleans

function subtractX(first,...rest){
  return [  ...rest, colors.colorize([1,0,0,0.5],first) ]
}

function main(){
  return subtract(
    cube({size:20}),
    translate([0,0,6], cylinder({height:8,radius:5}))
  )
}

module.exports = {main}

image

then all you need to preview the boolean operaton, change one letter :)

  return subtractX(

image

also, just showing geometries of a boolean operation is faster than the boolean operation itself

cut with a large cube to see the inside

const jscad = require('@jscad/modeling')
const { connectors, geometry, geometries, maths, primitives, text, utils, booleans, expansions, extrusions, hulls, measurements, transforms, colors } = jscad
const { cylinder, cuboid, cube, sphere, circle, star,cylinderElliptic,  polyhedron, roundedRectangle, rectangle } = primitives
const { translate, scale } = transforms
const { union, subtract, intersect } = booleans

function main(){
  return subtract(
    cube({size:20}),
    translate([0,0,6], cylinder({height:8,radius:5})),
    translate([0,-10,0], cube({size:20})), // cut with cube to see inside
  )
}

module.exports = {main}

image

Sam-Apostel commented 2 years ago

I do think a vertex rendering mode could be helpfull too.

You could just extract the vertices becaus jscad supports rendering them

z3dev commented 2 years ago

I do think a vertex rendering mode could be helpfull too.

You could just extract the vertices becaus jscad supports rendering them

I think that you mean… the viewer supports lines between points. But sadly, only 2D lines. It definitely could be possible.

hrgdavor commented 2 years ago

I do think a vertex rendering mode could be helpfull too.

You could just extract the vertices becaus jscad supports rendering them

We are not against it :) ... we will get to it eventually :) so I posted workarounds ... also contributions are welcome :)