make annotations show up in map view
This commit is contained in:
parent
fb71f01239
commit
8c7b1cfa05
@ -57,12 +57,14 @@ Potree.Annotation = class extends THREE.EventDispatcher{
|
||||
this.elDescriptionClose = this.elDescription.find(".annotation-description-close");
|
||||
//this.elDescriptionContent = this.elDescription.find(".annotation-description-content");
|
||||
|
||||
this.elTitle.click(() => {
|
||||
this.clickTitle = () => {
|
||||
if(this.hasView()){
|
||||
this.moveHere(this.scene.camera);
|
||||
}
|
||||
this.dispatchEvent({type: "click", target: this});
|
||||
});
|
||||
};
|
||||
|
||||
this.elTitle.click(this.clickTitle);
|
||||
|
||||
this.actions = this.actions.map(a => {
|
||||
if(a instanceof Potree.Action){
|
||||
|
||||
@ -17,33 +17,120 @@ Potree.MapView = class{
|
||||
this.toolLayer = null;
|
||||
this.sourcesLayer = null;
|
||||
this.sourcesLabelLayer = null;
|
||||
|
||||
//this.annotationStyleFunction = function() {
|
||||
// return [
|
||||
// new ol.style.Style({
|
||||
// fill: new ol.style.Fill({
|
||||
// color: 'rgba(255,255,255,0.4)'
|
||||
// }),
|
||||
// stroke: new ol.style.Stroke({
|
||||
// color: '#3399CC',
|
||||
// width: 1.25
|
||||
// }),
|
||||
// text: new ol.style.Text({
|
||||
// font: '12px Calibri,sans-serif',
|
||||
// fill: new ol.style.Fill({ color: '#000' }),
|
||||
// stroke: new ol.style.Stroke({
|
||||
// color: '#fff', width: 2
|
||||
// }),
|
||||
// // get the text from the feature - `this` is ol.Feature
|
||||
// text: this.get('description')
|
||||
// })
|
||||
// })
|
||||
// ];
|
||||
//};
|
||||
|
||||
this.createAnnotationStyle = (text) => {
|
||||
return [
|
||||
new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
radius: 10,
|
||||
stroke: new ol.style.Stroke({
|
||||
color: [255, 255, 255, 0.5],
|
||||
width: 2
|
||||
}),
|
||||
fill: new ol.style.Fill({
|
||||
color: [0, 0, 0, 0.5]
|
||||
})
|
||||
})
|
||||
})/*,
|
||||
new ol.style.Style({
|
||||
text: new ol.style.Text({
|
||||
font: '12px helvetica,sans-serif',
|
||||
text: text,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#000'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#fff',
|
||||
width: 2
|
||||
})
|
||||
})
|
||||
})*/
|
||||
];
|
||||
}
|
||||
|
||||
this.createLabelStyle = (text) => {
|
||||
let style = new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
radius: 6,
|
||||
stroke: new ol.style.Stroke({
|
||||
color: 'white',
|
||||
width: 2
|
||||
}),
|
||||
fill: new ol.style.Fill({
|
||||
color: 'green'
|
||||
})
|
||||
}),
|
||||
text: new ol.style.Text({
|
||||
font: '12px helvetica,sans-serif',
|
||||
text: text,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#000'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#fff',
|
||||
width: 2
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
init(){
|
||||
$( "#potree_map" ).draggable({ handle: $('#potree_map_header') });
|
||||
$( "#potree_map" ).resizable();
|
||||
//$( "#potree_map_toggle" ).css("display", "block");
|
||||
this.elMap = $("#potree_map");
|
||||
this.elMap.draggable({ handle: $('#potree_map_header') });
|
||||
this.elMap.resizable();
|
||||
|
||||
this.elTooltip = $(`<div style="position: relative; z-index: 100"></div>`);
|
||||
this.elMap.append(this.elTooltip);
|
||||
|
||||
let extentsLayer = this.getExtentsLayer();
|
||||
let cameraLayer = this.getCameraLayer();
|
||||
let toolLayer = this.getToolLayer();
|
||||
let sourcesLayer = this.getSourcesLayer();
|
||||
let sourcesLabelLayer = this.getSourcesLabelLayer();
|
||||
let annotationsLayer = this.getAnnotationsLayer();
|
||||
|
||||
var mousePositionControl = new ol.control.MousePosition({
|
||||
let mousePositionControl = new ol.control.MousePosition({
|
||||
coordinateFormat: ol.coordinate.createStringXY(5),
|
||||
projection: "EPSG:4326",
|
||||
undefinedHTML: ' '
|
||||
});
|
||||
|
||||
let DownloadSelectionControl = function(opt_options){
|
||||
var options = opt_options || {};
|
||||
let options = opt_options || {};
|
||||
|
||||
// TOGGLE TILES
|
||||
var btToggleTiles = document.createElement('button');
|
||||
let btToggleTiles = document.createElement('button');
|
||||
btToggleTiles.innerHTML = 'T';
|
||||
btToggleTiles.addEventListener('click', () => {
|
||||
var visible = this.sourcesLayer.getVisible();
|
||||
let visible = this.sourcesLayer.getVisible();
|
||||
this.sourcesLayer.setVisible(!visible);
|
||||
this.sourcesLabelLayer.setVisible(!visible);
|
||||
}, false);
|
||||
@ -51,20 +138,20 @@ Potree.MapView = class{
|
||||
btToggleTiles.title = "show / hide tiles";
|
||||
|
||||
// DOWNLOAD SELECTED TILES
|
||||
var link = document.createElement("a");
|
||||
let link = document.createElement("a");
|
||||
link.href = "#";
|
||||
link.download = "list.txt";
|
||||
link.style.float = "left";
|
||||
|
||||
var button = document.createElement('button');
|
||||
let button = document.createElement('button');
|
||||
button.innerHTML = 'D';
|
||||
link.appendChild(button);
|
||||
|
||||
var this_ = this;
|
||||
var handleDownload = (e) => {
|
||||
var features = selectedFeatures.getArray();
|
||||
let this_ = this;
|
||||
let handleDownload = (e) => {
|
||||
let features = selectedFeatures.getArray();
|
||||
|
||||
var url = [location.protocol, '//', location.host, location.pathname].join('');
|
||||
let url = [location.protocol, '//', location.host, location.pathname].join('');
|
||||
|
||||
if(features.length === 0){
|
||||
alert("No tiles were selected. Select area with ctrl + left mouse button!");
|
||||
@ -72,27 +159,27 @@ Potree.MapView = class{
|
||||
e.stopImmediatePropagation();
|
||||
return false;
|
||||
}else if(features.length === 1){
|
||||
var feature = features[0];
|
||||
let feature = features[0];
|
||||
|
||||
if(feature.source){
|
||||
var cloudjsurl = feature.pointcloud.pcoGeometry.url;
|
||||
var sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name);
|
||||
let cloudjsurl = feature.pointcloud.pcoGeometry.url;
|
||||
let sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name);
|
||||
link.href = sourceurl.href;
|
||||
link.download = feature.source.name;
|
||||
}
|
||||
}else{
|
||||
var content = "";
|
||||
let content = "";
|
||||
for(var i = 0; i < features.length; i++){
|
||||
var feature = features[i];
|
||||
let feature = features[i];
|
||||
|
||||
if(feature.source){
|
||||
var cloudjsurl = feature.pointcloud.pcoGeometry.url;
|
||||
var sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name);
|
||||
let cloudjsurl = feature.pointcloud.pcoGeometry.url;
|
||||
let sourceurl = new URL(url + '/../' + cloudjsurl + '/../source/' + feature.source.name);
|
||||
content += sourceurl.href + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
var uri = "data:application/octet-stream;base64,"+btoa(content);
|
||||
let uri = "data:application/octet-stream;base64,"+btoa(content);
|
||||
link.href = uri;
|
||||
link.download = "list_of_files.txt";
|
||||
}
|
||||
@ -101,7 +188,7 @@ Potree.MapView = class{
|
||||
button.addEventListener('click', handleDownload, false);
|
||||
|
||||
// assemble container
|
||||
var element = document.createElement('div');
|
||||
let element = document.createElement('div');
|
||||
element.className = 'ol-unselectable ol-control';
|
||||
element.appendChild(link);
|
||||
element.appendChild(btToggleTiles);
|
||||
@ -130,6 +217,7 @@ Potree.MapView = class{
|
||||
layers: [
|
||||
new ol.layer.Tile({source: new ol.source.OSM()}),
|
||||
this.toolLayer,
|
||||
this.annotationsLayer,
|
||||
this.sourcesLayer,
|
||||
this.sourcesLabelLayer,
|
||||
extentsLayer,
|
||||
@ -154,23 +242,48 @@ Potree.MapView = class{
|
||||
});
|
||||
this.map.addLayer(this.dragBoxLayer);
|
||||
|
||||
var select = new ol.interaction.Select();
|
||||
let select = new ol.interaction.Select();
|
||||
this.map.addInteraction(select);
|
||||
|
||||
var selectedFeatures = select.getFeatures();
|
||||
let selectedFeatures = select.getFeatures();
|
||||
|
||||
var dragBox = new ol.interaction.DragBox({
|
||||
let dragBox = new ol.interaction.DragBox({
|
||||
condition: ol.events.condition.platformModifierKeyOnly
|
||||
});
|
||||
|
||||
this.map.addInteraction(dragBox);
|
||||
|
||||
|
||||
this.map.on('pointermove', evt => {
|
||||
let pixel = evt.pixel;
|
||||
let feature = this.map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||
return feature;
|
||||
});
|
||||
|
||||
//console.log(feature);
|
||||
this.elTooltip.css("display", feature ? '' : 'none');
|
||||
if(feature && feature.onHover){
|
||||
feature.onHover(evt);
|
||||
//overlay.setPosition(evt.coordinate);
|
||||
//tooltip.innerHTML = feature.get('name');
|
||||
}
|
||||
});
|
||||
|
||||
this.map.on('click', evt => {
|
||||
let pixel = evt.pixel;
|
||||
let feature = this.map.forEachFeatureAtPixel(pixel, function(feature) {
|
||||
return feature;
|
||||
});
|
||||
|
||||
if(feature && feature.onHover){
|
||||
feature.onClick(evt);
|
||||
}
|
||||
});
|
||||
|
||||
dragBox.on('boxend', (e) => {
|
||||
// features that intersect the box are added to the collection of
|
||||
// selected features, and their names are displayed in the "info"
|
||||
// div
|
||||
var extent = dragBox.getGeometry().getExtent();
|
||||
let extent = dragBox.getGeometry().getExtent();
|
||||
this.sourcesLayer.getSource().forEachFeatureIntersectingExtent(extent, (feature) => {
|
||||
selectedFeatures.push(feature);
|
||||
});
|
||||
@ -183,25 +296,6 @@ Potree.MapView = class{
|
||||
this.map.on('click', () => {
|
||||
selectedFeatures.clear();
|
||||
});
|
||||
|
||||
//// adding pointclouds to map
|
||||
//this.viewer.addEventListener("pointcloud_added", (event) => {
|
||||
// this.load(event.pointcloud);
|
||||
//});
|
||||
//for(var i = 0; i < this.viewer.scene.pointclouds.length; i++){
|
||||
// this.load(this.viewer.scene.pointclouds[i]);
|
||||
//}
|
||||
|
||||
//this.viewer.profileTool.addEventListener("profile_added", this.updateToolDrawings);
|
||||
//this.viewer.profileTool.addEventListener("profile_removed", this.updateToolDrawings);
|
||||
//this.viewer.profileTool.addEventListener("marker_moved", this.updateToolDrawings);
|
||||
//this.viewer.profileTool.addEventListener("marker_removed", this.updateToolDrawings);
|
||||
//this.viewer.profileTool.addEventListener("marker_added", this.updateToolDrawings);
|
||||
//
|
||||
//this.viewer.measuringTool.addEventListener("measurement_added", this.updateToolDrawings);
|
||||
//this.viewer.measuringTool.addEventListener("marker_added", this.updateToolDrawings);
|
||||
//this.viewer.measuringTool.addEventListener("marker_removed", this.updateToolDrawings);
|
||||
//this.viewer.measuringTool.addEventListener("marker_moved", this.updateToolDrawings);
|
||||
|
||||
this.viewer.addEventListener("scene_changed", e => {
|
||||
this.setScene(e.scene);
|
||||
@ -211,6 +305,34 @@ Potree.MapView = class{
|
||||
this.load(e.pointcloud);
|
||||
};
|
||||
|
||||
this.onAnnotationAdded = e => {
|
||||
|
||||
let annotation = e.annotation;
|
||||
let position = annotation.position;
|
||||
let mapPos = this.toMap.forward([position.x, position.y]);
|
||||
let feature = new ol.Feature({
|
||||
geometry: new ol.geom.Point(mapPos),
|
||||
name: annotation.title
|
||||
});
|
||||
feature.setStyle(this.createAnnotationStyle(annotation.title));
|
||||
|
||||
feature.onHover = evt => {
|
||||
let coordinates = feature.getGeometry().getCoordinates();
|
||||
let p = this.map.getPixelFromCoordinate(coordinates);
|
||||
|
||||
this.elTooltip.html(annotation.title);
|
||||
this.elTooltip.css("left", `${p[0]}px`);
|
||||
this.elTooltip.css("top", `${p[1]}px`);
|
||||
};
|
||||
|
||||
feature.onClick = evt => {
|
||||
annotation.clickTitle();
|
||||
};
|
||||
|
||||
this.getAnnotationsLayer().getSource().addFeature(feature);
|
||||
|
||||
};
|
||||
|
||||
this.setScene(this.viewer.scene);
|
||||
}
|
||||
|
||||
@ -221,11 +343,13 @@ Potree.MapView = class{
|
||||
|
||||
if(this.scene){
|
||||
this.scene.removeEventListener("pointcloud_added", this.onPointcloudAdded);
|
||||
this.scene.annotations.removeEventListener("annotation_added", this.onAnnotationAdded);
|
||||
}
|
||||
|
||||
this.scene = scene;
|
||||
|
||||
this.scene.addEventListener("pointcloud_added", this.onPointcloudAdded);
|
||||
this.scene.annotations.addEventListener("annotation_added", this.onAnnotationAdded);
|
||||
|
||||
for(var i = 0; i < this.viewer.scene.pointclouds.length; i++){
|
||||
this.load(this.viewer.scene.pointclouds[i]);
|
||||
@ -266,6 +390,28 @@ Potree.MapView = class{
|
||||
return this.extentsLayer;
|
||||
}
|
||||
|
||||
getAnnotationsLayer(){
|
||||
if(this.annotationsLayer){
|
||||
return this.annotationsLayer;
|
||||
}
|
||||
|
||||
this.annotationsLayer = new ol.layer.Vector({
|
||||
source: new ol.source.Vector({
|
||||
}),
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 0, 0, 1)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: 'rgba(255, 0, 0, 1)',
|
||||
width: 2
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
return this.annotationsLayer;
|
||||
}
|
||||
|
||||
getCameraLayer(){
|
||||
if(this.cameraLayer){
|
||||
return this.cameraLayer;
|
||||
@ -273,8 +419,8 @@ Potree.MapView = class{
|
||||
|
||||
// CAMERA LAYER
|
||||
this.gCamera = new ol.geom.LineString([[0,0], [0,0], [0,0], [0,0]]);
|
||||
var feature = new ol.Feature(this.gCamera);
|
||||
var featureVector = new ol.source.Vector({
|
||||
let feature = new ol.Feature(this.gCamera);
|
||||
let featureVector = new ol.source.Vector({
|
||||
features: [feature]
|
||||
});
|
||||
|
||||
@ -365,14 +511,14 @@ Potree.MapView = class{
|
||||
};
|
||||
|
||||
getMapExtent(){
|
||||
var bb = this.viewer.getBoundingBox();
|
||||
let bb = this.viewer.getBoundingBox();
|
||||
|
||||
var bottomLeft = this.toMap.forward([bb.min.x, bb.min.y]);
|
||||
var bottomRight = this.toMap.forward([bb.max.x, bb.min.y]);
|
||||
var topRight = this.toMap.forward([bb.max.x, bb.max.y]);
|
||||
var topLeft = this.toMap.forward([bb.min.x, bb.max.y]);
|
||||
let bottomLeft = this.toMap.forward([bb.min.x, bb.min.y]);
|
||||
let bottomRight = this.toMap.forward([bb.max.x, bb.min.y]);
|
||||
let topRight = this.toMap.forward([bb.max.x, bb.max.y]);
|
||||
let topLeft = this.toMap.forward([bb.min.x, bb.max.y]);
|
||||
|
||||
var extent = {
|
||||
let extent = {
|
||||
bottomLeft: bottomLeft,
|
||||
bottomRight: bottomRight,
|
||||
topRight: topRight,
|
||||
@ -383,9 +529,9 @@ Potree.MapView = class{
|
||||
};
|
||||
|
||||
getMapCenter(){
|
||||
var mapExtent = this.getMapExtent();
|
||||
let mapExtent = this.getMapExtent();
|
||||
|
||||
var mapCenter = [
|
||||
let mapCenter = [
|
||||
(mapExtent.bottomLeft[0] + mapExtent.topRight[0]) / 2,
|
||||
(mapExtent.bottomLeft[1] + mapExtent.topRight[1]) / 2
|
||||
];
|
||||
@ -396,30 +542,30 @@ Potree.MapView = class{
|
||||
updateToolDrawings(){
|
||||
this.toolLayer.getSource().clear();
|
||||
|
||||
var profiles = this.viewer.profileTool.profiles;
|
||||
let profiles = this.viewer.profileTool.profiles;
|
||||
for(var i = 0; i < profiles.length; i++){
|
||||
var profile = profiles[i];
|
||||
var coordinates = [];
|
||||
let profile = profiles[i];
|
||||
let coordinates = [];
|
||||
|
||||
for(var j = 0; j < profile.points.length; j++){
|
||||
var point = profile.points[j];
|
||||
var pointMap = this.toMap.forward([point.x, point.y]);
|
||||
let point = profile.points[j];
|
||||
let pointMap = this.toMap.forward([point.x, point.y]);
|
||||
coordinates.push(pointMap);
|
||||
}
|
||||
|
||||
var line = new ol.geom.LineString(coordinates);
|
||||
var feature = new ol.Feature(line);
|
||||
let line = new ol.geom.LineString(coordinates);
|
||||
let feature = new ol.Feature(line);
|
||||
this.toolLayer.getSource().addFeature(feature);
|
||||
}
|
||||
|
||||
var measurements = this.viewer.measuringTool.measurements;
|
||||
let measurements = this.viewer.measuringTool.measurements;
|
||||
for(var i = 0; i < measurements.length; i++){
|
||||
var measurement = measurements[i];
|
||||
var coordinates = [];
|
||||
let measurement = measurements[i];
|
||||
let coordinates = [];
|
||||
|
||||
for(var j = 0; j < measurement.points.length; j++){
|
||||
var point = measurement.points[j].position;
|
||||
var pointMap = this.toMap.forward([point.x, point.y]);
|
||||
let point = measurement.points[j].position;
|
||||
let pointMap = this.toMap.forward([point.x, point.y]);
|
||||
coordinates.push(pointMap);
|
||||
}
|
||||
|
||||
@ -427,8 +573,8 @@ Potree.MapView = class{
|
||||
coordinates.push(coordinates[0]);
|
||||
}
|
||||
|
||||
var line = new ol.geom.LineString(coordinates);
|
||||
var feature = new ol.Feature(line);
|
||||
let line = new ol.geom.LineString(coordinates);
|
||||
let feature = new ol.Feature(line);
|
||||
this.toolLayer.getSource().addFeature(feature);
|
||||
}
|
||||
}
|
||||
@ -436,7 +582,7 @@ Potree.MapView = class{
|
||||
|
||||
load(pointcloud){
|
||||
|
||||
if(!(pointcloud instanceof Potree.PointCloudOctree)){
|
||||
if(!pointcloud){
|
||||
return;
|
||||
}
|
||||
|
||||
@ -448,50 +594,13 @@ Potree.MapView = class{
|
||||
this.setSceneProjection(pointcloud.projection);
|
||||
}
|
||||
|
||||
var mapExtent = this.getMapExtent();
|
||||
var mapCenter = this.getMapCenter();
|
||||
let mapExtent = this.getMapExtent();
|
||||
let mapCenter = this.getMapCenter();
|
||||
|
||||
|
||||
var view = this.map.getView();
|
||||
let view = this.map.getView();
|
||||
view.setCenter(mapCenter);
|
||||
|
||||
//{
|
||||
// let bb = this.viewer.getBoundingBox();
|
||||
// let corners = [
|
||||
// [bb.min.x, bb.min.y],
|
||||
// [bb.max.x, bb.min.y],
|
||||
// [bb.max.x, bb.max.y],
|
||||
// [bb.min.x, bb.max.y],
|
||||
// [bb.min.x, bb.min.y]];
|
||||
//
|
||||
// let vertices = [];
|
||||
//
|
||||
// for(let i = 0; i < corners.length - 1; i++){
|
||||
// let pieces = 5;
|
||||
//
|
||||
// for(let j = 0; j < pieces; j++){
|
||||
// let t0 = j / pieces;
|
||||
// let t1 = (j+1) / pieces;
|
||||
//
|
||||
// let c0 = corners[i+0];
|
||||
// let c1 = corners[i+1];
|
||||
//
|
||||
// let p0 = [
|
||||
// (1 - t0) * c0[0] + t0 * c1[0],
|
||||
// (1 - t0) * c0[1] + t0 * c1[1]];
|
||||
//
|
||||
// let p1 = [
|
||||
// (1 - t1) * c0[0] + t1 * c1[0],
|
||||
// (1 - t1) * c0[1] + t1 * c1[1]];
|
||||
//
|
||||
// vertices.push(this.toMap.forward(p0));
|
||||
// vertices.push(this.toMap.forward(p1));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// this.gExtent.setCoordinates(vertices);
|
||||
//}
|
||||
|
||||
this.gExtent.setCoordinates([
|
||||
mapExtent.bottomLeft,
|
||||
mapExtent.bottomRight,
|
||||
@ -504,62 +613,37 @@ Potree.MapView = class{
|
||||
constrainResolution: false
|
||||
});
|
||||
|
||||
let createLabelStyle = (text) => {
|
||||
var style = new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(100,50,200,0.5)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: 'rgba(120,30,100,0.8)',
|
||||
width: 3
|
||||
})
|
||||
}),
|
||||
text: new ol.style.Text({
|
||||
font: '12px helvetica,sans-serif',
|
||||
text: text,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#000'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#fff',
|
||||
width: 2
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
|
||||
var url = pointcloud.pcoGeometry.url + "/../sources.json";
|
||||
let url = pointcloud.pcoGeometry.url + "/../sources.json";
|
||||
$.getJSON(url, (data) => {
|
||||
var sources = data.sources;
|
||||
let sources = data.sources;
|
||||
|
||||
for(var i = 0; i < sources.length; i++){
|
||||
var source = sources[i];
|
||||
var name = source.name;
|
||||
var points = source.points;
|
||||
var bounds = source.bounds;
|
||||
let source = sources[i];
|
||||
let name = source.name;
|
||||
let points = source.points;
|
||||
let bounds = source.bounds;
|
||||
|
||||
var mapBounds = {
|
||||
let mapBounds = {
|
||||
min: this.toMap.forward( [bounds.min[0], bounds.min[1]] ),
|
||||
max: this.toMap.forward( [bounds.max[0], bounds.max[1]] )
|
||||
}
|
||||
var mapCenter = [
|
||||
let mapCenter = [
|
||||
(mapBounds.min[0] + mapBounds.max[0]) / 2,
|
||||
(mapBounds.min[1] + mapBounds.max[1]) / 2,
|
||||
];
|
||||
|
||||
var p1 = this.toMap.forward( [bounds.min[0], bounds.min[1]] );
|
||||
var p2 = this.toMap.forward( [bounds.max[0], bounds.min[1]] );
|
||||
var p3 = this.toMap.forward( [bounds.max[0], bounds.max[1]] );
|
||||
var p4 = this.toMap.forward( [bounds.min[0], bounds.max[1]] );
|
||||
let p1 = this.toMap.forward( [bounds.min[0], bounds.min[1]] );
|
||||
let p2 = this.toMap.forward( [bounds.max[0], bounds.min[1]] );
|
||||
let p3 = this.toMap.forward( [bounds.max[0], bounds.max[1]] );
|
||||
let p4 = this.toMap.forward( [bounds.min[0], bounds.max[1]] );
|
||||
|
||||
var boxes = [];
|
||||
let boxes = [];
|
||||
//var feature = new ol.Feature({
|
||||
// 'geometry': new ol.geom.LineString([p1, p2, p3, p4, p1])
|
||||
//});
|
||||
var feature = new ol.Feature({
|
||||
let feature = new ol.Feature({
|
||||
'geometry': new ol.geom.Polygon([[p1, p2, p3, p4, p1]])
|
||||
});
|
||||
feature.source = source;
|
||||
@ -571,7 +655,7 @@ Potree.MapView = class{
|
||||
geometry: new ol.geom.Point(mapCenter),
|
||||
name: name
|
||||
});
|
||||
feature.setStyle(createLabelStyle(name));
|
||||
feature.setStyle(this.createLabelStyle(name));
|
||||
this.sourcesLabelLayer.getSource().addFeature(feature);
|
||||
}
|
||||
});
|
||||
@ -582,37 +666,37 @@ Potree.MapView = class{
|
||||
return;
|
||||
}
|
||||
|
||||
var pm = $( "#potree_map" );
|
||||
let pm = $( "#potree_map" );
|
||||
|
||||
if(!pm.is(":visible")){
|
||||
return;
|
||||
}
|
||||
|
||||
// resize
|
||||
var mapSize = this.map.getSize();
|
||||
var resized = (pm.width() != mapSize[0] || pm.height() != mapSize[1]);
|
||||
let mapSize = this.map.getSize();
|
||||
let resized = (pm.width() != mapSize[0] || pm.height() != mapSize[1]);
|
||||
if(resized){
|
||||
this.map.updateSize();
|
||||
}
|
||||
|
||||
// camera
|
||||
var scale = this.map.getView().getResolution();
|
||||
var camera = this.viewer.scene.camera;
|
||||
var campos = camera.position;
|
||||
var camdir = camera.getWorldDirection();
|
||||
var sceneLookAt = camdir.clone().multiplyScalar(30 * scale).add(campos);
|
||||
var geoPos = camera.position;
|
||||
var geoLookAt = sceneLookAt;
|
||||
var mapPos = new THREE.Vector2().fromArray(this.toMap.forward([geoPos.x, geoPos.y]));
|
||||
var mapLookAt = new THREE.Vector2().fromArray(this.toMap.forward([geoLookAt.x, geoLookAt.y]));
|
||||
var mapDir = new THREE.Vector2().subVectors(mapLookAt, mapPos).normalize();
|
||||
let scale = this.map.getView().getResolution();
|
||||
let camera = this.viewer.scene.camera;
|
||||
let campos = camera.position;
|
||||
let camdir = camera.getWorldDirection();
|
||||
let sceneLookAt = camdir.clone().multiplyScalar(30 * scale).add(campos);
|
||||
let geoPos = camera.position;
|
||||
let geoLookAt = sceneLookAt;
|
||||
let mapPos = new THREE.Vector2().fromArray(this.toMap.forward([geoPos.x, geoPos.y]));
|
||||
let mapLookAt = new THREE.Vector2().fromArray(this.toMap.forward([geoLookAt.x, geoLookAt.y]));
|
||||
let mapDir = new THREE.Vector2().subVectors(mapLookAt, mapPos).normalize();
|
||||
mapLookAt = mapPos.clone().add(mapDir.clone().multiplyScalar(30 * scale));
|
||||
var mapLength = mapPos.distanceTo(mapLookAt);
|
||||
var mapSide = new THREE.Vector2(-mapDir.y, mapDir.x);
|
||||
let mapLength = mapPos.distanceTo(mapLookAt);
|
||||
let mapSide = new THREE.Vector2(-mapDir.y, mapDir.x);
|
||||
|
||||
var p1 = mapPos.toArray();
|
||||
var p2 = mapLookAt.clone().sub(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray();
|
||||
var p3 = mapLookAt.clone().add(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray();
|
||||
let p1 = mapPos.toArray();
|
||||
let p2 = mapLookAt.clone().sub(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray();
|
||||
let p3 = mapLookAt.clone().add(mapSide.clone().multiplyScalar(0.3 * mapLength)).toArray();
|
||||
|
||||
|
||||
this.gCamera.setCoordinates([p1, p2, p3, p1]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user