228 lines
6.7 KiB
HTML
228 lines
6.7 KiB
HTML
|
|
|
|
<html>
|
|
<head>
|
|
<title>Overpass</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.js"></script>
|
|
<!--
|
|
<script src="../src/Potree.js"></script>
|
|
<script src="../src/loader/LasLazLoader.js"></script>
|
|
<script src="../src/FirstPersonControls.js"></script>
|
|
<script src="../src/PointCloudOctreeGeometry.js"></script>
|
|
<script src="../src/PointCloudOctree.js"></script>
|
|
<script src="../src/loader/POCLoader.js"></script>
|
|
<script src="../src/loader/PointAttributes.js"></script>
|
|
<script src="../src/utils.js"></script>
|
|
<script src="../src/LRU.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: 10px; top: 140px; width: 400px; color:white"> move: w,a,s,d<br>
|
|
rotate: left mouse<br>
|
|
pan: right mouse</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 of an overpass, courtesy of <a href="http://www.surfaceandedge.com/" target="_blank">Surface & Edge</a><br>
|
|
This is to test an octree made laz files which are decoded by the browser using laslaz.js of the <a href="https://github.com/verma/plasio/tree/js-laszip" target="_blank">plas.io js-laszip branch</a>
|
|
</div>
|
|
<!--
|
|
<script>
|
|
var llWorkers = [];
|
|
for(var i = 0; i < 5; i++){
|
|
var wwCode = atob(Potree.workers.laslaz);
|
|
var ww = Potree.utils.createWorker(wwCode);
|
|
llWorkers.push(ww);
|
|
}
|
|
|
|
</script>-->
|
|
|
|
<script>
|
|
var defaultPointSize = 0.04;
|
|
var defaultLOD = 4;
|
|
var defaultFOV = 60;
|
|
var pointcloudPath = "../../../../pointclouds/surface_and_edge/overpass/overpass_laz/cloud.js";
|
|
var pointcloudPath = "../../../../pointclouds/surface_and_edge/overpass/overpass_las/cloud.js";
|
|
var pointcloudPath = "../../../../pointclouds/surface_and_edge/overpass/overpass/cloud.js";
|
|
//var pointcloudPath = "../../../../pointclouds/surface_and_edge/overpass/overpass_2bcolors.las_converted/cloud.js";
|
|
//var pointcloudPath = "http://potree.org/resources/pointclouds/dechen_cave/cloud.js";
|
|
|
|
var renderer;
|
|
var camera;
|
|
var cube;
|
|
var scene;
|
|
var pointCloud;
|
|
var cameraCube, sceneCube;
|
|
var stats;
|
|
var pointcloudMaterial;
|
|
|
|
function loadSkybox(){
|
|
cameraCube = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 100000 );
|
|
sceneCube = new THREE.Scene();
|
|
|
|
var path = "../resources/textures/skybox/";
|
|
var format = ".jpg";
|
|
var urls = [
|
|
path + 'px' + format, path + 'nx' + format,
|
|
path + 'py' + format, path + 'ny' + format,
|
|
path + 'pz' + format, path + 'nz' + format
|
|
];
|
|
|
|
var textureCube = THREE.ImageUtils.loadTextureCube( urls, new THREE.CubeRefractionMapping() );
|
|
var material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube, refractionRatio: 0.95 } );
|
|
|
|
var shader = THREE.ShaderLib[ "cube" ];
|
|
shader.uniforms[ "tCube" ].value = textureCube;
|
|
|
|
var material = new THREE.ShaderMaterial( {
|
|
|
|
fragmentShader: shader.fragmentShader,
|
|
vertexShader: shader.vertexShader,
|
|
uniforms: shader.uniforms,
|
|
depthWrite: false,
|
|
side: THREE.BackSide
|
|
|
|
} ),
|
|
|
|
mesh = new THREE.Mesh( new THREE.BoxGeometry( 100, 100, 100 ), material );
|
|
sceneCube.add( mesh );
|
|
}
|
|
|
|
function initGUI(){
|
|
var gui = new dat.GUI({
|
|
height : 5 * 32 - 1
|
|
});
|
|
|
|
var params = {
|
|
PointSize: defaultPointSize,
|
|
LOD: defaultLOD,
|
|
FOV: defaultFOV,
|
|
|
|
};
|
|
|
|
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 pFOV = gui.add(params, 'FOV', 20, 120);
|
|
pFOV.onChange(function(value){
|
|
camera.fov = value;
|
|
camera.updateProjectionMatrix();
|
|
});
|
|
}
|
|
|
|
function initThree(){
|
|
stats = new Stats();
|
|
stats.domElement.style.position = 'absolute';
|
|
stats.domElement.style.top = '0px';
|
|
stats.domElement.style.margin = '5px';
|
|
document.body.appendChild( stats.domElement );
|
|
|
|
scene = new THREE.Scene();
|
|
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 100000);
|
|
|
|
renderer = new THREE.WebGLRenderer();
|
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
renderer.autoClear = false;
|
|
document.body.appendChild(renderer.domElement);
|
|
|
|
loadSkybox();
|
|
|
|
// camera and controls
|
|
camera.position.set(0,5,10);
|
|
camera.fov = defaultFOV;
|
|
camera.updateProjectionMatrix();
|
|
controls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
|
camera.rotation.order = 'ZYX';
|
|
controls.moveSpeed *= 0.2;
|
|
camera.position.set(-32, 10, -8);
|
|
camera.rotation.set(-0.3, -1.2, 0);
|
|
|
|
pointcloudMaterial = new THREE.PointCloudMaterial( { size: defaultPointSize, vertexColors: true } );
|
|
|
|
// load pointcloud
|
|
var pco = POCLoader.load(pointcloudPath);
|
|
pointCloud = new Potree.PointCloudOctree(pco, pointcloudMaterial);
|
|
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
|
|
));
|
|
|
|
pointCloud.moveToOrigin();
|
|
pointCloud.moveToGroundPlane();
|
|
|
|
scene.add(pointCloud);
|
|
}
|
|
|
|
function render() {
|
|
|
|
requestAnimationFrame(render);
|
|
|
|
pointCloud.update( camera );
|
|
|
|
// render skybox
|
|
cameraCube.rotation.copy( camera.rotation );
|
|
renderer.render( sceneCube, cameraCube );
|
|
|
|
renderer.render(scene, camera);
|
|
|
|
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointCloud.numVisibleNodes;
|
|
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointCloud.numVisiblePoints);
|
|
|
|
stats.update();
|
|
controls.update(0.1);
|
|
|
|
};
|
|
|
|
initThree();
|
|
initGUI();
|
|
render();
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
</html> |