Jump to content

Mouse and camera controls


Mezzorio
 Share

Recommended Posts

I wanted to know how to recreate the mouse movement effect I have found in an online example I am trying to recreate, the example is found here: https://www.g-star.com/en_gb/raw

Currently I get Jerky movements and fast rotation, I'm looking for infinite gradual scrolling effect which increases depending on mouse position, this is what im using for my mouse movement are there any alternatives or changes I can make to fix this? 

 var mouse = {x:0,y:0};
            var cameraMoves = {x:0,y:0,z:-0.1,move:false,speed:0.03};

            function mouseMove(e){

                 mouse.x = e.clientX;
                 mouse.y = e.clientY;

            camera.rotation.x += Math.max(Math.min((e.clientX - mouse.x) * 0.01, cameraMoves.speed), -cameraMoves.speed);
            camera.rotation.y += Math.max(Math.min((e.clientY - mouse.x) * 0.01, cameraMoves.speed), -cameraMoves.speed);
 

Link to comment
Share on other sites

Hey @Deltakosh, that hasn't made any changes to the functionality I have working. I need it too;

Have a constant rotating speed reflecting the mouse distance from center.

Move based off mouse movement left/right side of the screen

It currently moves in the inverse direction,, needs to not do that

Need a way of making movement smoother

Link to comment
Share on other sites

12 hours ago, Deltakosh said:

Do you know of any ways to make the motion smoother? or a way to animate the images so they suffer less for the camera rotation? 

Also i need to enable a tiny bit of movement along the y axis and am struggling with how to do that it just enables full to sky and floor whatever i try and set

Link to comment
Share on other sites

On 10/08/2017 at 6:49 PM, adam said:

I set a max speed on these:

https://www.babylonjs-playground.com/#A8TKYS#4

This one translates the camera position:

https://www.babylonjs-playground.com/#A8TKYS#3

edit: I also changed the cell sizes from 4300 to 256.

I'm not too sure i understand the cell sizes side of things, what exactly does it mean? also do you know how to enable movement along the y but only but a small amount?

Edit: I went back and changed the cell size and my images now won't work?

Link to comment
Share on other sites

On 10/08/2017 at 6:27 PM, Deltakosh said:

You can make it smoother by adding a bit of inertia

How is Inertia used? or could you link me to the docs? I follow through the different docs but cannot find anywhere, the description of how it is used or works just mention of the word nothing on how to call it or what it does.

 

Edit: Also how do I invent camera rotation, so it moves the same way as the mouse is going rather than the opposite way which makes no sense as a default anyway.

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