import * as THREE from 'three'

import { MviewAsset } from '../assets/marmosets/MviewFiles'

class MarmosetTexture extends THREE.Texture {

    constructor() {

        super();


    } 

    build( asset: MviewAsset) {

       
        this.name = asset.name;
        let image = new Image();

        this.magFilter = THREE.LinearFilter;
        this.minFilter = THREE.LinearFilter;
        this.generateMipmaps = true
        this.anisotropy = 4;

        image.src = URL.createObjectURL(new Blob([new Uint8Array(asset.data)], { type: asset.type }))
        image.onload = event => {

            this.image = image
            this.needsUpdate = true;
            
        }

        this.premultiplyAlpha = false
    }


    // 1. mipMap  true
    // 2. aniso   mobile ? 0 : 4
    // 3. clamp   !!pamarmeter
    // 4. filter   

}

export default MarmosetTexture