Files
Leenkx_Examples/script_camera_lerp/Sources/lnx/CameraTrait.hx
2026-05-06 17:52:45 -07:00

27 lines
514 B
Haxe

package lnx;
import iron.object.Object;
import iron.Scene;
import iron.math.Quat;
class CameraTrait extends iron.Trait {
var cube:Object;
public function new() {
super();
notifyOnInit(function() {
cube = Scene.active.getChild("Cube");
});
notifyOnUpdate(function() {
if(cube.transform.rot != object.transform.rot){
var newRot = new Quat().lerp(cube.transform.rot, object.transform.rot, 0.9);
object.transform.rot.setFrom(newRot);
object.transform.buildMatrix();
}
});
}
}