import 'dart:math' as math;

import '../../domain/entities/ar_experience.dart';

class ArSceneController {
  ArSceneController(this.experience)
      : scale = experience.initialScale,
        yaw = 0;

  final ArExperience experience;
  double scale;
  double yaw;

  bool get hasPlacedObject => _hasPlacedObject;
  bool get waitingForSurfaceTap => !_hasPlacedObject;

  bool _hasPlacedObject = false;

  void markObjectPlaced() {
    _hasPlacedObject = true;
  }

  void markObjectRemoved() {
    _hasPlacedObject = false;
  }

  double setScale(double nextScale) {
    scale = experience.clampScale(nextScale);
    return scale;
  }

  double rotate(double radians) {
    yaw = (yaw + radians) % (math.pi * 2);
    return yaw;
  }

  void reset() {
    scale = experience.initialScale;
    yaw = 0;
    _hasPlacedObject = false;
  }
}
