Hello everyone,
I’m working on a React Three Fiber (R3F) project and have encountered significant performance issues on low-end devices when enabling the CameraControls
component from the drei library. With CameraControls
active, the app experiences severe lag and buffering, but removing it resolves the issue. My project features a rotating 3D globe, HTML overlays (using drei's Html
), and interactive camera control with the globe.
Below is my current CameraControls
setup:
<>
<CameraControls
ref={controlsRef}
setLookAt={[0, 0, 0]}
azimuthAngle={Math.PI * 1.8}
polarAngle={1}
distance={getDistance()}
minPolarAngle={MIN_POLAR_ANGLE}
maxPolarAngle={MAX_POLAR_ANGLE}
minDistance={getDistance()-4}
maxDistance={getDistance()+3}
draggingSmoothTime={0.3}
truckSpeed={0}
enabled={cameraEnabled}
dollySpeed={1}
/>
</>
Note that the parameter values are for testing only, and some atypical values were intentionally used during experimentation.
My main question is:
- Is the lag primarily due to the high computational cost of
CameraControls
?
- Or could it be related to optimization issues in my project setup?
Any advice or insights on tuning performance or debugging this issue would be greatly appreciated.
Thank you in advance for your help!