You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

visionOS下RealityKit自定义System无法每帧更新问题求助

自定义RealityKit System在visionOS真机上无法持续每帧更新的问题

我发现为RealityKit/visionOS应用创建的自定义System并未如文档所述及常理预期那样每帧更新。它们仅在每次UI交互后运行一段时间就会“停滞”,仅在再次进行UI交互或用户大幅移动时才会重新触发更新。我原本认为这些System默认不应与UI绑定,因此对该问题原因感到困惑。

我通过模板项目复现了该问题,仅添加了一组非常简单的System。以下是用于旋转一对球体的核心System代码:

import RealityKit
import RealityKitContent
import SwiftUI

public struct RotationSystem: System {

    static let query = EntityQuery(where: .has(RealityKitContent.WobblyThingComponent.self))

    public init(scene: RealityKit.Scene) {
    }

    public func update(context: SceneUpdateContext) {
        
        print("system update, deltaTime: \(context.deltaTime)")
        
        let entities = context.scene.performQuery(Self.query).map({ $0 })

        for entity in entities {
            
            let newRotation = simd_quatf(angle: Float(context.deltaTime * 0.5), axis: [0, 1, 0]) * entity.transform.rotation
                    
            entity.transform.rotation = newRotation
        }
    }
}

WobblyThingComponent已附加到Reality Composer Pro中两个球体的父实体,System与组件均已在应用启动时按常规方式注册。

该System在模拟器中运行流畅,但在Xcode预览及Vision Pro真机中均无法正常工作(而真机正是核心测试目标)。

测试日志确认System并未频繁触发更新,可看到代表长时间停滞的超大deltaTime值:

system update, deltaTime: 0.2055550068616867
system update, deltaTime: 0.4999987483024597

我在Diaroma示例项目中未发现该问题,但将其与我的测试项目逐一对比后,仍无法找出导致差异的原因。

若有人能指出问题所在,我将万分感激——我已为此困扰多日。

环境信息

  • Xcode: Version 15.3 (15E204a)
  • visionOS: 1.1 和 1.1.1

内容的提问来源于stack exchange,提问作者Jason RT Bond

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 08:13:00