-
Notifications
You must be signed in to change notification settings - Fork 26
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
Draft: Deckgl Fiber Renderer #35
Draft: Deckgl Fiber Renderer #35
Conversation
canvas, | ||
layers: [], | ||
onWebGLInitialized: state.setWebgl | ||
// TODO: investigate if we need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would love insight into any tips and tricks this can potentially unlock
root.current = createRoot<HTMLCanvasElement>(canvas); | ||
} | ||
|
||
// @ts-expect-error FIXME |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
} from '@deck.gl/layers'; | ||
import type {Instance} from './types'; | ||
|
||
// IDEA: we can technically move this purely to userland so that a user is defining precisely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Articulating this more, as a developer I could in theory only extend explicitly what I am using in my app e.g. say I am only using a MapView and ScatterplotLayer:
extend({
MapView,
ScatterplotLayer
});
This would allow the bundle size to shrink (in theory) for the package consumer.
// NOTE: may need to attach handlers here | ||
commitMount: noop, | ||
|
||
// NOTE: this fires per instance, since deckgl cannot update individual layers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -0,0 +1,304 @@ | |||
import {log} from '@deck.gl/core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logging temporary
*/ | ||
|
||
state.deckgl.setProps({ | ||
// TODO: investigate why we need to spread the array here for deckgl to pick up layer changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hunch here is that Deck does some internal shallow compare against the layer list array? e.g. doing:
state.deckgl.setProps({
layers: layerCache,
});
Does not work since we are mutating layerCache
directly in some of the other functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is about 8 years old, so much has changed (and I'd guess this is no longer only applicable to react). Here's the first commit that mentioned it https://github.com/visgl/deck.gl/pull/700/files
@ibgreen it looks like you wrote this original comment.. I don't suppose you'd know if this is why we need to spread the layer array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a shallow check here.. that'd be my guess.
I wonder if it'd be more performant to always spread like this, or to make immutable updates to layerCache instead of mutations? I imagine it depends on the update frequency and how often mutations happen prior to "commit". I suppose there could be a dirty flag to skip the spread if no mutations occurred?
const state = container.getState(); | ||
|
||
/** | ||
* TODO: implicit view/layer filter logic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brandonjpierce Sorry for slow response here. I sent you an invite to this repository so that you can merge things yourself. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will give this a rubberstamp approval for merging, as long as it doesn't break the repo.
@ibgreen thank you! I am working with my team to button up a number of the TODOs we have remaining on this (we have some folks out sick/on PTO right now). Will keep y'all updated with regards to polish and maturity of the PR. |
Sounds good. A reasonable approach is also to merge this baseline and do incremental improvements from there. Let me know if your team needs additional write permissions to the repo. |
Please reopen if this picks up again. |
This looks very interesting! We have been struggling with some of the same concerns consolidating the React and deck.gl mindsets in our project. Especially when leaning heavily on libraries as React Query and Zustand for managing data and state. |
Is there any reason why this effort is stoped? |
Original PR on the deck.gl repo visgl/deck.gl#8560
ℹ️ Opening PR early to get initial feedback while we polish up
⚠️ Example dir currently not working, seems to be an issue with luma.gl
Remaining TODOs
Example
Background
Initial discussion in Slack: https://deckgl.slack.com/archives/C34AC5MSQ/p1689366597250129
My company has a very large and complex React application that also uses Deck.gl. Over time as the complexity and scope of the project grew we were running into issues with the existing
@deck.gl/react
package due to some of its limitations with children ordering and a few others.A very popular technique adopted in the
three
community was to provide a React renderer for ThreeJS so that developers would not need to swap between the two paradigms in their brain. This is the goal of this effort as well. Allow developers to always "think in React".This deck.gl fiber renderer has been used in a production app for almost half a year now and has unlocked some really incredible techniques for our team.
Some high level concepts:
Change List
@deck.gl/react-fiber
react-fiber