本文介紹了如何銷毀 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 場景?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!