我创建了一个三j的场景,添加了相机,灯和各种对象。
问题很简单:我该如何销毁场景?从场景中删除所有组件?
我需要销毁场景,因为我做不是想要将任务委托给垃圾收集器。
我使用了此:
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);
该方法是空的,您可以使用它:
function empty(elem) {
while (elem.lastChild) elem.removeChild(elem.lastChild);
}