bernhard-42 / three-cad-viewer

A CAD viewer component based on three.js
MIT License
158 stars 28 forks source link

Generation of model for the viewer #6

Closed KaruroChori closed 2 years ago

KaruroChori commented 2 years ago

Hi, I wanted to integrate this viewer in the documentation of a project, but I cannot find information about the actual format used by the example files. How have those file been generated? Is it one of the export formats provided by CadQuery? Thank you!

bernhard-42 commented 2 years ago

Would

help?

vertices, triangles, normals are created via tessellation and edges by discretizing the edges provided by the CAD kernel (see e.g. https://github.com/bernhard-42/cad-viewer-widget/blob/master/notebooks/Classic-OCC-Bottle.ipynb for python-occ or https://github.com/bernhard-42/jupyter-cadquery/blob/master/jupyter_cadquery/tessellator.py for CadQuery)

The lates release candidate (3.1.0rc4) of Jupyter-CadQuery has an export function https://github.com/bernhard-42/jupyter-cadquery/blob/ff773855f480624f30ae7bf874e728ec9ebddd68/jupyter_cadquery/serialize.py#L116-L123

KaruroChori commented 2 years ago

Yes, I find it much clearer now! Thank you. And that export function will be extremely handy.

ashis0013 commented 1 year ago

@bernhard-42 given a dxf file how can I generate the required JSON