- From: Joe Pea via GitHub <sysbot+gh@w3.org>
- Date: Fri, 27 Dec 2024 06:15:18 +0000
- To: public-fxtf-archive@w3.org
The spec (and behavior in all browsers but Firefox) is also at odds with `rotateSelf`. Here are the [steps for `rotateSelf`](https://drafts.fxtf.org/geometry/#dom-dommatrix-rotateself): 1. If rotY and rotZ are both missing, set rotZ to the value of rotX and set rotX and rotY to 0. 2. If rotY is still missing, set rotY to 0. 3. If rotZ is still missing, set rotZ to 0. 4. If rotX or rotY are not 0 or -0, set [is 2D](https://drafts.fxtf.org/geometry/#matrix-is-2d) of the current matrix to false. 5. [Post-multiply](https://drafts.fxtf.org/geometry/#post-multiply) a rotation transformation on the current matrix around the vector 0, 0, 1 by the specified rotation rotZ in degrees. The 3D rotation matrix is [described](https://drafts.csswg.org/css-transforms-1/#RotateDefined) in CSS Transforms with alpha = rotZ in degrees. [[CSS3-TRANSFORMS]](https://drafts.fxtf.org/geometry/#biblio-css3-transforms) 6. [Post-multiply](https://drafts.fxtf.org/geometry/#post-multiply) a rotation transformation on the current matrix around the vector 0, 1, 0 by the specified rotation rotY in degrees. The 3D rotation matrix is [described](https://drafts.csswg.org/css-transforms-1/#RotateDefined) in CSS Transforms with alpha = rotY in degrees. [[CSS3-TRANSFORMS]](https://drafts.fxtf.org/geometry/#biblio-css3-transforms) 7. [Post-multiply](https://drafts.fxtf.org/geometry/#post-multiply) a rotation transformation on the current matrix around the vector 1, 0, 0 by the specified rotation rotX in degrees. The 3D rotation matrix is [described](https://drafts.csswg.org/css-transforms-1/#RotateDefined) in CSS Transforms with alpha = rotX in degrees. [[CSS3-TRANSFORMS]](https://drafts.fxtf.org/geometry/#biblio-css3-transforms) 8. Return the current matrix. Note that, if the angle of rotation around X or Y are zero, then `is2D` **shall not** be set to `false`! However, with `rotateAxisAngleSelf`, if the rotation (angle) around X or Y are zero, `is2D` **does** get set to `false`! It would be good for consistency if Firefox's behavior was adopted into the spec for `rotateAxisAngleSelf` (basically early return if `angle` is zero). With this inconsistency fixed in the spec, then the implementation of `rotateAxisAngleSelf` can be easily re-used for `rotateSelf` while the expected behavior (of Firefox) will apply to both cases. Here's an example in TypeScript: ```ts rotateAxisAngleSelf(x = 0, y = 0, z = 0, angle = 0) { if (angle === 0) return this // <--------------- Firefox behavior. toAxisRotation(axisRotationMatrix, x, y, z, angle) this.multiplySelf(axisRotationMatrix) // "post multiply" if (x !== 0 || y !== 0) this[is2D] = false // <---- without early return, all other browsers do this even if "nothing happened" return this } rotateSelf(rotX = 0, rotY?: number, rotZ?: number) { if (rotY == null && rotZ == null) { rotZ = rotX rotX = 0 rotY = 0 } rotY ??= 0 rotZ ??= 0 this.rotateAxisAngleSelf(0, 0, 1, rotZ) this.rotateAxisAngleSelf(0, 1, 0, rotY) this.rotateAxisAngleSelf(1, 0, 0, rotX) return this } ``` If we remove the early return from `rotateAxisAngleSelf` then we get the behavior in all browsers other than Firefox, but in that case, we need to implement `rotateSelf` like this: ```ts rotateAxisAngleSelf(x = 0, y = 0, z = 0, angle = 0) { // if (angle === 0) return this // <--------------- Firefox behavior (commented out) toAxisRotation(axisRotationMatrix, x, y, z, angle) this.multiplySelf(axisRotationMatrix) // "post multiply" if (x !== 0 || y !== 0) this[is2D] = false // <---- without early return, all other browsers do this even if "nothing happened" return this } rotateSelf(rotX = 0, rotY?: number, rotZ?: number) { if (rotY == null && rotZ == null) { rotZ = rotX rotX = 0 rotY = 0 } rotY ??= 0 rotZ ??= 0 // the conditional checks prevent is2D from unnecessarily becoming false. if (rotZ) this.rotateAxisAngleSelf(0, 0, 1, rotZ) if (rotY) this.rotateAxisAngleSelf(0, 1, 0, rotY) if (rotX) this.rotateAxisAngleSelf(1, 0, 0, rotX) return this } ``` -- GitHub Notification of comment by trusktr Please view or discuss this issue at https://github.com/w3c/fxtf-drafts/issues/579#issuecomment-2563363020 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Friday, 27 December 2024 06:15:19 UTC