cgajs
cgajs copied to clipboard
Rotation is always about the world origin
For the following
Lot --> extrude(1)
s(5, 1, 1)
split(x) {1: A | 1: NIL | 1: B | 1: NIL | 1: C}
A --> color("red")
B --> color("green")
C --> color("blue")
r(0, 45, 0)
I intended C
to be in line with A
& B
, but rotated 45 degrees about its centre; instead, it is rotated about the world origin and moves out of line. I have to translate C
to the origin, rotate and translate back to simulate the intended effect:
Lot --> extrude(1)
s(5, 1, 1)
split(x) {1: A | 1: NIL | 1: B | 1: NIL | 1: C}
A --> color("red")
B --> color("green")
C --> color("blue")
t(-4.5, 0, 0.5)
r(0, 45, 0)
t(4.5, 0, -0.5)
(Also note that the translation to origin has 0.5 X & Z offsets, as lots are not centred on the world origin)
Hey! and thanks for playing with cgajs!
Yeah - the rotation is certainly annoying. It is however on purpose, since this is what the CGA reference dictates. Rotation by default is around the pivot, which is in the "bottom left" corner of each object: http://cehelp.esri.com/help/index.jsp?topic=/com.procedural.cityengine.help/html/manual/cga/shape_operations/cga_so_trans_coordinatesystems.html
What could be improved in my implementation though is to allow you to override the rotation center: https://esri.github.io/esri-cityengine-sdk/html/cgaref/cgareference/op_r.html
or implement setPivot
or any of the others ways of moving the pivot for each shape.
I'll have a look!