dispose method

dynamic dispose()
  • Remove all listeners, stop animations and clean scene

Implementation

dispose() {
  if (this._animationId != -1) {
    cancelAnimationFrame(this._animationId);
  }

  this.domElement.removeEventListener('pointerdown', this.onPointerDown);
  this.domElement.removeEventListener('pointercancel', this.onPointerCancel);
  this.domElement.removeEventListener('wheel', this.onWheel);
  this.domElement.removeEventListener('contextmenu', this.onContextMenu);

  domElement.removeEventListener('pointermove', this.onPointerMove);
  domElement.removeEventListener('pointerup', this.onPointerUp);

  domElement.removeEventListener('resize', this.onWindowResize);

  if (this.scene != null) this.scene!.remove(this._gizmos);
  this.disposeGrid();
}