Jump to content

ArcRotateCamera - Change .alpha Rotate Axis


Rolento
 Share

Recommended Posts

@iTekVR Okay, nice. Its not that hard as it sounds ...

You need this:http://math.hws.edu/graphicsbook/demos/c7/rotators.html

the basics:
http://www.babylonjs.com/cyos/#2FK9TG

Overwrite me:
BABYLON.Camera.prototype.getWorldMatrix = function() {
        if (!this._worldMatrix) {
            this._worldMatrix = BABYLON.Matrix.Identity();
        }
        var viewMatrix = this.getViewMatrix();
        viewMatrix.invertToRef(this._worldMatrix);
        return this._worldMatrix;
    }; etc...
BABYLON.ArcRotateCamera = function(name, alpha, beta, radius, target, scene) {
        BABYLON.Camera.call(this, name, BABYLON.Vector3.Zero(), scene);
        this.alpha = alpha;
        this.beta = beta;
        this.radius = radius;
        this.target = target;
        this._keys = [];
        this.keysUp = [38];
        this.keysDown = [40];
        this.keysLeft = [37];
        this.keysRight = [39];
        this._viewMatrix = new BABYLON.Matrix();
        BABYLON.ArcRotateCamera.prototype._initCache.call(this);
        this.getViewMatrix();
    };

 BABYLON.Vector3.Unproject = function(source, viewportWidth, viewportHeight, world, view, projection) {
        var matrix = world.multiply(view).multiply(projection);
        matrix.invert();
        source.x = source.x / viewportWidth * 2 - 1;
        source.y = -(source.y / viewportHeight * 2 - 1);
        var vector = BABYLON.Vector3.TransformCoordinates(source, matrix);
        var num = source.x * matrix.m[3] + source.y * matrix.m[7] + source.z * matrix.m[11] + matrix.m[15];
        if (BABYLON.Tools.WithinEpsilon(num, 1.0)) {
            vector = vector.scale(1.0 / num);
        }
        return vector;
    };  and so on

 

But i think, someone will write a nice wrapper function for you!  (soon) 


 

 

Link to comment
Share on other sites

This thread caught my eye. Reminded me of an old problem I had 

Unfortunately I never got around to the further investigations or pull request. For my own work I continued to use ArcRotate camera, but took over the controls all myself. Haven't re-implemented tilt/rotate, but I'll still likely micromanage that myself instead of delegating back to the camera's controls once I do.

 

 

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