dispose method

dynamic dispose()

Remove all listeners, stop animations and clean scene

Implementation

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

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

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

  domElement.removeEventListener('resize', onWindowResize);

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