Is there any downside of passing a Vector3
instead of three single values into functions like Matrix4,makeTranslation(x, y, z)
?
If not I would make a few PRs in the future where Matrix4.makeTranslation(x, y, z)
and other functions would also accept a Vector3
. Of course I would also at it in the documentation.
So I would suggest to allow “overriding” of functions, I know JavaScript can’t do this but it is possible to do it by code.
Example:
// three.js/src/math/Matrix4.js
// Before
makeTranslation: function ( x, y, z ) {
this.set(
1, 0, 0, x,
0, 1, 0, y,
0, 0, 1, z,
0, 0, 0, 1
);
return this;
},...
// After (with "overriding")
makeTranslation: function ( x, y, z ) {
if (x instanceof THREE.Vector3) { // haven't tested this line, but should work
z = x.z;
y = x.y;
x = x.x;
}
this.set(
1, 0, 0, x,
0, 1, 0, y,
0, 0, 1, z,
0, 0, 0, 1
);
return this;
},...
Three.js version
- [x ] Dev
Browser
- All of them
OS
- All of them
We support multiple types in certain cases. For example,
This method is particularly problematic for users:
Users often do this, instead, and are confused when it doesn’t work.
Furthermore, because a
Vector3
is required, I have seen aVector3
instantiated in the render loopI think supporting alternate types is fine in certain cases —
lookAt()
may be a good candidate.