Just learned that inverse does not work if the transform has a scale or skew. Apparently, this is marked as a FIXME in the godot source code, and the function isn’t marked as deprecated.

Instead, you should always use affine_inverse, which does account for scale.

Transform3D Transform3D::inverse() const {
	// FIXME: this function assumes the basis is a rotation matrix, with no scaling.
	// Transform3D::affine_inverse can handle matrices with scaling, so GDScript should eventually use that.
	Transform3D ret = *this;
	ret.invert();
	return ret;
}

See: https://github.com/godotengine/godot/blob/13a0d6e9b253654f5cc2a44f3d0b3cae10440443/core/math/transform_3d.cpp#L52 See: https://github.com/godotengine/godot/issues/39433