小编use*_*393的帖子

在 Reality Composer 生成的场景中以编程方式设置纹理

我正在使用 Reality Composer 创建一个圆柱体对象。我的要求是用自定义图像包裹圆柱体。图像由应用程序动态创建。

我尝试了以下方法,但到目前为止它不起作用。

    1. 从 Experience 加载锚点后。
    1. 从锚点获取模型实体。
    1. 从模型实体中获取模型组件。
    1. 添加或编辑材料。

代码:

// Load the "anchor" scene from the "Experience" Reality File
let anchor = try! Experience.loadAnchor()

// Add the anchor to the scene
arView.scene.anchors.append(anchor)

let cylinderEntity : Entity = anchor.cylinder!

let cylinderModelEntity = cylinderEntity.children[0]

var cylinderModelComponent : ModelComponent = cylinderModelEntity.components[ModelComponent.self]!

let paths : NSArray = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) as NSArray
let path : NSString = paths.object(at: 0) as! NSString
let filePath : NSString = path.strings(byAppendingPaths: ["Image.png"])[0] as NSString
let …
Run Code Online (Sandbox Code Playgroud)

augmented-reality swift arkit realitykit reality-composer

1
推荐指数
1
解决办法
740
查看次数