Skip to content
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

Add example using three-d #1398

Closed
wants to merge 11 commits into from
Closed

Add example using three-d #1398

wants to merge 11 commits into from

Conversation

emilk
Copy link
Owner

@emilk emilk commented Mar 22, 2022

EDIT: rebased in #1407

https://github.com/asny/three-d recently merged a PR adding glow support: asny/three-d#210.
This means it is a prime candidate for embedding 3D painting inside an eframe app.

Screen Shot 2022-03-22 at 10 27 24

There are currently a few kinks that need to be figured out:

  • sudden egui paint failure
  • viewport
  • anti-aliasing
  • Send+Sync

Sudden egui paint failure

When reusing the same three_d context over time (as one should), we get two(!) good frames of egui+three_d, but frame three and onwards the egui painting breaks (nothing is painted), but the three_d still works. Very weird!

EDIT: fixed by asny/three-d@07bbf3b

Viewport

The thee-d camera requires a viewport (in pixels). This need to be passed in to the PaintCallback function, or there needs to be some way of telling three-d to use the currently set viewport (less likely).

EDIT: fixed by 9181dc7

Anti-aliasing

It would be nice to enable MSAA to smooth out the edges.

Shape: Send + Sync

Shape is Send + Sync and three_d::Context is not. This means we cannot store a three_d context and send it to the Shape::Callback.

So we either need to recreate the three_d context each frame (obviously a bad idea), or access it through a thread_local hack. This PR adds both as examples, with a checkbox to switch.

We could consider making Shape: !Send + !Sync, but that has a lot of downstream implications, as discussed in #1399

@emilk emilk changed the title Add example using three-d Add example using three-d Mar 22, 2022
https://github.com/asny/three-d recently merged a PR adding
`glow` support: asny/three-d#210
This means it is a prime candidate for embedding 3D painting inside
an eframe app.

There are currently a few kinks that need to be figured out:

When reusing the same three_d context over time (as one should),
we only get one frame of egui together with three_d, and then after that
a black screen with just the three_d painting on top.

I need to fix that before merging this PR.

`Shape` is `Send + Sync` and `three_d::Context` is not. This means
we cannot store a three_d context and send it to the `Shape::Callback`.

So we either need to recreate the three_d context each frame (obviously
a bad idea), or access it through a `thread_local` hack.
This PR adds both as examples, with a checkbox to switch.

We could consider making `Shape: !Send + !Sync`, but that would mean
`egui::Context` could not be `Send+Sync` either (because the egui
context stores shapes).

This is discussed in #1399
@emilk
Copy link
Owner Author

emilk commented Mar 22, 2022

Rebased and split into #1406 and #1407

@emilk emilk closed this Mar 22, 2022
@emilk emilk deleted the three-d-example branch March 23, 2022 10:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant