-
Notifications
You must be signed in to change notification settings - Fork 8
Support for Pyodide and PyScript #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
feel like some stuff breaks due to the python name mangling when using double underscores in combination with the subclass... which happens quite a bit - so I am sorta surprised it still works this far. But I can't find any such references for Pyodide which would be odd if that is a known limitation. |
that wasn't the case. I actually fell through the line here rendercanvas/rendercanvas/base.py Lines 450 to 451 in fa7defc
I also registered the auto backend successfully - meaning if you build the wheel and then load it statically. The examples noise.py and snake.py work out of the box (although not events yet). But the weekend has a few more days :)
auto_demo.mp4E: turns out that wasn't true either and I am using the existing |
|
singular keydown event works... so more events and other types shouldn't be impossible. However I will get to that another day. snake_events.mp4 |
|
tried all day to make it work for the docs ... but either the .whl don't get included as static files or pyodide has trouble importing the wheel. I also wanted to automate the iframe inclusion with sphinx-gallery but seems like you need to either modify the classic "works on my machine", so have a video of what could have been instead: doc_embed.mp4 |
|
Even so it's awesome how far you managed to take this! |
|
regarding the buffer copy, the best I found is I am also using that in the wgpu branch for all the buffer/texture writes so let's hope there is a better way. |
Apply suggestions Co-authored-by: Jan <[email protected]>
|
I applied all suggestions.
Also see pyodide/pyodide#5972, it looks like it's possible to do it without a copy, but only from JS code?
Oh, that's good to know. That makes it extra important to get this working ... |
|
Thanks for the meticulous review Jan! |
|
one more thing, I am getting ads on the docs page. But not in the wgpu-py or pygfx docs. Not sure what plan you have and how many projects that covers but perhaps it's just a checkbox somewhere. Just a heads up, I don't really mind myself. |
Also fixed that. For the drag example the squares are huge, but I'll leave that for another day.
I had a plan for just 2 projects. I now upped it to three :) |
|
very nice! It's ready from my end. I added a commit to the wgpu PR and it was working earlier (the renaming back to canvas is currently outdated) with mouse events being accurate, tab switching not breaking etc. Things we haven't covered is changing scheduling mode(I had an example earlier where it only animated on hover) and turning off vsync, however that might not make sense in a browser context anyway. Something that happens to me quite a bit during development was errors during the draw call, which then spam the console due to |
No, vsync does not apply; we're not rendering to the screen, but to a texture that's used by the browser's compositor to combine it with other content.
We already shorten messages if they are the same. But we can also hide them, and e.g. only emit every second or so. |
#38
two evenings of tinkering but I can feel a bit of progress. Rendercanvas looks very web inspired, so I am reading a lot of things between the docs, pyodide docs, pyodide source that sound close but are ever so slightly different. Plus I don't have any webdev experience, it's more like a learning opportunity.
for those that want to give it a try - you can essentially just load the .html as a static page with the python script inserted. But you will need to build wheels and load them locally. Installing from pypi via micropip doesn't include these changes.
some todos:
messageevents from the browser (for example to close?)