使用three.js加载带顶点颜色的collada文件

时间:2015-05-21 17:32:50

标签: colors three.js vertex collada

我正在尝试使用three.js加载dae文件,但我无法显示要显示的内容。我找不到任何使用dae文件加载文件本身的顶点颜色的示例。我可以通过将材质设置为MeshBasicMaterial并将属性Vertex Colors设置为Vertex Colors来将其加载到threejs.org/editor。我试图在代码中复制它,但我不认为我完全理解如何。这是我的装载机功能......

loader.load( 'objects/chair.dae', function ( collada ) {
//dummy1.dae
    var dae = collada.scene;
    var skin = collada.skins[ 0 ];
    console.log(collada.scene);
    //collada.dae.materials[0] =   collada.scene.children[0].children[0].material;
    //dae.material = collada.scene.children[0].children[0].material;
    //var material = collada.scene.children[0].children[0].material;
    var material = new THREE.MeshBasicMaterial({
    vertexColors: THREE.VertexColors
    });
    collada.scene.position.set(0,0,0);//x,z,y- if you think in blender     dimensions ;)
    collada.scene.scale.set(15.0, 15.0, 15.0);
    var mesh = new THREE.Mesh(collada, material);
    scene.add(mesh);
    //scene.add(collada.scene);
    var axes = new THREE.AxisHelper(50);
    axes.position = dae.position;
    scene.add(axes);
    var gridXZ = new THREE.GridHelper(100, 10);
    gridXZ.setColors( new THREE.Color(0x8f8f8f), new THREE.Color(0x8f8f8f) );
    gridXZ.position.set(0,0,0 );
    scene.add(gridXZ);
});

这会产生错误。

1 个答案:

答案 0 :(得分:0)

至于代码,基本上你必须改变Collada对象中网格的材质。类似的东西:

QMAKE_CXXFLAGS += -Wc++11-extensions