Sam*_*ard 3 augmented-reality swift arkit realitykit reality-composer
我希望能够将在 Reality Composer 中创建的文件添加到 Swift Playground 中以进行测试。我也认为用作剧本的补充会很有趣。如何将 rcproject 添加到 Playground 中,例如 Apple 提供的场景“Box”的 Experience.rcproject?
您只能
.reality使用以下代码在 Playground 中读取 RC文件格式:
import Cocoa
import RealityKit
import PlaygroundSupport
let arView = ARView(frame: CGRect(x: 0, y: 0, width: 800, height: 200))
arView.environment.background = .color(.black)
let fileURL = Bundle.main.url(forResource: "main", withExtension: "reality")
let bowlingScene = try! Entity.load(contentsOf: fileURL!)
let anchor = AnchorEntity()
anchor.addChild(bowlingScene)
anchor.scale = [4,4,4]
anchor.position.y = -0.5
arView.scene.anchors.append(anchor)
PlaygroundPage.current.liveView = arView
Run Code Online (Sandbox Code Playgroud)
因此,提供一个
.playground带有main.reality场景的文件,使其嵌套。
| 归档时间: |
|
| 查看次数: |
498 次 |
| 最近记录: |