toji / gl-matrix

Javascript Matrix and Vector library for High Performance WebGL apps
glmatrix.net
MIT License
5.37k stars 721 forks source link

set() vs fromValues() #417

Closed z3dev closed 3 years ago

z3dev commented 3 years ago

For consistency sake, only one of these needs to be present, as the fromValues() should also have an 'out' parameter, just like all the other from* functions.

vec3.fromValues(out, x, y, z)

After this change, set() is redundant.

toji commented 3 years ago

.fromValues() creates a new vector, while .set() changes the values of an existing vector, which is why it requires an out parameter. (The 'fromMat/Quat/etc` functions are different in that they convert between types.) Given that they serve two different purposes, we should keep the methods separate.