Camera set radius does not work in render loop?

I create instance of VRDeviceOrientationArcRotateCamera nad setTarget to ball.

let _cameraDistance = 7;
engine.runRenderLoop(() => {
_camera.radius = _cameraDistance;

VRDeviceOrientationArcRotateCamera camera sould folow ball and distace between this camera
and ball should be always 7. BUT _camera.radius = _cameraDistance; DOES NOT WORK !

Can anybody help/suggest what is the problem why _camera.radius = _cameraDistance does not work?

If camera is ArcCamera than radius in render loops work OK, but VRDeviceOrientationArcRotateCamera
is not working. VRDeviceOrientationArcRotateCamera behave different than ArcCamera.
Is there any bug or what should be the difference/problem?



the best option is to provide a repro in the playground so we can have a look (pinging @trevordev)

Perhaps this might help. Posted by @Deltakosh. You then have two options:

In the first playground scene, line 48


1 Like

I would like to have mouse scroll to set distance between camera and ball.
But I would like that ArcCamera and VRDeviceOrientationArcRotateCamera sould behave same way.

Scroll Mouse listener strange…
I would like that only mouse scroll can change distance between ball and camera. And than distance
should remain and camera sould folow ball (settarget of camera is ball).

Do anybody know how to solve this problem?


we should uncomment
myBox.rotation.z = 0.1;


F12 browser debug is behaving weird if we refresh playground . If we refresh than log is logged 2 times
if we refresh again it logs 3 times and so on…
Why is that???

when I scrol for +1 it executed twice ?? Why ??
I will get insane becaouse scroll function !!

I’m not certain why you want to place your event listener outside of your scene. This will work, but can cause issues. The reason why your mouse scroll value was updated back to the original camera position, was that you were setting a RegisterAfterRender function calling a variable of 10 set globally outside your render loop.

The solution is far simpler.

Here’s your scene with a BABYLON.VRDeviceOrientationArcRotateCamera set to your desired transforms:

However, you won’t be able to control the VR camera with the mouse wheel.


1 Like