Closed dmnsgn closed 5 years ago
Most rotations in pex-renderer are Quaternions. In pex-math we do have old OpenGL axis + angle rotations too. What's the use case for mat3.fromTranslationRotationScale(t, s, r)
? What's the axis of the rotation?
Mat3 is capable of representing 3d rotations and mat3.fromQuat
exists so we could align with mat4
and accept quat
in both cases. Currently in this PR it's confusing to have 2 functions with the same name but different types.
I updated the first comment with usage.
mat2d should be faster for texture transform as offset and scale are array[2]
and rotation is in radians.
I removed mat3.fromTranslationRotationScale
as it will be confusing and not needed anymore with the addition of mat2d.
mat23
is a better name because we don't have mat3d
This is equivalent to Unity's Material#SetTextureOffset and Material#SetTextureScale, or Three.js's Texture#offset and Texture#repeat. UV rotation is not widely supported as of today, but is included here for forward compatibility.
I can't think of an use case where texture rotation would be useful. That simplifies data to vec2 offset and vec2 scale which... can be sent together as one vec4 and no need for mat23. Hmm?
- How is it faster? Because we don't use quaternions for such a simple rotation?
And because it is 6 and not 9 elements
- I think
mat23
is a better name because we don't havemat3d
I took it from glmatrix. What about mat2x3
instead to match OpenGL and WebGL 2?
- Here is a crazy idea. From the KHR_texture_transform specs.
This is equivalent to Unity's Material#SetTextureOffset and Material#SetTextureScale, or Three.js's Texture#offset and Texture#repeat. UV rotation is not widely supported as of today, but is included here for forward compatibility.
I can't think of an use case where texture rotation would be useful. That simplifies data to vec2 offset and vec2 scale which... can be sent together as one vec4 and no need for mat23. Hmm?
Imagine an atlas of 4 rectangular textures 300x130:
Altlas: 512x512
Columns layout:
- 300 + [82] + 130
- 300 + [82] + 130
- 300 + [212]
Row layout:
130 +
130 +
130 +
[122]
___________
| / / / / |
| / / / / |
| / / / |
___________
Cool, I updated yesterday, it's ready to be merged.
Published as pex-math@next
aka pex-math@3.0.0-2
Fix #20