Added undo button (only one level)
This commit is contained in:
parent
5df1d17746
commit
cda69b86c6
|
@ -26,6 +26,7 @@ button.
|
|||
|
||||
<button class="btn btn-primary" id="full" style="margin-bottom: 10px; display: none;">Fullscreen</button>
|
||||
<button class="btn btn-primary" id="reset" style="margin-bottom:10px">Reset camera</button>
|
||||
<button class="btn btn-primary" id="undo" style="margin-bottom:10px">Undo</button>
|
||||
<input type="checkbox" id="fullarrow" style="margin-bottom:10px">
|
||||
<label for="fullarrow">Full arrow</label>
|
||||
<input type="checkbox" id="collisions" style="margin-bottom:10px" checked>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,9 +478,11 @@ 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) {
|
||||
var returnCamera;
|
||||
|
|
Loading…
Reference in New Issue