API:
/**
* @en Inversely transform a point from world coordinate system to local coordinate system.
* @zh 逆向变换一个空间点,一般用于将世界坐标转换到本地坐标系中。
* @param out The result point in local coordinate system will be stored in this vector
* @param p A position in world coordinate system
*/
inverseTransformPoint(out: math.Vec3, p: math.Vec3): math.Vec3;
用途:
此时调用 inverseTransformPoint 函数:
start() {
let out = new Vec3();
console.log(this.node.inverseTransformPoint(out, new Vec3(340, 620)));
console.log(this.node.inverseTransformPoint(out, new Vec3(360, 640)));
console.log(this.node.inverseTransformPoint(out, new Vec3(380, 660)));
}
得到的结果是:
(-20,-20,0)
(0,0,0)
(20,20,0)