TrackballControls aren't working

Hi, I’m new to Three.js and 3D in general.

I have a simple code with a cube that I want to rotate and view from different angles. Everything looks fine but the TrackballControls aren’t working. Probably, the problem must be really easy to solve but I can’t find the error in the code. Can you help me? I will be really grateful if you help me to spot the error.

The code pen is here https://codepen.io/RodrigoAP/pen/XGKRGL

check this:

You can’t let the position of controls.target equals to camera.position. And further more, you have to render the view every time when camera’s matrix changed in TrackballControls.
controls.target.copy(cube.position)
controls.addEventListener(‘change’, render)

2 Likes

Thanks a lot for your help. I have a lot of things to learn and understand.

If you haven’t found it already.
You can learn a lot from the examples on discourse (many for beginners).