Reputation: 2203
In my Three JS application, I downloaded some JSON files for objects from clara.io. I load them into the an object variable with THREE.ObjectLoader
. I add it to the scene and everything works fine.
However, when I try to display the wireframe of the object with THREE.WireframeHelper
, I get the following error:
Uncaught TypeError: Cannot read property 'array' of undefined
Apparently, the geometry of the object is undefined.
So the question is: do custom shapes loaded in this manner always have empty geometries? If no, how can I obtain an object with it's geometry "intact"?
Upvotes: 1
Views: 50
Reputation: 104823
The loaded object likely has child objects and child meshes.
In your loader callback, use this pattern:
object.traverse( function( child ) {
if ( child instanceof THREE.Mesh ) {
var wh = new THREE.WireframeHelper( child, 0xffffff );
scene.add( wh );
}
} );
three.js r.73
Upvotes: 4