How to rotate object properly

I’m using three.js for my current project but it seems like the output is different from the output that I want. I already tried to play around with the rotation but no luck. Please see my code below.

Output that I want

Currently have:
JSFIDDLE

The structure of your code is not correct.

You need a function like

function animate() {

	  requestAnimationFrame( animate );

	  time = Date.now() * 0.001;
	  mesh.rotation.y = time;
	  mesh.rotation.z = 0.5* ( 1 +  Math.sin( time ) );
 
	 renderer.render( scene, camera );

}

see examples like
BeginnerExample ( // see also the function animate( ) for all steps )
or
BufferGeometryNormals ( .addAttribute is now .setAttribute )

1 Like

Why do I need requestAnimationFrame?

1 Like

Javascript provides three methods for animations:

setTimeout ()

setInterval () - repeats statements in an interval

With - requestAnimationFrame () - the browser takes over the interface and optimizes the method

2 Likes

/cc

What do you mean by /cc?

Many community members are active at the forum and stackoverflow. It’s possible that a dev answers a question without knowing that an answer already exists at the other platform. That is a bit annoying.

Hence, it’s a good style to state that you ask a question elsewhere, too. If users don’t do this, I usually share the link in their topic.

@Mugen87 I never thought this forum is active since I am just new here, and Stackoverflow is a big platform. Sorry to annoy you. Just deleted the question in stackoverflow. Thanks for correcting

No problem. It’s okay to ask at stackoverflow, too, as long as you share the link to it.

2 Likes

@hofk I’ve added the animate but still the same result. I just need to rotate it like an isometric view. Please see my updated code here in jsfiddle.