我如何停止 requestAnimationFrame [英] How do I stop requestAnimationFrame

查看:182
本文介绍了我如何停止 requestAnimationFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要移除画布并构建一个新画布.我遇到了一个问题,我不知道如何停止/中断 Three.js 或 webGL 更新过程.如果我强制执行 javascript 错误,我可以停止它(但这真的很愚蠢).

I need to remove a canvas and build a new one. I'm having a problem where I don't know how to stop/interrupt the Three.js or webGL update process. I can stop it if I force a javascript error (but that's really stupid).

有谁知道如何停止进程,这样我就不会开始堆积没有任何用处或与新进程冲突的进程?

Does anyone know how to stop the process so that I don't start to pile processes that aren't doing anything useful or conflicting with the new ones?

推荐答案

var id;

function animate() {

    id = requestAnimationFrame( animate );

    renderer.render( scene, camera );

}

取消

cancelAnimationFrame( id );

three.js r.55

three.js r.55

这篇关于我如何停止 requestAnimationFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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