首页 > 解决方案 > 如何缩放 SCNNodes 以适应盒子?

问题描述

我有多个 collada 文件,其中包含从不同的 3D 程序源创建的各种大小的对象(人类)。我希望缩放对象,使它们适合框架或盒子。根据我的阅读,我不能使用边界框来缩放节点,那么您使用什么功能来缩放节点,相对于彼此?

// humanNode = {...get node, which is some unknown size }

let (minBound, maxBound) = humanNode.boundingBox

let blockNode = SCNNode(geometry: SCNBox(width: 10, height: 10, length: 10, chamferRadius: 0))

// calculate scale factor so it fits inside of box without having known its size before hand.

s = { ...some method to calculate the scale to fit the humanNode into the box }

humanNode.scale = SCNVector3Make(s, s, s)

如何获得它相对于我想要放入的文字框的大小并对其进行缩放?是否可以将节点绘制到屏幕外以测量其大小?

标签: swiftscenekit

解决方案


推荐阅读