cljfx

https://github.com/cljfx/cljfx
lvh 2020-08-06T00:43:39.187300Z

Has anyone done 3D shapes and rotations with cljfx? I'm trying: https://gist.github.com/lvh/5b356405b2d79038022fe474b5fd13c1 -- but while ostensibly the rotations are getting parsed (when I inspect the output of @(renderer) I can find actual Rotation objects with the correct values), the box doesn't appear to be rotating -- I know state updates work because e.g. color changes work fine.

vlaaad 2020-08-06T08:34:33.187700Z

Hmm, I'm not sure transforms is what you need to rotate objects

vlaaad 2020-08-06T08:36:31.187900Z

There is :rotate and :rotation-axis props on node, perhaps that's what will work

lvh 2020-08-06T11:39:42.188800Z

Unfortunately the use case here is getting data from an inertial measurement unit so I have pitch, roll and yaw

lvh 2020-08-06T11:40:00.189500Z

I guess I can use Euler’s rotation theorem to get to 1 rotation?

lvh 2020-08-06T11:52:22.189700Z

FWIW the reason I thought I needed transforms here was because I was working from JavaFX examples, e.g.: https://www.dummies.com/programming/java/javafx-programming-example-3d-box/

lvh 2020-08-06T11:52:43.190Z

salient part:

lvh 2020-08-06T11:52:44.190200Z

> To rotate on more than one axis, you must use the Rotate class instead. You create a separate Rotate instance for each axis you want to rotate the object on and then add all the Rotate instances to the object’s Transforms collection via the getTransforms().addAll method, like this:

lvh 2020-08-06T11:52:54.190400Z

Rotate rxBox = new Rotate(0, 0, 0, 0, Rotate.X_AXIS);
Rotate ryBox = new Rotate(0, 0, 0, 0, Rotate.Y_AXIS);
Rotate rzBox = new Rotate(0, 0, 0, 0, Rotate.Z_AXIS);
rxBox.setAngle(30);
ryBox.setAngle(50);
rzBox.setAngle(30);
box.getTransforms().addAll(rxBox, ryBox, rzBox);

lvh 2020-08-06T11:57:10.190600Z

A similar project I found using plain JavaFX appears to try very hard to turn all rotations into 1 affine transform, but it mostly just does that so it can see the sum of the rotations and display that separately: https://github.com/tschuett-munich/gyro-to-javafx/blob/master/src/de/roboshock/javafx/gyropuppet/RotationTracker.java

lvh 2020-08-06T11:59:04.190900Z

that said even if I did that I'd still have an Affine at the end and there doesn't appear to be a better place to put that than :transforms

lvh 2020-08-06T12:01:49.191100Z

uh wtf

lvh 2020-08-06T12:01:53.191300Z

I just did exactly the same thing and now it works

lvh 2020-08-06T12:02:20.191500Z

well, I'm sure it's an issue with only half the code being updated or something

lvh 2020-08-06T12:04:48.191700Z

OK, so I think the problem is that I'm rewriting root but of course that has an old reference because it takes the fn and not #'root

lvh 2020-08-06T12:05:37.191900Z

I was expecting calling the renderer to fix it but because root itself is changing I need to build an entirely new renderer, I'm not just updating state

lvh 2020-08-06T12:05:53.192100Z

anyway now I have a beautiful slanted box, thank you 😄