diff --git a/example/src/demos/Portals.tsx b/example/src/demos/Portals.tsx index 9cfc027d10..bab9a3d4a1 100644 --- a/example/src/demos/Portals.tsx +++ b/example/src/demos/Portals.tsx @@ -35,7 +35,7 @@ export function Soda(props: any) { 'https://market-assets.fra1.cdn.digitaloceanspaces.com/market-assets/models/soda-bottle/model.gltf', ) as any return ( - + @@ -113,6 +113,7 @@ const App = () => ( + @@ -121,8 +122,16 @@ const App = () => ( - + ) +function Test() { + const controls = useThree((state) => state.controls) + console.log(controls) + useFrame((state) => { + //console.log(state.pointer.x) + }) +} + export default App diff --git a/packages/fiber/src/core/events.ts b/packages/fiber/src/core/events.ts index 9d8bda3a02..ee8ad46789 100644 --- a/packages/fiber/src/core/events.ts +++ b/packages/fiber/src/core/events.ts @@ -267,6 +267,7 @@ export function createEvents(store: UseBoundStore) { callback: (event: ThreeEvent) => void, ) { const rootState = store.getState() + // If anything has been found, forward it to the event listeners if (intersections.length) { const localState = { stopped: false } @@ -424,7 +425,7 @@ export function createEvents(store: UseBoundStore) { const isPointerMove = name === 'onPointerMove' const isClickEvent = name === 'onClick' || name === 'onContextMenu' || name === 'onDoubleClick' const filter = isPointerMove ? filterPointerEvents : undefined - // const hits = patchIntersects(intersect(filter), event) + const hits = intersect(event, filter) const delta = isClickEvent ? calculateDistance(event) : 0 @@ -449,6 +450,7 @@ export function createEvents(store: UseBoundStore) { const eventObject = data.eventObject const instance = (eventObject as unknown as Instance).__r3f const handlers = instance?.handlers + // Check presence of handlers if (!instance?.eventCount) return diff --git a/packages/fiber/src/core/index.tsx b/packages/fiber/src/core/index.tsx index f9aecd310e..f83a607d53 100644 --- a/packages/fiber/src/core/index.tsx +++ b/packages/fiber/src/core/index.tsx @@ -435,7 +435,6 @@ function Portal({ * the "R3F hooks can only be used within the Canvas component!" warning: * * {createPortal(...)} */ - const { events, size, ...rest } = state const previousRoot = useStore() const [raycaster] = React.useState(() => new THREE.Raycaster()) @@ -453,7 +452,9 @@ function Portal({ // Some props should be off-limits privateKeys.includes(key as PrivateKeys) || // Otherwise filter out the props that are different and let the inject layer take precedence - rootState[key as keyof RootState] !== injectState[key as keyof RootState] + // Unless the inject layer props is undefined, then we keep the root layer + (rootState[key as keyof RootState] !== injectState[key as keyof RootState] && + injectState[key as keyof RootState]) ) { delete intersect[key as keyof RootState] }