Improved mouse event
This commit is contained in:
parent
4d79ea6484
commit
35a8522088
|
@ -2,6 +2,11 @@
|
|||
var PointerCamera = function() {
|
||||
THREE.PerspectiveCamera.apply(this, arguments);
|
||||
|
||||
if (arguments[4] === undefined)
|
||||
listenerTarget = document;
|
||||
else
|
||||
listenerTarget = arguments[4];
|
||||
|
||||
// Set Position
|
||||
this.theta = Math.PI;
|
||||
this.phi = Math.PI;
|
||||
|
@ -40,9 +45,12 @@ var PointerCamera = function() {
|
|||
|
||||
document.addEventListener('keydown', onKeyDown, false);
|
||||
document.addEventListener('keyup', onKeyUp, false);
|
||||
document.addEventListener('mousedown', onMouseDown, false);
|
||||
document.addEventListener('mousemove', onMouseMove, false);
|
||||
document.addEventListener('mouseup', onMouseUp, false);
|
||||
listenerTarget.addEventListener('mousedown', onMouseDown, false);
|
||||
listenerTarget.addEventListener('mousemove', onMouseMove, false);
|
||||
listenerTarget.addEventListener('mouseup', onMouseUp, false);
|
||||
listenerTarget.addEventListener('mouseout', onMouseUp, false);
|
||||
|
||||
console.log(arguments[3]);
|
||||
}
|
||||
PointerCamera.prototype = Object.create(THREE.PerspectiveCamera.prototype);
|
||||
PointerCamera.prototype.constructor = PointerCamera;
|
||||
|
|
|
@ -39,7 +39,7 @@ function init() {
|
|||
scene.add(ambient_light);
|
||||
|
||||
// on initialise la camera que l’on place ensuite sur la scène
|
||||
var camera1 = new PointerCamera(50, container_size.width / container_size.height, 1, 100000);
|
||||
var camera1 = new PointerCamera(50, container_size.width / container_size.height, 1, 100000, container);
|
||||
|
||||
var camera2 = new FixedCamera(50,
|
||||
container_size.width / container_size.height,
|
||||
|
|
Loading…
Reference in New Issue