Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 使用几何图形放置SCNNode_Ios_Swift_Scenekit_Arkit - Fatal编程技术网

Ios 使用几何图形放置SCNNode

Ios 使用几何图形放置SCNNode,ios,swift,scenekit,arkit,Ios,Swift,Scenekit,Arkit,我正在创建一个长方体以放置在我的AR场景中,代码如下: let box = SCNBox(width: side, height: side, length: side, chamferRadius: 0.008) box.firstMaterial?.diffuse.contents = UIColor(red: 220/255, green: 65/255, blue: 23/255, alpha: 0.6) box.firstMaterial?.diffuse.contents = UII

我正在创建一个长方体以放置在我的AR场景中,代码如下:

let box = SCNBox(width: side, height: side, length: side, chamferRadius: 0.008)
box.firstMaterial?.diffuse.contents = UIColor(red: 220/255, green: 65/255, blue: 23/255, alpha: 0.6)
box.firstMaterial?.diffuse.contents = UIImage(named:"test1")!
let nodo = SCNNode(geometry: box)
nodo.position = position
我想弄明白的是如何使盒子在屏幕大小(图像空间)中保持恒定大小

我希望将长方体节点放置在3D场景中,使其始终看起来大小相同,比如30x30像素

所以,当我在移动手机的ARKit摄像头周围移动时,无论我离盒子有多远或多近,我都希望盒子在视口中始终在屏幕上显示相同的大小


如何实现这一点?

如果您需要将对象设置为3D,解决方案是使用对象与摄影机之间的距离,在每一帧中对其进行缩放。有一个


如果需要二维平面,可以使用
UIKit
放置该平面,并通过将三维点投影到二维系统并使用这些值作为视图的坐标,每帧更新其位置。()

非常好。我没有看到这个问题,我会先尝试解决这个问题,看看事情是如何发展的。