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

514
Vistas
Threejs Scene not working in my project / THREE not defined

I wanted to create m first three js project and followed a tutorial. But when my page loads no scene is showing up. The sscene should be completly black but the site is just white.

Chrome Browser Console:

three.js:1 Failed to load resource: net::ERR_FILE_NOT_FOUND main.js:1 Uncaught SyntaxError: Cannot use import statement outside a module

My vs code workspace;

enter image description here

My html and js code:

function main(){

    var scene = new THREE.Scene();
    var camera = new THREE.PerspectiveCamera(45,window.innerWidth/window.innerHeight,1,1000);
    var renderer = new THREE.WebGLRenderer();

    renderer.setSize(window.innerWidth,window,innerHeight);
    document.getElementById('webgl').appendChild(renderer.domElement);
    renderer.render(scene,camera);
}

main();
<!DOCTYPE html>

<html>
    <head>
        <title>Three js test</title>
        <style type="text/css">html, body {margin: 0; padding: 0; overflow: hidden;}</style>
    </head>
    <body>
        <div id="webgl"></div>
        <script src="/lib/three.js"></script>
        <script src="./main.js"></script>
    </body>
</html>

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

0

<script src="lib/three.js"></script>

Maybe try removing the '/' from your three.js path?

about 4 years ago · Juan Pablo Isaza Denunciar

0

I ended up working with the live server extension of vs code and used the three.module.js.

It worked using this.

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