This week the focus was just on working out one new threejs example that has to do with creating and mutating a group of lines. I did a lot of other things this week of coarse that has to do with playing around with tube geometry, but that might be a matter for another future threejs example that will be similar to this one. This example is just a project in which I continued with my lat threejs example that also had to do with creating a group of lines but the goal was just to create a group of lines that form a sphere of sorts and then mutate things from there. With this example what I wanted to do is make a similar system of sorts, but to make it so that a group of lines that form a sphere is just one of many options.
The module that I have made that I am writing about can be used to create an instance of a threejs group where each child of the group is an instance of a line. A line in threejs is one alternative to that of the typical mesh object that is used to add content to an over all scene object.
One major aspect of this module has to do with setting and updating the position attribute of an instance of buffer geometry using the set from points method as well as an alternative method that is better for updating the geometry rather than creating it for the first time.
The source code that I am writing about here can also be found on github along with the source for my many other threejs example thus far.
When I wrote this post I was using r140 of threejs and the code in this post as working fine for me on my end with that revision of threejs.
In this section I will be going over the source code of the line group module that helps me with the process of creating and updating a collection of lines that are children of a group. In additional to the module itself I have also worked out a few types as I am calling them thus far when it comes to objects that define the logic for creating an updating the state of a group of lines. In the module itself I have a single built in line group type to mainly serve as a guide when knowing how to go about making a custom line group for the module.
The Line group module itself has a create, load, and set public methods thus far. The create method is what I call to create a new line group, the load methods is what I use to load a type of line group, and the set method is what to use to update the state of a line group with a given set of frame, maxFrame, and base data values to set the state of the line group.
I made a number of external plug-ins while making the first version of this module in order to just test out that the loading method works as a way to pull logic that has to do with a specific line group out of the module and into an external optional file. This module turned out similar to what I worked out for my sphere circles example, but I wans thi8nging more in terms of just a stack of circles that I am chaining in a way that does not have to form a sphere like shape when it came to making this one.
The whole idea of this project was to make a module that provides a way to create a more flexible from of what I worked out for my lines sphere circles example where the collection of lines that I made for that example is just one way to go about using the module. So then I should be able to just quickly create a plug-in that is more of less the same code that I worked out for that example as a plug-in for this line group module and sure enough here it is and it seems to work fine just far.
For the sake of this section then I now just want a little additional code that is a simple use case example of the built in line group type ‘tri’, as well as the two additional types that I have made thus far in the form of external fines to use with this module then.
This lines group module is shaping up to be what it is that I had in kind when I started working on it, but I am not sure if I would want to put much more time into further refining this project or not. I am sure that I would if I end up using this on a day to day basis that goes without saying, but I am not sure of that will end up being the case with this project or not. In the event that I do start using something like this on a day to day basic I am currently of the mindset that I might want to do so with yet another example that is similar to this one, only it will involve the use of TubeGeometry rather than that of lines as there is a lot more that can be done with that compared to lines.