Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!