THREE.ParametricGeometry
With THREE.ParametricGeometry
, you can create a geometry based on an equation. Before we dive into our own example, a good thing to start with is to look at the examples already provided by Three.js. When you download the Three.js distribution, you get the examples/js/ParametricGeometries.js
file. In this file, you can find a couple of examples of equations you can use together with THREE.ParametricGeometry
. The most basic example is the function to create a plane:
plane: function ( width, height ) { return function ( u, v, optionalTarget ) { var result = optionalTarget || new THREE.Vector3(); var x = u * width; var y = 0; var z = v * height; return result.set( x, y, z ); }; }
This function is called by THREE.ParametricGeometry
. The u
and v
values will range from 0
to 1
and will be called a large number of times for all the values from 0
to 1
. In this example, the u
value is used to determine the x coordinate of the vector and...