export default class SceneEventBridge {
  constructor(options = {}) {
    this.eventBus = options.eventBus;
    this.getTreeSnapshot = options.getTreeSnapshot || (() => null);
    this.getOriginalModelStyleChanges = options.getOriginalModelStyleChanges || (() => []);
  }

  emit(eventName, payload) {
    if (!this.eventBus) return;
    this.eventBus.emit(eventName, payload);
  }

  emitSceneGraphChanged(payload = {}) {
    this.emit('sceneGraphChanged', {
      tree: this.getTreeSnapshot(),
      ...payload,
    });
  }

  emitOriginalModelChangeListChanged(payload = {}) {
    this.emit('originalModelChangeListChanged', {
      list: this.getOriginalModelStyleChanges(),
      ...payload,
    });
  }

  destroy() {
    if (this.eventBus && this.eventBus.clear) {
      this.eventBus.clear();
    }
  }
}
