For the last example, we'll look at how you can use an existing library to easily create parametric geometries. In this case, we'll show you how to create trees like the ones shown in the following screenshot (05.05-generated-tree
):
Note
The library we use to create this generated tree is called proctree.js
, which you can download from GitHub at the following link:
This library allows you to specify a bunch of parameters, which are used to create a tree geometry. To get this to work with Three.js, we have to convert the information provided by this library to Three.js. Let's look at what proctree.js
generates so that we can decide how to convert it:
var myTree = new Tree({ // configuration }); console.log(myTree);
The following screenshot shows this result in the Chrome console:
As shown in the previous screenshot, the proctree.js
library creates the following components when generating a tree:
Property |
Description |
---|---|
|