Whats the best was to pass props to the parent component of the CANVAS. #2167
Unanswered
dannyWoodford
asked this question in
Q&A
Replies: 1 comment
-
Has anyone found a solution to this? Based on my research, I have yet to find a working example of React Three Fiber working with external React components, such as a UI bar. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I know the only item in the "Gotchas" of the r3f docs is passing props down from a parent component to the Canvas. The way to get around this is using a ContextBridge or state management system but is there any good way to pass props out of the canvas?
For example: Having the in-and-out dolly of OrbitControls with a min and minDistance so that it proportionately moves a css slider outside of the canvas?
currently, I can achieve this with this code but it's slow and there are too many calls, so much so that the position of the camera outpaces the calls and creates a "rubber band-like" effect that feels really loose.
`import React, { useEffect, useRef } from 'react'
import { PerspectiveCamera, OrbitControls } from '@react-three/drei'
import { earthRadius } from "satellite.js/lib/constants"
export default function Setup({ ...props }) {
const orbitCon = useRef()
const orbitControler = orbitCon.current
const setZoomValue = props.setZoomValue
}
`
Beta Was this translation helpful? Give feedback.
All reactions