import { ShaderMaterial, Vector3 } from "three";
import shader_fg from './visualize.frag.js';
import shader_vx from './visualize.vert.js';

export class SH3VisualisationMaterial extends ShaderMaterial {

    constructor() {
        const sh = [];

        for (let i = 0; i < 9; i++) {
            sh.push(new Vector3());
        }

        super({
            fragmentShader: shader_fg,
            vertexShader: shader_vx,
            lights: false,
            uniforms: {
                intensity: {
                    value: 1,
                },
                sh: {
                    value: sh
                }
            }
        })
    }

    fromArray(data, offset){

        const uniform_value = this.uniforms.sh.value;
        for (let i = 0; i < 9; i++) {
            uniform_value[i].fromArray(data, offset + i * 3);
        }

    }

}
