rajesh February 2016

Was unable to relate and setup a onmousemove event?

I would like to setup a mouse move event handler for my three.js but was unable to relate it to mouse and make it successful it could be really helpful if some one could say how can i do it. I know no were i am using mouse related coordinates but i am worried to do something affects my calculation part.

root = document.getElementById("WebGL");

window.addEventListener('resize', onWindowResize(width, height), false);
root.addEventListener('mousemove', MouseMoveGoogleMapsUpdate(), false);


function MouseMoveGoogleMapsUpdate(){

    var angle = onMouseMove();

    line.setMap(null);  //removing the old lines on circle


            var newstartpoint   = pointGoogleMaps(circle.getRadius() * Math.cos(-angle[0]),
                                        circle.getRadius() * Math.sin(-angle[0]), origin);

            var  viewdir        = pointGoogleMaps(circle.getRadius() * Math.cos(-angle[1]),
                                        circle.getRadius() * Math.sin(-angle[1]), origin);

            var newendpoint    = pointGoogleMaps(circle.getRadius() * Math.cos(angle[2]),
                                        circle.getRadius() * Math.sin(angle[2]), origin);

            line = new google.maps.Polyline({
            path: [newstartpoint, origin, newendpoint],
            geodesic: true,  //By setting it to true the distance is cal in meters
            strokeColor: '#0000FF',
            strokeOpacity: 0.8,
            strokeWeight: 2,            
            map: map
            });

}


function onMouseMove(){

    var degrees = Math.PI/180.0;
    var raycaster = new THREE.Raycaster();
    var viewingDir = camera.getWorldDirection();
    var Vectors = [0,0,0];
    var Angles = [0,0,0];

    for(i=0; i<3; i++)
    {
        Vectors[i] = new THREE.Vector3(i-1, 0, 0.5);
        raycaster.setFromCamera(Vectors[i], camera);
        Vectors[i].sub(camera.position);
        Vectors[i].normalize();

    }

    for(i=0; i<3; i+=2)
    {
        var d        

Answers


Martin February 2016

canvas.addEventListener( 'mousemove', onDocumentMouseMove, false );
function onDocumentMouseMove( event ) {  
        event.preventDefault();
        mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
        mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
}

I don't see event in your code ...

Post Status

Asked in February 2016
Viewed 2,287 times
Voted 10
Answered 1 times

Search




Leave an answer