Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Curved plane surface in CSS3 or Three.js?

Tags:

css

three.js

3d

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

curved surface

like image 485
dani Avatar asked May 06 '13 09:05

dani


People also ask

Are planes curved or surface?

A flat surface is called a "plane". Both ball and capsule have curved surfaces. And floor and board have flat surfaces.


1 Answers

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);

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.

like image 157
Dragan Okanovic Avatar answered Oct 17 '22 03:10

Dragan Okanovic