Weird behavior from camera when I do some specific operations

Hello my friends,
I have one tricky question. My app uses two cameras to be able to interact with the gizmo. Another addition I did was to use an approach to zoom to cursor in my scene. Everything works fine until I do one of the next operations:

1- If I switch the view clicking on the gizmo and then try to zoom in or out, I end up with a empty scene. My objects are gone.

2- If I zoom in reaaly close to the points cloud for instance, right click on one of the points, setting one of them as the new control target, then zooming out gives me the same effect as in 1, making me loose my objects.

I have tried a few options mentioned but without success. I would appreciate a help!
Here is the link to my repository:

Here I

Can you link us to a working demo of your error? It’s not fair to others’ time to ask them to clone your repo, install it, and then debug it.

1 Like

Sorry @marquizzo, You are right. I have tried to create a sand box here:
suspicious-sutherland-ch5ml - CodeSandbox. But for some reason it’s complaining about one of the loops what does not happen in the browser. I will record the event here, so maybe you can give me some tip on the solution. I am new to programming at all.

ezgif.com-gif-maker

I have put the sandbox to work! Could you help me @marquizzo ?

Have you ever faced this issue @Mugen87 ?

I might be able to take a look at it later today. For the time being, objects disappearing like this is very often because a NaN or undefined value is sneaking into the objects. Something like:

position.set(x, NaN, z); or
scale.copy(undefined);

and then everything disappears. Have you tried doing a console.log() on any values that might change when you perform that last click?

Thanks @marquizzo ! I have, and I have checked that one of the values sometimes is really high. The detail is that I am using a function to zoom to cursor on my App. But I haven’t found any solution.:confused:

I am using a customized version of the Orbit controls that I have found here in the forum, because I wanted that feature

At first glance it looks like the customized version of OrbitControls changes the center of rotation pretty frequently, and the camera position can quickly grow out of control so it’s very easy to just get lost. Your scene is not empty, you’re just looking away from the object. I think your OrbitControls updates just need some fine-tuning. See below, the green object is almost entirely out of view:

Another thing I noticed is that your camera position can grow insanely large. Doing console.log(camera.position.toArray()) I sometimes get -3e+56 in the X value. That’s 3 with 56 zeroes behind it. You probably need to re-visit your calculations and prevent things like these from happening.

Thank you for the tip @marquizzo ! I will go after it. Did you see also the weird behavior in the frustum? Sometimes when I move the camera around, a piece of the object disappears. Is that something related to some attribute from the camera that I am not updating?