Jump to content

ArcRotateCamera + 2-Finger Pan


inxs
 Share

Recommended Posts

Hello all,

Im very happy with the ArcRotateCamera and its native touch support.

Unfortunately there is only one feature I'm missing:

The possibility to pan the camera with a 2-finger gesture. It is not possible to move the camera position with the fingers, only rotate it.

Is there anybody who already worte an input for this behavior?

 

Thank you

Jonny

Link to comment
Share on other sites

see this

On 2017-6-2 at 10:24 PM, lhx880619 said:

@davrous already changed the default input(add mode) to support mode switch

 


var panningMode =
                    _this.mode == "panning" ||
                    (evt.ctrlKey && _this.camera._useCtrlForPanning) ||
                    (!_this.camera._useCtrlForPanning && _this._isPanClick);
                if ( _this.panningSensibility !== 0 && panningMode ) {
                    _this.camera
                        .inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
                    _this.camera
                        .inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
                }

 

 

Link to comment
Share on other sites

Hello all,

I fixed it by extending the ArcRotateCameraPointerInput (New section after 'two-finger panning'):

 else if (pointA && pointB) {
                    // if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
                    const ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
                    ed.x = evt.clientX;
                    ed.y = evt.clientY;
                    const direction = this.pinchInwards ? 1 : -1;
                    const distX = pointA.x - pointB.x;
                    const distY = pointA.y - pointB.y;
                    const pinchSquaredDistance = (distX * distX) + (distY * distY);
                    if (previousPinchDistance === 0) {
                        previousPinchDistance = pinchSquaredDistance;
                        return;
                    }

                    if (pinchSquaredDistance !== previousPinchDistance) {
                        this.camera
                            .inertialRadiusOffset += (pinchSquaredDistance - previousPinchDistance) /
                            (this.pinchPrecision *
                                ((this.angularSensibilityX + this.angularSensibilityY) / 2) *
                                direction);
                        previousPinchDistance = pinchSquaredDistance;
                    }

                    // Two-finger panning
                    const panDistanceX = (pointA.x + pointB.x) / 2;
                    const panDistanceY = (pointA.y + pointB.y) / 2;

                    if (previousPanDistanceX === 0) {
                        previousPanDistanceX = panDistanceX;
                    }

                    if (previousPanDistanceY === 0) {
                        previousPanDistanceY = panDistanceY;
                    }

                    this.camera.inertialPanningX -= (panDistanceX - previousPanDistanceX) / this.panningSensibility;
                    this.camera.inertialPanningY += (panDistanceY - previousPanDistanceY) / this.panningSensibility;

                    previousPanDistanceX = panDistanceX;
                    previousPanDistanceY = panDistanceY;
                }

 

I would be looking forward to improvements :)

Edited by inxs
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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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