Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing between glMatrix, Sylvester and CanvasMatrix? [closed]

Finally, I decided to make my own WebGL 3D engine from the ground up, I begin tutorials from http://www.khronos.org/webgl/ and http://learningwebgl.com and https://developer.mozilla.org/en/WebGL

But problem is that each tutorial used/recommend different library for Matrix calculations, so I'm confused!

  • khronos recommend CanvasMatrix (but now they switch to J3DI.js from Apple ?)
  • Mozilla recommend Sylvester all the way!
  • Learningwebgl.com recommend glMatrix

Question is: Which one is well suited for 3D WebGL Applications, Charts and Games? (both performance and usability matters)

Thanks

like image 540
xxx Avatar asked Aug 22 '11 12:08

xxx


1 Answers

Look at http://glmatrix.googlecode.com/hg/benchmark/matrix_benchmark.html http://greggman.github.io/webgl-matrix-benchmarks/matrix_benchmark.html

I use glMatrix, and it works fine. The API is a bit weird.

var in = vec3.create([1, 2, 3]);

//overwrite 'in' in-place
vec3.scale(in, 2);

//write output to a different vector
var out = vec3.create();
vec3.scale(in, 2, out);

Or for glMatrix 2

var in = vec3.fromValues(1, 2, 3);

//overwrite 'in' in-place
vec3.scale(in, in, 2);

//write output to a different vector
var out = vec3.create();
vec3.scale(out, in, 2);

But it's fast, it supports the operations I want, and it's straightforward. Additionally, The source is very understandable.

I have no experience with the others, though.

Update:

There are benchmarks of more libraries available at http://stepheneb.github.com/webgl-matrix-benchmarks/matrix_benchmark.html. In Chrome on my Mac, Closure wins pretty handily. In Chrome on my PC, it's much more of a toss-up. I'm still using glMatrix for now, since it lives in a single Javascript file.

like image 176
Daniel Yankowsky Avatar answered Sep 30 '22 19:09

Daniel Yankowsky