forked from LeenkxTeam/Leenkx_Examples
update
This commit is contained in:
45
script_transform/Sources/lnx/TransformTest.hx
Normal file
45
script_transform/Sources/lnx/TransformTest.hx
Normal file
@ -0,0 +1,45 @@
|
||||
package lnx;
|
||||
|
||||
class TransformTest extends iron.Trait {
|
||||
public function new() {
|
||||
super();
|
||||
|
||||
notifyOnInit(function() {
|
||||
|
||||
trace('Testing 2 cubes, parent cube at (1, 0, 0), child cube at (5, 0, 0)');
|
||||
|
||||
trace('Parent location: ' + object.parent.transform.loc);
|
||||
// (1, 0, 0)
|
||||
|
||||
trace('Child location: ' + object.transform.loc);
|
||||
// (5, 0, 0)
|
||||
|
||||
trace('Child location in world space: ' + object.transform.world.getLoc());
|
||||
// (6, 0, 0)
|
||||
|
||||
trace('Setting child to parent location …');
|
||||
object.transform.loc.set(0, 0, 0);
|
||||
object.transform.buildMatrix();
|
||||
|
||||
trace('Child location: ' + object.transform.loc);
|
||||
// (0, 0, 0)
|
||||
|
||||
trace('Child location in world space: ' + object.transform.world.getLoc());
|
||||
// (1, 0, 0)
|
||||
|
||||
trace('Moving parent …');
|
||||
object.parent.transform.loc.set(0, 3, 0);
|
||||
object.parent.transform.buildMatrix();
|
||||
|
||||
trace('Child location: ' + object.transform.loc);
|
||||
// (0, 0, 0)
|
||||
|
||||
trace('Child location in world space: ' + object.transform.world.getLoc());
|
||||
// (0, 3, 0)
|
||||
|
||||
// Note: In Blender, you may need to:
|
||||
// - Clear Parent - Clear Parent Inverse
|
||||
// - To get local transform
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user