Weird Walk Two threejs example
Last week I started a weird walk guy threejs example, and as such this week I think I will make another threejs example where I just a continue with that example. However of course I will be taking this idea into a new direction with how I create and move legs. With the first weird walk I was thinking that it would be cool to just have to mesh objects for legs, and have just one axis of each leg scale up and down as a kind of crude yet amusing walk cycle. For this example I am thinking more in terms with something that is a walk cycle where the legs are two or more mesh objects that rotate at certain pivot locations. However as with the first weird walk cycle example I do so in a very weird way in which the thighs of the weird walk guy move forward from the rest of the body very far so the look is in no way natural. So in other words when it comes to this weird walk guy example, just like with the first example, I am going in a kind of weird for the sake of weird kind of direction.
This time I made some changes that have to do with how I go about adding textures to a module that I make this way my making another file that helps me with the process of making data textures. This is however the kind of change that I might do with the weird walk one module as well though which it comes to maybe doing more to revise the source code with that example. So for the most part what stands alone here is what is added in terms of additional mesh objects and code that is used to update those mesh objects.
This weird walk two example and what to know first
This is a post on a project example that makes use of threejs, and consists of several javaScript files to create a crude yet effective informal model with a weird walk cycle. This is not in any way a post on the topic of getting started with threejs as well as any additional skills that are required before hand in order to get something of value from reading this. In fact I assume that you have at fair amount of experience with threejs and JavaScript in general. However I do like to make use of these opening sections of posts to write about at least a few things that you might want to read up more on before reading the rest of this post regardless of experence.
I have many other threejs examples like this one
This is not the first example that I have made that is like this, in fact I have made a few informal models as I have come to call them. The first one that I have made would be my guy one module that I made many years ago now. I have mentioned that this is indeed a weird walk one, but sense I wrote this post for the first time I also made a weird walk three project as well.
The source code of this example is on Github
I have the source code of this example parked on my test threejs repository on Github.
Version numbers matter
When I first started writing this post I was using r135 of threejs with the source code examples, and the last time I came around to do some editing I was using r146. I was able to get this example up and ruining fine with that revision of threejs, but I am sure that it will end up breaking at some point in the future. I do take the time to come around and do a little editing of each if these threejs posts, but it might be a while until I come around again.
1 - The first revision of weird walk two ( r0 )
In this section I will be going over the source code of the first and at time time of this writing, the only revision of this weird walk module. I can not say that I have any interest in making any future revisions of this module as I have many other examples that are of greater interest. So future edits of this post might just have to do with making additional demos of this first revision.
The goal with this was to just start with what I all ready worked out with the first weird walk one example, but now I just want to have a slightly different walk cycle. Also while I am at it make a javaScript file that has more to do with creating textures with the data texture constructor rather than that if the canvas texture constructor.
The data textures module
Here I have the source code for the data textures module that I will be using to create textures for the weird walk guy, as well as additional mesh objects that I create in the main javaScript example for this. This module consists of a few public methods one of which will return a texture created from the given color channel data array in the form of a unit8array. The other methods are various ways of going about creating that kind of an array that is used to create the textures. I have a for each pixel method that where I can given a function in which I can define logic that is to be used to create the red, green, blue, and alpha values for each color channel of each pixel. I then have additional options for creating textures with this, but the general idea is the same, one way or another crate a texture by way of the THREE.DataTexture constructor.
|
|
The weird guy two module ( r0 )
Now that I have the texture module out of the way I can now write about the weird guy two module that makes use of this data texture module to create the textures for the various materials that are used to skin the various parts of the guy. At the top of the module I am using the seeded random method of the math utils object as a way to create just a texture with random variations of black and write for each pixel. This is what I use to just add some kind of texture other than that of just a solid color which strokes me as just a kind of place holder type thing for some kind of better option for a texture, but for some things this might still work well.
After that I once again just have a method to create and return the group that I will add to the scene object when making some code that makes use of this. After that I just have two additional public methods that are used to set the walk cycle, and to also set the state of the arms as well. The only major different here is that I am using the object3d rotation property of the mesh objects to rotate mesh objects, rather than the object3d scale property to just set the scale of the legs as I did in weird walk one.
|
|
1.1 - A demo of weird walk two ( r0 )
I have my data textures file, and I now also have my weird guy module that I can use to create an instance of this guy module that will have a weird and amusing walk cycle. So now I just need a little additional javaScript code that will create a simple animation loop in which I am using at least one instance of this guy module. On top of using the weird guy two module to create an instance of the weird walk guy I also am making use of the for each pixel method of the data texture module to create a custom texture for the ground mesh that I am also using in the scene.
|
|
Conclusion
I am not sure what the future of this example might be if any actually. I have a whole lot of other threejs examples that i would like to work on more when it comes to making updated revision of the module that is used along with additional demos of the modules and videos for them. With that said I can not say that weird walk two is at the top of the list and that the first weird walk example, as well as the third one have higher priority when it comes to revision. Still I did have a basic general idea with this one that is kind of cool, so who knows what the future may hold when it comes to the nest time I come around to edit this post a little.