Home > Enterprise >  OBJLoader not displaying anything
OBJLoader not displaying anything

Time:11-24

I'm trying three js with OBJ files, but it does not get rendered on the screen, can someone please help me with this issue? is there something obvious I'm missing?

On the other hand, a geometric cube renders perfectly.

OBJ file can be downloaded here: enter image description here

CodePudding user response:

You have to add some lights to your scene otherwise the asset will be rendered black. Try it with something like:

const ambientLight = new THREE.AmbientLight( 0xffffff, 0.4 );
scene.add( ambientLight );

const directionalLight = new THREE.DirectionalLight( 0xffffff, 0.8 );
directionalLight.position.set( 100, 100, 0 );
scene.add( directionalLight );

Also move your camera away from the origin. The OBJ is quite big so try it with:

camera.position.set(0,0,50);

CodePudding user response:

Update:

The problem was my OBJ loader inside webpack, for some reason using

 {
   test: /\.obj$/,
   loader: 'webpack-obj-loader'
 }

made so my code did not work.

removing it solved my problem

  • Related