[request ] add extra Vector3 static methods from unity3d
sonygod opened this issue · 4 comments
add extra Vector3 static method from unity3d
http://docs.unity3d.com/ScriptReference/Vector3.html
Vector3.Angle
Vector3.Project
...ect
The functions in Unity3D but not in Vector3 are: Angle, Clamp, Distance, Max, Min, MoveTowards, OrthoNormalize, Project, ProjectOnPlane, Reflect, RotateTowards, Slerp, SmoothDamp.
Min, Max, Project, OrthoNormalize, Reflect, ProjectOnPlane, Slerp: A reasonable request, I can add these.
Angle, Clamp: These exist on Vector2, I was planning on adding those anyway (note that these aren't static functions, they're member functions).
Distance: This is something that I've had at least one other request for. I guess subtracting vectors and checking length isn't as intuitive. On the other hand, I don't want to pollute the interface. Not sure whether to add this. What's your opinion?
MoveTowards, RotateTowards, SmoothDamp: I'll think about these. They're a little less straightforward and might not actually belong on the Vector classes.
my opinion is full implement Unity's API, the I copy exist code directly .
current *.hx can be use unity by this project
https://github.com/PeyTy/LuaXe
and convert hx to lua use in unity
your project can be imporve the performance ,instead use lua call unity api,use lua file directly,
it's fast!
I looked into MoveTowards, RotateTowards, SmoothDamp and they seem pretty complex/specific to Unity. Though I have no problem implementing the non-specific/simple functions, full compatibility with Unity's API is a non-goal for hxmath.
That said, I will keep the more complex interpolation functions in mind when I revisit the Frame classes.
I am still (slowly) working on the other functions.
Everything is now supported except MoveTowards, RotateTowards, and SmoothDamp.
I've also opened issue #32 to track changing user-facing angles to degrees instead of radians. This is more in line with most game math libraries.
Summary of what's been added (static functions typically allocate new objects, member functions are more efficient):
Unity3D function | hxmath objects | hxmath functions |
---|---|---|
Min | Vector[2,3,4] | minWith, min (static) |
Max | Vector[2,3,4] | maxWith, max (static) |
Project | Vector[2,3,4] | projectOnto, project (static) |
Clamp | Vector[2,3,4] | clamp |
Distance | Vector[2,3,4] | distanceTo |
Angle | Vector[2,3], Quaternion | angleWith |
OrthoNormalize | Vector[2,3] | orthoNormalize (static, modifies input) |
Reflect | Vector[2,3] | reflectBy, reflect (static) |
ProjectOntoPlane | Vector3 | projectOntoPlane |
Slerp | Quaternion | slerp (static) |