[英]In ARKit, what are the plane detection delegate methods in ARSKViewDelegate?
[英]How do I render a jpg image using ARKit ARSKViewDelegate?
我想将jpg图像渲染为漂浮在空间中的2d矩形。 使用SpriteKit示例 - 如何从ARSKViewDelegate
返回jpg图像?
该演示返回一个SKLabelNode
- 是否有一个Node类适合我将从网络中获取的jpg图像,可能是UIImage
?
func view(_ view: ARSKView, nodeFor anchor: ARAnchor) -> SKNode? {
// Create and configure a node for the anchor added to the view's session.
let labelNode = SKLabelNode(text: "👾")
labelNode.horizontalAlignmentMode = .center
labelNode.verticalAlignmentMode = .center
return labelNode;
}
您可以使用SCNPlane
并将UIImage
指定为该平面的内容。
let imagePlane = SCNPlane(width: sceneView.bounds.width/6000, height: sceneView.bounds.height/6000)
imagePlane.firstMaterial?.diffuse.contents = //<-- UIImage here
imagePlane.firstMaterial?.lightingModel = .constant
let planeNode = SCNNode(geometry: imagePlane)
更新:现在我注意到你正在使用SpriteKit。 我共享的代码是使用SceneKit。
看起来我可以使用SKSpriteNode
中的SKTexture
。 唯一的问题是我在日志中看到有关性能下降的警告。 [Technique] World tracking performance is being affected by resource constraints [1]
let url = URL(string: imageURL)
let data = try? Data(contentsOf: url!) //make sure your image in this url does exist, otherwise unwrap in a if let check
let theImage = UIImage(data: data!)
let Texture = SKTexture(image: theImage!)
return SKSpriteNode(texture: Texture)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.