我想在加载后从对象获取一个材质,但我无法访问我的对象的子项
function loadObject () {
var loader = new THREE.OBJLoader();
var container = new THREE.Object3D();
var mesh = null;
loader.load( this.link , function ( object ) {
object.traverse(function (child) {
if(child instanceof THREE.Mesh){
var geometry = new THREE.Geometry().fromBufferGeometry(child.geometry);
mesh = new THREE.Mesh(geometry, child.material);
mesh.name = 'tibia';
container.add( mesh );
console.log(container.children.length);
}
});
});
return container;
};
var myObject = loadObject();