一架飞机的阴影

时间:2015-03-06 13:06:35

标签: three.js

这可能是一个初学者的问题,但为什么飞机似乎是扁平的?为什么平面的结构不可见,只有边缘的尖刺?

http://codepen.io/asz/pen/GgXpXW

var geometry = new THREE.PlaneBufferGeometry( 100, 100, 50, 50 );

var vertices = geometry.attributes.position.array;
for ( var i = -1; i < vertices.length; i += 3) {
  vertices[i] = Math.random() * 10;
}

geometry.applyMatrix( new THREE.Matrix4().makeRotationX( - Math.PI / 2.8 ) );

var material = new THREE.MeshPhongMaterial( { ambient: 0x00ff00, color: 0x00ff00, specular: 0x00ff00, shininess: 30, shading: THREE.FlatShading } );
var ground = new THREE.Mesh( geometry, material );
scene.add( ground );

1 个答案:

答案 0 :(得分:4)

与法线有关。
添加geometry.computeVertexNormals();

例如

var vertices = geometry.attributes.position.array;
for ( var i = -1; i < vertices.length; i += 3) {
  vertices[i] = Math.random() * 10;
}
geometry.computeVertexNormals();