Does anyone familiar with pythreejs know how to integrate it into an anvil app? It basically uses ipython.display to render a scene, so I don’t know which component it corresponds to since it’s not exactly a photo or video.
pythreejs module doesn’t make sense in Anvil.
You need to display components in the browser,
and the browser doesn’t know anything about the IPython display.
You’d end up writing that code in a server module/uplink with no way to send it to a client module.
The good news… You can definitely achieve what you want in Anvil.
What you’ll want to do is look at a threejs, which is specifically written for the browser (and as you might have guessed from the name - pythonthreejs is based on this library).
Here is an example from our blog that uses threejs.
You can import threejs using
import anvil.js
THREE = anvil.js.import_from("https://cdn.skypack.dev/three@0.134.0")
# then probably
sphere = THREE.Mesh(...)
cube = THREE.Mesh(...)
But recommended to check out the blog post in combination with the threejs docs to work out how to implement your code with Anvil.
Then, if you get stuck, you can post a new question on the forum , or the finished app as a show and tell .
One reason to explicitly mention it above - it’s very new - we added it around a month ago.
It should be in the autocomplete and here are some related docs on the subject.