# Error on loading obj file

**URL:** <https://discourse.threejs.org/t/error-on-loading-obj-file/43587>\
**Category:** Questions\
**Tags:** loaders\
**Created:** [October 13, 2022, 9:55am UTC](https://discourse.threejs.org/t/error-on-loading-obj-file/43587 "2022-10-13T09:55:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pravin\_Poudel](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/pravin_poudel/32/33369_2.png) [@Pravin\_Poudel](https://discourse.threejs.org/u/Pravin_Poudel)\
**Post date:** [October 13, 2022, 9:55am UTC](https://discourse.threejs.org/t/error-on-loading-obj-file/43587/1 "2022-10-13T09:55:38Z")

</div>

i am loading a material and i want to have all children of the model inside the scene instead of the whole model object so that i can do better selection with raycasting.

```javascript
new MTLLoader().setPath('models/').load('house_water.mtl', function (materials) {
        materials.preload()
        objLoader
            .setMaterials(materials)
            .setPath('models/')
            .load('house_water.obj', function (object) {
                object.traverse(function (child) {
                    if (child instanceof THREE.Mesh) {
                        scene.add(child)
                    }
                })
            })
    })

```

when i do this i get this error !!

```javascript

TypeError: Cannot read properties of undefined (reading 'traverse')
      at Group.traverse (three.module.js?a971:7938:1)
      at eval (client.ts?0176:41:1)
      at Object.eval [as onLoad] (OBJLoader.js?dac0:458:1)
      at eval (three.module.js?a971:39938:1)

```

can anyone please help me?
