javascript - Was unable to relate and setup a onmousemove event? -
i setup mouse move event handler three.js unable relate mouse , make successful helpful if 1 how can it. know no using mouse related coordinates worried affects 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 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 true distance 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 dotp = vectors[i].x * vectors[1].x + vectors[i].y * vectors[1].y + vectors[i].z * vectors[1].z; if (dotp >= 1) angles[i] = 0.0; else if (dotp <= -1) angles[i] = math.pi; else angles[i] = math.acos(dotp); } angles[1] = math.atan2(viewingdir.x, -viewingdir.z); fov = angles[0] + angles[2]; angles[0] = angles[1] - 0.5 * fov; //x-dir angles[2] = angles[1] + 0.5 * fov; //y-dir return angles; }
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 code ...
Comments
Post a Comment