Closed kronpano closed 4 years ago
OK, it really is the case - scaling affects the rotation BUT only the non-uniform scaling. So rule containing "{ry 10 s 1.5}box" that is OK but if you have rotation and non uniform scaling like "{ ry 10 s 1.5 1 1} box" that actually affects the rotation.
As example I use the simple script of
9 * {ry 22.5 y -1 s 1.4} 1 * {ry -22.5}box
This gives you a nice tower of stacked boxes. In the image you can also see the angle value - I put a debug statement into the code when the element is actually added to the scene which shows the x, y and z angles:
var rot2 = new THREE.Euler().setFromRotationMatrix (object.matrix,"YZX") console.log(rot2._x * 180 / Math.PI,rot2._y * 180 / Math.PI,rot2._z * 180 / Math.PI ) switch (object.type) { case 'background': clearColor(object.color); break; case 'primitive': lesson10.MyAddPrimitive(object); break; } These angles are extracted from the Matrix4 - the quaternions - which I still don't fully understand.
OK - first uniform scaling: script: 9 * {ry 22.5 y -1 s 1.4} 1 * {ry -22.5}box (angle chosen to make it easy to see in the degub you can see angles are close enough to 0,45,90,135 and 180 and now non uniform scaling:
script: 9 * {ry 22.5 y -1 s 1.4 1 1 } 1 * {ry -22.5}box
it also gets worse if one scaling goes up and one down: script: 9 * {ry 22.5 y -1 s 1.4 1 0.8 } 1 * {ry -22.5}box After nine rotations of 22.5 it barely reaches 90 degrees not the 180 you would expect.
Looking at the code it is all connected to the Matrix4 (and matrix,js) in interpreter.js where the values are stored and renderer.js addPrimitive where the object matrix is applied.
I am not sure about matrix.js and the functions in there. Need to investigate further but I am not familiar with the Matrix4 side of things.
Looking at three.js it might be connected to https://github.com/mrdoob/three.js/issues/3185 ??? But - as said before - I don;t fully understand the Matrix4.
Sorry. I came home now. I have to work much more hard for schedule delay in this week. Maybe.. next few weeks.
No worries - we all know that sadly work - real paid work is more important. Will probably play a bit more and possibly raise issues but that does NOT mean I expect anything.
Everybody does things in their time - thanks for such a great start !!!
It looks fixed now.
tower rule tower md 44 { {s 2 5 3 }box {y 5 rx 10 rz 10 s 0.95 } tower }
tower rule tower md 44 { {s 2 5 3 }box {y 5 rx 10 rz 10 s 0.95 1 1 } tower }
9 {ry 22.5 y -1 s 1.4} 1 {ry -22.5}box
@kronpano Is it ok to close this issue?
If the issue hasn't been fixed, please reopen issue.
Using the following script:
Now the only change is to change the scaling in the recursive function call:
There are quite a few wobbles when it comes to the rotation and there seem to be points where the box is actually growing - not shrinking - even though the rule is same or smaller.
It leads to an irregular image when all it should do is shrink in the direction of one axis.
This behaviour will be different from the original Structure Synth because there the shearing happened when rotation and scaling was used in the same rule .