bernhard-42 / vscode-ocp-cad-viewer

A viewer for OCP based Code-CAD (CadQuery, build123d) integrated into VS Code
Apache License 2.0
96 stars 10 forks source link

OCP Image Import #28

Closed jdegenstein closed 6 months ago

jdegenstein commented 1 year ago

Like many other CAD software it would be great to import a raster image into OCP CAD Viewer. That way you could take a photo of a real-life object, import/rescale in OCP CAD Viewer, and then design/sketch on top of the image in build123d/CQ. Flatbed scanners can be really good sources of reference images as well.

Desired features:

As far as ThreeJS is concerned, here is a working example someone created of loading an image onto a plane as a texture: https://codepen.io/duhaime/pen/jaYdLg

I suggest looking at the Python Pillow library (there may be lighter weight alternatives). This may be relevant for encoding an image to an IO object in memory. https://pillow.readthedocs.io/en/latest/reference/Image.html#PIL.Image.Image.tobytes

This SO question may also be relevant: https://stackoverflow.com/questions/27826422/get-binary-image-data-from-pil-image

Yeicor commented 8 months ago

I was about to suggest this too, but I would generalize to import textured meshes to use as a reference while designing. This would be interesting for loading 3D scans or other models without losing texture information.

There could be a helper function for loading an image that would create the model described above and load it as a textured mesh.

bernhard-42 commented 6 months ago

fixed in 2.2.2