选择glMatrix,Sylvester和CanvasMatrix?

xxx*_*xxx 9 javascript webgl

最后,我决定从头开始制作自己的WebGL 3D引擎,我从http://www.khronos.org/webgl/http://learningwebgl.com以及https://developer.mozilla.org开始教程./ EN/WebGL的

但问题是每个教程使用/推荐不同的库用于Matrix计算,所以我很困惑!

  • khronos推荐CanvasMatrix(但现在他们从Apple切换到J3DI.js?)
  • Mozilla一路推荐西尔维斯特!
  • Learningwebgl.com推荐glMatrix

问题是:哪一个非常适合3D WebGL应用程序,图表和游戏?(性能和可用性都很重要)

谢谢

Dan*_*sky 7

请查看http://glmatrix.googlecode.com/hg/benchmark/matrix_benchmark.html

我使用glMatrix,它工作正常.API有点奇怪.

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);
Run Code Online (Sandbox Code Playgroud)

或者对于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);
Run Code Online (Sandbox Code Playgroud)

但它很快,它支持我想要的操作,而且很简单.来源可以理解.

不过,我对其他人没有经验.

更新:

http://stepheneb.github.com/webgl-matrix-benchmarks/matrix_benchmark.html上提供了更多库的基准测试.在Mac上的Chrome中,Closure非常轻松获胜.在我的电脑上的Chrome中,它更像是一个折腾.我现在还在使用glMatrix,因为它只存在于一个Javascript文件中.

  • 我[刚刚添加了Sylvester](https://github.com/feklee/webgl-matrix-benchmarks)到基准测试(pull request pending).西尔维斯特很慢*.为什么它比[Numeric Javascript benchmark](http://www.numericjs.com/benchmark.html)中的Closure更快?答案:该基准测试Closure的通用矩阵函数,而不是专用于WebGL的函数. (2认同)