let scene = new THREE.Scene();
let camera = new THREE.PerspectiveCamera(60, innerWidth / innerHeight, 0.1, 100);
camera.position.set(1, 2, 7);
let renderer = new THREE.WebGLRenderer();
renderer.setSize(innerWidth, innerHeight);
document.body.prepend(renderer.domElement);
let controls = new THREE.OrbitControls(camera, renderer.domElement);
scene.add(new THREE.AxesHelper(2));
const orbitRadius = 5;
let orbitPath = new THREE.Path().absarc(0, 0, orbitRadius, 0, Math.PI * 2);
let orbit = new THREE.Line(
new THREE.BufferGeometry().setFromPoints(orbitPath.getSpacedPoints(72)).rotateX(-Math.PI * 0.5),
new THREE.LineBasicMaterial({color: "yellow"})
);
scene.add(orbit);
let globe = new THREE.Mesh(
new THREE.SphereGeometry(2, 16, 8),
new THREE.MeshBasicMaterial({color: "magenta", wireframe: true})
);
globe.rotation.order = "ZYX"; // setting rotation order
globe.rotation.z = THREE.MathUtils.degToRad(23); // adjusting inclination
globe.add(
new THREE.Line(
new THREE.BufferGeometry().setFromPoints([new THREE.Vector2(0, -3), new THREE.Vector2(0, 3)]),
new THREE.LineBasicMaterial({color: "aqua"})
)
)
scene.add(globe);
let clock = new THREE.Clock();
renderer.setAnimationLoop( _ => {
let t = clock.getElapsedTime();
globe.rotation.y = t;
globe.position.x = Math.cos(t * 0.25) * orbitRadius;
globe.position.z = -Math.sin(t * 0.25) * orbitRadius;
renderer.render(scene, camera);
});
body{
overflow: hidden;
margin: 0;
}
<script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>