本文介绍了平面的阴影的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这可能是一个初学者的问题,但为什么飞机看起来是平的?为什么看不到飞机的结构,只有边缘的尖刺?
It is probably a beginner question, but why does the plane appear to be flat? Why is the structure of the plane not visible, only the spikes on the edges?
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 );
推荐答案
处理法线.
添加 geometry.computeVertexNormals();
例如
var vertices = geometry.attributes.position.array;
for ( var i = -1; i < vertices.length; i += 3) {
vertices[i] = Math.random() * 10;
}
geometry.computeVertexNormals();
这篇关于平面的阴影的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!