简体   繁体   中英

Animating an SCNText in ARKit

I have an SCNText node displayed in the AR screen. I am trying to animate it by using SCNAction property. 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.

If you want the node to fade out use a value of -1.

请在添加文本节点之前将文本节点的Opactiy设置为0,然后再以1.0而不是10.0的方式运行不透明度操作

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM