# Error loading obj file

**URL:** <https://forum.babylonjs.com/t/error-loading-obj-file/42439>\
**Category:** Bugs\
**Created:** [July 14, 2023, 3:40pm UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439 "2023-07-14T15:40:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Bozzolan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/daniel_bozzolan/32/6374_2.png) [@Daniel\_Bozzolan](https://forum.babylonjs.com/u/Daniel_Bozzolan)\
**Post date:** [July 14, 2023, 3:40pm UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439/1 "2023-07-14T15:40:02Z")

</div>

Hello!

It seems that trying to import this .obj file (in babylonjs sandbox), it can’t be read and I can’t understand the error in console. It works fine in other 3d viewers.

The error is the following:  
solidParser.ts:212 Uncaught TypeError: Cannot read properties of undefined (reading ‘x’)  
at e.\_unwrapData (solidParser.ts:212:76)  
at e.parse (solidParser.ts:745:22)  
at e.\_parseSolid (objFileLoader.ts:242:21)  
at e.importMeshAsync (objFileLoader.ts:156:21)  
at e.loadAsync (objFileLoader.ts:178:21)  
at sceneLoader.ts:1050:26  
at f (sceneLoader.ts:571:13)  
at o.onload (fileTools.ts:369:9)  
[aaa.zip](https://forum.babylonjs.com/uploads/short-url/sZrj55IillwtxGxdk1RbLFQv1IH.zip) (1.1 MB)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 14, 2023, 4:20pm UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439/2 "2023-07-14T16:20:14Z")

</div>

Hello! It seems this file is a bit malformed, because it doesn’t have any UV data (which would be lines starting with vt):

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/5/2599fe84d33a3796ae4e51473892939c2f09d670.png)

But the face data is specified as if there was UV data:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/6/d6d6a44af0afad5ac2549817d8be19ab1c7e4343.png)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/b/2ba6a6d658b4e1cd956572354d142f68d0db950b.png)

the expected format here would be the `f 1//1 2//2 etc...`

The other viewers are probably trying to fix this under the hood by assuming that, if you have a face in the `f 1/1 2/2...` format, but there are no UV coordinates, then the second index refers to the normals instead of the UVs. Should we do the same @sebavan ? We could perform this correction by default, or throw an error in the default case, and pass an option to correct.

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [July 15, 2023, 7:47am UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439/3 "2023-07-15T07:47:52Z")

</div>

> [@carolhmj](#):
>
> Should we do the same

That would be the cherry on the cake 🍒 😄 Though, I think the current behavior is quite expected. No UV, no tex projection == no money, no candy, no cando 🤪 🤣 I actually encountered this before while being careless with my assets and in fine, I’m fine with it the way it is (of course, personal opinion only).

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 17, 2023, 8:59pm UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439/4 "2023-07-17T20:59:50Z")

</div>

I would suggest to do it only if this happens frequently in some tools creating obj 🙂

@Daniel_Bozzolan where did you get your file from ?

---

<div class="post-metadata">

**Author:** ![Daniel\_Bozzolan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/daniel_bozzolan/32/6374_2.png) [@Daniel\_Bozzolan](https://forum.babylonjs.com/u/Daniel_Bozzolan)\
**Post date:** [July 18, 2023, 7:05am UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439/5 "2023-07-18T07:05:46Z")

</div>

The file comes from a user input for which i’d like to use babylonJs as a viewer.  
We have no control over the generation of the file. 🙂

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [July 18, 2023, 11:55am UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439/6 "2023-07-18T11:55:07Z")

</div>

> [@Daniel\_Bozzolan](#):
>
> We have no control over the generation of the file

May be you could have control over the user? I.E. providing some guidelines for import files?  
Simple suggestion of course. Don’t mind me 🤭 and meanwhile, have a great day 🕶

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 18, 2023, 2:01pm UTC](https://forum.babylonjs.com/t/error-loading-obj-file/42439/7 "2023-07-18T14:01:38Z")

</div>

Do you have a lot of input files like this from various users ? and could you ask them for the sources ?
