import * as THREE from 'three';

// Video texture for emissive "screen"-like effect on orange material
export const video = document.createElement('video');
video.src = '/shader-flash.webm';
video.muted = true;
video.loop = true;
video.playsInline = true;
video.autoplay = true;
video.preload = 'auto';

export const videoTexture = new THREE.VideoTexture(video);
videoTexture.colorSpace = THREE.SRGBColorSpace;
videoTexture.generateMipmaps = false;
videoTexture.minFilter = THREE.LinearFilter;
videoTexture.magFilter = THREE.LinearFilter;

// Ensure autoplay starts (muted autoplay is commonly allowed)
video.play().catch(() => { });

// Bold glass material (starts rough, will transition to clear)
export const boldGlassMaterial = new THREE.MeshPhysicalMaterial({
  color: 0xffffff,
  metalness: 0.2,
  roughness: 0.5,
  transmission: 1,
  ior: 2,
  thickness: 2,
  clearcoat: 1.0,
  clearcoatRoughness: 0.1,
  attenuationColor: new THREE.Color(0xffffff),
  attenuationDistance: 0.8,
  envMapIntensity: 0,
  specularIntensity: 1.0,
  specularColor: new THREE.Color(0xffffff),
  transparent: true,
  depthWrite: false,
  alphaTest: 0
});

// Orange wireframe material for bold Cubewire mesh
export const boldWireframeMaterial = new THREE.MeshStandardMaterial({
  color: 0xff8600,
  metalness: 0.05,
  roughness: 0.5
});

// Clear thick glass for innovation (starts with animated values)
export const innovationGlassMaterial = new THREE.MeshPhysicalMaterial({
  color: 0xffffff,
  metalness: 0.2,
  roughness: 0.05,
  transmission: 1,
  ior: 1.0,
  thickness: 1.0,
  clearcoat: 1.0,
  clearcoatRoughness: 0.1,
  attenuationColor: new THREE.Color(0xffffff),
  attenuationDistance: 0.8,
  envMapIntensity: 0,
  specularIntensity: 1.0,
  specularColor: new THREE.Color(0x000000),
  transparent: true,
  depthWrite: false,
  alphaTest: 0
});

// Slightly frosted glass for agility and storytelling
export const frostedGlassMaterial = new THREE.MeshPhysicalMaterial({
  color: 0xffffff,
  metalness: 0.0,
  roughness: 0.25,
  transmission: 1.0,
  ior: 1.5,
  thickness: 2.0,
  clearcoat: 0.75,
  clearcoatRoughness: 0.25,
  attenuationColor: new THREE.Color(0xffffff),
  attenuationDistance: 1.5,
  envMapIntensity: 1.25,
  specularIntensity: 1.0,
  specularColor: new THREE.Color(0xffffff),
  transparent: true,
  depthWrite: false,
  side: THREE.DoubleSide
});

// Orange material with video shader for innovation
export const lightOrangeMaterial = new THREE.MeshStandardMaterial({
  color: 0xff8600,
  metalness: 0.05,
  roughness: 0.4,
  envMapIntensity: 0,
  emissive: new THREE.Color(0xffad47),
  emissiveMap: videoTexture,
  emissiveIntensity: 2.25
});
