应用纹理时,Collada模型不会渲染

时间:2014-10-15 11:25:34

标签: three.js collada

当我尝试将纹理应用于我的.dae模型时,它不会呈现,控制台会显示此错误:

    [.WebGLRenderingContext]GL ERROR :GL_INVALID_OPERATION : 
      glDrawElements: attempt to access out of range vertices in attribute 2

当我将以下代码添加到collada loader

时会发生这种情况
loader.load( 'models/walls.dae', function ( collada ) {
var colladaWalls = collada.scene.children[0]
colladaWalls.name = "walls";
var wallsTexture = new THREE.ImageUtils.loadTexture( 'textures/walls.jpg' );
wallsTexture.wrapS = wallsTexture.wrapT = THREE.RepeatWrapping; 
wallsTexture.repeat.set( 2, 2 );
//adding the line below cause the model to not be loaded
colladaWalls.material = new THREE.MeshPhongMaterial( { map: wallsTexture, side: THREE.DoubleSide } ); 
colladaWalls.material.needsUpdate = true;
colladaWalls.material.wireframe = false;
colladaWalls.position.set(0,-2,0);//x,z,y- if you think in blender dimensions ;)
colladaWalls.scale.set(2,2,2);
scene.add( colladaWalls ); 
} );

问题:为什么?

1 个答案:

答案 0 :(得分:0)

MeshPhongMaterial()需要更多属性。尝试使用MeshBasicMaterial()