Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
drcmda committed Jun 26, 2023
2 parents 8c1b635 + dc0fa78 commit cfa7ac9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 3 additions & 1 deletion packages/fiber/src/core/renderer.ts
Expand Up @@ -353,8 +353,10 @@ function createRenderer<TCanvas>(_roots: Map<TCanvas, Root>, _getEventPriority?:
return Boolean(localState.handlers)
},
prepareUpdate(instance, _type, oldProps, newProps) {
const localState = instance?.__r3f ?? {}

// Create diff-sets
if (instance.__r3f.primitive && newProps.object && newProps.object !== instance) {
if (localState.primitive && newProps.object && newProps.object !== instance) {
return [true]
} else {
// This is a data object, let's extract critical information about it
Expand Down
23 changes: 11 additions & 12 deletions packages/fiber/src/core/utils.ts
Expand Up @@ -177,19 +177,18 @@ export function dispose<TObj extends { dispose?: () => void; type?: string; [key
// Each object in the scene carries a small LocalState descriptor
export function prepare<T = THREE.Object3D>(object: T, state?: Partial<LocalState>) {
const instance = object as unknown as Instance
if (state?.primitive || !instance.__r3f) {
instance.__r3f = {
type: '',
root: null as unknown as UseBoundStore<RootState>,
previousAttach: null,
memoizedProps: {},
eventCount: 0,
handlers: {},
objects: [],
parent: null,
...state,
}
instance.__r3f = {
type: '',
root: null as unknown as UseBoundStore<RootState>,
previousAttach: null,
memoizedProps: {},
eventCount: 0,
handlers: {},
objects: [],
parent: null,
...state,
}

return object
}

Expand Down

0 comments on commit cfa7ac9

Please sign in to comment.