Is it possible to declare a structure in javascript without it having to be a class that must be dynamically allocated?
Currently I am doing something like this:
class HairParticle
{
var position : Vector3 = Vector3.zero;
var velocity : Vector3 = Vector3.zero;
}
class Hair extends System.Object
{
var nParticles : int = 10;
var theParticles : HairParticle[];
function Hair() {
theParticles = new HairParticle[nParticles];
for (var i : int = 0; i < nParticles; i++ )
theParticles[i] = new HairParticle();
}
}
What I would like to avoid is this line:
theParticles[i] = new HairParticle();
Which as far as I can see allocates an entire object for nothing more than 6 floats.
But if you can declare a struct in Javascript, I haven’t been able to deduce the syntax.
(Edited on April 5, to see if I could bump my question to the top of list that way)