Catch web-app error and cancel alert animations

This commit is contained in:
Blue (Lukas Rieger) 2020-01-21 23:06:09 +01:00
parent 2c1fb0a8db
commit a217ddf045
2 changed files with 25 additions and 23 deletions

View File

@ -475,15 +475,15 @@ export default class BlueMap {
let displayAlert = () => { let displayAlert = () => {
let alert = $(`<div class="alert box" data-alert-id="${id}" style="display: none;"><div class="alert-close-button"></div>${content}</div>`).appendTo(alertBox); let alert = $(`<div class="alert box" data-alert-id="${id}" style="display: none;"><div class="alert-close-button"></div>${content}</div>`).appendTo(alertBox);
alert.find('.alert-close-button').click(() => { alert.find('.alert-close-button').click(() => {
alert.fadeOut(200, () => alert.remove()); alert.stop().fadeOut(200, () => alert.remove());
}); });
alert.fadeIn(200); alert.stop().fadeIn(200);
}; };
if (id !== undefined) { if (id !== undefined) {
let sameAlert = alertBox.find(`.alert[data-alert-id=${id}]`); let sameAlert = alertBox.find(`.alert[data-alert-id=${id}]`);
if (sameAlert.length > 0) { if (sameAlert.length > 0) {
alertBox.fadeOut(200, () => { alertBox.stop().fadeOut(200, () => {
alertBox.html(''); alertBox.html('');
alertBox.show(); alertBox.show();
}); });
@ -493,7 +493,7 @@ export default class BlueMap {
let oldAlerts = alertBox.find('.alert'); let oldAlerts = alertBox.find('.alert');
if (oldAlerts.length > 0){ if (oldAlerts.length > 0){
alertBox.fadeOut(200, () => { alertBox.stop().fadeOut(200, () => {
alertBox.html(''); alertBox.html('');
alertBox.show(); alertBox.show();
displayAlert(); displayAlert();

View File

@ -228,6 +228,8 @@ export default class Controls {
return this.heightScene.children.filter(child => inTile(child.position, targetPos)) return this.heightScene.children.filter(child => inTile(child.position, targetPos))
}; };
// check hight at target
try {
let rayStart = new Vector3(this.targetPosition.x, 300, this.targetPosition.z); let rayStart = new Vector3(this.targetPosition.x, 300, this.targetPosition.z);
this.raycaster.set(rayStart, this.rayDirection); this.raycaster.set(rayStart, this.rayDirection);
this.raycaster.near = 1; this.raycaster.near = 1;
@ -236,20 +238,20 @@ export default class Controls {
if (intersects.length > 0) { if (intersects.length > 0) {
this.minHeight = intersects[0].point.y; this.minHeight = intersects[0].point.y;
//this.targetPosition.y = this.minHeight;
} else {
//this.targetPosition.y = 0;
} }
} catch (ignore){}
rayStart.set(this.camera.position.x, 300, this.camera.position.z); // check height at camera
try {
let rayStart = new Vector3(this.camera.position.x, 300, this.camera.position.z);
this.raycaster.set(rayStart, this.rayDirection); this.raycaster.set(rayStart, this.rayDirection);
intersects.length = 0; let intersects = this.raycaster.intersectObjects(tileChildren(this.camera.position));
intersects = this.raycaster.intersectObjects(tileChildren(this.camera.position));
if (intersects.length > 0) { if (intersects.length > 0) {
if (intersects[0].point.y > this.minHeight) { if (intersects[0].point.y > this.minHeight) {
this.minHeight = intersects[0].point.y; this.minHeight = intersects[0].point.y;
} }
} }
} catch (ignore){}
} }
updateMouseMoves = () => { updateMouseMoves = () => {