更改对象的颜色 [英] Change a colour of an object

查看:39
本文介绍了更改对象的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在研究如何从 Swift 转换对象颜色的选项.该对象已从 Reality Composer 添加到场景中.

我在

I am currently looking into options on how to transform objects colour from Swift. The object has been added to the scene from Reality Composer.

I found in the documentation that I can change position, rotation, scale, however, I am unable to find a way how to change colour.

解决方案

Use the following code to change a colour of box model (found in Xcode template):

let boxScene = try! Experience.loadBox()

let modelEntity = boxScene.steelBox!.children[0] as! ModelEntity

var material = SimpleMaterial()
material.baseColor = .color(.green)
modelEntity.model?.materials = [material]

arView.scene.anchors.append(boxScene)

print(boxScene)

Downcast to ModelEntity is necessary for accessing model's components:

这篇关于更改对象的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆