swift - 如何缩放 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)
如何获得它相对于我想要放入的文字框的大小并对其进行缩放?是否可以将节点绘制到屏幕外以测量其大小?
解决方案
推荐阅读
- java - 在每个 Switch-case 后提示用户打印,除了 case:“0 exit”
- python-3.x - 编译的 Python 函数 Executable 不是单个文件并且不运行
- r - 在 df2 中识别 df1 中的元素,然后在 df2 中使用 R 重合的那些行中添加列
- laravel - Laravel Socialite Github 提供商电子邮件为空
- javascript - 动态更改占位符文本
- java - 将场景从一个包切换到另一个包 javafx
- c++ - 需要对使用 BST 的电话簿上的 c++ 项目进行一些澄清
- angular - 模块错误(来自 ./node_modules/postcss-loader/src/index.js):(发出的值而不是错误的实例)CssSyntaxError
- spring-boot - 从 Spring Boot 发送带有 logback 的无代理日志时,如何为 datadog 定义源标签?
- excel - 如何根据 2 张纸计算行数