Hello playcanvas community!!
How to make 3D model rotator by mouse,
I don’t won’t to rotate camera rather I want to make camera fix and rotate model only
Also in addition add zoom in and out through scroll wheel.
Thanks again
Hello playcanvas community!!
How to make 3D model rotator by mouse,
I don’t won’t to rotate camera rather I want to make camera fix and rotate model only
Also in addition add zoom in and out through scroll wheel.
Thanks again
Hi @Nofil_khan,
Here is an example project with the rotation behavior that you’re looking for:
https://developer.playcanvas.com/en/tutorials/rotating-objects-with-mouse/
Take a look at the orbit-camera.js and mouse-input.js scripts in this example project:
https://developer.playcanvas.com/en/tutorials/orbit-camera/
If specifically look at the onMouseWheel
function in mouse-input.js, you can use a similar event function to move the camera along it’s forward axis to get closer or farther away from the object. To make that transition smooth, have a look at the update
function (line 293 specifically) as a starting point to see how you might approach the issue.
I hope this is helpful.
I did do an alternative to the above example that ‘feels’ more correct to me when rotation an object that you may want to consider:
https://playcanvas.com/project/586330/overview/the-room-item-exam
This is awesome, two more requests(these are related to my initial question)
A lot of it is dependent on where you would use it. For example, zooming in can be done by:
How to only rotate a 3D object when it’s on the 3D object only,not anywhere on the screen??
Not sure what you mean here
Give it a try yourself and see where you end up
I will sure give it a try ,I will try to do it by more easy way than your code is for rotate 3D model.
Secondly what I mean with second part of question is that
In example you see if we click and drag anywhere on screen it rotates 3D model,I want to move/rotate only if you clicked directly on model not anywhere on screen .
How would that be possible
You can use one of these two methods: https://developer.playcanvas.com/en/tutorials/entity-picking/ to know if your mousedown is over the entity. If it is, then do rotation on mouse move. If not, don’t do anything.
I will give it a shot
I will give it a shot