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

118
Visualizações
Importing a module into a threejs javascript scene

I have a basic setup with an index.html which imports a javascript file with a threejs scene.

In this threejs scene, I am trying to import a plugin which runs a specific type of volumetric graphic (https://github.com/ScatterCo/Depthkit.js). I have downloaded the depthkit.js file from the build folder from the above github and placed it in my ./js folder structure locally.

My full javascript looks like this currently:

import * as THREE from './js/three.module.js';
import * as DK from './js/depthkit.js';

let camera, scene, renderer;
let geometry, material, mesh, depthkit;

init();

function init() {

    camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.01, 10 );
    camera.position.z = 1;

    scene = new THREE.Scene();

    geometry = new THREE.BoxGeometry( 0.2, 0.2, 0.2 );
    material = new THREE.MeshNormalMaterial();

    mesh = new THREE.Mesh( geometry, material );
    scene.add( mesh );

    depthkit = new DK.DepthKit();
    depthkit.load(
        "./assets/dk_single.txt",
        "./assets/dk_single.mp4",
        character => {
            scene.add(character);
        }
    );

    renderer = new THREE.WebGLRenderer( { antialias: true } );
    renderer.setSize( window.innerWidth, window.innerHeight );
    renderer.setAnimationLoop( animation );
    document.body.appendChild( renderer.domElement );

}

function animation( time ) {

    mesh.rotation.x = time / 2000;
    mesh.rotation.y = time / 1000;

    renderer.render( scene, camera );

} 

Normally if I run a threejs scene like this by running index.html with LiveServer from VSCode, it will work fine. But since adding this depthkit object, I am getting this console error related to the depthkit:

Uncaught ReferenceError: THREE is not defined
    at Object.2.glslify (depthkit.js:414)
    at s (depthkit.js:1)
    at depthkit.js:1
    at Object.3../depthkit (depthkit.js:429)
    at s (depthkit.js:1)
    at e (depthkit.js:1)
    at depthkit.js:1

Am I importing the depthkit.js properly?

about 4 years ago · Juan Pablo Isaza
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