【发布时间】:2015-06-09 15:03:58
【问题描述】:
我创建了一个循环数组对象,没问题。
当我旋转时,中心似乎有一个正弦函数或高斯函数。
相机是z 60,结构半径是30。
初始视图,无伪影
向上旋转 90 度,无伪影
旋转 180 度,物体中心出现伪影
继续旋转,神器还在。
对象的代码在这里
class func Build(scene: SCNScene) -> SCNNode {
let radius: Double = 30.0
let numberOfStrands: Int = 24
//Create the base chromosomes.
let baseChromosome = SCNBox(width: 4.0, height: 24, length: 1.0, chamferRadius: 0.5)
let baseChromosomes = DNA.buildCircleOfObjects(baseChromosome, numberOfItems: numberOfStrands, radius: radius)
baseChromosomes.position = SCNVector3(x: 0, y: 0.5, z: 0)
return baseChromosomes
}
class func buildCircleOfObjects(_geometry: SCNGeometry, numberOfItems: Int, radius: Double) -> SCNNode {
var x: Double = 0.0
var z: Double = radius
let theta: Double = (M_PI) / Double(numberOfItems / 2)
let incrementalY: Double = (M_PI) / Double(numberOfItems) * 2
let nodeCollection = SCNNode()
nodeCollection.position = SCNVector3(x: 0, y: 0.5, z: 0)
for index in 1...numberOfItems {
x = radius * sin(Double(index) * theta)
z = radius * cos(Double(index) * theta)
let node = SCNNode(geometry: _geometry)
node.position = SCNVector3(x: Float(x), y: 0, z:Float(z))
let rotation = Float(incrementalY) * Float(index)
node.rotation = SCNVector4(x: 0, y: 1, z: 0, w: rotation)
nodeCollection.addChildNode(node)
}
return nodeCollection
}
}
【问题讨论】:
-
我不是 scenekit pro,但是对于 30 的半径,如果相机 z 定义了对象必须移动的空间,我认为 60 不足以高度非零的圆柱体。如果您使用更大的相机 z(或更小半径)会发生什么?
-
我认为你是对的,它是 xFov、yFov、zNear、zFar 的组合......最初我认为可能是一种奇怪的剔除效果。
-
这些设置终于奏效了
cameraNode.camera?.xFov = 60 cameraNode.camera?.yFov = 60 cameraNode.camera?.zFar = 1000 cameraNode.camera?.zNear = 0.01