1
我在同一地点的项目中有2个球体。 firstSphere较小,tempSphere较大。如何比较场景套件中两个球体的大小?
编辑: 第一个图形会比tempShape大。当我停下,我想测试就像firstShape“如果firstShape.scale == tempShape.scale”
//Create Shape
let firstShapeGeo = SCNSphere(radius: shapeRadius)
firstShape.geometry = firstShapeGeo
let shapeMaterial = SCNMaterial()
shapeMaterial.diffuse.contents = UIColor(colorLiteralRed: 0.2, green: 0.8, blue: 0.9, alpha: 1.0)
firstShapeGeo.materials = [shapeMaterial]
firstShape.position = SCNVector3Make(0, 0, 0)
scene.rootNode.addChildNode(firstShape)
firstShape.name = "\(shapeNumber)"
// Create Temp Shape
tempShapeRadius = shapeRadius + 1.0
let tempShapeGeo = SCNSphere(radius: tempShapeRadius)
tempShape.geometry = tempShapeGeo
let tempShapeMaterial = SCNMaterial()
tempShapeMaterial.diffuse.contents = UIColor(colorLiteralRed: 0.2, green: 0.8, blue: 0.9, alpha: 0.5)
tempShapeGeo.materials = [tempShapeMaterial]
firstShape.position = SCNVector3Make(0, 0, 0)
scene.rootNode.addChildNode(tempShape)
这就是我正在变的firstSphere
let grow = SCNAction.scale(to: tempShapeRadius * 2 + 1, duration: 1)
let shrink = SCNAction.scale(to: tempShapeRadius, duration: 1)
let sequence = SCNAction.sequence([grow, shrink])
firstShape.run(SCNAction.repeatForever(sequence))
较小的范围越来越大通过使用SCNAction.scale
更大,所以我不相信半径实际上在变化。不知道这是否是你需要知道的。
任何帮助将不胜感激!谢谢!
你能举一个如何比较尺度的例子。我先试着比较尺度,但我似乎不断收到错误。 –
它内置于代码片段中。 “成长”会缩放'firstShape',直到'tempShape'的大小,然后回落到'1',这是原始值。 – bpedit
我很抱歉,我不清楚这个问题。第一个图形将比tempShape稍大。我试图测试像'如果firstShape.scale == tempShape.scale'我会更新我想我看到的问题 –