solid-three
solid-three copied to clipboard
next `solid-three`
This branch continues the context-and-proxies
-branch from @vorth in which he took the proxy-implementation from @nksaraf solid-three-chess
branch of react-three-fiber
.
This branch' intention is to remove all the dependencies and artefacts from react
, remove the dependency on zustand
as an internal state manager in favour of solid/store
and streamline the code, while keeping as close as possible to r3f's v9 codebase.
what has been done
- fixed the broken event-system
- remove all references to useRef
.current
- remove dependency on zustand
-
useThree
works different then r3f's, while they have selectors to subscribe to store-updates, with ouruseThree
is just a wrapper arounduseContext(ThreeContext)
, as we don't have to worry about unnecessary re-renders. - a lot of code in
core
now uses solid-store specific code to update the store, so the distinction betweencore
andsolid
directory is further made unclear. - it simplified some of the internal code, since we don't have to
const state = store.getState()
and the like. -
store.subscribe()
has been replaced bycreateEffect(on(() => store, () => {…}))
which I am not 100% sure is the same.store. subscribe
might be deep-tracking bc off the whole immutable-thing.
-
- I added an optimization to
applyProps
to prevent unnecessary creations/cleanups of effects withmapArray(() => Object.keys(props), ...)
and checking if prop is possibly reactive (=== a getter or function
) - refactors/cleanups:
- the code in
solid/index.ts
is moved tosolid/renderer.ts
.core/renderer.ts
is removed. It contained some types it itself had inherit from the removed reconciler.ts, they have been moved tothree-types.ts
. -
index.ts
, ~solid/index.ts
~ (directories are merged, see below) andcore/index.ts
now only export files - removed secondary implementation of
applyProps
- removed unused three-types (remains of r3f's main branch)
- replaced our custom three-types with r3f's v9 branch' implementation (it used to be done manually, but in the meanwhile they also figured out how to infer it from
three.js
) - our
.prettierrc
had the line"plugins": ["prettier-plugin-tailwindcss"]
which caused my prettier to not function. I replaced our.prettierrc
with the one of r3f to prevent unnecessary differences between codebases. - went ahead and merged the
core
andsolid
-repo back intocore
, more closely mimicking r3f's project-structure - renamed
core/components
tocore/proxy
(bc I thought it was a better parallel withreconciler
and i preferred how it looked lol) - refactored the codebase to mimick r3f's codebase as close as possible
- the code in
reflections
~Currently our codebase is somewhere between r3f's main branch and v9. For example, Instance
is typed like the main branch, but we have Stages
like v9. Probably these changes happened after nikhil made his implementation (found pr when they made the change). Idk if we should pull everything closer to v9 or not. I think yes, but my previous attempts have all failed.~
Instance has been ported to current v9 implementation. Our codebase is now up-to-date.
~As I said above; since we now have solid-store-related code throughout the codebase idk if it still makes sense to make the distinction between the two. I think mb it's best to just bring it back into 1 repo and try to mimic the structure as closely to r3f as possible, so we can at least manually compare the two when needed.~
I went ahead and merged those directories
I think it would probably be good to try out some more complex examples, to test out this version. Maybe port the examples of r3f.