mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
added mouse wheel for zooming
This commit is contained in:
parent
59978429c7
commit
93857ced2d
2 changed files with 26 additions and 1 deletions
|
|
@ -27,10 +27,30 @@ define(['Lib/Vendor/Three', 'Game/Config/Settings'], function (Three, Settings)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.camera.position.z = 481;
|
this.camera.position.z = 481; // 481
|
||||||
this.setPosition(Settings.STAGE_WIDTH / 2, -Settings.STAGE_HEIGHT / 2);
|
this.setPosition(Settings.STAGE_WIDTH / 2, -Settings.STAGE_HEIGHT / 2);
|
||||||
|
|
||||||
|
this.initWheel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CameraController.prototype.initWheel = function() {
|
||||||
|
var callback = this.handleWheel.bind(this);
|
||||||
|
if(window.addEventListener)
|
||||||
|
window.addEventListener("DOMMouseScroll", callback, false);
|
||||||
|
else
|
||||||
|
window.onmousewheel = document.onmousewheel = callback;
|
||||||
|
};
|
||||||
|
|
||||||
|
CameraController.prototype.handleWheel = function(event) {
|
||||||
|
var delta = 0;
|
||||||
|
if(!event) event = window.event; // IE
|
||||||
|
if(event.wheelDelta) delta = event.wheelDelta/120;
|
||||||
|
else if(event.detail) delta = -event.detail/3;
|
||||||
|
if(delta) this.camera.position.z += delta * 10;
|
||||||
|
if(event.preventDefault) event.preventDefault();
|
||||||
|
event.returnValue = false;
|
||||||
|
};
|
||||||
|
|
||||||
CameraController.prototype.getCamera = function () {
|
CameraController.prototype.getCamera = function () {
|
||||||
return this.camera;
|
return this.camera;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
||||||
var ambientLight = new Three.AmbientLight(0xffffff);
|
var ambientLight = new Three.AmbientLight(0xffffff);
|
||||||
this.scene.add(ambientLight);
|
this.scene.add(ambientLight);
|
||||||
|
|
||||||
|
|
||||||
//var directionalLight = new Three.DirectionalLight(0xffffff);
|
//var directionalLight = new Three.DirectionalLight(0xffffff);
|
||||||
//directionalLight.position.set(1, 0, 10).normalize();
|
//directionalLight.position.set(1, 0, 10).normalize();
|
||||||
//this.scene.add(directionalLight);
|
//this.scene.add(directionalLight);
|
||||||
|
|
@ -67,6 +68,10 @@ define(requires, function (DomController, Three, Settings, CameraController) {
|
||||||
//});
|
//});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewController.prototype.loadPlayerMesh = function(player) {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
ViewController.prototype.loadMeshes = function(objects) {
|
ViewController.prototype.loadMeshes = function(objects) {
|
||||||
var self = this;
|
var self = this;
|
||||||
for (var i = 0; i < objects.length; i++) {
|
for (var i = 0; i < objects.length; i++) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue