i’m developing a warehouse 3D scene and i had started with an ArcRotateCamera pointing on the origin.
All work fine till the user doesn’ decide to navigate closer. Moving the camera with mouse wheel, when the camera reaches and pass the origin the view is flipped back keeping the view on the origin.
Ok this is the normal behaviur of ArcRotateCamera but…is it possible to avoid that?
The alternative seems to use an Univeral Camera but i really like all the features that comes with an arcRotateCamera (panning, zoom, etc.). With the Universal Camera, if i understand, i have to program it by myself.
It pass through the target but it is blocked after some step. Forthermore, if i zoom in with mouse wheel to the target it gets blocked then i use pan for increasing the dstance from target (right mouse click and drag the cam) when i try to use the zoom again is still blocked, even if i’m far from the target.
I tryied something similar in this PG: https://playground.babylonjs.com/#A6TFXB#8 (only a test on z-axis). When i approach the target i chage its position.z of 3 steps. But it seems non to work as expeted. Forthermore, as you sayd, it is very difficult to cacth camera direction.
Maybe i’ve found the right compromise for my application using ArcRotateCamera.
I’ve inserted two hided planes the sorround my scene and i set the target behind these planes.
Enabling collisions with those planes the camera can’t never reach the target and seems is possible to navigate the warehouse.
But now i’ve another question, hopefully the last one: is it possible to change the rotation center without changing the target? With the solution described above, now i can navigate the warehouse but the target is quite far form the camera and when i rotate the camera the radius is too big.
I’d like to change the center of the rotation to a more closer point, keeping the target at the same place.
If I’m understanding right, you want to be able to dynamically change the center of your rotation without having to change the actual camera target, is that correct? If so, would this mean that your camera would rotate with the new point but possible be off-center? I just want to make sure that I understand what you’re looking for so that I can advise you properly.
yes, that was my intent, but in the meanwhile i’ve found another solution that maybe could be more suitable for my application. I don’t know if continue on this post or open a new one: anyway this is how i’m planning to do.
I use ArcRotateCamera with locketTarget and than i move the target. This could be useful to make animation moving from a mesh to another.
All work fine but in this way i loose the pan feature (right click and drag). So i implement a scene.onPointerObservable to capture inputs and manually change the right click behaviur.
I made something like @PolygonalSun suggested in this post How to change UniversalCamera behaviour
It works but, as i mentioned in that post too, when i try panning, after some moves the scene goes far away: it seems that x,y mouse coord increase with very big value: and i don’t understant why. I tryied also with debug ad all i can see is that at certain point the coords increase to very big values.
What i’ve previuosly wrote happen yesterday on my Smart Working position: we connects to our office PC with an RDP. Is it possibile that RDP slow down the connection and that the cause of what i was facing?
I’ve tryed now (today i’m in my office) and seems to work fine.
Can you give me a feedback? It works fine also for you?
Thank yuo guys.