简体   繁体   中英

Create border or outline on ModelEntity?

How can I create a border/outline on a ModelEntity in RealityKit?

Something like this blue border in Reality Composer:

在此处输入图像描述

Such an outline could be rendered with faceCulling property:

import UIKit
import RealityKit

class ViewController: UIViewController {
    
    @IBOutlet var arView: ARView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        let scene = try! Experience2.loadScene()
        let scene2 = scene.clone(recursive: true)
        
        let outline = scene2.findEntity(named: "simpBld_root") as! ModelEntity
        outline.scale *= 1.02
        
        var material = PhysicallyBasedMaterial()
        material.emissiveColor.color = .white
        material.emissiveIntensity = 0.5
        material.faceCulling = .front
        outline.model?.materials[0] = material
        
        arView.scene.anchors.append(scene)
        arView.scene.anchors.append(scene2)
    }
}

在此处输入图像描述

PS

In your case, the name of a rook is:

.findEntity(named: "chess_rook_white_base_iconic_lod0")

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