Open GoogleCodeExporter opened 8 years ago
doesn't work with arrays as glmatrixtype
Original comment by jeroom832@gmail.com
on 3 Aug 2010 at 4:36
Original comment by Tojiro@gmail.com
on 10 Oct 2010 at 3:58
I'm a bit torn on this, since I want the library to work with browsers that
lack WebGL support (arrays only) but would very much like the speed benefits of
using the copy functions. I could test what's available with every copy, or
defer to a function, but in either of those cases the additional overhead
potentially cancels out the benefit of the native copy. :( I'll give this one
some more thought.
Original comment by Tojiro@gmail.com
on 10 Oct 2010 at 4:07
Here is a proposal for the two cases with dup:
mat4.dup = function(mat){
if (glMatrixArrayType == Array) {
var dest = new glMatrixArrayType(16);
if(mat) {
dest[0] = mat[0];
dest[1] = mat[1];
dest[2] = mat[2];
dest[3] = mat[3];
dest[4] = mat[4];
dest[5] = mat[5];
dest[6] = mat[6];
dest[7] = mat[7];
dest[8] = mat[8];
dest[9] = mat[9];
dest[10] = mat[10];
dest[11] = mat[11];
dest[12] = mat[12];
dest[13] = mat[13];
dest[14] = mat[14];
dest[15] = mat[15];
}
return dest;
} else {
return new glMatrixArrayType(mat);
}
}
Original comment by denis.ra...@gmail.com
on 19 Oct 2010 at 2:09
We will be adding this to https://github.com/feisty/math
Please come and lodge an issue https://github.com/feisty/math/issues
Original comment by pyrotech...@gmail.com
on 15 Dec 2010 at 12:29
[deleted comment]
I think the best way is to add a function to array and Float32Array this way:
Array.prototype.copy = function() {
var b = [];
b[0] = this[0];
b[1] = this[1];
...
return b;
}
and
Float32Array.prototype.copy = function() {
return new Float32Array(this);
}
and
mat4.dup = function(mat){
return mat.copy();
}
Original comment by danielhe...@gmail.com
on 28 Feb 2011 at 8:51
another option is to create just the same function
mat4.dup = function(mat){
var dest = new glMatrixArrayType(16);
dest[0] = mat[0];
dest[1] = mat[1];
...
}
Original comment by danielhe...@gmail.com
on 28 Feb 2011 at 8:57
Original issue reported on code.google.com by
denis.ra...@gmail.com
on 23 Jul 2010 at 1:07