From cda69b86c67b7666235712e7a8e1a98d14d6c6c8 Mon Sep 17 00:00:00 2001 From: Thomas FORGIONE Date: Wed, 29 Apr 2015 15:51:25 +0200 Subject: [PATCH] Added undo button (only one level) --- prototype/index.md | 1 + static/js/PointerCamera.js | 10 ++++++++++ static/js/prototype/main.js | 8 +++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/prototype/index.md b/prototype/index.md index 060050b..b790815 100644 --- a/prototype/index.md +++ b/prototype/index.md @@ -26,6 +26,7 @@ button. + diff --git a/static/js/PointerCamera.js b/static/js/PointerCamera.js index b4d699a..add4360 100644 --- a/static/js/PointerCamera.js +++ b/static/js/PointerCamera.js @@ -247,6 +247,16 @@ PointerCamera.prototype.log = function() { console.log("(" + this.target.x + "," + this.target.y + ',' + this.target.z + ')'); } +PointerCamera.prototype.save = function() { + this.backup = {}; + this.backup.position = this.position.clone(); + this.backup.target = this.target.clone(); +} + +PointerCamera.prototype.load = function() { + this.move(this.backup); +} + // Static members PointerCamera.DISTANCE_X = 1000; PointerCamera.DISTANCE_Z = 300; diff --git a/static/js/prototype/main.js b/static/js/prototype/main.js index c63b73a..ffb0315 100644 --- a/static/js/prototype/main.js +++ b/static/js/prototype/main.js @@ -65,6 +65,10 @@ function init() { showArrows = showarrows.checked; } + document.getElementById('undo').onclick = function() { + cameras.mainCamera().load(); + } + // on initialise le moteur de rendu container = document.getElementById('container'); container.style.height = container_size.height() + 'px'; @@ -474,8 +478,10 @@ function updateMouse(event) { function click(event) { var newCamera = pointedCamera(event); - if (newCamera !== undefined) + if (newCamera !== undefined) { + cameras.mainCamera().save(); cameras.mainCamera().move(newCamera); + } } function pointedCamera(event) {