I'm using react-globe.gl to create a globe object for my next.js website. Everything works well apart from the manually set controls.
Here's my code for the component:
import dynamic from "next/dynamic";
const Globe = dynamic(import("react-globe.gl"), { ssr: false });
let size = 1250;
import data from "./Globe-data";
export default function GlobeJS(){
return (
<Globe
width={size}
height={size}
hexPolygonsData={data.features}
hexPolygonResolution={3}
hexPolygonMargin={0.3}
hexPolygonColor={() => "#ffffff"}
backgroundColor="#000"
atmosphereColor="#fff"
controls = {{
autoRotate: true,
autoRotateSpeed: 0.4,
enableZoom: false
}}
/>
)
}
The Globe by itself looks fine, however, it does not spin and zooming is still enabled, showing that the controls have been ignored. What have I done wrong here? All sources show that this code is supposed to work. Many thanks!
If I am understanding correctly, controls() is a method for globeEl.current as it returns an instance of Three.js's OrbitControls, Now, all autoRotate, autoRotateSpeed, and enableZoom are properties of globeEl.current.controls().
So, what you can do is to use useRef() and useEffect() to deal with this. I am using React.js if the code below helps.