限制Three.js中的帧速率以提高性能,requestAnimationFrame吗? [英] Limiting framerate in Three.js to increase performance, requestAnimationFrame?

查看:158
本文介绍了限制Three.js中的帧速率以提高性能,requestAnimationFrame吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当时在想,对于某些项目,我并不是完全需要60fps。我认为,如果我能够使其以该帧速率平稳运行,则可以有更多的对象和事物以30fps的速度运行。我发现如果我在three.js中编辑了requestAnimationFrame垫片,我可以将它限制为30。但是我想知道是否有更好的方法使用提供的three.js本身来做到这一点。另外,这是否会给我带来我所想的性能提升。我能否以30fps的速度渲染60倍的对象?我知道以30和60运行时的区别,但是我能否使其以平稳的恒定30fps运行?

I was thinking that for some projects I do 60fps is not totally needed. I figured I could have more objects and things that ran at 30fps if I could get it to run smoothly at that framerate. I figured if I edited the requestAnimationFrame shim inside of three.js I could limit it to 30 that way. But I was wondering if there was a better way to do this using three.js itself as provided. Also, will this give me the kind of performance increase I am thinking. Will I be able to render twice as many objects at 30fps as I will at 60? I know the difference between running things at 30 and 60, but will I be able to get it to run at a smooth constant 30fps?

我通常使用WebGLRenderer,并且如果需要,可以退回到Canvas上,除非是专门针对某个项目的项目,通常是webgl着色器项目。

I generally use the WebGLRenderer, and fall back to Canvas if needed except for projects that are targeting one specifically, and typically those are webgl shader projects.

推荐答案

function animate() {

    setTimeout( function() {

        requestAnimationFrame( animate );

    }, 1000 / 30 );

    renderer.render();

}

这篇关于限制Three.js中的帧速率以提高性能,requestAnimationFrame吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆