Graphics Reference
In-Depth Information
shading: THREE.FlatShading
});
var mesh = new THREE.Mesh(geom, mat);
scene.add(mesh);
You can clearly see that three arguments have been applied to the constructor of
THREE.ParametricObject . This is discussed in more detail in the How it works…
section.
All you have to do after creating the geometry is create THREE.Mesh and add it to
the scene just like any other Three.js object.
How it works...
From step 2 in the preceding code snippet, you can see that we provide three argu-
ments to the constructor of THREE.ParametricObject . The first one is the func-
tion we showed you in step 1, the second determines in how many steps we di-
vide the u parameter, and the third one determines in how many steps we divide
the v parameter. The higher the number, the more vertices will be created, and the
smoother the final geometry will look. Note, though, that a very high amount of ver-
tices has an adverse effect on performance.
When you create THREE.ParametricGeometry , Three.js will call the provided
function a number of times. The amount of times the function is called is based on
the second and third parameters. This results in a set of THREE.Vector3 objects,
which are then automatically combined into faces. This results in a geometry that
you can use just like any other geometry.
There's more…
There are many different things you can do with these kinds of geometries than what
is shown in this recipe. In the 02.10-create-parametric-geometries.html
source file, you can find a couple of other functions that create interesting-looking
geometries such as the one shown in the following screenshot:
Search WWH ::




Custom Search