ios - 如何确保不相对于相机移动 SCN 节点
问题描述
我在 SCN 场景中创建了点、线、文本等视图实体。但是一旦创建,如果我移动我的相机,即使这些实体也会相对于相机移动。
我想将这些实体(例如,SCN 节点)保持在相同的位置(我在创建它们时使用的坐标)。
例如,我正在使用下面的函数来创建一个点。
// add dot node with given position
func nodeWithPosition(_ position: SCNVector3) -> SCNNode {
// create sphere geometry with radius
let sphere = SCNSphere(radius: 0.01)
// set color
sphere.firstMaterial?.diffuse.contents = UIColor(red: 255/255.0,
green: 153/255.0,
blue: 83/255.0,
alpha: 1)
// set lighting model
sphere.firstMaterial?.lightingModel = .constant
sphere.firstMaterial?.isDoubleSided = true
// create node with 'sphere' geometry
let node = SCNNode(geometry: sphere)
node.position = position
return node
}
上面的函数可以这样使用:
let node = self.nodeWithPosition(position)
sceneView.scene.rootNode.addChildNode(node)
如果有人可以帮助我,我会非常高兴。
解决方案
推荐阅读
- javascript - Node.js vm:如何通过外部事件终止脚本(不使用超时)?
- c# - jQuery Datatables json AJAX 帮助请“表中没有可用数据”
- node.js - NodeJs - 从带有原始数据的 Node Js 应用程序对 Zebra 打印机进行 Rest 调用
- yii2 - 如何在名称中进行验证,我只想在此字段中填写字母
- python - 在 python 中合并多个 JSON 或输出单个 JSON 文件
- c# - 单个数据库中每个租户从 1 开始的自动增量 ID
- c# - /global.asax(1): error ASPPARSE: Could not load type
- javascript - 如何重置角度4中的复选框
- makefile - Makefile for loop - 变量永远不会被设置
- riscv - 向 RISCV-32ima 添加新指令:“bad RISCV-opcode”