在glMatrix, Sylvester和CanvasMatrix之间选择

Choosing between glMatrix, Sylvester and CanvasMatrix?

本文关键字:CanvasMatrix 之间 选择 Sylvester glMatrix      更新时间:2023-09-26

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

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

  • khronos推荐CanvasMatrix(但现在他们从Apple切换到J3DI.js ?)
  • Mozilla一直推荐Sylvester !
  • Learningwebgl.com推荐glMatrix

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

谢谢

看http://greggman.github.io/webgl-matrix-benchmarks/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);

对于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);

但是它很快,它支持我想要的操作,而且它很简单。此外,来源是非常容易理解的。

我对其他的没有经验。

更新:

在http://stepheneb.github.io/webgl-matrix-benchmarks/matrix_benchmark.html上有更多库的基准测试。在我Mac上的Chrome浏览器中,Closure很容易获胜。在我个人电脑上的Chrome浏览器中,这就更像是一种选择了。我现在仍然使用glMatrix,因为它存在于单个Javascript文件中。