I have a cube that I want to move using mouse movements in javascript.
I wrote the following code but I need a little bit help.
I cant get it to work. Any help would be appreciated.
Thanks

Code:
console.log(models["cube"].model.vertexArray.length);

    document.addEventListener('mouse', function(event) {
        if(document.onmousemove = Mouse.handleMouseMove;) { //move around
            mat4.identity(matRot);
            mat4.identity(matrixRotated);
            mat4.rotateY(matRot,-Math.PI/50,matrixRotated);
            models["cube"].model.rotate(matrixRotated);

        }
        else if(document.onmouseup = Mouse.handleMouseUp;) { // up
            models["cube"].model.translate(0,0,-0.1);
        }
        else if(document.onmousedown = Mouse.handleMouseDown;) {// down         
            models["cube"].model.translate(0,0,0.05);
        }
    });