【问题标题】:SceneKit didApplyAnimationsAtTime calculation timeSceneKit didApplyAnimationsAtTime 计算时间
【发布时间】:2020-01-24 18:15:53
【问题描述】:

您好,我正在尝试计算渲染器运行动作和动画所需的时间。 据我了解:https://developer.apple.com/documentation/scenekit/scnscenerendererdelegate

rendererDiDSomething 中的 time 属性:如果您的游戏需要时间在屏幕上渲染,则每个回调中的时间应该不同。

我有一个带有操纵动画的复杂场景,我可以使用 SceneView 统计信息看到动画每帧占用了很多时间。但是当我检查回调中的时间属性时,它们都是一样的。 我还尝试计算帧之间的时间差,它总是 0.0

我在这里缺少什么?

片段说明:

func renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval) {
    print(time)
}

func renderer(_ renderer: SCNSceneRenderer, didApplyAnimationsAtTime time: TimeInterval) {
    print(time)
}

func renderer(_ renderer: SCNSceneRenderer, didRenderScene scene: SCNScene, atTime time: TimeInterval) {
    print(time)
}

谢谢!

【问题讨论】:

    标签: swift scenekit augmented-reality arkit


    【解决方案1】:

    我认为所有具有 time 参数的 SceneKit 的 renderer() 实例方法都向我们展示了相同的值,因为这次是由 Double 类的 TimeInterval 类型别名提供的系统时间(以秒和毫秒表示) .

    似乎我们无法在这个 API 中找出渲染循环中的 子帧时间 是什么,比如精确地评估约束的时间,或者动画的时间。已申请。

    【讨论】:

    • 嗨,ARGeo,这是一个有趣的回应,Apple 正在为我们提供这些回调,以便我们可以在帧中的关键时刻更新任何逻辑。他们负责将此逻辑发送到引擎,但我们无法进一步了解。这现在更有意义了。时间是帧时间,而不是那些关键时刻的子帧时间。这应该是公认的答案,谢谢!
    • 我想time 参数主要是为了比较。但是渲染循环的逻辑本身在每个 render() 方法中(我的意思是before...after... 等)。
    猜你喜欢
    • 2014-08-25
    • 2018-10-29
    • 2021-08-24
    • 2017-09-13
    • 1970-01-01
    • 1970-01-01
    • 2013-01-28
    • 1970-01-01
    • 2014-02-18
    相关资源
    最近更新 更多