import { ColorFormat } from "@hitplay/ads_common";
import { ThreeC_internal, Template } from "@hitplay/playable_template";
import { AmbientLight, DirectionalLight } from "three";
import { Color } from "three/src/math/Color";

export class ThreeC extends ThreeC_internal {
  static createBaseLights() {
    this.defaultDirectionalLight = new DirectionalLight(0xffffff, 3.5);
    this.defaultAmbientLight = new AmbientLight(0xffffff, 1);

    this.defaultAmbientLight.color = new Color().setHex(
      Number(Template.getValue<ColorFormat>("global", "light_color"))
    );
    this.defaultAmbientLight.intensity = 
      Template.getValue<number>("global", "light_intensity")
  }

  static setupDirectionalLight() {
    const dirLight = this.defaultDirectionalLight;

    dirLight.position.set(8, 10, 4); // shines down from the top-front
    dirLight.target.position.set(0, 0, 0);

    // Real-time shadows are disabled on purpose. The character ships its own
    // baked "blob" shadow inside the GLB (the "Shadow" mesh), which is cheaper
    // and never shimmers. The directional light is kept only for shading.
    dirLight.castShadow = false;

    this.addToScene(dirLight);
    this.addToScene(this.defaultAmbientLight);
    this.addToScene(dirLight.target);
  }
}
