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

查看:37
本文介绍了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天全站免登陆