Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

Rotation #14

@Arnavion

Description

@Arnavion
  • Partial implementation in this branch - diff
  • Rotation is always applied in the order Y-X-Z
  • Rotations apply from the point where they're defined till the end of the line or till they're redefined. However, a redefined rotation is always measured from the zero of the screen. For example, the line M{\fry60}N{\fry60}O will cause O to be rotated a total of 60 degrees, not 120.
  • When individual angles of rotation are thus overridden, the other angles remain unmodified. For example, in the line M{\frz45\fry60}N{\fry0}O, M will be rotated by 0-0-0, N will be rotated by 60-0-45 and O by 0-0-45
  • However, this cannot be rendered as completely separate rotations. In the previous example, the N will be slightly into the screen due to the 60 degrees Y-angle, and the O will be also into the screen (but parallel to the X-Y plane). Effectively the O will be in a plane closer to the viewer than the M, and so will appear larger.

All these facts combined mean that rotations must nest. The line M{\frz45\fry60}N{\fry0}O{\frx90\frz30}P must be rendered as follows:

<span id="1">M<span id="2">N<span id="3">O<span id="4">P</span></span></span></span>

with the following transforms on each:

#1: .transform = "";
#2: .transform = "rotateY(60deg) rotateX(0deg) rotateZ(-45deg)";
#3: .transform = "rotateZ(45deg) rotateX(-0deg) rotateY(-60deg) " + // undo existing rotation to reset back to 0
                 "rotateY(0deg) rotateX(0deg) rotateZ(-45deg)"; // apply new rotation
#4: .transform = "rotateZ(45deg) rotateX(-0deg) rotateY(-0deg) " + // undo existing rotation to reset back to 0
                 "rotateY(0deg) rotateX(90deg) rotateZ(-30deg)"; // apply new rotation

The only thing that should start a top-level span with no reversed rotation applied first is a \N


Unfortunately browsers implement rotation in a retarded manner. All rotations are done from scratch, i.e., if the parent element is rotated, the child element's rotation is not applied on top of the parent's rotation. Instead, it's applied as if the way the child is visible right now is the 0-0-0 state. Thus there is no way to undo a parent's rotation on a child and apply a new rotation.

<style type="text/css">div { display: inline-block; }</style>
<div><div>ABCD</div></div>
<div style="-webkit-transform: rotateY(60deg); transform: rotateY(60deg);"><div>ABCD</div></div>
<div style="-webkit-transform: rotateY(60deg); transform: rotateY(60deg);"><div style="-webkit-transform: rotateY(-60deg); transform: rotateY(-60deg);">ABCD</div></div>

Notice how the third div doesn't look like the first. The child doesn't have the parent's 60deg rotation reversed, instead it has a -60deg rotation applied to its appearance due to the parent rotation (second div).

Another example: http://jsfiddle.net/ag5dQ/4/ Notice how .child_b1 is the same size as .child_b, but .child_b2 isn't.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions