Hello there fellas,
It’s been a while since last time !
So many things happened and that’s why I’m here today!
I work with wordpress for a while now, and I succeed to implement threeJS, but now, it’s time to go further and work with something else : node.js and nuxt !
The idea is to pass from CDN (with wordpress) to NPM install, etc. (Yes, that’s my life, nobody cares, but I like to explain the background )
I managed to import three.js and the modules quite easily :
I recreated my scene, imported my GLTF model, used CSS2D renderer but now, I have a problem with RGBELoader !
Here is what I’ve done with js file classic (wordpress)
new THREE.RGBELoader().setDataType(THREE.UnsignedByteType).load('/wp-content/themes/portfolio/js/venice.hdr', function(texture) {
const envMap = pmremGenerator.fromEquirectangular(texture).texture;
scene.background = envMap;
scene.environment = envMap;
texture.dispose();
pmremGenerator.dispose();
})
Here is what I’ve done with Nuxt :
const pmremGenerator = new THREE.PMREMGenerator(this.renderer);
pmremGenerator.compileEquirectangularShader();
new RGBELoader().setDataType(THREE.UnsignedByteType).load('/models/venice.hdr', function(texture) {
const envMap = pmremGenerator.fromEquirectangular(texture).texture;
this.scene.background = envMap;
this.scene.environment = envMap;
texture.dispose();
pmremGenerator.dispose();
})
The difference :
- I deleted the “THREE.” before “RGBELoader()”
- I imported the module from jsm/
- I put the venice.hdr inside the static folder
- i saw @Mugen87 on other questions so I tried this :
pmremGenerator.compileEquirectangularShader();
But now I have this log inside my browser :
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘length’)
at eval (three.module.js?5a89:38723)
I really don’t understand : my file is loaded, I can see it the network tab on the developer tool.
So I thought : Maybe there is a problem with .hdr in vue.js / Nuxt.js but I didn’t see anything related to this kind of problem.
Could you help me find a solution to correctly load envMap for my model ?
THANK YOU
Researches :