Closed ArnaultT closed 5 years ago
I would try to load the file in the kernel (python I assume), with something like this: https://github.com/WoLpH/numpy-stl
Then convert its output to the appropriate pythreejs primitives. If you have any luck with it, feel free to share the code. I'd be happy to include it as an example!
Hi, It took me too much time but the solution was quite easy thanks to your help !
from stl import mesh
from pythreejs import *
from IPython.display import display
# Load the STL files and add the vectors to the plot
your_mesh = mesh.Mesh.from_file('myMesh.stl')
vertices = BufferAttribute(array=your_mesh.vectors, normalized=False)
geometry = BufferGeometry( attributes={'position': vertices}, )
I suppose I just need to work on the render now Thank you
Thanks, I also realized normalized
had the wrong default (c.f. https://github.com/jupyter-widgets/pythreejs/pull/221).
Hello,
I am quite a newbie with Three.js and ipywidget. Sorry if my question is dumb.
I would like to display a STL file using pythreejs in a jupyter notebook but I didn't found any function to do that. I am not sure to understand if it is possible or not so I tried to create a custom widget to use the three.js function (https://github.com/mrdoob/three.js/blob/master/examples/webgl_loader_stl.html) I followed the documentation but I am stuck at this step: "This code should then be wrapped up in a widget extension (see documentation from ipywidgets on how to do this)." I don't know how to do that or how to use the ipywidget cookiecutter.
I am not certain that to create a custom widget is the best solution so here is my question:
How to import STL file with pythreejs ?
Thanks a lot for your help
Arnault