CSS3或Three.js中的曲面? [英] Curved plane surface in CSS3 or Three.js?

查看:1580
本文介绍了CSS3或Three.js中的曲面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How can I create a curved plane surface (like the one pictured) using CSS3 or Three.js?

推荐答案

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'函数,或者指数函数,如我所示。
希望这有帮助。

You create geometry, and displace it's vertices the way you would like to. For creating curved surface you could use 'sin' or 'cos' functions, or exponential, as I showed. Hope this helps.

这篇关于CSS3或Three.js中的曲面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆