Tree Sphere threejs example
I wrote a post on a simple crude three model example using three.js, but I thought I would come around to making another one of these just for the sake of doing the same thing a different way. The last tree model that I made involves making a whole bunch of cone geometries and then positioning them and rotating them in a way to make something that looks a little like an ever green tree. This is another model like that where I am just using a sphere geometry and a box geometry to create another kind of tree that is more of the Deciduous rather than evergreen type.
So it goes without saying that I am going for a kind of style where I am just making simple basic models using the built in three.js geometries. In the long run though it might be best to look into how to go about making models in blender and then importing them into threejs by way of something like the dae file loader.
This is then a fairly basic threejs example of this kind of model but there are still a few basic things that I need to work out when it comes to creating these kinds of groups of mesh objects. One thing to be aware of is what happens when I use the object3d look at method with out of these. For this tree model I would want for the look at method to make it so that the bottom of the trunk is what is facing the position that I give to the look at method.
A tree Sphere model example in three.js and what to know first
Source code examples up on Github
The source code examples that I write about here can also be found on Github.
Version Numbers matter with threejs
Groups and the Object3d class
In this three.js example I am making use of the THREE.Group constructor as a way to create a collection of mesh objects that compose something that looks a little like a tree. I am also using a lot of other features that are part of the object3d class such as the look at method of that class just to name on little feature. The Object3d class is a base class of a whole lot of other classes in three.js that include Groups, but also things like Mesh Objects, and Cameras so the class is worth looking into in death if you have not done so before hand.
1 - The tree sphere module
So then here I have the tree sphere model as it currently stands as of this writing. There is not much to write about when it comes to a crude, simple static model that is created using the built in geometry constructors of three.js like this. However I think I have the few things that I should be ware of solid as it seems to be working the way I expect it to when it comes to how I intend to use it in an over all scene.
That is it for the tree sphere module, the idea here was to just make a very simple crude model that looks a little like a tree following a every simple art style. I do not thing that it can get much more simple than this, so now it is just a question of using the is some kind of basic scene to make sure that it works as it should when using the look at method of the over all group that contains both the trunk and the sphere at top.
2 - A Simple demo of this tree sphere module
the main thing here is the line where I am using the look at method of the tree group that is created with the create method of the tree model. When I call the look at method and have the tree look at a position that is below it the bottom of the trunk f the tree is what is facing that given point in worked space. That is of course how I would like to have the tree model work when using it, if for some reason I want that to be different I am just going to have the adjust accordingly. However that aside I would say that is more or less it, this is just a basic tree model and it works more or less as I would expect. Now the question is what to do when it comes to making an over all larger scene that might make use of this tree model.
This tree model might end up being used in a few additional three.js examples here and there when I want to have something that I can use to just quickly create some groups of objects that will look like trees. More often than not something like this will work just fine, however that is because I am going for a very simplistic art style when it comes to this sort of thing.
There is not much to say about this, however there might be a lot to say about some over all project in which I am using the tree sphere model as just one assets in an over all larger scene of some kind. One other example that I have made thus far that make use of this tree sphere model will be my tree sphere world example. In this example I am making a main world module that creates a bunch of these tree models and places them along the surface of a sphere that represents some kind of small little world.