Custom Rotate X Y Z axis (mouse, keyboard events)

Hi, am trying to rotate my model using key events, one use case was rotating via the Z-axis. I read that you can change camera.upVector to (0,0,1) which works but completely changes the position of the model, I want to keep it stationary when I changing the rotation. I tried to pass in the other x and y positions but that didn’t help.

I’ve made a playground, it doesn’t have a model tho so the code line 86 onward.

Can someone point me in the right direction please?

Your PG does not work (you have an error in the console)

but overall, if you want to rotate the model why not updating model.rotation.y ?

I’ll have a look into that, didnt know that was a thing. As I want to trigger Y rotation via a key then can spin it with the mouse

I can change camera.rotation.y but doesnt do anything. However, camera.upVector = new BABYLON.Vector3(0, 0, 1); does allow Y rotation but the model will flip to a certain postion to achieve that, I’d like it up to stay in place and move rotation

Not camera :slight_smile: I said model: please just rotate your model

1 Like

Please provide a working playground so we can help you

rotate my model, accessed via the meshes? i’ll give it a try. Sorry I’ve only started working with babylon. I’ll try and make the playground work with a sphere and update it

Haha not a problem at all. We are here to help :slight_smile:

Just a suggestion it is easier to see rotation with a box rather than a sphere.

1 Like