-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let Matrix3.prototype.fromAngleVector accept a Vector3 #2
Comments
Hello, I've been thinking about this since it was first suggested (a long time ago), and I think a good approach would be to add an Euler angles class, like in Three.js. If we implemented it in Goo, it would look something like this: var angles = new Euler({ order: 'YZX' });
angles.setFromRotationMatrix(entity.transformComponent.transform.rotation);
angles.y += world.tpf;
entity.transformComponent.transform.rotation.setFromEuler(angles); This approach has some advantages over the vector approach:
What do you think? |
An optional Euler class sounds great, but why not simply add parameter detection to the function like GooJS does in other places ? |
We're trying to move away from polymorphism / parameter detection I think, to improve performance... Especially on these things that you might want to call every frame. Right @rherlitz ? |
We'll consider the options there, but get it in somehow :) |
One needs to strike a balance between performance and ease of use. |
I think it is not that hard to have both ease of use and performance. Just have a method with a different name or the euler class like @schteppe mentioned. And eventually if you add some kind of type system it might even be possible to inline stuff. |
I believe in ease of use and the Principle of least astonishment The current API violates that principle and adding support for Vector3 would fix it. So the only way to be backwards compatible and consistent with the rest of the API would be to add support for Vector3. |
Yea, we need to think through it pretty well. One thing is certain, it should all be consistent. But I very much hate overloads in such a performance critical lib and having a bunch of different ways to do things. When you start adding typeof to your code things get really messy really quick. I vote for going with the Euler solution (even if we need to deprecate stuff) or adding a method |
Currently, Matrix3x3.prototype.fromAngles takes three separate parameters: x, y, z. It would be nice if there was an additional function, or added functionality to the current 'fromAngles', to accept a Vector3 Object as well:
var rot = new goo.Matrix3x3();
entity.transformComponent.transform.rotation.toAngles(rot); // notice a Vector3 passed in here...
rot.y += ctx.world.tpf;
// this would be nice!
entity.transformComponent.transform.rotation.fromAngleVector(rot); // we pass in the Vector3 here as well.
Currently, we have to pass in each part of the Vector3:
entity.transformComponent.transform.rotation.fromAngles(rot[0]. rot[1], rot[2]);
The text was updated successfully, but these errors were encountered: