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