From b8ca6732ec20cb060cff2fe8c86704fde615429b Mon Sep 17 00:00:00 2001 From: Robin Hawkes Date: Tue, 3 Mar 2015 01:07:07 +0000 Subject: [PATCH] Added layers UI option --- build/vizi.js | 12 ++++++++---- build/vizi.min.js | 2 +- examples/basic-example/main.js | 3 ++- src/Core/World.js | 12 ++++++++---- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/build/vizi.js b/build/vizi.js index e33e583..ba049c2 100644 --- a/build/vizi.js +++ b/build/vizi.js @@ -6573,7 +6573,8 @@ if (typeof window === undefined) { crs: VIZI.CRS.EPSG3857, center: new VIZI.LatLon(51.50358, -0.01924), zoom: 16, - suppressRenderer: false // Set true for tests + suppressRenderer: false, // Set true for tests + layersUI: true }); if (!self.options.viewport) { @@ -6599,8 +6600,9 @@ if (typeof window === undefined) { self.options.viewport.appendChild(uiContainer); // Set up layer UI - // TODO: Make this togglable via an option - self.layersUI = new VIZI.LayersUI(self.layers); + if (self.options.layersUI) { + self.layersUI = new VIZI.LayersUI(self.layers); + } // TODO: Ability to override this with a scene passed into the options // TODO: Pass-through options that tweak scene (antialias, etc) @@ -6682,7 +6684,9 @@ if (typeof window === undefined) { self.scene.add(layer.object); // Update layers UI - self.layersUI.onChange(); + if (self.layersUI) { + self.layersUI.onChange(); + } }; VIZI.World.prototype.addSwitchboard = function(switchboard) { diff --git a/build/vizi.min.js b/build/vizi.min.js index 98de921..be52118 100644 --- a/build/vizi.min.js +++ b/build/vizi.min.js @@ -965,7 +965,7 @@ WildEmitter.prototype.getWildcardCallbacks = function (eventName) { }; /*! ViziCities - v0.2.0 - 2015-03-03 */ -if(void 0===typeof window)var VIZI;!function(){"use strict";var a={VERSION:"0.2.0",DEBUG:!1};console.log("═════════════════════════════════════════════════════════════"),console.log("██╗ ██╗██╗███████╗██╗ ██████╗██╗████████╗██╗███████╗███████╗"),console.log("██║ ██║██║╚══███╔╝██║██╔════╝██║╚══██╔══╝██║██╔════╝██╔════╝"),console.log("██║ ██║██║ ███╔╝ ██║██║ ██║ ██║ ██║█████╗ ███████╗"),console.log("╚██╗ ██╔╝██║ ███╔╝ ██║██║ ██║ ██║ ██║██╔══╝ ╚════██║"),console.log(" ╚████╔╝ ██║███████╗██║╚██████╗██║ ██║ ██║███████╗███████║"),console.log(" ╚═══╝ ╚═╝╚══════╝╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝"),console.log("═══════════════════════════ "+a.VERSION+" ═══════════════════════════"),void 0===typeof window?window.VIZI=a:VIZI=a}(),function(){"use strict";VIZI.Attribution=function(a){var b=this;if(VIZI.DEBUG&&console.log("Initialising VIZI.Attribution"),b.options=a||{},_.defaults(b.options,{}),!b.options.element)throw new Error("Required element option missing");b.defaultMessage="Powered by ViziCities",b.container=b.createContainer(b.options.element),b.add(b.defaultMessage)},VIZI.Attribution.prototype.createContainer=function(a){var b=document.createElement("div");return b.classList.add("vizicities-attribution"),a.appendChild(b),b},VIZI.Attribution.prototype.add=function(a){var b=this,c="";b.container.innerHTML.length>0&&(c=" | "),b.container.innerHTML+=c+a}}(),function(){"use strict";VIZI.Clock=function(){VIZI.DEBUG&&console.log("Initialising VIZI.Clock");var a=this;THREE.Clock.call(a)},VIZI.Clock.prototype=Object.create(THREE.Clock.prototype)}(),function(){"use strict";VIZI.EventEmitter=function(){WildEmitter.call(this)},VIZI.EventEmitter.prototype=Object.create(WildEmitter.prototype)}(),function(){"use strict";VIZI.Messenger=function(){var a=new VIZI.EventEmitter;return a}()}(),function(){"use strict";VIZI.World=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.World");var b=this;if(b.options=a||{},_.defaults(b.options,{crs:VIZI.CRS.EPSG3857,center:new VIZI.LatLon(51.50358,-.01924),zoom:16,suppressRenderer:!1}),!b.options.viewport)throw new Error("Required viewport option missing");b.crs=b.options.crs,b.attribution=new VIZI.Attribution({element:b.options.viewport}),b.switchboards=[],b.layers=[];var c=document.createElement("div");c.classList.add("vizicities-ui"),b.options.viewport.appendChild(c),b.layersUI=new VIZI.LayersUI(b.layers),b.scene=new VIZI.Scene({viewport:b.options.viewport,suppressRenderer:b.options.suppressRenderer}),b.camera=b.options.camera||new VIZI.Camera({aspect:b.options.viewport.clientWidth/b.options.viewport.clientHeight}),b.camera.addToScene(b.scene),b.origin=new VIZI.LatLon(b.options.center),b.originZoom=b.options.zoom,b.zoom=void 0,b.center=void 0,b.updateView(b.options.center,b.options.zoom),window.addEventListener("resize",function(){b.resizeView(b.options.viewport.clientWidth,b.options.viewport.clientHeight)}),VIZI.Messenger.on("controls:move",function(a){b.moveToPoint(a)}),VIZI.Messenger.on("controls:zoom",function(a){var c=Math.ceil(b.crs.altitudeToZoom(a));b.zoomTo(c)})},VIZI.World.prototype.project=function(a,b){var c=this;b=b||c.originZoom;var d=c.crs.latLonToPoint(c.origin,b,{round:!0}),e=c.crs.latLonToPoint(a,b,{round:!0});return e.subtract(d)},VIZI.World.prototype.unproject=function(a,b){var c=this;b=b||c.originZoom;var d=c.crs.latLonToPoint(c.origin,b,{round:!0});return c.crs.pointToLatLon(a.add(d),b)},VIZI.World.prototype.pixelsPerMeter=function(a,b){var c=this;return b=b||c.originZoom,c.crs.pixelsPerMeter(a,b)},VIZI.World.prototype.addLayer=function(a){var b=this;b.layers.push(a),b.scene.add(a.object),b.layersUI.onChange()},VIZI.World.prototype.addSwitchboard=function(a){var b=this;b.switchboards.push(a)},VIZI.World.prototype.onTick=function(a){var b=this;_.each(b.switchboards,function(b){b.onTick(a)})},VIZI.World.prototype.render=function(){var a=this;a.scene.render(a.camera)},VIZI.World.prototype.updateView=function(a,b){var c=this;b&&(c.zoom=b),c.center=a,VIZI.Messenger.emit("world:updateView",c.center,c.zoom)},VIZI.World.prototype.resizeView=function(a,b){var c=this,d=a/b;c.camera.changeAspect(d),c.scene.resize(a,b)},VIZI.World.prototype.moveToLatLon=function(a){var b=this;b.updateView(a)},VIZI.World.prototype.moveToPoint=function(a){var b=this,c=b.unproject(a);b.updateView(c)},VIZI.World.prototype.moveBy=function(a){var b=this,c=b.crs.latLonToPoint(b.center,b.zoom),d=c.add(a);b.updateView(b.crs.pointToLatLon(d,b.zoom))},VIZI.World.prototype.zoomTo=function(a){var b=this;b.updateView(b.center,a)},VIZI.World.prototype.zoomIn=function(a){var b=this;b.updateView(b.center,b.zoom+a)},VIZI.World.prototype.zoomOut=function(a){var b=this;b.updateView(b.center,b.zoom-a)},VIZI.World.prototype.lookAtLatLon=function(a){var b=this,c=b.project(a);b.camera.lookAt(c)},VIZI.World.prototype.lookAtPoint=function(a){var b=this;b.camera.lookAt(a)}}(),function(){"use strict";var a=12756274,b=Math.PI*a,c=b/2;VIZI.CRS={code:void 0,tileSize:256,projection:void 0,inverseProjection:void 0,latLonToPoint:function(a,b,d){var e=this;d=d||{},_.defaults(d,{convert:!0,round:!1});var f,g=e.project(a),h=e.resolution(b);if(f=d.round===!0?new VIZI.Point(Math.round((g[0]+c)/h),Math.round((g[1]+c)/h)):new VIZI.Point((g[0]+c)/h,(g[1]+c)/h),d.convert!==!1){var i=e.tileSize<b?0:b>20?20:b}}}(),function(){"use strict";VIZI.Camera=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.Camera");var b=this;if(b.options=a||{},_.defaults(b.options,{fov:40,near:2,far:4e4,position:new VIZI.Point(260,600,550),target:new VIZI.Point}),!b.options.aspect)throw new Error("Required aspect option missing");b.camera=new THREE.PerspectiveCamera(b.options.fov,b.options.aspect,b.options.near,b.options.far),b.moveTo(b.options.position),b.lookAt(b.options.target)},VIZI.Camera.prototype.addToScene=function(a){var b=this;a.add(b.camera)},VIZI.Camera.prototype.moveTo=function(a){var b=this;b.camera.position.x=a.x,b.camera.position.y=a.y,b.camera.position.z=a.z},VIZI.Camera.prototype.moveBy=function(a){var b=this;b.camera.position.x+=a.x,b.camera.position.y+=a.y,b.camera.position.z+=a.z},VIZI.Camera.prototype.lookAt=function(a){var b=this;b.camera.lookAt(new THREE.Vector3(a.x,a.y,a.z))},VIZI.Camera.prototype.changeAspect=function(a){var b=this;b.camera.aspect=a,b.camera.updateProjectionMatrix()}}(),function(){"use strict";VIZI.Layer=function(){VIZI.DEBUG&&console.log("Initialising VIZI.Layer");var a=this;VIZI.EventEmitter.call(a),a.object=new THREE.Object3D},VIZI.Layer.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.Layer.prototype.addToWorld=function(a){var b=this;b.beforeAdd(a),a.addLayer(b),b.onAdd(a)},VIZI.Layer.prototype.beforeAdd=function(){},VIZI.Layer.prototype.onAdd=function(){},VIZI.Layer.prototype.add=function(a){var b=this;b.object.add(a)},VIZI.Layer.prototype.remove=function(a){var b=this;b.object.remove(a)},VIZI.Layer.prototype.applyVertexColors=function(a,b){a.faces.forEach(function(a){for(var c=a instanceof THREE.Face3?3:4,d=0;c>d;d++)a.vertexColors[d]=b})}}(),function(){"use strict";VIZI.Scene=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.Scene");var b=this;if(b.options=a||{},_.defaults(b.options,{antialias:!1,fogColour:16777215,suppressRenderer:!1}),!b.options.viewport)throw new Error("Required viewport option missing");b.scene=b.createScene(),b.renderer=b.createRenderer()},VIZI.Scene.prototype.createScene=function(){var a=this,b=new THREE.Scene;b.fog=new THREE.Fog(a.options.fogColour,1,15e3);var c=new THREE.DirectionalLight(10066329);c.intesity=.1,c.position.x=1,c.position.y=1,c.position.z=1,b.add(c);var d=new THREE.DirectionalLight(10066329);return d.intesity=.1,d.position.x=-1,d.position.y=1,d.position.z=-1,b.add(d),b},VIZI.Scene.prototype.createRenderer=function(){var a,b=this;return a=b.options.suppressRenderer?{setSize:function(){},setClearColor:function(){},render:function(){},domElement:document.createElement("canvas")}:new THREE.WebGLRenderer({antialias:b.options.antialias}),a.setSize(b.options.viewport.clientWidth,b.options.viewport.clientHeight),a.setClearColor(b.scene.fog.color,1),a.gammaInput=!0,a.gammaOutput=!0,b.options.viewport.appendChild(a.domElement),a},VIZI.Scene.prototype.add=function(a){var b=this;b.scene.add(a)},VIZI.Scene.prototype.remove=function(a){var b=this;b.scene.remove(a)},VIZI.Scene.prototype.render=function(a){var b=this;if(!b.scene)throw new Error("Scene is required for render");if(!a)throw new Error("Camera is required for render");b.renderer.render(b.scene,a.camera)},VIZI.Scene.prototype.resize=function(a,b){var c=this;c.renderer.setSize(a,b)}}(),function(){"use strict";VIZI.Controls=function(a,b){var c=this;if(VIZI.EventEmitter.call(c),c.options=b||{},_.defaults(c.options,{}),!a)throw new Error("Required camera missing")},VIZI.Controls.prototype=Object.create(VIZI.EventEmitter.prototype)}(),function(){"use strict";VIZI.LayersUI=function(a){var b=this,c=b;b.layers=a,b.layerControl=React.createClass({displayName:"layerControl",render:function(){var a=this,b=a.props.layers.map(function(b){var d;return d=b.hidden?React.createElement("input",{type:"checkbox",onClick:a.props.onShow.bind(c,b.object.id)}):React.createElement("input",{type:"checkbox",checked:!0,onClick:a.props.onHide.bind(c,b.object.id)}),React.createElement("li",{key:b.object.id},d," ",b.name)});return React.createElement("section",{className:"vizicities-layers-ui"},React.createElement("header",null,React.createElement("h2",null,"Layers")),React.createElement("ul",null,b))}}),b.onChange()},VIZI.LayersUI.prototype.onHideLayer=function(a){var b=this,c=_.find(b.layers,function(b){return b.object.id===a});c&&(c.object.visible=!1,c.hidden=!0),b.onChange()},VIZI.LayersUI.prototype.onShowLayer=function(a){var b=this,c=_.find(b.layers,function(b){return b.object.id===a});c&&(c.object.visible=!0,c.hidden=!1),b.onChange()},VIZI.LayersUI.prototype.onChange=function(){var a=this,b=a.layerControl;React.render(React.createElement(b,{layers:a.layers,onHide:a.onHideLayer,onShow:a.onShowLayer}),document.querySelector(".vizicities-ui"))}}(),function(){"use strict";VIZI.BlueprintHelperTileGrid=function(a,b){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintHelperTileGrid");var c=this;if(VIZI.EventEmitter.call(c),!(a&&a instanceof VIZI.World))throw new Error("Required world property missing");if(c.world=a,c.options=b||{},_.defaults(c.options,{}),!c.options.zoom)throw new Error("Required options zoom property missing");if(!c.options.cullZoom)throw new Error("Required options cull zoom property missing");if(void 0===c.options.tilesPerDirection)throw new Error("Required options tiles per direction property missing");c.disable=!1,c.centerTile=new VIZI.Point,c.centerTileLatLon=new VIZI.LatLon,c.tileZoom=c.options.zoom,c.cullZoom=c.options.cullZoom,c.tilesPerDirection=c.options.tilesPerDirection,c.bounds,c.boundsLatLon,c.tileCount,c.tiles=[],c.gridDiffSinceMouseUp=new VIZI.Point},VIZI.BlueprintHelperTileGrid.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.BlueprintHelperTileGrid.prototype.init=function(){var a=this,b=a.world.center;VIZI.DEBUG&&console.log("coords",b),a.centerTile=a.world.crs.latLonToTile(b,a.tileZoom),VIZI.DEBUG&&console.log("centerTile",a.centerTile),a.centerTileLatLon=new VIZI.LatLon(a.world.center),VIZI.DEBUG&&console.log("centerTileLatLon",a.centerTileLatLon);var c=a.world.crs.tileBoundsPoint(a.centerTile,a.tileZoom);return VIZI.DEBUG&&console.log("centerTileBoundsPoint",c),a.bounds=a.getBounds(a.tilesPerDirection),a.boundsLatLon=a.getBoundsLatLon(a.bounds),VIZI.DEBUG&&console.log("bounds",a.bounds),VIZI.DEBUG&&console.log("boundsLatLon",a.boundsLatLon),a.tileCount=new VIZI.Point(a.bounds.e-a.bounds.w+1,a.bounds.s-a.bounds.n+1),VIZI.DEBUG&&console.log("tileCount",a.tileCount),document.body.addEventListener("mouseup",function(b){a.onMouseUp(b)},!1),VIZI.Messenger.on("world:updateView",function(b,c){a.onWorldUpdate(b,c)}),a.collectTiles(),a.tiles},VIZI.BlueprintHelperTileGrid.prototype.collectTiles=function(){for(var a=this,b=[],c=0;cb.distance?1:0}),a.tiles=b},VIZI.BlueprintHelperTileGrid.prototype.getBounds=function(a){var b=this,c={n:Math.floor(b.centerTile.y)-a,e:Math.ceil(b.centerTile.x)+a,s:Math.ceil(b.centerTile.y)+a,w:Math.floor(b.centerTile.x)-a};return c},VIZI.BlueprintHelperTileGrid.prototype.getBoundsLatLon=function(a){var b=this,c=b.world.crs.tileBoundsLatLon(new VIZI.Point(a.e,a.n),b.tileZoom),d=b.world.crs.tileBoundsLatLon(new VIZI.Point(a.w,a.s),b.tileZoom),e={n:c.n,e:c.e,s:d.s,w:d.w};return e},VIZI.BlueprintHelperTileGrid.prototype.onWorldUpdate=function(a,b){var c=this,d=c.world.crs.latLonToTile(a,c.tileZoom),e=new VIZI.Point(Math.floor(d.x)-Math.floor(c.centerTile.x),Math.floor(d.y)-Math.floor(c.centerTile.y));(Math.abs(e.x)>0||Math.abs(e.y)>0)&&(c.centerTile=d,c.centerTileLatLon=new VIZI.LatLon(c.world.center),c.bounds=c.getBounds(c.tilesPerDirection),c.boundsLatLon=c.getBoundsLatLon(c.bounds),c.gridDiffSinceMouseUp.x+=e.x,c.gridDiffSinceMouseUp.y+=e.y,c.collectTiles()),b0||Math.abs(a.gridDiffSinceMouseUp.y)>0)&&(a.emit("moved",a.tiles,a.gridDiffSinceMouseUp),a.gridDiffSinceMouseUp=new VIZI.Point)},VIZI.BlueprintHelperTileGrid.prototype.globalToLocalTiles=function(a,b){var c=this;return new VIZI.Point(a-c.bounds.w,b-c.bounds.n)}}(),function(){"use strict";VIZI.BlueprintInput=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintInput");var b=this;VIZI.EventEmitter.call(b),b.options=a||{},b.triggers=[],b.actions=[]},VIZI.BlueprintInput.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.BlueprintInput.prototype.init=function(){}}(),function(){"use strict";VIZI.BlueprintInputGPX=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["gpx"]}],b.actions=[{name:"requestData",arguments:[]}]},VIZI.BlueprintInputGPX.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputGPX.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputGPX.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.xml(a.options.path,function(b,c){if(b)return VIZI.DEBUG&&console.log("Failed to request GPX data"),void console.warn(b);var d=JXON.build(c.querySelector("gpx"));a.emit("dataReceived",d)})}}(),function(){"use strict";var a=/\{([zxy])\}/g;VIZI.BlueprintInputGeoJSON=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["geoJSON"]},{name:"tileReceived",arguments:["geoJSON","tile"]}],b.actions=[{name:"requestData",arguments:[]},{name:"requestTiles",arguments:["tiles"]}]},VIZI.BlueprintInputGeoJSON.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputGeoJSON.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputGeoJSON.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.json(a.options.path,function(b,c){return b?(VIZI.DEBUG&&console.log("Failed to request GeoJSON data"),void console.warn(b)):void a.emit("dataReceived",c)})},VIZI.BlueprintInputGeoJSON.prototype.requestTiles=function(b){var c=this;if(!c.options.tilePath)throw new Error("Required tile path option missing");VIZI.DEBUG&&console.log("Requesting tiles",b),_.each(b,function(b){a.lastIndex=0;var d=c.options.tilePath.replace(a,function(a,c){return b[c]});d3.json(d,function(a,d){return a?(VIZI.DEBUG&&console.log("Failed to request GeoJSON data"),void console.warn(a)):void c.emit("tileReceived",d,b)})})}}(),function(){"use strict";VIZI.BlueprintInputKML=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["kml"]}],b.actions=[{name:"requestData",arguments:[]}]},VIZI.BlueprintInputKML.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputKML.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputKML.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.xml(a.options.path,function(b,c){if(b)return VIZI.DEBUG&&console.log("Failed to request KML data"),void console.warn(b);var d=JXON.build(c.querySelector("kml"));a.processCoordinates(d),a.emit("dataReceived",d)})},VIZI.BlueprintInputKML.prototype.processCoordinates=function(a){var b=this;_.each(a,function(c,d){_.isObject(c)?b.processCoordinates(c):"coordinates"===d&&(a[d]=c.split(","))})}}(),function(){"use strict";var a=/\{([zxy])\}/g;VIZI.BlueprintInputMapTiles=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{tilePath:"https://a.tiles.mapbox.com/v3/examples.map-i86l3621/{z}/{x}/{y}@2x.png"}),b.triggers=[{name:"initialised",arguments:[]},{name:"tileReceived",arguments:["image","tile"]}],b.actions=[{name:"requestTiles",arguments:["tiles"]}]},VIZI.BlueprintInputMapTiles.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputMapTiles.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputMapTiles.prototype.requestTiles=function(b){var c=this;VIZI.DEBUG&&console.log("Requesting tiles",b),_.each(b,function(b){a.lastIndex=0;var d=c.options.tilePath.replace(a,function(a,c){return b[c]}),e=new Image;e.onload=function(){c.emit("tileReceived",e,b),e=void 0},e.crossOrigin="Anonymous",e.src=d})}}(),function(){"use strict";VIZI.BlueprintOutput=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintOutput");var b=this;VIZI.Layer.call(b),b.options=a||{},b.triggers=[],b.actions=[],b.name=""},VIZI.BlueprintOutput.prototype=Object.create(VIZI.Layer.prototype),VIZI.BlueprintOutput.prototype.init=function(){},VIZI.BlueprintOutput.prototype.onTick=function(){}}(),function(){"use strict";VIZI.BlueprintOutputBuildingTiles=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{materialType:"MeshLambertMaterial",materialOptions:{},workerURL:"vizi-worker.min.js",name:"Building tiles"}),_.defaults(b.options.materialOptions,{color:15658734,ambient:16777215,emissive:13421772,shading:THREE.FlatShading}),b.triggers=[{name:"initialised",arguments:["tiles"]},{name:"gridUpdated",arguments:["tiles","newTiles"]}],b.actions=[{name:"outputBuildingTile",arguments:["buildings","tile"]}],b.name=b.options.name,b.grids={},b.world,b.worker},VIZI.BlueprintOutputBuildingTiles.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputBuildingTiles.prototype.init=function(){var a=this;a.worker=operative(a.outputBuildingTileWorker,[a.options.workerURL]),_.each(a.options.grids,function(b){a.grids[b.zoom]=a.createGrid(b)});var b=[];_.each(a.grids,function(a){b=b.concat(a.grid.tiles)}),a.emit("initialised",b)},VIZI.BlueprintOutputBuildingTiles.prototype.createGrid=function(a){var b=this,c={},d=new VIZI.BlueprintHelperTileGrid(b.world,a);d.on("moved",function(a,e){VIZI.DEBUG&&console.log("Grid moved",a,e);var f=c.meshes,g=[];c.meshes={},a.forEach(function(a){var b=a.x+"/"+a.y;f.hasOwnProperty(b)?(c.meshes[b]=f[b],delete f[b]):g.push(a)}),_.forEach(f,function(a){b.remove(a)}),d.disable||b.emit("gridUpdated",a,g)}),d.on("disabled",function(){VIZI.DEBUG&&console.log("Grid disabled"),_.each(c.meshes,function(a){a.visible=!1})}),d.on("enabled",function(){VIZI.DEBUG&&console.log("Grid enabled"),b.emit("gridUpdated",d.tiles),_.each(c.meshes,function(a){a.visible=!0})});var e=d.init();return VIZI.DEBUG&&console.log("Grid initialised",e),c.grid=d,c.meshes={},c},VIZI.BlueprintOutputBuildingTiles.prototype.outputBuildingTile=function(a,b){if(a.length){var c=this,d=c.grids[b.z],e=b.x+"/"+b.y;if(!d.meshes[e]){var f=c.options.materialType;f&&"function"==typeof THREE[f]||(f="MeshLambertMaterial");var g=new THREE[f](c.options.materialOptions);c.worker(c.world.origin,c.world.originZoom,c.options,a).then(function(a){var b=a.offset,f=new THREE.BufferGeometry;f.addAttribute("position",new THREE.BufferAttribute(a.position,3)),f.addAttribute("normal",new THREE.BufferAttribute(a.normal,3)),f.addAttribute("uv",new THREE.BufferAttribute(a.uv,2));var h=new THREE.Mesh(f,g);h.position.x=-1*b.x,h.position.y=-1*b.y,h.position.z=-1*b.z,d.meshes[e]=h,c.add(h)},function(){})}}},VIZI.BlueprintOutputBuildingTiles.prototype.outputBuildingTileWorker=function(a,b,c,d){var e,f=this,g=f.deferred(),h=VIZI.CRS.EPSG3857,i=function(c,d){d=d||b;var e=h.latLonToPoint(a,d,{round:!0}),f=h.latLonToPoint(c,d,{round:!0});return f.subtract(e)},j=function(a,c){return c=c||b,h.pixelsPerMeter(a,c)},k=new THREE.Geometry;_.each(d,function(a){var b=new VIZI.Point,d=new THREE.Shape,f=a.outline.shift(),g=a.outline;_.each(f,function(a,c){var f=new VIZI.LatLon(a[1],a[0]),g=i(f);void 0===e&&(e=j(f)),0===b.length&&(b.x=-1*g.x,b.y=-1*g.y),0===c?d.moveTo(g.x+b.x,g.y+b.y):d.lineTo(g.x+b.x,g.y+b.y)}),_.each(g,function(a){var c=new THREE.Path;_.each(a,function(a,d){var e=new VIZI.LatLon(a[1],a[0]),f=i(e);0===d?c.moveTo(f.x+b.x,f.y+b.y):c.lineTo(f.x+b.x,f.y+b.y)}),d.holes.push(c)});var h=a.height?a.height:5+10*Math.random(),l=a.minHeight?a.minHeight:0;h*=e.y,l*=e.y;var m={amount:h-l,bevelEnabled:!1},n=new THREE.ExtrudeGeometry(d,m);if(n.computeFaceNormals(),!l&&!c.preserveGroundFaces)for(var o=n.faces.length-1;o>=0;o--)Math.abs(n.faces[o].normal.z-1)0&&(j.renderDepth=-1*b.options.layer,j.material.depthWrite=!1,j.material.transparent=!0),j.position.x=-1*i.x,j.position.y=-1*i.y,j.position.z=-1*i.z,b.add(j)},VIZI.BlueprintOutputChoropleth.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputCollada=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{name:"Collada"}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputCollada",arguments:["collada"]}],b.name=b.options.name,b.world},VIZI.BlueprintOutputCollada.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputCollada.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputCollada.prototype.outputCollada=function(a){var b=this,c=new THREE.ColladaLoader;c.options.convertUpAxis=!0;var d;_.each(a,function(a){var e=b.options.modelPathPrefix?b.options.modelPathPrefix+a.modelPath:a.modelPath;c.load(e,function(c){var e=c.scene,f=new VIZI.LatLon(a.coordinates[1],a.coordinates[0]),g=b.world.project(f);void 0===d&&(d=b.world.pixelsPerMeter(f)),e.position.x=g.x,e.position.z=g.y,e.scale.x=e.scale.y=e.scale.z=e.scale.x*d.y,e.updateMatrix(),b.add(e)})})},VIZI.BlueprintOutputCollada.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputDebugLines=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{name:"Debug lines"}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputLines",arguments:["data"]}],b.name=b.options.name,b.world},VIZI.BlueprintOutputDebugLines.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputDebugLines.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputDebugLines.prototype.outputLines=function(a){var b,c=this,d=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),e=new THREE.Geometry;_.each(a,function(a){var d=new VIZI.LatLon(a.coordinates[1],a.coordinates[0]),f=c.world.project(d);void 0===b&&(b=c.world.pixelsPerMeter(d));var g=a.height||10;g*=b.y,e.vertices.push(new THREE.Vector3(f.x,g,f.y))});var f=new THREE.Line(e,d);c.add(f)},VIZI.BlueprintOutputDebugLines.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputDebugPoints=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{name:"Debug points"}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputPoints",arguments:["data"]}],b.name=b.options.name,b.world},VIZI.BlueprintOutputDebugPoints.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputDebugPoints.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputDebugPoints.prototype.outputPoints=function(a){for(var b=this,c=new THREE.MeshBasicMaterial({color:16711680,shading:THREE.FlatShading}),d=new THREE.BoxGeometry(40,1,40),e=d.vertices,f=0;f0&&(c=" | "),b.container.innerHTML+=c+a}}(),function(){"use strict";VIZI.Clock=function(){VIZI.DEBUG&&console.log("Initialising VIZI.Clock");var a=this;THREE.Clock.call(a)},VIZI.Clock.prototype=Object.create(THREE.Clock.prototype)}(),function(){"use strict";VIZI.EventEmitter=function(){WildEmitter.call(this)},VIZI.EventEmitter.prototype=Object.create(WildEmitter.prototype)}(),function(){"use strict";VIZI.Messenger=function(){var a=new VIZI.EventEmitter;return a}()}(),function(){"use strict";VIZI.World=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.World");var b=this;if(b.options=a||{},_.defaults(b.options,{crs:VIZI.CRS.EPSG3857,center:new VIZI.LatLon(51.50358,-.01924),zoom:16,suppressRenderer:!1,layersUI:!0}),!b.options.viewport)throw new Error("Required viewport option missing");b.crs=b.options.crs,b.attribution=new VIZI.Attribution({element:b.options.viewport}),b.switchboards=[],b.layers=[];var c=document.createElement("div");c.classList.add("vizicities-ui"),b.options.viewport.appendChild(c),b.options.layersUI&&(b.layersUI=new VIZI.LayersUI(b.layers)),b.scene=new VIZI.Scene({viewport:b.options.viewport,suppressRenderer:b.options.suppressRenderer}),b.camera=b.options.camera||new VIZI.Camera({aspect:b.options.viewport.clientWidth/b.options.viewport.clientHeight}),b.camera.addToScene(b.scene),b.origin=new VIZI.LatLon(b.options.center),b.originZoom=b.options.zoom,b.zoom=void 0,b.center=void 0,b.updateView(b.options.center,b.options.zoom),window.addEventListener("resize",function(){b.resizeView(b.options.viewport.clientWidth,b.options.viewport.clientHeight)}),VIZI.Messenger.on("controls:move",function(a){b.moveToPoint(a)}),VIZI.Messenger.on("controls:zoom",function(a){var c=Math.ceil(b.crs.altitudeToZoom(a));b.zoomTo(c)})},VIZI.World.prototype.project=function(a,b){var c=this;b=b||c.originZoom;var d=c.crs.latLonToPoint(c.origin,b,{round:!0}),e=c.crs.latLonToPoint(a,b,{round:!0});return e.subtract(d)},VIZI.World.prototype.unproject=function(a,b){var c=this;b=b||c.originZoom;var d=c.crs.latLonToPoint(c.origin,b,{round:!0});return c.crs.pointToLatLon(a.add(d),b)},VIZI.World.prototype.pixelsPerMeter=function(a,b){var c=this;return b=b||c.originZoom,c.crs.pixelsPerMeter(a,b)},VIZI.World.prototype.addLayer=function(a){var b=this;b.layers.push(a),b.scene.add(a.object),b.layersUI&&b.layersUI.onChange()},VIZI.World.prototype.addSwitchboard=function(a){var b=this;b.switchboards.push(a)},VIZI.World.prototype.onTick=function(a){var b=this;_.each(b.switchboards,function(b){b.onTick(a)})},VIZI.World.prototype.render=function(){var a=this;a.scene.render(a.camera)},VIZI.World.prototype.updateView=function(a,b){var c=this;b&&(c.zoom=b),c.center=a,VIZI.Messenger.emit("world:updateView",c.center,c.zoom)},VIZI.World.prototype.resizeView=function(a,b){var c=this,d=a/b;c.camera.changeAspect(d),c.scene.resize(a,b)},VIZI.World.prototype.moveToLatLon=function(a){var b=this;b.updateView(a)},VIZI.World.prototype.moveToPoint=function(a){var b=this,c=b.unproject(a);b.updateView(c)},VIZI.World.prototype.moveBy=function(a){var b=this,c=b.crs.latLonToPoint(b.center,b.zoom),d=c.add(a);b.updateView(b.crs.pointToLatLon(d,b.zoom))},VIZI.World.prototype.zoomTo=function(a){var b=this;b.updateView(b.center,a)},VIZI.World.prototype.zoomIn=function(a){var b=this;b.updateView(b.center,b.zoom+a)},VIZI.World.prototype.zoomOut=function(a){var b=this;b.updateView(b.center,b.zoom-a)},VIZI.World.prototype.lookAtLatLon=function(a){var b=this,c=b.project(a);b.camera.lookAt(c)},VIZI.World.prototype.lookAtPoint=function(a){var b=this;b.camera.lookAt(a)}}(),function(){"use strict";var a=12756274,b=Math.PI*a,c=b/2;VIZI.CRS={code:void 0,tileSize:256,projection:void 0,inverseProjection:void 0,latLonToPoint:function(a,b,d){var e=this;d=d||{},_.defaults(d,{convert:!0,round:!1});var f,g=e.project(a),h=e.resolution(b);if(f=d.round===!0?new VIZI.Point(Math.round((g[0]+c)/h),Math.round((g[1]+c)/h)):new VIZI.Point((g[0]+c)/h,(g[1]+c)/h),d.convert!==!1){var i=e.tileSize<b?0:b>20?20:b}}}(),function(){"use strict";VIZI.Camera=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.Camera");var b=this;if(b.options=a||{},_.defaults(b.options,{fov:40,near:2,far:4e4,position:new VIZI.Point(260,600,550),target:new VIZI.Point}),!b.options.aspect)throw new Error("Required aspect option missing");b.camera=new THREE.PerspectiveCamera(b.options.fov,b.options.aspect,b.options.near,b.options.far),b.moveTo(b.options.position),b.lookAt(b.options.target)},VIZI.Camera.prototype.addToScene=function(a){var b=this;a.add(b.camera)},VIZI.Camera.prototype.moveTo=function(a){var b=this;b.camera.position.x=a.x,b.camera.position.y=a.y,b.camera.position.z=a.z},VIZI.Camera.prototype.moveBy=function(a){var b=this;b.camera.position.x+=a.x,b.camera.position.y+=a.y,b.camera.position.z+=a.z},VIZI.Camera.prototype.lookAt=function(a){var b=this;b.camera.lookAt(new THREE.Vector3(a.x,a.y,a.z))},VIZI.Camera.prototype.changeAspect=function(a){var b=this;b.camera.aspect=a,b.camera.updateProjectionMatrix()}}(),function(){"use strict";VIZI.Layer=function(){VIZI.DEBUG&&console.log("Initialising VIZI.Layer");var a=this;VIZI.EventEmitter.call(a),a.object=new THREE.Object3D},VIZI.Layer.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.Layer.prototype.addToWorld=function(a){var b=this;b.beforeAdd(a),a.addLayer(b),b.onAdd(a)},VIZI.Layer.prototype.beforeAdd=function(){},VIZI.Layer.prototype.onAdd=function(){},VIZI.Layer.prototype.add=function(a){var b=this;b.object.add(a)},VIZI.Layer.prototype.remove=function(a){var b=this;b.object.remove(a)},VIZI.Layer.prototype.applyVertexColors=function(a,b){a.faces.forEach(function(a){for(var c=a instanceof THREE.Face3?3:4,d=0;c>d;d++)a.vertexColors[d]=b})}}(),function(){"use strict";VIZI.Scene=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.Scene");var b=this;if(b.options=a||{},_.defaults(b.options,{antialias:!1,fogColour:16777215,suppressRenderer:!1}),!b.options.viewport)throw new Error("Required viewport option missing");b.scene=b.createScene(),b.renderer=b.createRenderer()},VIZI.Scene.prototype.createScene=function(){var a=this,b=new THREE.Scene;b.fog=new THREE.Fog(a.options.fogColour,1,15e3);var c=new THREE.DirectionalLight(10066329);c.intesity=.1,c.position.x=1,c.position.y=1,c.position.z=1,b.add(c);var d=new THREE.DirectionalLight(10066329);return d.intesity=.1,d.position.x=-1,d.position.y=1,d.position.z=-1,b.add(d),b},VIZI.Scene.prototype.createRenderer=function(){var a,b=this;return a=b.options.suppressRenderer?{setSize:function(){},setClearColor:function(){},render:function(){},domElement:document.createElement("canvas")}:new THREE.WebGLRenderer({antialias:b.options.antialias}),a.setSize(b.options.viewport.clientWidth,b.options.viewport.clientHeight),a.setClearColor(b.scene.fog.color,1),a.gammaInput=!0,a.gammaOutput=!0,b.options.viewport.appendChild(a.domElement),a},VIZI.Scene.prototype.add=function(a){var b=this;b.scene.add(a)},VIZI.Scene.prototype.remove=function(a){var b=this;b.scene.remove(a)},VIZI.Scene.prototype.render=function(a){var b=this;if(!b.scene)throw new Error("Scene is required for render");if(!a)throw new Error("Camera is required for render");b.renderer.render(b.scene,a.camera)},VIZI.Scene.prototype.resize=function(a,b){var c=this;c.renderer.setSize(a,b)}}(),function(){"use strict";VIZI.Controls=function(a,b){var c=this;if(VIZI.EventEmitter.call(c),c.options=b||{},_.defaults(c.options,{}),!a)throw new Error("Required camera missing")},VIZI.Controls.prototype=Object.create(VIZI.EventEmitter.prototype)}(),function(){"use strict";VIZI.LayersUI=function(a){var b=this,c=b;b.layers=a,b.layerControl=React.createClass({displayName:"layerControl",render:function(){var a=this,b=a.props.layers.map(function(b){var d;return d=b.hidden?React.createElement("input",{type:"checkbox",onClick:a.props.onShow.bind(c,b.object.id)}):React.createElement("input",{type:"checkbox",checked:!0,onClick:a.props.onHide.bind(c,b.object.id)}),React.createElement("li",{key:b.object.id},d," ",b.name)});return React.createElement("section",{className:"vizicities-layers-ui"},React.createElement("header",null,React.createElement("h2",null,"Layers")),React.createElement("ul",null,b))}}),b.onChange()},VIZI.LayersUI.prototype.onHideLayer=function(a){var b=this,c=_.find(b.layers,function(b){return b.object.id===a});c&&(c.object.visible=!1,c.hidden=!0),b.onChange()},VIZI.LayersUI.prototype.onShowLayer=function(a){var b=this,c=_.find(b.layers,function(b){return b.object.id===a});c&&(c.object.visible=!0,c.hidden=!1),b.onChange()},VIZI.LayersUI.prototype.onChange=function(){var a=this,b=a.layerControl;React.render(React.createElement(b,{layers:a.layers,onHide:a.onHideLayer,onShow:a.onShowLayer}),document.querySelector(".vizicities-ui"))}}(),function(){"use strict";VIZI.BlueprintHelperTileGrid=function(a,b){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintHelperTileGrid");var c=this;if(VIZI.EventEmitter.call(c),!(a&&a instanceof VIZI.World))throw new Error("Required world property missing");if(c.world=a,c.options=b||{},_.defaults(c.options,{}),!c.options.zoom)throw new Error("Required options zoom property missing");if(!c.options.cullZoom)throw new Error("Required options cull zoom property missing");if(void 0===c.options.tilesPerDirection)throw new Error("Required options tiles per direction property missing");c.disable=!1,c.centerTile=new VIZI.Point,c.centerTileLatLon=new VIZI.LatLon,c.tileZoom=c.options.zoom,c.cullZoom=c.options.cullZoom,c.tilesPerDirection=c.options.tilesPerDirection,c.bounds,c.boundsLatLon,c.tileCount,c.tiles=[],c.gridDiffSinceMouseUp=new VIZI.Point},VIZI.BlueprintHelperTileGrid.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.BlueprintHelperTileGrid.prototype.init=function(){var a=this,b=a.world.center;VIZI.DEBUG&&console.log("coords",b),a.centerTile=a.world.crs.latLonToTile(b,a.tileZoom),VIZI.DEBUG&&console.log("centerTile",a.centerTile),a.centerTileLatLon=new VIZI.LatLon(a.world.center),VIZI.DEBUG&&console.log("centerTileLatLon",a.centerTileLatLon);var c=a.world.crs.tileBoundsPoint(a.centerTile,a.tileZoom);return VIZI.DEBUG&&console.log("centerTileBoundsPoint",c),a.bounds=a.getBounds(a.tilesPerDirection),a.boundsLatLon=a.getBoundsLatLon(a.bounds),VIZI.DEBUG&&console.log("bounds",a.bounds),VIZI.DEBUG&&console.log("boundsLatLon",a.boundsLatLon),a.tileCount=new VIZI.Point(a.bounds.e-a.bounds.w+1,a.bounds.s-a.bounds.n+1),VIZI.DEBUG&&console.log("tileCount",a.tileCount),document.body.addEventListener("mouseup",function(b){a.onMouseUp(b)},!1),VIZI.Messenger.on("world:updateView",function(b,c){a.onWorldUpdate(b,c)}),a.collectTiles(),a.tiles},VIZI.BlueprintHelperTileGrid.prototype.collectTiles=function(){for(var a=this,b=[],c=0;cb.distance?1:0}),a.tiles=b},VIZI.BlueprintHelperTileGrid.prototype.getBounds=function(a){var b=this,c={n:Math.floor(b.centerTile.y)-a,e:Math.ceil(b.centerTile.x)+a,s:Math.ceil(b.centerTile.y)+a,w:Math.floor(b.centerTile.x)-a};return c},VIZI.BlueprintHelperTileGrid.prototype.getBoundsLatLon=function(a){var b=this,c=b.world.crs.tileBoundsLatLon(new VIZI.Point(a.e,a.n),b.tileZoom),d=b.world.crs.tileBoundsLatLon(new VIZI.Point(a.w,a.s),b.tileZoom),e={n:c.n,e:c.e,s:d.s,w:d.w};return e},VIZI.BlueprintHelperTileGrid.prototype.onWorldUpdate=function(a,b){var c=this,d=c.world.crs.latLonToTile(a,c.tileZoom),e=new VIZI.Point(Math.floor(d.x)-Math.floor(c.centerTile.x),Math.floor(d.y)-Math.floor(c.centerTile.y));(Math.abs(e.x)>0||Math.abs(e.y)>0)&&(c.centerTile=d,c.centerTileLatLon=new VIZI.LatLon(c.world.center),c.bounds=c.getBounds(c.tilesPerDirection),c.boundsLatLon=c.getBoundsLatLon(c.bounds),c.gridDiffSinceMouseUp.x+=e.x,c.gridDiffSinceMouseUp.y+=e.y,c.collectTiles()),b0||Math.abs(a.gridDiffSinceMouseUp.y)>0)&&(a.emit("moved",a.tiles,a.gridDiffSinceMouseUp),a.gridDiffSinceMouseUp=new VIZI.Point)},VIZI.BlueprintHelperTileGrid.prototype.globalToLocalTiles=function(a,b){var c=this;return new VIZI.Point(a-c.bounds.w,b-c.bounds.n)}}(),function(){"use strict";VIZI.BlueprintInput=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintInput");var b=this;VIZI.EventEmitter.call(b),b.options=a||{},b.triggers=[],b.actions=[]},VIZI.BlueprintInput.prototype=Object.create(VIZI.EventEmitter.prototype),VIZI.BlueprintInput.prototype.init=function(){}}(),function(){"use strict";VIZI.BlueprintInputGPX=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["gpx"]}],b.actions=[{name:"requestData",arguments:[]}]},VIZI.BlueprintInputGPX.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputGPX.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputGPX.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.xml(a.options.path,function(b,c){if(b)return VIZI.DEBUG&&console.log("Failed to request GPX data"),void console.warn(b);var d=JXON.build(c.querySelector("gpx"));a.emit("dataReceived",d)})}}(),function(){"use strict";var a=/\{([zxy])\}/g;VIZI.BlueprintInputGeoJSON=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["geoJSON"]},{name:"tileReceived",arguments:["geoJSON","tile"]}],b.actions=[{name:"requestData",arguments:[]},{name:"requestTiles",arguments:["tiles"]}]},VIZI.BlueprintInputGeoJSON.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputGeoJSON.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputGeoJSON.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.json(a.options.path,function(b,c){return b?(VIZI.DEBUG&&console.log("Failed to request GeoJSON data"),void console.warn(b)):void a.emit("dataReceived",c)})},VIZI.BlueprintInputGeoJSON.prototype.requestTiles=function(b){var c=this;if(!c.options.tilePath)throw new Error("Required tile path option missing");VIZI.DEBUG&&console.log("Requesting tiles",b),_.each(b,function(b){a.lastIndex=0;var d=c.options.tilePath.replace(a,function(a,c){return b[c]});d3.json(d,function(a,d){return a?(VIZI.DEBUG&&console.log("Failed to request GeoJSON data"),void console.warn(a)):void c.emit("tileReceived",d,b)})})}}(),function(){"use strict";VIZI.BlueprintInputKML=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{}),b.triggers=[{name:"initialised",arguments:[]},{name:"dataReceived",arguments:["kml"]}],b.actions=[{name:"requestData",arguments:[]}]},VIZI.BlueprintInputKML.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputKML.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputKML.prototype.requestData=function(){var a=this;if(!a.options.path)throw new Error("Required path option missing");d3.xml(a.options.path,function(b,c){if(b)return VIZI.DEBUG&&console.log("Failed to request KML data"),void console.warn(b);var d=JXON.build(c.querySelector("kml"));a.processCoordinates(d),a.emit("dataReceived",d)})},VIZI.BlueprintInputKML.prototype.processCoordinates=function(a){var b=this;_.each(a,function(c,d){_.isObject(c)?b.processCoordinates(c):"coordinates"===d&&(a[d]=c.split(","))})}}(),function(){"use strict";var a=/\{([zxy])\}/g;VIZI.BlueprintInputMapTiles=function(a){var b=this;VIZI.BlueprintInput.call(b,a),_.defaults(b.options,{tilePath:"https://a.tiles.mapbox.com/v3/examples.map-i86l3621/{z}/{x}/{y}@2x.png"}),b.triggers=[{name:"initialised",arguments:[]},{name:"tileReceived",arguments:["image","tile"]}],b.actions=[{name:"requestTiles",arguments:["tiles"]}]},VIZI.BlueprintInputMapTiles.prototype=Object.create(VIZI.BlueprintInput.prototype),VIZI.BlueprintInputMapTiles.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintInputMapTiles.prototype.requestTiles=function(b){var c=this;VIZI.DEBUG&&console.log("Requesting tiles",b),_.each(b,function(b){a.lastIndex=0;var d=c.options.tilePath.replace(a,function(a,c){return b[c]}),e=new Image;e.onload=function(){c.emit("tileReceived",e,b),e=void 0},e.crossOrigin="Anonymous",e.src=d})}}(),function(){"use strict";VIZI.BlueprintOutput=function(a){VIZI.DEBUG&&console.log("Initialising VIZI.BlueprintOutput");var b=this;VIZI.Layer.call(b),b.options=a||{},b.triggers=[],b.actions=[],b.name=""},VIZI.BlueprintOutput.prototype=Object.create(VIZI.Layer.prototype),VIZI.BlueprintOutput.prototype.init=function(){},VIZI.BlueprintOutput.prototype.onTick=function(){}}(),function(){"use strict";VIZI.BlueprintOutputBuildingTiles=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{materialType:"MeshLambertMaterial",materialOptions:{},workerURL:"vizi-worker.min.js",name:"Building tiles"}),_.defaults(b.options.materialOptions,{color:15658734,ambient:16777215,emissive:13421772,shading:THREE.FlatShading}),b.triggers=[{name:"initialised",arguments:["tiles"]},{name:"gridUpdated",arguments:["tiles","newTiles"]}],b.actions=[{name:"outputBuildingTile",arguments:["buildings","tile"]}],b.name=b.options.name,b.grids={},b.world,b.worker},VIZI.BlueprintOutputBuildingTiles.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputBuildingTiles.prototype.init=function(){var a=this;a.worker=operative(a.outputBuildingTileWorker,[a.options.workerURL]),_.each(a.options.grids,function(b){a.grids[b.zoom]=a.createGrid(b)});var b=[];_.each(a.grids,function(a){b=b.concat(a.grid.tiles)}),a.emit("initialised",b)},VIZI.BlueprintOutputBuildingTiles.prototype.createGrid=function(a){var b=this,c={},d=new VIZI.BlueprintHelperTileGrid(b.world,a);d.on("moved",function(a,e){VIZI.DEBUG&&console.log("Grid moved",a,e);var f=c.meshes,g=[];c.meshes={},a.forEach(function(a){var b=a.x+"/"+a.y;f.hasOwnProperty(b)?(c.meshes[b]=f[b],delete f[b]):g.push(a)}),_.forEach(f,function(a){b.remove(a)}),d.disable||b.emit("gridUpdated",a,g)}),d.on("disabled",function(){VIZI.DEBUG&&console.log("Grid disabled"),_.each(c.meshes,function(a){a.visible=!1})}),d.on("enabled",function(){VIZI.DEBUG&&console.log("Grid enabled"),b.emit("gridUpdated",d.tiles),_.each(c.meshes,function(a){a.visible=!0})});var e=d.init();return VIZI.DEBUG&&console.log("Grid initialised",e),c.grid=d,c.meshes={},c},VIZI.BlueprintOutputBuildingTiles.prototype.outputBuildingTile=function(a,b){if(a.length){var c=this,d=c.grids[b.z],e=b.x+"/"+b.y;if(!d.meshes[e]){var f=c.options.materialType;f&&"function"==typeof THREE[f]||(f="MeshLambertMaterial");var g=new THREE[f](c.options.materialOptions);c.worker(c.world.origin,c.world.originZoom,c.options,a).then(function(a){var b=a.offset,f=new THREE.BufferGeometry;f.addAttribute("position",new THREE.BufferAttribute(a.position,3)),f.addAttribute("normal",new THREE.BufferAttribute(a.normal,3)),f.addAttribute("uv",new THREE.BufferAttribute(a.uv,2));var h=new THREE.Mesh(f,g);h.position.x=-1*b.x,h.position.y=-1*b.y,h.position.z=-1*b.z,d.meshes[e]=h,c.add(h)},function(){})}}},VIZI.BlueprintOutputBuildingTiles.prototype.outputBuildingTileWorker=function(a,b,c,d){var e,f=this,g=f.deferred(),h=VIZI.CRS.EPSG3857,i=function(c,d){d=d||b;var e=h.latLonToPoint(a,d,{round:!0}),f=h.latLonToPoint(c,d,{round:!0});return f.subtract(e)},j=function(a,c){return c=c||b,h.pixelsPerMeter(a,c)},k=new THREE.Geometry;_.each(d,function(a){var b=new VIZI.Point,d=new THREE.Shape,f=a.outline.shift(),g=a.outline;_.each(f,function(a,c){var f=new VIZI.LatLon(a[1],a[0]),g=i(f);void 0===e&&(e=j(f)),0===b.length&&(b.x=-1*g.x,b.y=-1*g.y),0===c?d.moveTo(g.x+b.x,g.y+b.y):d.lineTo(g.x+b.x,g.y+b.y)}),_.each(g,function(a){var c=new THREE.Path;_.each(a,function(a,d){var e=new VIZI.LatLon(a[1],a[0]),f=i(e);0===d?c.moveTo(f.x+b.x,f.y+b.y):c.lineTo(f.x+b.x,f.y+b.y)}),d.holes.push(c)});var h=a.height?a.height:5+10*Math.random(),l=a.minHeight?a.minHeight:0;h*=e.y,l*=e.y;var m={amount:h-l,bevelEnabled:!1},n=new THREE.ExtrudeGeometry(d,m);if(n.computeFaceNormals(),!l&&!c.preserveGroundFaces)for(var o=n.faces.length-1;o>=0;o--)Math.abs(n.faces[o].normal.z-1)0&&(j.renderDepth=-1*b.options.layer,j.material.depthWrite=!1,j.material.transparent=!0),j.position.x=-1*i.x,j.position.y=-1*i.y,j.position.z=-1*i.z,b.add(j)},VIZI.BlueprintOutputChoropleth.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputCollada=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{name:"Collada"}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputCollada",arguments:["collada"]}],b.name=b.options.name,b.world},VIZI.BlueprintOutputCollada.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputCollada.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputCollada.prototype.outputCollada=function(a){var b=this,c=new THREE.ColladaLoader;c.options.convertUpAxis=!0;var d;_.each(a,function(a){var e=b.options.modelPathPrefix?b.options.modelPathPrefix+a.modelPath:a.modelPath;c.load(e,function(c){var e=c.scene,f=new VIZI.LatLon(a.coordinates[1],a.coordinates[0]),g=b.world.project(f);void 0===d&&(d=b.world.pixelsPerMeter(f)),e.position.x=g.x,e.position.z=g.y,e.scale.x=e.scale.y=e.scale.z=e.scale.x*d.y,e.updateMatrix(),b.add(e)})})},VIZI.BlueprintOutputCollada.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputDebugLines=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{name:"Debug lines"}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputLines",arguments:["data"]}],b.name=b.options.name,b.world},VIZI.BlueprintOutputDebugLines.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputDebugLines.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputDebugLines.prototype.outputLines=function(a){var b,c=this,d=new THREE.LineBasicMaterial({color:16711680,linewidth:3}),e=new THREE.Geometry;_.each(a,function(a){var d=new VIZI.LatLon(a.coordinates[1],a.coordinates[0]),f=c.world.project(d);void 0===b&&(b=c.world.pixelsPerMeter(d));var g=a.height||10;g*=b.y,e.vertices.push(new THREE.Vector3(f.x,g,f.y))});var f=new THREE.Line(e,d);c.add(f)},VIZI.BlueprintOutputDebugLines.prototype.onAdd=function(a){var b=this;b.world=a,b.init()}}(),function(){"use strict";VIZI.BlueprintOutputDebugPoints=function(a){var b=this;VIZI.BlueprintOutput.call(b,a),_.defaults(b.options,{name:"Debug points"}),b.triggers=[{name:"initialised",arguments:[]}],b.actions=[{name:"outputPoints",arguments:["data"]}],b.name=b.options.name,b.world},VIZI.BlueprintOutputDebugPoints.prototype=Object.create(VIZI.BlueprintOutput.prototype),VIZI.BlueprintOutputDebugPoints.prototype.init=function(){var a=this;a.emit("initialised")},VIZI.BlueprintOutputDebugPoints.prototype.outputPoints=function(a){for(var b=this,c=new THREE.MeshBasicMaterial({color:16711680,shading:THREE.FlatShading}),d=new THREE.BoxGeometry(40,1,40),e=d.vertices,f=0;fa)){var c=a/b.controls.offset.length();c>0?b.controls.dollyOut(c):0>c&&b.controls.dollyIn(c),b.controls.update()}},VIZI.ControlsMap.prototype.getZoom=function(){var a=this;return a.controls.offset.length()},VIZI.ControlsMap.prototype.onTick=function(a){var b=this;b.controls.update(a)}}(),function(){"use strict";VIZI.ControlsOrbit=function(a,b){var c=this;VIZI.Controls.call(c,a,b),c.controls=new THREE.OrbitControls(a.camera,c.options.viewport.querySelector("canvas")),c.controls.addEventListener("start",function(){c.onStart()}),c.controls.addEventListener("change",function(){c.onChange()}),c.controls.addEventListener("end",function(){c.onEnd()})},VIZI.ControlsOrbit.prototype=Object.create(VIZI.Controls.prototype),VIZI.ControlsOrbit.prototype.onStart=function(){},VIZI.ControlsOrbit.prototype.onChange=function(){var a=this,b=new VIZI.Point(a.controls.target.x,a.controls.target.z);VIZI.Messenger.emit("controls:move",b);var c=a.getZoom();VIZI.Messenger.emit("controls:zoom",c)},VIZI.ControlsOrbit.prototype.onEnd=function(){},VIZI.ControlsOrbit.prototype.moveTo=function(a){var b=this;b.controls.target.x=a.x,b.controls.target.z=a.y,b.controls.update()},VIZI.ControlsOrbit.prototype.moveBy=function(a){var b=this;b.controls.target.x+=a.x,b.controls.target.z+=a.y,b.controls.update()},VIZI.ControlsOrbit.prototype.zoomTo=function(a){var b=this;if(!(10>a)){var c=a/b.controls.offset.length();c>0?b.controls.dollyOut(c):0>c&&b.controls.dollyIn(c),b.controls.update()}},VIZI.ControlsOrbit.prototype.getZoom=function(){var a=this;return a.controls.offset.length()},VIZI.ControlsOrbit.prototype.onTick=function(a){var b=this;b.controls.update(a)}}(),function(){"use strict";VIZI.CRS.EPSG3857=_.extend({},VIZI.CRS,{code:"EPSG:3857"}),VIZI.CRS.EPSG900913=_.extend({},VIZI.CRS.EPSG3857,{code:"EPSG:900913"})}(),function(){"use strict";VIZI.LatLon=function(a,b,c){var d=this;d.lat=a||0,d.lon=b||0,d.alt=c||0,a instanceof VIZI.LatLon?(d.lat=a.lat,d.lon=a.lon,d.alt=a.alt):_.isArray(a)&&(d.lat=a[0],d.lon=a[1],d.alt=a[2]||0)}}(),function(){"use strict";VIZI.Point=function(a,b,c){var d=this;d.x=a||0,d.y=b||0,d.z=c||0,a instanceof VIZI.Point?(d.x=a.x,d.y=a.y,d.z=a.z):_.isArray(a)&&(d.x=a[0],d.y=a[1],d.z=a[2]||0)},VIZI.Point.prototype.add=function(a){var b=this,c=new VIZI.Point(b.x+a.x,b.y+a.y,b.z+a.z);return c},VIZI.Point.prototype.subtract=function(a){var b=this,c=new VIZI.Point(b.x-a.x,b.y-a.y,b.z-a.z);return c}}(),THREE.ColladaLoader=function(){function a(a,c,d){var e=0;if(document.implementation&&document.implementation.createDocument){var f=new XMLHttpRequest;f.onreadystatechange=function(){if(4===f.readyState){if(0===f.status||200===f.status)if(f.responseXML)Qb=c,b(f.responseXML,void 0,a);else if(f.responseText){Qb=c;var g=new DOMParser,h=g.parseFromString(f.responseText,"application/xml");b(h,void 0,a)}else console.error("ColladaLoader: Empty or non-existing file ("+a+")")}else 3===f.readyState&&d&&(0===e&&(e=f.getResponseHeader("Content-Length")),d({total:e,loaded:f.responseText.length}))},f.open("GET",a,!0),f.send(null)}else alert("Don't know how to parse XML!")}function b(a,b,c){if(Ob=a,b=b||Qb,void 0!==c){var i=c.split("/");i.pop(),Lb=(i.length<1?".":i.join("/"))+"/"}d(),zb(),Sb=e("library_images image",F,"image"),Wb=e("library_materials material",Z,"material"),Xb=e("library_effects effect",cb,"effect"),Vb=e("library_geometries geometry",P,"geometry"),Yb=e("library_cameras camera",ib,"camera"),Zb=e("library_lights light",kb,"light"),Ub=e("library_controllers controller",G,"controller"),Tb=e("library_animations animation",eb,"animation"),Kb=e("library_visual_scenes visual_scene",J,"visual_scene"),kinematicsModels=e("library_kinematics_models kinematics_model",mb,"kinematics_model"),Mb=[],Nb=[],Gb=f(),Pb=new THREE.Scene;for(var j=0;jh;h++){var i=d[h],j=(new b).parse(i);j.id&&0!==j.id.length||(j.id=c+f++),e[j.id]=j}return e}function f(){var a=Ob.querySelectorAll("scene instance_visual_scene")[0];if(a){var b=a.getAttribute("url").replace(/^#/,"");return Kb[b.length>0?b:"visual_scene0"]}return null}function g(){var a=Ob.querySelectorAll("instance_kinematics_model")[0];if(a){var b=a.getAttribute("url").replace(/^#/,"");return kinematicsModels[b.length>0?b:"kinematics_model0"]}return null}function h(){Ib=[],i(Pb)}function i(a){var b=Gb.getChildById(a.colladaId,!0),c=null;if(b&&b.keys){c={fps:60,hierarchy:[{node:b,keys:b.keys,sids:b.sids}],node:a,name:"animation_"+a.name,length:0},Ib.push(c);for(var d=0,e=b.keys.length;e>d;d++)c.length=Math.max(c.length,b.keys[d].time)}else c={hierarchy:[{keys:[],sids:[]}]};for(var d=0,e=a.children.length;e>d;d++)for(var f=i(a.children[d]),g=0,h=f.hierarchy.length;h>g;g++)c.hierarchy.push({keys:[],sids:[]});return c}function k(){var a,b=1e6,c=-b,d=0;for(var e in Tb){var f=Tb[e];a=a||f.id;for(var g=0;g=0){var g=b.invBindMatrices[e];d.invBindMatrix=g,d.skinningMatrix=new THREE.Matrix4,d.skinningMatrix.multiplyMatrices(d.world,g),d.animatrix=new THREE.Matrix4,d.animatrix.copy(d.localworld),d.weights=[];for(var f=0;ff.limits.max||c1)for(C=new THREE.MeshFaceMaterial(s),e=0;e0?(C.morphTargets=!0,C.skinning=!1):(C.morphTargets=!1,C.skinning=!0),B=new THREE.SkinnedMesh(D,C,!1),B.name="skin_"+Nb.length,Nb.push(B)):void 0!==c?(l(D,c),C.morphTargets=!0,B=new THREE.Mesh(D,C),B.name="morph_"+Mb.length,Mb.push(B)):B=D.isLineStrip===!0?new THREE.Line(D):new THREE.Mesh(D,C),f.add(B)}}for(d=0;dd;d++){var f,g=a.channels[d],h=g.fullSid,i=g.sampler,j=i.input,k=a.getTransformBySid(g.sid);if(g.arrIndices){f=[];for(var l=0,m=g.arrIndices.length;m>l;l++)f[l]=Eb(g.arrIndices[l])}else f=Fb(g.member);if(k){-1===c.indexOf(h)&&c.push(h);for(var l=0,m=j.length;m>l;l++){var n=j[l],o=i.getData(k.type,l,f),p=A(b,n);if(!p){p=new hb(n);var q=B(b,n);b.splice(-1===q?b.length:q,0,p)}p.addTarget(h,k,f,o)}}else console.log('Could not find transform "'+g.sid+'" in node '+a.id)}for(var d=0;dd&&null===c;d++){var f=a[d];if(f.time===b)c=f;else if(f.time>b)break}return c}function B(a,b){for(var c=-1,d=0,e=a.length;e>d&&-1===c;d++){var f=a[d];f.time>=b&&(c=d)}return c}function C(a,b,c,d){var e=E(a,d,c?c-1:0),f=D(a,d,c+1);if(e&&f){var g,h=(b.time-e.time)/(f.time-e.time),i=e.getTarget(d),j=f.getTarget(d).data,k=i.data;if("matrix"===i.type)g=k;else if(k.length){g=[];for(var l=0;l=0?c:c+a.length;c>=0;c--){var d=a[c];if(d.hasTarget(b))return d}return null}function F(){this.id="",this.init_from=""}function G(){this.id="",this.name="",this.type="",this.skin=null,this.morph=null}function H(){this.method=null,this.source=null,this.targets=null,this.weights=null}function I(){this.source="",this.bindShapeMatrix=null,this.invBindMatrices=[],this.joints=[],this.weights=[]}function J(){this.id="",this.name="",this.nodes=[],this.scene=new THREE.Scene}function K(){this.id="",this.name="",this.sid="",this.nodes=[],this.controllers=[],this.transforms=[],this.geometries=[],this.channels=[],this.matrix=new THREE.Matrix4}function L(){this.sid="",this.type="",this.data=[],this.obj=null}function M(){this.url="",this.skeleton=[],this.instance_material=[]}function N(){this.symbol="",this.target=""}function O(){this.url="",this.instance_material=[]}function P(){this.id="",this.mesh=null}function Q(a){this.geometry=a.id,this.primitives=[],this.vertices=null,this.geometry3js=null}function R(){this.material="",this.count=0,this.inputs=[],this.vcount=null,this.p=[],this.geometry=new THREE.Geometry}function S(){R.call(this),this.vcount=[]}function T(){R.call(this),this.vcount=1}function U(){R.call(this),this.vcount=3}function V(){this.source="",this.count=0,this.stride=0,this.params=[]}function W(){this.input={}}function X(){this.semantic="",this.offset=0,this.source="",this.set=0}function Y(a){this.id=a,this.type=null}function Z(){this.id="",this.name="",this.instance_effect=null}function $(){this.color=new THREE.Color,this.color.setRGB(Math.random(),Math.random(),Math.random()),this.color.a=1,this.texture=null,this.texcoord=null,this.texOpts=null}function _(a,b){this.type=a,this.effect=b,this.material=null}function ab(a){this.effect=a,this.init_from=null,this.format=null}function bb(a){this.effect=a,this.source=null,this.wrap_s=null,this.wrap_t=null,this.minfilter=null,this.magfilter=null,this.mipfilter=null}function cb(){this.id="",this.name="",this.shader=null,this.surface={},this.sampler={}}function db(){this.url=""}function eb(){this.id="",this.name="",this.source={},this.sampler=[],this.channel=[]}function fb(a){this.animation=a,this.source="",this.target="",this.fullSid=null,this.sid=null,this.dotSyntax=null,this.arrSyntax=null,this.arrIndices=null,this.member=null}function gb(a){this.id="",this.animation=a,this.inputs=[],this.input=null,this.output=null,this.strideOut=null,this.interpolation=null,this.startTime=null,this.endTime=null,this.duration=0}function hb(a){this.targets=[],this.time=a}function ib(){this.id="",this.name="",this.technique=""}function jb(){this.url=""}function kb(){this.id="",this.name="",this.technique=""}function lb(){this.url=""}function mb(){this.id="",this.name="",this.joints=[],this.links=[]}function nb(){this.sid="",this.name="",this.axis=new THREE.Vector3,this.limits={min:0,max:0},this.type="",this.static=!1,this.zeroPosition=0,this.middlePosition=0}function ob(){this.sid="",this.name="",this.transforms=[],this.attachments=[]}function pb(){this.joint="",this.transforms=[],this.links=[]}function qb(a){var b=a.getAttribute("id");return void 0!=Rb[b]?Rb[b]:(Rb[b]=new Y(b).parse(a),Rb[b])}function rb(a){for(var b=ub(a),c=[],d=0,e=b.length;e>d;d++)c.push("true"===b[d]||"1"===b[d]?!0:!1);return c}function sb(a){for(var b=ub(a),c=[],d=0,e=b.length;e>d;d++)c.push(parseFloat(b[d]));return c}function tb(a){for(var b=ub(a),c=[],d=0,e=b.length;e>d;d++)c.push(parseInt(b[d],10));return c}function ub(a){return a.length>0?vb(a).split(/\s+/):[]}function vb(a){return a.replace(/^\s+/,"").replace(/\s+$/,"")}function wb(a,b,c){return a.hasAttribute(b)?parseInt(a.getAttribute(b),10):c}function xb(a,b){loader=new THREE.ImageLoader,loader.load(b,function(b){a.image=b,a.needsUpdate=!0})}function yb(a,b){a.doubleSided=!1;var c=b.querySelectorAll("extra double_sided")[0];c&&c&&1===parseInt(c.textContent,10)&&(a.doubleSided=!0)}function zb(){if(_b.convertUpAxis!==!0||bc===_b.upAxis)cc=null;else switch(bc){case"X":cc="Y"===_b.upAxis?"XtoY":"XtoZ";break;case"Y":cc="X"===_b.upAxis?"YtoX":"YtoZ";break;case"Z":cc="X"===_b.upAxis?"ZtoX":"ZtoY"}}function Ab(a,b){if(_b.convertUpAxis===!0&&bc!==_b.upAxis)switch(cc){case"XtoY":var c=a[0];a[0]=b*a[1],a[1]=c;break;case"XtoZ":var c=a[2];a[2]=a[1],a[1]=a[0],a[0]=c;break;case"YtoX":var c=a[0];a[0]=a[1],a[1]=b*c;break;case"YtoZ":var c=a[1];a[1]=b*a[2],a[2]=c;break;case"ZtoX":var c=a[0];a[0]=a[1],a[1]=a[2],a[2]=c;break;case"ZtoY":var c=a[1];a[1]=a[2],a[2]=b*c}}function Bb(a,b){if(_b.convertUpAxis!==!0||bc===_b.upAxis)return b;switch(a){case"X":b="XtoY"===cc?-1*b:b;break;case"Y":b="YtoZ"===cc||"YtoX"===cc?-1*b:b;break;case"Z":b="ZtoY"===cc?-1*b:b}return b}function Cb(a,b){var c=[a[b],a[b+1],a[b+2]];return Ab(c,-1),new THREE.Vector3(c[0],c[1],c[2])}function Db(a){if(_b.convertUpAxis){var b=[a[0],a[4],a[8]];Ab(b,-1),a[0]=b[0],a[4]=b[1],a[8]=b[2],b=[a[1],a[5],a[9]],Ab(b,-1),a[1]=b[0],a[5]=b[1],a[9]=b[2],b=[a[2],a[6],a[10]],Ab(b,-1),a[2]=b[0],a[6]=b[1],a[10]=b[2],b=[a[0],a[1],a[2]],Ab(b,-1),a[0]=b[0],a[1]=b[1],a[2]=b[2],b=[a[4],a[5],a[6]],Ab(b,-1),a[4]=b[0],a[5]=b[1],a[6]=b[2],b=[a[8],a[9],a[10]],Ab(b,-1),a[8]=b[0],a[9]=b[1],a[10]=b[2],b=[a[3],a[7],a[11]],Ab(b,-1),a[3]=b[0],a[7]=b[1],a[11]=b[2]}return(new THREE.Matrix4).set(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15])}function Eb(a){if(a>-1&&3>a){var b=["X","Y","Z"],c={X:0,Y:1,Z:2};a=Fb(b[a]),a=c[a]}return a}function Fb(a){if(_b.convertUpAxis)switch(a){case"X":switch(cc){case"XtoY":case"XtoZ":case"YtoX":a="Y";break;case"ZtoX":a="Z"}break;case"Y":switch(cc){case"XtoY":case"YtoX":case"ZtoX":a="X";break;case"XtoZ":case"YtoZ":case"ZtoY":a="Z"}break;case"Z":switch(cc){case"XtoZ":a="X";break;case"YtoZ":case"ZtoX":case"ZtoY":a="Y"}}return a}var Gb,Hb,Ib,Jb,Kb,Hb,Lb,Mb,Nb,Ob=null,Pb=null,Qb=null,Rb={},Sb={},Tb={},Ub={},Vb={},Wb={},Xb={},Yb={},Zb={},$b=THREE.SmoothShading,_b={centerGeometry:!1,convertUpAxis:!1,subdivideFaces:!0,upAxis:"Y",defaultEnvMap:null},ac=1,bc="Y",cc=null;return F.prototype.parse=function(a){this.id=a.getAttribute("id");for(var b=0;bk;k++){for(var l={},m=0;m=0,i=g.indexOf("(")>=0;if(h)f=g.split("."),g=f.shift(),d=f.shift();else if(i){c=g.split("("),g=c.shift();for(var j=0;jn?p:n,e.semantic){case"TEXCOORD":o.push(e.set)}}for(var q=0;qc;c++)for(d=0;dx;x++)u.push(Cb(h.data,t[x]*i))}else b.calcNormals=!0;if(!v&&(v={},e=this.vertices.input.TEXCOORD)){o.push(e.set),h=Rb[e.source],i=h.accessor.params.length;for(var x=0,y=t.length;y>x;x++)g=t[x]*i,void 0===v[e.set]&&(v[e.set]=[]),v[e.set].push(new THREE.Vector2(h.data[g],1-h.data[g+1]))}if(0===w.length&&(e=this.vertices.input.COLOR)){h=Rb[e.source],i=h.accessor.params.length;for(var x=0,y=t.length;y>x;x++)g=t[x]*i,w.push((new THREE.Color).setRGB(h.data[g],h.data[g+1],h.data[g+2]))}var z,A,B=null,C=[];if(3===m)C.push(new THREE.Face3(t[0],t[1],t[2],u,w.length?w:new THREE.Color));else if(4===m)C.push(new THREE.Face3(t[0],t[1],t[3],[u[0],u[1],u[3]],w.length?[w[0],w[1],w[3]]:new THREE.Color)),C.push(new THREE.Face3(t[1],t[2],t[3],[u[1],u[2],u[3]],w.length?[w[1],w[2],w[3]]:new THREE.Color));else if(m>4&&_b.subdivideFaces){var D=w.length?w:new THREE.Color;for(d=1;m-1>d;)C.push(new THREE.Face3(t[0],t[d],t[d+1],[u[0],u[d++],u[d]],D))}if(C.length)for(var x=0,y=C.length;y>x;x++)for(B=C[x],B.daeMaterial=a.material,b.faces.push(B),d=0;d4?[z[0],z[x+1],z[x+2]]:4===m?0===x?[z[0],z[1],z[3]]:[z[1].clone(),z[2],z[3].clone()]:[z[0],z[1],z[2]],void 0===b.faceVertexUvs[d]&&(b.faceVertexUvs[d]=[]),b.faceVertexUvs[d].push(A);else console.log("dropped face with vcount "+m+" for geometry with id: "+b.id);s+=n*m}},R.prototype.setVertices=function(a){for(var b=0;b0&&(this[c.nodeName]=parseFloat(e[0].textContent))}}return this.create(),this},_.prototype.create=function(){var a={},b=!1;if(void 0!==this.transparency&&void 0!==this.transparent){var c=(this.transparent,(this.transparent.color.r+this.transparent.color.g+this.transparent.color.b)/3*this.transparency);c>0&&(b=!0,a.transparent=!0,a.opacity=1-c)}var d={diffuse:"map",ambient:"lightMap",specular:"specularMap",emission:"emissionMap",bump:"bumpMap",normal:"normalMap"};for(var e in this)switch(e){case"ambient":case"emission":case"diffuse":case"specular":case"bump":case"normal":var f=this[e];if(f instanceof $)if(f.isTexture()){var g=f.texture,h=this.effect.sampler[g];if(void 0!==h&&void 0!==h.source){var i=this.effect.surface[h.source];if(void 0!==i){var j=Sb[i.init_from];if(j){var k,l=Lb+j.init_from,m=THREE.Loader.Handlers.get(l);null!==m?k=m.load(l):(k=new THREE.Texture,xb(k,l)),k.wrapS=f.texOpts.wrapU?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,k.wrapT=f.texOpts.wrapV?THREE.RepeatWrapping:THREE.ClampToEdgeWrapping,k.offset.x=f.texOpts.offsetU,k.offset.y=f.texOpts.offsetV,k.repeat.x=f.texOpts.repeatU,k.repeat.y=f.texOpts.repeatV,a[d[e]]=k,"emission"===e&&(a.emissive=16777215)}}}}else"diffuse"!==e&&b||("emission"===e?a.emissive=f.color.getHex():a[e]=f.color.getHex());break;case"shininess":a[e]=this[e];break;case"reflectivity":a[e]=this[e],a[e]>0&&(a.envMap=_b.defaultEnvMap),a.combine=THREE.MixOperation;break;case"index_of_refraction":a.refractionRatio=this[e],1!==this[e]&&(a.envMap=_b.defaultEnvMap);break;case"transparency":}switch(a.shading=$b,a.side=this.effect.doubleSided?THREE.DoubleSide:THREE.FrontSide,this.type){case"constant":void 0!=a.emissive&&(a.color=a.emissive),this.material=new THREE.MeshBasicMaterial(a);break;case"phong":case"blinn":void 0!=a.diffuse&&(a.color=a.diffuse),this.material=new THREE.MeshPhongMaterial(a);break;case"lambert":default:void 0!=a.diffuse&&(a.color=a.diffuse),this.material=new THREE.MeshLambertMaterial(a)}return this.material},ab.prototype.parse=function(a){for(var b=0;b=0,e=c.indexOf("(")>=0;if(d)b=c.split("."),this.sid=b.shift(),this.member=b.shift();else if(e){var f=c.split("(");this.sid=f.shift();for(var g=0;g1){d=[],b*=this.strideOut;for(var e=0;ec;c++){var e,f=this.targets[c],g=a.getTarget(f.sid);if("matrix"!==f.transform.type&&g){var h=(b-this.time)/(a.time-this.time),i=g.data,j=f.data;if(0>h&&(h=0),h>1&&(h=1),j.length){e=[];for(var k=0;k=this.limits.max&&(this.static=!0),this.middlePosition=(this.limits.min+this.limits.max)/2,this},ob.prototype.parse=function(a){this.sid=a.getAttribute("sid"),this.name=a.getAttribute("name"),this.transforms=[],this.attachments=[];for(var b=0;bd;d++)f.faceVertexUvs[d]=[]}for(h=0,i=G.length;i>h;)v=new THREE.Vector3,v.x=G[h++]*b,v.y=G[h++]*b,v.z=G[h++]*b,f.vertices.push(v);for(h=0,i=F.length;i>h;)if(n=F[h++],o=c(n,0),p=c(n,1),q=c(n,3),r=c(n,4),s=c(n,5),t=c(n,6),u=c(n,7),o){if(x=new THREE.Face3,x.a=F[h],x.b=F[h+1],x.c=F[h+3],y=new THREE.Face3,y.a=F[h+1],y.b=F[h+2],y.c=F[h+3],h+=4,p&&(m=F[h++],x.materialIndex=m,y.materialIndex=m),g=f.faces.length,q)for(d=0;J>d;d++)for(B=a.uvs[d],f.faceVertexUvs[d][g]=[],f.faceVertexUvs[d][g+1]=[],e=0;4>e;e++)l=F[h++],D=B[2*l],E=B[2*l+1],C=new THREE.Vector2(D,E),2!==e&&f.faceVertexUvs[d][g].push(C),0!==e&&f.faceVertexUvs[d][g+1].push(C);if(r&&(k=3*F[h++],x.normal.set(H[k++],H[k++],H[k]),y.normal.copy(x.normal)),s)for(d=0;4>d;d++)k=3*F[h++],A=new THREE.Vector3(H[k++],H[k++],H[k]),2!==d&&x.vertexNormals.push(A),0!==d&&y.vertexNormals.push(A);if(t&&(j=F[h++],z=I[j],x.color.setHex(z),y.color.setHex(z)),u)for(d=0;4>d;d++)j=F[h++],z=I[j],2!==d&&x.vertexColors.push(new THREE.Color(z)),0!==d&&y.vertexColors.push(new THREE.Color(z));f.faces.push(x),f.faces.push(y)}else{if(w=new THREE.Face3,w.a=F[h++],w.b=F[h++],w.c=F[h++],p&&(m=F[h++],w.materialIndex=m),g=f.faces.length,q)for(d=0;J>d;d++)for(B=a.uvs[d],f.faceVertexUvs[d][g]=[],e=0;3>e;e++)l=F[h++],D=B[2*l],E=B[2*l+1],C=new THREE.Vector2(D,E),f.faceVertexUvs[d][g].push(C);if(r&&(k=3*F[h++],w.normal.set(H[k++],H[k++],H[k])),s)for(d=0;3>d;d++)k=3*F[h++],A=new THREE.Vector3(H[k++],H[k++],H[k]),w.vertexNormals.push(A);if(t&&(j=F[h++],w.color.setHex(I[j])),u)for(d=0;3>d;d++)j=F[h++],w.vertexColors.push(new THREE.Color(I[j]));f.faces.push(w)}}function d(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var c=0,d=a.skinWeights.length;d>c;c+=b){var e=a.skinWeights[c],g=b>1?a.skinWeights[c+1]:0,h=b>2?a.skinWeights[c+2]:0,i=b>3?a.skinWeights[c+3]:0;f.skinWeights.push(new THREE.Vector4(e,g,h,i)) }if(a.skinIndices)for(var c=0,d=a.skinIndices.length;d>c;c+=b){var j=a.skinIndices[c],k=b>1?a.skinIndices[c+1]:0,l=b>2?a.skinIndices[c+2]:0,m=b>3?a.skinIndices[c+3]:0;f.skinIndices.push(new THREE.Vector4(j,k,l,m))}f.bones=a.bones,f.bones&&f.bones.length>0&&(f.skinWeights.length!==f.skinIndices.length||f.skinIndices.length!==f.vertices.length)&&console.warn("When skinning, number of vertices ("+f.vertices.length+"), skinIndices ("+f.skinIndices.length+"), and skinWeights ("+f.skinWeights.length+") should match."),f.animation=a.animation,f.animations=a.animations}function e(b){if(void 0!==a.morphTargets){var c,d,e,g,h,i;for(c=0,d=a.morphTargets.length;d>c;c++)for(f.morphTargets[c]={},f.morphTargets[c].name=a.morphTargets[c].name,f.morphTargets[c].vertices=[],h=f.morphTargets[c].vertices,i=a.morphTargets[c].vertices,e=0,g=i.length;g>e;e+=3){var j=new THREE.Vector3;j.x=i[e]*b,j.y=i[e+1]*b,j.z=i[e+2]*b,h.push(j)}}if(void 0!==a.morphColors){var c,d,k,l,m,n,o;for(c=0,d=a.morphColors.length;d>c;c++)for(f.morphColors[c]={},f.morphColors[c].name=a.morphColors[c].name,f.morphColors[c].colors=[],m=f.morphColors[c].colors,n=a.morphColors[c].colors,k=0,l=n.length;l>k;k+=3)o=new THREE.Color(16755200),o.setRGB(n[k],n[k+1],n[k+2]),m.push(o)}}var f=new THREE.Geometry,g=void 0!==a.scale?1/a.scale:1;if(c(g),d(),e(g),f.computeFaceNormals(),f.computeBoundingSphere(),void 0===a.materials||0===a.materials.length)return{geometry:f};var h=this.initMaterials(a.materials,b);return this.needsTangents(h)&&f.computeTangents(),{geometry:f,materials:h}},"undefined"==typeof XMLSerializer&&(XMLSerializer=require("xmldom").XMLSerializer,document={},document.implementation=new(require("xmldom").DOMImplementation));var JXON=new function(){function a(a){return j.test(a)?null:k.test(a)?"true"===a.toLowerCase():isFinite(a)?parseFloat(a):isFinite(Date.parse(a))?new Date(a):a}function b(){}function c(a){return null===a?new b:a instanceof Object?a:new a.constructor(a)}function d(b,e,j,k){var l,m,n=i.length,o=b.hasChildNodes(),p=b.hasAttributes(),q=Boolean(2&e),r=0,s="",t=q?{}:!0;if(o)for(var u,v=0;vy;y++)l=i[y].nodeName.toLowerCase(),m=d(i[y],e,j,k),t.hasOwnProperty(l)?(t[l].constructor!==Array&&(t[l]=[t[l]]),t[l].push(m)):(t[l]=m,r++);if(p){for(var z,A=b.attributes.length,B=k?"":h,C=k?{}:t,D=0;A>D;r++,D++)z=b.attributes.item(D),C[B+z.name.toLowerCase()]=a(z.value.trim());k&&(j&&Object.freeze(C),t[g]=C,r-=A-1)}return 3===e||(2===e||1===e&&r>0)&&s?t[f]=x:!q&&0===r&&s&&(t=x),j&&(q||r>0)&&Object.freeze(t),i.length=n,t}function e(a,b,c){var d,i;c instanceof String||c instanceof Number||c instanceof Boolean?b.appendChild(a.createTextNode(c.toString())):c.constructor===Date&&b.appendChild(a.createTextNode(c.toGMTString()));for(var j in c)if(d=c[j],!(isFinite(j)||d instanceof Function))if(j===f)null!==d&&d!==!0&&b.appendChild(a.createTextNode(d.constructor===Date?d.toGMTString():String(d)));else if(j===g)for(var k in d)b.setAttribute(k,d[k]);else if(j.charAt(0)===h)b.setAttribute(j.slice(1),d);else if(d.constructor===Array)for(var l=0;l1&&"number"==typeof b?3&b:1;return d(a,f,c||!1,arguments.length>3?e:3===f)},this.unbuild=function(a){var b=document.implementation.createDocument("","",null);return e(b,b,a),b},this.stringify=function(a){return(new XMLSerializer).serializeToString(JXON.unbuild(a))}};THREE.MapControls=function(a,b){function c(){return 2*Math.PI/60/60*m.autoRotateSpeed}function d(){var a=F===E.TOUCH_DOLLY?m.zoomSpeed:.7*m.zoomSpeed;return Math.pow(.95,a)}function e(a){if(m.enabled!==!1){if(a.preventDefault(),a.button===m.mouseButtons.ORBIT){if(m.noRotate===!0)return;F=E.ROTATE,o.set(a.clientX,a.clientY)}else if(a.button===m.mouseButtons.ZOOM){if(m.noZoom===!0)return;F=E.DOLLY,v.set(a.clientX,a.clientY)}else if(a.button===m.mouseButtons.PAN){if(m.noPan===!0)return;F=E.PAN,r.set(a.clientX,a.clientY)}document.addEventListener("mousemove",f,!1),document.addEventListener("mouseup",g,!1),m.dispatchEvent(J)}}function f(a){if(m.enabled!==!1){a.preventDefault();var b=m.domElement===document?m.domElement.body:m.domElement;if(F===E.ROTATE){if(m.noRotate===!0)return;p.set(a.clientX,a.clientY),q.subVectors(p,o),m.rotateLeft(2*Math.PI*q.x/b.clientWidth*m.rotateSpeed),m.rotateUp(2*Math.PI*q.y/b.clientHeight*m.rotateSpeed),o.copy(p)}else if(F===E.DOLLY){if(m.noZoom===!0)return;w.set(a.clientX,a.clientY),x.subVectors(w,v),x.y>0?m.dollyIn():m.dollyOut(),v.copy(w)}else if(F===E.PAN){if(m.noPan===!0)return;s.set(a.clientX,a.clientY),t.subVectors(s,r),m.pan(t.x,t.y),r.copy(s)}m.update()}}function g(){m.enabled!==!1&&(document.removeEventListener("mousemove",f,!1),document.removeEventListener("mouseup",g,!1),m.dispatchEvent(K),F=E.NONE)}function h(a){if(m.enabled!==!1&&m.noZoom!==!0){a.preventDefault(),a.stopPropagation();var b=0;void 0!==a.wheelDelta?b=a.wheelDelta:void 0!==a.detail&&(b=-a.detail),b>0?m.dollyOut():m.dollyIn(),m.update(),m.dispatchEvent(J),m.dispatchEvent(K)}}function i(a){if(m.enabled!==!1&&m.noKeys!==!0&&m.noPan!==!0)switch(a.keyCode){case m.keys.UP:m.pan(0,m.keyPanSpeed),m.update();break;case m.keys.BOTTOM:m.pan(0,-m.keyPanSpeed),m.update();break;case m.keys.LEFT:m.pan(m.keyPanSpeed,0),m.update();break;case m.keys.RIGHT:m.pan(-m.keyPanSpeed,0),m.update()}}function j(a){if(m.enabled!==!1){switch(a.touches.length){case 1:if(m.noRotate===!0)return;F=E.TOUCH_ROTATE,o.set(a.touches[0].pageX,a.touches[0].pageY);break;case 2:if(m.noZoom===!0)return;F=E.TOUCH_DOLLY;var b=a.touches[0].pageX-a.touches[1].pageX,c=a.touches[0].pageY-a.touches[1].pageY,d=Math.sqrt(b*b+c*c);v.set(0,d);break;case 3:if(m.noPan===!0)return;F=E.TOUCH_PAN,r.set(a.touches[0].pageX,a.touches[0].pageY);break;default:F=E.NONE}m.dispatchEvent(J)}}function k(a){if(m.enabled!==!1){a.preventDefault(),a.stopPropagation();var b=m.domElement===document?m.domElement.body:m.domElement;switch(a.touches.length){case 1:if(m.noRotate===!0)return;if(F!==E.TOUCH_ROTATE)return;p.set(a.touches[0].pageX,a.touches[0].pageY),q.subVectors(p,o),m.rotateLeft(2*Math.PI*q.x/b.clientWidth*m.rotateSpeed),m.rotateUp(2*Math.PI*q.y/b.clientHeight*m.rotateSpeed),o.copy(p),m.update();break;case 2:if(m.noZoom===!0)return;if(F!==E.TOUCH_DOLLY)return;var c=a.touches[0].pageX-a.touches[1].pageX,d=a.touches[0].pageY-a.touches[1].pageY,e=Math.sqrt(c*c+d*d);w.set(0,e),x.subVectors(w,v),x.y>0?m.dollyOut():m.dollyIn(),v.copy(w),m.update();break;case 3:if(m.noPan===!0)return;if(F!==E.TOUCH_PAN)return;s.set(a.touches[0].pageX,a.touches[0].pageY),t.subVectors(s,r),m.pan(t.x,t.y),r.copy(s),m.update();break;default:F=E.NONE}}}function l(){m.enabled!==!1&&(m.dispatchEvent(K),F=E.NONE)}this.object=a,this.domElement=void 0!==b?b:document,this.enabled=!0,this.target=new THREE.Vector3,this.center=this.target,this.noZoom=!1,this.zoomSpeed=1,this.minDistance=0,this.maxDistance=1/0,this.noRotate=!1,this.rotateSpeed=1,this.noPan=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.noKeys=!1,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:THREE.MOUSE.LEFT,ZOOM:THREE.MOUSE.MIDDLE,PAN:THREE.MOUSE.RIGHT};var m=this,n=1e-6,o=new THREE.Vector2,p=new THREE.Vector2,q=new THREE.Vector2,r=new THREE.Vector2,s=new THREE.Vector2,t=new THREE.Vector2,u=new THREE.Vector3;this.offset=new THREE.Vector3;var v=new THREE.Vector2,w=new THREE.Vector2,x=new THREE.Vector2,y=0,z=0,A=1,B=new THREE.Vector3,C=new THREE.Vector3,D=new THREE.Quaternion,E={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},F=E.NONE;this.target0=this.target.clone(),this.position0=this.object.position.clone();var G=(new THREE.Quaternion).setFromUnitVectors(a.up,new THREE.Vector3(0,1,0)),H=G.clone().inverse(),I={type:"change"},J={type:"start"},K={type:"end"};this.rotateLeft=function(a){void 0===a&&(a=c()),z-=a},this.rotateUp=function(a){void 0===a&&(a=c()),y-=a},this.panLeft=function(a){var b=this.object.matrix.elements;u.set(b[0],0,b[2]).normalize(),u.multiplyScalar(-a),B.add(u)},this.panUp=function(a){var b=this.object.matrix.elements;u.set(b[8],0,b[10]).normalize(),u.multiplyScalar(-a),B.add(u)},this.pan=function(a,b){var c=m.domElement===document?m.domElement.body:m.domElement;if(void 0!==m.object.fov){var d=m.object.position,e=d.clone().sub(m.target),f=e.length();f*=Math.tan(m.object.fov/2*Math.PI/180),m.panLeft(2*a*f/c.clientHeight),m.panUp(2*b*f/c.clientHeight)}else void 0!==m.object.top?(m.panLeft(a*(m.object.right-m.object.left)/c.clientWidth),m.panUp(b*(m.object.top-m.object.bottom)/c.clientHeight)):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.")},this.dollyIn=function(a){void 0===a&&(a=d()),A/=a},this.dollyOut=function(a){void 0===a&&(a=d()),A*=a},this.update=function(){var a=this.object.position;this.offset.copy(a).sub(this.target),this.offset.applyQuaternion(G);var b=Math.atan2(this.offset.x,this.offset.z),d=Math.atan2(Math.sqrt(this.offset.x*this.offset.x+this.offset.z*this.offset.z),this.offset.y);this.autoRotate&&this.rotateLeft(c()),b+=z,d+=y,b=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,b)),d=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,d)),d=Math.max(n,Math.min(Math.PI-n,d));var e=this.offset.length()*A;e=Math.max(this.minDistance,Math.min(this.maxDistance,e)),this.target.add(B),this.offset.x=e*Math.sin(d)*Math.sin(b),this.offset.y=e*Math.cos(d),this.offset.z=e*Math.sin(d)*Math.cos(b),this.offset.applyQuaternion(H),a.copy(this.target).add(this.offset),this.object.lookAt(this.target),z=0,y=0,A=1,B.set(0,0,0),(C.distanceToSquared(this.object.position)>n||8*(1-D.dot(this.object.quaternion))>n)&&(this.dispatchEvent(I),C.copy(this.object.position),D.copy(this.object.quaternion))},this.reset=function(){F=E.NONE,this.target.copy(this.target0),this.object.position.copy(this.position0),this.update()},this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1),this.domElement.addEventListener("mousedown",e,!1),this.domElement.addEventListener("mousewheel",h,!1),this.domElement.addEventListener("DOMMouseScroll",h,!1),this.domElement.addEventListener("touchstart",j,!1),this.domElement.addEventListener("touchend",l,!1),this.domElement.addEventListener("touchmove",k,!1),window.addEventListener("keydown",i,!1),this.update()},THREE.MapControls.prototype=Object.create(THREE.EventDispatcher.prototype),THREE.OrbitControls=function(a,b){function c(){return 2*Math.PI/60/60*m.autoRotateSpeed}function d(){var a=F===E.TOUCH_DOLLY?m.zoomSpeed:.7*m.zoomSpeed;return Math.pow(.95,a)}function e(a){if(m.enabled!==!1){if(a.preventDefault(),a.button===m.mouseButtons.ORBIT){if(m.noRotate===!0)return;F=E.ROTATE,o.set(a.clientX,a.clientY)}else if(a.button===m.mouseButtons.ZOOM){if(m.noZoom===!0)return;F=E.DOLLY,v.set(a.clientX,a.clientY)}else if(a.button===m.mouseButtons.PAN){if(m.noPan===!0)return;F=E.PAN,r.set(a.clientX,a.clientY)}document.addEventListener("mousemove",f,!1),document.addEventListener("mouseup",g,!1),m.dispatchEvent(J)}}function f(a){if(m.enabled!==!1){a.preventDefault();var b=m.domElement===document?m.domElement.body:m.domElement;if(F===E.ROTATE){if(m.noRotate===!0)return;p.set(a.clientX,a.clientY),q.subVectors(p,o),m.rotateLeft(2*Math.PI*q.x/b.clientWidth*m.rotateSpeed),m.rotateUp(2*Math.PI*q.y/b.clientHeight*m.rotateSpeed),o.copy(p)}else if(F===E.DOLLY){if(m.noZoom===!0)return;w.set(a.clientX,a.clientY),x.subVectors(w,v),x.y>0?m.dollyIn():m.dollyOut(),v.copy(w)}else if(F===E.PAN){if(m.noPan===!0)return;s.set(a.clientX,a.clientY),t.subVectors(s,r),m.pan(t.x,t.y),r.copy(s)}m.update()}}function g(){m.enabled!==!1&&(document.removeEventListener("mousemove",f,!1),document.removeEventListener("mouseup",g,!1),m.dispatchEvent(K),F=E.NONE)}function h(a){if(m.enabled!==!1&&m.noZoom!==!0){a.preventDefault(),a.stopPropagation();var b=0;void 0!==a.wheelDelta?b=a.wheelDelta:void 0!==a.detail&&(b=-a.detail),b>0?m.dollyOut():m.dollyIn(),m.update(),m.dispatchEvent(J),m.dispatchEvent(K)}}function i(a){if(m.enabled!==!1&&m.noKeys!==!0&&m.noPan!==!0)switch(a.keyCode){case m.keys.UP:m.pan(0,m.keyPanSpeed),m.update();break;case m.keys.BOTTOM:m.pan(0,-m.keyPanSpeed),m.update();break;case m.keys.LEFT:m.pan(m.keyPanSpeed,0),m.update();break;case m.keys.RIGHT:m.pan(-m.keyPanSpeed,0),m.update()}}function j(a){if(m.enabled!==!1){switch(a.touches.length){case 1:if(m.noRotate===!0)return;F=E.TOUCH_ROTATE,o.set(a.touches[0].pageX,a.touches[0].pageY);break;case 2:if(m.noZoom===!0)return;F=E.TOUCH_DOLLY;var b=a.touches[0].pageX-a.touches[1].pageX,c=a.touches[0].pageY-a.touches[1].pageY,d=Math.sqrt(b*b+c*c);v.set(0,d);break;case 3:if(m.noPan===!0)return;F=E.TOUCH_PAN,r.set(a.touches[0].pageX,a.touches[0].pageY);break;default:F=E.NONE}m.dispatchEvent(J)}}function k(a){if(m.enabled!==!1){a.preventDefault(),a.stopPropagation();var b=m.domElement===document?m.domElement.body:m.domElement;switch(a.touches.length){case 1:if(m.noRotate===!0)return;if(F!==E.TOUCH_ROTATE)return;p.set(a.touches[0].pageX,a.touches[0].pageY),q.subVectors(p,o),m.rotateLeft(2*Math.PI*q.x/b.clientWidth*m.rotateSpeed),m.rotateUp(2*Math.PI*q.y/b.clientHeight*m.rotateSpeed),o.copy(p),m.update();break;case 2:if(m.noZoom===!0)return;if(F!==E.TOUCH_DOLLY)return;var c=a.touches[0].pageX-a.touches[1].pageX,d=a.touches[0].pageY-a.touches[1].pageY,e=Math.sqrt(c*c+d*d);w.set(0,e),x.subVectors(w,v),x.y>0?m.dollyOut():m.dollyIn(),v.copy(w),m.update();break;case 3:if(m.noPan===!0)return;if(F!==E.TOUCH_PAN)return;s.set(a.touches[0].pageX,a.touches[0].pageY),t.subVectors(s,r),m.pan(t.x,t.y),r.copy(s),m.update();break;default:F=E.NONE}}}function l(){m.enabled!==!1&&(m.dispatchEvent(K),F=E.NONE)}this.object=a,this.domElement=void 0!==b?b:document,this.enabled=!0,this.target=new THREE.Vector3,this.center=this.target,this.noZoom=!1,this.zoomSpeed=1,this.minDistance=0,this.maxDistance=1/0,this.noRotate=!1,this.rotateSpeed=1,this.noPan=!1,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.noKeys=!1,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:THREE.MOUSE.LEFT,ZOOM:THREE.MOUSE.MIDDLE,PAN:THREE.MOUSE.RIGHT};var m=this,n=1e-6,o=new THREE.Vector2,p=new THREE.Vector2,q=new THREE.Vector2,r=new THREE.Vector2,s=new THREE.Vector2,t=new THREE.Vector2,u=new THREE.Vector3;this.offset=new THREE.Vector3;var v=new THREE.Vector2,w=new THREE.Vector2,x=new THREE.Vector2,y=0,z=0,A=1,B=new THREE.Vector3,C=new THREE.Vector3,D=new THREE.Quaternion,E={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},F=E.NONE;this.target0=this.target.clone(),this.position0=this.object.position.clone();var G=(new THREE.Quaternion).setFromUnitVectors(a.up,new THREE.Vector3(0,1,0)),H=G.clone().inverse(),I={type:"change"},J={type:"start"},K={type:"end"};this.rotateLeft=function(a){void 0===a&&(a=c()),z-=a},this.rotateUp=function(a){void 0===a&&(a=c()),y-=a},this.panLeft=function(a){var b=this.object.matrix.elements;u.set(b[0],b[1],b[2]),u.multiplyScalar(-a),B.add(u)},this.panUp=function(a){var b=this.object.matrix.elements;u.set(b[4],b[5],b[6]),u.multiplyScalar(a),B.add(u)},this.pan=function(a,b){var c=m.domElement===document?m.domElement.body:m.domElement;if(void 0!==m.object.fov){var d=m.object.position,e=d.clone().sub(m.target),f=e.length();f*=Math.tan(m.object.fov/2*Math.PI/180),m.panLeft(2*a*f/c.clientHeight),m.panUp(2*b*f/c.clientHeight)}else void 0!==m.object.top?(m.panLeft(a*(m.object.right-m.object.left)/c.clientWidth),m.panUp(b*(m.object.top-m.object.bottom)/c.clientHeight)):console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.")},this.dollyIn=function(a){void 0===a&&(a=d()),A/=a},this.dollyOut=function(a){void 0===a&&(a=d()),A*=a},this.update=function(){var a=this.object.position;this.offset.copy(a).sub(this.target),this.offset.applyQuaternion(G);var b=Math.atan2(this.offset.x,this.offset.z),d=Math.atan2(Math.sqrt(this.offset.x*this.offset.x+this.offset.z*this.offset.z),this.offset.y);this.autoRotate&&this.rotateLeft(c()),b+=z,d+=y,b=Math.max(this.minAzimuthAngle,Math.min(this.maxAzimuthAngle,b)),d=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,d)),d=Math.max(n,Math.min(Math.PI-n,d));var e=this.offset.length()*A;e=Math.max(this.minDistance,Math.min(this.maxDistance,e)),this.target.add(B),this.offset.x=e*Math.sin(d)*Math.sin(b),this.offset.y=e*Math.cos(d),this.offset.z=e*Math.sin(d)*Math.cos(b),this.offset.applyQuaternion(H),a.copy(this.target).add(this.offset),this.object.lookAt(this.target),z=0,y=0,A=1,B.set(0,0,0),(C.distanceToSquared(this.object.position)>n||8*(1-D.dot(this.object.quaternion))>n)&&(this.dispatchEvent(I),C.copy(this.object.position),D.copy(this.object.quaternion))},this.reset=function(){F=E.NONE,this.target.copy(this.target0),this.object.position.copy(this.position0),this.update()},this.domElement.addEventListener("contextmenu",function(a){a.preventDefault()},!1),this.domElement.addEventListener("mousedown",e,!1),this.domElement.addEventListener("mousewheel",h,!1),this.domElement.addEventListener("DOMMouseScroll",h,!1),this.domElement.addEventListener("touchstart",j,!1),this.domElement.addEventListener("touchend",l,!1),this.domElement.addEventListener("touchmove",k,!1),window.addEventListener("keydown",i,!1),this.update()},THREE.OrbitControls.prototype=Object.create(THREE.EventDispatcher.prototype); \ No newline at end of file diff --git a/examples/basic-example/main.js b/examples/basic-example/main.js index 9183fb2..6ac7988 100644 --- a/examples/basic-example/main.js +++ b/examples/basic-example/main.js @@ -1,5 +1,6 @@ var world = new VIZI.World({ - viewport: document.querySelector("#vizicities-viewport") + viewport: document.querySelector("#vizicities-viewport"), + layersUI: true // center: new VIZI.LatLon(40.01000594412381, -105.2727379358738) // Collada }); diff --git a/src/Core/World.js b/src/Core/World.js index dd285f6..9468ccb 100644 --- a/src/Core/World.js +++ b/src/Core/World.js @@ -19,7 +19,8 @@ crs: VIZI.CRS.EPSG3857, center: new VIZI.LatLon(51.50358, -0.01924), zoom: 16, - suppressRenderer: false // Set true for tests + suppressRenderer: false, // Set true for tests + layersUI: true }); if (!self.options.viewport) { @@ -45,8 +46,9 @@ self.options.viewport.appendChild(uiContainer); // Set up layer UI - // TODO: Make this togglable via an option - self.layersUI = new VIZI.LayersUI(self.layers); + if (self.options.layersUI) { + self.layersUI = new VIZI.LayersUI(self.layers); + } // TODO: Ability to override this with a scene passed into the options // TODO: Pass-through options that tweak scene (antialias, etc) @@ -128,7 +130,9 @@ self.scene.add(layer.object); // Update layers UI - self.layersUI.onChange(); + if (self.layersUI) { + self.layersUI.onChange(); + } }; VIZI.World.prototype.addSwitchboard = function(switchboard) {