295 lines
8.2 KiB
HTML
295 lines
8.2 KiB
HTML
<html>
|
|
<head>
|
|
<meta charset="utf-8"/>
|
|
<title>Lion</title>
|
|
<style>canvas { width: 100%; height: 100% }</style>
|
|
</head>
|
|
<body style="margin: 0; padding: 0">
|
|
|
|
<style type="text/css">
|
|
|
|
#renderArea{
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
.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.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 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;
|
|
var scene;
|
|
var pointcloud;
|
|
var skybox;
|
|
var stats;
|
|
var clock = new THREE.Clock();
|
|
var showSkybox = false;
|
|
|
|
function initGUI(){
|
|
|
|
// dat.gui
|
|
var gui = new dat.GUI({
|
|
height : 5 * 32 - 1
|
|
});
|
|
|
|
var params = {
|
|
"points(m)": pointCountTarget,
|
|
PointSize: pointSize,
|
|
"opacity": opacity,
|
|
"SizeType" : "Adaptive",
|
|
"show octree" : false,
|
|
"Materials" : "RGB",
|
|
"interpolate": interpolate,
|
|
"circles": false,
|
|
"skybox": false
|
|
};
|
|
|
|
var pPoints = gui.add(params, 'points(m)', 0.02, 0.5);
|
|
pPoints.onChange(function(value){
|
|
pointCountTarget = value;
|
|
});
|
|
|
|
var pPointSize = gui.add(params, 'PointSize', 0, 3);
|
|
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", "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
|
|
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(){
|
|
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(fov, aspect, near, far);
|
|
|
|
renderer = new THREE.WebGLRenderer();
|
|
renderer.setSize(width, height);
|
|
renderer.autoClear = false;
|
|
elRenderArea.appendChild(renderer.domElement);
|
|
|
|
skybox = Potree.utils.loadSkybox("../resources/textures/skybox/");
|
|
|
|
// camera and controls
|
|
camera.position.set(3, 7, 6);
|
|
controls = new THREE.OrbitControls(camera, renderer.domElement);
|
|
controls.target.set( 0, 5, 0 );
|
|
camera.lookAt(controls.target);
|
|
|
|
// enable frag_depth extension for the interpolation shader, if available
|
|
renderer.context.getExtension("EXT_frag_depth");
|
|
|
|
// load 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 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);
|
|
|
|
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
|
|
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();
|
|
loop();
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |