Releases: pmndrs/react-ogl
v0.3.2
What's Changed
- fix(core): fix typo in attach by @CodyJasonBennett in 1b93a08
Full Changelog: v0.3.1...v0.3.2
v0.3.1
What's Changed
- fix(core): don't create RaF in render by @CodyJasonBennett in 5aeb6cd
Full Changelog: v0.3.0...v0.3.1
v0.3.0
What's Changed
- feat(core): customize gl behavior via extend by @CodyJasonBennett in #30
- feat(core): expanded attach by @CodyJasonBennett in #31
- feat: use zustand for granular context updates by @CodyJasonBennett in #32
This is a big update in terms of feature parity with https://github.com/pmndrs/react-three-fiber with some perf improvements. Among them:
useStore, zustand, and granular useOGL signature
We now use Zustand under the hood for granular context subscriptions, including a new hook useStore
:
// Only update when gl updates
import { useOGL } from 'react-ogl'
const gl = useOGL(state => state.gl)
// Or, for custom zustand selectors:
import { useStore } from 'react-ogl'
const store = useStore()
React.useEffect(() => store.subscribe(state => ... ), [])
expanded attach API
Expands the attach
prop by accepting an attach function in addition to a string. This is 1-1 with R3F v8's unified attach API.
// will attach to parent.target
<parent>
<child attach="target" />
</parent>
// will attach to parent.target.subtarget
<parent>
<child attach="target-subtarget" />
</parent>
// will attach to parent.target[0] and parent.target[1], creates an array if parent.target is undefined
// useful for attaching multiple elements to an array
<parent>
<child attach="target-0" />
<child attach="target-1" />
</parent>
// will call child.setParent on mount and child.removeChild unmount
<parent>
<child
attach={(parent, self) => {
self.setParent(parent)
// remove on unmount
return () => parent.removeChild(self)
}}
/>
</parent>
specify effectful classes via extend
extend now accepts a passGL
argument inwhich passes the active gl context automatically to the element in construction. Importantly, this will affect all elements passed in the call to extend
or any elements who extend them. Passing gl as an arg to these elements will still work as before, however, it is unneeded.
// Marks both classes as effectful and will receive an effect
extend({ CustomClass1, CustomClass2 }, true)
- const gl = useOGL()
- <customClass1 args={[gl]} prop={value} />
- <customClass2 args={[gl]} prop={value} />
+ <customClass1 prop={value} />
+ <customClass2 prop={value} />
This is enabled for core classes to let users use props instead of args for common classes like meshes, materials, geometry, and so on.
<program vertex="" fragment="" />
Full Changelog: v0.2.2...v0.3.0
v0.2.2
What's Changed
- chore: swc => vite, add cjs target by @CodyJasonBennett in #29
Full Changelog: v0.2.1...v0.2.2
v0.2.1
What's Changed
- chore: add examples by @CodyJasonBennett in #27
- fix(types): respect attribute signature by @CodyJasonBennett in bb1102b
Full Changelog: v0.2.0...v0.2.1
v0.2.0
What's Changed
- fix: use .mjs for node compat by @CodyJasonBennett in f8970be
- fix(TS): move type deps to dependencies by @CodyJasonBennett in c5e4bfe
- refactor(core): attach on mount, correctly handle fiber handoff by @CodyJasonBennett in #24
- refactor: unify hooks, react-merge-refs => useImperativeHandle by @CodyJasonBennett in #25
- BREAKING: unify targets, flatten folder structure by @CodyJasonBennett in #26
This release does away with platform-specific imports (react-ogl/web
or react-ogl/native
) in favor of a unified target (react-ogl
).
// web
- import ... from 'react-ogl/web'
+ import ... from 'react-ogl'
// native
- import ... from 'react-ogl/native'
+ import ... from 'react-ogl'
Additional fixes improve internal stability when using concurrent features, suspense, and devtools.
Full Changelog: v0.1.6...v0.2.0
v0.1.6
What's Changed
- fix(reconciler): add scheduler fallbacks for SSR, add required hooks by @CodyJasonBennett in #16
- fix(core): only save internal handlers by @CodyJasonBennett in #22
Full Changelog: v0.1.5...v0.1.6
v0.1.5
What's Changed
- fix: not change subscribed reference by @eXponenta in #21
Full Changelog: v0.1.4...v0.1.5
v0.1.4
v0.1.3
What's Changed
- fix: parent reference missing, dispose by @eXponenta in #13
Full Changelog: v0.1.2...v0.1.3