Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

301
Vistas
Three.js texture does not load

I'm trying to make a model of planet Earth, but the texture doesn't load and I don't know why this happens, I tried to change the image format and also use it as an export link and it still doesn't work.

my code:

import * as THREE from 'https://cdn.skypack.dev/three@0.134.0'





const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer(
);
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);




renderer.setSize(window.innerWidth, window.innerHeight); 
document.body.appendChild(renderer.domElement);




const sphere = new THREE.Mesh(
    new THREE.SphereGeometry(5, 50, 50), 
    new THREE.MeshBasicMaterial({
        map: new THREE.TextureLoader().load('.img/global.jpeg')
        })
        
    
    );
    



scene.add(sphere);
camera.position.z = 15;


function animate() {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
}
animate();

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

My first suggestion is for you to split up your code into individual steps so you can pinpoint where the error is taking place. Additionally, TextureLoader.load() has a few callback functions that you can help you determine if loading was successful or if it failed:

const geom = new THREE.SphereGeometry(5, 50, 50);

const texLoader = new THREE.TextureLoader();
const texture = texLoader.load(
    // Location
    '.img/global.jpeg', 

    // On success
    function(texture) {
        console.log("Success!");
        console.log(texture);
    },

    // Progress (ignored)
    undefined,

    // On error
    function(err) {
        console.log("Error");
        console.log(err);

    }
);

const mat = new THREE.MeshBasicMaterial({map: texture});
const sphere = new THREE.Mesh(geom, mat);

Then you can check your console to see what the logs are displaying.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda