Start a new topic

Move 3D Model around the screen

Hey Team,

I am creating the demo of 3D model move around the screen by joysticks. I have created the button which will like joystick when I move the button to left the 3D model should move to left and when I move the button to right or up it should move to that direction from the current position. So I have used "Property animation" method for that. But it does not move where my joysticks move. Can someone give me reference code?



Hello Tarun,

I would suggest using JavaScript's setInterval and clearInterval functions for that and subscribing to the touchmove and touchend events. Something like this:


var updateTimeInMs = 10;
var intervalId = -1;

function handleTouchMove(e)
	if (/* the touch is within the bounds of your joystick image */)
		if (intervalId === -1)
			intervalId = setInterval(
					World.yourModel.translate.x += 0.01;

function handleTouchEnd(e)
	intervalId = -1;


You still need to control the direction of movement and do the same thing for the y component of the translation, but I think this code snippet should get the point across well enough.

Kind regards


Thank you..!!!


Tarun Kumar

Login or Signup to post a comment