I have the following C++ struct which I want to create as faithfully as possible in Javascript:
struct Vertex
{
float coords[4];
float colors[4];
};
So I did the following:
function Vertex(coords, colors)
{
this.coords = [];
this.colors = [];
}
Now, the following works to create a Vertex instance:
var oneVertex = new Vertex();
oneVertex.coords = [20.0, 20.0, 0.0, 1.0];
oneVertex.colors = [0.0, 0.0, 0.0, 1.0];
but the following (slicker?) doesn't:
var oneVertex = new Vertex([20.0, 20.0, 0.0, 1.0],
[0.0, 0.0, 0.0, 1.0]);
Why? I am new to Javascript and what little I have read suggests it should be ok. Obviously not. It would be helpful to understand what I am missing. Thanks.