Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Preview should handle updates itself #236

Open
remcoder opened this issue Oct 18, 2024 · 6 comments
Open

Preview should handle updates itself #236

remcoder opened this issue Oct 18, 2024 · 6 comments

Comments

@remcoder
Copy link
Member

We can remove the necessity for the consumer to call render() after updating public props. This way the lib can decide what type of update is needed.

Outline

Whenever a prop is changed, we queue the change.
Every tick, the queue is read and processed and emptied.

Update types

  • scene changes can be done immediately w/o requiring the model to be rerendered. Examples:

    • build volume changes
    • clipping planes
    • ? toggling groups on and off ?
  • incremental parsing

    • a new chunk of gcode is parsed and translated into a geometry
    • only the new chunk is added to the scene
  • full render of the model

    • the model is removed from the scene
    • the parsed gcode is rendered anew and added to the scene
    • example: extrusion width was changed
@sophiedeziel
Copy link
Collaborator

I agree so much with this!

@sophiedeziel
Copy link
Collaborator

sophiedeziel commented Oct 19, 2024

Some thoughts:

Should we go as far as making the whole render() method private? I don't think so but let's get into that thought experiment.

Not having to call .render() at all is a huge improvement. What would happen if we don't make it private and it's called all over the place? Would we lose some optimization opportunities?

If we're forced to break something or have a subpar experience, maybe we should consider having this as part of the v2->v3 transition. Or plan for v4.

If you ask me, this should be included in the initial v3 release. v3-alpha3 or v3.0. It's the kind of thing that gets me excited. But I'm open to leave that for later.

@remcoder
Copy link
Member Author

We can make it private now and evaluate before we publish. I want to at least update the examples before we publish so that should be a good test.

@remcoder
Copy link
Member Author

Btw where I said 'publish' I meant the final v3.

@remcoder
Copy link
Member Author

remcoder commented Oct 19, 2024

Threejs has the option to toggle the update behavior from automatic to explicit. We could adopt the same strategy but I'd prefer to just choose a single approach that always works. Our lib isn't that generic hopefully.

@sophiedeziel
Copy link
Collaborator

I'd prefer to just choose a single approach that always works

Me too! There's incredible benefits both for us and for the lib client dev.

There are options that requires a re-render, and some other that don't. The application integrating the lib does not have to know that. The lib knows everything about it's internals and can make that call. I don't see why there would need to be a .render() call externally, even if we have an "explicit" mode. I don't see a use case for an explicit mode, do you?

@sophiedeziel sophiedeziel modified the milestone: 3.0-alpha2 Oct 23, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants