这似乎是一种奇怪的行为,但我想知道是否有一种方法可以让节点在屏幕上具有相同的大小,无论它离相机有多远?
我正在尝试在城市中显示二维元素(只是一个文本和一个图像),其中一些可能很远,但我仍然希望文本和图像可见,但我也不希望它看起来当我离它太近时会变得巨大。
我目前正在使用 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)
}
}
最佳答案
您可以测量 pointOfView 和目标节点之间的距离。您可以使用比例属性相应地测量目标节点
关于ios - 控制缩放行为 ARKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52612153/