我有以下内容SCNNode
:
let box = SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 0) let boxNode = SCNNode(geometry: box) boxNode.position = SCNVector3(x: 0, y: 0, z: 0)
如果我申请:
boxNode.scale = SCNVector3(x: 0.5, y: 0.5, z: 0.5)
它似乎对盒子的大小没有影响.我已经检查了这个boxNode.getBoundingBoxMin(&v1, max: &v2)
.它始终是相同的,并在屏幕上显示相同.
我错过了什么吗?文档暗示设置比例应该影响节点的几何形状,因此是不同的大小.
谢谢.J.
我只是在操场上测试过,它对我来说很有效.也许您的相机正在放大以补偿较小的盒子?
import SceneKit import SpriteKit import XCPlayground let sceneView = SCNView(frame: CGRect(x: 0, y: 0, width: 800, height: 600)) XCPlaygroundPage.currentPage.liveView = sceneView var scene = SCNScene() sceneView.scene = scene sceneView.backgroundColor = SKColor.greenColor() sceneView.debugOptions = .ShowWireframe // default lighting sceneView.autoenablesDefaultLighting = true // a camera var cameraNode = SCNNode() cameraNode.camera = SCNCamera() cameraNode.position = SCNVector3(x: 15, y: 15, z: 30) scene.rootNode.addChildNode(cameraNode) let box = SCNBox(width: 10.0, height: 10.0, length: 10.0, chamferRadius: 0) let boxNode = SCNNode(geometry: box) boxNode.position = SCNVector3(x: 0, y: 0, z: 0) scene.rootNode.addChildNode(boxNode) let centerConstraint = SCNLookAtConstraint(target: boxNode) cameraNode.constraints = [centerConstraint] let sphere = SCNSphere(radius: 4) let sphereNode = SCNNode(geometry: sphere) sphereNode.position = SCNVector3(x:15, y:0, z:0) scene.rootNode.addChildNode(sphereNode) //boxNode.scale = SCNVector3(x: 0.5, y: 0.5, z: 0.5)
取消注释最后一行,您将看到框(10 x 10 x 10)开关开关从大于球体(直径8)到小于球体.这是在缩放之后: