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.
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 !!
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?