SceneKit material 被随机模式填充,为什么?

SceneKit material being filled with random patterns, why?

我有一个简单的触摸检测方法,可以改变被触摸节点的颜色。

override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
    super.touchesBegan(touches, withEvent: event)

    let touch = touches.first as! UITouch
    let point = touch.locationInView(view)

    let options: [NSObject : AnyObject] = [
        SCNHitTestFirstFoundOnlyKey: NSNumber(bool: true),
        SCNHitTestSortResultsKey: NSNumber(bool: true)
    ]

    if let results = sceneView.hitTest(point, options: options) as? [SCNHitTestResult] {
        if let result = results.first {
            // Red color material
            let material = SCNMaterial()
            material.diffuse.contents = UIColor.redColor()

            // Assign it to the node
            result.node.geometry?.firstMaterial = material
        }
    }
}

我的节点层次结构包含一个使用自定义 SCNGeometry 制作的节点和 8 个具有常规 SCNBox 几何形状的节点。

let boxGeometry = SCNBox(width: 1, height: 1, length: 1, chamferRadius: 0)
let boxNode = SCNNode(geometry: boxGeometry)
boxNode.position = SCNVector3(x: vector.x, y: vector.y, z: vector.z)

下面是触摸框后颜色如何变化的几个屏幕截图。图案在每次旋转时闪烁和变化。

这种奇怪的颜色模式是什么原因造成的?我只想让它保持纯色。

在我看来你有两个节点在彼此内部 - 框的数量与你在问题中指定的数量不相加。