mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-25 20:16:00 +01:00
Catch web-app error and cancel alert animations
This commit is contained in:
parent
2c1fb0a8db
commit
a217ddf045
@ -475,15 +475,15 @@ export default class BlueMap {
|
||||
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);
|
||||
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) {
|
||||
let sameAlert = alertBox.find(`.alert[data-alert-id=${id}]`);
|
||||
if (sameAlert.length > 0) {
|
||||
alertBox.fadeOut(200, () => {
|
||||
alertBox.stop().fadeOut(200, () => {
|
||||
alertBox.html('');
|
||||
alertBox.show();
|
||||
});
|
||||
@ -493,7 +493,7 @@ export default class BlueMap {
|
||||
|
||||
let oldAlerts = alertBox.find('.alert');
|
||||
if (oldAlerts.length > 0){
|
||||
alertBox.fadeOut(200, () => {
|
||||
alertBox.stop().fadeOut(200, () => {
|
||||
alertBox.html('');
|
||||
alertBox.show();
|
||||
displayAlert();
|
||||
|
@ -215,41 +215,43 @@ export default class Controls {
|
||||
}
|
||||
|
||||
updateHeights() {
|
||||
function between(n, min, max) {
|
||||
return n >= min && n < max;
|
||||
}
|
||||
function between(n, min, max) {
|
||||
return n >= min && n < max;
|
||||
}
|
||||
|
||||
let inTile = (pos, thisPos) => {
|
||||
return between(pos.x, thisPos.x - this.tileSize.x, thisPos.x) &&
|
||||
between(pos.z, thisPos.z - this.tileSize.z, thisPos.z);
|
||||
};
|
||||
let inTile = (pos, thisPos) => {
|
||||
return between(pos.x, thisPos.x - this.tileSize.x, thisPos.x) &&
|
||||
between(pos.z, thisPos.z - this.tileSize.z, thisPos.z);
|
||||
};
|
||||
|
||||
let tileChildren = (targetPos) => {
|
||||
return this.heightScene.children.filter(child => inTile(child.position, targetPos))
|
||||
};
|
||||
let tileChildren = (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);
|
||||
this.raycaster.set(rayStart, this.rayDirection);
|
||||
this.raycaster.near = 1;
|
||||
this.raycaster.far = 300;
|
||||
let intersects = this.raycaster.intersectObjects(tileChildren(this.targetPosition));
|
||||
|
||||
if (intersects.length > 0){
|
||||
if (intersects.length > 0) {
|
||||
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);
|
||||
intersects.length = 0;
|
||||
intersects = this.raycaster.intersectObjects(tileChildren(this.camera.position));
|
||||
if (intersects.length > 0){
|
||||
if (intersects[0].point.y > this.minHeight){
|
||||
let intersects = this.raycaster.intersectObjects(tileChildren(this.camera.position));
|
||||
if (intersects.length > 0) {
|
||||
if (intersects[0].point.y > this.minHeight) {
|
||||
this.minHeight = intersects[0].point.y;
|
||||
}
|
||||
}
|
||||
} catch (ignore){}
|
||||
}
|
||||
|
||||
updateMouseMoves = () => {
|
||||
|
Loading…
Reference in New Issue
Block a user