'how to change starting position of a sphere in threejs
I created a 3D Earth using three.js that rotates, but the problem is that it starts spinning over the ocean. i triedto change starting position using matrixWorld but didn't change anything can someone help plz here is my js:
... const earthgeometry = new THREE.SphereGeometry(0.344,64,32);
const eatrhmaterial = new THREE.MeshPhongMaterial({
roughness: 1,
metalness:0,
map: THREE.ImageUtils.loadTexture('static/img/earthmap1k.jpg'),
bumpMap: THREE.ImageUtils.loadTexture('static/img/earthbump.jpg'),
bumpScale: 0.3,
});
const earthmesh = new THREE.Mesh(earthgeometry,eatrhmaterial);
earthmesh.position.set (0.49,0.035,0.58);
earthmesh.matrixWorld.setPosition(new THREE.Vector3(100, 100, 100));
...
Solution 1:[1]
The same way you set a position, you can set a rotation of your object.
const earthgeometry = new THREE.SphereGeometry(0.344,64,32);
const earthmaterial = new THREE.MeshPhongMaterial({
//material definition here
});
const earthmesh = new THREE.Mesh(earthgeometry,earthmaterial);
earthmesh.position.set (0.49,0.035,0.58);
earthmesh.rotation.set (0,1.1,0);//or any other values
remember :
- rotation are in radians: 360° = 2*Math.PI
- Y axis is the vertical one
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mquantin |
