+ 1

How to make 3D rotatable in my code

https://code.sololearn.com/Wq0t9SRkTz2B/?ref=app My code will make earth rotates automatically but I need to rotate by myself i.e.. by cursor or by touch what code should be typed to rotate by ourselves

10th Sep 2020, 4:38 AM
Abishek Ganesh B S
Abishek Ganesh B S - avatar
3 Answers
+ 1
Abishek, the 3D Earth rotation in my code at https://code.sololearn.com/WqG6xi6CqDrm isn't rotating based on user input but you can change that easily enough to suit your needs. Look for this function. You could change the rotation properties there to match something changed by user input: function updateSphereAnimation(sphere) { return function() { //sphere.position.z += 0.2; sphere.rotation.y += 0.001; }; } sphere.rotation has an x, y, z rotation angle. The angle is in radians. I'm sure there's lots more you'd want to adjust to fit it into your page but it should be doable.
11th Sep 2020, 7:28 AM
Josh Greig
Josh Greig - avatar
+ 1
That page looks pretty crafty and creative. For the rotating Earth, you should be able to copy and adapt what I created at: https://code.sololearn.com/WqG6xi6CqDrm/#html That rotating Earth looks sophisticated but it is just drawn on a canvas element. You should be able to overlay your 2D graphics like your rocket on it. It'll likely take you a good few hours to play around with the code to get it fully integrated into what you've started.
10th Sep 2020, 8:31 PM
Josh Greig
Josh Greig - avatar
0
Josh Greig Hello sir, your code looks 3D but not rotatable by ourselves.
11th Sep 2020, 3:16 AM
Abishek Ganesh B S
Abishek Ganesh B S - avatar