diff --git a/BlueMapCore/src/main/webroot/js/libs/BlueMap.js b/BlueMapCore/src/main/webroot/js/libs/BlueMap.js index 777dc504..663941b9 100644 --- a/BlueMapCore/src/main/webroot/js/libs/BlueMap.js +++ b/BlueMapCore/src/main/webroot/js/libs/BlueMap.js @@ -475,15 +475,15 @@ export default class BlueMap { let displayAlert = () => { let alert = $(``).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(); diff --git a/BlueMapCore/src/main/webroot/js/libs/Controls.js b/BlueMapCore/src/main/webroot/js/libs/Controls.js index da71cfb4..7effecd9 100644 --- a/BlueMapCore/src/main/webroot/js/libs/Controls.js +++ b/BlueMapCore/src/main/webroot/js/libs/Controls.js @@ -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 = () => {