I didn’t read through all your code. Maybe you could accomplish this with a ‘tween’ library? For Processing, there’s Ani. I don’t think it supports 3D, but it might adapt okay –
add_library('Ani')
import jycessing.primitives.PrimitiveFloat as Float
y_rot = Float(0.0)
def setup():
size(500, 500, P3D)
Ani.init(this)
def draw():
background(200)
translate(width/2, height/2, 0)
rotateY(y_rot.value)
box(100)
def mouseReleased():
# rotate box to 0° when pointer clicked at left edge,
# and to 360° (τ rad) for pointer click at right edge
rad = map(mouseX, 0, width, 0, TAU)
Ani.to(y_rot, 1, 'value', rad)
print(degrees(rad))
In the Ani.to(y_rot, 1, 'value', rad)
line –
- the y_rot is your current rotation value
- rad is the new/target y_rot value
- 1 is the number of seconds to animate between y_rot and rad
Because of some Python-to-Java wierdness, you have to use jycessing.primitives.PrimitiveFloat
for your Ani variables – hence the Float()
to define y_rot
, and accessing it with y_rot.value
.