[英]Animating an SCNText in ARKit
I have an SCNText node displayed in the AR screen. 我在AR屏幕上显示了一个SCNText节点。 I am trying to animate it by using SCNAction property.
我正在尝试通过使用SCNAction属性为其设置动画。 But it is not working properly.
但是它不能正常工作。 Is there any other way to animate the node?
还有其他使节点动起来的方法吗?
Also if I want to insert an image in place of the text what should I do? 另外,如果我想插入图像代替文本,该怎么办? I know I can't add it as a geometry.
我知道我无法将其添加为几何。 So is there any other way?
那么还有其他办法吗?
Thank you 谢谢
func displayText() {
let textGeo = SCNText(string: "HELLO WORLD", extrusionDepth: 1.0)
textGeo.firstMaterial?.diffuse.contents = UIColor.black
let textNode = SCNNode(geometry: textGeo)
textNode.position = SCNVector3(0,0.1,-0.5)
textNode.scale = SCNVector3(0.002,0.002,0.002)
self.sceneView.scene.rootNode.addChildNode(textNode)
let action = SCNAction.fadeOpacity(by: 10.0, duration: 5.0)
textNode.runAction(action)
An SCNNode's opacity ranges from 0 to 1. As your node starts with an opacity of 1, fading the opacity by 10 will have no effect. SCNNode的不透明度范围为0到1。由于您的节点以不透明度1开始,因此将不透明度降低10不会产生任何影响。
If you want the node to fade out use a value of -1. 如果要使节点淡出,请使用值-1。
请在添加文本节点之前将文本节点的Opactiy设置为0,然后再以1.0而不是10.0的方式运行不透明度操作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.