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)