Sketch mode ideas #8458
andrewvarga
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I wanted to have a document where I'm putting my ideas about our current codebase, especially with respect to the upcoming implementation of the new sketch mode, focusing on sceneEntities / three.js / general architecture.
SceneEntitiesbeing 4K+ lines,ModelingMachine5K.I think it would be nice to have each entity / tool in its own file/module. Now removing or adding an entity / tool includes touching multiple files and it's easy to forget a few locations, I think the new sketch mode is already going into this direction from what I've seen (?)
userDataand we don't really have a chance to swap three.js to another engine. And while we may never have to do that, I think there is some value in making it more encapsulated.updateSceneObjectColorswhich sets the selected segments to blue when the selection happens. I think it would simplify a lot if we instead had a minimal state being the source of truths and rendering would reflect that state by design without needing to manually update objects. I think each frame we should update the three.js render objects according to their state in a more "immediate mode rendering style" instead of updating them on the fly when they change.Eg. there is a updateSceneObjectColors function which updates three.js material properties based on the current selection, and it is invoked in ModelingMachine when selection changes. If instead we set these properties before each render from the current state it would be impossible to miss and rendering would always be consistent.
In a more immediate more paradigm things could look like:
Note that there is no way that the selection state is inconsistent with the rendering because we render everything from a clean slate using the state of the App instead of setting material colors directly. Basically it's just the same approach as React's state and render methods which ensure the state is always correctly rendered.
kclManager,codeManager,sceneInfra, etc could be turned into simple instances that are created ones and passed to where they are needed through dependency injection. [This may already be in progress]To me there is a lot of value in keeping the codebase as simple as possible which is easiest if we own it as much as we can. Also, without XState we'd need something like redux or our own state manager which bring their own problems..maybe the solution is just to use XState better than we currently do.
Example of how this would look like with a custom
useModelimplementation.Obviously I'm missing some details but if it's our own code things can be significantly simpler compared to using a general state framework which has to accommodate for many different types of applications, not just one.
Beta Was this translation helpful? Give feedback.
All reactions