最佳答案
您可以添加一个 SCNPlane
并使用 SCNLookAtConstraint
以便飞机始终注视着相机。
您可以创建自定义 Material 并将其设置为 material properties到:
A color (UIColor or CGColor), specifying a constant color across the material’s surface A number (
An image (UIImage or CGImage), specifying a texture to be mapped across the material’s surface
- A Core Animation layer (CALayer)
- A texture (SKTexture, MDLTexture, MTLTexture, or GLKTextureInfo)
- A SpriteKit scene (SKScene)
您也可以使用 CoreAnimation 或 SpriteKit 显示动画内容,但是
SceneKit cannot use a layer that is already being displayed elsewhere (for example, the backing layer of a UIView object)
这是一个使用 SpriteKit 的例子:
- 创建您的 SpriteKit 场景:
例如:
let skScene = SKScene(size: CGSize(width: 200, height: 200))
skScene.backgroundColor = UIColor.clear
let rectangle = SKShapeNode(rect: CGRect(x: 0, y: 0, width: 200, height: 200), cornerRadius: 10)
rectangle.fillColor = #colorLiteral(red: 0.807843148708344, green: 0.0274509806185961, blue: 0.333333343267441, alpha: 1.0)
rectangle.strokeColor = #colorLiteral(red: 0.439215689897537, green: 0.0117647061124444, blue: 0.192156866192818, alpha: 1.0)
rectangle.lineWidth = 5
rectangle.alpha = 0.4
let labelNode = SKLabelNode(text: "Hello World")
labelNode.fontSize = 20
labelNode.fontName = "San Fransisco"
labelNode.position = CGPoint(x:100,y:100)
skScene.addChild(rectangle)
skScene.addChild(labelNode)
- 创建您的平面并将场景设置为您的 Material 属性
例如
let plane = SCNPlane(width: 20, height: 20)
let material = SCNMaterial()
material.isDoubleSided = true
material.diffuse.contents = skScene
plane.materials = [material]
let node = SCNNode(geometry: plane)
scene.rootNode.addChildNode(node)
- 让你的场景动起来
例如
labelNode.run(SKAction.repeatForever(SKAction.rotate(byAngle: .pi, duration: 2)))
关于ios - 我如何在 ARkit 场景 iOS 中添加具有文本的 2dView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45317366/