CSS3或Three.js中的曲面平面?

时间:2013-05-06 09:24:31

标签: css3 3d three.js

如何使用CSS3或Three.js创建曲面平面(如图所示)?

curved surface

1 个答案:

答案 0 :(得分:7)

var width = 100, height = 100, width_segments =1, height_segments = 100;
var plane = new THREE.PlaneGeometry(width, height, width_segments, height_segments);

for(var i=0; i<plane.vertices.length/2; i++) {
    plane.vertices[2*i].position.z = Math.pow(2, i/20);
    plane.vertices[2*i+1].position.z = Math.pow(2, i/20);
}

var mesh = new THREE.Mesh(plane, new THREE.MeshLambertMaterial({color: 0x888888}));
mesh.doubleSided = true;
mesh.rotation.y = Math.PI/2-0.5;
scene.add(mesh);

您可以创建几何体,并按照您希望的方式移动它的顶点。对于创建曲面,你可以使用'sin'或'cos'函数,或指数,如我所示。 希望这会有所帮助。