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

208
Visualizações
How to import modules to threejs project correctly?

I'm trying to import modules so I can use the bloom effect, but I keep getting this error. The .js were copied from three/examples/js/ so they are up to date.

index.html:

<script src="../module/three.js";></script>
<script src="../module/EffectComposer.js"></script>
<script src="../module/CopyShader.js"></script>
<script src="../module/ShaderPass.js"></script>
<script src="../module/RenderPass.js"></script>
<script src="../module/UnrealBloomPass.js"></script>
<script src="../module/MaskPass.js"></script>
<script src="../module/Pass.js"></script>
<script src="../module/LuminosityHighPassShader.js"></script>
<script type="module" src="index.js"></script>

index.js:

import * as THREE from "../module/three.module.js";

...
//bloom renderer
const renderScene = new THREE.RenderPass(scene, camera);

and it results in the following error: Uncaught TypeError: THREE.RenderPass is not a constructor

How am I supposed to do it in the correct way?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You are importing three.js twice. One time via script tag and another time via ES6 import statement. This is a wrong pattern and definitely needs to be prevented.

The ES6 import redefines the THREE namespace in your app and thus overwrites the previous imports via the script tag. So please delete the following line and try it again:

import * as THREE from "../module/three.module.js";
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