# OBJ Loader not working

**URL:** <https://discourse.threejs.org/t/obj-loader-not-working/26253>\
**Category:** Questions\
**Tags:** obj-loader, getting-started\
**Created:** [May 14, 2021, 3:05pm UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253 "2021-05-14T15:05:29Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shange](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Shange](https://discourse.threejs.org/u/Shange)\
**Post date:** [May 14, 2021, 3:05pm UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253/1 "2021-05-14T15:05:29Z")

</div>

I want to load the ninja OBJ file from threejs/examples/models/obj/ninja but it doesn’t seem to be working, see my code here: [Glitch :･ﾟ✧](https://glitch.com/edit/#!/obj-model-loader) any help would be appreciated

 ![Screenshot 2021-05-14 at 15.56.26](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/9/4/94318bb4e84edf780b633e7b2abc6586f8692ef4.jpeg)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [May 14, 2021, 8:39pm UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253/3 "2021-05-14T20:39:31Z")

</div>

Unfortunately, this particular model is not properly centered. Try to translate the model in the `onLoad()` callback and move the camera a bit away from the plane. Use the following to move the model into your viewing area.

```javascript
root.position.y -= 160;

```

---

<div class="post-metadata">

**Author:** ![Shange](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Shange](https://discourse.threejs.org/u/Shange)\
**Post date:** [May 15, 2021, 10:24am UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253/4 "2021-05-15T10:24:10Z")

</div>

Thanks, it’s working now, how do I add texture to the model like in the example below?

 ![Screenshot 2021-05-15 at 11.22.17](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/d/c/dc8dba1b6366d83b7e3a54b51e3043f70488cdde.jpeg)  
 ![Screenshot 2021-05-15 at 13.19.28](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/7/8/78a701df0ac2aa905abd91f6289f29a96ec0447b.jpeg)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [May 15, 2021, 2:15pm UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253/5 "2021-05-15T14:15:41Z")

</div>

Have you tried to adapt the code from the example? Remember, it’s open-source 😉 .

---

<div class="post-metadata">

**Author:** ![Shange](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Shange](https://discourse.threejs.org/u/Shange)\
**Post date:** [May 15, 2021, 7:42pm UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253/6 "2021-05-15T19:42:52Z")

</div>

I’ve managed to get it working but can’t figure out how to add a background, see code here: [Glitch :･ﾟ✧](https://glitch.com/edit/#!/obj-model-loader)

 ![Screenshot 2021-05-15 at 20.38.59](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/a/7/a72f5cddff8d4e334202401aaf14a69b648ef7a7.jpeg)  
this is the background I want to add, it’s called ‘venice sunset’:  
 ![venice_sunset](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/3X/0/8/08cad715bdec8d4643f415e72cf81095637e46d3.jpeg)

---

<div class="post-metadata">

**Author:** ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)\
**Post date:** [May 16, 2021, 5:28pm UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253/7 "2021-05-16T17:28:31Z")

</div>

I think you should find a solution for this issue in your other topic: [Damaged Battle Helmet](https://discourse.threejs.org/t/damaged-battle-helmet/26119)

---

<div class="post-metadata">

**Author:** ![Shange](https://avatars.discourse-cdn.com/v4/letter/s/46a35a/32.png) [@Shange](https://discourse.threejs.org/u/Shange)\
**Post date:** [May 16, 2021, 6:23pm UTC](https://discourse.threejs.org/t/obj-loader-not-working/26253/8 "2021-05-16T18:23:38Z")

</div>

I’ve already tried replacing the scene.background with an envmap but it doesn’t work

```
     {
            const loader = new THREE.TextureLoader();
            const texture = loader.load(
            'https://cdn.glitch.com/0f2dd307-0d28-4fe9-9ef9-db84277033dd%2Fvenice_sunset.jpg?v=1620758317378',
            () => {
            const rt = new THREE.WebGLCubeRenderTarget(texture.image.height);
            rt.fromEquirectangularTexture(renderer, texture);
            scene.background = rt.texture;
            scene.environment = rt.texture
          });
      }
```
