watmough / glmatrix Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/glmatrix
Automatically exported from code.google.com/p/glmatrix
Suggestion imprementação Lerp and slerp.
vec3.lerp = function(vec, vec2, lerp, dest){
dest[0] = vec[0] + lerp * (vec2[0] - vec[0]);
dest[1] = vec[1] + lerp * (vec2[1] - vec[1]);
dest[2] = vec[2] + lerp * (vec2[2] - vec[2]);
}
e
quat4.slerp = function(quat, quat2, lerp, dest){
var epsilon = 1.0;
var dot = quat[0]*quat2[0] + quat[1]*quat2[1] + quat[2]*quat2[2] +
quat[3]*quat2[3];
if (dot < 0.0) epsilon = -1.0;
dest[0] = 1.0 - lerp * quat[0] + epision * lerp * quat2[0];
dest[1] = 1.0 - lerp * quat[1] + epision * lerp * quat2[1];
dest[2] = 1.0 - lerp * quat[2] + epision * lerp * quat2[2];
dest[3] = 1.0 - lerp * quat[3] + epision * lerp * quat2[3];
}
Original issue reported on code.google.com by [email protected]
on 9 Nov 2010 at 4:23
webglFloatArray is going to get replaced by either FloatArray and DoubleArray
or Float32Array and Float64Array
This should also make things even faster.
Original issue reported on code.google.com by [email protected]
on 3 Jun 2010 at 6:40
Dest is already defined in args or otherwise created.
Original issue reported on code.google.com by [email protected]
on 4 Jul 2010 at 8:59
Looks like it is not an optimization after all:
<html>
<script type="text/javascript">
function a(x) {
if (!x){}
}
function b(x) {
if (x==0){}
}
var n = 30000000;
var len = 10;
var d=new Date();
do {
a(0);
}
while(n--);
var e = new Date() -d;
var a = 10;
var n = 30000000;
var len = 10;
var f = new Date();
do {
b(0);
}
while(--n);
var g = new Date() -f;
alert(e);
alert(g);
</script>
</html>
Original issue reported on code.google.com by [email protected]
on 14 Jun 2010 at 6:51
I have a reasonable amount of objects that require translation, rotation, and
then return to previous matrix.
Not understanding how expensive the different options are, i’ve been doing:
mat4.translate(mvMatrix, [-0.5, 1.5, 0.0]);
mat4.rotate(mvMatrix, degToRad(ryRArm), [1.0, 0.0, 0.0]);
mat4.translate(mvMatrix, [0.5, -1.5, 0.0]);
.. do more ops in area ..
Is it worth introducing that function, or am I being dense? :)
Original issue reported on code.google.com by jdrinkwater
on 4 Mar 2011 at 12:56
Using javascript closures is faster than typed arrays.
See this benchmark in my clone:
http://danielheres-glmatrix2.googlecode.com/hg/benchmark/matrix_benchmark.html?r
=a1885c17e9a5e0f319ddf6e31e59e08f7e59ac84
Original issue reported on code.google.com by [email protected]
on 28 Dec 2010 at 1:25
Closure compiler seems to shave of another 1.5kb which can't be bad
Original issue reported on code.google.com by [email protected]
on 6 Jun 2010 at 8:46
I might be mistaken but i turned your library into a closure compiler extern
file and it complains that type vec4 is not defined in your script
Original issue reported on code.google.com by [email protected]
on 18 Oct 2010 at 1:56
Line 1350 says that the current function is mat4.ortho. It is in fact
mat4.lookAt. Easy fix.
Original issue reported on code.google.com by [email protected]
on 18 Mar 2011 at 12:32
mat4.frustum = function(left, right, bottom, top, near, far, dest) {
dest[0] = near << 1 / (right - left);
dest[1] = 0;
dest[2] = 0;
dest[3] = 0;
dest[4] = 0;
dest[5] = near << 1 / (top - bottom);
dest[6] = 0;
dest[7] = 0;
dest[8] = (right + left) / (right - left);
dest[9] = (top + bottom) / (top - bottom);
dest[10] = -(far + near) / (far - near);
dest[11] = -1;
dest[12] = 0;
dest[13] = 0;
dest[14] = -(far * near << 1) / (far - near);
dest[15] = 0;
return dest;
};
Shaves about 6% from benchmark here.
Proof with microbenchmark:
<html>
<script type="text/javascript">
var d = new Date();
var i = 100;
for (var a = 0; a < 10000000; a++) {
var i = i << 1;
}
var e = new Date() - d;
var f = new Date();
var i = 100;
for (var a = 0; a < 10000000; a++) {
var i = i * 2;
}
var g = new Date() - f;
alert(e);
alert(g);
</script>
</html>
Original issue reported on code.google.com by [email protected]
on 5 Jun 2010 at 7:51
in mat4.lookAt,
Benchmark:
<html>
<script type="text/javascript">
var q = new WebGLFloatArray(3);
var n = 30000000;
var len = 10;
var d=new Date();
do {
q[0] = q[0] / len;
q[1] = q[1] / len;
q[2] = q[2] / len;
}
while(n--);
var e = new Date() -d;
var a = 10;
var n = 30000000;
var len = 10;
var f = new Date();
do {
q[0] /= len;
q[1] /= len;
q[2] /= len;
}
while(--n);
var g = new Date() -f;
alert(e);
alert(g);
</script>
</html>
Original issue reported on code.google.com by [email protected]
on 14 Jun 2010 at 6:26
I'm trying to unproject but am having difficulty!
mat4.unproject = function (width, height, maxDepth, minDepth, x, y,
screenSpace, ProjectionMatrix, ViewMatrix, uv) {
var scale = mat4.create();
var invScale = mat4.create();
scale[0] = width / 2f;
scale[5] = -height / 2f;
scale[10] = maxDepth - minDepth;
scale[12] = x + width / 2f;
scale[13] = y + height / 2f;
scale[14] = minDepth;
scale[15] = 1f;
mat4.inverse(scale, invScale);
var us = vec3.create();
var up = vec3.create();
mat4.multiplyVec3(invScale, screenSpace, us);
mat4.multiplyVec3(projectionMatrix, us, up);
mat4.multiplyVec3(viewMatrix, up, uv);
}
Original issue reported on code.google.com by [email protected]
on 21 Jun 2010 at 5:02
Conclusions:
In this benchmark both Minefield and Chromium *= -1 is fastest as suggested in
quat4.inverse.
<html>
<script type="text/javascript">
var q = new WebGLFloatArray(3);
var n = 30000000;
var d=new Date();
do {
q[0] *= -1;
q[1] *= -1;
q[2] *= -1;
}
while(n--);
var e = new Date() -d;
var a = 10;
var n = 30000000;
var f = new Date();
do {
q[0] = -q[0];
q[1] *= -q[1];
q[2] *= -q[2];
}
while(--n);
var g = new Date() -f;
alert(e);
alert(g);
</script>
</html>
Original issue reported on code.google.com by [email protected]
on 14 Jun 2010 at 6:10
I fixed some tiny syntax issues with semicolons that JSLint cried about.
Also, I switched from normal equal comparisons (== and !=) to strict equal
comparisons (=== and !==) because the strict versions are much faster.
Thank you for your work.
Cheers!
Tero
Original issue reported on code.google.com by [email protected]
on 18 Mar 2011 at 1:16
Attachments:
So we don't have to check it in code and can remove if(!dest)
Original issue reported on code.google.com by [email protected]
on 5 Jun 2010 at 11:12
this is a fix for issue 39
Original issue reported on code.google.com by [email protected]
on 16 Mar 2011 at 10:15
Attachments:
The calculation of a normal transformation matrix requires a transpose for
mat3. Currently this can be worked around by doing:
var normMat = mat3.create();
mat4.toInverseMat3(mvMatrix, normMat);
normMat2 = mat3.toMat4(normMat);
mat4.transpose(normMat);
but this is just annoying. The transpose should be done on the mat3, not the
mat4.
Original issue reported on code.google.com by [email protected]
on 27 Feb 2011 at 10:23
Just a typo... should be caching vec2 values but caches vec instead.
Original issue reported on code.google.com by [email protected]
on 8 Jun 2010 at 1:50
Props on that library! the API is graceful! But I have a bug with the matrix
scaling :
What steps will reproduce the problem?
1. Scale a ModelView Matrix
2. Inverse and Transpose for the Normal Matrix
3. Specular Lights on normal mapped model looks wrong
What is the expected output? What do you see instead?
There are lights aberations that are not appearing when I don't touch the scale
Original issue reported on code.google.com by [email protected]
on 31 Jul 2010 at 4:44
In mat4.lookat(...), "return mat4.identity()" should be "return
mat4.identity(dest)".
In general I think that there you need to make a clearer separation of
destructive vs non destructive operations eg
function mat4.setIdentity(dest) { ..... return undefined;}
and
function mat4.identity() {var dest=mat4.create(); mat4.setIdentity(dest);
return dest; }
Also I notice there isn't a quat4.create() method at the moment.
And +1 for unit testing :-)
Original issue reported on code.google.com by Drew.Whitehouse
on 24 Jun 2010 at 1:59
if you create a matrix, then modify it, then print it, then modify it again and
print it to console... you will see both logs being identical (to the latest
state of the matrix you have been modifying) despite the matrix not being the
same in both logging statements.
A workaround is to call the first console.log() like this:
console.log(mat4.create(testMat));
this way we know that the value printed out to console is the value the matrix
had at that point in the JavaScript program.
Defining the following helper function is another workaround:
function printVec3 (v) {
console.log(vec3.create(v));
}
function printVec4 (v) {
console.log(vec4.create(v));
}
function printMat3 (m) {
console.log(mat3.create(m));
}
function printMat4 (m) {
console.log(mat4.create(m));
}
Original issue reported on code.google.com by [email protected]
on 6 Apr 2011 at 1:55
It is not exactly the same but it is faster.
Microbenchmark:
<html>
<script type="text/javascript">
var a = 0;
var d=new Date();
for(var x = 0; x < 10000000; x++) {
if (!a){}
}
var e = new Date() -d;
var f=new Date();
for(var b = 0; b < 10000000; b++) {
if (a==0){}
}
var g = new Date() -d;
alert(e);
alert(g);
</script>
</html>
Original issue reported on code.google.com by [email protected]
on 5 Jun 2010 at 10:33
What steps will reproduce the problem?
1. try creating a random matrix
2. notices that it still return a indetity matrix
3.
What is the expected output?
randomized matrix
What do you see instead?
a identity matrix
Original issue reported on code.google.com by [email protected]
on 2 Mar 2011 at 8:46
Lines 1551-1553 (quat4.inverse) contain:
quat[0] *= 1
quat[1] *= 1
quat[2] *= 1
It's clearly a typo, '-'s are missing.
Original issue reported on code.google.com by [email protected]
on 6 Apr 2011 at 9:29
The mat4.ortho function is different from the glOrtho implementation (found at
http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml), which switches the
positive and negative directions.
Fixed by changing:
1247 dest[12] = (left + right) / rl;
1248 dest[13] = (top + bottom) / tb;
1249 dest[14] = (far + near) / fn;
to:
1247 dest[12] = -(left + right) / rl;
1248 dest[13] = -(top + bottom) / tb;
1249 dest[14] = -(far + near) / fn;
Cheers for the library - it's super useful,
Joe
Original issue reported on code.google.com by [email protected]
on 23 Sep 2010 at 3:23
It is most call convenient to rotate in roll (z), pitch (x), and then yaw (y).
Original issue reported on code.google.com by [email protected]
on 19 Jun 2010 at 10:48
Perhaps it would be clearer if mat4.multiply was renamed mat4.preMultiply. Then
have mat4.multiply(A,B) do A*B (instead of B*A), and for completeness set
mat4.postMultiply = mat4.postMultiply.
Original issue reported on code.google.com by Drew.Whitehouse
on 26 Jun 2010 at 7:16
var dest = new glMatrixArrayType(9);
...
dest[9] = mat[9];
the above does not exist.
Original issue reported on code.google.com by [email protected]
on 1 Mar 2011 at 2:06
replace it by something like this:
var a00 = mat[0], a01 = mat[1], a02 = mat[2];
var b01 = a22*a11-a12*a21;
var b11 = -a22*a10+a12*a20;
var b21 = a21*a10-a11*a20;
var d = a00 * b01 + a01 * b11 + a02 * b21;
if (!d) { return null; }
var a10 = mat[4], a11 = mat[5], a12 = mat[6];
var a20 = mat[8], a21 = mat[9], a22 = mat[10];
var b02 = -a22*a01+a02*a21;
var b03 = a12*a01-a02*a11;
var b12 = a22*a00-a02*a20;
var b13 = -a12*a00+a02*a10;
var b22 = -a21*a00+a01*a20;
var b23 = a11*a00-a01*a10;
Original issue reported on code.google.com by [email protected]
on 4 Jun 2010 at 8:11
Could You, please, include Sylvester lib in the benchmark?
A few pages uses it for WebGL and I'm interested in the results.
Original issue reported on code.google.com by [email protected]
on 1 Mar 2011 at 1:17
very important to use the array dup
mat4.dup = function(mat){
return new glMatrixArrayType(mat);
}
Original issue reported on code.google.com by [email protected]
on 23 Jul 2010 at 1:07
mat4.frustum partially fails for non-integer near parameters, miserably for
near < 1 (at least on my chromium foo << n = Math.floor(foo) << n)
Original issue reported on code.google.com by [email protected]
on 14 Jun 2010 at 8:47
dest[4] should be dest[3] in this method and mat[4] should be mat[3]
mat4.multiplyVec4 = function(mat, vec, dest) {
if(!dest) { dest = vec }
var x = vec[0], y = vec[1], z = vec[2], w = vec[3];
dest[0] = mat[0]*x + mat[4]*y + mat[8]*z + mat[12]*w;
dest[1] = mat[1]*x + mat[5]*y + mat[9]*z + mat[13]*w;
dest[2] = mat[2]*x + mat[6]*y + mat[10]*z + mat[14]*w;
/* Here is the error: dest[4] should be dest[3] and mat[4] should be mat[3]*/
dest[4] = mat[4]*x + mat[7]*y + mat[11]*z + mat[15]*w;
return dest;
};
Original issue reported on code.google.com by [email protected]
on 18 Dec 2010 at 4:46
vec4 objects are handy for storing points with the W component, as well as
vertex color, and other things.
you support vec4 in the mat4 functions, but dont specifically declare the vec4's
Original issue reported on code.google.com by [email protected]
on 29 Mar 2011 at 12:45
It is not yet but this will surely be a lot faster
Original issue reported on code.google.com by [email protected]
on 8 Jun 2010 at 4:32
Much faster in Chromium (about 40%), slower in Minefield. Strange.
<html>
<script type="text/javascript">
var n = 30000000;
var len = 10;
var d=new Date();
do {
var l = 10;
var il = 1/l;
}
while(n--);
var e = new Date() -d;
var n = 30000000;
var len = 10;
var f = new Date();
do {
var l = 10;
l = 1/l;
}
while(--n);
var g = new Date() -f;
alert(e);
alert(g);
</script>
</html>
Original issue reported on code.google.com by [email protected]
on 14 Jun 2010 at 6:31
this is a testcase to see if the canvasMatrixRandom works or not.
Original issue reported on code.google.com by [email protected]
on 2 Mar 2011 at 8:50
Attachments:
We will need some sort of unit testing if this wants to be easily testable
Original issue reported on code.google.com by [email protected]
on 23 Jun 2010 at 8:29
Hi, I'm using the glmatrix library in my WebGL lib, and I added a bunch of
stuff to it (vec2, slightly more complete mat3 & vec3, object create count
logging).
See https://github.com/kig/magi/blob/master/src/matrix.js
and pick whatever you like.
Some of the new things aren't probably something you'd want (like setLeft(dest,
src), and I think mat4.billboard is broken), but maybe there's something of use.
Original issue reported on code.google.com by [email protected]
on 27 Feb 2011 at 11:01
about 4 times faster here
Just for fun :) The callback is to compensate for the lack of multiple
return values.
mat4.multiply = function(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21,
a22, a23, a30, a31, a32, a33, b00, b01, b02, b03, b10, b11, b12, b13, b20,
b21, b22, b23, b30, b31, b32, b33, callback) {
callback(b00 * a00 + b01 * a10 + b02 * a20 + b03 * a30,
b00 * a01 + b01 * a11 + b02 * a21 + b03 * a31,
b00 * a02 + b01 * a12 + b02 * a22 + b03 * a32,
b00 * a03 + b01 * a13 + b02 * a23 + b03 * a33,
b10 * a00 + b11 * a10 + b12 * a20 + b13 * a30,
b10 * a01 + b11 * a11 + b12 * a21 + b13 * a31,
b10 * a02 + b11 * a12 + b12 * a22 + b13 * a32,
b10 * a03 + b11 * a13 + b12 * a23 + b13 * a33,
b20 * a00 + b21 * a10 + b22 * a20 + b23 * a30,
b20 * a01 + b21 * a11 + b22 * a21 + b23 * a31,
b20 * a02 + b21 * a12 + b22 * a22 + b23 * a32,
b20 * a03 + b21 * a13 + b22 * a23 + b23 * a33,
b30 * a00 + b31 * a10 + b32 * a20 + b33 * a30,
b30 * a01 + b31 * a11 + b32 * a21 + b33 * a31,
b30 * a02 + b31 * a12 + b32 * a22 + b33 * a32,
b30 * a03 + b31 * a13 + b32 * a23 + b33 * a33);
};
benchmark:
{ name: 'glMatrix', test: function(count) {
var a = 5.0;var b = 1.0;var c = 2.0;var d = 4.0;var e = 5.0;var f =
6.0;var g = 2.0;var h = 0.0;var i = 8.0;var j = 10.0;var k = 2.0;var l =
3.0;var m = 4.0;var n = 5.0;var o = 6.0;var p = 7.0;var q = 8.0;var r =
9.0;var s = 10.0;var t = 2.0;var u = 3.0;var v = 4.0;var w = 5.0;var x =
6.0;var y = 7.0;var z = 2.0;var A = 3.0;var B = 4.0;var C = 5.0;var D =
6.0;var E = 7.0;var F = 2.0;
function cb(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s,
t, u, v, w, x, y, z, A, B, C, D, E, F){}
var start = Date.now();
for (var i = 0; i < count; ++i) {
mat4.multiply(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r,
s, t, u, v, w, x, y, z, A, B, C, D, E, F, cb);
}
return Date.now()-start;
}},
Original issue reported on code.google.com by [email protected]
on 5 Jun 2010 at 8:47
Hi Brandon,
I was working with the JavaScript graphing library flotr and needed to pick a
matrix library for some webgl work so I first played with and then adapted the
benchmarks you created in your glmatrix library:
https://glmatrix.googlecode.com/hg/.
My changes include:
- I'm only including the benchmarks.
- I've updated to the latest mjs as of Dec 15: 16:8e5b0944ef1e and included it
in several more tests.
- I've also added a graph display of the results using flotr, see:
http://solutoire.com/flotr/
My fork of these benchmarks are available here:
https://github.com/stepheneb/webgl-matrix-benchmarks
And you can run them in a browser with webgl at this url:
http://stepheneb.github.com/webgl-matrix-benchmarks/matrix_benchmark.html
The somewhat lame reason this is a fork is that it was taking me longer thanI
wanted using mercurial (don't use hg much) to follow the typical workflow I use
on github, fork a repo, push my changes into a branch and send a pull request
to the original developer ...
I've made a branch in my hg checkout of your code with these changes but ... it
wasn't clear to me the simplest way to share these with you.
I was quite interested in sharing my results because I found that glmatrix and
mjs are about 5x faster in Minefield than Chrome ... and about twice as fast in
Chrome than in a WebKit nightly -- I posted a message to
[email protected] asking people there if they thought these results were
reasonable.
They surprised me ...
Original issue reported on code.google.com by [email protected]
on 14 Feb 2011 at 5:05
in mat4.rotate:
if (len != 1) {
var ilen = 1 / len;
x *= ilen; y *= ilen; z *= ilen;
}
to
if (len != 1) {
x /= len; y /= len; z /= len;
}
and vec3.normalize:
dest[0] = x / len;
dest[1] = y / len;
dest[2] = z / len;
Original issue reported on code.google.com by [email protected]
on 5 Jun 2010 at 10:05
for example
vec3.add = function(vec, vec2, dest) {
if(!dest) { dest = vec; }
if(vec == dest) {
dest[0] += vec2[0];
dest[1] += vec2[1];
dest[2] += vec2[2];
} else {
dest[0] = vec[0] + vec2[0];
dest[1] = vec[1] + vec2[1];
dest[2] = vec[2] + vec2[2];
}
return dest;
}
could be
vec3.add = function(vec, vec2, dest) {
if(!dest) {
var dest = vec;
dest[0] += vec2[0];
dest[1] += vec2[1];
dest[2] += vec2[2];
return dest;
}
if(vec == dest) {
dest[0] += vec2[0];
dest[1] += vec2[1];
dest[2] += vec2[2];
return dest;
}
dest[0] = vec[0] + vec2[0];
dest[1] = vec[1] + vec2[1];
dest[2] = vec[2] + vec2[2];
return dest;
}
}
Original issue reported on code.google.com by [email protected]
on 4 Jun 2010 at 7:18
this is a patch to fix the canvasmatrix randomizer
Original issue reported on code.google.com by [email protected]
on 2 Mar 2011 at 9:25
Attachments:
Something like this (didn't test it)?
mat4.lookAt = function(eye, center, up, dest) {
var eyex = eye[0],
eyey = eye[1],
eyez = eye[2],
upx = up[0],
upy = up[1],
upz = up[2],
centerx = center[0],
centery = center[1],
centerz = center[2];
if (eyex == centerx && eyey == centery && eyez == centerz) {
return mat4.identity();
}
var z0,z1,z2,x0,x1,x2,y0,y1,y2,len;
//vec3.direction(eye, center, z);
z0 = eyex - center[0];
z1 = eyey - center[1];
z2 = eyez - center[2];
// normalize (no check needed for 0 becuase of early return)
len = Math.sqrt(z0 * z0 + z1 * z1 + z2 * z2);
z0 = z0/len;
z1 = z1/len;
z2 = z2/len;
//vec3.normalize(vec3.cross(up, z, x));
x0 = upy * z2 - upz * z1;
x1 = upz * z0 - upx * z2;
x2 = upx * z1 - upy * z0;
len = Math.sqrt(x0 * x0 + x1 * x1 + x2 * x2);
if (!len) {
dest[0] = 0;
dest[4] = 0;
dest[8] = 0;
dest[12] = 0;
} else {
x0 = x0/len;
x1 = x1/len;
x2 = x2/len;
dest[0] = x0;
dest[4] = x1;
dest[8] = x2;
dest[12] = -(x0 * eyex + x1 * eyey + x2 * eyez);
};
//vec3.normalize(vec3.cross(z, x, y));
y0 = z1 * x2 - z2 * x1;
y1 = z2 * x0 - z0 * x2;
y2 = z0 * x1 - z1 * x0;
len = Math.sqrt(y0 * y0 + y1 * y1 + y2 * y2);
if (!len) {
dest[1] = 0;
dest[5] = 0;
dest[9] = 0;
dest[13] = 0;
} else {
y0 = y0/len;
y1 = y1/len;
y2 = y2/len;
dest[1] = y0;
dest[5] = y1;
dest[9] = y2;
dest[13] = -(y0 * eyex + y1 * eyey + y2 * eyez);
}
dest[2] = z0;
dest[3] = 0;
dest[6] = z1;
dest[7] = 0;
dest[10] = z2;
dest[11] = 0;
dest[14] = -(z0 * eyex + z1 * eyey + z2 * eyez);
dest[15] = 1;
return dest;
};
Original issue reported on code.google.com by [email protected]
on 14 Jun 2010 at 6:09
quat4.normalize(quat) is missing a "dest" argument
Original issue reported on code.google.com by Drew.Whitehouse
on 25 Jun 2010 at 7:48
not only is === more accurate it is a lot faster.
Original issue reported on code.google.com by [email protected]
on 6 Jun 2010 at 8:20
Didn't test / benchmark it, maybe it's slower.
mat4.ortho = function(left, right, bottom, top, near, far, dest) {
var lmr = 1 / (left - right);
var tmb = 1 / (top - bottom);
dest[0] = lmr << 1;
dest[1] = 0;
dest[2] = 0;
dest[3] = 0;
dest[4] = 0;
dest[5] = tmb << 1;
dest[6] = 0;
dest[7] = 0;
dest[8] = 0;
dest[9] = 0;
dest[10] = -2 / (far - near);
dest[11] = 0;
dest[12] = (left + right) * lmr;
dest[13] = (top + bottom) * tmb;
dest[14] = (far + near) / (far - near);
dest[15] = 1;
return dest;
};
OR
mat4.ortho = function(left, right, bottom, top, near, far, dest) {
var lmr = 1 / (left - right);
var tmb = 1 / (top - bottom);
var fmn = 1 / (far - near);
dest[0] = lmr << 1;
dest[1] = 0;
dest[2] = 0;
dest[3] = 0;
dest[4] = 0;
dest[5] = tmb << 1;
dest[6] = 0;
dest[7] = 0;
dest[8] = 0;
dest[9] = 0;
dest[10] = -2 * fmn;
dest[11] = 0;
dest[12] = (left + right) * lmr;
dest[13] = (top + bottom) * tmb;
dest[14] = (far + near) * fmn;
dest[15] = 1;
return dest;
};
OR maybe with
dest[10] = ~fmn << 1 + 1;
(~ changes the sign)
Original issue reported on code.google.com by [email protected]
on 7 Jun 2010 at 10:14
You should include the function to multiply a mat4 or mat3 * 1/2 or 5, etc.
Original issue reported on code.google.com by [email protected]
on 28 Mar 2011 at 11:29
just a tiny bit faster...
Original issue reported on code.google.com by [email protected]
on 21 Jun 2010 at 5:57
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.