Hacker News new | ask | show | jobs
by ionfish 5771 days ago
The CSS 2D [1] and 3D [2] Transforms Modules specify that browsers should expose an implementation of the CSSMatrix interface; unfortunately, only WebKit does this at the moment. However, since that's also the only browser in which the CSS 3D Transforms Module is implemented, it doesn't really matter too much yet. WebKitCSSMatrix [3] provides most of the low-level code you'll want to generate 3D transforms, including the fundamental multiply and inverse methods, along with convenience methods for scaling, translating, rotating elements around the x, y and z axes and rotating around arbitrary (three-dimensional) vectors.

[1] http://www.w3.org/TR/css3-2d-transforms/

[2] http://www.w3.org/TR/css3-3d-transforms/

[3] http://developer.apple.com/safari/library/documentation/Audi...

1 comments

The CSS 2D transforms are frustratingly crippled in my opinion. Instead of allowing the specification of a full 3x3 matrix for doing homogeneous coordinate transformations (and thus general perspective transforms), only a 2x3 matrix can be specified. I’m really glad they actually give access to the whole 4x4 matrix in the 3D version.
Yes, it's a big improvement. The WebKitCSSMatrix implementation is actually compatible with both specifications: it provides getters and setters for elements a-f as well as m11-m44, and serialises to "matrix(a, b, c, d, e, f)" if the matrix is affine.