function handleNewTexture(evt) {
        let file = textureBtn.files;
        let reader = new FileReader;
        let fileName = file[0].name;

        reader.readAsDataURL(file[0]);
        reader.onload = addImg;

        function addImg(imgsrc) {
            fileName = fileName.replace(/\.[^/.]+$/, ""); //Remove extension

            let a = document.createElement('a');
            a.href = "#";
            a.setAttribute("data-texture", fileName);
            a.innerHTML = fileName;

            let newSpan = document.createElement('span');
            newSpan.className = "sample";
            newSpan.style.backgroundImage = "url(" + imgsrc.target.result + ")";

            a.appendChild(newSpan);
            document.getElementById("textures").appendChild(a);

            textureControls = document.querySelectorAll('.textures > a');
            for (let i = 0; i < textureControls.length; i++) {
                textureControls[i].addEventListener('click', handleTexture);
            }
        }
    }
/* ------------------------------------------------------------------------
     * handleNewTexture:
     * ------------------------------------------------------------------------
     * param evt - Javascript evt
     *
     * Loads the selected texture and adds it to the list of textures.
     */


param evt - Javascript evt

Loads the selected texture and adds it to the list of textures.
param evt - Javascript evt Loads the selected texture and adds it to the list of textures .
function handleNewTexture(evt) {
        let file = textureBtn.files;
        let reader = new FileReader;
        let fileName = file[0].name;
        reader.readAsDataURL(file[0]);
        reader.onload = addImg;
        function addImg(imgsrc) {
            fileName = fileName.replace(/\.[^/.]+$/, ""); 
            let a = document.createElement('a');
            a.href = "#";
            a.setAttribute("data-texture", fileName);
            a.innerHTML = fileName;
            let newSpan = document.createElement('span');
            newSpan.className = "sample";
            newSpan.style.backgroundImage = "url(" + imgsrc.target.result + ")";
            a.appendChild(newSpan);
            document.getElementById("textures").appendChild(a);
            textureControls = document.querySelectorAll('.textures > a');
            for (let i = 0; i < textureControls.length; i++) {
                textureControls[i].addEventListener('click', handleTexture);
            }
        }
    }
function handleNewTexture ( evt ) { let file = textureBtn . files ; let reader = new FileReader ; let fileName = file [ 0 ] . name ; reader . readAsDataURL ( file [ 0 ] ) ; reader . onload = addImg ; function addImg ( imgsrc ) { fileName = fileName . replace ( / \.[^/.]+$ / , "" ) ; let a = document . createElement ( 'a' ) ; a . href = "#" ; a . setAttribute ( "data-texture" , fileName ) ; a . innerHTML = fileName ; let newSpan = document . createElement ( 'span' ) ; newSpan . className = "sample" ; newSpan . style . backgroundImage = "url(" + imgsrc . target . result + ")" ; a . appendChild ( newSpan ) ; document . getElementById ( "textures" ) . appendChild ( a ) ; textureControls = document . querySelectorAll ( '.textures > a' ) ; for ( let i = 0 ; i < textureControls . length ; i ++ ) { textureControls [ i ] . addEventListener ( 'click' , handleTexture ) ; } } }
handleNewTexture:
handleNewTexture :
//Remove extension