Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

302
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda