Hello everyone,
I’m currently working on a project using React Three Fiber (R3F) and encountered significant performance issues when enabling CameraControls
from the drei library. Here’s the situation:
- Issue: When I enable
CameraControls
, low-end devices experience severe lag and buffering. - Temporary Solution: Removing
CameraControls
resolves the performance issue.
My project includes:
- A 3D globe model that rotates.
- HTML elements (using
drei's Html
) placed on the globe. - Interaction between the globe and the camera.
Here’s the relevant 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}
/>
</>
Please note: The parameter values are for testing purposes, and I’ve intentionally used some odd values during experimentation, so please don’t focus on those.
My question is:
- Is the performance issue likely caused by the high computational cost of CameraControls itself?
- Or is it more likely due to optimization issues in my project?
I’d appreciate any advice or insights on improving performance with CameraControls
or debugging whether it’s the main culprit.
Thank you in advance for your help!