【发布时间】:2019-03-07 19:19:48
【问题描述】:
这似乎是一种奇怪的行为,但我想知道是否有办法让屏幕上的节点无论离相机多远都具有相同大小?
我正在尝试在城市中显示 2D 元素(只是文本和图像),其中一些可能很远,但我仍然希望文本和图像可见,但我也不希望它看起来当我离它太近时,它是巨大的。
我目前正在使用 Apple SpriteKit 示例:
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?)
{
guard let sceneView = self.view as? ARSKView else
{
return
}
// Create anchor using the camera's current position
if let currentFrame = sceneView.session.currentFrame
{
// Create a transform with a translation of 0.2 meters in front of the camera
var translation = matrix_identity_float4x4
translation.columns.3.z = -0.2
let transform = simd_mul(currentFrame.camera.transform, translation)
// Add a new anchor to the session
let anchor = ARAnchor(transform: transform)
sceneView.session.add(anchor: anchor)
}
}
【问题讨论】:
-
您能否在场景顶部叠加另一个视图,也许?或者在相机上附加一个平面(而不仅仅是添加对象时相机的位置)?
-
对不起,我不确定你的意思是什么?那会有什么帮助?我刚开始使用 ARKit,所以我有点挣扎......
-
我也没有做过太多的 ARKit,我只是使用了一点 Blender。 (:我的意思是,在相机前面放置一个平面但附加到它,所以当你在平面周围移动相机时,它会随之移动。在 Blender 中,这被称为“父母”,SceneKit 可能会或可能不会叫它别的东西。
标签: ios swift sprite-kit arkit