leapmotion / leapjs

JavaScript client for the Leap Motion Controller
https://developer.leapmotion.com/leapjs
Apache License 2.0
2k stars 446 forks source link

Math library considerations #96

Open theo-armour opened 10 years ago

theo-armour commented 10 years ago

In a separate issue (#91) @neptunius mentions:

@joshbuddy removed the Vector and Matrix classes in commit 25d803b to introduce gl-matrix, a high-performance math library, so we don't have to maintain our own. As @theo-armour noticed, it lacks some convenience functions in our homebrew math library that @deckar01 ported from LeapMath.h (C++) to JavaScript. If we want to bring those back, we can revive Jared's implementations and convert them to be compatible with vec3 and mat3 types provided by gl-matrix. Josh and I think it would be best to do this in a separate library to keep the LeapJS client library lean. However, there are likely other vector math utility libraries out there already, maybe one built on gl-matrix, that we can use instead of doing it all ourselves. Let's use existing libraries whenever possible!

The following are thoughts and conasiderations regarding the search for a math library that would help complete Brandon Jone's gl-matrix.

Here is good place to start when looking for JavaScript libraries:

http://jster.net/

Most of the 21 math libraries listed relate to stats, big data and other general math requirements.

The physics and game engine sections might also lead to some finds. Physijs - one of the most popular is an add-on the Three.js.

In the WebGL section, glMatrix is one of the libraries listed. https://github.com/toji/gl-matrix/tree/master/src/gl-matrix

The following are links to some of the math libraries that I have founded embedded in the various webGL apps:

GLGE https://github.com/supereggbert/GLGE/blob/master/src/core/glge_math.js

Curve3D https://github.com/sunetos/curve3d/blob/master/src/math.js

SpiderGL https://github.com/dibenedetto/SpiderGL/blob/master/src/math.js

C3DL https://github.com/cathyatseneca/c3dl/tree/master/c3dl/math

Glow https://github.com/empaempa/GLOW/tree/master/src/extras/math

OSG https://github.com/cedricpinson/osgjs/tree/develop/js/osg

CubicVR https://github.com/cjcliffe/CubicVR.js/blob/master/source/CubicVR.Math.js

Scene.js https://github.com/xeolabs/scenejs/blob/V3.0/src/core/math.js

LightGL https://github.com/evanw/lightgl.js/tree/master/src

J3D https://github.com/drojdjou/J3D/tree/master/src/math

PhiloGL https://github.com/senchalabs/philogl/blob/master/src/math.js

Closure http://closure-library.googlecode.com/svn/trunk/closure/goog/math/matrix.js

XTK https://github.com/xtk/X/blob/master/math/

N3D << new kid on block https://github.com/1Pupik1989/N3D/tree/master/source

Three.js https://github.com/mrdoob/three.js/tree/master/src/math

Benchmarks http://jsperf.com/three-gl-matrix-shootout http://jsperf.com/glmatrix-theejs-vec3-transform/6 http://jsperf.com/comparison-matrix-and-vector-library/9 http://jsperf.com/threejs-glmatrix-transfomr-vec3/5 see also this thread: https://github.com/mrdoob/three.js/issues/3454

Of all these libraries. my gut feeling is that the Three.ls library is the most complete and most actively developed, followed by Scene.js and Philogl. But then again, I am biased.

I very much hope, however, that the Leap Motion does not get tied or even identified with any particular 3D WebGL engine and that example are made using Scene.js and others libraries.

In any case, the code needed to complete the Leap Motion JavaScript library is already out there and available freely both as in beer and liberty. Many of the apps have their math routines all tidy in a single directory. Any and all of the developers would be happy to see their code being used productively in a new way.

My guess is that the majority of young new programmers coming in the Leap Motion arena will use JavaScript. The time to be talking about and sharing code is now...

Please do let your app coders know what what we can do to help

Theo

KlausBlass commented 10 years ago

When I googled for "SceneJS Leap Motion" to find some existing implementation this page of yours came up as the only relevant hit. So I had to start doing something on my own. If you're interested - here is a first result: https://www.youtube.com/watch?v=jAKr9ZvlGwc If you know of some other implementation I would be very interested... Klaus

theo-armour commented 10 years ago

Nice!

More comments later.

Are you open source?

On Tue, May 6, 2014 at 11:00 AM, KlausBlass notifications@github.comwrote:

When I googled for "SceneJS Leap Motion" to find some existing implementation this page of yours came up as the only relevant hit. So I had to start doing something on my own. If you're interested - here is a first result: https://www.youtube.com/watch?v=jAKr9ZvlGwc If you know of some other implementation I would be very interested... Klaus

— Reply to this email directly or view it on GitHubhttps://github.com/leapmotion/leapjs/issues/96#issuecomment-42336776 .

pehrlich commented 10 years ago

cc @nashira

KlausBlass commented 10 years ago

I will upload my sources to GitHub as soon as I have something a bit more complete...