pex-gl / pex-math

Array-based vector, quaternion and matrix math with utils for PEX.
MIT License
14 stars 2 forks source link

vec3.create for future calculations #12

Closed simonharrisco closed 6 years ago

simonharrisco commented 6 years ago

At the moment if you initialise a vec3 you can only create [0,0,0].

What if you would like to set a vector manually for future calculations how about:

function create (x,y,z) {
  return [
    x || 0,
    y || 0,
    z || 0
  ]
}
nicknikolov commented 6 years ago

Then you just create JS array inline, no need to call extra function.

simonharrisco commented 6 years ago

Too true, I'm used to vec3 objects with vector3.x over vec3[0] arrays. Silly suggestion

nicknikolov commented 6 years ago

No its a reasonable question from API design point of view but at the end of the day we already destroying the JS garbage collector, so you API shouldn't encourage even more allocations and function creations.

vorg commented 6 years ago

@nicknikolov the problem is we already have create:

function create () {
  return [0, 0, 0]
}

that means vec3.create(1,2,3) does nothing and returns [0,0,0].. not good!

nicknikolov commented 6 years ago

True actually, up for removing it in 4.0