Jump to content

Prevent delay in panning and zooming for arc rotate camera


Recommended Posts

Hi Team,

I am using arc rotate camera in the scene. There is delay/animation in panning when pressed control+drag. I want the panning to happen on the go without delay. I am trying to modify the native library code for arc rotate camera, but the snippet itself is loaded with delay. Is there a way to disable delay/animation in panning effect? 


if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
                console.log('Start Drag---------------')
                console.log(new Date())
                if (!this._localDirection) {
                    this._localDirection = BABYLON.Vector3.Zero();
                    this._transformedDirection = BABYLON.Vector3.Zero();
                this.inertialPanningX *= this.inertia;
                this.inertialPanningY *= this.inertia;
                if (Math.abs(this.inertialPanningX) < BABYLON.Epsilon)
                    this.inertialPanningX = 0;
                if (Math.abs(this.inertialPanningY) < BABYLON.Epsilon)
                    this.inertialPanningY = 0;
                this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
                BABYLON.Vector3.TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
                //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
                if (!this.panningAxis.y) {
                    this._transformedDirection.y = 0;
                if (!this.target.getAbsolutePosition) {
                console.log(new Date())
                console.log('End Drag---------------')

also tried setting various values to speed, panningSensibility, cameraAcceleration. 

Link to comment
Share on other sites


So, not sure what you mean actually. If there is a certain delay, it is max a single frame (ca. 16 ms) since the event data is not retrieved when the render loop is running. In reality, it is probably much less than 16ms. 

Where exactly do you see delay in the code? If there is, it is probably unintentional and should be removed.

Link to comment
Share on other sites

That works for zoom in/out. but panning isn't working any more :( 


here is the cam code


 scene = new BABYLON.Scene(engine);

    camera1 = new BABYLON.ArcRotateCamera("Camera1", 1.57, 0.01, 120, new BABYLON.Vector3(0, -0.4, 10), scene);
    camera1.attachControl(canvas, true);

    // This targets the camera to scene origin
    //camera1.setTarget(new BABYLON.Vector3.Zero());
    //set camera position
    camera1.setPosition(new BABYLON.Vector3(0, 200, 11));
    //set zoom limit
    camera1.lowerRadiusLimit = 40;
    camera1.upperRadiusLimit = 160;
    camera1.checkCollisions = true;
    if (!is3D) {
        //limit the arcCam alpha and beta (essentially to disabled the rotation).
        camera1.upperAlphaLimit = -Math.PI / 2;
        camera1.lowerAlphaLimit = -Math.PI / 2;
        camera1.upperBetaLimit = 0;
        camera1.lowerBetaLimit = 0;

    camera1.inertia = 0
    //camera1.speed = 500
    scene.activeCamera = camera1;
    scene.activeCamera.attachControl(canvas, true);


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...