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

376
Visualizações
Why is my installaton of ThreeJS inside of laravel not working?

First of all I know Laravel is a PHP framework and has nothing to do with the frontend(JavaScript) of my application. BUT laravel provides the possibility of using webpack which if I got things right is for node modules and other javascript stuff..

What I've done so far:

Installed ThreeJS with command:

npm install three

than executed

npm run dev

After that I included the Libary in my app.js file in the resources folder of Laravel like this:

var THREE = require('three');

(I tried including it whitout assinging it to a variable but that seemed not to work so I just did what some google research told me)

Again I ran npm run dev and the Libary was included inside my packed app.js in the public/js/ path of my project. Everything seems to be fine. I included the app.js file inside of my view and also set the script attribute type to module. But now when I try to import threejs via import * as THREE from 'three';

inside my view it says that the module cannot be found. I know I could just copy the contents of ThreeJS inside the node_modules folder to my public path JS folder but I wanted to keep it as a node module. Any Advise?

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

0

Before you can instantiate Three.Js you have to import the library:

In your resources\js\app.js

import * as THREE from 'three';

const scene = new THREE.Scene();

However, it's recommended to create a instance in the component that actually requires it unless you need it globally.

about 4 years ago · Juan Pablo Isaza Relatório

0

I'm feeling like super stupid right now but adding a window.THREE instead of var three fixed the issue somehow.. Thanks for your help and time anyway!

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