Sphere not rendering in my threejs

You have a few problems in your code… names, quotes, possible camera placements, lighting issues… First, I would change the names and quotes (not curly). Try this:

const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
scene.add(ambientLight);

//…

const earth = createCelestialBody(
    5, 
    'https://i.ibb.co/your-earth-texture.jpg', 
    { x: -10, y: 0, z: 0 }
);
const mars = createCelestialBody(
    3, 
    'https://i.ibb.co/your-mars-texture.jpg', 
    { x: 10, y: 0, z: 0 }
);

//…

window.addEventListener('resize', () => {
    renderer.setSize(window.innerWidth, window.innerHeight);
    camera.aspect = window.innerWidth / window.innerHeight;
    camera.updateProjectionMatrix();
});

1 Like