stop method

  1. @override
Future<void> stop()
override

Takes out what start put in — the scene renderer, the animation system, the model loader — and lets go of the renderer and the models, the GPU models they hold among them: isStarted is false again.

Implementation

@override
Future<void> stop() async {
  final engine = _engine;
  final scene = _scene;
  if (scene != null) {
    engine?.rendering.removeSceneRenderer(scene);
    scene.dispose();
  }
  final animations = _animations;
  if (animations != null && engine?.isDisposed == false) {
    engine?.world.removeSystem(animations);
  }
  final loader = _loader;
  if (loader != null) {
    engine?.assets.unregisterLoader(AssetType.model, loader);
  }
  final models = _models;
  if (models != null) {
    models.reloadListeners.remove(_modelReloaded);
    if (identical(engine?.context.graphics3DModels, models)) {
      engine?.context.graphics3DModels = null;
    }
    // The model assets the engine still holds keep the models: their GPU
    // side goes now.
    models.clear();
  }
  _scene = null;
  _animations = null;
  _loader = null;
  _models = null;
  _renderer = null;
  _engine = null;
}