Closed Bug 704468 Opened 13 years ago Closed 13 years ago

Wrong rotation direction for rotate3d(x,y,z,angle)

Categories

(Core :: CSS Parsing and Computation, defect)

10 Branch
x86
macOS
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla11
Tracking Status
firefox10 - fixed
firefox11 --- fixed

People

(Reporter: waste, Assigned: mattwoodrow)

References

Details

(Whiteboard: [qa!])

Attachments

(4 files, 1 obsolete file)

Attached file HTML-demo
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.51.22 (KHTML, like Gecko) Version/5.1.1 Safari/534.51.22 Steps to reproduce: Apply CSS3 3d rotation (rotate3d(0,0,1,50deg) to element. Actual results: Element rotated counterclockwise around axis Expected results: According to the spec it should have rotated *clockwise*. (See http://www.eleqtriq.com/wp-content/static/demos/2011/mozbugs/)
Attachment #576138 - Attachment mime type: text/plain → text/html
I am fairly sure that this is invalid. As I see it, vector (0,0,1) is coming out of the screen so any rotation will be as 'seen' from behind the screen; The rotation that you want would be (0,0,-1,50deg). [cf (1,0,0) being left to right, and (0,1,0) being top to bottom]
Component: General → Style System (CSS)
Product: Firefox → Core
QA Contact: general → style-system
As I understand the spec the rotation vector is relative to the rotation origin of the elements local coordinate system. In the example the rotation occurs around a positive vector pointing towards the viewer, so a clockwise rotation should be a rotation from left to right IMHO. Another way to describe this rotation would be rotateZ(50deg), which works consistently in Fox and Webkit. The third way to describe this rotation would be to transfer vector and angle into a matrix. And again, applying a CSS3D transform with the resulting matrix, matrix3d(0.643,0.7663,0,0,-0.766,0.643,0,0,0,0,1,0,0,0,0,1) suddenly gives us the transformation we expected -clockwise around the Z-axis- consistently in Fox and Webkit. However, even If your assumption would be true, this would mean that Webkit implementation has a bug. Unfortunately Webkit supports CSS3d for almost two years, which means every existing content will break in Fox10 causing new headaches for developers. If this is the case, I as a developer would prefer the pragmatic solution that the spec is changed and Fox adopts the webkit way of handling rotations.
Attached file -1 in vector vs rotatex/y/z (obsolete) —
According to the spec the axis angle combination is equivalent to this matrix3d transformation: matrix3d(1 + (1-cos(angle))*(x*x-1), -z*sin(angle)+(1-cos(angle))*x*y, y*sin(angle)+(1-cos(angle))*x*z, 0, z*sin(angle)+(1-cos(angle))*x*y, 1 + (1-cos(angle))*(y*y-1), -x*sin(angle)+(1-cos(angle))*y*z, 0, -y*sin(angle)+(1-cos(angle))*x*z, x*sin(angle)+(1-cos(angle))*y*z, 1 + (1-cos(angle))*(z*z-1), 0, 0, 0, 0, 1). However, both transformations behave differently in aurora, one more indication that rotate3d is not implemented as expected.
Attachment #576443 - Attachment mime type: text/plain → text/html
Matt, can you take a look please?
Assignee: nobody → matt.woodrow
Blocks: 505115
Status: UNCONFIRMED → NEW
Ever confirmed: true
Added -webkit-transform styles
Attachment #576434 - Attachment is obsolete: true
(In reply to Dirk from comment #2) > ... And again, applying a CSS3D transform with > the resulting matrix, > matrix3d(0.643,0.7663,0,0,-0.766,0.643,0,0,0,0,1,0,0,0,0,1) suddenly gives > us the transformation we expected -clockwise around the Z-axis- consistently > in Fox and Webkit. This is not the matrix you get when applying the algorithm from the spec -z*sin(angle) gives -0.76626 so AFAICT we are following the standard but don't give the same result as webkit. [in attachment 576443 [details] computed styles are rotate3d: -moz-transform: matrix(0.642531, -0.76626, 0.76626, 0.642531, 0px, 0px); matrix3d: -moz-transform: matrix(0.643, 0.7663, -0.766, 0.643, 0px, 0px);]
Your right! Well then - hello again, inconsistencies and vendorprefix, my old friends :-/
We do need to figure out whether the bug is in the spec or in WebKit...
(And to be clear why there's a tracking nomination: we should figure this out before we ship 3d transforms.)
Looks like there is a consensus about this on www-style. This patch reverse the rotation direction of rotate3d() with a note that it's still wrong in the spec.
Attachment #578940 - Flags: review?(dbaron)
Comment on attachment 578940 [details] [diff] [review] Reverse the rotation direction r=dbaron
Attachment #578940 - Flags: review?(dbaron) → review+
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla11
Comment on attachment 578940 [details] [diff] [review] Reverse the rotation direction We shouldn't ship 3d transforms without this trivial fix, so requesting aurora approval.
Attachment #578940 - Flags: approval-mozilla-aurora?
Attachment #578940 - Flags: approval-mozilla-aurora? → approval-mozilla-aurora+
Verified s fixed using the attached test cases on: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0a2) Gecko/20111214 Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0a1) Gecko/20111212
Status: RESOLVED → VERIFIED
Whiteboard: [qa!]
Depends on: 769892
No longer depends on: 769892
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: