Hello World example of Election.js

I have been putting getting started with election.js long enough, so this year will be the year that I write at least a few posts on the subject while I am learning how to make election.ks apps. Whenever I learn something new I have to start somewhere, so as one would expect this will be a hello world example of an election app. For this hello world election app I started out with an example that I found at the quick start guild of the election js website. I then just made just a few chances from the example in a effort to make it even a little more reduced, but also addressed some things that I think should be address right away even for a hello world app.

One thing that I wanted to figure out right away was how to go about having a custom native menu for the app. Sense this is a hello world app the default for this is a little more advanced than what is needed. So Right away i looked into how to go about having a custom template for the native menu, even for a hello world app.

Read More

Vector3 set from spherical coords method

There is a whole lot to write about when it comes to the Vector3 class such as things like normalizing an instance of Vector3, or getting the distance between two instances of a Vector3 object. One thing that often want to do when making any kind of project with threejs is to position an object in terms of a spherical set of values in terms of a radius, and then two angles that have to do with coordinates similar to that of latitude and longitude.

Thus far I have made one threejs project example that had to do with creating a module that is centered around the single purpose of positioning an object3d based object of one kind or another to the surface of a sphere. That example has to do not just with setting a position, but also setting a desired value for the rotation of an object3d based object such as a mesh or camera.

The system I made for that example does seem for the most part to work okay, but I still think that there are more ways of doing the same thing, some of which might prove to be better for one reason or another. With that said while I was taking a second look at the Vector3 documentation I have found that there is a prototype method in the vector3 class that has to do with setting the values of a verctor3 instance using a radius, and two angles in radian values called Vector3.setFromSphericalCoords. So then this method might also prove to be a helpful fool for working out some kind of system like the one I made for the threejs project example example post, but to know for sure I have to make at least a few quick demos.

Read More

Source Layer javaScript tool example

For a final new javaScript example for this month at least I made what might prove to be the first of several tool type project examples. What I mean by this is that I might often want to create some kind of project where the aim is to create some kind of resource such as a sprite sheet, world map, or maybe just some kind of image asset actually. I do not care so take the time to create a full blown image editor from the ground up mind you when it comes to that I have come to enjoy just using GIMP and moving on with my life. However often it might make sense to create some kind of custom image editor where I can open up a image file that I do not want to use directly as part of the image project, but to just serve as a source for a drawing that I will create in another canvas layer on top of this source layer.

So then this javaScript tool example will be a simple art program, however that main focus here is to create a kind of simple module that will be used to create an mutate a kind of source object that will be used in this tool, but can easily be used in other tools without having to change much to the code of the module.

Read More

Lodash String methods

This will be a post on string methods in the popular javaScript library known as lodash. The main reason why I am bothering with this is that I have wrote posts on lodash collection methods in general, as well as object methods, and array methods in lodash, so then it makes sense to write a post on the general topic of working with strings and loash.

Much of the functionality of the lodash string methods can also be achieved with corresponding native javaScript methods, so like many of my other posts on lodash I will also be touching base on vanilla javaScript and strings later in this post.

Read More

New Object Pool library javaScript example

Looks like I will be continuing to expand on my collection of javaScript examples posts with a new examples as it just seems like the thing to do once I write about the basics of javaScript. This week the example that I made is a new object pool library that I made for a recent digital art example earlier this month. After doing so I thought that this new object pool library deserves a for post folder of its own in my test vjs repository, and I should also maybe mack at least one if not more examples that make use of this library when it comes to making additional javaScript projects.

This is not the first time I made this sort of library that I then end up using in one or more additional projects, in fact this is still very much based off of what I started in my canvas examples series post on this subject of object pools. If you are not sure what an object pool is the general idea is more or less as the term descries, it is just a system of creating a pool of objects that are then used over and over again, rather than creating and destroying objects as needed.

One major improvement that I wanted to make with this object pool library is how the object state is stored as well as rendered. The older object pool module that I based this on centered around the idea of having the x and y values of an object refer to the upper left corner of a display object. In this pool I wanted to change things with the various methods so that the x and y values refer to the center point of a display object actually, and then things are figured out from there. While I was at it I started to make some additional improvements on top of that of course though. As I keep copying the source code of the original library over from project to project I have made little additions here and there with this, one of which is a wrap object method which is a typical methods that is needed for a library such as thins, however for this version of the library I also added a clamp method.

Read More