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 场景?


基础教程推荐
- 如何在特定日期之前获取消息? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01