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.61k stars 511 forks source link

Missing triangles in 3D view #36

Closed codehero closed 10 years ago

codehero commented 10 years ago

My .jscad file shows missing triangles in the 3d previewer and STL output

image

codehero commented 10 years ago

code is here https://gist.github.com/codehero/8274288

Spiritdude commented 10 years ago

I reduced it to the cylinder (x-axis) substracted from the cube; it's something in the csg.js substract operation: http://sprunge.us/IQPG

Spiritdude commented 10 years ago

This seems to work http://openjscad.org/#http://sprunge.us/XYeQ

Spiritdude commented 10 years ago

Ok, try this http://openjscad.org/#http://sprunge.us/MVbU and enter "Diameter of fork bolt" = 8, but at 8.1 it gives this error with the missing part . . .

Spiritdude commented 10 years ago

I found the problem, make sure the resolution is integer, not a fraction, do resolution: Math.floor(something * something)

codehero commented 10 years ago

OK cool, thanks for checking it out. Maybe the API should throw an exception if there is a fractional part to the resolution?

Spiritdude commented 10 years ago

I just made sure the CSG.*({resolution: something}); is fetched as int.