简体   繁体   English

在SceneKit中为对象着色等于什么?

[英]What is the equivalent of colorizing an object in SceneKit?

How can I animate a change in color of an SCNNode ? 如何设置SCNNode颜色的变化动画? In SpriteKit I would just use the colorizeWithColor SKAction , but that is not an option in SceneKit . SpriteKit我只使用colorizeWithColor SKAction ,但这不是SceneKit的选项。 In SpriteKit , I would typically have a collision between two nodes. SpriteKit ,我通常会在两个节点之间发生冲突。 When the nodes collided one of the nodes changed colors simply by running the colorizeWithColor SKAction . 当节点冲突时,只需运行colorizeWithColor SKAction即可更改其中一个节点的颜色。 What's the equivalent of this in SceneKit for an SCNNode ? SceneKitSCNNode的等效功能是什么?

You can use the multiply property of your material to achieve a similar effect. 您可以使用材质的multiply属性来达到类似的效果。 You can set the fade length with SCNTransaction 's animationDuration property. 您可以使用SCNTransactionanimationDuration属性设置淡入淡出的长度。

SCNTransaction.begin()
SCNTransaction.animationDuration = yourFadeDuration
geometry?.firstMaterial?.multiply.contents = yourDesiredColor
SCNTransaction.commit()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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