I wan't to get transform of Position3D relative to grandparent, but not global. Currently I am doing this:
func moveNode(node, from, to):
var temp_transform = node.global_transform
from.remove_child(node)
to.add_child(node)
node.transform = temp_transform
But I need node
transform relative to the parent of from
and to
, not global_transform
, since node
grandparent is scaled.
In three.js I was doing this in following way:
moveNode(node, from, to) {
from.updateMatrixWorld();
to.updateMatrixWorld();
node.applyMatrix(from.matrixWorld)
from.remove(piece)
node.applyMatrix(new THREE.Matrix4().getInverse(to.matrixWorld))
to.add(piece)
}
But I can't find equivalent of applyMatrix
and getInverse
in Godot.