How to make a click and drag for a camera in jQuery?

393
January 02, 2017, at 10:58 PM

I have been experimenting with WebGL and I have got a semi-functioning planet which rotates when clicked using the event click command. but I am finding it difficult changing this code to work with drag and click.

var mouse = {
    x: 0, 
    y: 0
}
document.addEventListener('click', function(event) {
    mouse.x = (event.clientX / window.innerWidth ) - 0.5
    mouse.y = (event.clientY / window.innerHeight) - 0.5
}, false)
updateFcts.push(function(delta, now) {
    camera.position.x += (mouse.x * 5 - camera.position.x) * (delta * 3)
    camera.position.y += (mouse.y * 5 - camera.position.y) * (delta * 3)        
    camera.lookAt(scene.position)
})

I want to be able to rotate around the planet like in Google Earth. I know this is only part of the code but I am using https://github.com/jeromeetienne/threex.planets to make the site and have no idea what I need to change.

I am also wanting to add pin links to the site so that when you rotate around the planet you can click on the links to navigate to new pages.

Rent Charter Buses Company
READ ALSO
lazyload: show div only when it's contained image loads

lazyload: show div only when it's contained image loads

I'm using the lazyload plugin for loading all the images in my webThese images are each one contained in a div with also some description and buttons

271
How to format jquery keyup function in such a way so that it will compute the id of html tags at runtime?

How to format jquery keyup function in such a way so that it will compute the id of html tags at runtime?

I want to format the jquery keyup function in such a way so that it will compute id of html tags at runtime by checking which input is currently under user control ( active )For example :

252
How run two functions on onchange radio in jquery?

How run two functions on onchange radio in jquery?

I have some selects and inputs on my page:

374