How can I destroy THREEJS Scene?(如何销毁 THREEJS 场景?)
问题描述
我创建了一个 Threejs 场景,添加了相机、灯光和各种对象.
I created a Threejs Scene, adding camera, lights and various objects.
问题很简单:如何破坏场景?从场景中移除所有组件?
The question is simple: how can I destroy scene? Removing from scene all components?
我需要销毁场景,因为我确实不想将任务委托给垃圾收集器.
I need to destroy scene because and I do not want to delegate the task to the garbage collector.
推荐答案
我用这个:
cancelAnimationFrame(this.id);// Stop the animation
this.renderer.domElement.addEventListener('dblclick', null, false); //remove listener to render
this.scene = null;
this.projector = null;
this.camera = null;
this.controls = null;
empty(this.modelContainer);
方法empty是jQuery empty的替代品,可以使用:
The method empty is a substitute to jQuery empty, you can use it:
function empty(elem) {
while (elem.lastChild) elem.removeChild(elem.lastChild);
}
这篇关于如何销毁 THREEJS 场景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何销毁 THREEJS 场景?


基础教程推荐
- Bokeh Div文本对齐 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01