ios - ARKit 中访问节点名称

标签 ios swift arkit

我正在尝试从以下内容中检索 string=Gate。

<SCNHitTestResult: 0x1c4016dc0 <0.167996,0.067400,-0.095000> | geometryIndex=0 node=<SCNNode: 0x1c43e1100 'test' pos(0.000000 0.000000 -0.100000) scale(0.010000 0.010000 0.010000) | geometry=<SCNText: 0x1c43e0e00 | 3 elements | string=Gate extrusionDepth=1.000>  | no child> bone=(null)>

MyCode 访问几何并且工作正常,如下

let hitResults: [SCNHitTestResult] = sceneView.hitTest(location, options: hitTestOptions)
if let hit = hitResults.first { 
   print(hit.node.geometry) 
}

I already have tried this hit.node.geometry?.name but this returns nil

最佳答案

我刚刚解决了这个问题

node.name = "test"
if(hit.node.name == "test") { // Do Something } 

关于ios - ARKit 中访问节点名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48414093/

相关文章:

ios - 当应用程序在后台时向服务器发送数据

ios - 设置回原来的ui布局约束——放大动画

ios - 从 [Message] 到 [Message] 的条件转换总是成功

swift - 二元运算符 '+' 不能应用于类型 'Int' 和 '[Int]' 的操作数

ios - 使用 SceneKit 在 ARKit 中绘制楔形

ios - 获取有关 ARKit 中捏合手势的详细信息

ios - 强制其他应用在 iOS 中释放麦克风

ios - 为什么 [SomeClass class] 可以在 main.m 中返回 null

swift - 从一个结构转换为另一个

swift - 为什么在使用 ARSCNView 关闭 ViewController 时 UI 会卡住?