import * as THREE from "three";
import React from "react";

export interface ProcessPoint {
  uuid: string;
  position: number[];
  actions?: PointAction[];
}

export interface PointAction {
  type: string;
  isUsed: boolean;
  spawnInterval?: number | string;
  material?: string;
  delay?: number | string;
}

export interface ProcessData {
  id: string;
  name: string;
  paths?: {
    points?: ProcessPoint[];
  }[];
  animationPath?: { x: number; y: number; z: number }[];
  speed?: number;
  customMaterials?: Record<string, THREE.Material>;
}

export interface ProcessAnimationState {
  spawnedObjects: Record<string, SpawnedObject | SpawnedObjectWithCollision>;
  nextSpawnTime: number;
  objectIdCounter: number;
  isProcessDelaying: boolean;
  processDelayStartTime: number;
  processDelayDuration: number;
  isCollisionPaused?: boolean;
}

export interface SpawnedObject {
  ref: React.RefObject<THREE.Object3D>;
  state: {
    currentIndex: number;
    progress: number;
    isAnimating: boolean;
    speed: number;
    isDelaying: boolean;
    delayStartTime: number;
    currentDelayDuration: number;
    delayComplete: boolean;
    currentPathIndex: number;
  };
  visible: boolean;
  material: THREE.Material;
  currentMaterialType: string;
  spawnTime: number;
  position: THREE.Vector3;
  collision?: {
    boundingBox: THREE.Box3;
    isColliding: boolean;
    colliding: boolean; // Added this property
  };
}

// For use in your processAnimator.tsx
// Update the CollisionState interface to include all required properties
interface CollisionState {
    boundingBox: THREE.Box3;
    isColliding: boolean;
    colliding: boolean;  // This was missing
    collidingWith: string[];
  }
export interface SpawnedObjectWithCollision extends SpawnedObject {
    collision: {
      boundingBox: THREE.Box3;
      isColliding: boolean;
      colliding: boolean;
      collidingWith: string[];
    };
  }
