commit
cd4b868164
1802
build/js/potree.js
1802
build/js/potree.js
File diff suppressed because it is too large
Load Diff
5
build/js/potree.min.js
vendored
5
build/js/potree.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1,240 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Lion</title>
|
||||
|
||||
</head>
|
||||
<body style="margin: 0px; padding: 0px; overflow: hidden">
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
.info{
|
||||
color:white;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px black,
|
||||
1px -1px 1px black,
|
||||
-1px 1px 1px black,
|
||||
-1px -1px 1px black;
|
||||
}
|
||||
|
||||
#lblDistance{
|
||||
color:white;
|
||||
font-weight: bold;
|
||||
text-shadow: 2px 2px 2px black,
|
||||
2px -2px 2px black,
|
||||
-2px 2px 2px black,
|
||||
-2px -2px 2px black;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script src="../libs/three.js/build/three.js"></script>
|
||||
<script src="../libs/other/OrbitControls.js"></script>
|
||||
<script src="../libs/other/stats.min.js"></script>
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
<script src="../build/js/potree.min.js"></script>
|
||||
|
||||
<input type="button" value="place start"
|
||||
style="position:absolute; left: 10px; top: 10px; width: 100px; z-index: 100"
|
||||
onclick="placeStart()">
|
||||
<input type="button" value="place end"
|
||||
style="position:absolute; left: 10px; top: 40px; width: 100px; z-index: 100"
|
||||
onclick="placeEnd()">
|
||||
|
||||
<div id="lblDistance" class="info" style="position: absolute; width: 20px; z-index: 100;">abc</div>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px;"></div>
|
||||
<div id="lblNumVisiblePoints" class="info" style="position: absolute; left: 10px; top: 100px; width: 400px;"></div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var defaultPointSize = 0.03;
|
||||
var defaultLOD = 15;
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud_bin.js";
|
||||
|
||||
var renderer;
|
||||
var camera;
|
||||
var scene;
|
||||
var mouse = { x: 1, y: 1 };
|
||||
var projector, raycaster;
|
||||
var pointcloud, pointcloudMaterial;
|
||||
var spStart, spEnd, sConnection;
|
||||
var placeStartMode = false;
|
||||
var placeEndMode = false;
|
||||
var skybox;
|
||||
|
||||
function initGUI(){
|
||||
var gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
LOD: defaultLOD,
|
||||
"show aabb" : false
|
||||
};
|
||||
|
||||
var pLOD = gui.add(params, 'LOD', 0.5,20);
|
||||
pLOD.onChange(function(value){
|
||||
pointcloud.LOD = value;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 0.1);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloudMaterial.size = value;
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'show aabb');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
});
|
||||
}
|
||||
|
||||
function initThree() {
|
||||
scene = new THREE.Scene();
|
||||
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
|
||||
|
||||
projector = new THREE.Projector();
|
||||
raycaster = new THREE.Raycaster();
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
renderer.autoClear = false;
|
||||
document.body.appendChild(renderer.domElement);
|
||||
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
// pointcloud
|
||||
pointcloudMaterial = new THREE.PointCloudMaterial( { size: defaultPointSize, vertexColors: true } );
|
||||
var pco = POCLoader.load(pointcloudPath);
|
||||
pointcloud = new Potree.PointCloudOctree(pco, pointcloudMaterial);
|
||||
pointcloud.LOD = defaultLOD;
|
||||
pointcloud.rotation.set(Math.PI/2, 0.85* -Math.PI/2, -0.0);
|
||||
pointcloud.moveToOrigin();
|
||||
pointcloud.moveToGroundPlane();
|
||||
pointcloud.position.y -= 1.6
|
||||
scene.add(pointcloud);
|
||||
|
||||
// grid
|
||||
scene.add(Potree.utils.createGrid(8,8,1));
|
||||
|
||||
// measurement
|
||||
var sphereGeometry = new THREE.SphereGeometry(0.05, 32, 32);
|
||||
var sphereMaterial = new THREE.MeshBasicMaterial({color: 0xbb0000, shading: THREE.FlatShading});
|
||||
spStart = new THREE.Mesh(sphereGeometry, sphereMaterial);
|
||||
spEnd = new THREE.Mesh(sphereGeometry, sphereMaterial);
|
||||
spStart.position.set(-2.2,1.9, 1.66);
|
||||
spEnd.position.set(0.02,2,2.64);
|
||||
scene.add(spStart);
|
||||
scene.add(spEnd);
|
||||
|
||||
var lc = new THREE.Color( 0xff0000 );
|
||||
var lineGeometry = new THREE.Geometry();
|
||||
lineGeometry.vertices.push(spStart.position.clone(), spEnd.position.clone());
|
||||
lineGeometry.colors.push(lc, lc, lc);
|
||||
var lineMaterial = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
|
||||
sConnection = new THREE.Line(lineGeometry, lineMaterial);
|
||||
scene.add(sConnection);
|
||||
|
||||
// controls
|
||||
camera.position.set(4,6,10);
|
||||
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
controls.target.set( 0, 3, 0 );
|
||||
camera.lookAt(controls.target);
|
||||
|
||||
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
||||
renderer.domElement.addEventListener( 'click', onClick, false );
|
||||
}
|
||||
|
||||
function onDocumentMouseMove( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
|
||||
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
|
||||
}
|
||||
|
||||
function render() {
|
||||
requestAnimationFrame(render);
|
||||
|
||||
camera.updateMatrixWorld(true);
|
||||
|
||||
controls.update(0.1);
|
||||
|
||||
vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
|
||||
projector.unprojectVector( vector, camera );
|
||||
raycaster.params = {"PointCloud" : {threshold: 0.1}};
|
||||
raycaster.ray.set( camera.position, vector.sub( camera.position ).normalize() );
|
||||
|
||||
scene.traverse( function ( object ) {
|
||||
if ( object instanceof Potree.PointCloudOctree ) {
|
||||
object.update( camera );
|
||||
}
|
||||
} );
|
||||
|
||||
if(placeStartMode || placeEndMode){
|
||||
var intersects = raycaster.intersectObject(pointcloud, true);
|
||||
|
||||
if(intersects.length > 0){
|
||||
var I = intersects[0];
|
||||
|
||||
if(placeStartMode){
|
||||
spStart.position.copy(I.point);
|
||||
}else if(placeEndMode){
|
||||
spEnd.position.copy(I.point);
|
||||
}
|
||||
sConnection.geometry.vertices[0].copy(spStart.position);
|
||||
sConnection.geometry.vertices[1].copy(spEnd.position);
|
||||
sConnection.geometry.verticesNeedUpdate = true;
|
||||
sConnection.geometry.computeBoundingSphere();
|
||||
}
|
||||
}
|
||||
|
||||
// placing distance label
|
||||
var labelPos = spStart.position.clone().add(spEnd.position).multiplyScalar(0.5);
|
||||
projector.projectVector(labelPos, camera);
|
||||
labelPos.x = (labelPos.x + 1)/2 * window.innerWidth;
|
||||
labelPos.y = -(labelPos.y - 1)/2 * window.innerHeight;
|
||||
|
||||
var distance = spStart.position.distanceTo(spEnd.position);
|
||||
var lblDistance = document.getElementById("lblDistance");
|
||||
lblDistance.style.left = labelPos.x;
|
||||
lblDistance.style.top = labelPos.y;
|
||||
lblDistance.innerHTML = distance.toFixed(2);
|
||||
|
||||
var numVisibleNodes = pointcloud.numVisibleNodes;
|
||||
var numVisiblePoints = pointcloud.numVisiblePoints;
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(numVisiblePoints);
|
||||
|
||||
// render skybox
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
|
||||
renderer.render(scene, camera);
|
||||
};
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
render();
|
||||
|
||||
function placeStart(){
|
||||
placeStartMode = true;
|
||||
placeEndMode = false;
|
||||
}
|
||||
|
||||
function placeEnd(){
|
||||
placeStartMode = false;
|
||||
placeEndMode = true;
|
||||
}
|
||||
|
||||
function onClick(){
|
||||
placeStartMode = false;
|
||||
placeEndMode = false;
|
||||
|
||||
console.log(spStart.position);
|
||||
console.log(spEnd.position);
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,400 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="http://openlayers.org/en/v3.0.0/css/ol.css" type="text/css">
|
||||
<style>
|
||||
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.map {
|
||||
position: absolute;
|
||||
height: 300px;
|
||||
width: 400px;
|
||||
right: 5px;
|
||||
bottom: 5px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#renderArea{
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.info{
|
||||
position: absolute;
|
||||
z-index: 2000;
|
||||
color:white;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px black,
|
||||
1px -1px 1px black,
|
||||
-1px 1px 1px black,
|
||||
-1px -1px 1px black;
|
||||
}
|
||||
|
||||
a:hover, a:visited, a:link, a:active{
|
||||
color: #ccccff;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<script src="http://openlayers.org/en/v3.0.0/build/ol.js" type="text/javascript"></script>
|
||||
|
||||
<script src="../libs/three.js/build/three.js"></script>
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
<script src="../libs/proj4/proj4.js"></script>
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
|
||||
<title>Georeferencing Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" class="map"></div>
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
|
||||
Georeferencing (sync with OpenLayers3) and Measurement.<br>
|
||||
Double click to generate measurement points. Measurement points will be displayed
|
||||
in the point cloud as well as the OpenStreetMap window.
|
||||
|
||||
<br><br>
|
||||
Point cloud courtesy of <a href="http://www.sigeom.ch/" target="_blank">sigeom sa</a><br>
|
||||
Rue des Oeuches 45<br>
|
||||
2740 Moutier<br>
|
||||
Switzerland <br>
|
||||
|
||||
<br>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/vol_total/cloud.js";
|
||||
var defaultPointSize = 4;
|
||||
var defaultLOD = 17;
|
||||
|
||||
// add EPSG:21781 to the proj4 projection database
|
||||
proj4.defs('EPSG:21781', "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs ");
|
||||
var fromSwiss = proj4.defs("EPSG:21781");
|
||||
var toWGS84 = proj4.defs("WGS84");
|
||||
|
||||
// extent (with altitude) in EPSG:21781 / Swiss Coordinate System
|
||||
var minSwiss = [584757.154, 230878.747, 662.379];
|
||||
var maxSwiss = [593758.872, 232521.598, 850.323];
|
||||
|
||||
// extent in EPSG:4326 / WGS84 World Geodetic System
|
||||
var minExtent = proj4(proj4.defs("EPSG:21781"), proj4.defs("WGS84"), [minSwiss[0], minSwiss[1]]);
|
||||
var maxExtent = proj4(proj4.defs("EPSG:21781"), proj4.defs("WGS84"), [maxSwiss[0], maxSwiss[1]]);
|
||||
|
||||
// extent in EPSG:3857 / WGS84 Web Mercator
|
||||
var minT = ol.proj.transform(minExtent, 'EPSG:4326', 'EPSG:3857');
|
||||
var maxT = ol.proj.transform(maxExtent, 'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
// the offset of the point cloud in EPSG:21781 coordinate system to local scene coordinates.
|
||||
// subtract this offset in order to move from local scene coordinates (obtained from picking, etc.)
|
||||
// to EPSG:21781 coordinates
|
||||
var offset = new THREE.Vector3();
|
||||
|
||||
|
||||
// OpenLayers3 stuff
|
||||
var featureVector;
|
||||
var camFrustumFeatureVector;
|
||||
var camFrustum;
|
||||
|
||||
// three.js / potree stuff
|
||||
var renderer;
|
||||
var scene;
|
||||
var camera;
|
||||
var skybox;
|
||||
var materials = {};
|
||||
var clock = new THREE.Clock();
|
||||
var measuringTool;
|
||||
|
||||
function initMapView(){
|
||||
|
||||
var extent = [minT[0], minT[1], maxT[0], maxT[1]];
|
||||
var center = [(maxT[0] + minT[0]) / 2, (maxT[1] + minT[1]) / 2];
|
||||
|
||||
// draw the extent as box inside the map view
|
||||
var box = new ol.geom.LineString([
|
||||
minT, [maxT[0], minT[1]], maxT, [minT[0], maxT[1]], minT
|
||||
]);
|
||||
|
||||
var feature = new ol.Feature(box);
|
||||
featureVector = new ol.source.Vector({
|
||||
features: [feature]
|
||||
});
|
||||
|
||||
var layer = new ol.layer.Vector({
|
||||
source: featureVector,
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#ff0000',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 3,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#0000ff'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
camFrustumFeatureVector = new ol.source.Vector({
|
||||
features: []
|
||||
});
|
||||
|
||||
var camFrustumLayer = new ol.layer.Vector({
|
||||
source: camFrustumFeatureVector,
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#ff0000',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 3,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#ff0000'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
// create the map
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}).extend([
|
||||
new ol.control.ZoomToExtent({
|
||||
extent: extent,
|
||||
closest: true
|
||||
})
|
||||
]),
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
}),
|
||||
layer,
|
||||
camFrustumLayer
|
||||
],
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
center: center,
|
||||
zoom: 12
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function initPotreeView(){
|
||||
var renderArea = document.getElementById("renderArea");
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
var fov = 60;
|
||||
|
||||
var aspect = renderArea.clientWidth / renderArea.clientHeight;
|
||||
scene = new THREE.Scene();
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(renderArea.clientWidth, renderArea.clientHeight);
|
||||
renderer.autoClear = false;
|
||||
renderArea.appendChild(renderer.domElement);
|
||||
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
camera.position.set(500, 200, -300);
|
||||
controls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
camera.rotation.order = 'ZYX';
|
||||
camera.rotation.x = -0.5;
|
||||
camera.rotation.y = -5*Math.PI/4;
|
||||
controls.moveSpeed *= 10;
|
||||
|
||||
materials.rgb = new Potree.PointCloudRGBMaterial({ size: defaultPointSize});
|
||||
materials.rgbInterpolated = new Potree.PointCloudRGBInterpolationMaterial({ size: defaultPointSize});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 0, max: 60});
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
||||
offset = pco.offset;
|
||||
pointcloud = new Potree.PointCloudOctree(pco, materials.rgb);
|
||||
pointcloud.LOD = defaultLOD;
|
||||
pointcloud.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,0,1,0,
|
||||
0,-1,0,0,
|
||||
0,0,0,1
|
||||
));
|
||||
scene.add(pointcloud);
|
||||
|
||||
measuringTool = new Potree.MeasuringTool(scene, camera, renderer.domElement);
|
||||
|
||||
// execute this event whenever a new measurement point has been set
|
||||
measuringTool.addEventListener("newpoint", function(event){
|
||||
// transform from local scene to swiss projection.
|
||||
var point = new THREE.Vector3(event.position.x, -event.position.z, event.position.y);
|
||||
point = point.sub(offset);
|
||||
|
||||
// transform from swiss projection to WGS84
|
||||
var fromSwiss = proj4.defs("EPSG:21781");
|
||||
var toWGS84 = proj4.defs("WGS84");
|
||||
var coordinate = proj4(fromSwiss, toWGS84, [point.x, point.y]);
|
||||
|
||||
// transform from WGS84 to Web Mercator
|
||||
coordinate = ol.proj.transform(coordinate, 'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
// add a point to the OpenLayers map
|
||||
var olPoint = new ol.geom.Point(coordinate);
|
||||
var feature = new ol.Feature(olPoint);
|
||||
featureVector.addFeature(feature);
|
||||
});
|
||||
}
|
||||
|
||||
function initGUI(){
|
||||
|
||||
// dat.gui
|
||||
var gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
LOD: defaultLOD,
|
||||
"show octree" : false,
|
||||
"Materials" : materials.rgb
|
||||
};
|
||||
|
||||
var pLOD = gui.add(params, 'LOD', 0.5,20);
|
||||
pLOD.onChange(function(value){
|
||||
pointcloud.LOD = value;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 6.0);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloud.material.size = value;
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "RGB High Quality", "Height" ]);
|
||||
pMaterial.onChange(function(value){
|
||||
var size = pointcloud.material.size;
|
||||
if(value === "RGB"){
|
||||
pointcloud.material = materials.rgb;
|
||||
}else if(value === "RGB High Quality"){
|
||||
var frag_depth_ext = renderer.context.getExtension('EXT_frag_depth');
|
||||
if(!frag_depth_ext){
|
||||
var message = "failed to load EXT_frag_depth. This extension is required for the high quality shader.\n";
|
||||
message += "using standard RGB material instead";
|
||||
alert(message);
|
||||
pointcloud.material = materials.rgb;
|
||||
}else{
|
||||
pointcloud.material = materials.rgbInterpolated;
|
||||
}
|
||||
|
||||
}else if(value === "Height"){
|
||||
pointcloud.material = materials.height;
|
||||
}
|
||||
|
||||
pointcloud.material.size = size;
|
||||
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'show octree');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
});
|
||||
}
|
||||
|
||||
function update(){
|
||||
controls.update(clock.getDelta());
|
||||
pointcloud.update(camera);
|
||||
|
||||
if(camFrustum === undefined){
|
||||
camFrustum = new ol.geom.LineString([ [0,0], [0, 0] ]);
|
||||
var feature = new ol.Feature(camFrustum);
|
||||
camFrustumFeatureVector.addFeature(feature);
|
||||
}
|
||||
|
||||
|
||||
var aspect = camera.aspect;
|
||||
var top = Math.tan( THREE.Math.degToRad( camera.fov * 0.5 ) ) * camera.near;
|
||||
var bottom = - top;
|
||||
var left = aspect * bottom;
|
||||
var right = aspect * top;
|
||||
|
||||
var camPos = new THREE.Vector3(0, 0, 0);
|
||||
left = new THREE.Vector3(left, 0, -camera.near).multiplyScalar(3000);
|
||||
right = new THREE.Vector3(right, 0, -camera.near).multiplyScalar(3000);
|
||||
camPos.applyMatrix4(camera.matrixWorld);
|
||||
left.applyMatrix4(camera.matrixWorld);
|
||||
right.applyMatrix4(camera.matrixWorld);
|
||||
|
||||
|
||||
// transform from local scene to swiss projection.
|
||||
camPos = new THREE.Vector3(camPos.x, -camPos.z, camPos.y).sub(offset);
|
||||
left = new THREE.Vector3(left.x, -left.z, left.y).sub(offset);
|
||||
right = new THREE.Vector3(right.x, -right.z, right.y).sub(offset);
|
||||
|
||||
camPos = proj4(fromSwiss, toWGS84, [camPos.x, camPos.y]);
|
||||
left = proj4(fromSwiss, toWGS84, [left.x, left.y]);
|
||||
right = proj4(fromSwiss, toWGS84, [right.x, right.y]);
|
||||
|
||||
camPos = ol.proj.transform(camPos, 'EPSG:4326', 'EPSG:3857');
|
||||
left = ol.proj.transform(left, 'EPSG:4326', 'EPSG:3857');
|
||||
right = ol.proj.transform(right, 'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
camFrustum.setCoordinates([camPos, left, right, camPos]);
|
||||
}
|
||||
|
||||
function render(){
|
||||
// resize
|
||||
var renderArea = document.getElementById("renderArea");
|
||||
var width = renderArea.clientWidth;
|
||||
var height = renderArea.clientHeight;
|
||||
|
||||
renderer.setSize(width, height-10);
|
||||
camera.aspect = width / height;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
// render skybox
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
|
||||
// render scenes
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(measuringTool.sceneMeasurement, camera);
|
||||
|
||||
}
|
||||
|
||||
function loop(){
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
}
|
||||
|
||||
initMapView();
|
||||
initPotreeView();
|
||||
initGUI();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
833
examples/georeferencing_measurement_heightprofile.html
Normal file
833
examples/georeferencing_measurement_heightprofile.html
Normal file
@ -0,0 +1,833 @@
|
||||
<html lang="en">
|
||||
<!--
|
||||
|
||||
used projections:
|
||||
- EPSG:21781 / Swiss
|
||||
- EPSG:3857 / WebMercator
|
||||
- Local Scene Coordinates
|
||||
|
||||
This demo shows how to handle georeferenced point clouds and how to use the measure and profile tools.
|
||||
|
||||
|
||||
|
||||
== Georeferencing ==
|
||||
|
||||
Georeferenced point clouds tend to have very large coordinates values which float values can't handle.
|
||||
In order to maximize the available precision, the point cloud must be moved towards the origin.
|
||||
Another problem is that georeferenced coordinates often use
|
||||
x for easting, y for northing and z for the elevation / height.
|
||||
Potree on the other hand uses
|
||||
x for easting, -z for northing and y for elevation / height;
|
||||
A reference frame is used in order to move the point cloud to the origin and flip y and -z.
|
||||
|
||||
referenceFrame = new THREE.Object3D();
|
||||
referenceFrame.position.set(-pointcloud.position.x, -pointcloud.position.y, 0);
|
||||
referenceFrame.updateMatrix();
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,0,1,0,
|
||||
0,-1,0,0,
|
||||
0,0,0,1
|
||||
));
|
||||
|
||||
The transformations are automatically applied to the point cloud by attaching it to the referenceFrame.
|
||||
|
||||
referenceFrame.add(pointcloud);
|
||||
|
||||
The point cloud is now in a local scene coordinate system and all the tools like
|
||||
measuring and height profile will return local scene coordinates.
|
||||
In order to transform from local scene coordinates back to the geo coordinates,
|
||||
you can use the helper function toGeo(THREE.Vector3 coordinate);
|
||||
|
||||
Coordinates in the OpenLayers window are given in the Web Mercator projection.
|
||||
To sync the map window with the scene, the coordinates must be transformed from Web Mercator to
|
||||
the projection of the point cloud and then to scene coordinates.
|
||||
Transforming from Web Mercator to Swiss can be done with proj4js
|
||||
|
||||
var swissCoordinate = proj4(webMercator, swiss, webMercatorCoordinate);
|
||||
|
||||
Note that proj4js uses an array with 2 elements while toGeo and toLocal uses THREE.Vector3 instances.
|
||||
To transform the swissCoordinates to local coordinates, use
|
||||
|
||||
var sceneCoordinate = toLocal(new THREE.Vector3(swissCoordinate[0], swissCoordinate[1], 0));
|
||||
|
||||
|
||||
|
||||
== Profile ==
|
||||
|
||||
There are 2 ways to get a height profile:
|
||||
- ProfileTool: renders points inside the profile area into a texture.
|
||||
- pointcloud.getProfile(): Returns points inside the profile area
|
||||
|
||||
In this demo, both are used side by side. The ProfileTool is very fast and can be used as a
|
||||
preview to the result of the getProfile() function.
|
||||
The depth parameter specifies the detail level of the result.
|
||||
Especially with higher depth values, it is likely that not all the octree nodes necessary
|
||||
for the calculation have been loaded, yet which is why you can provide a callback function
|
||||
that is called once all the necessary nodes have been loaded and the point profile has been calculated.
|
||||
If you call getProfile without a callback, it will ignore unloaded nodes and immediately return
|
||||
a result.
|
||||
|
||||
|
||||
== GeoExtent ==
|
||||
|
||||
You can get the boundaries of the currently visible parts using pointcloud.getVisibleExtent()
|
||||
The updateMapExtent() shows how this can be used to visualize the boundaries in the map view.
|
||||
|
||||
|
||||
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel="stylesheet" href="http://openlayers.org/en/v3.0.0/css/ol.css" type="text/css">
|
||||
<title>Georeferencing Example</title>
|
||||
<style>canvas { width: 100%; height: 100% }</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" class="map"></div>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#renderArea{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.map {
|
||||
position: absolute;
|
||||
height: 300px;
|
||||
width: 400px;
|
||||
right: 5px;
|
||||
bottom: 5px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.info{
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px black,
|
||||
1px -1px 1px black,
|
||||
-1px 1px 1px black,
|
||||
-1px -1px 1px black;
|
||||
}
|
||||
|
||||
a:hover, a:visited, a:link, a:active{
|
||||
color: #ccccff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script src="http://openlayers.org/en/v3.0.0/build/ol.js" type="text/javascript"></script>
|
||||
|
||||
<script src="../libs/three.js/build/three.js"></script>
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
<script src="../libs/proj4/proj4.js"></script>
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="js/ProgressBar.js"></script>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="lblCoordinates" class="info" style="position: absolute; left: 5px; bottom: 10px">
|
||||
test
|
||||
</div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
Point cloud courtesy of <a href="http://www.sigeom.ch/" target="_blank">sigeom sa</a><br>
|
||||
<br>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 5px; top: 20px">
|
||||
Georeferencing, Height Profile and Measurement.<br>
|
||||
Double click to generate measurement points. <br>
|
||||
Drag endpoints of red line in map window to modify the profile. <br>
|
||||
Check "coordinates" to display mouse hover coordinates on the bottom left.<br>
|
||||
Push the <input type="button" value="Height Profile" onclick="doHeightProfile()"/> button to create some spheres along the profile<br>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="renderArea"></div>
|
||||
<script type="text/javascript">
|
||||
var pointSize = 20;
|
||||
var pointCountTarget = 1;
|
||||
var opacity = 1;
|
||||
var pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
var pointColorType = Potree.PointColorType.RGB;
|
||||
var pointShape = Potree.PointShape.SQUARE;
|
||||
var interpolate = false;
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/vol_total/cloud.js";
|
||||
|
||||
// add EPSG:21781 to the proj4 projection database
|
||||
proj4.defs('EPSG:21781', "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs ");
|
||||
var swiss = proj4.defs("EPSG:21781");
|
||||
var WGS84 = proj4.defs("WGS84");
|
||||
var webMercator = proj4.defs("EPSG:3857");
|
||||
|
||||
// extent of the point cloud (with altitude) in EPSG:21781 / Swiss Coordinate System
|
||||
var minSwiss = [589500, 231300, 722.505];
|
||||
var maxSwiss = [590099, 231565.743, 776.459];
|
||||
|
||||
// extent in EPSG:3857 / WGS84 Web Mercator
|
||||
var minWeb = proj4(swiss, webMercator, [minSwiss[0], minSwiss[1]]);
|
||||
var maxWeb = proj4(swiss, webMercator, [maxSwiss[0], maxSwiss[1]]);
|
||||
|
||||
// default values for start and end of profile in Web Mercator
|
||||
var profileStart = proj4(swiss, webMercator, [589468, 231313]);
|
||||
var profileEnd = proj4(swiss, webMercator, [590134, 231328]);
|
||||
|
||||
// bounds of the EPSG:21781 projection
|
||||
//var swissMin = new THREE.Vector3(485869.5728, 76443.1884, 0);
|
||||
//var swissMax = new THREE.Vector3(837076.5648, 299941.7864, 0);
|
||||
|
||||
// OpenLayers3 stuff
|
||||
var featureVector;
|
||||
var camFrustumFeatureVector;
|
||||
var camFrustum;
|
||||
var profileOverlay;
|
||||
var visibleBounds;
|
||||
|
||||
// three.js / potree stuff
|
||||
var renderer;
|
||||
var scene, sceneHUD;
|
||||
var referenceFrame;
|
||||
var camera, cameraHUD;
|
||||
var skybox;
|
||||
var pointcloud;
|
||||
var clock = new THREE.Clock();
|
||||
var measuringTool;
|
||||
var profileTool;
|
||||
var showCoordinates = false;
|
||||
var mouse = {x: 0, y: 0};
|
||||
var elCoordinates = document.getElementById("lblCoordinates");
|
||||
var showSkybox = true;
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
// create a OpenLayers Map View
|
||||
function initMapView(){
|
||||
|
||||
{ // pointcloud extent layer
|
||||
var extent = [minWeb[0], minWeb[1], maxWeb[0], maxWeb[1]];
|
||||
var center = [(maxWeb[0] + minWeb[0]) / 2, (maxWeb[1] + minWeb[1]) / 2];
|
||||
|
||||
// draw the extent as box inside the map view
|
||||
var box = new ol.geom.LineString([
|
||||
minWeb, [maxWeb[0], minWeb[1]], maxWeb, [minWeb[0], maxWeb[1]], minWeb
|
||||
]);
|
||||
|
||||
|
||||
var feature = new ol.Feature(box);
|
||||
|
||||
featureVector = new ol.source.Vector({
|
||||
features: [feature]
|
||||
});
|
||||
|
||||
var extentLayer = new ol.layer.Vector({
|
||||
source: featureVector,
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#000000',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 3,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#000000'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
{ // visible bounds layer
|
||||
visibleBounds = new ol.geom.LineString([
|
||||
minWeb, [maxWeb[0], minWeb[1]], maxWeb, [minWeb[0], maxWeb[1]], minWeb
|
||||
]);
|
||||
var visibleBoundsFeature = new ol.Feature(visibleBounds);
|
||||
|
||||
var visibleBoundsLayer = new ol.layer.Vector({
|
||||
source: featureVector,
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#0000ff',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 3,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#0000ff'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
{ // cam frustum layer
|
||||
camFrustumFeatureVector = new ol.source.Vector({
|
||||
features: []
|
||||
});
|
||||
|
||||
var camFrustumLayer = new ol.layer.Vector({
|
||||
source: camFrustumFeatureVector,
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#000000',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 3,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#000000'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// create the map
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}).extend([
|
||||
new ol.control.ZoomToExtent({
|
||||
extent: extent,
|
||||
closest: true
|
||||
})
|
||||
]),
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
}),
|
||||
extentLayer,
|
||||
visibleBoundsLayer,
|
||||
camFrustumLayer
|
||||
],
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
center: center,
|
||||
zoom: 15
|
||||
})
|
||||
});
|
||||
|
||||
{// profile layer
|
||||
profileOverlay = new ol.FeatureOverlay({
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#ff0000',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 7,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#ff0000'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
profileOverlay.setMap(map);
|
||||
|
||||
var profile = new ol.geom.LineString([profileStart, profileEnd]);
|
||||
var profileFeature = new ol.Feature(profile);
|
||||
profileOverlay.addFeature(profileFeature);
|
||||
|
||||
// enable drag modification of the profile line
|
||||
var modify = new ol.interaction.Modify({
|
||||
features: profileOverlay.getFeatures(),
|
||||
});
|
||||
map.addInteraction(modify);
|
||||
}
|
||||
}
|
||||
|
||||
function initPotreeView(){
|
||||
var near = 0.1;
|
||||
var far = 1000000;
|
||||
var fov = 60;
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
// scenes
|
||||
scene = new THREE.Scene();
|
||||
sceneHUD = new THREE.Scene();
|
||||
|
||||
// renderer
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(width, height);
|
||||
renderer.autoClear = false;
|
||||
elRenderArea.appendChild(renderer.domElement);
|
||||
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
// cameras and controls
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
cameraHUD = new THREE.OrthographicCamera( -1, 1, 1, -1, -100, 1000 );
|
||||
controls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
camera.rotation.order = 'ZYX';
|
||||
controls.moveSpeed *= 10;
|
||||
camera.position.set(600, 880, -370);
|
||||
camera.lookAt(new THREE.Vector3(480, 797, -219));
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, function(geometry){
|
||||
offset = geometry.offset;
|
||||
pointcloud = new Potree.PointCloudOctree(geometry, new Potree.PointCloudMaterial());
|
||||
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
|
||||
// the reference frame transforms the point cloud into the scene coordinate system
|
||||
// by moving it towards the origin and flipping the y and z axes.
|
||||
// This is necessary to avoid precision errors due to large floating point values.
|
||||
referenceFrame = new THREE.Object3D();
|
||||
referenceFrame.position.set(-pointcloud.position.x, -pointcloud.position.y, 0);
|
||||
referenceFrame.updateMatrix();
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,0,1,0,
|
||||
0,-1,0,0,
|
||||
0,0,0,1
|
||||
));
|
||||
scene.add(referenceFrame);
|
||||
referenceFrame.add(pointcloud);
|
||||
referenceFrame.updateMatrixWorld();
|
||||
});
|
||||
|
||||
// create measuring tool
|
||||
measuringTool = new Potree.MeasuringTool(scene, camera, renderer);
|
||||
measuringTool.addEventListener("newpoint", function(event){
|
||||
point = toGeo(event.position);
|
||||
|
||||
// transform from swiss projection to Web Mercator
|
||||
var swiss = proj4.defs("EPSG:21781");
|
||||
var WGS84 = proj4.defs("WGS84");
|
||||
var coordinate = proj4(swiss, webMercator, [point.x, point.y]);
|
||||
|
||||
// add a point to the OpenLayers map
|
||||
var olPoint = new ol.geom.Point(coordinate);
|
||||
var feature = new ol.Feature(olPoint);
|
||||
featureVector.addFeature(feature);
|
||||
});
|
||||
|
||||
// create profile tool
|
||||
profileTool = new Potree.ProfileTool(400, 200, 10);
|
||||
profileTool.position.set(0,0,0);
|
||||
scene.add(profileTool);
|
||||
sceneHUD.add(profileTool.hudElement);
|
||||
profileTool.setCoordinates(
|
||||
new THREE.Vector3(-32, 750, -13),
|
||||
new THREE.Vector3(634, 750, -28));
|
||||
|
||||
renderer.domElement.addEventListener( 'mousemove', onMouseMove, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* transform from geo coordinates to local scene coordinates
|
||||
*/
|
||||
function toLocal(position){
|
||||
var scenePos = position.clone().applyMatrix4(referenceFrame.matrixWorld);
|
||||
return scenePos;
|
||||
}
|
||||
|
||||
/**
|
||||
* transform from local scene coordinates to geo coordinates
|
||||
*/
|
||||
function toGeo(object){
|
||||
var geo;
|
||||
var inverse = new THREE.Matrix4().getInverse(referenceFrame.matrixWorld);
|
||||
|
||||
if(object instanceof THREE.Vector3){
|
||||
geo = object.clone().applyMatrix4(inverse);
|
||||
}else if(object instanceof THREE.Box3){
|
||||
var geoMin = object.min.clone().applyMatrix4(inverse);
|
||||
var geoMax = object.max.clone().applyMatrix4(inverse);
|
||||
geo = new THREE.Box3(geoMin, geoMax);
|
||||
}
|
||||
|
||||
return geo;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a dat.GUI widget that lets the user modify certain values
|
||||
*/
|
||||
function initGUI(){
|
||||
var gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": 1.0,
|
||||
"SizeType" : "Adaptive",
|
||||
"show octree" : false,
|
||||
"Materials" : "RGB",
|
||||
"interpolate": false,
|
||||
"circles": false,
|
||||
"coordinates": showCoordinates,
|
||||
"skybox": true
|
||||
};
|
||||
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 1);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value ;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0, 50);
|
||||
pPointSize.onChange(function(value){
|
||||
pointSize = value;
|
||||
});
|
||||
|
||||
var pOpacity = gui.add(params, 'opacity', 0, 1);
|
||||
pOpacity.onChange(function(value){
|
||||
opacity = value;
|
||||
});
|
||||
|
||||
var pSizeType = gui.add(params, 'SizeType', [ "Fixed", "Attenuated", "Adaptive"]);
|
||||
pSizeType.onChange(function(value){
|
||||
if(value === "Fixed"){
|
||||
pointSizeType = Potree.PointSizeType.FIXED;
|
||||
}else if(value === "Attenuated"){
|
||||
pointSizeType = Potree.PointSizeType.ATTENUATED;
|
||||
}else if(value === "Adaptive"){
|
||||
pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
}
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Octree Depth"]);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
}else if(value === "Color"){
|
||||
pointColorType = Potree.PointColorType.COLOR;
|
||||
}else if(value === "Height"){
|
||||
pointColorType = Potree.PointColorType.HEIGHT;
|
||||
}else if(value === "Octree Depth"){
|
||||
pointColorType = Potree.PointColorType.OCTREE_DEPTH;
|
||||
}else if(value === "Point Index"){
|
||||
pointColorType = Potree.PointColorType.POINT_INDEX;
|
||||
}
|
||||
});
|
||||
|
||||
if(renderer.context.getExtension("EXT_frag_depth")){
|
||||
var pInterpolate = gui.add(params, 'interpolate');
|
||||
pInterpolate.onChange(function(value){
|
||||
interpolate = value;
|
||||
});
|
||||
}
|
||||
|
||||
var pCircular = gui.add(params, 'circles');
|
||||
pCircular.onChange(function(value){
|
||||
if(value){
|
||||
pointShape = Potree.PointShape.CIRCLE;
|
||||
}else{
|
||||
pointShape = Potree.PointShape.SQUARE;
|
||||
}
|
||||
});
|
||||
|
||||
var pCoordinates = gui.add(params, 'coordinates');
|
||||
pCoordinates.onChange(function(value){
|
||||
showCoordinates = value;
|
||||
});
|
||||
|
||||
var pSykbox = gui.add(params, 'skybox');
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
});
|
||||
}
|
||||
|
||||
function update(){
|
||||
controls.update(clock.getDelta());
|
||||
|
||||
if(pointcloud){
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointShape = pointShape;
|
||||
pointcloud.material.interpolate = interpolate;
|
||||
pointcloud.material.heightMin = 710;
|
||||
pointcloud.material.heightMax = 770;
|
||||
|
||||
pointcloud.update(camera);
|
||||
updateMapFrustum();
|
||||
updateCoordinatePicking();
|
||||
updateProfile();
|
||||
updateMapExtent();
|
||||
updateProgressBar();
|
||||
}
|
||||
}
|
||||
|
||||
function updateProgressBar(){
|
||||
if(pointcloud){
|
||||
var progress = pointcloud.visibleNodes.length / pointcloud.visibleGeometry.length;
|
||||
|
||||
progressBar.progress = progress;
|
||||
progressBar.message = "loading: " + pointcloud.visibleNodes.length + " / " + pointcloud.visibleGeometry.length;
|
||||
|
||||
if(progress === 1){
|
||||
progressBar.hide();
|
||||
}else if(progress < 1){
|
||||
progressBar.show();
|
||||
}
|
||||
}else{
|
||||
progressBar.show();
|
||||
progressBar.message = "loading metadata";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update the frustum in the map window according to the camera
|
||||
*/
|
||||
function updateMapFrustum(){
|
||||
if(camFrustum === undefined){
|
||||
camFrustum = new ol.geom.LineString([ [0,0], [0, 0] ]);
|
||||
var feature = new ol.Feature(camFrustum);
|
||||
camFrustumFeatureVector.addFeature(feature);
|
||||
}
|
||||
|
||||
var aspect = camera.aspect;
|
||||
var top = Math.tan( THREE.Math.degToRad( camera.fov * 0.5 ) ) * camera.near;
|
||||
var bottom = - top;
|
||||
var left = aspect * bottom;
|
||||
var right = aspect * top;
|
||||
|
||||
var camPos = new THREE.Vector3(0, 0, 0);
|
||||
left = new THREE.Vector3(left, 0, -camera.near).multiplyScalar(3000);
|
||||
right = new THREE.Vector3(right, 0, -camera.near).multiplyScalar(3000);
|
||||
camPos.applyMatrix4(camera.matrixWorld);
|
||||
left.applyMatrix4(camera.matrixWorld);
|
||||
right.applyMatrix4(camera.matrixWorld);
|
||||
|
||||
camPos = toGeo(camPos);
|
||||
left = toGeo(left);
|
||||
right = toGeo(right);
|
||||
|
||||
camPos = proj4(swiss, webMercator, [camPos.x, camPos.y]);
|
||||
left = proj4(swiss, webMercator, [left.x, left.y]);
|
||||
right = proj4(swiss, webMercator, [right.x, right.y]);
|
||||
|
||||
camFrustum.setCoordinates([camPos, left, right, camPos]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* update the coordinate display if the "coordinates" checkbox is checked
|
||||
*/
|
||||
function updateCoordinatePicking(){
|
||||
if(showCoordinates){
|
||||
|
||||
var I = getMousePointCloudIntersection();
|
||||
if(I){
|
||||
|
||||
var sceneCoordinates = I;
|
||||
var geoCoordinates = toGeo(sceneCoordinates);
|
||||
|
||||
var msg = "EPSG:21781: " + geoCoordinates.x.toFixed(2) + " / ";
|
||||
msg += geoCoordinates.y.toFixed(2) + " / ";
|
||||
msg += geoCoordinates.z.toFixed(2);
|
||||
msg += " - sceneCoordinates: " + sceneCoordinates.x.toFixed(2) + " / ";
|
||||
msg += sceneCoordinates.y.toFixed(2) + " / ";
|
||||
msg += sceneCoordinates.z.toFixed(2);
|
||||
|
||||
elCoordinates.innerHTML = msg;
|
||||
}
|
||||
}else{
|
||||
elCoordinates.innerHTML = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update the map extent in the map window
|
||||
*/
|
||||
function updateMapExtent(){
|
||||
var geoExtent = toGeo(pointcloud.getVisibleExtent());
|
||||
|
||||
geoMin = proj4(swiss, webMercator, [geoExtent.min.x, geoExtent.min.y]);
|
||||
geoMax = proj4(swiss, webMercator, [geoExtent.max.x, geoExtent.max.y]);
|
||||
|
||||
visibleBounds.setCoordinates([
|
||||
geoMin,
|
||||
[geoMax[0], geoMin[1]],
|
||||
geoMax,
|
||||
[geoMin[0], geoMax[1]],
|
||||
geoMin
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the ProfileTools start and end according to the users modification
|
||||
* in the map window
|
||||
*/
|
||||
function updateProfile(){
|
||||
var features = profileOverlay.getFeatures();
|
||||
if(features.getArray().length == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
var geometry = profileOverlay.getFeatures().getArray()[0].getGeometry();
|
||||
var coordinates = geometry.getCoordinates();
|
||||
|
||||
if(coordinates.length < 2){
|
||||
return;
|
||||
}
|
||||
|
||||
var start = new THREE.Vector3(coordinates[0][0], coordinates[0][1], 0);
|
||||
var end = new THREE.Vector3(coordinates[1][0], coordinates[1][1], 0);
|
||||
|
||||
var startSwiss = proj4(webMercator, swiss, [start.x, start.y]);
|
||||
var startScene = toLocal(new THREE.Vector3(startSwiss[0], startSwiss[1], 0));
|
||||
|
||||
var endSwiss = proj4(webMercator, swiss, [end.x, end.y]);
|
||||
var endScene = toLocal(new THREE.Vector3(endSwiss[0], endSwiss[1], 0));
|
||||
|
||||
startScene.y = 750;
|
||||
endScene.y = 750;
|
||||
|
||||
profileTool.setCoordinates(startScene, endScene);
|
||||
|
||||
}
|
||||
|
||||
function getMousePointCloudIntersection(){
|
||||
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
|
||||
vector.unproject(camera);
|
||||
var direction = vector.sub(camera.position).normalize();
|
||||
var ray = new THREE.Ray(camera.position, direction);
|
||||
|
||||
var pointClouds = [];
|
||||
scene.traverse(function(object){
|
||||
if(object instanceof Potree.PointCloudOctree){
|
||||
pointClouds.push(object);
|
||||
}
|
||||
});
|
||||
|
||||
var closestPoint = null;
|
||||
var closestPointDistance = null;
|
||||
|
||||
for(var i = 0; i < pointClouds.length; i++){
|
||||
var pointcloud = pointClouds[i];
|
||||
var point = pointcloud.pick(renderer, camera, ray, {accuracy: 0.5});
|
||||
|
||||
if(!point){
|
||||
continue;
|
||||
}
|
||||
|
||||
var distance = camera.position.distanceTo(point.position);
|
||||
|
||||
if(!closestPoint || distance < closestPointDistance){
|
||||
closestPoint = point;
|
||||
closestPointDistance = distance;
|
||||
}
|
||||
}
|
||||
|
||||
return closestPoint ? closestPoint.position : null;
|
||||
}
|
||||
|
||||
function render(){
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
|
||||
profileTool.hudElement.scale.x = 400 / width;
|
||||
profileTool.hudElement.scale.y = 300 / height;
|
||||
profileTool.hudElement.position.x = 1 - 405 / width;
|
||||
profileTool.hudElement.position.y = -1 + 905 / height;
|
||||
|
||||
// render skybox
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}
|
||||
|
||||
// render scenes
|
||||
profileTool.render(renderer, scene);
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(measuringTool.sceneMeasurement, camera);
|
||||
renderer.render(sceneHUD, cameraHUD);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Demonstrating the pointcloud.getProfile() method by creating spheres at some
|
||||
* of the points inside the profile.
|
||||
* The depth value specifies the density of the points.
|
||||
* This method is async and will call its callback once all the necessary
|
||||
* nodes have been loaded. If no callback is given, it will immediately
|
||||
* return an array of points and ignore nodes that have not been loaded, yet.
|
||||
*
|
||||
*/
|
||||
function doHeightProfile(){
|
||||
var start = profileTool.start;
|
||||
var end = profileTool.end;
|
||||
var width = 10;
|
||||
var depth = 4;
|
||||
|
||||
var callback = function(event){
|
||||
if(event.type === "finished"){
|
||||
var points = event.points;
|
||||
var sphereGeometry = new THREE.SphereGeometry(1, 5, 5);
|
||||
for(var i = 0; i < points.length; i += Math.ceil(points.length / 500)){
|
||||
var point = points[i];
|
||||
var sphere = new THREE.Mesh(sphereGeometry);
|
||||
sphere.position.copy(point);
|
||||
scene.add(sphere);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
pointcloud.getProfile(start, end, width, depth, callback);
|
||||
}
|
||||
|
||||
function onMouseMove(event){
|
||||
mouse.x = ( event.clientX / renderer.domElement.clientWidth ) * 2 - 1;
|
||||
mouse.y = - ( event.clientY / renderer.domElement.clientHeight ) * 2 + 1;
|
||||
};
|
||||
|
||||
function loop(){
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
}
|
||||
|
||||
initMapView();
|
||||
initPotreeView();
|
||||
initGUI();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
56
examples/js/ProgressBar.js
Normal file
56
examples/js/ProgressBar.js
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
|
||||
function ProgressBar(){
|
||||
this._progress = 0;
|
||||
this._message = "";
|
||||
|
||||
this.maxOpacity = 0.6;
|
||||
|
||||
this.element = document.createElement("div");
|
||||
this.element.innerHTML = "";
|
||||
this.element.style.position = "fixed";
|
||||
this.element.style.bottom = "20px";
|
||||
this.element.style.width = "200px";
|
||||
this.element.style.marginLeft = "-100px";
|
||||
this.element.style.left = "50%";
|
||||
this.element.style.borderRadius = "5px";
|
||||
this.element.style.border = "1px solid #727678";
|
||||
this.element.style.height = "16px";
|
||||
this.element.style.padding = "1px";
|
||||
// this.element.style.backgroundColor = "white";
|
||||
this.element.style.backgroundImage = "-webkit-linear-gradient(right, #f2f6f8 0%,#d8e1e7 50%,#b5c6d0 51%,#e0eff9 100%)";
|
||||
this.element.style.textAlign = "center";
|
||||
this.element.style.opacity = this.maxOpacity;
|
||||
|
||||
document.body.appendChild(this.element);
|
||||
};
|
||||
|
||||
ProgressBar.prototype.hide = function(){
|
||||
this.element.style.opacity = 0;
|
||||
this.element.style.transition = "all 0.2s ease";
|
||||
};
|
||||
|
||||
ProgressBar.prototype.show = function(){
|
||||
this.element.style.opacity = this.maxOpacity;
|
||||
this.element.style.transition = "all 0.2s ease";
|
||||
};
|
||||
|
||||
Object.defineProperty(ProgressBar.prototype, "progress", {
|
||||
get: function(){
|
||||
return this._progress;
|
||||
},
|
||||
set: function(value){
|
||||
this._progress = value;
|
||||
this.element.style.backgroundImage = "-webkit-linear-gradient(left, #f2f6f8 0%,#d8e1e7 " + (value * 100) + "%,#b5c6d0 " + (value * 100 + 1) + "%,#e0eff9 100%)";
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(ProgressBar.prototype, "message", {
|
||||
get: function(){
|
||||
return this._message;
|
||||
},
|
||||
set: function(message){
|
||||
this._message = message;
|
||||
this.element.innerHTML = message;
|
||||
}
|
||||
});
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Lion</title>
|
||||
<style>canvas { width: 100%; height: 100% }</style>
|
||||
</head>
|
||||
@ -9,8 +8,13 @@
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
#renderArea{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.info{
|
||||
color:white;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px black,
|
||||
1px -1px 1px black,
|
||||
@ -31,22 +35,32 @@
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="js/ProgressBar.js"></script>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
||||
<div id="lblNumVisiblePoints" class="info" style="position: absolute; left: 10px; top: 100px; width: 400px; color:white"></div>
|
||||
<div id="lblMessage" class="info" style="position: absolute; left: 10px; bottom: 0px; width: 400px; color:white"></div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
<br>
|
||||
The RGB High Quality shader interpolates between points, rather than rendering the nearest one.
|
||||
|
||||
</div>
|
||||
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
var defaultPointSize = 0.07;
|
||||
var defaultBlendDepth = 0.01;
|
||||
var defaultLOD = 15;
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud_bin.js";
|
||||
var pointSize = 0.5;
|
||||
var pointCountTarget = 0.4;
|
||||
var opacity = 1;
|
||||
var pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
var pointColorType = Potree.PointColorType.RGB;
|
||||
var pointShape = Potree.PointShape.SQUARE;
|
||||
var interpolate = false;
|
||||
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud.js";
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
var renderer;
|
||||
var camera;
|
||||
@ -55,7 +69,7 @@
|
||||
var skybox;
|
||||
var stats;
|
||||
var clock = new THREE.Clock();
|
||||
var materials = {};
|
||||
var showSkybox = false;
|
||||
|
||||
function initGUI(){
|
||||
|
||||
@ -65,53 +79,78 @@
|
||||
});
|
||||
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
BlendDepth: defaultBlendDepth,
|
||||
LOD: defaultLOD,
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": opacity,
|
||||
"SizeType" : "Adaptive",
|
||||
"show octree" : false,
|
||||
"Materials" : materials.rgb
|
||||
"Materials" : "RGB",
|
||||
"interpolate": interpolate,
|
||||
"circles": false,
|
||||
"skybox": false
|
||||
};
|
||||
|
||||
var pLOD = gui.add(params, 'LOD', 0.5,20);
|
||||
pLOD.onChange(function(value){
|
||||
pointcloud.LOD = value;
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 0.5);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value ;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 0.2);
|
||||
var pPointSize = gui.add(params, 'PointSize', 0, 3);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloud.material.size = value;
|
||||
pointSize = value;
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "RGB High Quality", "Color", "Height" ]);
|
||||
pMaterial.onChange(function(value){
|
||||
var size = pointcloud.material.size;
|
||||
if(value === "RGB"){
|
||||
pointcloud.material = materials.rgb;
|
||||
}else if(value === "RGB High Quality"){
|
||||
var frag_depth_ext = renderer.context.getExtension('EXT_frag_depth');
|
||||
if(!frag_depth_ext){
|
||||
var message = "failed to load EXT_frag_depth. This extension is required for the high quality shader.\n";
|
||||
message += "using standard RGB material instead";
|
||||
alert(message);
|
||||
pointcloud.material = materials.rgb;
|
||||
}else{
|
||||
pointcloud.material = materials.rgbInterpolated;
|
||||
}
|
||||
|
||||
}else if(value === "Color"){
|
||||
pointcloud.material = materials.color;
|
||||
}else if(value === "Height"){
|
||||
pointcloud.material = materials.height;
|
||||
var pOpacity = gui.add(params, 'opacity', 0, 1);
|
||||
pOpacity.onChange(function(value){
|
||||
opacity = value;
|
||||
});
|
||||
|
||||
var pSizeType = gui.add(params, 'SizeType', [ "Fixed", "Attenuated", "Adaptive"]);
|
||||
pSizeType.onChange(function(value){
|
||||
if(value === "Fixed"){
|
||||
pointSizeType = Potree.PointSizeType.FIXED;
|
||||
}else if(value === "Attenuated"){
|
||||
pointSizeType = Potree.PointSizeType.ATTENUATED;
|
||||
}else if(value === "Adaptive"){
|
||||
pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
}
|
||||
|
||||
pointcloud.material.size = size;
|
||||
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'show octree');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Octree Depth"]);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
}else if(value === "Color"){
|
||||
pointColorType = Potree.PointColorType.COLOR;
|
||||
}else if(value === "Height"){
|
||||
pointColorType = Potree.PointColorType.HEIGHT;
|
||||
|
||||
}else if(value === "Octree Depth"){
|
||||
pointColorType = Potree.PointColorType.OCTREE_DEPTH;
|
||||
}else if(value === "Point Index"){
|
||||
pointColorType = Potree.PointColorType.POINT_INDEX;
|
||||
}
|
||||
});
|
||||
|
||||
if(renderer.context.getExtension("EXT_frag_depth")){
|
||||
var pInterpolate = gui.add(params, 'interpolate');
|
||||
pInterpolate.onChange(function(value){
|
||||
interpolate = value;
|
||||
});
|
||||
}
|
||||
|
||||
var pCircular = gui.add(params, 'circles');
|
||||
pCircular.onChange(function(value){
|
||||
if(value){
|
||||
pointShape = Potree.PointShape.CIRCLE;
|
||||
}else{
|
||||
pointShape = Potree.PointShape.SQUARE;
|
||||
}
|
||||
});
|
||||
|
||||
var pSykbox = gui.add(params, 'skybox');
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
});
|
||||
|
||||
// stats
|
||||
@ -123,13 +162,20 @@
|
||||
}
|
||||
|
||||
function initThree(){
|
||||
var fov = 75;
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 100000);
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
renderer.setSize(width, height);
|
||||
renderer.autoClear = false;
|
||||
document.body.appendChild(renderer.domElement);
|
||||
elRenderArea.appendChild(renderer.domElement);
|
||||
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
@ -138,50 +184,101 @@
|
||||
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
controls.target.set( 0, 5, 0 );
|
||||
camera.lookAt(controls.target);
|
||||
|
||||
// materials
|
||||
materials.rgb = new Potree.PointCloudRGBMaterial({ size: defaultPointSize});
|
||||
materials.rgbInterpolated = new Potree.PointCloudRGBInterpolationMaterial({ size: defaultPointSize});
|
||||
materials.color = new Potree.PointCloudColorMaterial({size: defaultPointSize});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 2, max: 8});
|
||||
|
||||
// enable frag_depth extension for the interpolation shader, if available
|
||||
renderer.context.getExtension("EXT_frag_depth");
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
||||
|
||||
pointcloud = new Potree.PointCloudOctree(pco, materials.rgb);
|
||||
pointcloud.LOD = defaultLOD;
|
||||
pointcloud.rotation.set(Math.PI/2, 0.85* -Math.PI/2, -0.0);
|
||||
pointcloud.moveToOrigin();
|
||||
pointcloud.moveToGroundPlane();
|
||||
|
||||
scene.add(pointcloud);
|
||||
POCLoader.load(pointcloudPath, function(geometry){
|
||||
pointcloud = new Potree.PointCloudOctree(geometry);
|
||||
|
||||
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
|
||||
pointcloud.rotation.set(Math.PI/2, 0.85* -Math.PI/2, -0.0);
|
||||
pointcloud.moveToOrigin();
|
||||
pointcloud.moveToGroundPlane();
|
||||
|
||||
scene.add(pointcloud);
|
||||
});
|
||||
|
||||
var grid = Potree.utils.createGrid(5, 5, 2);
|
||||
scene.add(grid);
|
||||
}
|
||||
|
||||
function render() {
|
||||
requestAnimationFrame(render);
|
||||
function update(){
|
||||
if(pointcloud){
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointShape = pointShape;
|
||||
pointcloud.material.interpolate = interpolate;
|
||||
pointcloud.material.heightMin = 0;
|
||||
pointcloud.material.heightMax = 8;
|
||||
|
||||
pointcloud.update(camera);
|
||||
|
||||
pointcloud.update(camera);
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
stats.update();
|
||||
|
||||
controls.update(clock.getDelta());
|
||||
|
||||
// update progress bar
|
||||
if(pointcloud){
|
||||
var progress = pointcloud.visibleNodes.length / pointcloud.visibleGeometry.length;
|
||||
|
||||
progressBar.progress = progress;
|
||||
progressBar.message = "loading: " + pointcloud.visibleNodes.length + " / " + pointcloud.visibleGeometry.length;
|
||||
|
||||
if(progress === 1){
|
||||
progressBar.hide();
|
||||
}else if(progress < 1){
|
||||
progressBar.show();
|
||||
}
|
||||
}else{
|
||||
progressBar.show();
|
||||
progressBar.message = "loading metadata";
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
|
||||
|
||||
// render skybox
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
function loop() {
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
};
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
render();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Lion</title>
|
||||
<style>canvas { width: 100%; height: 100% }</style>
|
||||
</head>
|
||||
@ -9,8 +8,13 @@
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
#renderArea{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.info{
|
||||
color:white;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px black,
|
||||
1px -1px 1px black,
|
||||
@ -34,18 +38,32 @@
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="../build/js/laslaz.js"></script>
|
||||
|
||||
<script src="js/ProgressBar.js"></script>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
||||
<div id="lblNumVisiblePoints" class="info" style="position: absolute; left: 10px; top: 100px; width: 400px; color:white"></div>
|
||||
<div id="lblMessage" class="info" style="position: absolute; left: 10px; bottom: 0px; width: 400px; color:white"></div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
</div>
|
||||
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
var defaultPointSize = 0.09;
|
||||
var defaultLOD = 12;
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud_las.js";
|
||||
var pointSize = 0.5;
|
||||
var pointCountTarget = 0.4;
|
||||
var opacity = 1;
|
||||
var pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
var pointColorType = Potree.PointColorType.RGB;
|
||||
var pointShape = Potree.PointShape.SQUARE;
|
||||
var interpolate = false;
|
||||
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa_las/cloud.js";
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
var renderer;
|
||||
var camera;
|
||||
@ -54,7 +72,7 @@
|
||||
var skybox;
|
||||
var stats;
|
||||
var clock = new THREE.Clock();
|
||||
var materials = {};
|
||||
var showSkybox = false;
|
||||
|
||||
function initGUI(){
|
||||
|
||||
@ -64,43 +82,82 @@
|
||||
});
|
||||
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
LOD: defaultLOD,
|
||||
"show aabb" : false,
|
||||
"Materials" : materials.rgb
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": opacity,
|
||||
"SizeType" : "Adaptive",
|
||||
"show octree" : false,
|
||||
"Materials" : "RGB",
|
||||
"interpolate": interpolate,
|
||||
"circles": false,
|
||||
"skybox": false
|
||||
};
|
||||
|
||||
var pLOD = gui.add(params, 'LOD', 0.5,20);
|
||||
pLOD.onChange(function(value){
|
||||
pointcloud.LOD = value;
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 0.5);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 0.3);
|
||||
var pPointSize = gui.add(params, 'PointSize', 0, 3);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloud.material.size = value;
|
||||
pointSize = value;
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Intensity" ]);
|
||||
pMaterial.onChange(function(value){
|
||||
var size = pointcloud.material.size;
|
||||
if(value === "RGB"){
|
||||
pointcloud.material = materials.rgb;
|
||||
}else if(value === "Color"){
|
||||
pointcloud.material = materials.color;
|
||||
}else if(value === "Height"){
|
||||
pointcloud.material = materials.height;
|
||||
}else if(value === "Intensity"){
|
||||
pointcloud.material = materials.intensity;
|
||||
var pOpacity = gui.add(params, 'opacity', 0, 1);
|
||||
pOpacity.onChange(function(value){
|
||||
opacity = value;
|
||||
});
|
||||
|
||||
var pSizeType = gui.add(params, 'SizeType', [ "Fixed", "Attenuated", "Adaptive"]);
|
||||
pSizeType.onChange(function(value){
|
||||
if(value === "Fixed"){
|
||||
pointSizeType = Potree.PointSizeType.FIXED;
|
||||
}else if(value === "Attenuated"){
|
||||
pointSizeType = Potree.PointSizeType.ATTENUATED;
|
||||
}else if(value === "Adaptive"){
|
||||
pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
}
|
||||
|
||||
pointcloud.material.size = size;
|
||||
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'show aabb');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Intensity", "Intensity Gradient", "Octree Depth"]);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
}else if(value === "Color"){
|
||||
pointColorType = Potree.PointColorType.COLOR;
|
||||
}else if(value === "Height"){
|
||||
pointColorType = Potree.PointColorType.HEIGHT;
|
||||
|
||||
}else if(value === "Octree Depth"){
|
||||
pointColorType = Potree.PointColorType.OCTREE_DEPTH;
|
||||
}else if(value === "Point Index"){
|
||||
pointColorType = Potree.PointColorType.POINT_INDEX;
|
||||
}else if(value === "Intensity"){
|
||||
pointColorType = Potree.PointColorType.INTENSITY;
|
||||
}else if(value === "Intensity Gradient"){
|
||||
pointColorType = Potree.PointColorType.INTENSITY_GRADIENT;
|
||||
}
|
||||
});
|
||||
|
||||
if(renderer.context.getExtension("EXT_frag_depth")){
|
||||
var pInterpolate = gui.add(params, 'interpolate');
|
||||
pInterpolate.onChange(function(value){
|
||||
interpolate = value;
|
||||
});
|
||||
}
|
||||
|
||||
var pCircular = gui.add(params, 'circles');
|
||||
pCircular.onChange(function(value){
|
||||
if(value){
|
||||
pointShape = Potree.PointShape.CIRCLE;
|
||||
}else{
|
||||
pointShape = Potree.PointShape.SQUARE;
|
||||
}
|
||||
});
|
||||
|
||||
var pSykbox = gui.add(params, 'skybox');
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
});
|
||||
|
||||
// stats
|
||||
@ -112,65 +169,125 @@
|
||||
}
|
||||
|
||||
function initThree(){
|
||||
var fov = 75;
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 100000);
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
renderer.setSize(width, height);
|
||||
renderer.autoClear = false;
|
||||
document.body.appendChild(renderer.domElement);
|
||||
elRenderArea.appendChild(renderer.domElement);
|
||||
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
// camera and controls
|
||||
camera.position.set(2, 7, 7);
|
||||
camera.position.set(3, 7, 6);
|
||||
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
controls.target.set( 0, 4, 0 );
|
||||
controls.target.set( 0, 5, 0 );
|
||||
camera.lookAt(controls.target);
|
||||
|
||||
// materials
|
||||
materials.rgb = new Potree.PointCloudRGBMaterial({ size: defaultPointSize});
|
||||
materials.color = new Potree.PointCloudColorMaterial({size: defaultPointSize});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 0, max: 10});
|
||||
materials.intensity = new Potree.PointCloudIntensityMaterial({size: defaultPointSize, min: 0, max: 65535});
|
||||
// enable frag_depth extension for the interpolation shader, if available
|
||||
renderer.context.getExtension("EXT_frag_depth");
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
||||
|
||||
pointcloud = new Potree.PointCloudOctree(pco, materials.rgb);
|
||||
pointcloud.LOD = defaultLOD;
|
||||
pointcloud.rotation.set(Math.PI/2, 0.85* -Math.PI/2, -0.0);
|
||||
pointcloud.moveToOrigin();
|
||||
pointcloud.moveToGroundPlane();
|
||||
|
||||
scene.add(pointcloud);
|
||||
POCLoader.load(pointcloudPath, function(geometry){
|
||||
pointcloud = new Potree.PointCloudOctree(geometry);
|
||||
|
||||
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
|
||||
pointcloud.rotation.set(Math.PI/2, 0.85* -Math.PI/2, -0.0);
|
||||
pointcloud.moveToOrigin();
|
||||
pointcloud.moveToGroundPlane();
|
||||
|
||||
scene.add(pointcloud);
|
||||
});
|
||||
|
||||
var grid = Potree.utils.createGrid(5, 5, 2);
|
||||
scene.add(grid);
|
||||
}
|
||||
|
||||
function render() {
|
||||
requestAnimationFrame(render);
|
||||
function update(){
|
||||
if(pointcloud){
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointShape = pointShape;
|
||||
pointcloud.material.interpolate = interpolate;
|
||||
pointcloud.material.heightMin = 0;
|
||||
pointcloud.material.heightMax = 8;
|
||||
pointcloud.material.intensityMin = 0;
|
||||
pointcloud.material.intensityMax = 65000;
|
||||
|
||||
pointcloud.update(camera);
|
||||
|
||||
pointcloud.update(camera);
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
stats.update();
|
||||
|
||||
controls.update(clock.getDelta());
|
||||
|
||||
// update progress bar
|
||||
if(pointcloud){
|
||||
var progress = pointcloud.visibleNodes.length / pointcloud.visibleGeometry.length;
|
||||
|
||||
progressBar.progress = progress;
|
||||
progressBar.message = "loading: " + pointcloud.visibleNodes.length + " / " + pointcloud.visibleGeometry.length;
|
||||
|
||||
if(progress === 1){
|
||||
progressBar.hide();
|
||||
}else if(progress < 1){
|
||||
progressBar.show();
|
||||
}
|
||||
}else{
|
||||
progressBar.show();
|
||||
progressBar.message = "loading metadata";
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
|
||||
|
||||
// render skybox
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
function loop() {
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
};
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
render();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Lion</title>
|
||||
<style>canvas { width: 100%; height: 100% }</style>
|
||||
</head>
|
||||
@ -9,8 +8,13 @@
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
#renderArea{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.info{
|
||||
color:white;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px black,
|
||||
1px -1px 1px black,
|
||||
@ -34,18 +38,32 @@
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="../build/js/laslaz.js"></script>
|
||||
|
||||
<script src="js/ProgressBar.js"></script>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
||||
<div id="lblNumVisiblePoints" class="info" style="position: absolute; left: 10px; top: 100px; width: 400px; color:white"></div>
|
||||
<div id="lblMessage" class="info" style="position: absolute; left: 10px; bottom: 0px; width: 400px; color:white"></div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
</div>
|
||||
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
var defaultPointSize = 0.09;
|
||||
var defaultLOD = 12;
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud_laz.js";
|
||||
var pointSize = 0.5;
|
||||
var pointCountTarget = 0.4;
|
||||
var opacity = 1;
|
||||
var pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
var pointColorType = Potree.PointColorType.RGB;
|
||||
var pointShape = Potree.PointShape.SQUARE;
|
||||
var interpolate = false;
|
||||
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa_laz/cloud.js";
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
var renderer;
|
||||
var camera;
|
||||
@ -54,7 +72,7 @@
|
||||
var skybox;
|
||||
var stats;
|
||||
var clock = new THREE.Clock();
|
||||
var materials = {};
|
||||
var showSkybox = false;
|
||||
|
||||
function initGUI(){
|
||||
|
||||
@ -64,43 +82,82 @@
|
||||
});
|
||||
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
LOD: defaultLOD,
|
||||
"show aabb" : false,
|
||||
"Materials" : materials.rgb
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": opacity,
|
||||
"SizeType" : "Adaptive",
|
||||
"show octree" : false,
|
||||
"Materials" : "RGB",
|
||||
"interpolate": interpolate,
|
||||
"circles": false,
|
||||
"skybox": false
|
||||
};
|
||||
|
||||
var pLOD = gui.add(params, 'LOD', 0.5,20);
|
||||
pLOD.onChange(function(value){
|
||||
pointcloud.LOD = value;
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 0.5);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 0.3);
|
||||
var pPointSize = gui.add(params, 'PointSize', 0, 3);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloud.material.size = value;
|
||||
pointSize = value;
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Intensity" ]);
|
||||
pMaterial.onChange(function(value){
|
||||
var size = pointcloud.material.size;
|
||||
if(value === "RGB"){
|
||||
pointcloud.material = materials.rgb;
|
||||
}else if(value === "Color"){
|
||||
pointcloud.material = materials.color;
|
||||
}else if(value === "Height"){
|
||||
pointcloud.material = materials.height;
|
||||
}else if(value === "Intensity"){
|
||||
pointcloud.material = materials.intensity;
|
||||
var pOpacity = gui.add(params, 'opacity', 0, 1);
|
||||
pOpacity.onChange(function(value){
|
||||
opacity = value;
|
||||
});
|
||||
|
||||
var pSizeType = gui.add(params, 'SizeType', [ "Fixed", "Attenuated", "Adaptive"]);
|
||||
pSizeType.onChange(function(value){
|
||||
if(value === "Fixed"){
|
||||
pointSizeType = Potree.PointSizeType.FIXED;
|
||||
}else if(value === "Attenuated"){
|
||||
pointSizeType = Potree.PointSizeType.ATTENUATED;
|
||||
}else if(value === "Adaptive"){
|
||||
pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
}
|
||||
|
||||
pointcloud.material.size = size;
|
||||
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'show aabb');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Intensity", "Intensity Gradient", "Octree Depth"]);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
}else if(value === "Color"){
|
||||
pointColorType = Potree.PointColorType.COLOR;
|
||||
}else if(value === "Height"){
|
||||
pointColorType = Potree.PointColorType.HEIGHT;
|
||||
|
||||
}else if(value === "Octree Depth"){
|
||||
pointColorType = Potree.PointColorType.OCTREE_DEPTH;
|
||||
}else if(value === "Point Index"){
|
||||
pointColorType = Potree.PointColorType.POINT_INDEX;
|
||||
}else if(value === "Intensity"){
|
||||
pointColorType = Potree.PointColorType.INTENSITY;
|
||||
}else if(value === "Intensity Gradient"){
|
||||
pointColorType = Potree.PointColorType.INTENSITY_GRADIENT;
|
||||
}
|
||||
});
|
||||
|
||||
if(renderer.context.getExtension("EXT_frag_depth")){
|
||||
var pInterpolate = gui.add(params, 'interpolate');
|
||||
pInterpolate.onChange(function(value){
|
||||
interpolate = value;
|
||||
});
|
||||
}
|
||||
|
||||
var pCircular = gui.add(params, 'circles');
|
||||
pCircular.onChange(function(value){
|
||||
if(value){
|
||||
pointShape = Potree.PointShape.CIRCLE;
|
||||
}else{
|
||||
pointShape = Potree.PointShape.SQUARE;
|
||||
}
|
||||
});
|
||||
|
||||
var pSykbox = gui.add(params, 'skybox');
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
});
|
||||
|
||||
// stats
|
||||
@ -112,65 +169,125 @@
|
||||
}
|
||||
|
||||
function initThree(){
|
||||
var fov = 75;
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 100000);
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(window.innerWidth, window.innerHeight);
|
||||
renderer.setSize(width, height);
|
||||
renderer.autoClear = false;
|
||||
document.body.appendChild(renderer.domElement);
|
||||
elRenderArea.appendChild(renderer.domElement);
|
||||
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
// camera and controls
|
||||
camera.position.set(2, 7, 7);
|
||||
camera.position.set(3, 7, 6);
|
||||
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
controls.target.set( 0, 4, 0 );
|
||||
controls.target.set( 0, 5, 0 );
|
||||
camera.lookAt(controls.target);
|
||||
|
||||
// materials
|
||||
materials.rgb = new Potree.PointCloudRGBMaterial({ size: defaultPointSize});
|
||||
materials.color = new Potree.PointCloudColorMaterial({size: defaultPointSize});
|
||||
materials.height = new Potree.PointCloudHeightMaterial({size: defaultPointSize, min: 0, max: 10});
|
||||
materials.intensity = new Potree.PointCloudIntensityMaterial({size: defaultPointSize, min: 0, max: 65535});
|
||||
// enable frag_depth extension for the interpolation shader, if available
|
||||
renderer.context.getExtension("EXT_frag_depth");
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
||||
|
||||
pointcloud = new Potree.PointCloudOctree(pco, materials.rgb);
|
||||
pointcloud.LOD = defaultLOD;
|
||||
pointcloud.rotation.set(Math.PI/2, 0.85* -Math.PI/2, -0.0);
|
||||
pointcloud.moveToOrigin();
|
||||
pointcloud.moveToGroundPlane();
|
||||
|
||||
scene.add(pointcloud);
|
||||
POCLoader.load(pointcloudPath, function(geometry){
|
||||
pointcloud = new Potree.PointCloudOctree(geometry);
|
||||
|
||||
pointcloud.material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
|
||||
pointcloud.rotation.set(Math.PI/2, 0.85* -Math.PI/2, -0.0);
|
||||
pointcloud.moveToOrigin();
|
||||
pointcloud.moveToGroundPlane();
|
||||
|
||||
scene.add(pointcloud);
|
||||
});
|
||||
|
||||
var grid = Potree.utils.createGrid(5, 5, 2);
|
||||
scene.add(grid);
|
||||
}
|
||||
|
||||
function render() {
|
||||
requestAnimationFrame(render);
|
||||
function update(){
|
||||
if(pointcloud){
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointShape = pointShape;
|
||||
pointcloud.material.interpolate = interpolate;
|
||||
pointcloud.material.heightMin = 0;
|
||||
pointcloud.material.heightMax = 8;
|
||||
pointcloud.material.intensityMin = 0;
|
||||
pointcloud.material.intensityMax = 65000;
|
||||
|
||||
pointcloud.update(camera);
|
||||
|
||||
pointcloud.update(camera);
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
stats.update();
|
||||
|
||||
controls.update(clock.getDelta());
|
||||
|
||||
// update progress bar
|
||||
if(pointcloud){
|
||||
var progress = pointcloud.visibleNodes.length / pointcloud.visibleGeometry.length;
|
||||
|
||||
progressBar.progress = progress;
|
||||
progressBar.message = "loading: " + pointcloud.visibleNodes.length + " / " + pointcloud.visibleGeometry.length;
|
||||
|
||||
if(progress === 1){
|
||||
progressBar.hide();
|
||||
}else if(progress < 1){
|
||||
progressBar.show();
|
||||
}
|
||||
}else{
|
||||
progressBar.show();
|
||||
progressBar.message = "loading metadata";
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
|
||||
|
||||
// render skybox
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
}
|
||||
|
||||
function loop() {
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
};
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
render();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ var camera;
|
||||
var scene;
|
||||
var pickLocation;
|
||||
var mouse = { x: 1, y: 1 };
|
||||
var projector, raycaster;
|
||||
var raycaster;
|
||||
|
||||
function generatePointcloud(){
|
||||
var geometry = new THREE.BufferGeometry();
|
||||
@ -62,7 +62,6 @@ function init() {
|
||||
scene = new THREE.Scene();
|
||||
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
|
||||
|
||||
projector = new THREE.Projector();
|
||||
raycaster = new THREE.Raycaster();
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
@ -99,7 +98,7 @@ function render() {
|
||||
camera.updateMatrixWorld(true);
|
||||
|
||||
vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
|
||||
projector.unprojectVector( vector, camera );
|
||||
vector.unproject(camera);
|
||||
raycaster.params = {"PointCloud" : {threshold: 0.1}};
|
||||
raycaster.ray.set( camera.position, vector.sub( camera.position ).normalize() );
|
||||
|
||||
|
||||
@ -1,404 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="http://openlayers.org/en/v3.0.0/css/ol.css" type="text/css">
|
||||
<style>
|
||||
|
||||
body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.map {
|
||||
position: absolute;
|
||||
height: 300px;
|
||||
width: 400px;
|
||||
right: 5px;
|
||||
bottom: 5px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
#renderArea{
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.info{
|
||||
position: absolute;
|
||||
z-index: 2000;
|
||||
color:white;
|
||||
font-weight: bold;
|
||||
text-shadow: 1px 1px 1px black,
|
||||
1px -1px 1px black,
|
||||
-1px 1px 1px black,
|
||||
-1px -1px 1px black;
|
||||
}
|
||||
|
||||
a:hover, a:visited, a:link, a:active{
|
||||
color: #ccccff;
|
||||
text-decoration: none;
|
||||
}
|
||||
</style>
|
||||
<script src="http://openlayers.org/en/v3.0.0/build/ol.js" type="text/javascript"></script>
|
||||
|
||||
<script src="../libs/signals/signals.min.js"></script>
|
||||
<script src="../libs/three.js/build/three.js"></script>
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
<script src="../libs/proj4/proj4.js"></script>
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
|
||||
<script src="profile.js"></script>
|
||||
|
||||
<title>Georeferencing Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="map" class="map"></div>
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<div class="info" style="position: absolute; left: 300px; right: 300px; top: 10px; text-align: center;">
|
||||
<a href="http://potree.org" target="_blank">potree.org</a><br>
|
||||
|
||||
Georeferencing (sync with OpenLayers3) and Measurement.<br>
|
||||
Double click to generate measurement points.
|
||||
|
||||
<br><br>
|
||||
Point cloud courtesy of <a href="http://www.sigeom.ch/" target="_blank">sigeom sa</a><br>
|
||||
Rue des Oeuches 45<br>
|
||||
2740 Moutier<br>
|
||||
Switzerland <br>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/vol_total/cloud.js";
|
||||
var defaultPointSize = 3;
|
||||
var defaultLOD = 17;
|
||||
|
||||
// add EPSG:21781 to the proj4 projection database
|
||||
proj4.defs('EPSG:21781', "+proj=somerc +lat_0=46.95240555555556 +lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel +towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs ");
|
||||
var fromSwiss = proj4.defs("EPSG:21781");
|
||||
var toWGS84 = proj4.defs("WGS84");
|
||||
|
||||
// extent (with altitude) in EPSG:21781 / Swiss Coordinate System
|
||||
var minSwiss = [584757.154, 230878.747, 662.379];
|
||||
var maxSwiss = [593758.872, 232521.598, 850.323];
|
||||
|
||||
// extent in EPSG:4326 / WGS84 World Geodetic System
|
||||
var minExtent = proj4(proj4.defs("EPSG:21781"), proj4.defs("WGS84"), [minSwiss[0], minSwiss[1]]);
|
||||
var maxExtent = proj4(proj4.defs("EPSG:21781"), proj4.defs("WGS84"), [maxSwiss[0], maxSwiss[1]]);
|
||||
|
||||
// extent in EPSG:3857 / WGS84 Web Mercator
|
||||
var minT = ol.proj.transform(minExtent, 'EPSG:4326', 'EPSG:3857');
|
||||
var maxT = ol.proj.transform(maxExtent, 'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
// the offset of the point cloud in EPSG:21781 coordinate system to local scene coordinates.
|
||||
// subtract this offset in order to move from local scene coordinates (obtained from picking, etc.)
|
||||
// to EPSG:21781 coordinates
|
||||
var offset = new THREE.Vector3();
|
||||
|
||||
|
||||
// OpenLayers3 stuff
|
||||
var featureVector;
|
||||
var camFrustumFeatureVector;
|
||||
var camFrustum;
|
||||
|
||||
// three.js / potree stuff
|
||||
var renderer;
|
||||
var scene, sceneHUD;
|
||||
var camera, cameraHUD;
|
||||
var skybox;
|
||||
var materials = {};
|
||||
var clock = new THREE.Clock();
|
||||
var viewerControls;
|
||||
var profileTool;
|
||||
var translationTool;
|
||||
|
||||
function initMapView(){
|
||||
|
||||
var extent = [minT[0], minT[1], maxT[0], maxT[1]];
|
||||
var center = [(maxT[0] + minT[0]) / 2, (maxT[1] + minT[1]) / 2];
|
||||
|
||||
// draw the extent as box inside the map view
|
||||
var box = new ol.geom.LineString([
|
||||
minT, [maxT[0], minT[1]], maxT, [minT[0], maxT[1]], minT
|
||||
]);
|
||||
|
||||
var feature = new ol.Feature(box);
|
||||
featureVector = new ol.source.Vector({
|
||||
features: [feature]
|
||||
});
|
||||
|
||||
var layer = new ol.layer.Vector({
|
||||
source: featureVector,
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#ff0000',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 3,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#0000ff'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
camFrustumFeatureVector = new ol.source.Vector({
|
||||
features: []
|
||||
});
|
||||
|
||||
var camFrustumLayer = new ol.layer.Vector({
|
||||
source: camFrustumFeatureVector,
|
||||
style: new ol.style.Style({
|
||||
fill: new ol.style.Fill({
|
||||
color: 'rgba(255, 255, 255, 0.2)'
|
||||
}),
|
||||
stroke: new ol.style.Stroke({
|
||||
color: '#ff0000',
|
||||
width: 2
|
||||
}),
|
||||
image: new ol.style.Circle({
|
||||
radius: 3,
|
||||
fill: new ol.style.Fill({
|
||||
color: '#ff0000'
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
// create the map
|
||||
var map = new ol.Map({
|
||||
controls: ol.control.defaults({
|
||||
attributionOptions: /** @type {olx.control.AttributionOptions} */ ({
|
||||
collapsible: false
|
||||
})
|
||||
}).extend([
|
||||
new ol.control.ZoomToExtent({
|
||||
extent: extent,
|
||||
closest: true
|
||||
})
|
||||
]),
|
||||
layers: [
|
||||
new ol.layer.Tile({
|
||||
source: new ol.source.OSM()
|
||||
}),
|
||||
layer,
|
||||
camFrustumLayer
|
||||
],
|
||||
target: 'map',
|
||||
view: new ol.View({
|
||||
center: center,
|
||||
zoom: 12
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function initPotreeView(){
|
||||
var renderArea = document.getElementById("renderArea");
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
var fov = 60;
|
||||
|
||||
var aspect = renderArea.clientWidth / renderArea.clientHeight;
|
||||
scene = new THREE.Scene();
|
||||
sceneHUD = new THREE.Scene();
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
cameraHUD = new THREE.OrthographicCamera( -1, 1, 1, -1, -100, 1000 );
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(renderArea.clientWidth, renderArea.clientHeight);
|
||||
renderer.autoClear = false;
|
||||
renderArea.appendChild(renderer.domElement);
|
||||
|
||||
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
||||
|
||||
camera.position.set(500, 200, -300);
|
||||
controls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
camera.rotation.order = 'ZYX';
|
||||
camera.rotation.x = -0.5;
|
||||
camera.rotation.y = -5*Math.PI/4;
|
||||
controls.moveSpeed *= 10;
|
||||
|
||||
materials.rgb = new Potree.PointCloudRGBMaterial({ size: defaultPointSize});
|
||||
|
||||
// load pointcloud
|
||||
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
||||
offset = pco.offset;
|
||||
pointcloud = new Potree.PointCloudOctree(pco, materials.rgb);
|
||||
pointcloud.LOD = defaultLOD;
|
||||
pointcloud.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,0,1,0,
|
||||
0,-1,0,0,
|
||||
0,0,0,1
|
||||
));
|
||||
scene.add(pointcloud);
|
||||
|
||||
profileTool = new Potree.ProfileTool(200, 100, 2);
|
||||
profileTool.position.set(200, 50, -100);
|
||||
profileTool.rotation.y = Math.PI / 2;
|
||||
scene.add(profileTool);
|
||||
sceneHUD.add(profileTool.hudElement);
|
||||
|
||||
translationTool = new Potree.TranslationTool(camera);
|
||||
translationTool.setTargets([profileTool]);
|
||||
scene.add(translationTool);
|
||||
|
||||
|
||||
//measuringTool = new Potree.MeasuringTool(scene, camera, renderer.domElement);
|
||||
|
||||
// execute this event whenever a new measurement point has been set
|
||||
//measuringTool.addEventListener("newpoint", function(event){
|
||||
// // transform from local scene to swiss projection.
|
||||
// var point = new THREE.Vector3(event.position.x, -event.position.z, event.position.y);
|
||||
// point = point.sub(offset);
|
||||
//
|
||||
// // transform from swiss projection to WGS84
|
||||
// var fromSwiss = proj4.defs("EPSG:21781");
|
||||
// var toWGS84 = proj4.defs("WGS84");
|
||||
// var coordinate = proj4(fromSwiss, toWGS84, [point.x, point.y]);
|
||||
//
|
||||
// // transform from WGS84 to Web Mercator
|
||||
// coordinate = ol.proj.transform(coordinate, 'EPSG:4326', 'EPSG:3857');
|
||||
//
|
||||
// // add a point to the OpenLayers map
|
||||
// var olPoint = new ol.geom.Point(coordinate);
|
||||
// var feature = new ol.Feature(olPoint);
|
||||
// featureVector.addFeature(feature);
|
||||
//});
|
||||
}
|
||||
|
||||
function initGUI(){
|
||||
|
||||
// dat.gui
|
||||
var gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
PointSize: defaultPointSize,
|
||||
LOD: defaultLOD,
|
||||
"bounding box" : false
|
||||
};
|
||||
|
||||
var pLOD = gui.add(params, 'LOD', 0.5,20);
|
||||
pLOD.onChange(function(value){
|
||||
pointcloud.LOD = value;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0.01, 4.0);
|
||||
pPointSize.onChange(function(value){
|
||||
pointcloud.material.size = value;
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'bounding box');
|
||||
pBoundingBox.onChange(function(value){
|
||||
pointcloud.showBoundingBox = value;
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function update(){
|
||||
var renderArea = document.getElementById("renderArea");
|
||||
var width = renderArea.clientWidth;
|
||||
var height = renderArea.clientHeight;
|
||||
|
||||
//controls.update(clock.getDelta());
|
||||
viewerControls.update(clock.getDelta());
|
||||
pointcloud.update(camera);
|
||||
|
||||
if(camFrustum === undefined){
|
||||
camFrustum = new ol.geom.LineString([ [0,0], [0, 0] ]);
|
||||
var feature = new ol.Feature(camFrustum);
|
||||
camFrustumFeatureVector.addFeature(feature);
|
||||
}
|
||||
|
||||
|
||||
var aspect = camera.aspect;
|
||||
var top = Math.tan( THREE.Math.degToRad( camera.fov * 0.5 ) ) * camera.near;
|
||||
var bottom = - top;
|
||||
var left = aspect * bottom;
|
||||
var right = aspect * top;
|
||||
|
||||
var camPos = new THREE.Vector3(0, 0, 0);
|
||||
left = new THREE.Vector3(left, 0, -camera.near).multiplyScalar(3000);
|
||||
right = new THREE.Vector3(right, 0, -camera.near).multiplyScalar(3000);
|
||||
camPos.applyMatrix4(camera.matrixWorld);
|
||||
left.applyMatrix4(camera.matrixWorld);
|
||||
right.applyMatrix4(camera.matrixWorld);
|
||||
|
||||
|
||||
// transform from local scene to swiss projection.
|
||||
camPos = new THREE.Vector3(camPos.x, -camPos.z, camPos.y).sub(offset);
|
||||
left = new THREE.Vector3(left.x, -left.z, left.y).sub(offset);
|
||||
right = new THREE.Vector3(right.x, -right.z, right.y).sub(offset);
|
||||
|
||||
camPos = proj4(fromSwiss, toWGS84, [camPos.x, camPos.y]);
|
||||
left = proj4(fromSwiss, toWGS84, [left.x, left.y]);
|
||||
right = proj4(fromSwiss, toWGS84, [right.x, right.y]);
|
||||
|
||||
camPos = ol.proj.transform(camPos, 'EPSG:4326', 'EPSG:3857');
|
||||
left = ol.proj.transform(left, 'EPSG:4326', 'EPSG:3857');
|
||||
right = ol.proj.transform(right, 'EPSG:4326', 'EPSG:3857');
|
||||
|
||||
camFrustum.setCoordinates([camPos, left, right, camPos]);
|
||||
|
||||
|
||||
profileTool.hudElement.scale.x = 400 / width;
|
||||
profileTool.hudElement.scale.y = 300 / height;
|
||||
profileTool.hudElement.position.x = 1 - 405 / width;
|
||||
profileTool.hudElement.position.y = -1 + 905 / height;
|
||||
}
|
||||
|
||||
function render(){
|
||||
// resize
|
||||
var renderArea = document.getElementById("renderArea");
|
||||
var width = renderArea.clientWidth;
|
||||
var height = renderArea.clientHeight;
|
||||
|
||||
renderer.setSize(width, height-10);
|
||||
camera.aspect = width / height;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
// render skybox
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
|
||||
// render scenes
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(measuringControl.sceneMeasurement, camera);
|
||||
renderer.render(sceneHUD, cameraHUD);
|
||||
|
||||
profileTool.render(renderer, scene);
|
||||
|
||||
}
|
||||
|
||||
function loop(){
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
}
|
||||
|
||||
initMapView();
|
||||
initPotreeView();
|
||||
initGUI();
|
||||
|
||||
initSignals();
|
||||
|
||||
loop();
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -1,774 +0,0 @@
|
||||
|
||||
function initSignals(){
|
||||
viewerControls = new ViewerControls(renderer.domElement, camera, scene);
|
||||
|
||||
measuringControl = new Potree.MeasuringControls(scene, camera);
|
||||
viewerControls.addControl(measuringControl);
|
||||
|
||||
|
||||
viewerControls.addControl(translationTool);
|
||||
|
||||
|
||||
var firstPersonControls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
firstPersonControls.moveSpeed *= 10;
|
||||
viewerControls.addControl(firstPersonControls);
|
||||
}
|
||||
|
||||
|
||||
ViewerControls = function(element, camera, scene){
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.mouse = {x: 0, y: 0};
|
||||
this.element = element;
|
||||
this.camera = camera;
|
||||
this.scene = scene;
|
||||
|
||||
this.events = {
|
||||
mousemove : new signals.Signal(),
|
||||
mouseclick : new signals.Signal(),
|
||||
mousedown : new signals.Signal(),
|
||||
mouseup : new signals.Signal(),
|
||||
mousewheel : new signals.Signal(),
|
||||
dblclick : new signals.Signal(),
|
||||
update : new signals.Signal(),
|
||||
keydown: new signals.Signal(),
|
||||
keyup: new signals.Signal()
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.addControl = function(control){
|
||||
if(control.onMouseMove !== undefined){
|
||||
scope.events.mousemove.add(control.onMouseMove);
|
||||
}
|
||||
|
||||
if(control.onMouseClick !== undefined){
|
||||
scope.events.mouseclick.add(control.onMouseClick);
|
||||
}
|
||||
|
||||
if(control.onMouseDown !== undefined){
|
||||
scope.events.mousedown.add(control.onMouseDown);
|
||||
}
|
||||
|
||||
if(control.onMouseUp !== undefined){
|
||||
scope.events.mouseup.add(control.onMouseUp);
|
||||
}
|
||||
|
||||
if(control.onMouseWheel !== undefined){
|
||||
scope.events.mousewheel.add(control.onMouseWheel);
|
||||
}
|
||||
|
||||
if(control.onDoubleClick !== undefined){
|
||||
scope.events.dblclick.add(control.onDoubleClick);
|
||||
}
|
||||
|
||||
if(control.update !== undefined){
|
||||
scope.events.update.add(control.update);
|
||||
}
|
||||
|
||||
if(control.onKeyDown !== undefined){
|
||||
scope.events.keydown.add(control.onKeyDown);
|
||||
}
|
||||
|
||||
if(control.onKeyUp !== undefined){
|
||||
scope.events.keyup.add(control.onKeyUp);
|
||||
}
|
||||
}
|
||||
|
||||
this.onMouseMove = function(event){
|
||||
scope.mouse.x = ( event.clientX / scope.element.clientWidth ) * 2 - 1;
|
||||
scope.mouse.y = - ( event.clientY / scope.element.clientHeight ) * 2 + 1;
|
||||
|
||||
var vector = new THREE.Vector3( scope.mouse.x, scope.mouse.y, 0.5 );
|
||||
var projector = new THREE.Projector();
|
||||
projector.unprojectVector( vector, scope.camera );
|
||||
|
||||
scope.mouse.relativePosition = {x: event.clientX, y: event.clientY};
|
||||
scope.mouse.normalizedPosition = {x: scope.mouse.x, y: scope.mouse.y};
|
||||
scope.mouse.scenePosition = vector;
|
||||
|
||||
var message = {
|
||||
relativePosition: scope.mouse.relativePosition,
|
||||
normalizedPosition: scope.mouse.normalizedPosition,
|
||||
scenePosition: scope.mouse.scenePosition,
|
||||
signal: scope.events.mousemove
|
||||
};
|
||||
|
||||
scope.events.mousemove.dispatch(message);
|
||||
}
|
||||
|
||||
this.onMouseClick = function(event){
|
||||
var message = {
|
||||
|
||||
};
|
||||
|
||||
scope.events.mouseclick.dispatch(message);
|
||||
}
|
||||
|
||||
this.onDoubleClick = function(event){
|
||||
|
||||
var message = {
|
||||
relativePosition: scope.mouse.relativePosition,
|
||||
normalizedPosition: scope.mouse.normalizedPosition,
|
||||
scenePosition: scope.mouse.scenePosition
|
||||
};
|
||||
|
||||
|
||||
scope.events.dblclick.dispatch(message);
|
||||
}
|
||||
|
||||
this.onMouseDown = function(event){
|
||||
event.preventDefault();
|
||||
|
||||
var message = {
|
||||
which: event.which,
|
||||
button: event.button,
|
||||
relativePosition: scope.mouse.relativePosition,
|
||||
normalizedPosition: scope.mouse.normalizedPosition,
|
||||
scenePosition: scope.mouse.scenePosition,
|
||||
signal: scope.events.mousedown
|
||||
};
|
||||
|
||||
scope.events.mousedown.dispatch(message);
|
||||
}
|
||||
|
||||
this.onMouseUp = function(event){
|
||||
event.preventDefault();
|
||||
|
||||
var message = {
|
||||
|
||||
};
|
||||
|
||||
scope.events.mouseup.dispatch(message);
|
||||
}
|
||||
|
||||
this.update = function(time){
|
||||
var message = {
|
||||
time: time
|
||||
};
|
||||
|
||||
scope.events.update.dispatch(message);
|
||||
}
|
||||
|
||||
this.onKeyDown = function(event){
|
||||
var message = {
|
||||
keyCode: event.keyCode
|
||||
};
|
||||
|
||||
scope.events.keydown.dispatch(message);
|
||||
}
|
||||
|
||||
this.onKeyUp = function(event){
|
||||
var message = {
|
||||
keyCode: event.keyCode
|
||||
};
|
||||
|
||||
scope.events.keyup.dispatch(message);
|
||||
}
|
||||
|
||||
this.onContextMenu = function(event){
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
this.onMouseWheel = function(event){
|
||||
event.preventDefault();
|
||||
|
||||
var delta = 0;
|
||||
if ( event.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9
|
||||
delta = event.wheelDelta;
|
||||
} else if ( event.detail !== undefined ) { // Firefox
|
||||
delta = - event.detail;
|
||||
}
|
||||
|
||||
var message = {
|
||||
delta: delta
|
||||
};
|
||||
|
||||
scope.events.mousewheel.dispatch(message);
|
||||
}
|
||||
|
||||
|
||||
element.addEventListener("mousemove", this.onMouseMove);
|
||||
element.addEventListener("click", this.onMouseClick);
|
||||
element.addEventListener("dblclick", this.onDoubleClick);
|
||||
element.addEventListener("mousedown", this.onMouseDown);
|
||||
element.addEventListener("mouseup", this.onMouseUp);
|
||||
element.addEventListener("contextmenu", this.onContextMenu);
|
||||
element.addEventListener("mousewheel", this.onMouseWheel);
|
||||
|
||||
window.addEventListener("keydown", this.onKeyDown);
|
||||
window.addEventListener("keyup", this.onKeyUp);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Potree.MeasuringControls = function(scene, camera){
|
||||
|
||||
var scope = this;
|
||||
|
||||
this.scene = scene;
|
||||
this.camera = camera;
|
||||
|
||||
this.mouse = {x: 0, y: 0};
|
||||
|
||||
var STATE = {
|
||||
DEFAULT: 0,
|
||||
PICKING: 1
|
||||
};
|
||||
|
||||
var state = STATE.DEFAULT;
|
||||
|
||||
this.activeMeasurement;
|
||||
this.measurements = [];
|
||||
this.sceneMeasurement = new THREE.Scene();
|
||||
this.sceneRoot = new THREE.Object3D();
|
||||
this.sceneMeasurement.add(this.sceneRoot);
|
||||
|
||||
function Measure(){
|
||||
this.points = [];
|
||||
this.spheres = [];
|
||||
this.edges = [];
|
||||
this.sphereLabels = [];
|
||||
this.edgeLabels = [];
|
||||
}
|
||||
|
||||
|
||||
this.onDoubleClick = function(event){
|
||||
var I = getMousePointCloudIntersection(event.normalizedPosition);
|
||||
if(I){
|
||||
var pos = I.clone();
|
||||
|
||||
var sphereMaterial = new THREE.MeshNormalMaterial({shading: THREE.SmoothShading})
|
||||
var sphereGeometry = new THREE.SphereGeometry(0.4, 10, 10);
|
||||
|
||||
var sphere = new THREE.Mesh(sphereGeometry, sphereMaterial);
|
||||
sphere.position.copy(I);
|
||||
scope.sceneRoot.add(sphere);
|
||||
|
||||
var sphereEnd = new THREE.Mesh(sphereGeometry, sphereMaterial);
|
||||
sphereEnd.position.copy(I);
|
||||
scope.sceneRoot.add(sphereEnd);
|
||||
|
||||
var msg = pos.x.toFixed(2) + " / " + pos.y.toFixed(2) + " / " + pos.z.toFixed(2);
|
||||
|
||||
var label = new Potree.TextSprite(msg);
|
||||
label.setBorderColor({r:0, g:255, b:0, a:1.0});
|
||||
label.material.depthTest = false;
|
||||
label.material.opacity = 0;
|
||||
label.position.copy(I);
|
||||
label.position.y += 0.5;
|
||||
scope.sceneRoot.add( label );
|
||||
|
||||
var labelEnd = new Potree.TextSprite(msg);
|
||||
labelEnd.setBorderColor({r:0, g:255, b:0, a:1.0});
|
||||
labelEnd.material.depthTest = false;
|
||||
labelEnd.material.opacity = 0;
|
||||
labelEnd.position.copy(I);
|
||||
labelEnd.position.y += 0.5;
|
||||
scope.sceneRoot.add( labelEnd );
|
||||
|
||||
var lc = new THREE.Color( 0xff0000 );
|
||||
var lineGeometry = new THREE.Geometry();
|
||||
lineGeometry.vertices.push(I.clone(), I.clone());
|
||||
lineGeometry.colors.push(lc, lc, lc);
|
||||
var lineMaterial = new THREE.LineBasicMaterial( { vertexColors: THREE.VertexColors } );
|
||||
lineMaterial.depthTest = false;
|
||||
sConnection = new THREE.Line(lineGeometry, lineMaterial);
|
||||
scope.sceneRoot.add(sConnection);
|
||||
|
||||
var edgeLabel = new Potree.TextSprite(0);
|
||||
edgeLabel.setBorderColor({r:0, g:255, b:0, a:0.0});
|
||||
edgeLabel.setBackgroundColor({r:0, g:255, b:0, a:0.0});
|
||||
edgeLabel.material.depthTest = false;
|
||||
edgeLabel.position.copy(I);
|
||||
edgeLabel.position.y += 0.5;
|
||||
scope.sceneRoot.add( edgeLabel );
|
||||
|
||||
|
||||
//floatingOrigin.addReferenceFrame(sphere);
|
||||
//floatingOrigin.addReferenceFrame(sphereEnd);
|
||||
//floatingOrigin.addReferenceFrame(label);
|
||||
//floatingOrigin.addReferenceFrame(labelEnd);
|
||||
//floatingOrigin.addReferenceFrame(sConnection);
|
||||
//floatingOrigin.addReferenceFrame(edgeLabel);
|
||||
|
||||
if(state === STATE.DEFAULT){
|
||||
state = STATE.PICKING;
|
||||
scope.activeMeasurement = new Measure();
|
||||
|
||||
scope.activeMeasurement.spheres.push(sphere);
|
||||
}else if(state === STATE.PICKING){
|
||||
|
||||
}
|
||||
|
||||
scope.activeMeasurement.points.push(I);
|
||||
|
||||
scope.activeMeasurement.spheres.push(sphereEnd);
|
||||
scope.activeMeasurement.sphereLabels.push(label);
|
||||
scope.activeMeasurement.sphereLabels.push(labelEnd);
|
||||
scope.activeMeasurement.edges.push(sConnection);
|
||||
scope.activeMeasurement.edgeLabels.push(edgeLabel);
|
||||
|
||||
|
||||
var event = {
|
||||
type: 'newpoint',
|
||||
position: pos.clone()
|
||||
};
|
||||
scope.dispatchEvent(event);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
this.onMouseMove = function(event){
|
||||
|
||||
if(state == STATE.PICKING && scope.activeMeasurement){
|
||||
var I = getMousePointCloudIntersection(event.normalizedPosition);
|
||||
|
||||
if(I){
|
||||
var pos = I.clone();
|
||||
var l = scope.activeMeasurement.spheres.length;
|
||||
var sphere = scope.activeMeasurement.spheres[l-1];
|
||||
var label = scope.activeMeasurement.sphereLabels[l-1];
|
||||
var edge = scope.activeMeasurement.edges[l-2];
|
||||
var edgeLabel = scope.activeMeasurement.edgeLabels[l-2];
|
||||
|
||||
var msg = pos.x.toFixed(2) + " / " + pos.y.toFixed(2) + " / " + pos.z.toFixed(2);
|
||||
label.setText(msg);
|
||||
|
||||
sphere.position.copy(I);
|
||||
label.position.copy(I);
|
||||
label.position.y += 0.5;
|
||||
|
||||
edge.geometry.vertices[1].copy(I);
|
||||
edge.geometry.verticesNeedUpdate = true;
|
||||
edge.geometry.computeBoundingSphere();
|
||||
|
||||
var edgeLabelPos = edge.geometry.vertices[1].clone().add(edge.geometry.vertices[0]).multiplyScalar(0.5);
|
||||
var edgeLabelText = edge.geometry.vertices[0].distanceTo(edge.geometry.vertices[1]).toFixed(2);
|
||||
edgeLabel.position.copy(edgeLabelPos);
|
||||
edgeLabel.setText(edgeLabelText);
|
||||
edgeLabel.scale.multiplyScalar(10);
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
this.onRightClick = function(event){
|
||||
if(state == STATE.PICKING){
|
||||
var sphere = scope.activeMeasurement.spheres.pop();
|
||||
var edge = scope.activeMeasurement.edges.pop();
|
||||
var sphereLabel = scope.activeMeasurement.sphereLabels.pop();
|
||||
var edgeLabel = scope.activeMeasurement.edgeLabels.pop();
|
||||
|
||||
scope.sceneRoot.remove(sphere);
|
||||
scope.sceneRoot.remove(edge);
|
||||
scope.sceneRoot.remove(sphereLabel);
|
||||
scope.sceneRoot.remove(edgeLabel);
|
||||
|
||||
scope.measurements.push(scope.activeMeasurement);
|
||||
scope.activeMeasurement = undefined;
|
||||
|
||||
state = STATE.DEFAULT;
|
||||
}
|
||||
}
|
||||
|
||||
this.onMouseDown = function(event){
|
||||
if(event.which === 3){
|
||||
scope.onRightClick(event);
|
||||
}
|
||||
}
|
||||
|
||||
function getMousePointCloudIntersection(mouse){
|
||||
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
|
||||
var projector = new THREE.Projector();
|
||||
projector.unprojectVector( vector, scope.camera );
|
||||
|
||||
var raycaster = new THREE.Raycaster();
|
||||
raycaster.params = {"PointCloud" : {threshold: 1}};
|
||||
raycaster.ray.set( scope.camera.position, vector.sub( scope.camera.position ).normalize() );
|
||||
|
||||
var pointClouds = [];
|
||||
scope.scene.traverse(function(object){
|
||||
if(object instanceof Potree.PointCloudOctree){
|
||||
pointClouds.push(object);
|
||||
}
|
||||
});
|
||||
|
||||
var intersects = raycaster.intersectObjects(pointClouds, true);
|
||||
|
||||
if(intersects.length > 0){
|
||||
var I = intersects[0];
|
||||
|
||||
return I.point;
|
||||
}else{
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Potree.MeasuringControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
THREE.FirstPersonControls = function ( object, domElement ) {
|
||||
this.object = object;
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
// Set to false to disable this control
|
||||
this.enabled = true;
|
||||
|
||||
this.rotateSpeed = 1.0;
|
||||
this.moveSpeed = 10.0;
|
||||
|
||||
this.keys = {
|
||||
LEFT: 37,
|
||||
UP: 38,
|
||||
RIGHT: 39,
|
||||
BOTTOM: 40,
|
||||
A: 'A'.charCodeAt(0),
|
||||
S: 'S'.charCodeAt(0),
|
||||
D: 'D'.charCodeAt(0),
|
||||
W: 'W'.charCodeAt(0)
|
||||
};
|
||||
|
||||
var scope = this;
|
||||
|
||||
var rotateStart = new THREE.Vector2();
|
||||
var rotateEnd = new THREE.Vector2();
|
||||
var rotateDelta = new THREE.Vector2();
|
||||
|
||||
var panStart = new THREE.Vector2();
|
||||
var panEnd = new THREE.Vector2();
|
||||
var panDelta = new THREE.Vector2();
|
||||
var panOffset = new THREE.Vector3();
|
||||
|
||||
var offset = new THREE.Vector3();
|
||||
|
||||
var phiDelta = 0;
|
||||
var thetaDelta = 0;
|
||||
var scale = 1;
|
||||
var pan = new THREE.Vector3();
|
||||
|
||||
var lastPosition = new THREE.Vector3();
|
||||
|
||||
var STATE = { NONE : -1, ROTATE : 0, SPEEDCHANGE : 1, PAN : 2 };
|
||||
|
||||
var state = STATE.NONE;
|
||||
|
||||
// for reset
|
||||
this.position0 = this.object.position.clone();
|
||||
|
||||
// events
|
||||
|
||||
var changeEvent = { type: 'change' };
|
||||
var startEvent = { type: 'start'};
|
||||
var endEvent = { type: 'end'};
|
||||
|
||||
this.rotateLeft = function ( angle ) {
|
||||
thetaDelta -= angle;
|
||||
};
|
||||
|
||||
this.rotateUp = function ( angle ) {
|
||||
phiDelta -= angle;
|
||||
};
|
||||
|
||||
// pass in distance in world space to move left
|
||||
this.panLeft = function ( distance ) {
|
||||
|
||||
var te = this.object.matrix.elements;
|
||||
|
||||
// get X column of matrix
|
||||
panOffset.set( te[ 0 ], te[ 1 ], te[ 2 ] );
|
||||
panOffset.multiplyScalar( - distance );
|
||||
|
||||
pan.add( panOffset );
|
||||
|
||||
};
|
||||
|
||||
// pass in distance in world space to move up
|
||||
this.panUp = function ( distance ) {
|
||||
|
||||
var te = this.object.matrix.elements;
|
||||
|
||||
// get Y column of matrix
|
||||
panOffset.set( te[ 4 ], te[ 5 ], te[ 6 ] );
|
||||
panOffset.multiplyScalar( distance );
|
||||
|
||||
pan.add( panOffset );
|
||||
|
||||
};
|
||||
|
||||
// pass in distance in world space to move forward
|
||||
this.panForward = function ( distance ) {
|
||||
|
||||
var te = this.object.matrix.elements;
|
||||
|
||||
// get Y column of matrix
|
||||
panOffset.set( te[ 8 ], te[ 9 ], te[ 10 ] );
|
||||
panOffset.multiplyScalar( distance );
|
||||
|
||||
pan.add( panOffset );
|
||||
|
||||
};
|
||||
|
||||
this.pan = function ( deltaX, deltaY ) {
|
||||
|
||||
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
|
||||
|
||||
if ( scope.object.fov !== undefined ) {
|
||||
// perspective
|
||||
var position = scope.object.position;
|
||||
var offset = position.clone();
|
||||
var targetDistance = offset.length();
|
||||
|
||||
// half of the fov is center to top of screen
|
||||
targetDistance *= Math.tan( ( scope.object.fov / 2 ) * Math.PI / 180.0 );
|
||||
|
||||
// we actually don't use screenWidth, since perspective camera is fixed to screen height
|
||||
scope.panLeft( 2 * deltaX * targetDistance / element.clientHeight );
|
||||
scope.panUp( 2 * deltaY * targetDistance / element.clientHeight );
|
||||
} else if ( scope.object.top !== undefined ) {
|
||||
|
||||
// orthographic
|
||||
scope.panLeft( deltaX * (scope.object.right - scope.object.left) / element.clientWidth );
|
||||
scope.panUp( deltaY * (scope.object.top - scope.object.bottom) / element.clientHeight );
|
||||
} else {
|
||||
|
||||
// camera neither orthographic or perspective
|
||||
console.warn( 'WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.' );
|
||||
}
|
||||
};
|
||||
|
||||
this.update = function (event) {
|
||||
var delta = event.time;
|
||||
var position = scope.object.position;
|
||||
|
||||
if(delta !== undefined){
|
||||
if(scope.moveRight){
|
||||
scope.panLeft(-delta * scope.moveSpeed);
|
||||
}
|
||||
if(scope.moveLeft){
|
||||
scope.panLeft(delta * scope.moveSpeed);
|
||||
}
|
||||
if(scope.moveForward){
|
||||
scope.panForward(-delta * scope.moveSpeed);
|
||||
}
|
||||
if(scope.moveBackward){
|
||||
scope.panForward(delta * scope.moveSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
if(!pan.equals(new THREE.Vector3(0,0,0))){
|
||||
var event = {
|
||||
type: 'move',
|
||||
translation: pan.clone()
|
||||
};
|
||||
scope.dispatchEvent(event);
|
||||
}
|
||||
|
||||
position.add(pan);
|
||||
|
||||
scope.object.updateMatrix();
|
||||
var rot = new THREE.Matrix4().makeRotationY(thetaDelta);
|
||||
var res = new THREE.Matrix4().multiplyMatrices(rot, scope.object.matrix);
|
||||
scope.object.quaternion.setFromRotationMatrix(res);
|
||||
|
||||
scope.object.rotation.x += phiDelta;
|
||||
|
||||
thetaDelta = 0;
|
||||
phiDelta = 0;
|
||||
scale = 1;
|
||||
pan.set( 0, 0, 0 );
|
||||
|
||||
if ( lastPosition.distanceTo( scope.object.position ) > 0 ) {
|
||||
scope.dispatchEvent( changeEvent );
|
||||
|
||||
lastPosition.copy( scope.object.position );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.reset = function () {
|
||||
state = STATE.NONE;
|
||||
|
||||
this.object.position.copy( this.position0 );
|
||||
};
|
||||
|
||||
this.onMouseDown = function( event ) {
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
if ( event.button === 0 ) {
|
||||
state = STATE.ROTATE;
|
||||
|
||||
rotateStart.set( event.relativePosition.x, event.relativePosition.y );
|
||||
} else if ( event.button === 2 ) {
|
||||
state = STATE.PAN;
|
||||
|
||||
panStart.set( event.relativePosition.x, event.relativePosition.y );
|
||||
}
|
||||
|
||||
scope.dispatchEvent( startEvent );
|
||||
}
|
||||
|
||||
this.onMouseMove = function( event ) {
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
|
||||
|
||||
if ( state === STATE.ROTATE ) {
|
||||
rotateEnd.set( event.relativePosition.x, event.relativePosition.y );
|
||||
rotateDelta.subVectors( rotateEnd, rotateStart );
|
||||
|
||||
// rotating across whole screen goes 360 degrees around
|
||||
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed );
|
||||
|
||||
// rotating up and down along whole screen attempts to go 360, but limited to 180
|
||||
scope.rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed );
|
||||
|
||||
rotateStart.copy( rotateEnd );
|
||||
|
||||
} else if ( state === STATE.PAN ) {
|
||||
panEnd.set( event.relativePosition.x, event.relativePosition.y );
|
||||
panDelta.subVectors( panEnd, panStart );
|
||||
panDelta.multiplyScalar(0.0005).multiplyScalar(scope.moveSpeed);
|
||||
|
||||
scope.pan( panDelta.x, panDelta.y );
|
||||
|
||||
panStart.copy( panEnd );
|
||||
}
|
||||
}
|
||||
|
||||
this.onMouseUp = function() {
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
scope.dispatchEvent( endEvent );
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
this.onMouseWheel = function(event) {
|
||||
if ( scope.enabled === false || scope.noZoom === true ) return;
|
||||
|
||||
scope.moveSpeed += scope.moveSpeed * 0.001 * event.delta;
|
||||
scope.moveSpeed = Math.max(0.1, scope.moveSpeed);
|
||||
|
||||
scope.dispatchEvent( startEvent );
|
||||
scope.dispatchEvent( endEvent );
|
||||
}
|
||||
|
||||
this.onKeyDown = function( event ) {
|
||||
if ( scope.enabled === false) return;
|
||||
|
||||
switch ( event.keyCode ) {
|
||||
case scope.keys.UP: scope.moveForward = true; break;
|
||||
case scope.keys.BOTTOM: scope.moveBackward = true; break;
|
||||
case scope.keys.LEFT: scope.moveLeft = true; break;
|
||||
case scope.keys.RIGHT: scope.moveRight = true; break;
|
||||
case scope.keys.W: scope.moveForward = true; break;
|
||||
case scope.keys.S: scope.moveBackward = true; break;
|
||||
case scope.keys.A: scope.moveLeft = true; break;
|
||||
case scope.keys.D: scope.moveRight = true; break;
|
||||
}
|
||||
}
|
||||
|
||||
this.onKeyUp = function( event ) {
|
||||
switch ( event.keyCode ) {
|
||||
case scope.keys.W: scope.moveForward = false; break;
|
||||
case scope.keys.S: scope.moveBackward = false; break;
|
||||
case scope.keys.A: scope.moveLeft = false; break;
|
||||
case scope.keys.D: scope.moveRight = false; break;
|
||||
case scope.keys.UP: scope.moveForward = false; break;
|
||||
case scope.keys.BOTTOM: scope.moveBackward = false; break;
|
||||
case scope.keys.LEFT: scope.moveLeft = false; break;
|
||||
case scope.keys.RIGHT: scope.moveRight = false; break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
THREE.FirstPersonControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
@ -21,11 +21,7 @@ var paths = {
|
||||
"src/loader/POCLoader.js",
|
||||
"src/loader/PointAttributes.js",
|
||||
"src/loader/LasLazLoader.js",
|
||||
"src/materials/PointCloudRGBMaterial.js",
|
||||
"src/materials/PointCloudRGBInterpolationMaterial.js",
|
||||
"src/materials/PointCloudIntensityMaterial.js",
|
||||
"src/materials/PointCloudHeightMaterial.js",
|
||||
"src/materials/PointCloudColorMaterial.js",
|
||||
"src/materials/PointCloudMaterial.js",
|
||||
"src/FirstPersonControls.js",
|
||||
"src/LRU.js",
|
||||
"src/PointCloudOctree.js",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1107
libs/three.js/build/three.min.js
vendored
1107
libs/three.js/build/three.min.js
vendored
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
Ě]<5D>ż„ž=żaTÜ@±ş»˙|a‚ż›U?ż0LÜ@«µ´˙Ě]<5D>ż›U?żŚÜ@˘©˙Š<1F>ż&俆8ŕ@˘«¨˙±á<C2B1>ż¸żHŕ@ž¤ ˙Ě]<5D>żâXżŮß@śĄ˘˙=<3D>żŕľż–Cß@§®Ş˙Ĺţ‚ż4!żŁ#ß@ ¦˘˙=<3D>żAń#ż–Cß@¬łŻ˙nŁ<6E>żÔ+%żß@›¤Ł˙A‚‚ż„
/ż°ß@• ś˙|a‚żŚżŮß@¶ż¸˙u‚żrůż·bß@¬ł°˙nŁ<6E>ż‚â'żqß@¶±˙Ě]{ż¶„żšwŕ@Š•‘˙{~żî|żAńß@ť¦Ł˙d]|żÔ+%żxzß@ź¨Ą˙R'€żů 'żPüŢ@<40>™”˙›Użš™)żqß@®·µ˙żM,żôŢ@ˇŞ¨˙q}ż
|
||||
hż=á@ˇŞĄ˙ßŕ{żÔšżá@ˇ«˘˙V~ż‚â'ż·bß@ĽĆÁ˙
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,2 +0,0 @@
|
||||
š[?U0À×A)HÿŒJZ?¯”À5^A†¯sÿõ¹J¿sh¿ÛùAÆç’ÿEG2¿ª`¿âéA^‹5ÿ<06>5¿îë¿ÛùARzÿš™¿u“¿×£AY}Cÿ4¿ü©¿TtA:V3ÿç¿!¿ö—A9O,ÿ+¿£¿uA+. ÿDiϾa¿ûËAs<41>RÿÞ¿âX¿9´A48)ÿ?5Þ¾<C39E>&¿ÀA]lTÿ½RÖ¾îë¿f÷Af‰Qÿp_¿sh¿Åþ
|
||||
AyšAÿ˿Ԛ¿³{ A`s9ÿ¯”¿÷ä¿‚s A<>©Fÿb¡¿ü©¿|aA~¦Gÿ-¿<>&¿çŒAd‰<ÿkš¿~Œ¿Š°AY|5ÿåò¿ü©¿
àA`{Pÿ…¿ü©¿_A„}lÿ¿¿Œ¿îëARf8ÿX¿î|¿xAM\0ÿ
|
||||
Binary file not shown.
@ -1 +0,0 @@
|
||||
ŒJZ?ìÀÀ…ëA&:ÿKYV?ÄBÀMóAŒ²vÿgÕW?NÑÀA‡°qÿŒJZ?Ù_À“:AW}5ÿùY?Õ ÀtFA©jÿ~ŒY?€·ÀTRA…¯pÿKYV?f÷ÀjAšÃŠÿu“X?À§yA<>¸‚ÿ
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +0,0 @@
|
||||
u‚¿=
|
||||
¿˜Lá@§¯«ÿª‚<C2AA>¿q=
|
||||
¿˜Lá@ ©¤ÿ|a‚¿û¿µá@ŒŽ‹ÿÌ]ƒ¿ŠŽ¿ÊTá@²·²ÿ=ƒ¿Üh¿Ù_à@’•ŒÿƒÀ‚¿;p¿§à@™Ÿ—ÿ—<C3BF>¿2w
¿Zdá@¯¸´ÿ›U¿ú~
|
||||
¿œá@©²ÿmV}¿?5¿Þ“á@¦¯ªÿ§€¿[±¿)\á@µ¿¹ÿ
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1 +0,0 @@
|
||||
®Øÿ>Sc¾gDá@E@?ÿ£?f÷d¾)\á@KEBÿª`? ^¾¬‹á@QIGÿa?O@S¾œá@YPOÿ’\þ>¨WJ¾ësá@IDAÿ"lø>×£0¾)\á@>9:ÿýöõ>›æ¾˜Lá@956ÿQkú>ˆô¾M„á@713ÿ
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user