首页 > 解决方案 > 如何用lefteyetransform ARKit2移动圆圈

问题描述

我正在尝试开发一个根据左眼移动圆圈的游戏

        let screenSize = UIScreen.main.bounds
        let  screenWidth = screenSize.width
        let screenHeight = screenSize.height
        let    camera = self.sceneView.session.currentFrame?.camera
        let pippo = simd_mul((anchor.transform),faceAnchor.leftEyeTransform)
        var j: SCNVector3 = SCNVector3(pippo.columns.3.x ,pippo.columns.3.y , -pippo.columns.3.z);
        self.circlePath = UIBezierPath(arcCenter: CGPoint(x: CGFloat(   j.x * Float(screenHeight/2) ),y:CGFloat(  j.y * Float(screenWidth/2) )), radius: CGFloat(20), startAngle: CGFloat(0), endAngle:CGFloat(Double.pi * 2), clockwise: true)
        self.shapeLayer = CAShapeLayer()
        self.shapeLayer.path = self.circlePath.cgPath
        self.shapeLayer.fillColor = UIColor.clear.cgColor
        self.shapeLayer.strokeColor = UIColor.red.cgColor
        self.shapeLayer.lineWidth = 3.0
        self.view.layer.addSublayer(self.shapeLayer)

我移动了一点圆圈,但它以屏幕的最左侧为中心(而不是在中间)并且移动并没有覆盖整个屏幕,而只是其中的一部分,我该如何解决?提前致谢。

标签: swiftarkit

解决方案


推荐阅读