Giter Site home page Giter Site logo

richardwa / tscad Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 1.0 1.07 MB

Constructive Solid Geometry (CSG) using Signed Distance Functions (SDF) and Typescript

License: GNU General Public License v3.0

TypeScript 92.96% HTML 0.50% JavaScript 0.47% Vue 6.07%
marching-cubes sdf dual-marching-cubes signed-distance-functions

tscad's Introduction

TSCAD

Constructive Solid Geometry (CSG) using Signed Distance Functions (SDF) and Typescript

Features

  • Language support / coder friendly - I want a 3D modeling tool similar to openscad, but with a full language tools, IDE, etc for easy coding. This is why typescript is my first choice.
  • Implicit Functions - The other aspect that peaked my interest is ImplicitCAD. I was impressed with the elegance in the maths. Haskell is an awesome language and i would recommend anyone learn it, however IDE support was still missing at the time of this writing.
  • Rounded Union - I always felt this was missing in Openscad, and was a major driver for me to find my own solution. With SDF this is very easy to implement.
  • Version Control - using code has other major advantages like version control and diff's.
  • exports to OBJ file format. I was able to export STL (ascii) initially, but it turns out that OBJ was even easier and gave smaller file sizes.

Cons

  • 3D mesh files are ugly!!! Why is it that the viewer renders a sharp image but the obj file is so imprecise? Unfortunately this is the downfall of using SDF, It is very easy for the ray marcher algorithm but very difficult to get out polygons. If anyone has the perfect solution it would be used in MRI imaging and other multi-million dollar systems.

Setup

git clone https://github.com/richardwa/tscad.git
npm install
npm run dev

write to obj file

npm run render ./projects/sample.ts

CSG Functions

  • These were mostly implemented using Inigo's site and examples. It is a joy at how wonderful and simple these functions are.
  • boolean operations: union, diff, intersect
  • extrusions: extrude, revolve, mirror, tile
  • manipulations: translate, rotate, scale
  • 3D primitives: cube, sphere, cylinder
  • 2D primitives: square, circle, regular polygons, arbitary polygons
  • core CSG library is implemented in typescript and webgl (glsl)

Implicit Surface Extraction - Dual Marching Cubes

  • I spent alot of time working on this to get all the features I was looking for in an extraction algorithm.
  • bounds can be arbitarily large without incurring much cost.
  • variable sized cubes when extracting surface to get a good shape and not spend too much cycles/file size on the flat parts
  • somewhat easy to understand implemetation. At first my implemenations had alot of conditionals (up, down , left, right etc) when working on cubes. There were symetries to be exploited for shorter code, but took a while to find the best way.
  • while i may still look into mesh simplification, I don't want to solely rely on post processing. Didn't want to waste cycles on creating then removing small triangles.
  • no cracks on the rendered object
  • example: rounded union of cube and sphere with variable sized mesh

3D Printing / Slicing

  • while Dual Marching Cubes can produce reasonable high quality models, there are can still be rendering artifacts. To overcome these, we can use the 'slicing' render which gives a solid with holes but should be usable by a slicer. Only downside is to pre-rotate the shape on how it should sit on the bed.

References

tscad's People

Contributors

richardwa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

w-k

tscad's Issues

V2 JSCAD

Cool project! Thanks for using JSCAD.

It's time to move forward with V2 JSCAD, including the new modeling (CSG) package.

Please see www.jscad.xyz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.