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 the upcoming implementation of the new sketch mode, focusing on sceneEntities / three.js / general architecture not so much on the constraints side.
These are things I saw in the existing implementation and I thought it would be worth to discuss.
SceneEntities
being 4K+ lines,ModelingMachine
5K.I think it would be nice to have each entity / tool in its own file. 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 though?
userData
and we don't really have a chance to swap three.js to another engine. And while we may never have to do that in practice, I think there is some value in making it more encapsulated.updateSceneObjectColors
which 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 (simplified code which misses some details):
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 owning and keeping our code as simple as possible which is easiest if we own it as much as possible. Also, without xstate we'd need something like redux or our own state manager which bring their own problems..maybe the solution is to use xstate better instead of not using it.
Example of how this would look like with a custom
useModel
implementation.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