0

I have a custom dae file and am wanting to scale it down to fit in some areas, what I have found, unfortunately, is that if the scaling factor falls below .65, the node isn't rendered for some reason. I'm not sure what I am doing wrong. Here is the code I am currently using.

func logoPanel(height: CGFloat, width: CGFloat) -> SCNNode {
    let nodeCollection = SCNNode()

    var v1 = SCNVector3(x:0, y:0, z:0)
    var v2 = SCNVector3(x:0, y:0, z:0)
    let logoNode = collada2SCNNode(Double(height))
    let padding = 0.3

    logoNode.getBoundingBoxMin(&v1, max:&v2)
    if Double(v2.y - v1.y) + padding > (Double(height) - (radius*2)) / 2 {
        // scale logo node down
        let scaleFactor = Float(((Double(height) - (radius*2)) / 2) / (Double(v2.y - v1.y) + padding))
        logoNode.transform = SCNMatrix4MakeScale(scaleFactor, scaleFactor, scaleFactor)
        logoNode.position = SCNVector3Make(0, Float((-height/2.0) + 0.1), 0)
    }

    nodeCollection.addChildNode(logoNode)

    return nodeCollection
}
Ian Oswald
  • 1,365
  • 3
  • 16
  • 27

0 Answers0