坐标转换问题

3d摄像机坐标转换怎么搞啊,数学不好,源码没理明白
cocos creator 2.3.1
`const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
start() {
const cam = this.addComponent(cc.Camera)
this.node.is3DNode = true
cam.ortho = false
cam.alignWithScreen
this.node.setWorldPosition(cc.v3(0, 0, -5))
const node = new cc.Node()
node.is3DNode = true
node.setWorldPosition(cc.v3(1, 1, 0))
const worldPos = cc.v3()
node.getWorldPosition(worldPos)
const screenPos = cam.getWorldToScreenPoint(worldPos)
const pos = cam.getScreenToWorldPoint(screenPos)
if (!pos.equals(worldPos)) {
console.log(’???’, worldPos.toString(), pos.toString());
//??? (1.00, 1.00, 0.00) (-816.14, -816.14, -4085.68)
}
}
}`

先凑合一下。。。
`const { ccclass, property } = cc._decorator;

@ccclass
export default class Drag3dObj extends cc.Component {

@property(cc.Node)
target: cc.Node = null;

@property(cc.Camera)
cam: cc.Camera = null;

onEnable() {
    this.node.on(cc.Node.EventType.TOUCH_START, this.onTouchMove, this)
    this.node.on(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)

    let targetpos = cc.v3()
    this.target.getWorldPosition(targetpos)

    const camPos = cc.v3()
    this.cam.node.getWorldPosition(camPos)
    const camRot = cc.quat()
    this.cam.node.getWorldRotation(camRot)
    const f = cc.v3()
    cc.Vec3.transformQuat(f, cc.Vec3.FRONT, camRot)
    this.dis = targetpos.sub(camPos).project(f).mag()
}
onDisable() {
    this.node.off(cc.Node.EventType.TOUCH_START, this.onTouchMove, this)
    this.node.off(cc.Node.EventType.TOUCH_MOVE, this.onTouchMove, this)
}
dis: number = 10
onTouchMove(event: cc.Event.EventTouch) {
    const epos = event.getLocation()
    const size = cc.view.getVisibleSize()
    epos.x = epos.x - size.width / 2
    epos.y = epos.y - size.height / 2



    const camPos = cc.v3()
    this.cam.node.getWorldPosition(camPos)
    const camRot = cc.quat()
    this.cam.node.getWorldRotation(camRot)

    const f = cc.v3()
    cc.Vec3.transformQuat(f, cc.v3(0, 0, -1), camRot)
    const r = cc.v3()
    cc.Vec3.transformQuat(r, cc.Vec3.RIGHT, camRot)
    const u = cc.v3()
    cc.Vec3.transformQuat(u, cc.Vec3.UP, camRot)


    const h = this.dis * Math.tan(Math.PI / (180 / this.cam.fov * 2)) * 2
    const w = h * size.width / size.height

    const targetpos = camPos.add(f.mul(this.dis)).add(u.mul(epos.y / size.height * h)).add(r.mul(epos.x / size.width * w))

    this.target.setWorldPosition(targetpos)
}

}

`