132 lines
4.1 KiB
HTML
132 lines
4.1 KiB
HTML
|
|
|
|
<html>
|
|
<head>
|
|
<title>lion</title>
|
|
<style>canvas { width: 100%; height: 100% }</style>
|
|
</head>
|
|
<body style="margin: 0; padding: 0">
|
|
<script src="../libs/three.js/build/three.js"></script>
|
|
<script src="../libs/other/OrbitControls.js"></script>
|
|
<script src="../src/Potree.js"></script>
|
|
<script src="../src/PointCloudOctree.js"></script>
|
|
<script src="../src/PointCloudOctreeGeometry.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>
|
|
<script>
|
|
var renderer;
|
|
var camera;
|
|
var cube;
|
|
var scene;
|
|
var octreeNodesVisible = 0;
|
|
var pointsVisible = 0;
|
|
var pointCloud;
|
|
var pointClouds = [];
|
|
|
|
function initThree(){
|
|
scene = new THREE.Scene();
|
|
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
|
|
|
|
renderer = new THREE.WebGLRenderer();
|
|
renderer.setSize(window.innerWidth, window.innerHeight);
|
|
document.body.appendChild(renderer.domElement);
|
|
|
|
camera.position.z = 6;
|
|
camera.position.y = 4;
|
|
camera.position.x = 4;
|
|
|
|
var pointLight = new THREE.PointLight(0xffffff);
|
|
pointLight.position.set(10, 10, 10);
|
|
scene.add(pointLight);
|
|
|
|
var ambientLight = new THREE.AmbientLight(0x111111);
|
|
scene.add(ambientLight);
|
|
|
|
controls = new THREE.OrbitControls(camera);
|
|
controls.target.set( 0, 3, 0 );
|
|
camera.lookAt(new THREE.Vector3(0,3,0));
|
|
|
|
var material = new THREE.PointCloudMaterial( { size: 0.02, vertexColors: true } );
|
|
var pco = POCLoader.load("../resources/pointclouds/lion_takanawa/cloud.js");
|
|
|
|
pointCloud = new Potree.PointCloudOctree(pco, material);
|
|
pointCloud.LODDistance = 80;
|
|
pointCloud.rotation.x = Math.PI;
|
|
pointCloud.position.x = 8;
|
|
pointCloud.position.z = -2;
|
|
pointCloud.position.y = 4;
|
|
scene.add(pointCloud);
|
|
|
|
scene.add(createGrid(8,8,1));
|
|
}
|
|
|
|
function onDocumentMouseMove( event ) {
|
|
event.preventDefault();
|
|
|
|
mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
|
|
mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
|
|
}
|
|
|
|
function createGrid(width, length, spacing){
|
|
var material = new THREE.LineBasicMaterial({
|
|
color: 0xBBBBBB
|
|
});
|
|
|
|
var geometry = new THREE.Geometry();
|
|
for(var i = 0; i <= length; i++){
|
|
geometry.vertices.push(new THREE.Vector3(-(spacing*width)/2, 0, i*spacing-(spacing*length)/2));
|
|
geometry.vertices.push(new THREE.Vector3(+(spacing*width)/2, 0, i*spacing-(spacing*length)/2));
|
|
}
|
|
|
|
for(var i = 0; i <= width; i++){
|
|
geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, 0, -(spacing*length)/2));
|
|
geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, 0, +(spacing*length)/2));
|
|
}
|
|
|
|
var line = new THREE.Line(geometry, material, THREE.LinePieces);
|
|
line.receiveShadow = true;
|
|
return line;
|
|
}
|
|
|
|
|
|
var toggle = 0;
|
|
function render() {
|
|
requestAnimationFrame(render);
|
|
|
|
octreeNodesVisible = 0;
|
|
pointsVisible = 0;
|
|
scene.traverse( function ( object ) {
|
|
if ( object instanceof Potree.PointCloudOctree ) {
|
|
object.update( camera );
|
|
}else if(object instanceof THREE.PointCloud){
|
|
if(object.visible){
|
|
octreeNodesVisible++;
|
|
pointsVisible += object.numPoints;
|
|
}
|
|
}
|
|
} );
|
|
|
|
renderer.render(scene, camera);
|
|
|
|
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + octreeNodesVisible;
|
|
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + pointsVisible;
|
|
};
|
|
|
|
initThree();
|
|
render();
|
|
|
|
</script>
|
|
|
|
<div id="lblNumVisibleNodes" style="position: absolute; left: 10px; top: 20px; width: 400px; color:white"></div>
|
|
<div id="lblNumVisiblePoints" style="position: absolute; left: 10px; top: 40px; width: 400px; color:white"></div>
|
|
<div id="lblControl" style="position:absolute; left: 10px; top: 80px; width: 400px; color: white">
|
|
Orbit Controls:<br>
|
|
left mouse button: rotate object<br>
|
|
right mouse button: pan the screen<br>
|
|
scrool wheel: zoom in and out
|
|
</div>
|
|
|
|
</body>
|
|
</html> |