# OBJLoader appears to corrupt JS object

**URL:** <https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936>\
**Category:** Questions\
**Tags:** obj-loader\
**Created:** [April 5, 2019, 11:21pm UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936 "2019-04-05T23:21:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![osiriswrecks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/osiriswrecks/32/2136_2.png) [@osiriswrecks](https://discourse.threejs.org/u/osiriswrecks)\
**Post date:** [April 5, 2019, 11:21pm UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936/1 "2019-04-05T23:21:21Z")

</div>

I’m having trouble loading one particular OBJ file with Three’s OBJ loader. Here is the error:

```
three.min.js:524 Uncaught TypeError: Cannot read property 'traverse' of undefined at Pb.traverse (three.min.js:524)

```

Looking in the JS inspector it appears that the summary of the JS object at the top thinks there are 3 objects in the OBJ file (which is true), but when you expand to see the details the children array contains only two children. Somehow, Three JS is trying to traverse the third child and finding nothing because it isn’t there. Or it is. Or should be. I can’t tell anymore. (In the screenshot below, note the “children: Array(3)” at the very top, and then “children: Array(2)” in the dropdown.) This appears to _only_ happen with this particular file, but I can’t figure out why.

![Screenshot_20190405_191830](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/threejs/original/2X/7/74265a61d308544f1c4c52b01524b2f2f804edc2.png)

Has anyone else had this issue before?

---

<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:** [April 6, 2019, 9:21am UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936/2 "2019-04-06T09:21:47Z")

</div>

Can you please share the `OBJ` in this thread?

The logs of the browser console can sometimes be misleading. From [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Console/log):

> Please be warned that if you log objects in the latest versions of Chrome and Firefox what you get logged on the console is a _reference to the object_ , which is not necessarily the ‘value’ of the object at the moment in time you call console.log(), but it is the value of the object at the moment you click it open.

---

<div class="post-metadata">

**Author:** ![osiriswrecks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/osiriswrecks/32/2136_2.png) [@osiriswrecks](https://discourse.threejs.org/u/osiriswrecks)\
**Post date:** [April 6, 2019, 11:10pm UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936/3 "2019-04-06T23:10:43Z")

</div>

Absolutely. Take a look at it here: [platform.mtl](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/c/ccf47c2d81e4d749b6a46aa47a80319005539917.mtl) (441 Bytes)  
[platform.obj](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/d/d84025c0ada746a5515d385c483883b6acc16050.obj) (2.5 KB)

There should be three objects - Blender imports them perfectly for me. It’s possible it’s not exporting properly, but having someone doublecheck would be great.

---

<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:** [April 7, 2019, 9:17am UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936/4 "2019-04-07T09:17:41Z")

</div>

The dev tools in Chrome seems to correctly show the object hierarchy. A `THREE.Group` object with two children.

![image](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/threejs/original/2X/1/1b28d2780543557db1e8856fc958d326e25df2da.png)

When I import the `OBJ` in Blender, I see two objects in the outline menu, too:

![image](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/threejs/original/2X/d/db21e80aed5366cdf379cf0ae342649c4bcae259.png)

The `OBJ` itself does only contain two object definitions. So the overall result looks right.

---

<div class="post-metadata">

**Author:** ![osiriswrecks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/osiriswrecks/32/2136_2.png) [@osiriswrecks](https://discourse.threejs.org/u/osiriswrecks)\
**Post date:** [April 7, 2019, 1:00pm UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936/5 "2019-04-07T13:00:02Z")

</div>

Ah, crud. Turns out I gave you the wrong file. That OBJ works as expected because I reverted to an older one so I could continue working. Try this one?

[platform\_problem.obj](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/2/26bc6d0118d922ffa2b69e319d5250665461797c.obj) (4.2 KB)  
[platform\_problem.mtl](https://canada1.discourse-cdn.com/flex035/uploads/threejs/original/2X/9/99f7119c3c089fb3295bb30e62bb1701d4b9afea.mtl) (668 Bytes)

---

<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:** [April 7, 2019, 1:22pm UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936/6 "2019-04-07T13:22:04Z")

</div>

No inconsistency even with this model:

![image](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/threejs/original/2X/7/7c2760209bffc66714b8594eaed00039bcc42dfb.png)

Blender:

![image](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/threejs/original/2X/5/5a680e0dbf0114639668b0145d7b36486100420b.png)

Traversing works fine…

---

<div class="post-metadata">

**Author:** ![osiriswrecks](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/osiriswrecks/32/2136_2.png) [@osiriswrecks](https://discourse.threejs.org/u/osiriswrecks)\
**Post date:** [April 7, 2019, 4:45pm UTC](https://discourse.threejs.org/t/objloader-appears-to-corrupt-js-object/6936/7 "2019-04-07T16:45:39Z")

</div>

Hm. I guess I’ll clear my cache and try again later this afternoon. I have no idea why it’s giving me grief. I’ll post an update when I do to let you know if it helped.
