Translate and rotate planete in three js

I am programming solar system using three Js. The sun is in the middle, i would like to use translate to position the planets.

var moongeometry = new THREE.SphereGeometry( 0.5, 5, 5 );

 var moonMaterial = new THREE.MeshPhongMaterial({

 map: THREE.ImageUtils.loadTexture("textures/mercury_texture.jpg")

 });

var moon = new THREE.Mesh(moongeometry, moonMaterial);

moon.position.x += 5;

moon.translate(0.5,0.5, 0.5);

moon.scale(1,1,1);

scene.add(moon);

I am not able to see it.

1 Like

I believe you apply translation to the actual geometry, so use moongeometry.translate instead

And also you are not using the right methods such as moon.scale and moon.translate.

I suggest you read this
https://threejs.org/docs/index.html?q=objec#api/en/core/Object3D

https://threejs.org/docs/index.html?q=geome#api/en/core/BufferGeometry

1 Like

Have you seen this from the Collection of examples from discourse.threejs.org ?

discourse.threejs.hofk.de 2019
2021-06-03 08.25.51

1 Like