296 lines
8.8 KiB
HTML
296 lines
8.8 KiB
HTML
|
|
|
|
<html>
|
|
<head>
|
|
<title>Lion</title>
|
|
<style>canvas { width: 100%; height: 100% }</style>
|
|
</head>
|
|
<body style="margin: 0; padding: 0">
|
|
|
|
<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;
|
|
}
|
|
|
|
a:hover, a:visited, a:link, a:active{
|
|
color: #ccccff;
|
|
text-decoration: none;
|
|
}
|
|
|
|
</style>
|
|
|
|
<script src="../libs/plasio/js/laslaz.js"></script>
|
|
<script src="../libs/plasio/vendor/bluebird.js"></script>
|
|
<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>
|
|
<script src="../src/PointCloudOctree.js"></script>
|
|
<script src="../src/FloatingOrigin.js"></script>
|
|
<script src="../src/TextSprite.js"></script>
|
|
<script src="../src/Materials/PointCloudRGBMaterial.js"></script>
|
|
<script src="../src/FirstPersonControls.js"></script>
|
|
<script src="../src/utils/TranslationTool.js"></script>
|
|
<script src="../src/utils/ProfileTool.js"></script>
|
|
<script src="../src/utils/MeasuringTool.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 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>
|
|
Rue des Oeuches 45<br>
|
|
2740 Moutier<br>
|
|
Switzerland <br>
|
|
|
|
<br>
|
|
Work in Progress of profile and measurement tools.
|
|
Double click to generate measurement point, right click to cancel measurement tool.
|
|
</div>
|
|
|
|
<script>
|
|
var States = {
|
|
DEFAULT: 1,
|
|
PICKING: 2
|
|
};
|
|
|
|
var defaultPointSize = 1.3;
|
|
var defaultLOD = 9;
|
|
var pointcloudPath = "../../../../pointclouds/bruno_friedmann/vol_total/vol_total_bin/cloud.js";
|
|
//var pointcloudPath = "../resources/pointclouds/sorvilier/cloud.js";
|
|
|
|
var renderer;
|
|
var scene, sceneTools, sceneHUD;
|
|
var camera, cameraHUD;
|
|
var pointcloud;
|
|
var skybox;
|
|
var stats;
|
|
var clock = new THREE.Clock();
|
|
var materials = {};
|
|
var floatingOrigin;
|
|
var mouse = { x: 1, y: 1 };
|
|
var state = States.DEFAULT;
|
|
var profile;
|
|
var translationTool;
|
|
var profileTool;
|
|
var measuringTool;
|
|
|
|
function initGUI(){
|
|
|
|
// dat.gui
|
|
var gui = new dat.GUI({
|
|
height : 5 * 32 - 1
|
|
});
|
|
|
|
var params = {
|
|
PointSize: defaultPointSize,
|
|
LOD: defaultLOD,
|
|
"show aabb" : 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, 2.0);
|
|
pPointSize.onChange(function(value){
|
|
pointcloud.material.size = value;
|
|
});
|
|
|
|
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height" ]);
|
|
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;
|
|
}
|
|
|
|
pointcloud.material.size = size;
|
|
|
|
console.log(value);
|
|
});
|
|
|
|
var pBoundingBox = gui.add(params, 'show aabb');
|
|
pBoundingBox.onChange(function(value){
|
|
pointcloud.showBoundingBox = value;
|
|
});
|
|
|
|
// stats
|
|
stats = new Stats();
|
|
stats.domElement.style.position = 'absolute';
|
|
stats.domElement.style.top = '0px';
|
|
stats.domElement.style.margin = '5px';
|
|
document.body.appendChild( stats.domElement );
|
|
|
|
}
|
|
|
|
function initThree(){
|
|
scene = new THREE.Scene();
|
|
sceneHUD = new THREE.Scene();
|
|
sceneTools = new THREE.Scene();
|
|
|
|
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 100000);
|
|
cameraHUD = new THREE.OrthographicCamera( -1, 1, 1, -1, -100, 1000 );
|
|
cameraHUD.lookAt( new THREE.Vector3(0,0,0));
|
|
//floatingOrigin = new FloatingOrigin(camera);
|
|
|
|
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/");
|
|
|
|
// camera and controls
|
|
camera.position.set(5050, 158, -600);
|
|
controls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
|
camera.rotation.order = 'ZYX';
|
|
camera.rotation.x = -0.5;
|
|
camera.rotation.y = -3*Math.PI/4;
|
|
controls.moveSpeed *= 10;
|
|
|
|
// 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: 150});
|
|
|
|
// load pointcloud
|
|
var pco = POCLoader.load(pointcloudPath, {toOrigin: true});
|
|
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);
|
|
|
|
// translation tool
|
|
translationTool = new Potree.TranslationTool();
|
|
sceneTools.add(translationTool);
|
|
|
|
// profile tool
|
|
var forward = new THREE.Vector3(-1, 0, 0);
|
|
var side = new THREE.Vector3(0, 0, -1);
|
|
profileTool = new Potree.ProfileTool(200, 100, 2);
|
|
profileTool.position.set(5147, 108, -400);
|
|
profileTool.setOrientation(forward, side);
|
|
sceneTools.add(profileTool);
|
|
translationTool.setTargets([profileTool]);
|
|
|
|
// profile display
|
|
var profileGeometry = new THREE.BoxGeometry(1,1,1);
|
|
var profileMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff, map: profileTool.rtProfile } );
|
|
profileMaterial.depthTest = false;
|
|
profile = new THREE.Mesh(profileGeometry, profileMaterial);
|
|
profile.scale.set(1,1,1);
|
|
profile.position.set(0, 0, 0);
|
|
sceneHUD.add(profile);
|
|
|
|
// measuring tool
|
|
measuringTool = new Potree.MeasuringTool(scene, camera, renderer.domElement);
|
|
|
|
|
|
//floatingOrigin.addReferenceFrame(pointcloud);
|
|
//floatingOrigin.addReferenceFrame(profileTool);
|
|
//floatingOrigin.addReferenceFrame(translationTool);
|
|
//floatingOrigin.addReferenceFrame(measuringTool.sceneRoot);
|
|
|
|
|
|
|
|
|
|
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
|
|
renderer.domElement.addEventListener( 'mousedown', onMouseDown, true );
|
|
renderer.domElement.addEventListener( 'mouseup', onMouseUp, true );
|
|
}
|
|
|
|
function onMouseUp(){
|
|
translationTool.onMouseUp();
|
|
controls.enabled = true;
|
|
}
|
|
|
|
function onMouseDown(event){
|
|
if(event.which === 1){
|
|
var handled = translationTool.onMouseDown(mouse, camera);
|
|
controls.enabled = !handled;
|
|
}
|
|
}
|
|
|
|
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);
|
|
|
|
renderer.domElement.width = window.innerWidth;
|
|
renderer.domElement.height = window.innerHeight;
|
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
camera.aspect = window.innerWidth / window.innerHeight;
|
|
camera.updateProjectionMatrix();
|
|
//renderer.setSize(renderer.domElement.clientWidth, renderer.domElement.clientHeight);
|
|
|
|
var numVisibleNodes = pointcloud.numVisibleNodes;
|
|
var numVisiblePoints = pointcloud.numVisiblePoints;
|
|
pointcloud.update(camera);
|
|
|
|
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + numVisibleNodes;
|
|
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(numVisiblePoints);
|
|
stats.update();
|
|
|
|
if(translationTool.state == translationTool.STATE.DEFAULT){
|
|
controls.update(clock.getDelta());
|
|
}
|
|
|
|
//floatingOrigin.update();
|
|
|
|
translationTool.onMouseMove(mouse, camera);
|
|
|
|
profileTool.render(renderer, scene);
|
|
profile.scale.x = 0.5;
|
|
profile.scale.y = 0.5 * (renderer.domElement.clientWidth / renderer.domElement.clientHeight) * (profileTool.height / profileTool.width);
|
|
profile.position.x = 0.7;
|
|
profile.position.y = -0.7;
|
|
|
|
|
|
// render skybox
|
|
skybox.camera.rotation.copy(camera.rotation);
|
|
renderer.render(skybox.scene, skybox.camera);
|
|
|
|
// render scenes
|
|
renderer.render(scene, camera);
|
|
renderer.render(sceneTools, camera);
|
|
renderer.render(sceneHUD, cameraHUD);
|
|
renderer.render(measuringTool.sceneMeasurement, camera);
|
|
|
|
};
|
|
|
|
|
|
|
|
initThree();
|
|
initGUI();
|
|
render();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |