diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index 555de4f0..0115ae50 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -14,7 +14,7 @@ jobs:
- name: Test with Gradle
run: ./gradlew test
- name: Build with Gradle
- run: ./gradlew shadowJar
+ run: ./gradlew build
- uses: actions/upload-artifact@v1
with:
name: artifact
diff --git a/.gitignore b/.gitignore
index 77d3d11a..a2cea087 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,9 @@ bin/*
.project
*/.project
+node_modules/
+package-lock.json
+
# exclude generated resource
BlueMapCore/src/main/resources/webroot.zip
-BlueMapCore/src/main/resources/resourceExtensions.zip
\ No newline at end of file
+BlueMapCore/src/main/resources/resourceExtensions.zip
diff --git a/BlueMapCore/build.gradle b/BlueMapCore/build.gradle
index 660a351f..cbd52a0b 100644
--- a/BlueMapCore/build.gradle
+++ b/BlueMapCore/build.gradle
@@ -1,24 +1,57 @@
+plugins {
+ id 'com.moowork.node' version '1.3.1'
+}
+
dependencies {
- compile 'com.google.guava:guava:21.0'
- compile 'com.google.code.gson:gson:2.8.0'
- compile 'org.apache.commons:commons-lang3:3.5'
- compile group: 'commons-io', name: 'commons-io', version: '2.6'
- compile 'com.flowpowered:flow-math:1.0.3'
- compile 'ninja.leaping.configurate:configurate-hocon:3.3'
- compile 'ninja.leaping.configurate:configurate-gson:3.3'
- compile 'ninja.leaping.configurate:configurate-yaml:3.3'
- compile 'com.github.Querz:NBT:4.0'
-
- testCompile 'junit:junit:4.12'
+ compile 'com.google.guava:guava:21.0'
+ compile 'com.google.code.gson:gson:2.8.0'
+ compile 'org.apache.commons:commons-lang3:3.5'
+ compile group: 'commons-io', name: 'commons-io', version: '2.6'
+ compile 'com.flowpowered:flow-math:1.0.3'
+ compile 'ninja.leaping.configurate:configurate-hocon:3.3'
+ compile 'ninja.leaping.configurate:configurate-gson:3.3'
+ compile 'ninja.leaping.configurate:configurate-yaml:3.3'
+ compile 'com.github.Querz:NBT:4.0'
+
+ testCompile 'junit:junit:4.12'
+}
+
+node {
+ version = '12.14.1'
+ download = true
+}
+
+task fixPackageLock() {
+ if (!file("./package-lock.json").exists()) {
+ file("./package-lock.json").text = ""
+ }
+}
+
+task cleanWebroot(type: Delete) {
+ delete 'build/generated/webroot/'
+}
+
+// Run WebPack build to generate resources into the generated resources
+task webpackWebroot(type: NpmTask) {
+ args = ['run', 'build']
}
task zipWebroot(type: Zip) {
- from fileTree('src/main/webroot')
+ from fileTree('build/generated/webroot/')
archiveName 'webroot.zip'
destinationDir(file('src/main/resources/'))
outputs.upToDateWhen { false }
}
+// removes tmp build directory, build project with webpack, zip contents for the shaded jar
+task buildWebroot {
+ dependsOn 'fixPackageLock'
+ dependsOn 'npmInstall'
+ dependsOn 'cleanWebroot'
+ dependsOn 'webpackWebroot'
+ dependsOn 'zipWebroot'
+}
+
task zipResourceExtensions(type: Zip) {
from fileTree('src/main/resourceExtensions')
archiveName 'resourceExtensions.zip'
@@ -27,5 +60,5 @@ task zipResourceExtensions(type: Zip) {
}
//always update the zip before build
-compileJava.dependsOn(zipWebroot)
-compileJava.dependsOn(zipResourceExtensions)
+processResources.dependsOn(buildWebroot)
+processResources.dependsOn(zipResourceExtensions)
diff --git a/BlueMapCore/package.json b/BlueMapCore/package.json
new file mode 100644
index 00000000..512f0515
--- /dev/null
+++ b/BlueMapCore/package.json
@@ -0,0 +1,42 @@
+{
+ "name": "bluemap",
+ "description": "BlueMap is a tool that generates 3d-maps of your Minecraft worlds and displays them in your browser.",
+ "private": true,
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/BlueMap-Minecraft/BlueMap.git"
+ },
+ "keywords": [
+ "minecraft"
+ ],
+ "author": "Blue",
+ "license": "MIT",
+ "bugs": {
+ "url": "https://github.com/BlueMap-Minecraft/BlueMap/issues"
+ },
+ "homepage": "https://github.com/BlueMap-Minecraft/BlueMap#readme",
+ "dependencies": {
+ "jquery": "^3.4.1",
+ "three": "^0.94.0"
+ },
+ "devDependencies": {
+ "css-loader": "^3.4.2",
+ "fibers": "^4.0.2",
+ "file-loader": "^5.0.2",
+ "html-webpack-plugin": "^3.2.0",
+ "mini-css-extract-plugin": "^0.9.0",
+ "node-sass": "^4.13.0",
+ "sass": "^1.24.4",
+ "sass-loader": "^8.0.2",
+ "ts-loader": "^6.2.1",
+ "typescript": "^3.7.4",
+ "webpack": "^4.41.5",
+ "webpack-cli": "^3.3.10",
+ "webpack-dev-server": "^3.10.1"
+ },
+ "scripts": {
+ "test": "echo \"Error: no test specified\" && exit 1",
+ "build": "webpack --mode production",
+ "start": "webpack-dev-server --watch --mode development"
+ }
+}
diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/TileRenderer.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/TileRenderer.java
index d874c246..c65d03e7 100644
--- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/TileRenderer.java
+++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/render/TileRenderer.java
@@ -34,38 +34,38 @@
public class TileRenderer {
private HiresModelManager hiresModelManager;
private LowresModelManager lowresModelManager;
-
+
public TileRenderer(HiresModelManager hiresModelManager, LowresModelManager lowresModelManager) {
this.hiresModelManager = hiresModelManager;
this.lowresModelManager = lowresModelManager;
}
-
+
/**
* Renders the provided WorldTile (only) if the world is generated
* @throws IOException If an IO-Exception occurs during the render
*/
public void render(WorldTile tile) throws IOException {
- //check if the region is generated before rendering, don't render if it's not generated
+ //check if the region is generated before rendering, don't render if it's not generated
AABB area = hiresModelManager.getTileRegion(tile);
if (!tile.getWorld().isAreaGenerated(area)) return;
-
+
HiresModel hiresModel = hiresModelManager.render(tile);
lowresModelManager.render(hiresModel);
}
-
+
/**
* Saves changes to disk
*/
public void save(){
lowresModelManager.save();
}
-
+
public HiresModelManager getHiresModelManager() {
return hiresModelManager;
}
-
+
public LowresModelManager getLowresModelManager() {
return lowresModelManager;
}
-
+
}
diff --git a/BlueMapCore/src/main/webroot/index.html b/BlueMapCore/src/main/webroot/index.html
index 4f13a002..d818108c 100644
--- a/BlueMapCore/src/main/webroot/index.html
+++ b/BlueMapCore/src/main/webroot/index.html
@@ -1,22 +1,10 @@
-
-
-
- BlueMap
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+ BlueMap
+
+
+
+
diff --git a/BlueMapCore/src/main/webroot/js/libs/BlueMap.js b/BlueMapCore/src/main/webroot/js/libs/BlueMap.js
new file mode 100644
index 00000000..552417c8
--- /dev/null
+++ b/BlueMapCore/src/main/webroot/js/libs/BlueMap.js
@@ -0,0 +1,483 @@
+/*
+ * This file is part of BlueMap, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) Blue (Lukas Rieger)
+ * Copyright (c) contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+import $ from 'jquery';
+import {
+ AmbientLight,
+ BackSide,
+ BufferGeometryLoader,
+ ClampToEdgeWrapping,
+ CubeGeometry,
+ DirectionalLight,
+ FileLoader,
+ FrontSide,
+ Mesh,
+ MeshBasicMaterial,
+ MeshLambertMaterial,
+ NormalBlending,
+ NearestFilter,
+ PerspectiveCamera,
+ Scene,
+ Texture,
+ TextureLoader,
+ VertexColors,
+ WebGLRenderer,
+} from 'three';
+
+import Compass from './modules/Compass.js';
+import Info from './modules/Info.js';
+import MapMenu from './modules/MapMenu.js';
+import Position from './modules/Position.js';
+import Settings from './modules/Settings.js';
+
+import Controls from './Controls.js';
+import TileManager from './TileManager.js';
+
+import { stringToImage, pathFromCoords } from './utils.js';
+
+import SKYBOX_NORTH from '../../assets/skybox/north.png';
+import SKYBOX_SOUTH from '../../assets/skybox/south.png';
+import SKYBOX_EAST from '../../assets/skybox/east.png';
+import SKYBOX_WEST from '../../assets/skybox/west.png';
+import SKYBOX_UP from '../../assets/skybox/up.png';
+import SKYBOX_DOWN from '../../assets/skybox/down.png';
+
+export default class BlueMap {
+ constructor(element, dataRoot) {
+ this.element = element;
+ this.dataRoot = dataRoot;
+
+ this.loadingNoticeElement = $('loading...
').appendTo($(this.element));
+
+ this.fileLoader = new FileLoader();
+ this.blobLoader = new FileLoader();
+ this.blobLoader.setResponseType('blob');
+ this.bufferGeometryLoader = new BufferGeometryLoader();
+
+ this.initStage();
+ this.locationHash = '';
+ this.controls = new Controls(this.camera, this.element, this.hiresScene);
+
+ this.loadSettings().then(async () => {
+ this.lowresTileManager = new TileManager(
+ this,
+ this.settings[this.map]['lowres']['viewDistance'],
+ this.loadLowresTile,
+ this.lowresScene,
+ this.settings[this.map]['lowres']['tileSize'],
+ {x: 0, z: 0}
+ );
+
+ this.hiresTileManager = new TileManager(
+ this,
+ this.settings[this.map]['hires']['viewDistance'],
+ this.loadHiresTile,
+ this.hiresScene,
+ this.settings[this.map]['hires']['tileSize'],
+ {x: 0, z: 0}
+ );
+
+ await this.loadHiresMaterial();
+ await this.loadLowresMaterial();
+
+ this.initModules();
+ this.start();
+ });
+ }
+
+ initModules() {
+ this.modules = {};
+ this.modules.compass = new Compass(this);
+ this.modules.position = new Position(this);
+ this.modules.mapMenu = new MapMenu(this);
+ this.modules.info = new Info(this);
+ this.modules.settings = new Settings(this);
+ }
+
+ changeMap(map) {
+ this.hiresTileManager.close();
+ this.lowresTileManager.close();
+
+ this.map = map;
+ this.controls.resetPosition();
+
+ this.lowresTileManager = new TileManager(
+ this,
+ this.settings[this.map]['lowres']['viewDistance'],
+ this.loadLowresTile,
+ this.lowresScene,
+ this.settings[this.map]['lowres']['tileSize'],
+ {x: 0, z: 0}
+ );
+
+ this.hiresTileManager = new TileManager(
+ this,
+ this.settings[this.map]['hires']['viewDistance'],
+ this.loadHiresTile,
+ this.hiresScene,
+ this.settings[this.map]['hires']['tileSize'],
+ {x: 0, z: 0}
+ );
+
+ this.lowresTileManager.update();
+ this.hiresTileManager.update();
+
+ document.dispatchEvent(new Event('bluemap-map-change'));
+ }
+
+ loadLocationHash() {
+ let hashVars = window.location.hash.substring(1).split(':');
+ if (hashVars.length >= 1){
+ if (this.settings[hashVars[0]] !== undefined && this.map !== hashVars[0]){
+ this.changeMap(hashVars[0]);
+ }
+ }
+ if (hashVars.length >= 3){
+ let x = parseInt(hashVars[1]);
+ let z = parseInt(hashVars[2]);
+ if (!isNaN(x) && !isNaN(z)){
+ this.controls.targetPosition.x = x + 0.5;
+ this.controls.targetPosition.z = z + 0.5;
+ }
+ }
+ if (hashVars.length >= 6){
+ let dir = parseFloat(hashVars[3]);
+ let dist = parseFloat(hashVars[4]);
+ let angle = parseFloat(hashVars[5]);
+ if (!isNaN(dir)) this.controls.targetDirection = dir;
+ if (!isNaN(dist)) this.controls.targetDistance = dist;
+ if (!isNaN(angle)) this.controls.targetAngle = angle;
+ this.controls.direction = this.controls.targetDirection;
+ this.controls.distance = this.controls.targetDistance;
+ this.controls.angle = this.controls.targetAngle;
+ this.controls.targetPosition.y = this.controls.minHeight;
+ this.controls.position.copy(this.controls.targetPosition);
+ }
+ if (hashVars.length >= 7){
+ let height = parseInt(hashVars[6]);
+ if (!isNaN(height)){
+ this.controls.minHeight = height;
+ this.controls.targetPosition.y = height;
+ this.controls.position.copy(this.controls.targetPosition);
+ }
+ }
+ }
+
+ start() {
+ this.loadingNoticeElement.remove();
+
+ this.loadLocationHash();
+
+ $(window).on('hashchange', () => {
+ if (this.locationHash === window.location.hash) return;
+ this.loadLocationHash();
+ });
+
+ this.update();
+ this.render();
+
+ this.lowresTileManager.update();
+ this.hiresTileManager.update();
+ }
+
+ update = () => {
+ setTimeout(this.update, 1000);
+
+ this.lowresTileManager.setPosition(this.controls.targetPosition);
+ this.hiresTileManager.setPosition(this.controls.targetPosition);
+
+ this.locationHash =
+ '#' + this.map
+ + ':' + Math.floor(this.controls.targetPosition.x)
+ + ':' + Math.floor(this.controls.targetPosition.z)
+ + ':' + Math.round(this.controls.targetDirection * 100) / 100
+ + ':' + Math.round(this.controls.targetDistance * 100) / 100
+ + ':' + Math.ceil(this.controls.targetAngle * 100) / 100
+ + ':' + Math.floor(this.controls.targetPosition.y);
+ history.replaceState(undefined, undefined, this.locationHash);
+ };
+
+ render = () => {
+ requestAnimationFrame(this.render);
+
+ if (this.controls.update()) this.updateFrame = true;
+
+ if (!this.updateFrame) return;
+ this.updateFrame = false;
+
+ document.dispatchEvent(new Event('bluemap-update-frame'));
+
+ this.skyboxCamera.rotation.copy(this.camera.rotation);
+ this.skyboxCamera.updateProjectionMatrix();
+
+ this.renderer.clear();
+ this.renderer.render(this.skyboxScene, this.skyboxCamera, this.renderer.getRenderTarget(), false);
+ this.renderer.clearDepth();
+ this.renderer.render(this.lowresScene, this.camera, this.renderer.getRenderTarget(), false);
+ if (this.camera.position.y < 400) {
+ this.renderer.clearDepth();
+ this.renderer.render(this.hiresScene, this.camera, this.renderer.getRenderTarget(), false);
+ }
+ }
+
+ handleContainerResize = () => {
+ this.camera.aspect = this.element.clientWidth / this.element.clientHeight;
+ this.camera.updateProjectionMatrix();
+
+ this.skyboxCamera.aspect = this.element.clientWidth / this.element.clientHeight;
+ this.skyboxCamera.updateProjectionMatrix();
+
+ this.renderer.setSize(this.element.clientWidth * this.quality, this.element.clientHeight * this.quality);
+ $(this.renderer.domElement)
+ .css('width', this.element.clientWidth)
+ .css('height', this.element.clientHeight);
+
+ this.updateFrame = true;
+ }
+
+ async loadSettings() {
+ return new Promise(resolve => {
+ this.fileLoader.load(this.dataRoot + 'settings.json', settings => {
+ this.settings = JSON.parse(settings);
+ this.maps = [];
+ for (let map in this.settings) {
+ if (this.settings.hasOwnProperty(map) && this.settings[map].enabled){
+ this.maps.push(map);
+ }
+ }
+
+ this.maps.sort((map1, map2) => {
+ var sort = this.settings[map1].ordinal - this.settings[map2].ordinal;
+ if (isNaN(sort)) return 0;
+ return sort;
+ });
+
+ this.map = this.maps[0];
+ resolve();
+ });
+ });
+ }
+
+ initStage() {
+ this.updateFrame = true;
+ this.quality = 1;
+
+ this.renderer = new WebGLRenderer({
+ alpha: true,
+ antialias: true,
+ sortObjects: false,
+ preserveDrawingBuffer: true,
+ logarithmicDepthBuffer: true,
+ });
+ this.renderer.autoClear = false;
+
+ this.camera = new PerspectiveCamera(75, this.element.scrollWidth / this.element.scrollHeight, 0.1, 10000);
+ this.camera.updateProjectionMatrix();
+
+ this.skyboxCamera = this.camera.clone();
+ this.skyboxCamera.updateProjectionMatrix();
+
+ this.skyboxScene = new Scene();
+ this.skyboxScene.ambient = new AmbientLight(0xffffff, 1);
+ this.skyboxScene.add(this.skyboxScene.ambient);
+ this.skyboxScene.add(this.createSkybox());
+
+ this.lowresScene = new Scene();
+ this.lowresScene.ambient = new AmbientLight(0xffffff, 0.6);
+ this.lowresScene.add(this.lowresScene.ambient);
+ this.lowresScene.sunLight = new DirectionalLight(0xccccbb, 0.7);
+ this.lowresScene.sunLight.position.set(1, 5, 3);
+ this.lowresScene.add(this.lowresScene.sunLight);
+
+ this.hiresScene = new Scene();
+ this.hiresScene.ambient = new AmbientLight(0xffffff, 1);
+ this.hiresScene.add(this.hiresScene.ambient);
+ this.hiresScene.sunLight = new DirectionalLight(0xccccbb, 0.2);
+ this.hiresScene.sunLight.position.set(1, 5, 3);
+ this.hiresScene.add(this.hiresScene.sunLight);
+
+ this.element.append(this.renderer.domElement);
+ this.handleContainerResize();
+
+ $(window).resize(this.handleContainerResize);
+ }
+
+ createSkybox() {
+ let geometry = new CubeGeometry(10, 10, 10);
+ let material = [
+ new MeshBasicMaterial({
+ map: new TextureLoader().load(SKYBOX_SOUTH),
+ side: BackSide
+ }),
+ new MeshBasicMaterial({
+ map: new TextureLoader().load(SKYBOX_NORTH),
+ side: BackSide
+ }),
+ new MeshBasicMaterial({
+ map: new TextureLoader().load(SKYBOX_UP),
+ side: BackSide
+ }),
+ new MeshBasicMaterial({
+ map: new TextureLoader().load(SKYBOX_DOWN),
+ side: BackSide
+ }),
+ new MeshBasicMaterial({
+ map: new TextureLoader().load(SKYBOX_EAST),
+ side: BackSide
+ }),
+ new MeshBasicMaterial({
+ map: new TextureLoader().load(SKYBOX_WEST),
+ side: BackSide
+ })
+ ];
+ return new Mesh(geometry, material);
+ }
+
+ async loadHiresMaterial() {
+ return new Promise(resolve => {
+ this.fileLoader.load(this.dataRoot + 'textures.json', textures => {
+ textures = JSON.parse(textures);
+
+ let materials = [];
+ for (let i = 0; i < textures['textures'].length; i++) {
+ let t = textures['textures'][i];
+
+ let material = new MeshLambertMaterial({
+ transparent: t['transparent'],
+ alphaTest: 0.01,
+ depthWrite: true,
+ depthTest: true,
+ blending: NormalBlending,
+ vertexColors: VertexColors,
+ side: FrontSide,
+ wireframe: false
+ });
+
+ let texture = new Texture();
+ texture.image = stringToImage(t['texture']);
+
+ texture.premultiplyAlpha = false;
+ texture.generateMipmaps = false;
+ texture.magFilter = NearestFilter;
+ texture.minFilter = NearestFilter;
+ texture.wrapS = ClampToEdgeWrapping;
+ texture.wrapT = ClampToEdgeWrapping;
+ texture.flipY = false;
+ texture.needsUpdate = true;
+ texture.flatShading = true;
+
+ material.map = texture;
+ material.needsUpdate = true;
+
+ materials[i] = material;
+ }
+
+ this.hiresMaterial = materials;
+
+ resolve();
+ });
+ });
+ }
+
+ async loadLowresMaterial() {
+ this.lowresMaterial = new MeshLambertMaterial({
+ transparent: false,
+ depthWrite: true,
+ depthTest: true,
+ vertexColors: VertexColors,
+ side: FrontSide,
+ wireframe: false
+ });
+ }
+
+ async loadHiresTile(tileX, tileZ) {
+ let path = this.dataRoot + this.map + '/hires/';
+ path += pathFromCoords(tileX, tileZ);
+ path += '.json';
+
+ return new Promise((resolve, reject) => {
+ this.bufferGeometryLoader.load(path, geometry => {
+ let object = new Mesh(geometry, this.hiresMaterial);
+
+ let tileSize = this.settings[this.map]['hires']['tileSize'];
+ let translate = this.settings[this.map]['hires']['translate'];
+ let scale = this.settings[this.map]['hires']['scale'];
+ object.position.set(tileX * tileSize.x + translate.x, 0, tileZ * tileSize.z + translate.z);
+ object.scale.set(scale.x, 1, scale.z);
+
+ resolve(object);
+ }, () => {
+ }, reject);
+ });
+ }
+
+ async loadLowresTile(tileX, tileZ) {
+ let path = this.dataRoot + this.map + '/lowres/';
+ path += pathFromCoords(tileX, tileZ);
+ path += '.json';
+
+ return new Promise((reslove, reject) => {
+ this.bufferGeometryLoader.load(path, geometry => {
+ let object = new Mesh(geometry, this.lowresMaterial);
+
+ let tileSize = this.settings[this.map]['lowres']['tileSize'];
+ let translate = this.settings[this.map]['lowres']['translate'];
+ let scale = this.settings[this.map]['lowres']['scale'];
+ object.position.set(tileX * tileSize.x + translate.x, 0, tileZ * tileSize.z + translate.z);
+ object.scale.set(scale.x, 1, scale.z);
+
+ reslove(object);
+ }, () => {
+ }, reject);
+ })
+ }
+
+ // ###### UI ######
+
+ alert(content) {
+ let alertBox = $('#alert-box');
+ if (alertBox.length === 0){
+ alertBox = $('
').appendTo(this.element);
+ }
+
+ let displayAlert = () => {
+ let alert = $(``).appendTo(alertBox);
+ alert.find('.alert-close-button').click(() => {
+ alert.fadeOut(200, () => alert.remove());
+ });
+ alert.fadeIn(200);
+ };
+
+ let oldAlerts = alertBox.find('.alert');
+ if (oldAlerts.length > 0){
+ alertBox.fadeOut(200, () => {
+ alertBox.html('');
+ alertBox.show();
+ displayAlert();
+ });
+ } else {
+ displayAlert();
+ }
+ }
+}
diff --git a/BlueMapCore/src/main/webroot/js/libs/Controls.js b/BlueMapCore/src/main/webroot/js/libs/Controls.js
new file mode 100644
index 00000000..4008accb
--- /dev/null
+++ b/BlueMapCore/src/main/webroot/js/libs/Controls.js
@@ -0,0 +1,297 @@
+/*
+ * This file is part of BlueMap, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) Blue (Lukas Rieger)
+ * Copyright (c) contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the 'Software'), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Softwarevent.
+ *
+ * THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARevent.
+ */
+import $ from 'jquery';
+import {
+ Euler,
+ Raycaster,
+ Vector2,
+ Vector3,
+ MOUSE
+} from 'three';
+
+import { Vector2_ZERO } from './utils.js';
+
+export default class Controls {
+ static KEYS = {
+ LEFT: 37,
+ UP: 38,
+ RIGHT: 39,
+ DOWN: 40,
+ ORBIT: MOUSE.RIGHT,
+ MOVE: MOUSE.LEFT
+ };
+ static STATES = {
+ NONE: -1,
+ ORBIT: 0,
+ MOVE: 1,
+ };
+
+ /**
+ * targetHeightScene and cameraHeightScene are scenes of objects that are checked via raycasting for a height for the target and the camera
+ */
+ constructor(camera, element, heightScene) {
+ this.settings = {
+ zoom: {
+ min: 10,
+ max: 2000,
+ speed: 1.5,
+ smooth: 0.2,
+ },
+ move: {
+ speed: 1.75,
+ smooth: 0.3,
+ smoothY: 0.075,
+ },
+ tilt: {
+ max: Math.PI / 2.1,
+ speed: 1.5,
+ smooth: 0.3,
+ },
+ rotate: {
+ speed: 1.5,
+ smooth: 0.3,
+ }
+ };
+
+ this.camera = camera;
+ this.element = element;
+ this.heightScene = heightScene;
+ this.minHeight = 0;
+
+ this.raycaster = new Raycaster();
+ this.rayDirection = new Vector3(0, -1, 0);
+
+ this.resetPosition();
+
+ this.mouse = new Vector2(0, 0);
+ this.lastMouse = new Vector2(0, 0);
+ this.deltaMouse = new Vector2(0, 0);
+
+ //variables used to calculate with (to prevent object creation every update)
+ this.orbitRot = new Euler(0, 0, 0, 'YXZ');
+ this.cameraPosDelta = new Vector3(0, 0, 0);
+ this.moveDelta = new Vector2(0, 0);
+
+ this.keyStates = {}
+ this.state = Controls.STATES.NONE;
+
+ let canvas = $(this.element).find('canvas').get(0);
+ window.addEventListener('contextmenu', event => {
+ event.preventDefault();
+ }, false);
+ canvas.addEventListener('mousedown', this.onMouseDown, false);
+ window.addEventListener('mousemove', this.onMouseMove, false);
+ window.addEventListener('mouseup', this.onMouseUp, false);
+ canvas.addEventListener('wheel', this.onMouseWheel, false);
+ window.addEventListener('keydown', this.onKeyDown, false);
+ window.addEventListener('keyup', this.onKeyUp, false);
+
+ this.camera.position.set(0, 1000, 0);
+ this.camera.lookAt(this.position);
+ this.camera.updateProjectionMatrix();
+ }
+
+ resetPosition() {
+ this.position = new Vector3(0, 70, 0);
+ this.targetPosition = new Vector3(0, 70, 0);
+
+ this.distance = 5000;
+ this.targetDistance = 1000;
+
+ this.direction = 0;
+ this.targetDirection = 0;
+
+ this.angle = 0;
+ this.targetAngle = 0;
+ }
+
+ update() {
+ this.updateMouseMoves();
+
+ let changed = false;
+
+ let zoomLerp = (this.distance - 100) / 200;
+ if (zoomLerp < 0) zoomLerp = 0;
+ if (zoomLerp > 1) zoomLerp = 1;
+ this.targetPosition.y = 300 * zoomLerp + this.minHeight * (1 - zoomLerp);
+
+ this.position.x += (this.targetPosition.x - this.position.x) * this.settings.move.smooth;
+ this.position.y += (this.targetPosition.y - this.position.y) * this.settings.move.smoothY;
+ this.position.z += (this.targetPosition.z - this.position.z) * this.settings.move.smooth;
+
+ this.distance += (this.targetDistance - this.distance) * this.settings.zoom.smooth;
+
+ let deltaDir = (this.targetDirection - this.direction) * this.settings.rotate.smooth;
+ this.direction += deltaDir;
+ changed = changed || Math.abs(deltaDir) > 0.001;
+
+ let max = Math.min(this.settings.tilt.max, this.settings.tilt.max - Math.pow(((this.distance - this.settings.zoom.min) / (this.settings.zoom.max - this.settings.zoom.min)) * Math.pow(this.settings.tilt.max, 4), 1/4));
+ if (this.targetAngle > max) this.targetAngle = max;
+ if (this.targetAngle < 0.01) this.targetAngle = 0.001;
+ let deltaAngle = (this.targetAngle - this.angle) * this.settings.tilt.smooth;
+ this.angle += deltaAngle;
+ changed = changed || Math.abs(deltaAngle) > 0.001;
+
+ let last = this.camera.position.x + this.camera.position.y + this.camera.position.z;
+ this.orbitRot.set(this.angle, this.direction, 0);
+ this.cameraPosDelta.set(0, this.distance, 0).applyEuler(this.orbitRot);
+
+ this.camera.position.set(this.position.x + this.cameraPosDelta.x, this.position.y + this.cameraPosDelta.y, this.position.z + this.cameraPosDelta.z);
+ let move = last - (this.camera.position.x + this.camera.position.y + this.camera.position.z);
+
+ changed = changed || Math.abs(move) > 0.001;
+
+ if (changed) {
+ this.camera.lookAt(this.position);
+ this.camera.updateProjectionMatrix();
+
+ this.updateHeights();
+ }
+
+ return changed;
+ }
+
+ updateHeights() {
+ //TODO: this can be performance-improved by only intersecting the correct tile?
+
+ 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(this.heightScene.children);
+ if (intersects.length > 0){
+ this.minHeight = intersects[0].point.y;
+ //this.targetPosition.y = this.minHeight;
+ } else {
+ //this.targetPosition.y = 0;
+ }
+
+ rayStart.set(this.camera.position.x, 300, this.camera.position.z);
+ this.raycaster.set(rayStart, this.rayDirection);
+ intersects.length = 0;
+ intersects = this.raycaster.intersectObjects(this.heightScene.children);
+ if (intersects.length > 0){
+ if (intersects[0].point.y > this.minHeight){
+ this.minHeight = intersects[0].point.y;
+ }
+ }
+ };
+
+ updateMouseMoves = () => {
+ this.deltaMouse.set(this.lastMouse.x - this.mouse.x, this.lastMouse.y - this.mouse.y);
+
+ this.moveDelta.x = 0;
+ this.moveDelta.y = 0;
+
+ if (this.keyStates[Controls.KEYS.UP]){
+ this.moveDelta.y -= 20;
+ }
+ if (this.keyStates[Controls.KEYS.DOWN]){
+ this.moveDelta.y += 20;
+ }
+ if (this.keyStates[Controls.KEYS.LEFT]){
+ this.moveDelta.x -= 20;
+ }
+ if (this.keyStates[Controls.KEYS.RIGHT]){
+ this.moveDelta.x += 20;
+ }
+
+ if (this.state === Controls.STATES.MOVE) {
+ if (this.deltaMouse.x === 0 && this.deltaMouse.y === 0) return;
+ this.moveDelta.copy(this.deltaMouse);
+ }
+
+ if (this.moveDelta.x !== 0 || this.moveDelta.y !== 0) {
+ this.moveDelta.rotateAround(Vector2_ZERO, -this.direction);
+ this.targetPosition.set(
+ this.targetPosition.x + (this.moveDelta.x * this.distance / this.element.clientHeight * this.settings.move.speed),
+ this.targetPosition.y,
+ this.targetPosition.z + (this.moveDelta.y * this.distance / this.element.clientHeight * this.settings.move.speed)
+ );
+ }
+
+ if (this.state === Controls.STATES.ORBIT) {
+ this.targetDirection += (this.deltaMouse.x / this.element.clientHeight * Math.PI);
+ this.targetAngle += (this.deltaMouse.y / this.element.clientHeight * Math.PI);
+ }
+
+ this.lastMouse.copy(this.mouse);
+ };
+
+ onMouseWheel = event => {
+ if (event.deltaY > 0) {
+ this.targetDistance *= this.settings.zoom.speed;
+ } else if (event.deltaY < 0) {
+ this.targetDistance /= this.settings.zoom.speed;
+ }
+
+ if (this.targetDistance < this.settings.zoom.min) this.targetDistance = this.settings.zoom.min;
+ if (this.targetDistance > this.settings.zoom.max) this.targetDistance = this.settings.zoom.max;
+ }
+
+ onMouseMove = event => {
+ this.mouse.set(event.clientX, event.clientY);
+
+ if (this.state !== Controls.STATES.NONE){
+ event.preventDefault();
+ }
+ }
+
+ onMouseDown = event => {
+ if (this.state !== Controls.STATES.NONE) return;
+
+ switch (event.button) {
+ case Controls.KEYS.MOVE :
+ this.state = Controls.STATES.MOVE;
+ event.preventDefault();
+ break;
+ case Controls.KEYS.ORBIT :
+ this.state = Controls.STATES.ORBIT;
+ event.preventDefault();
+ break;
+ }
+ }
+
+ onMouseUp = event => {
+ if (this.state === Controls.STATES.NONE) return;
+
+ switch (event.button) {
+ case Controls.KEYS.MOVE :
+ if (this.state === Controls.STATES.MOVE) this.state = Controls.STATES.NONE;
+ break;
+ case Controls.KEYS.ORBIT :
+ if (this.state === Controls.STATES.ORBIT) this.state = Controls.STATES.NONE;
+ break;
+ }
+ }
+
+ onKeyDown = event => {
+ this.keyStates[event.keyCode] = true;
+ }
+
+ onKeyUp = e => {
+ this.keyStates[event.keyCode] = false;
+ }
+}
diff --git a/BlueMapCore/src/main/webroot/js/libs/Tile.js b/BlueMapCore/src/main/webroot/js/libs/Tile.js
new file mode 100644
index 00000000..cb3e3f8d
--- /dev/null
+++ b/BlueMapCore/src/main/webroot/js/libs/Tile.js
@@ -0,0 +1,59 @@
+/*
+ * This file is part of BlueMap, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) Blue (Lukas Rieger)
+ * Copyright (c) contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+export default class Tile {
+ isLoading = false;
+ disposed = false;
+ model = null;
+
+ constructor(scene, x, z) {
+ this.scene = scene;
+ this.x = x;
+ this.z = z;
+ }
+
+ setModel(model) {
+ this.disposeModel();
+
+ if (model) {
+ this.model = model;
+ this.scene.add(model);
+
+ //console.log('Added tile:', this.x, this.z);
+ }
+ }
+
+ disposeModel() {
+ this.disposed = true;
+
+ if (this.model) {
+ this.scene.remove(this.model);
+ this.model.geometry.dispose();
+ delete this.model;
+
+ //console.log('Removed tile:', this.x, this.z);
+ }
+ }
+}
diff --git a/BlueMapCore/src/main/webroot/js/libs/TileManager.js b/BlueMapCore/src/main/webroot/js/libs/TileManager.js
new file mode 100644
index 00000000..6640a3a9
--- /dev/null
+++ b/BlueMapCore/src/main/webroot/js/libs/TileManager.js
@@ -0,0 +1,184 @@
+/*
+ * This file is part of BlueMap, licensed under the MIT License (MIT).
+ *
+ * Copyright (c) Blue (Lukas Rieger)
+ * Copyright (c) contributors
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+import { Vector2 } from 'three';
+
+import Tile from './Tile.js';
+
+import { hashTile } from './utils.js';
+
+export default class TileManager {
+ constructor(blueMap, viewDistance, tileLoader, scene, tileSize, position) {
+ this.blueMap = blueMap;
+ this.viewDistance = viewDistance;
+ this.tileLoader = tileLoader;
+ this.scene = scene;
+ this.tileSize = new Vector2(tileSize.x, tileSize.z);
+
+ this.tile = new Vector2(position.x, position.z);
+ this.lastTile = this.tile.clone();
+
+ this.closed = false;
+ this.currentlyLoading = 0;
+ this.updateTimeout = null;
+
+ this.tiles = {};
+ }
+
+ setPosition(center) {
+ this.tile.set(center.x, center.z).divide(this.tileSize).floor();
+
+ if (!this.tile.equals(this.lastTile) && !this.closed) {
+ this.update();
+ this.lastTile.copy(this.tile);
+ }
+ }
+
+ update() {
+ if (this.closed) return;
+
+ // free a loader so if there was an error loading a tile we don't get stuck forever with the blocked loading process
+ this.currentlyLoading--;
+ if (this.currentlyLoading < 0) this.currentlyLoading = 0;
+
+ this.removeFarTiles();
+ this.loadCloseTiles();
+ }
+
+ removeFarTiles() {
+ let keys = Object.keys(this.tiles);
+ for (let i = 0; i < keys.length; i++) {
+ if (!this.tiles.hasOwnProperty(keys[i])) continue;
+
+ let tile = this.tiles[keys[i]];
+
+ let vd = this.viewDistance;
+
+ if (
+ tile.x + vd < this.tile.x ||
+ tile.x - vd > this.tile.x ||
+ tile.z + vd < this.tile.y ||
+ tile.z - vd > this.tile.y
+ ) {
+ tile.disposeModel();
+ delete this.tiles[keys[i]];
+ }
+ }
+ }
+
+ removeAllTiles() {
+ let keys = Object.keys(this.tiles);
+ for (let i = 0; i < keys.length; i++) {
+ if (!this.tiles.hasOwnProperty(keys[i])) continue;
+
+ let tile = this.tiles[keys[i]];
+ tile.disposeModel();
+ delete this.tiles[keys[i]];
+ }
+ }
+
+ close() {
+ this.closed = true;
+ this.removeAllTiles();
+ }
+
+ loadCloseTiles() {
+ if (this.closed) return;
+
+ if (this.currentlyLoading < 8) {
+ if (!this.loadNextTile()) return;
+ }
+
+ if (this.updateTimeout) clearTimeout(this.updateTimeout);
+ this.updateTimeout = setTimeout(() => this.loadCloseTiles(), 0);
+ }
+
+ loadNextTile() {
+ let x = 0;
+ let z = 0;
+ let d = 1;
+ let m = 1;
+
+ while (m < this.viewDistance * 2) {
+ while (2 * x * d < m) {
+ if (this.tryLoadTile(this.tile.x + x, this.tile.y + z)) return true;
+ x = x + d;
+ }
+ while (2 * z * d < m) {
+ if (this.tryLoadTile(this.tile.x + x, this.tile.y + z)) return true;
+ z = z + d;
+ }
+ d = -1 * d;
+ m = m + 1;
+ }
+
+ return false;
+ }
+
+ tryLoadTile(x, z) {
+ if (this.closed) return false;
+
+ let tileHash = hashTile(x, z);
+
+ let tile = this.tiles[tileHash];
+ if (tile !== undefined) return false;
+
+ tile = new Tile(this.scene, x, z);
+ tile.isLoading = true;
+
+ this.currentlyLoading++;
+
+ this.tiles[tileHash] = tile;
+
+ this.tileLoader.call(this.blueMap, x, z)
+ .then(model => {
+ tile.isLoading = false;
+
+ if (tile.disposed || this.closed) {
+ model.geometry.dispose();
+ tile.disposeModel();
+ delete this.tiles[tileHash];
+ return;
+ }
+
+ this.tiles[tileHash] = tile;
+ tile.setModel(model);
+
+ this.blueMap.updateFrame = true;
+
+ this.currentlyLoading--;
+ if (this.currentlyLoading < 0) this.currentlyLoading = 0;
+ }).catch(error => {
+ tile.isLoading = false;
+ tile.disposeModel();
+
+ this.currentlyLoading--;
+
+ //console.log("Failed to load tile: ", x, z);
+ });
+
+ return true;
+ }
+}
diff --git a/BlueMapCore/src/main/webroot/js/libs/bluemap.js b/BlueMapCore/src/main/webroot/js/libs/bluemap.js
deleted file mode 100644
index b6f86269..00000000
--- a/BlueMapCore/src/main/webroot/js/libs/bluemap.js
+++ /dev/null
@@ -1,1208 +0,0 @@
-/*
- * This file is part of BlueMap, licensed under the MIT License (MIT).
- *
- * Copyright (c) Blue (Lukas Rieger)
- * Copyright (c) contributors
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-BlueMap = function (element, dataRoot) {
- this.element = element;
- this.dataRoot = dataRoot;
-
- this.loadingNoticeElement = $('loading...
').appendTo($(this.element));
-
- this.fileLoader = new THREE.FileLoader();
- this.blobLoader = new THREE.FileLoader();
- this.blobLoader.setResponseType("blob");
- this.bufferGeometryLoader = new THREE.BufferGeometryLoader();
-
- this.initStage();
- this.locationHash = "";
- this.controls = new BlueMap.Controls(this.camera, this.element, this.hiresScene);
-
- this.loadSettings(function () {
- this.lowresTileManager = new BlueMap.TileManager(
- this,
- this.settings[this.map]["lowres"]["viewDistance"],
- this.loadLowresTile,
- this.lowresScene,
- this.settings[this.map]["lowres"]["tileSize"],
- {x: 0, z: 0}
- );
-
- this.hiresTileManager = new BlueMap.TileManager(
- this,
- this.settings[this.map]["hires"]["viewDistance"],
- this.loadHiresTile,
- this.hiresScene,
- this.settings[this.map]["hires"]["tileSize"],
- {x: 0, z: 0}
- );
-
- this.loadHiresMaterial(function () {
- this.loadLowresMaterial(function () {
- this.initModules();
- this.start();
- });
- });
- });
-};
-
-BlueMap.prototype.initModules = function () {
- this.modules = {};
-
- this.modules.compass = new BlueMap.Module.Compass(this);
- this.modules.position = new BlueMap.Module.Position(this);
- this.modules.mapMenu = new BlueMap.Module.MapMenu(this);
- this.modules.info = new BlueMap.Module.Info(this);
- this.modules.settings = new BlueMap.Module.Settings(this);
-};
-
-BlueMap.prototype.changeMap = function (map) {
- this.hiresTileManager.close();
- this.lowresTileManager.close();
-
- this.map = map;
- this.controls.resetPosition();
-
- this.lowresTileManager = new BlueMap.TileManager(
- this,
- this.settings[this.map]["lowres"]["viewDistance"],
- this.loadLowresTile,
- this.lowresScene,
- this.settings[this.map]["lowres"]["tileSize"],
- {x: 0, z: 0}
- );
-
- this.hiresTileManager = new BlueMap.TileManager(
- this,
- this.settings[this.map]["hires"]["viewDistance"],
- this.loadHiresTile,
- this.hiresScene,
- this.settings[this.map]["hires"]["tileSize"],
- {x: 0, z: 0}
- );
-
- this.lowresTileManager.update();
- this.hiresTileManager.update();
-
- document.dispatchEvent(new Event("bluemap-map-change"));
-};
-
-BlueMap.prototype.loadLocationHash = function(){
- let hashVars = window.location.hash.substring(1).split(":");
- if (hashVars.length >= 1){
- if (this.settings[hashVars[0]] !== undefined && this.map !== hashVars[0]){
- this.changeMap(hashVars[0]);
- }
- }
- if (hashVars.length >= 3){
- let x = parseInt(hashVars[1]);
- let z = parseInt(hashVars[2]);
- if (!isNaN(x) && !isNaN(z)){
- this.controls.targetPosition.x = x + 0.5;
- this.controls.targetPosition.z = z + 0.5;
- }
- }
- if (hashVars.length >= 6){
- let dir = parseFloat(hashVars[3]);
- let dist = parseFloat(hashVars[4]);
- let angle = parseFloat(hashVars[5]);
- if (!isNaN(dir)) this.controls.targetDirection = dir;
- if (!isNaN(dist)) this.controls.targetDistance = dist;
- if (!isNaN(angle)) this.controls.targetAngle = angle;
- this.controls.direction = this.controls.targetDirection;
- this.controls.distance = this.controls.targetDistance;
- this.controls.angle = this.controls.targetAngle;
- this.controls.targetPosition.y = this.controls.minHeight;
- this.controls.position.copy(this.controls.targetPosition);
- }
- if (hashVars.length >= 7){
- let height = parseInt(hashVars[6]);
- if (!isNaN(height)){
- this.controls.minHeight = height;
- this.controls.targetPosition.y = height;
- this.controls.position.copy(this.controls.targetPosition);
- }
- }
-};
-
-BlueMap.prototype.start = function () {
- let scope = this;
-
- this.loadingNoticeElement.remove();
-
- this.loadLocationHash();
-
- $(window).on("hashchange", function(evt){
- if (scope.locationHash === window.location.hash) return;
- scope.loadLocationHash();
- });
-
- this.update();
- this.render();
-
- this.lowresTileManager.update();
- this.hiresTileManager.update();
-};
-
-BlueMap.prototype.update = function () {
- let scope = this;
- setTimeout(function () {
- scope.update()
- }, 1000);
-
- this.lowresTileManager.setPosition(this.controls.targetPosition);
- this.hiresTileManager.setPosition(this.controls.targetPosition);
-
- this.locationHash =
- "#" + this.map
- + ":" + Math.floor(this.controls.targetPosition.x)
- + ":" + Math.floor(this.controls.targetPosition.z)
- + ":" + Math.round(this.controls.targetDirection * 100) / 100
- + ":" + Math.round(this.controls.targetDistance * 100) / 100
- + ":" + Math.ceil(this.controls.targetAngle * 100) / 100
- + ":" + Math.floor(this.controls.targetPosition.y);
- history.replaceState(undefined, undefined, this.locationHash);
-};
-
-BlueMap.prototype.render = function () {
- let scope = this;
- requestAnimationFrame(function () {
- scope.render()
- });
-
- if (this.controls.update()) this.updateFrame = true;
-
- if (!this.updateFrame) return;
- this.updateFrame = false;
-
- document.dispatchEvent(new Event("bluemap-update-frame"));
-
- this.skyboxCamera.rotation.copy(this.camera.rotation);
- this.skyboxCamera.updateProjectionMatrix();
-
-
- this.renderer.clear();
- this.renderer.render(this.skyboxScene, this.skyboxCamera, this.renderer.getRenderTarget(), false);
- this.renderer.clearDepth();
- this.renderer.render(this.lowresScene, this.camera, this.renderer.getRenderTarget(), false);
- if (this.camera.position.y < 400) {
- this.renderer.clearDepth();
- this.renderer.render(this.hiresScene, this.camera, this.renderer.getRenderTarget(), false);
- }
-};
-
-BlueMap.prototype.handleContainerResize = function () {
- this.camera.aspect = this.element.clientWidth / this.element.clientHeight;
- this.camera.updateProjectionMatrix();
-
- this.skyboxCamera.aspect = this.element.clientWidth / this.element.clientHeight;
- this.skyboxCamera.updateProjectionMatrix();
-
- this.renderer.setSize(this.element.clientWidth * this.quality, this.element.clientHeight * this.quality);
- $(this.renderer.domElement)
- .css("width", this.element.clientWidth)
- .css("height", this.element.clientHeight);
-
- this.updateFrame = true;
-};
-
-BlueMap.prototype.loadSettings = function (callback) {
- let scope = this;
-
- this.fileLoader.load(this.dataRoot + "settings.json", function (settings) {
- scope.settings = JSON.parse(settings);
-
- scope.maps = [];
- for (map in scope.settings){
- if (scope.settings.hasOwnProperty(map) && scope.settings[map].enabled){
- scope.maps.push(map);
- }
- }
-
- scope.maps.sort(function (map1, map2) {
- var sort = scope.settings[map1].ordinal - scope.settings[map2].ordinal;
- if (isNaN(sort)) return 0;
- return sort;
- });
-
- scope.map = scope.maps[0];
-
- callback.call(scope);
- });
-};
-
-BlueMap.prototype.initStage = function () {
- let scope = this;
-
- this.updateFrame = true;
- this.quality = 1;
-
- this.renderer = new THREE.WebGLRenderer({
- alpha: true,
- antialias: true,
- sortObjects: false,
- preserveDrawingBuffer: true,
- logarithmicDepthBuffer: true,
- });
- this.renderer.autoClear = false;
-
- this.camera = new THREE.PerspectiveCamera(75, this.element.scrollWidth / this.element.scrollHeight, 0.1, 10000);
- this.camera.updateProjectionMatrix();
-
- this.skyboxCamera = this.camera.clone();
- this.skyboxCamera.updateProjectionMatrix();
-
- this.skyboxScene = new THREE.Scene();
- this.skyboxScene.ambient = new THREE.AmbientLight(0xffffff, 1);
- this.skyboxScene.add(this.skyboxScene.ambient);
- this.skyboxScene.add(this.createSkybox());
-
- this.lowresScene = new THREE.Scene();
- this.lowresScene.ambient = new THREE.AmbientLight(0xffffff, 0.6);
- this.lowresScene.add(this.lowresScene.ambient);
- this.lowresScene.sunLight = new THREE.DirectionalLight(0xccccbb, 0.7);
- this.lowresScene.sunLight.position.set(1, 5, 3);
- this.lowresScene.add(this.lowresScene.sunLight);
-
- this.hiresScene = new THREE.Scene();
- this.hiresScene.ambient = new THREE.AmbientLight(0xffffff, 1);
- this.hiresScene.add(this.hiresScene.ambient);
- this.hiresScene.sunLight = new THREE.DirectionalLight(0xccccbb, 0.2);
- this.hiresScene.sunLight.position.set(1, 5, 3);
- this.hiresScene.add(this.hiresScene.sunLight);
-
- this.element.append(this.renderer.domElement);
- this.handleContainerResize();
-
- $(window).resize(function () {
- scope.handleContainerResize()
- });
-};
-
-BlueMap.prototype.createSkybox = function(){
- let geometry = new THREE.CubeGeometry(10, 10, 10);
- let material = [
- new THREE.MeshBasicMaterial({
- map: new THREE.TextureLoader().load('assets/skybox/south.png'),
- side: THREE.BackSide
- }),
- new THREE.MeshBasicMaterial({
- map: new THREE.TextureLoader().load('assets/skybox/north.png'),
- side: THREE.BackSide
- }),
- new THREE.MeshBasicMaterial({
- map: new THREE.TextureLoader().load('assets/skybox/up.png'),
- side: THREE.BackSide
- }),
- new THREE.MeshBasicMaterial({
- map: new THREE.TextureLoader().load('assets/skybox/down.png'),
- side: THREE.BackSide
- }),
- new THREE.MeshBasicMaterial({
- map: new THREE.TextureLoader().load('assets/skybox/east.png'),
- side: THREE.BackSide
- }),
- new THREE.MeshBasicMaterial({
- map: new THREE.TextureLoader().load('assets/skybox/west.png'),
- side: THREE.BackSide
- })
- ];
- return new THREE.Mesh(geometry, material);
-};
-
-BlueMap.prototype.loadHiresMaterial = function (callback) {
- let scope = this;
-
- this.fileLoader.load(this.dataRoot + "textures.json", function (textures) {
- textures = JSON.parse(textures);
-
- let materials = [];
- for (let i = 0; i < textures["textures"].length; i++) {
- let t = textures["textures"][i];
-
- let material = new THREE.MeshLambertMaterial({
- transparent: t["transparent"],
- alphaTest: 0.01,
- depthWrite: true,
- depthTest: true,
- blending: THREE.NormalBlending,
- vertexColors: THREE.VertexColors,
- side: THREE.FrontSide,
- wireframe: false
- });
-
- let texture = new THREE.Texture();
- texture.image = BlueMap.utils.stringToImage(t["texture"]);
-
- texture.premultiplyAlpha = false;
- texture.generateMipmaps = false;
- texture.magFilter = THREE.NearestFilter;
- texture.minFilter = THREE.NearestFilter;
- texture.wrapS = THREE.ClampToEdgeWrapping;
- texture.wrapT = THREE.ClampToEdgeWrapping;
- texture.flipY = false;
- texture.needsUpdate = true;
- texture.flatShading = true;
-
- material.map = texture;
- material.needsUpdate = true;
-
- materials[i] = material;
- }
-
- scope.hiresMaterial = materials;
-
- callback.call(scope);
- });
-};
-
-BlueMap.prototype.loadLowresMaterial = function (callback) {
- this.lowresMaterial = new THREE.MeshLambertMaterial({
- transparent: false,
- depthWrite: true,
- depthTest: true,
- vertexColors: THREE.VertexColors,
- side: THREE.FrontSide,
- wireframe: false
- });
-
- callback.call(this);
-};
-
-BlueMap.prototype.loadHiresTile = function (tileX, tileZ, callback, onError) {
- let scope = this;
-
- let path = this.dataRoot + this.map + "/hires/";
- path += BlueMap.utils.pathFromCoords(tileX, tileZ);
- path += ".json";
-
-
- this.bufferGeometryLoader.load(path, function (geometry) {
- let object = new THREE.Mesh(geometry, scope.hiresMaterial);
-
- let tileSize = scope.settings[scope.map]["hires"]["tileSize"];
- let translate = scope.settings[scope.map]["hires"]["translate"];
- let scale = scope.settings[scope.map]["hires"]["scale"];
- object.position.set(tileX * tileSize.x + translate.x, 0, tileZ * tileSize.z + translate.z);
- object.scale.set(scale.x, 1, scale.z);
-
- callback.call(scope, object);
- }, function () {
-
- }, function (error) {
- onError.call(scope, error);
- });
-};
-
-BlueMap.prototype.loadLowresTile = function (tileX, tileZ, callback, onError) {
- let scope = this;
-
- let path = this.dataRoot + this.map + "/lowres/";
- path += BlueMap.utils.pathFromCoords(tileX, tileZ);
- path += ".json";
-
- this.bufferGeometryLoader.load(path, function (geometry) {
- let object = new THREE.Mesh(geometry, scope.lowresMaterial);
-
- let tileSize = scope.settings[scope.map]["lowres"]["tileSize"];
- let translate = scope.settings[scope.map]["lowres"]["translate"];
- let scale = scope.settings[scope.map]["lowres"]["scale"];
- object.position.set(tileX * tileSize.x + translate.x, 0, tileZ * tileSize.z + translate.z);
- object.scale.set(scale.x, 1, scale.z);
-
- callback.call(scope, object);
- }, function () {
-
- }, function (error) {
- onError.call(scope, error);
- });
-};
-
-
-// ###### UI ######
-
-BlueMap.prototype.alert = function (content) {
- let alertBox = $('#alert-box');
- if (alertBox.length === 0){
- alertBox = $('
').appendTo(this.element);
- }
-
- let displayAlert = function(){
- let alert = $('').appendTo(alertBox);
- alert.find('.alert-close-button').click(function(){
- alert.fadeOut(200, function(){
- alert.remove();
- });
- });
- alert.fadeIn(200);
- };
-
- let oldAlerts = alertBox.find('.alert');
- if (oldAlerts.length > 0){
- alertBox.fadeOut(200, function () {
- alertBox.html('');
- alertBox.show();
- displayAlert();
- })
- } else {
- displayAlert();
- }
-};
-
-// ###### TileManager ######
-BlueMap.TileManager = function (blueMap, viewDistance, tileLoader, scene, tileSize, position) {
- this.blueMap = blueMap;
- this.viewDistance = viewDistance;
- this.tileLoader = tileLoader;
- this.scene = scene;
- this.tileSize = new THREE.Vector2(tileSize.x, tileSize.z);
-
- this.tile = new THREE.Vector2(position.x, position.z);
- this.lastTile = this.tile.clone();
-
- this.closed = false;
- this.currentlyLoading = 0;
- this.updateTimeout = null;
-
- this.tiles = {};
-};
-
-BlueMap.TileManager.prototype.setPosition = function (center) {
- this.tile.set(center.x, center.z).divide(this.tileSize).floor();
-
- if (!this.tile.equals(this.lastTile) && !this.closed) {
- this.update();
- this.lastTile.copy(this.tile);
- }
-};
-
-BlueMap.TileManager.prototype.update = function () {
- if (this.closed) return;
-
- //free a loader so if there was an error loading a tile we don't get stuck forever with the blocked loading process
- this.currentlyLoading--;
- if (this.currentlyLoading < 0) this.currentlyLoading = 0;
-
- this.removeFarTiles();
- this.loadCloseTiles();
-};
-
-BlueMap.TileManager.prototype.removeFarTiles = function () {
- let keys = Object.keys(this.tiles);
- for (let i = 0; i < keys.length; i++) {
- if (!this.tiles.hasOwnProperty(keys[i])) continue;
-
- let tile = this.tiles[keys[i]];
-
- let vd = this.viewDistance;
-
- if (
- tile.x + vd < this.tile.x ||
- tile.x - vd > this.tile.x ||
- tile.z + vd < this.tile.y ||
- tile.z - vd > this.tile.y
- ) {
- tile.disposeModel();
- delete this.tiles[keys[i]];
- }
- }
-};
-
-BlueMap.TileManager.prototype.removeAllTiles = function () {
- let keys = Object.keys(this.tiles);
- for (let i = 0; i < keys.length; i++) {
- if (!this.tiles.hasOwnProperty(keys[i])) continue;
-
- let tile = this.tiles[keys[i]];
- tile.disposeModel();
- delete this.tiles[keys[i]];
- }
-};
-
-BlueMap.TileManager.prototype.close = function () {
- this.closed = true;
- this.removeAllTiles();
-};
-
-BlueMap.TileManager.prototype.loadCloseTiles = function () {
- if (this.closed) return;
-
- let scope = this;
-
- if (this.currentlyLoading < 8) {
- if (!this.loadNextTile()) return;
- }
-
- if (this.updateTimeout) clearTimeout(this.updateTimeout);
- this.updateTimeout = setTimeout(function () {
- scope.loadCloseTiles()
- }, 0);
-};
-
-BlueMap.TileManager.prototype.loadNextTile = function () {
- let x = 0;
- let z = 0;
- let d = 1;
- let m = 1;
-
- while (m < this.viewDistance * 2) {
- while (2 * x * d < m) {
- if (this.tryLoadTile(this.tile.x + x, this.tile.y + z)) return true;
- x = x + d;
- }
- while (2 * z * d < m) {
- if (this.tryLoadTile(this.tile.x + x, this.tile.y + z)) return true;
- z = z + d;
- }
- d = -1 * d;
- m = m + 1;
- }
-
- return false;
-};
-
-BlueMap.TileManager.prototype.tryLoadTile = function (x, z) {
- if (this.closed) return;
-
- let scope = this;
-
- let tileHash = BlueMap.utils.hashTile(x, z);
-
- let tile = this.tiles[tileHash];
- if (tile !== undefined) return false;
-
- tile = new BlueMap.Tile(this.scene, x, z);
- tile.isLoading = true;
-
- this.currentlyLoading++;
-
- this.tiles[tileHash] = tile;
-
- this.tileLoader.call(this.blueMap, x, z, function (model) {
- tile.isLoading = false;
-
- if (tile.disposed || scope.closed) {
- model.geometry.dispose();
- tile.disposeModel();
- delete scope.tiles[tileHash];
- return;
- }
-
- scope.tiles[tileHash] = tile;
- tile.setModel(model);
-
- scope.blueMap.updateFrame = true;
-
- scope.currentlyLoading--;
- if (scope.currentlyLoading < 0) scope.currentlyLoading = 0;
- }, function (error) {
- tile.isLoading = false;
- tile.disposeModel();
-
- scope.currentlyLoading--;
-
- //console.log("Failed to load tile: ", x, z);
- });
-
- return true;
-};
-
-
-// ###### Tile ######
-BlueMap.Tile = function (scene, x, z) {
- this.scene = scene;
- this.x = x;
- this.z = z;
-
- this.isLoading = false;
- this.disposed = false;
-
- this.model = null;
-};
-
-BlueMap.Tile.prototype.setModel = function (model) {
- this.disposeModel();
-
- if (model) {
- this.model = model;
- this.scene.add(model);
-
- //console.log("Added tile:", this.x, this.z);
- }
-};
-
-BlueMap.Tile.prototype.disposeModel = function () {
- this.disposed = true;
-
- if (this.model) {
- this.scene.remove(this.model);
- this.model.geometry.dispose();
- delete this.model;
-
- //console.log("Removed tile:", this.x, this.z);
- }
-};
-
-
-// ###### Controls ######
-
-/**
- * targetHeightScene and cameraHeightScene are scenes of objects that are checked via raycasting for a height for the target and the camera
- */
-BlueMap.Controls = function (camera, element, heightScene) {
- let scope = this;
-
- this.settings = {
- zoom: {
- min: 10,
- max: 2000,
- speed: 1.5,
- smooth: 0.2,
- },
- move: {
- speed: 1.75,
- smooth: 0.3,
- smoothY: 0.075,
- },
- tilt: {
- max: Math.PI / 2.1,
- speed: 1.5,
- smooth: 0.3,
- },
- rotate: {
- speed: 1.5,
- smooth: 0.3,
- }
- };
-
- this.camera = camera;
- this.element = element;
- this.heightScene = heightScene;
- this.minHeight = 0;
-
- this.raycaster = new THREE.Raycaster();
- this.rayDirection = new THREE.Vector3(0, -1, 0);
-
- this.resetPosition();
-
- this.mouse = new THREE.Vector2(0, 0);
- this.lastMouse = new THREE.Vector2(0, 0);
- this.deltaMouse = new THREE.Vector2(0, 0);
-
- //variables used to calculate with (to prevent object creation every update)
- this.orbitRot = new THREE.Euler(0, 0, 0, "YXZ");
- this.cameraPosDelta = new THREE.Vector3(0, 0, 0);
- this.moveDelta = new THREE.Vector2(0, 0);
-
- this.keyStates = {};
-
- this.KEYS = {
- LEFT: 37,
- UP: 38,
- RIGHT: 39,
- DOWN: 40,
- ORBIT: THREE.MOUSE.RIGHT,
- MOVE: THREE.MOUSE.LEFT
- };
- this.STATES = {
- NONE: -1,
- ORBIT: 0,
- MOVE: 1,
- };
-
- this.state = this.STATES.NONE;
-
- let canvas = $(this.element).find("canvas").get(0);
- window.addEventListener('contextmenu', function (e) {
- e.preventDefault();
- }, false);
- canvas.addEventListener('mousedown', function (e) {
- scope.onMouseDown(e);
- }, false);
- window.addEventListener('mousemove', function (e) {
- scope.onMouseMove(e);
- }, false);
- window.addEventListener('mouseup', function (e) {
- scope.onMouseUp(e);
- }, false);
- canvas.addEventListener('wheel', function (e) {
- scope.onMouseWheel(e);
- }, false);
- window.addEventListener('keydown', function (e) {
- scope.onKeyDown(e);
- }, false);
- window.addEventListener('keyup', function (e) {
- scope.onKeyUp(e);
- }, false);
-
- this.camera.position.set(0, 1000, 0);
- this.camera.lookAt(this.position);
- this.camera.updateProjectionMatrix();
-};
-
-BlueMap.Controls.prototype.resetPosition = function () {
- this.position = new THREE.Vector3(0, 70, 0);
- this.targetPosition = new THREE.Vector3(0, 70, 0);
-
- this.distance = 5000;
- this.targetDistance = 1000;
-
- this.direction = 0;
- this.targetDirection = 0;
-
- this.angle = 0;
- this.targetAngle = 0;
-};
-
-BlueMap.Controls.prototype.update = function () {
- this.updateMouseMoves();
-
- let changed = false;
-
- let zoomLerp = (this.distance - 100) / 200;
- if (zoomLerp < 0) zoomLerp = 0;
- if (zoomLerp > 1) zoomLerp = 1;
- this.targetPosition.y = 300 * zoomLerp + this.minHeight * (1 - zoomLerp);
-
- this.position.x += (this.targetPosition.x - this.position.x) * this.settings.move.smooth;
- this.position.y += (this.targetPosition.y - this.position.y) * this.settings.move.smoothY;
- this.position.z += (this.targetPosition.z - this.position.z) * this.settings.move.smooth;
-
- this.distance += (this.targetDistance - this.distance) * this.settings.zoom.smooth;
-
- let deltaDir = (this.targetDirection - this.direction) * this.settings.rotate.smooth;
- this.direction += deltaDir;
- changed = changed || Math.abs(deltaDir) > 0.001;
-
- let max = Math.min(this.settings.tilt.max, this.settings.tilt.max - Math.pow(((this.distance - this.settings.zoom.min) / (this.settings.zoom.max - this.settings.zoom.min)) * Math.pow(this.settings.tilt.max, 4), 1/4));
- if (this.targetAngle > max) this.targetAngle = max;
- if (this.targetAngle < 0.01) this.targetAngle = 0.001;
- let deltaAngle = (this.targetAngle - this.angle) * this.settings.tilt.smooth;
- this.angle += deltaAngle;
- changed = changed || Math.abs(deltaAngle) > 0.001;
-
- let last = this.camera.position.x + this.camera.position.y + this.camera.position.z;
- this.orbitRot.set(this.angle, this.direction, 0);
- this.cameraPosDelta.set(0, this.distance, 0).applyEuler(this.orbitRot);
-
- this.camera.position.set(this.position.x + this.cameraPosDelta.x, this.position.y + this.cameraPosDelta.y, this.position.z + this.cameraPosDelta.z);
- let move = last - (this.camera.position.x + this.camera.position.y + this.camera.position.z);
-
- changed = changed || Math.abs(move) > 0.001;
-
- if (changed) {
- this.camera.lookAt(this.position);
- this.camera.updateProjectionMatrix();
-
- this.updateHeights();
- }
-
- return changed;
-};
-
-BlueMap.Controls.prototype.updateHeights = function(){
- //TODO: this can be performance-improved by only intersecting the correct tile?
-
- let rayStart = new THREE.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(this.heightScene.children);
- if (intersects.length > 0){
- this.minHeight = intersects[0].point.y;
- //this.targetPosition.y = this.minHeight;
- } else {
- //this.targetPosition.y = 0;
- }
-
- rayStart.set(this.camera.position.x, 300, this.camera.position.z);
- this.raycaster.set(rayStart, this.rayDirection);
- intersects.length = 0;
- intersects = this.raycaster.intersectObjects(this.heightScene.children);
- if (intersects.length > 0){
- if (intersects[0].point.y > this.minHeight){
- this.minHeight = intersects[0].point.y;
- }
- }
-};
-
-BlueMap.Controls.prototype.updateMouseMoves = function (e) {
- this.deltaMouse.set(this.lastMouse.x - this.mouse.x, this.lastMouse.y - this.mouse.y);
-
- this.moveDelta.x = 0;
- this.moveDelta.y = 0;
-
- if (this.keyStates[this.KEYS.UP]){
- this.moveDelta.y -= 20;
- }
- if (this.keyStates[this.KEYS.DOWN]){
- this.moveDelta.y += 20;
- }
- if (this.keyStates[this.KEYS.LEFT]){
- this.moveDelta.x -= 20;
- }
- if (this.keyStates[this.KEYS.RIGHT]){
- this.moveDelta.x += 20;
- }
-
- if (this.state === this.STATES.MOVE) {
- if (this.deltaMouse.x === 0 && this.deltaMouse.y === 0) return;
- this.moveDelta.copy(this.deltaMouse);
- }
-
- if (this.moveDelta.x !== 0 || this.moveDelta.y !== 0) {
- this.moveDelta.rotateAround(BlueMap.utils.Vector2.ZERO, -this.direction);
- this.targetPosition.set(
- this.targetPosition.x + (this.moveDelta.x * this.distance / this.element.clientHeight * this.settings.move.speed),
- this.targetPosition.y,
- this.targetPosition.z + (this.moveDelta.y * this.distance / this.element.clientHeight * this.settings.move.speed)
- );
- }
-
- if (this.state === this.STATES.ORBIT) {
- this.targetDirection += (this.deltaMouse.x / this.element.clientHeight * Math.PI);
- this.targetAngle += (this.deltaMouse.y / this.element.clientHeight * Math.PI);
- }
-
- this.lastMouse.copy(this.mouse);
-};
-
-BlueMap.Controls.prototype.onMouseWheel = function (e) {
- if (e.deltaY > 0) {
- this.targetDistance *= this.settings.zoom.speed;
- } else if (e.deltaY < 0) {
- this.targetDistance /= this.settings.zoom.speed;
- }
-
- if (this.targetDistance < this.settings.zoom.min) this.targetDistance = this.settings.zoom.min;
- if (this.targetDistance > this.settings.zoom.max) this.targetDistance = this.settings.zoom.max;
-};
-
-BlueMap.Controls.prototype.onMouseMove = function (e) {
- this.mouse.set(e.clientX, e.clientY);
-
- if (this.state !== this.STATES.NONE){
- e.preventDefault();
- }
-};
-
-BlueMap.Controls.prototype.onMouseDown = function (e) {
- if (this.state !== this.STATES.NONE) return;
-
- switch (e.button) {
- case this.KEYS.MOVE :
- this.state = this.STATES.MOVE;
- e.preventDefault();
- break;
- case this.KEYS.ORBIT :
- this.state = this.STATES.ORBIT;
- e.preventDefault();
- break;
- }
-};
-
-BlueMap.Controls.prototype.onMouseUp = function (e) {
- if (this.state === this.STATES.NONE) return;
-
- switch (e.button) {
- case this.KEYS.MOVE :
- if (this.state === this.STATES.MOVE) this.state = this.STATES.NONE;
- break;
- case this.KEYS.ORBIT :
- if (this.state === this.STATES.ORBIT) this.state = this.STATES.NONE;
- break;
- }
-};
-
-BlueMap.Controls.prototype.onKeyDown = function (e) {
- this.keyStates[e.keyCode] = true;
-};
-
-BlueMap.Controls.prototype.onKeyUp = function (e) {
- this.keyStates[e.keyCode] = false;
-};
-
-// ###### Modules ######
-BlueMap.Module = {
- getTopRightElement: function(blueMap){
- let element = $("#bluemap-topright");
-
- if (element.length === 0){
- element = $('
').appendTo(blueMap.element);
- }
-
- return element;
- },
-
- getTopLeftElement: function(blueMap){
- let element = $("#bluemap-topleft");
-
- if (element.length === 0){
- element = $('
').appendTo(blueMap.element);
- }
-
- return element;
- }
-};
-
-// ###### Modules.MapMenu ######
-BlueMap.Module.MapMenu = function (blueMap) {
- let scope = this;
-
- this.bluemap = blueMap;
- let maps = this.bluemap.settings;
-
- $("#bluemap-mapmenu").remove();
- this.element = $('').appendTo(BlueMap.Module.getTopLeftElement(blueMap));
-
- let dropdown = $('
').appendTo(this.element);
- this.maplist = $('').appendTo(dropdown);
-
- for (mapId in maps) {
- if (!maps.hasOwnProperty(mapId)) continue;
- if (!maps.enabled) continue;
-
- let map = maps[mapId];
- $('' + map.name + ' ').appendTo(this.maplist);
- }
-
- this.maplist.find('li[map=' + this.bluemap.map + ']').hide();
- this.maplist.find('li[map]').click(function (e) {
- let map = $(this).attr('map');
- scope.bluemap.changeMap(map);
- });
-
- $(document).on('bluemap-map-change', function(){
- scope.maplist.find('li').show();
- scope.maplist.find('li[map=' + scope.bluemap.map + ']').hide();
-
- scope.element.find(".selection").html(scope.bluemap.settings[scope.bluemap.map].name);
- });
-};
-
-// ###### Modules.Compass ######
-BlueMap.Module.Compass = function (blueMap) {
- let scope = this;
-
- this.blueMap = blueMap;
-
- $("#bluemap-compass").remove();
- this.element = $('').appendTo(BlueMap.Module.getTopLeftElement(blueMap));
- this.needle = $('#bluemap-compass-needle');
-
- $(document).on('bluemap-update-frame', function (){
- scope.needle.css("transform", "rotate(" + scope.blueMap.controls.direction + "rad)");
- });
-
- $(this.element).click(function(){
- scope.blueMap.controls.targetDirection = 0;
- scope.blueMap.controls.direction = scope.blueMap.controls.direction % (Math.PI * 2);
- if (scope.blueMap.controls.direction < -Math.PI) scope.blueMap.controls.direction += Math.PI * 2;
- if (scope.blueMap.controls.direction > Math.PI) scope.blueMap.controls.direction -= Math.PI * 2;
- });
-};
-
-// ###### Modules.Position ######
-BlueMap.Module.Position = function (blueMap) {
- let scope = this;
-
- this.blueMap = blueMap;
-
- let parent = BlueMap.Module.getTopLeftElement(blueMap);
-
- $(".bluemap-position").remove();
- this.elementX = $('0
').appendTo(parent);
- //this.elementY = $('0
').appendTo(parent);
- this.elementZ = $('0
').appendTo(parent);
-
- $(document).on('bluemap-update-frame', function (){
- scope.elementX.html(Math.floor(scope.blueMap.controls.targetPosition.x));
- //scope.elementY.html(scope.blueMap.controls.targetPosition.y === 0 ? "-" : Math.floor(scope.blueMap.controls.targetPosition.y));
- scope.elementZ.html(Math.floor(scope.blueMap.controls.targetPosition.z));
- });
-};
-
-// ###### Modules.Settings ######
-BlueMap.Module.Settings = function (blueMap) {
- let scope = this;
-
- this.blueMap = blueMap;
-
- let parent = BlueMap.Module.getTopRightElement(blueMap);
-
- $("#bluemap-settings").remove();
- this.elementMenu = $('
').appendTo(parent);
- this.elementSettings = $('').appendTo(parent);
- this.elementSettings.click(function(){
- if (scope.elementMenu.css('display') === "none"){
- scope.elementSettings.addClass("active");
- } else {
- scope.elementSettings.removeClass("active");
- }
-
- scope.elementMenu.animate({
- width: "toggle"
- }, 200);
- });
-
-
- /* Quality */
-
- this.elementQuality = $(
- 'Quality: Normal ' +
- 'High ' +
- 'Normal ' +
- 'Fast ' +
- ' '
- ).prependTo(this.elementMenu);
-
- this.elementQuality.find("li[quality]").click(function(){
- let desc = $(this).html();
- scope.blueMap.quality = parseFloat($(this).attr("quality"));
-
- scope.elementQuality.find('li').show();
- scope.elementQuality.find('li[quality=\'' + scope.blueMap.quality + '\']').hide();
-
- scope.elementQuality.find('.selection > span').html(desc);
-
- scope.blueMap.handleContainerResize();
- });
-
-
- /* Render Distance */
-
- this.pctToRenderDistance = function ( value , defaultValue ) {
- let max = defaultValue * 5;
- if (max > 20) max = 20;
-
- return THREE.Math.mapLinear(value, 0, 100, 1, max);
- };
-
- this.renderDistanceToPct = function ( value , defaultValue ) {
- let max = defaultValue * 5;
- if (max > 20) max = 20;
-
- return THREE.Math.mapLinear(value, 1, max, 0, 100);
- };
-
- this.init = function(){
- scope.defaultHighRes = scope.blueMap.hiresTileManager.viewDistance;
- scope.defaultLowRes = scope.blueMap.lowresTileManager.viewDistance;
-
- scope.elementRenderDistance.html(
- 'View Distance: ' + scope.blueMap.hiresTileManager.viewDistance + ' ' +
- '' +
- ' ' +
- '
'
- );
-
- let slider = scope.elementRenderDistance.find("input");
- slider.on('change input', function(e){
- scope.blueMap.hiresTileManager.viewDistance = scope.pctToRenderDistance(parseFloat(slider.val()), scope.defaultHighRes);
- scope.blueMap.lowresTileManager.viewDistance = scope.pctToRenderDistance(parseFloat(slider.val()), scope.defaultLowRes);
- scope.elementRenderDistance.find(".selection > span").html(Math.round(scope.blueMap.hiresTileManager.viewDistance * 10) / 10);
-
- scope.blueMap.lowresTileManager.update();
- scope.blueMap.hiresTileManager.update();
- });
- };
-
- this.elementRenderDistance = $(
- '' +
- '
'
- ).prependTo(this.elementMenu);
-
- scope.init();
-
- $(document).on('bluemap-map-change', this.init);
-};
-
-// ###### Modules.Info ######
-BlueMap.Module.Info = function (blueMap) {
- let scope = this;
-
- this.blueMap = blueMap;
-
- let parent = BlueMap.Module.getTopRightElement(blueMap);
-
- $("#bluemap-info").remove();
- this.elementInfo = $('
').appendTo(parent);
-
- this.elementInfo.click(function(){
- scope.blueMap.alert(
- 'Info ' +
- 'Visit BlueMap on GitHub ! ' +
- 'BlueMap works best with Chrome . ' +
- 'Controls ' +
- 'Leftclick-drag with your mouse or use the arrow-keys to navigate. ' +
- 'Rightclick-drag with your mouse to rotate your view. ' +
- 'Scroll to zoom. '
- );
- });
-};
-
-// ###### Utils ######
-BlueMap.utils = {};
-
-BlueMap.utils.stringToImage = function (string) {
- let image = document.createElementNS('http://www.w3.org/1999/xhtml', 'img');
- image.src = string;
- return image;
-};
-
-BlueMap.utils.pathFromCoords = function (x, z) {
- let path = "x";
- path += BlueMap.utils.splitNumberToPath(x);
-
- path += "z";
- path += BlueMap.utils.splitNumberToPath(z);
-
- path = path.substring(0, path.length - 1);
-
- return path;
-};
-
-BlueMap.utils.splitNumberToPath = function (num) {
- let path = "";
-
- if (num < 0) {
- num = -num;
- path += "-";
- }
-
- let s = num.toString();
-
- for (let i = 0; i < s.length; i++) {
- path += s.charAt(i) + "/";
- }
-
- return path;
-};
-
-BlueMap.utils.hashTile = function (x, z) {
- return "x" + x + "z" + z;
-};
-
-BlueMap.utils.Vector2 = {};
-BlueMap.utils.Vector2.ZERO = new THREE.Vector2(0, 0);
-BlueMap.utils.Vector3 = {};
-BlueMap.utils.Vector3.ZERO = new THREE.Vector3(0, 0);
diff --git a/BlueMapCore/src/main/webroot/js/libs/jquery.min.js b/BlueMapCore/src/main/webroot/js/libs/jquery.min.js
deleted file mode 100644
index 63174a0d..00000000
--- a/BlueMapCore/src/main/webroot/js/libs/jquery.min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! jQuery v1.8.2 jquery.com | jquery.org/license */
-(function(a,b){function G(a){var b=F[a]={};return p.each(a.split(s),function(a,c){b[c]=!0}),b}function J(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(I,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:+d+""===d?+d:H.test(d)?p.parseJSON(d):d}catch(f){}p.data(a,c,d)}else d=b}return d}function K(a){var b;for(b in a){if(b==="data"&&p.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function ba(){return!1}function bb(){return!0}function bh(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function bi(a,b){do a=a[b];while(a&&a.nodeType!==1);return a}function bj(a,b,c){b=b||0;if(p.isFunction(b))return p.grep(a,function(a,d){var e=!!b.call(a,d,a);return e===c});if(b.nodeType)return p.grep(a,function(a,d){return a===b===c});if(typeof b=="string"){var d=p.grep(a,function(a){return a.nodeType===1});if(be.test(b))return p.filter(b,d,!c);b=p.filter(b,d)}return p.grep(a,function(a,d){return p.inArray(a,b)>=0===c})}function bk(a){var b=bl.split("|"),c=a.createDocumentFragment();if(c.createElement)while(b.length)c.createElement(b.pop());return c}function bC(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function bD(a,b){if(b.nodeType!==1||!p.hasData(a))return;var c,d,e,f=p._data(a),g=p._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d").appendTo(e.body),c=b.css("display");b.remove();if(c==="none"||c===""){bI=e.body.appendChild(bI||p.extend(e.createElement("iframe"),{frameBorder:0,width:0,height:0}));if(!bJ||!bI.createElement)bJ=(bI.contentWindow||bI.contentDocument).document,bJ.write(""),bJ.close();b=bJ.body.appendChild(bJ.createElement(a)),c=bH(b,"display"),e.body.removeChild(bI)}return bS[a]=c,c}function ci(a,b,c,d){var e;if(p.isArray(b))p.each(b,function(b,e){c||ce.test(a)?d(a,e):ci(a+"["+(typeof e=="object"?b:"")+"]",e,c,d)});else if(!c&&p.type(b)==="object")for(e in b)ci(a+"["+e+"]",b[e],c,d);else d(a,b)}function cz(a){return function(b,c){typeof b!="string"&&(c=b,b="*");var d,e,f,g=b.toLowerCase().split(s),h=0,i=g.length;if(p.isFunction(c))for(;h)[^>]*$|#([\w\-]*)$)/,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^[\],:{}\s]*$/,x=/(?:^|:|,)(?:\s*\[)+/g,y=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,z=/"[^"\\\r\n]*"|true|false|null|-?(?:\d\d*\.|)\d+(?:[eE][\-+]?\d+|)/g,A=/^-ms-/,B=/-([\da-z])/gi,C=function(a,b){return(b+"").toUpperCase()},D=function(){e.addEventListener?(e.removeEventListener("DOMContentLoaded",D,!1),p.ready()):e.readyState==="complete"&&(e.detachEvent("onreadystatechange",D),p.ready())},E={};p.fn=p.prototype={constructor:p,init:function(a,c,d){var f,g,h,i;if(!a)return this;if(a.nodeType)return this.context=this[0]=a,this.length=1,this;if(typeof a=="string"){a.charAt(0)==="<"&&a.charAt(a.length-1)===">"&&a.length>=3?f=[null,a,null]:f=u.exec(a);if(f&&(f[1]||!c)){if(f[1])return c=c instanceof p?c[0]:c,i=c&&c.nodeType?c.ownerDocument||c:e,a=p.parseHTML(f[1],i,!0),v.test(f[1])&&p.isPlainObject(c)&&this.attr.call(a,c,!0),p.merge(this,a);g=e.getElementById(f[2]);if(g&&g.parentNode){if(g.id!==f[2])return d.find(a);this.length=1,this[0]=g}return this.context=e,this.selector=a,this}return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a)}return p.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),p.makeArray(a,this))},selector:"",jquery:"1.8.2",length:0,size:function(){return this.length},toArray:function(){return k.call(this)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=p.merge(this.constructor(),a);return d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")"),d},each:function(a,b){return p.each(this,a,b)},ready:function(a){return p.ready.promise().done(a),this},eq:function(a){return a=+a,a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(k.apply(this,arguments),"slice",k.call(arguments).join(","))},map:function(a){return this.pushStack(p.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:j,sort:[].sort,splice:[].splice},p.fn.init.prototype=p.fn,p.extend=p.fn.extend=function(){var a,c,d,e,f,g,h=arguments[0]||{},i=1,j=arguments.length,k=!1;typeof h=="boolean"&&(k=h,h=arguments[1]||{},i=2),typeof h!="object"&&!p.isFunction(h)&&(h={}),j===i&&(h=this,--i);for(;i0)return;d.resolveWith(e,[p]),p.fn.trigger&&p(e).trigger("ready").off("ready")},isFunction:function(a){return p.type(a)==="function"},isArray:Array.isArray||function(a){return p.type(a)==="array"},isWindow:function(a){return a!=null&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):E[m.call(a)]||"object"},isPlainObject:function(a){if(!a||p.type(a)!=="object"||a.nodeType||p.isWindow(a))return!1;try{if(a.constructor&&!n.call(a,"constructor")&&!n.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||n.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){var d;return!a||typeof a!="string"?null:(typeof b=="boolean"&&(c=b,b=0),b=b||e,(d=v.exec(a))?[b.createElement(d[1])]:(d=p.buildFragment([a],b,c?null:[]),p.merge([],(d.cacheable?p.clone(d.fragment):d.fragment).childNodes)))},parseJSON:function(b){if(!b||typeof b!="string")return null;b=p.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(w.test(b.replace(y,"@").replace(z,"]").replace(x,"")))return(new Function("return "+b))();p.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||typeof c!="string")return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&p.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&r.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(A,"ms-").replace(B,C)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,c,d){var e,f=0,g=a.length,h=g===b||p.isFunction(a);if(d){if(h){for(e in a)if(c.apply(a[e],d)===!1)break}else for(;f0&&a[0]&&a[i-1]||i===0||p.isArray(a));if(j)for(;h-1)i.splice(c,1),e&&(c<=g&&g--,c<=h&&h--)}),this},has:function(a){return p.inArray(a,i)>-1},empty:function(){return i=[],this},disable:function(){return i=j=c=b,this},disabled:function(){return!i},lock:function(){return j=b,c||l.disable(),this},locked:function(){return!j},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],i&&(!d||j)&&(e?j.push(b):k(b)),this},fire:function(){return l.fireWith(this,arguments),this},fired:function(){return!!d}};return l},p.extend({Deferred:function(a){var b=[["resolve","done",p.Callbacks("once memory"),"resolved"],["reject","fail",p.Callbacks("once memory"),"rejected"],["notify","progress",p.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return p.Deferred(function(c){p.each(b,function(b,d){var f=d[0],g=a[b];e[d[1]](p.isFunction(g)?function(){var a=g.apply(this,arguments);a&&p.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f+"With"](this===e?c:this,[a])}:c[f])}),a=null}).promise()},promise:function(a){return a!=null?p.extend(a,d):d}},e={};return d.pipe=d.then,p.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[a^1][2].disable,b[2][2].lock),e[f[0]]=g.fire,e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=k.call(arguments),d=c.length,e=d!==1||a&&p.isFunction(a.promise)?d:0,f=e===1?a:p.Deferred(),g=function(a,b,c){return function(d){b[a]=this,c[a]=arguments.length>1?k.call(arguments):d,c===h?f.notifyWith(b,c):--e||f.resolveWith(b,c)}},h,i,j;if(d>1){h=new Array(d),i=new Array(d),j=new Array(d);for(;ba ",c=n.getElementsByTagName("*"),d=n.getElementsByTagName("a")[0],d.style.cssText="top:1px;float:left;opacity:.5";if(!c||!c.length)return{};f=e.createElement("select"),g=f.appendChild(e.createElement("option")),h=n.getElementsByTagName("input")[0],b={leadingWhitespace:n.firstChild.nodeType===3,tbody:!n.getElementsByTagName("tbody").length,htmlSerialize:!!n.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:d.getAttribute("href")==="/a",opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:h.value==="on",optSelected:g.selected,getSetAttribute:n.className!=="t",enctype:!!e.createElement("form").enctype,html5Clone:e.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",boxModel:e.compatMode==="CSS1Compat",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},h.checked=!0,b.noCloneChecked=h.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!g.disabled;try{delete n.test}catch(o){b.deleteExpando=!1}!n.addEventListener&&n.attachEvent&&n.fireEvent&&(n.attachEvent("onclick",m=function(){b.noCloneEvent=!1}),n.cloneNode(!0).fireEvent("onclick"),n.detachEvent("onclick",m)),h=e.createElement("input"),h.value="t",h.setAttribute("type","radio"),b.radioValue=h.value==="t",h.setAttribute("checked","checked"),h.setAttribute("name","t"),n.appendChild(h),i=e.createDocumentFragment(),i.appendChild(n.lastChild),b.checkClone=i.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=h.checked,i.removeChild(h),i.appendChild(n);if(n.attachEvent)for(k in{submit:!0,change:!0,focusin:!0})j="on"+k,l=j in n,l||(n.setAttribute(j,"return;"),l=typeof n[j]=="function"),b[k+"Bubbles"]=l;return p(function(){var c,d,f,g,h="padding:0;margin:0;border:0;display:block;overflow:hidden;",i=e.getElementsByTagName("body")[0];if(!i)return;c=e.createElement("div"),c.style.cssText="visibility:hidden;border:0;width:0;height:0;position:static;top:0;margin-top:1px",i.insertBefore(c,i.firstChild),d=e.createElement("div"),c.appendChild(d),d.innerHTML="",f=d.getElementsByTagName("td"),f[0].style.cssText="padding:0;margin:0;border:0;display:none",l=f[0].offsetHeight===0,f[0].style.display="",f[1].style.display="none",b.reliableHiddenOffsets=l&&f[0].offsetHeight===0,d.innerHTML="",d.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=d.offsetWidth===4,b.doesNotIncludeMarginInBodyOffset=i.offsetTop!==1,a.getComputedStyle&&(b.pixelPosition=(a.getComputedStyle(d,null)||{}).top!=="1%",b.boxSizingReliable=(a.getComputedStyle(d,null)||{width:"4px"}).width==="4px",g=e.createElement("div"),g.style.cssText=d.style.cssText=h,g.style.marginRight=g.style.width="0",d.style.width="1px",d.appendChild(g),b.reliableMarginRight=!parseFloat((a.getComputedStyle(g,null)||{}).marginRight)),typeof d.style.zoom!="undefined"&&(d.innerHTML="",d.style.cssText=h+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=d.offsetWidth===3,d.style.display="block",d.style.overflow="visible",d.innerHTML="
",d.firstChild.style.width="5px",b.shrinkWrapBlocks=d.offsetWidth!==3,c.style.zoom=1),i.removeChild(c),c=d=f=g=null}),i.removeChild(n),c=d=f=g=h=i=n=null,b}();var H=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,I=/([A-Z])/g;p.extend({cache:{},deletedIds:[],uuid:0,expando:"jQuery"+(p.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?p.cache[a[p.expando]]:a[p.expando],!!a&&!K(a)},data:function(a,c,d,e){if(!p.acceptData(a))return;var f,g,h=p.expando,i=typeof c=="string",j=a.nodeType,k=j?p.cache:a,l=j?a[h]:a[h]&&h;if((!l||!k[l]||!e&&!k[l].data)&&i&&d===b)return;l||(j?a[h]=l=p.deletedIds.pop()||p.guid++:l=h),k[l]||(k[l]={},j||(k[l].toJSON=p.noop));if(typeof c=="object"||typeof c=="function")e?k[l]=p.extend(k[l],c):k[l].data=p.extend(k[l].data,c);return f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[p.camelCase(c)]=d),i?(g=f[c],g==null&&(g=f[p.camelCase(c)])):g=f,g},removeData:function(a,b,c){if(!p.acceptData(a))return;var d,e,f,g=a.nodeType,h=g?p.cache:a,i=g?a[p.expando]:p.expando;if(!h[i])return;if(b){d=c?h[i]:h[i].data;if(d){p.isArray(b)||(b in d?b=[b]:(b=p.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,f=b.length;e1,null,!1))},removeData:function(a){return this.each(function(){p.removeData(this,a)})}}),p.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=p._data(a,b),c&&(!d||p.isArray(c)?d=p._data(a,b,p.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=p.queue(a,b),d=c.length,e=c.shift(),f=p._queueHooks(a,b),g=function(){p.dequeue(a,b)};e==="inprogress"&&(e=c.shift(),d--),e&&(b==="fx"&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return p._data(a,c)||p._data(a,c,{empty:p.Callbacks("once memory").add(function(){p.removeData(a,b+"queue",!0),p.removeData(a,c,!0)})})}}),p.fn.extend({queue:function(a,c){var d=2;return typeof a!="string"&&(c=a,a="fx",d--),arguments.length1)},removeAttr:function(a){return this.each(function(){p.removeAttr(this,a)})},prop:function(a,b){return p.access(this,p.prop,a,b,arguments.length>1)},removeProp:function(a){return a=p.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g,h;if(p.isFunction(a))return this.each(function(b){p(this).addClass(a.call(this,b,this.className))});if(a&&typeof a=="string"){b=a.split(s);for(c=0,d=this.length;c=0)d=d.replace(" "+c[f]+" "," ");e.className=a?p.trim(d):""}}}return this},toggleClass:function(a,b){var c=typeof a,d=typeof b=="boolean";return p.isFunction(a)?this.each(function(c){p(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if(c==="string"){var e,f=0,g=p(this),h=b,i=a.split(s);while(e=i[f++])h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e)}else if(c==="undefined"||c==="boolean")this.className&&p._data(this,"__className__",this.className),this.className=this.className||a===!1?"":p._data(this,"__className__")||""})},hasClass:function(a){var b=" "+a+" ",c=0,d=this.length;for(;c=0)return!0;return!1},val:function(a){var c,d,e,f=this[0];if(!arguments.length){if(f)return c=p.valHooks[f.type]||p.valHooks[f.nodeName.toLowerCase()],c&&"get"in c&&(d=c.get(f,"value"))!==b?d:(d=f.value,typeof d=="string"?d.replace(P,""):d==null?"":d);return}return e=p.isFunction(a),this.each(function(d){var f,g=p(this);if(this.nodeType!==1)return;e?f=a.call(this,d,g.val()):f=a,f==null?f="":typeof f=="number"?f+="":p.isArray(f)&&(f=p.map(f,function(a){return a==null?"":a+""})),c=p.valHooks[this.type]||p.valHooks[this.nodeName.toLowerCase()];if(!c||!("set"in c)||c.set(this,f,"value")===b)this.value=f})}}),p.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,f=a.selectedIndex,g=[],h=a.options,i=a.type==="select-one";if(f<0)return null;c=i?f:0,d=i?f+1:h.length;for(;c=0}),c.length||(a.selectedIndex=-1),c}}},attrFn:{},attr:function(a,c,d,e){var f,g,h,i=a.nodeType;if(!a||i===3||i===8||i===2)return;if(e&&p.isFunction(p.fn[c]))return p(a)[c](d);if(typeof a.getAttribute=="undefined")return p.prop(a,c,d);h=i!==1||!p.isXMLDoc(a),h&&(c=c.toLowerCase(),g=p.attrHooks[c]||(T.test(c)?M:L));if(d!==b){if(d===null){p.removeAttr(a,c);return}return g&&"set"in g&&h&&(f=g.set(a,d,c))!==b?f:(a.setAttribute(c,d+""),d)}return g&&"get"in g&&h&&(f=g.get(a,c))!==null?f:(f=a.getAttribute(c),f===null?b:f)},removeAttr:function(a,b){var c,d,e,f,g=0;if(b&&a.nodeType===1){d=b.split(s);for(;g=0}})});var V=/^(?:textarea|input|select)$/i,W=/^([^\.]*|)(?:\.(.+)|)$/,X=/(?:^|\s)hover(\.\S+|)\b/,Y=/^key/,Z=/^(?:mouse|contextmenu)|click/,$=/^(?:focusinfocus|focusoutblur)$/,_=function(a){return p.event.special.hover?a:a.replace(X,"mouseenter$1 mouseleave$1")};p.event={add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,q,r;if(a.nodeType===3||a.nodeType===8||!c||!d||!(g=p._data(a)))return;d.handler&&(o=d,d=o.handler,f=o.selector),d.guid||(d.guid=p.guid++),i=g.events,i||(g.events=i={}),h=g.handle,h||(g.handle=h=function(a){return typeof p!="undefined"&&(!a||p.event.triggered!==a.type)?p.event.dispatch.apply(h.elem,arguments):b},h.elem=a),c=p.trim(_(c)).split(" ");for(j=0;j=0&&(s=s.slice(0,-1),i=!0),s.indexOf(".")>=0&&(t=s.split("."),s=t.shift(),t.sort());if((!f||p.event.customEvent[s])&&!p.event.global[s])return;c=typeof c=="object"?c[p.expando]?c:new p.Event(s,c):new p.Event(s),c.type=s,c.isTrigger=!0,c.exclusive=i,c.namespace=t.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,m=s.indexOf(":")<0?"on"+s:"";if(!f){h=p.cache;for(j in h)h[j].events&&h[j].events[s]&&p.event.trigger(c,d,h[j].handle.elem,!0);return}c.result=b,c.target||(c.target=f),d=d!=null?p.makeArray(d):[],d.unshift(c),n=p.event.special[s]||{};if(n.trigger&&n.trigger.apply(f,d)===!1)return;q=[[f,n.bindType||s]];if(!g&&!n.noBubble&&!p.isWindow(f)){r=n.delegateType||s,k=$.test(r+s)?f:f.parentNode;for(l=f;k;k=k.parentNode)q.push([k,r]),l=k;l===(f.ownerDocument||e)&&q.push([l.defaultView||l.parentWindow||a,r])}for(j=0;j=0:p.find(m,this,null,[f]).length),h[m]&&j.push(l);j.length&&u.push({elem:f,matches:j})}o.length>q&&u.push({elem:this,matches:o.slice(q)});for(d=0;d0?this.on(b,null,a,c):this.trigger(b)},Y.test(b)&&(p.event.fixHooks[b]=p.event.keyHooks),Z.test(b)&&(p.event.fixHooks[b]=p.event.mouseHooks)}),function(a,b){function bc(a,b,c,d){c=c||[],b=b||r;var e,f,i,j,k=b.nodeType;if(!a||typeof a!="string")return c;if(k!==1&&k!==9)return[];i=g(b);if(!i&&!d)if(e=P.exec(a))if(j=e[1]){if(k===9){f=b.getElementById(j);if(!f||!f.parentNode)return c;if(f.id===j)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(j))&&h(b,f)&&f.id===j)return c.push(f),c}else{if(e[2])return w.apply(c,x.call(b.getElementsByTagName(a),0)),c;if((j=e[3])&&_&&b.getElementsByClassName)return w.apply(c,x.call(b.getElementsByClassName(j),0)),c}return bp(a.replace(L,"$1"),b,c,d,i)}function bd(a){return function(b){var c=b.nodeName.toLowerCase();return c==="input"&&b.type===a}}function be(a){return function(b){var c=b.nodeName.toLowerCase();return(c==="input"||c==="button")&&b.type===a}}function bf(a){return z(function(b){return b=+b,z(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function bg(a,b,c){if(a===b)return c;var d=a.nextSibling;while(d){if(d===b)return-1;d=d.nextSibling}return 1}function bh(a,b){var c,d,f,g,h,i,j,k=C[o][a];if(k)return b?0:k.slice(0);h=a,i=[],j=e.preFilter;while(h){if(!c||(d=M.exec(h)))d&&(h=h.slice(d[0].length)),i.push(f=[]);c=!1;if(d=N.exec(h))f.push(c=new q(d.shift())),h=h.slice(c.length),c.type=d[0].replace(L," ");for(g in e.filter)(d=W[g].exec(h))&&(!j[g]||(d=j[g](d,r,!0)))&&(f.push(c=new q(d.shift())),h=h.slice(c.length),c.type=g,c.matches=d);if(!c)break}return b?h.length:h?bc.error(a):C(a,i).slice(0)}function bi(a,b,d){var e=b.dir,f=d&&b.dir==="parentNode",g=u++;return b.first?function(b,c,d){while(b=b[e])if(f||b.nodeType===1)return a(b,c,d)}:function(b,d,h){if(!h){var i,j=t+" "+g+" ",k=j+c;while(b=b[e])if(f||b.nodeType===1){if((i=b[o])===k)return b.sizset;if(typeof i=="string"&&i.indexOf(j)===0){if(b.sizset)return b}else{b[o]=k;if(a(b,d,h))return b.sizset=!0,b;b.sizset=!1}}}else while(b=b[e])if(f||b.nodeType===1)if(a(b,d,h))return b}}function bj(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function bk(a,b,c,d,e){var f,g=[],h=0,i=a.length,j=b!=null;for(;h-1},h,!0),m=[function(a,c,d){return!g&&(d||c!==l)||((b=c).nodeType?j(a,c,d):k(a,c,d))}];for(;i1&&bj(m),i>1&&a.slice(0,i-1).join("").replace(L,"$1"),c,i0,f=a.length>0,g=function(h,i,j,k,m){var n,o,p,q=[],s=0,u="0",x=h&&[],y=m!=null,z=l,A=h||f&&e.find.TAG("*",m&&i.parentNode||i),B=t+=z==null?1:Math.E;y&&(l=i!==r&&i,c=g.el);for(;(n=A[u])!=null;u++){if(f&&n){for(o=0;p=a[o];o++)if(p(n,i,j)){k.push(n);break}y&&(t=B,c=++g.el)}d&&((n=!p&&n)&&s--,h&&x.push(n))}s+=u;if(d&&u!==s){for(o=0;p=b[o];o++)p(x,q,i,j);if(h){if(s>0)while(u--)!x[u]&&!q[u]&&(q[u]=v.call(k));q=bk(q)}w.apply(k,q),y&&!h&&q.length>0&&s+b.length>1&&bc.uniqueSort(k)}return y&&(t=B,l=z),x};return g.el=0,d?z(g):g}function bo(a,b,c,d){var e=0,f=b.length;for(;e2&&(j=h[0]).type==="ID"&&b.nodeType===9&&!f&&e.relative[h[1].type]){b=e.find.ID(j.matches[0].replace(V,""),b,f)[0];if(!b)return c;a=a.slice(h.shift().length)}for(g=W.POS.test(a)?-1:h.length-1;g>=0;g--){j=h[g];if(e.relative[k=j.type])break;if(l=e.find[k])if(d=l(j.matches[0].replace(V,""),R.test(h[0].type)&&b.parentNode||b,f)){h.splice(g,1),a=d.length&&h.join("");if(!a)return w.apply(c,x.call(d,0)),c;break}}}return i(a,m)(d,b,f,c,R.test(a)),c}function bq(){}var c,d,e,f,g,h,i,j,k,l,m=!0,n="undefined",o=("sizcache"+Math.random()).replace(".",""),q=String,r=a.document,s=r.documentElement,t=0,u=0,v=[].pop,w=[].push,x=[].slice,y=[].indexOf||function(a){var b=0,c=this.length;for(;be.cacheLength&&delete a[b.shift()],a[c]=d},a)},B=A(),C=A(),D=A(),E="[\\x20\\t\\r\\n\\f]",F="(?:\\\\.|[-\\w]|[^\\x00-\\xa0])+",G=F.replace("w","w#"),H="([*^$|!~]?=)",I="\\["+E+"*("+F+")"+E+"*(?:"+H+E+"*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|("+G+")|)|)"+E+"*\\]",J=":("+F+")(?:\\((?:(['\"])((?:\\\\.|[^\\\\])*?)\\2|([^()[\\]]*|(?:(?:"+I+")|[^:]|\\\\.)*|.*))\\)|)",K=":(even|odd|eq|gt|lt|nth|first|last)(?:\\("+E+"*((?:-\\d)?\\d*)"+E+"*\\)|)(?=[^-]|$)",L=new RegExp("^"+E+"+|((?:^|[^\\\\])(?:\\\\.)*)"+E+"+$","g"),M=new RegExp("^"+E+"*,"+E+"*"),N=new RegExp("^"+E+"*([\\x20\\t\\r\\n\\f>+~])"+E+"*"),O=new RegExp(J),P=/^(?:#([\w\-]+)|(\w+)|\.([\w\-]+))$/,Q=/^:not/,R=/[\x20\t\r\n\f]*[+~]/,S=/:not\($/,T=/h\d/i,U=/input|select|textarea|button/i,V=/\\(?!\\)/g,W={ID:new RegExp("^#("+F+")"),CLASS:new RegExp("^\\.("+F+")"),NAME:new RegExp("^\\[name=['\"]?("+F+")['\"]?\\]"),TAG:new RegExp("^("+F.replace("w","w*")+")"),ATTR:new RegExp("^"+I),PSEUDO:new RegExp("^"+J),POS:new RegExp(K,"i"),CHILD:new RegExp("^:(only|nth|first|last)-child(?:\\("+E+"*(even|odd|(([+-]|)(\\d*)n|)"+E+"*(?:([+-]|)"+E+"*(\\d+)|))"+E+"*\\)|)","i"),needsContext:new RegExp("^"+E+"*[>+~]|"+K,"i")},X=function(a){var b=r.createElement("div");try{return a(b)}catch(c){return!1}finally{b=null}},Y=X(function(a){return a.appendChild(r.createComment("")),!a.getElementsByTagName("*").length}),Z=X(function(a){return a.innerHTML=" ",a.firstChild&&typeof a.firstChild.getAttribute!==n&&a.firstChild.getAttribute("href")==="#"}),$=X(function(a){a.innerHTML=" ";var b=typeof a.lastChild.getAttribute("multiple");return b!=="boolean"&&b!=="string"}),_=X(function(a){return a.innerHTML="
",!a.getElementsByClassName||!a.getElementsByClassName("e").length?!1:(a.lastChild.className="e",a.getElementsByClassName("e").length===2)}),ba=X(function(a){a.id=o+0,a.innerHTML="
",s.insertBefore(a,s.firstChild);var b=r.getElementsByName&&r.getElementsByName(o).length===2+r.getElementsByName(o+0).length;return d=!r.getElementById(o),s.removeChild(a),b});try{x.call(s.childNodes,0)[0].nodeType}catch(bb){x=function(a){var b,c=[];for(;b=this[a];a++)c.push(b);return c}}bc.matches=function(a,b){return bc(a,null,null,b)},bc.matchesSelector=function(a,b){return bc(b,null,null,[a]).length>0},f=bc.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(e===1||e===9||e===11){if(typeof a.textContent=="string")return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=f(a)}else if(e===3||e===4)return a.nodeValue}else for(;b=a[d];d++)c+=f(b);return c},g=bc.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?b.nodeName!=="HTML":!1},h=bc.contains=s.contains?function(a,b){var c=a.nodeType===9?a.documentElement:a,d=b&&b.parentNode;return a===d||!!(d&&d.nodeType===1&&c.contains&&c.contains(d))}:s.compareDocumentPosition?function(a,b){return b&&!!(a.compareDocumentPosition(b)&16)}:function(a,b){while(b=b.parentNode)if(b===a)return!0;return!1},bc.attr=function(a,b){var c,d=g(a);return d||(b=b.toLowerCase()),(c=e.attrHandle[b])?c(a):d||$?a.getAttribute(b):(c=a.getAttributeNode(b),c?typeof a[b]=="boolean"?a[b]?b:null:c.specified?c.value:null:null)},e=bc.selectors={cacheLength:50,createPseudo:z,match:W,attrHandle:Z?{}:{href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}},find:{ID:d?function(a,b,c){if(typeof b.getElementById!==n&&!c){var d=b.getElementById(a);return d&&d.parentNode?[d]:[]}}:function(a,c,d){if(typeof c.getElementById!==n&&!d){var e=c.getElementById(a);return e?e.id===a||typeof e.getAttributeNode!==n&&e.getAttributeNode("id").value===a?[e]:b:[]}},TAG:Y?function(a,b){if(typeof b.getElementsByTagName!==n)return b.getElementsByTagName(a)}:function(a,b){var c=b.getElementsByTagName(a);if(a==="*"){var d,e=[],f=0;for(;d=c[f];f++)d.nodeType===1&&e.push(d);return e}return c},NAME:ba&&function(a,b){if(typeof b.getElementsByName!==n)return b.getElementsByName(name)},CLASS:_&&function(a,b,c){if(typeof b.getElementsByClassName!==n&&!c)return b.getElementsByClassName(a)}},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(V,""),a[3]=(a[4]||a[5]||"").replace(V,""),a[2]==="~="&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),a[1]==="nth"?(a[2]||bc.error(a[0]),a[3]=+(a[3]?a[4]+(a[5]||1):2*(a[2]==="even"||a[2]==="odd")),a[4]=+(a[6]+a[7]||a[2]==="odd")):a[2]&&bc.error(a[0]),a},PSEUDO:function(a){var b,c;if(W.CHILD.test(a[0]))return null;if(a[3])a[2]=a[3];else if(b=a[4])O.test(b)&&(c=bh(b,!0))&&(c=b.indexOf(")",b.length-c)-b.length)&&(b=b.slice(0,c),a[0]=a[0].slice(0,c)),a[2]=b;return a.slice(0,3)}},filter:{ID:d?function(a){return a=a.replace(V,""),function(b){return b.getAttribute("id")===a}}:function(a){return a=a.replace(V,""),function(b){var c=typeof b.getAttributeNode!==n&&b.getAttributeNode("id");return c&&c.value===a}},TAG:function(a){return a==="*"?function(){return!0}:(a=a.replace(V,"").toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=B[o][a];return b||(b=B(a,new RegExp("(^|"+E+")"+a+"("+E+"|$)"))),function(a){return b.test(a.className||typeof a.getAttribute!==n&&a.getAttribute("class")||"")}},ATTR:function(a,b,c){return function(d,e){var f=bc.attr(d,a);return f==null?b==="!=":b?(f+="",b==="="?f===c:b==="!="?f!==c:b==="^="?c&&f.indexOf(c)===0:b==="*="?c&&f.indexOf(c)>-1:b==="$="?c&&f.substr(f.length-c.length)===c:b==="~="?(" "+f+" ").indexOf(c)>-1:b==="|="?f===c||f.substr(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d){return a==="nth"?function(a){var b,e,f=a.parentNode;if(c===1&&d===0)return!0;if(f){e=0;for(b=f.firstChild;b;b=b.nextSibling)if(b.nodeType===1){e++;if(a===b)break}}return e-=d,e===c||e%c===0&&e/c>=0}:function(b){var c=b;switch(a){case"only":case"first":while(c=c.previousSibling)if(c.nodeType===1)return!1;if(a==="first")return!0;c=b;case"last":while(c=c.nextSibling)if(c.nodeType===1)return!1;return!0}}},PSEUDO:function(a,b){var c,d=e.pseudos[a]||e.setFilters[a.toLowerCase()]||bc.error("unsupported pseudo: "+a);return d[o]?d(b):d.length>1?(c=[a,a,"",b],e.setFilters.hasOwnProperty(a.toLowerCase())?z(function(a,c){var e,f=d(a,b),g=f.length;while(g--)e=y.call(a,f[g]),a[e]=!(c[e]=f[g])}):function(a){return d(a,0,c)}):d}},pseudos:{not:z(function(a){var b=[],c=[],d=i(a.replace(L,"$1"));return d[o]?z(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)if(f=g[h])a[h]=!(b[h]=f)}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:z(function(a){return function(b){return bc(a,b).length>0}}),contains:z(function(a){return function(b){return(b.textContent||b.innerText||f(b)).indexOf(a)>-1}}),enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&!!a.checked||b==="option"&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},parent:function(a){return!e.pseudos.empty(a)},empty:function(a){var b;a=a.firstChild;while(a){if(a.nodeName>"@"||(b=a.nodeType)===3||b===4)return!1;a=a.nextSibling}return!0},header:function(a){return T.test(a.nodeName)},text:function(a){var b,c;return a.nodeName.toLowerCase()==="input"&&(b=a.type)==="text"&&((c=a.getAttribute("type"))==null||c.toLowerCase()===b)},radio:bd("radio"),checkbox:bd("checkbox"),file:bd("file"),password:bd("password"),image:bd("image"),submit:be("submit"),reset:be("reset"),button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&a.type==="button"||b==="button"},input:function(a){return U.test(a.nodeName)},focus:function(a){var b=a.ownerDocument;return a===b.activeElement&&(!b.hasFocus||b.hasFocus())&&(!!a.type||!!a.href)},active:function(a){return a===a.ownerDocument.activeElement},first:bf(function(a,b,c){return[0]}),last:bf(function(a,b,c){return[b-1]}),eq:bf(function(a,b,c){return[c<0?c+b:c]}),even:bf(function(a,b,c){for(var d=0;d=0;)a.push(d);return a}),gt:bf(function(a,b,c){for(var d=c<0?c+b:c;++d ",a.querySelectorAll("[selected]").length||e.push("\\["+E+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||e.push(":checked")}),X(function(a){a.innerHTML="
",a.querySelectorAll("[test^='']").length&&e.push("[*^$]="+E+"*(?:\"\"|'')"),a.innerHTML=" ",a.querySelectorAll(":enabled").length||e.push(":enabled",":disabled")}),e=new RegExp(e.join("|")),bp=function(a,d,f,g,h){if(!g&&!h&&(!e||!e.test(a))){var i,j,k=!0,l=o,m=d,n=d.nodeType===9&&a;if(d.nodeType===1&&d.nodeName.toLowerCase()!=="object"){i=bh(a),(k=d.getAttribute("id"))?l=k.replace(c,"\\$&"):d.setAttribute("id",l),l="[id='"+l+"'] ",j=i.length;while(j--)i[j]=l+i[j].join("");m=R.test(a)&&d.parentNode||d,n=i.join(",")}if(n)try{return w.apply(f,x.call(m.querySelectorAll(n),0)),f}catch(p){}finally{k||d.removeAttribute("id")}}return b(a,d,f,g,h)},h&&(X(function(b){a=h.call(b,"div");try{h.call(b,"[test!='']:sizzle"),f.push("!=",J)}catch(c){}}),f=new RegExp(f.join("|")),bc.matchesSelector=function(b,c){c=c.replace(d,"='$1']");if(!g(b)&&!f.test(c)&&(!e||!e.test(c)))try{var i=h.call(b,c);if(i||a||b.document&&b.document.nodeType!==11)return i}catch(j){}return bc(c,null,null,[b]).length>0})}(),e.pseudos.nth=e.pseudos.eq,e.filters=bq.prototype=e.pseudos,e.setFilters=new bq,bc.attr=p.attr,p.find=bc,p.expr=bc.selectors,p.expr[":"]=p.expr.pseudos,p.unique=bc.uniqueSort,p.text=bc.getText,p.isXMLDoc=bc.isXML,p.contains=bc.contains}(a);var bc=/Until$/,bd=/^(?:parents|prev(?:Until|All))/,be=/^.[^:#\[\.,]*$/,bf=p.expr.match.needsContext,bg={children:!0,contents:!0,next:!0,prev:!0};p.fn.extend({find:function(a){var b,c,d,e,f,g,h=this;if(typeof a!="string")return p(a).filter(function(){for(b=0,c=h.length;b0)for(e=d;e=0:p.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c,d=0,e=this.length,f=[],g=bf.test(a)||typeof a!="string"?p(a,b||this.context):0;for(;d-1:p.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}}return f=f.length>1?p.unique(f):f,this.pushStack(f,"closest",a)},index:function(a){return a?typeof a=="string"?p.inArray(this[0],p(a)):p.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.prevAll().length:-1},add:function(a,b){var c=typeof a=="string"?p(a,b):p.makeArray(a&&a.nodeType?[a]:a),d=p.merge(this.get(),c);return this.pushStack(bh(c[0])||bh(d[0])?d:p.unique(d))},addBack:function(a){return this.add(a==null?this.prevObject:this.prevObject.filter(a))}}),p.fn.andSelf=p.fn.addBack,p.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return p.dir(a,"parentNode")},parentsUntil:function(a,b,c){return p.dir(a,"parentNode",c)},next:function(a){return bi(a,"nextSibling")},prev:function(a){return bi(a,"previousSibling")},nextAll:function(a){return p.dir(a,"nextSibling")},prevAll:function(a){return p.dir(a,"previousSibling")},nextUntil:function(a,b,c){return p.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return p.dir(a,"previousSibling",c)},siblings:function(a){return p.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return p.sibling(a.firstChild)},contents:function(a){return p.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:p.merge([],a.childNodes)}},function(a,b){p.fn[a]=function(c,d){var e=p.map(this,b,c);return bc.test(a)||(d=c),d&&typeof d=="string"&&(e=p.filter(d,e)),e=this.length>1&&!bg[a]?p.unique(e):e,this.length>1&&bd.test(a)&&(e=e.reverse()),this.pushStack(e,a,k.call(arguments).join(","))}}),p.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),b.length===1?p.find.matchesSelector(b[0],a)?[b[0]]:[]:p.find.matches(a,b)},dir:function(a,c,d){var e=[],f=a[c];while(f&&f.nodeType!==9&&(d===b||f.nodeType!==1||!p(f).is(d)))f.nodeType===1&&e.push(f),f=f[c];return e},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var bl="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",bm=/ jQuery\d+="(?:null|\d+)"/g,bn=/^\s+/,bo=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,bp=/<([\w:]+)/,bq=/ ]","i"),bv=/^(?:checkbox|radio)$/,bw=/checked\s*(?:[^=]|=\s*.checked.)/i,bx=/\/(java|ecma)script/i,by=/^\s*\s*$/g,bz={option:[1,""," "],legend:[1,""," "],thead:[1,""],tr:[2,""],td:[3,""],col:[2,""],area:[1,""," "],_default:[0,"",""]},bA=bk(e),bB=bA.appendChild(e.createElement("div"));bz.optgroup=bz.option,bz.tbody=bz.tfoot=bz.colgroup=bz.caption=bz.thead,bz.th=bz.td,p.support.htmlSerialize||(bz._default=[1,"X","
"]),p.fn.extend({text:function(a){return p.access(this,function(a){return a===b?p.text(this):this.empty().append((this[0]&&this[0].ownerDocument||e).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(p.isFunction(a))return this.each(function(b){p(this).wrapAll(a.call(this,b))});if(this[0]){var b=p(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return p.isFunction(a)?this.each(function(b){p(this).wrapInner(a.call(this,b))}):this.each(function(){var b=p(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=p.isFunction(a);return this.each(function(c){p(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){p.nodeName(this,"body")||p(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){(this.nodeType===1||this.nodeType===11)&&this.insertBefore(a,this.firstChild)})},before:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(a,this),"before",this.selector)}},after:function(){if(!bh(this[0]))return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=p.clean(arguments);return this.pushStack(p.merge(this,a),"after",this.selector)}},remove:function(a,b){var c,d=0;for(;(c=this[d])!=null;d++)if(!a||p.filter(a,[c]).length)!b&&c.nodeType===1&&(p.cleanData(c.getElementsByTagName("*")),p.cleanData([c])),c.parentNode&&c.parentNode.removeChild(c);return this},empty:function(){var a,b=0;for(;(a=this[b])!=null;b++){a.nodeType===1&&p.cleanData(a.getElementsByTagName("*"));while(a.firstChild)a.removeChild(a.firstChild)}return this},clone:function(a,b){return a=a==null?!1:a,b=b==null?a:b,this.map(function(){return p.clone(this,a,b)})},html:function(a){return p.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return c.nodeType===1?c.innerHTML.replace(bm,""):b;if(typeof a=="string"&&!bs.test(a)&&(p.support.htmlSerialize||!bu.test(a))&&(p.support.leadingWhitespace||!bn.test(a))&&!bz[(bp.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(bo,"<$1>$2>");try{for(;d1&&typeof j=="string"&&bw.test(j))return this.each(function(){p(this).domManip(a,c,d)});if(p.isFunction(j))return this.each(function(e){var f=p(this);a[0]=j.call(this,e,c?f.html():b),f.domManip(a,c,d)});if(this[0]){e=p.buildFragment(a,this,k),g=e.fragment,f=g.firstChild,g.childNodes.length===1&&(g=f);if(f){c=c&&p.nodeName(f,"tr");for(h=e.cacheable||l-1;i0?this.clone(!0):this).get(),p(g[e])[b](d),f=f.concat(d);return this.pushStack(f,a,g.selector)}}),p.extend({clone:function(a,b,c){var d,e,f,g;p.support.html5Clone||p.isXMLDoc(a)||!bu.test("<"+a.nodeName+">")?g=a.cloneNode(!0):(bB.innerHTML=a.outerHTML,bB.removeChild(g=bB.firstChild));if((!p.support.noCloneEvent||!p.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!p.isXMLDoc(a)){bE(a,g),d=bF(a),e=bF(g);for(f=0;d[f];++f)e[f]&&bE(d[f],e[f])}if(b){bD(a,g);if(c){d=bF(a),e=bF(g);for(f=0;d[f];++f)bD(d[f],e[f])}}return d=e=null,g},clean:function(a,b,c,d){var f,g,h,i,j,k,l,m,n,o,q,r,s=b===e&&bA,t=[];if(!b||typeof b.createDocumentFragment=="undefined")b=e;for(f=0;(h=a[f])!=null;f++){typeof h=="number"&&(h+="");if(!h)continue;if(typeof h=="string")if(!br.test(h))h=b.createTextNode(h);else{s=s||bk(b),l=b.createElement("div"),s.appendChild(l),h=h.replace(bo,"<$1>$2>"),i=(bp.exec(h)||["",""])[1].toLowerCase(),j=bz[i]||bz._default,k=j[0],l.innerHTML=j[1]+h+j[2];while(k--)l=l.lastChild;if(!p.support.tbody){m=bq.test(h),n=i==="table"&&!m?l.firstChild&&l.firstChild.childNodes:j[1]===""&&!m?l.childNodes:[];for(g=n.length-1;g>=0;--g)p.nodeName(n[g],"tbody")&&!n[g].childNodes.length&&n[g].parentNode.removeChild(n[g])}!p.support.leadingWhitespace&&bn.test(h)&&l.insertBefore(b.createTextNode(bn.exec(h)[0]),l.firstChild),h=l.childNodes,l.parentNode.removeChild(l)}h.nodeType?t.push(h):p.merge(t,h)}l&&(h=l=s=null);if(!p.support.appendChecked)for(f=0;(h=t[f])!=null;f++)p.nodeName(h,"input")?bG(h):typeof h.getElementsByTagName!="undefined"&&p.grep(h.getElementsByTagName("input"),bG);if(c){q=function(a){if(!a.type||bx.test(a.type))return d?d.push(a.parentNode?a.parentNode.removeChild(a):a):c.appendChild(a)};for(f=0;(h=t[f])!=null;f++)if(!p.nodeName(h,"script")||!q(h))c.appendChild(h),typeof h.getElementsByTagName!="undefined"&&(r=p.grep(p.merge([],h.getElementsByTagName("script")),q),t.splice.apply(t,[f+1,0].concat(r)),f+=r.length)}return t},cleanData:function(a,b){var c,d,e,f,g=0,h=p.expando,i=p.cache,j=p.support.deleteExpando,k=p.event.special;for(;(e=a[g])!=null;g++)if(b||p.acceptData(e)){d=e[h],c=d&&i[d];if(c){if(c.events)for(f in c.events)k[f]?p.event.remove(e,f):p.removeEvent(e,f,c.handle);i[d]&&(delete i[d],j?delete e[h]:e.removeAttribute?e.removeAttribute(h):e[h]=null,p.deletedIds.push(d))}}}}),function(){var a,b;p.uaMatch=function(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},a=p.uaMatch(g.userAgent),b={},a.browser&&(b[a.browser]=!0,b.version=a.version),b.chrome?b.webkit=!0:b.webkit&&(b.safari=!0),p.browser=b,p.sub=function(){function a(b,c){return new a.fn.init(b,c)}p.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.sub=this.sub,a.fn.init=function c(c,d){return d&&d instanceof p&&!(d instanceof a)&&(d=a(d)),p.fn.init.call(this,c,d,b)},a.fn.init.prototype=a.fn;var b=a(e);return a}}();var bH,bI,bJ,bK=/alpha\([^)]*\)/i,bL=/opacity=([^)]*)/,bM=/^(top|right|bottom|left)$/,bN=/^(none|table(?!-c[ea]).+)/,bO=/^margin/,bP=new RegExp("^("+q+")(.*)$","i"),bQ=new RegExp("^("+q+")(?!px)[a-z%]+$","i"),bR=new RegExp("^([-+])=("+q+")","i"),bS={},bT={position:"absolute",visibility:"hidden",display:"block"},bU={letterSpacing:0,fontWeight:400},bV=["Top","Right","Bottom","Left"],bW=["Webkit","O","Moz","ms"],bX=p.fn.toggle;p.fn.extend({css:function(a,c){return p.access(this,function(a,c,d){return d!==b?p.style(a,c,d):p.css(a,c)},a,c,arguments.length>1)},show:function(){return b$(this,!0)},hide:function(){return b$(this)},toggle:function(a,b){var c=typeof a=="boolean";return p.isFunction(a)&&p.isFunction(b)?bX.apply(this,arguments):this.each(function(){(c?a:bZ(this))?p(this).show():p(this).hide()})}}),p.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bH(a,"opacity");return c===""?"1":c}}}},cssNumber:{fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":p.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(!a||a.nodeType===3||a.nodeType===8||!a.style)return;var f,g,h,i=p.camelCase(c),j=a.style;c=p.cssProps[i]||(p.cssProps[i]=bY(j,i)),h=p.cssHooks[c]||p.cssHooks[i];if(d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];g=typeof d,g==="string"&&(f=bR.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(p.css(a,c)),g="number");if(d==null||g==="number"&&isNaN(d))return;g==="number"&&!p.cssNumber[i]&&(d+="px");if(!h||!("set"in h)||(d=h.set(a,d,e))!==b)try{j[c]=d}catch(k){}},css:function(a,c,d,e){var f,g,h,i=p.camelCase(c);return c=p.cssProps[i]||(p.cssProps[i]=bY(a.style,i)),h=p.cssHooks[c]||p.cssHooks[i],h&&"get"in h&&(f=h.get(a,!0,e)),f===b&&(f=bH(a,c)),f==="normal"&&c in bU&&(f=bU[c]),d||e!==b?(g=parseFloat(f),d||p.isNumeric(g)?g||0:f):f},swap:function(a,b,c){var d,e,f={};for(e in b)f[e]=a.style[e],a.style[e]=b[e];d=c.call(a);for(e in b)a.style[e]=f[e];return d}}),a.getComputedStyle?bH=function(b,c){var d,e,f,g,h=a.getComputedStyle(b,null),i=b.style;return h&&(d=h[c],d===""&&!p.contains(b.ownerDocument,b)&&(d=p.style(b,c)),bQ.test(d)&&bO.test(c)&&(e=i.width,f=i.minWidth,g=i.maxWidth,i.minWidth=i.maxWidth=i.width=d,d=h.width,i.width=e,i.minWidth=f,i.maxWidth=g)),d}:e.documentElement.currentStyle&&(bH=function(a,b){var c,d,e=a.currentStyle&&a.currentStyle[b],f=a.style;return e==null&&f&&f[b]&&(e=f[b]),bQ.test(e)&&!bM.test(b)&&(c=f.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":e,e=f.pixelLeft+"px",f.left=c,d&&(a.runtimeStyle.left=d)),e===""?"auto":e}),p.each(["height","width"],function(a,b){p.cssHooks[b]={get:function(a,c,d){if(c)return a.offsetWidth===0&&bN.test(bH(a,"display"))?p.swap(a,bT,function(){return cb(a,b,d)}):cb(a,b,d)},set:function(a,c,d){return b_(a,c,d?ca(a,b,d,p.support.boxSizing&&p.css(a,"boxSizing")==="border-box"):0)}}}),p.support.opacity||(p.cssHooks.opacity={get:function(a,b){return bL.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=p.isNumeric(b)?"alpha(opacity="+b*100+")":"",f=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&p.trim(f.replace(bK,""))===""&&c.removeAttribute){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bK.test(f)?f.replace(bK,e):f+" "+e}}),p(function(){p.support.reliableMarginRight||(p.cssHooks.marginRight={get:function(a,b){return p.swap(a,{display:"inline-block"},function(){if(b)return bH(a,"marginRight")})}}),!p.support.pixelPosition&&p.fn.position&&p.each(["top","left"],function(a,b){p.cssHooks[b]={get:function(a,c){if(c){var d=bH(a,b);return bQ.test(d)?p(a).position()[b]+"px":d}}}})}),p.expr&&p.expr.filters&&(p.expr.filters.hidden=function(a){return a.offsetWidth===0&&a.offsetHeight===0||!p.support.reliableHiddenOffsets&&(a.style&&a.style.display||bH(a,"display"))==="none"},p.expr.filters.visible=function(a){return!p.expr.filters.hidden(a)}),p.each({margin:"",padding:"",border:"Width"},function(a,b){p.cssHooks[a+b]={expand:function(c){var d,e=typeof c=="string"?c.split(" "):[c],f={};for(d=0;d<4;d++)f[a+bV[d]+b]=e[d]||e[d-2]||e[0];return f}},bO.test(a)||(p.cssHooks[a+b].set=b_)});var cd=/%20/g,ce=/\[\]$/,cf=/\r?\n/g,cg=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,ch=/^(?:select|textarea)/i;p.fn.extend({serialize:function(){return p.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?p.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||ch.test(this.nodeName)||cg.test(this.type))}).map(function(a,b){var c=p(this).val();return c==null?null:p.isArray(c)?p.map(c,function(a,c){return{name:b.name,value:a.replace(cf,"\r\n")}}):{name:b.name,value:c.replace(cf,"\r\n")}}).get()}}),p.param=function(a,c){var d,e=[],f=function(a,b){b=p.isFunction(b)?b():b==null?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=p.ajaxSettings&&p.ajaxSettings.traditional);if(p.isArray(a)||a.jquery&&!p.isPlainObject(a))p.each(a,function(){f(this.name,this.value)});else for(d in a)ci(d,a[d],c,f);return e.join("&").replace(cd,"+")};var cj,ck,cl=/#.*$/,cm=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,cn=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,co=/^(?:GET|HEAD)$/,cp=/^\/\//,cq=/\?/,cr=/