Settings

Theme

Spinning Diagrams with CSS

x.st

954 points by hrldcpr 3 years ago · 44 comments

Reader

hrldcprOP 3 years ago

Some commenters on HN and Twitter were curious how I made the spinning diagrams in a previous thing I wrote, so 8 months later I finally wrote down an explanation.

(Previous HN thread here - https://news.ycombinator.com/item?id=32528769 )

  • pjot 3 years ago

    The spinning dimension adds such an information dense layer to the sum of cubes examples - a fantastic display of what is good data visualization.

    Also, I’m quite jealous of your one letter domain.

  • TimedToasts 3 years ago

    I enjoyed the part referencing selected/highlighted areas rotating 'correctly'. I had to try it and it was just as pleasing as you said it would be.

    Kudos for the write-up and kudos to the anonymous devs out there who wrote that portion of browser code.

  • ad404b8a372f2b9 3 years ago

    This is fantastic, do you have any other interesting techniques for displaying math?

    I never thought to augment plain old equations like that, it's making my mind bubble.

  • cloudking 3 years ago

    Awesome work, we really don't need Flash anymore :)

  • netsharc 3 years ago

    Really neat. Would it be possible to make the letters go gray when they go "behind the cube" from POV of the camera?

    • kilovoltaire 3 years ago

      Oh yeah that would look cool…

      Possibly transparent faces of the cube with a particular `mix-blend-mode` that leaves the background color alone but dims letters that get behind it?

      (That's just a wild guess, I don't know if it's actually possible.)

      • fwlr 3 years ago

        Faces of the cube with the same color as the background and opacity 0.2 would almost certainly work. My next thought is duplicate the original cube, remove the characters from the duplicate cube and set the color on the duplicate only, then move the duplicate cube back one pixel in the z direction.

efortis 3 years ago

Here's a fluid-width cube carousel you can stop at its faces:

https://ericfortis.github.io/web-animations/#-fluid-3d-cube-...

Source:

https://github.com/ericfortis/web-animations/blob/main/3d-ca...

unwind 3 years ago

This is awesome in (for me) at least two dimensions at the same time: it's a very interesting way of visualizing the actual math concept going on, by making the equation 3D to match what it's modelling. At the same time, it's very impressive technically that this can be done at all, and done without active per-frame custom code.

That this amount of "whoa that's not a 2D document" can be done by the web's standard stylizing technology is amazing. I'm not (again, personally) 100% convinced it should be this amazing[*], but that's another discussion.

Well done.

[*]: I'm just afraid of the complexity level in modern browsers, that's the other side of the "wow it can do that?" coin.

asimpletune 3 years ago

You can do so much with pure css. Using checkboxes elements to toggle menus comes to mind as one of the lowest hanging fruits. Also detail elements are great.

  • robin_reala 3 years ago

    As much as I like the idea of checkbox toggled panels, it’s worth pointing out that that technique is inaccessible.

    • asimpletune 3 years ago

      Really? Can you explain this a little more? If memory serves I use close/open check boxes that have labels with descriptive aria and IDs. Then toggling one hides itself and reveals the other.

packetslave 3 years ago

The pyramid animation at the top reminds me of 11:30 in this video: https://youtu.be/q6MJSfjXUgQ?t=690

...which is the same 2D/3D illusion, but made with, you know... humans.

Benney_ 3 years ago

3D CSS is actually super powerful, and once you wrap your head around how transforms interact with each other you can use it like any other 3D library.

Me and a friend made a game using 3D CSS a few years ago: https://js13kgames.com/entries/3dc5s.

I'm not sure I'd ever use it again for something that large as it's a hell of a lot of work but so satisfying once you see the monstrosity you've created running!

robbywashere_ 3 years ago

If Leonardo Da Vinci knew css

  • jaza 3 years ago

    He would never have finished Vitruvian Man, he would have wasted too much time trying to get it looking perfect across all browsers / devices / zoom levels.

  • sakesun 3 years ago

    If Euclid knew css

xyst 3 years ago

I wonder what a screen reader reads out when it encounters this

  • gondaloof 3 years ago

    CSS is largely ignored by readers with few exceptions (`transform` is ignored, `display: none` excludes the text).

    You can definitely make this accessible but that alone is a whole exercise. The best bet would be to use MathML-in-HTML and hope that the reader supports it.

myfonj 3 years ago

I have used the same approach for plotting named colours in RGB cube [1]

[1]: https://codepen.io/myf/full/poyoyLr

ramesh31 3 years ago

Great example of how absurdly powerful (yet simple) CSS is. Try doing this in one line with literally any other UI technology in existence.

throwaway14356 3 years ago

i made some n dimensional chart one time. it starts with the usual 2D x,y,z axes then rotates as if a cube to the next chart keeping the dots in the same 3D spot ending in 2D and on to the next chart :)

(using css where possible ofc)

sideproject 3 years ago

I'm more impressed with the domain name.

Giorgi 3 years ago

Damn is that 1 symbol domain?

xmppfans 3 years ago

It is very cool!

dist-epoch 3 years ago

On one hand people are in awe at this, on the other they complain how bloated browsers are and how much functionality is crammed in them and how they wish for a simple "document only web".

Pick one.

Cypher 3 years ago

It's nice

samstave 3 years ago

Maze runnner. interactions.

efields 3 years ago

Now make it respond to touch

  • gondaloof 3 years ago

    It's actually not terribly difficult, even without JavaScript if you use the new scroll-linked CSS animations and a fake/hidden scrollable area (but without JS, the rotation would be limited to the scroll area itself)

  • tomcam 3 years ago

    Hey, you're pretty smart--why not give it a spin (ahem) yourself?

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection