我正在加载.dae场景(来自Blender):
var collada_loader = new THREE.ColladaLoader();
collada_loader.load(
"resources/3D/objs.dae",
function(collada)
{
obj1 = collada.scene.getChildByName("obj1", true);
obj1.position.set(0, 0, 0);
obj1.material.color.setHex(0x003388);
scene.add(obj1);
obj2 = collada.scene.getChildByName("obj2", true);
obj2.position.set(100, 100, 100);
obj2.material.color.setHex(0x003388);
scene.add(obj2);
obj3 = collada.scene.getChildByName("obj3", true);
obj3.position.set(-100, -100, -100);
obj3.material.color.setHex(0x003388);
scene.add(obj3);
}
);
但obj * .material和obj * .geometry属性未定义!为什么? 我在loader的对象中找到了材料,并尝试创建网格:
var collada_loader = new THREE.ColladaLoader();
collada_loader.load(
"resources/3D/objs.dae",
function(collada)
{
var obj1_mat = collada.dae.materials["obj1_mat-material"];
var obj1_geom = collada.dae.geometries["obj1_geom-mesh"];
obj1 = new THREE.Mesh(obj1_geom, obj1_mat);
obj1.position.set(0, 0, 0);
obj1.material.color.setHex(0x003388);
scene.add(obj1);
var obj2_mat = collada.dae.materials["obj2_mat-material"];
var obj2_geom = collada.dae.geometries["obj2_geom-mesh"];
obj2 = new THREE.Mesh(obj2_geom, obj2_mat);
obj2.position.set(100, 100, 100);
obj2.material.color.setHex(0x003388);
scene.add(obj2);
var obj3_mat = collada.dae.materials["obj3_mat-material"];
var obj3_geom = collada.dae.geometries["obj3_geom-mesh"];
obj3 = new THREE.Mesh(obj3_geom, obj3_mat);
obj3.position.set(-100, -100, -100);
obj3.material.color.setHex(0x003388);
scene.add(obj3);
}
);
但现在Chrome写道:
Uncaught TypeError: geometry.addEventListener is not a function three.js:21479
WTF? 我解决了这个问题!有三个.ColladaLoader2() - 它工作正常!