forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
26
script_camera_lerp/Sources/lnx/CameraTrait.hx
Normal file
26
script_camera_lerp/Sources/lnx/CameraTrait.hx
Normal file
@ -0,0 +1,26 @@
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user