I want to fade objects in and out, and while setting an entity's OpacityComponent works, animating it doesn't seem to do anything.
In the following code the second sphere should fade out, but it keeps its initial opacity. On the other hand, the animation that changes its transform works. What am I doing wrong?
class ViewController: NSViewController {
override func loadView() {
let arView = ARView(frame: NSScreen.main!.frame)
let anchor = AnchorEntity(.world(transform: matrix_identity_float4x4))
arView.scene.addAnchor(anchor)
let sphere = ModelEntity(mesh: .generateSphere(radius: 0.5))
anchor.addChild(sphere)
sphere.components.set(OpacityComponent(opacity: 0.1))
let sphere2 = ModelEntity(mesh: .generateSphere(radius: 0.5))
sphere2.position = .init(x: 0.2, y: 0, z: 0)
anchor.addChild(sphere2)
sphere2.components.set(OpacityComponent(opacity: 0.1))
sphere.playAnimation(try! AnimationResource.makeActionAnimation(for: FromToByAction(to: 0, timing: .linear), duration: 1, bindTarget: .opacity))
sphere.playAnimation(try! AnimationResource.makeActionAnimation(for: FromToByAction(to: Transform(translation: SIMD3(x: 0.1, y: 0, z: 0)), timing: .linear), duration: 1, bindTarget: .transform))
view = arView
}
}
RealityKit
RSS for tagSimulate and render 3D content for use in your augmented reality apps using RealityKit.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I'm trying to convert my game from SceneKit to RealityKit. I noticed that even when the scene is static (nothing moves), RealityKit keeps using CPU. In SceneKit, CPU goes down to 0% with a static scene.
With this simplest of games, RealityKit keeps using about 65% CPU:
class ViewController: NSViewController {
override func loadView() {
view = ARView(frame: NSScreen.main!.frame)
}
}
Is this expected or a bug?
I created FB22125047.
I'm in the process of converting my SceneKit game to RealityKit. In SceneKit I used to be able to mark nodes as selected by setting SCNMaterial.emission with a custom color. I can do the same with PhysicallyBasedMaterial.emissiveColor, but I'd like to keep my entitities unaffected by the scene lights by using UnlitMaterial. In SceneKit I can set a category mask to indicate what light should affect what node, but there doesn't seem to be such a thing in RealityKit. So at the moment it seems like I have to choose between being able to mark an entity as selected, or having entities unaffected by lighting, but not both.
Is there some effect or component I can use to mark entities as selected by applying some coloring regardless of the material used?