Bob Razowsky Posted January 20, 2016 Share Posted January 20, 2016 Hi all! I searched the forum but did not find an aswer. I'd like to rotate a mesh on drag. It would look pretty much like if I was using and ArcRotateCamera, but I need a fixed camera. As anyone tried something like that yet? Another option would be to attach my background to the camera and copy the rotations, making it look like the background is fixed, but I can't make it work. Any ideas would be amazing! Thx a lot! Quote Link to comment Share on other sites More sharing options...
Samuel Girardin Posted January 20, 2016 Share Posted January 20, 2016 Hi, You can try that : http://babylonjs-playground.com/#1QPOEL Look closer at : var onPointerMove = function (evt) { if (!startingPoint) { return; } var current = getGroundPosition(evt); if (!current) { return; } var diff = current.subtract(startingPoint); // currentMesh.position.addInPlace(diff); // new line added currentMesh.rotation.y += diff.x/20; startingPoint = current; } sam Quote Link to comment Share on other sites More sharing options...
Bob Razowsky Posted January 20, 2016 Author Share Posted January 20, 2016 Hi Samuel, thx for your answer! I tried something similar, using mstate instead of pickInfo, and using mesh.rotate() to allow rotations on local axis. It kinda works! var diffX = mstate.x - this.startX; var diffY = mstate.y - this.startY; this.engine.skate.rotate(BABYLON.Axis.Y, -diffX / 20, BABYLON.Space.LOCAL) this.engine.skate.rotate(BABYLON.Axis.Z, diffY / 20, BABYLON.Space.LOCAL) I'll try to add some inertia now! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.