【问题标题】:How to add SCNNode runtime on ARSCNView?如何在 ARSCNView 上添加 SCNNode 运行时?
【发布时间】:2019-01-29 11:19:46
【问题描述】:

我必须使用 ARKit 将 SCNNode(可以通过点击事件检测到)添加到 ARSCNView。

现在,我面临的挑战是我必须在检测到的对象旁边动态地在 ARSCNView 上添加多个带有动画的 SCNNode。

目前,我已经在“Scene.scn”上手动添加了 SCNNode,如下图所示,

提前感谢您的帮助。

【问题讨论】:

    标签: ios swift swift4 arkit ios12


    【解决方案1】:
    class SphereNode : SCNNode {
        private var geo:SCNSphere!
    
        private  override init () {
            super.init()
        }
    
        convenience init(withPosition position:SCNVector3,color:UIColor) {
            self.init()
            geo = SCNSphere(radius: 0.007)
            self.geometry = geo
            self.geo.firstMaterial?.diffuse.contents = color
            self.position = position
    
            self.name = NodeNames.pointNode
    
        }
    
        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }
    
    }
    

    现在创建它的对象

    let measureNode = SphereNode(withPosition: yourPosition,color:.red)
    measureNode.name = "AnyName"
    

    添加它

    self.sceneView.scene.rootNode.addChildNode(measureNode)
    

    【讨论】:

    • 感谢您的支持,我们可以在节点内添加 webview 吗?
    • @VanditMehta 我不知道是否可以将整个 webview 添加到节点,但是您可以在完成后截取 webview 的屏幕截图图像并将其作为扩散内容添加到 scnnode
    猜你喜欢
    • 2021-06-25
    • 2018-03-28
    • 2020-10-04
    • 2018-07-21
    • 2019-09-20
    • 2018-09-11
    • 2021-08-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多