2015-06-12 17 views
5

Cách tốt nhất để hủy một phiên bản ba giây là gì?
Tôi thấy rằng khi tôi xóa canvas và thêm lại, trình kết xuất đầu tiên của tôi vẫn còn và tôi có hai.Ba js phá hủy trình kết xuất

Hiện nay tôi đang

  1. Loại bỏ tất cả các thính giả sự kiện
  2. hủy requestAnimationFrame
  3. xóa dụ renderer từ đó là cha mẹ

Trả lời

2

gì về một cái gì đó như thế nào?

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); 
} 

Đây là một tham chiếu đến này cũ SO bài: How can I destroy THREEJS Scene?

1

Để tiêu diệt các cảnh, hãy thử:

scene = null; 

Để loại bỏ một lưới:

scene.remove (lưới);

Các vấn đề liên quan