updated examples
This commit is contained in:
parent
6d043cf503
commit
a514b1495a
@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Lion</title>
|
||||
<title>Viewer</title>
|
||||
<style>canvas { width: 100%; height: 100% }</style>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0">
|
||||
@ -28,69 +28,163 @@
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script id="vs" type="x-shader/x-vertex">
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vUv = uv;
|
||||
|
||||
gl_Position = projectionMatrix *
|
||||
modelViewMatrix *
|
||||
vec4(position,1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fs" type="x-shader/x-vertex">
|
||||
|
||||
#extension GL_EXT_frag_depth : enable
|
||||
|
||||
uniform sampler2D depthMap;
|
||||
uniform sampler2D texture;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2D(texture, vUv);
|
||||
float depth = texture2D(depthMap, vUv).g;
|
||||
color = color / color.w;
|
||||
gl_FragColor = color;
|
||||
|
||||
gl_FragDepthEXT = depth;
|
||||
}
|
||||
</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="js/ProgressBar.js"></script>
|
||||
<script src="../examples/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 id="tools" style="position: fixed; width: 340px; bottom: 10px; right: 10px">
|
||||
|
||||
|
||||
<img src="../resources/icons/fps_controls.png"
|
||||
onclick="useFPSControls()"
|
||||
title="Fly Camera"/>
|
||||
|
||||
<img src="../resources/icons/orbit_controls.png"
|
||||
onclick="useOrbitControls()"
|
||||
title="Orbit Controls"/>
|
||||
|
||||
<img src="../resources/icons/focus.png"
|
||||
onclick="camera.zoomTo(pointcloud)"
|
||||
title="focus on pointcloud"/>
|
||||
|
||||
<img src="../resources/icons/flip_y_z.png"
|
||||
onclick="flipYZ()"
|
||||
title="flip y and z coordinates"/>
|
||||
|
||||
|
||||
<img src="../resources/icons/distance.png"
|
||||
onclick="measuringTool.setEnabled(true)"
|
||||
title="distance measurements"/>
|
||||
<img src="../resources/icons/area.png"
|
||||
onclick="areaTool.setEnabled(true)"
|
||||
title="area measurements"/>
|
||||
|
||||
<img src="../resources/icons/volume.png"
|
||||
onclick="volumeTool.startInsertion()"
|
||||
title="volume measurements"/>
|
||||
|
||||
<img src="../resources/icons/profile.png"
|
||||
onclick="profileTool.startInsertion({width: pointcloud.boundingSphere.radius / 100})"
|
||||
title="height profiles"/>
|
||||
|
||||
<img src="../resources/icons/clip_volume.png"
|
||||
onclick="volumeTool.startInsertion({clip: true})"
|
||||
title="clipping volumes"/>
|
||||
|
||||
|
||||
</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>
|
||||
<a href="http://potree.org" target="_blank">potree.org</a>
|
||||
</div>
|
||||
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
var pointSize = 1;
|
||||
var pointCountTarget = 0.4;
|
||||
var pointSize = 1.0 ;
|
||||
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 clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE;
|
||||
var quality = "Normal";
|
||||
var isFlipYZ = false;
|
||||
|
||||
var showStats = false;
|
||||
var showBoundingBox = false;
|
||||
|
||||
var fpControls;
|
||||
var orbitControls;
|
||||
var controls;
|
||||
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa/cloud.js";
|
||||
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
var gui;
|
||||
var renderer;
|
||||
var camera;
|
||||
var scene;
|
||||
var scenePointCloud;
|
||||
var sceneBG, cameraBG;
|
||||
var pointcloud;
|
||||
var skybox;
|
||||
var stats;
|
||||
var clock = new THREE.Clock();
|
||||
var showSkybox = false;
|
||||
var measuringTool;
|
||||
var areaTool;
|
||||
var volumeTool;
|
||||
var transformationTool;
|
||||
var referenceFrame;
|
||||
|
||||
function initGUI(){
|
||||
|
||||
// dat.gui
|
||||
var gui = new dat.GUI({
|
||||
gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
params = {
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": opacity,
|
||||
"SizeType" : "Adaptive",
|
||||
"show octree" : false,
|
||||
"Materials" : "RGB",
|
||||
"interpolate": interpolate,
|
||||
"circles": false,
|
||||
"skybox": false
|
||||
"Clip Mode": "Highlight Inside",
|
||||
"quality": "Normal",
|
||||
"skybox": false,
|
||||
"stats": showStats,
|
||||
"BoundingBox": showBoundingBox
|
||||
};
|
||||
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 0.5);
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 2);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value ;
|
||||
});
|
||||
@ -116,7 +210,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Octree Depth"]);
|
||||
var options = [];
|
||||
if(pointcloud.pcoGeometry.pointAttributes === "LAS" || pointcloud.pcoGeometry.pointAttributes === "LAZ"){
|
||||
options = [
|
||||
"RGB", "Color", "Height", "Intensity", "Intensity Gradient",
|
||||
"Classification", "Return Number", "Source",
|
||||
"Octree Depth"];
|
||||
}else{
|
||||
options = options = [ "RGB", "Color", "Height", "Octree Depth"];
|
||||
}
|
||||
|
||||
pMaterial = gui.add(params, 'Materials',options);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
@ -124,7 +228,16 @@
|
||||
pointColorType = Potree.PointColorType.COLOR;
|
||||
}else if(value === "Height"){
|
||||
pointColorType = Potree.PointColorType.HEIGHT;
|
||||
|
||||
}else if(value === "Intensity"){
|
||||
pointColorType = Potree.PointColorType.INTENSITY;
|
||||
}else if(value === "Intensity Gradient"){
|
||||
pointColorType = Potree.PointColorType.INTENSITY_GRADIENT;
|
||||
}else if(value === "Classification"){
|
||||
pointColorType = Potree.PointColorType.CLASSIFICATION;
|
||||
}else if(value === "Return Number"){
|
||||
pointColorType = Potree.PointColorType.RETURN_NUMBER;
|
||||
}else if(value === "Source"){
|
||||
pointColorType = Potree.PointColorType.SOURCE;
|
||||
}else if(value === "Octree Depth"){
|
||||
pointColorType = Potree.PointColorType.OCTREE_DEPTH;
|
||||
}else if(value === "Point Index"){
|
||||
@ -132,19 +245,19 @@
|
||||
}
|
||||
});
|
||||
|
||||
if(renderer.context.getExtension("EXT_frag_depth")){
|
||||
var pInterpolate = gui.add(params, 'interpolate');
|
||||
pInterpolate.onChange(function(value){
|
||||
interpolate = value;
|
||||
});
|
||||
}
|
||||
var pQuality = gui.add(params, 'quality', [ "Normal", "Circles", "Interpolation", "Splats"]);
|
||||
pQuality.onChange(function(value){
|
||||
quality = value;
|
||||
});
|
||||
|
||||
var pCircular = gui.add(params, 'circles');
|
||||
pCircular.onChange(function(value){
|
||||
if(value){
|
||||
pointShape = Potree.PointShape.CIRCLE;
|
||||
}else{
|
||||
pointShape = Potree.PointShape.SQUARE;
|
||||
var pClipMode = gui.add(params, 'Clip Mode', [ "No Clipping", "Clip Outside", "Highlight Inside"]);
|
||||
pClipMode.onChange(function(value){
|
||||
if(value === "No Clipping"){
|
||||
clipMode = Potree.ClipMode.DISABLED;
|
||||
}else if(value === "Clip Outside"){
|
||||
clipMode = Potree.ClipMode.CLIP_OUTSIDE;
|
||||
}else if(value === "Highlight Inside"){
|
||||
clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE;
|
||||
}
|
||||
});
|
||||
|
||||
@ -152,6 +265,16 @@
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
});
|
||||
|
||||
var pStats = gui.add(params, 'stats');
|
||||
pStats.onChange(function(value){
|
||||
showStats = value;
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'BoundingBox');
|
||||
pBoundingBox.onChange(function(value){
|
||||
showBoundingBox = value;
|
||||
});
|
||||
|
||||
// stats
|
||||
stats = new Stats();
|
||||
@ -167,10 +290,19 @@
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
var far = 1000000;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
scenePointCloud = new THREE.Scene();
|
||||
sceneBG = new THREE.Scene();
|
||||
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
cameraBG = new THREE.Camera();
|
||||
|
||||
camera.rotation.order = 'ZYX';
|
||||
|
||||
referenceFrame = new THREE.Object3D();
|
||||
scenePointCloud.add(referenceFrame);
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(width, height);
|
||||
@ -180,10 +312,13 @@
|
||||
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);
|
||||
camera.position.set(-304, 372, 318);
|
||||
camera.rotation.y = -Math.PI / 4;
|
||||
camera.rotation.x = -Math.PI / 6;
|
||||
useOrbitControls();
|
||||
|
||||
|
||||
controls.moveSpeed *= 10;
|
||||
|
||||
// enable frag_depth extension for the interpolation shader, if available
|
||||
renderer.context.getExtension("EXT_frag_depth");
|
||||
@ -196,36 +331,147 @@
|
||||
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();
|
||||
referenceFrame.add(pointcloud);
|
||||
|
||||
scene.add(pointcloud);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
var sg = pointcloud.boundingSphere.clone().applyMatrix4(pointcloud.matrixWorld);
|
||||
|
||||
referenceFrame.position.copy(sg.center).multiplyScalar(-1);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
|
||||
controls.moveSpeed = pointcloud.boundingSphere.radius / 2;
|
||||
|
||||
camera.zoomTo(pointcloud, 1.2);
|
||||
|
||||
flipYZ();
|
||||
|
||||
initGUI();
|
||||
useOrbitControls();
|
||||
});
|
||||
|
||||
var grid = Potree.utils.createGrid(5, 5, 2);
|
||||
scene.add(grid);
|
||||
|
||||
measuringTool = new Potree.MeasuringTool(scenePointCloud, camera, renderer);
|
||||
profileTool = new Potree.ProfileTool(scenePointCloud, camera, renderer);
|
||||
areaTool = new Potree.AreaTool(scenePointCloud, camera, renderer);
|
||||
volumeTool = new Potree.VolumeTool(scenePointCloud, camera, renderer);
|
||||
transformationTool = new Potree.TransformationTool(scenePointCloud, camera, renderer);
|
||||
|
||||
|
||||
// background
|
||||
// var texture = THREE.ImageUtils.loadTexture( '../resources/textures/background.gif' );
|
||||
var texture = Potree.utils.createBackgroundTexture(512, 512);
|
||||
|
||||
texture.minFilter = texture.magFilter = THREE.NearestFilter;
|
||||
texture.minFilter = texture.magFilter = THREE.LinearFilter;
|
||||
|
||||
var bg = new THREE.Mesh(
|
||||
new THREE.PlaneBufferGeometry(2, 2, 0),
|
||||
new THREE.MeshBasicMaterial({
|
||||
map: texture
|
||||
})
|
||||
);
|
||||
//bg.position.z = -1;
|
||||
bg.material.depthTest = false;
|
||||
bg.material.depthWrite = false;
|
||||
sceneBG.add(bg);
|
||||
|
||||
|
||||
window.addEventListener( 'keydown', onKeyDown, false );
|
||||
}
|
||||
|
||||
function flipYZ(){
|
||||
isFlipYZ = !isFlipYZ;
|
||||
|
||||
if(isFlipYZ){
|
||||
referenceFrame.matrix.copy(new THREE.Matrix4());
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,0,1,0,
|
||||
0,-1,0,0,
|
||||
0,0,0,1
|
||||
));
|
||||
|
||||
}else{
|
||||
referenceFrame.matrix.copy(new THREE.Matrix4());
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,1,0,0,
|
||||
0,0,1,0,
|
||||
0,0,0,1
|
||||
));
|
||||
}
|
||||
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
pointcloud.updateMatrixWorld();
|
||||
var sg = pointcloud.boundingSphere.clone().applyMatrix4(pointcloud.matrixWorld);
|
||||
referenceFrame.position.copy(sg.center).multiplyScalar(-1);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
referenceFrame.position.y -= pointcloud.getWorldPosition().y;
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
}
|
||||
|
||||
function onKeyDown(event){
|
||||
//console.log(event.keyCode);
|
||||
|
||||
if(event.keyCode === 69){
|
||||
// e pressed
|
||||
|
||||
transformationTool.translate();
|
||||
}else if(event.keyCode === 82){
|
||||
// r pressed
|
||||
|
||||
transformationTool.scale();
|
||||
}else if(event.keyCode === 84){
|
||||
// r pressed
|
||||
|
||||
transformationTool.rotate();
|
||||
}
|
||||
};
|
||||
|
||||
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, renderer);
|
||||
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
//pointcloud.material.size = pointSize;
|
||||
//pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
//pointcloud.material.opacity = opacity;
|
||||
//pointcloud.material.pointSizeType = pointSizeType;
|
||||
////pointcloud.material.pointColorType = pointColorType;
|
||||
//pointcloud.material.pointShape = (quality === "High") ? Potree.PointShape.CIRCLE : pointShape;
|
||||
//pointcloud.material.interpolate = (quality === "High");
|
||||
//pointcloud.material.heightMin = bbWorld.min.y;
|
||||
//pointcloud.material.heightMax = bbWorld.max.y;
|
||||
//pointcloud.material.clipMode = clipMode;
|
||||
////pointcloud.material.weighted = false;
|
||||
|
||||
pointcloud.material.clipMode = clipMode;
|
||||
pointcloud.material.heightMin = bbWorld.min.y;
|
||||
pointcloud.material.heightMax = bbWorld.max.y;
|
||||
pointcloud.material.intensityMin = 0;
|
||||
pointcloud.material.intensityMax = 200;
|
||||
pointcloud.showBoundingBox = showBoundingBox;
|
||||
pointcloud.update(camera, renderer);
|
||||
}
|
||||
|
||||
stats.update();
|
||||
if(stats && showStats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "";
|
||||
stats.domElement.style.display = "";
|
||||
|
||||
stats.update();
|
||||
|
||||
if(pointcloud){
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
}else if(stats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "none";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "none";
|
||||
stats.domElement.style.display = "none";
|
||||
}
|
||||
|
||||
controls.update(clock.getDelta());
|
||||
|
||||
@ -245,6 +491,83 @@
|
||||
progressBar.show();
|
||||
progressBar.message = "loading metadata";
|
||||
}
|
||||
|
||||
volumeTool.update();
|
||||
transformationTool.update();
|
||||
profileTool.update();
|
||||
|
||||
|
||||
var clipBoxes = [];
|
||||
|
||||
//var profiles = [];
|
||||
//for(var i = 0; i < profileTool.profiles.length; i++){
|
||||
// profiles.push(profileTool.profiles[i]);
|
||||
//}
|
||||
//if(profileTool.activeProfile){
|
||||
// profiles.push(profileTool.activeProfile);
|
||||
//}
|
||||
for(var i = 0; i < profileTool.profiles.length; i++){
|
||||
var profile = profileTool.profiles[i];
|
||||
|
||||
for(var j = 0; j < profile.boxes.length; j++){
|
||||
var box = profile.boxes[j];
|
||||
box.updateMatrixWorld();
|
||||
var boxInverse = new THREE.Matrix4().getInverse(box.matrixWorld);
|
||||
clipBoxes.push(boxInverse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(var i = 0; i < volumeTool.volumes.length; i++){
|
||||
var volume = volumeTool.volumes[i];
|
||||
|
||||
if(volume.clip){
|
||||
volume.updateMatrixWorld();
|
||||
var boxInverse = new THREE.Matrix4().getInverse(volume.matrixWorld);
|
||||
|
||||
clipBoxes.push(boxInverse);
|
||||
}
|
||||
}
|
||||
|
||||
if(pointcloud){
|
||||
pointcloud.material.setClipBoxes(clipBoxes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//fpControls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
// orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
// controls = fpControls;
|
||||
// orbitControls.enabled = false;
|
||||
|
||||
|
||||
function useFPSControls(){
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!fpControls){
|
||||
fpControls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = fpControls;
|
||||
controls.enabled = true;
|
||||
}
|
||||
|
||||
function useOrbitControls(){
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!orbitControls){
|
||||
orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = orbitControls;
|
||||
controls.enabled = true;
|
||||
|
||||
if(pointcloud){
|
||||
controls.target.copy(pointcloud.boundingSphere.center.clone().applyMatrix4(pointcloud.matrixWorld));
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
@ -263,21 +586,196 @@
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
|
||||
if(pointcloud){
|
||||
if(pointcloud.originalMaterial){
|
||||
pointcloud.material = pointcloud.originalMaterial;
|
||||
}
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = false;
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(scenePointCloud, camera);
|
||||
|
||||
profileTool.render();
|
||||
volumeTool.render();
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
areaTool.render();
|
||||
transformationTool.render();
|
||||
}
|
||||
|
||||
// high quality rendering using splats
|
||||
//
|
||||
var rtDepth = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.NearestFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
var rtNormalize = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
|
||||
var sceneNormalize;
|
||||
|
||||
var depthMaterial, weightedMaterial;
|
||||
|
||||
// render with splats
|
||||
function renderHighQuality(){
|
||||
|
||||
if(!sceneNormalize){
|
||||
sceneNormalize = new THREE.Scene();
|
||||
|
||||
var vsNormalize = document.getElementById('vs').innerHTML;
|
||||
var fsNormalize = document.getElementById('fs').innerHTML;
|
||||
|
||||
var uniformsNormalize = {
|
||||
depthMap: { type: "t", value: rtDepth },
|
||||
texture: { type: "t", value: rtNormalize }
|
||||
};
|
||||
|
||||
var materialNormalize = new THREE.ShaderMaterial({
|
||||
uniforms: uniformsNormalize,
|
||||
vertexShader: vsNormalize,
|
||||
fragmentShader: fsNormalize
|
||||
});
|
||||
|
||||
var quad = new THREE.Mesh( new THREE.PlaneBufferGeometry(2, 2, 0), materialNormalize);
|
||||
quad.material.depthTest = true;
|
||||
quad.material.depthWrite = true;
|
||||
quad.material.transparent = true;
|
||||
sceneNormalize.add(quad);
|
||||
|
||||
}
|
||||
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
rtDepth.setSize(width, height);
|
||||
rtNormalize.setSize(width, height);
|
||||
|
||||
|
||||
renderer.clear();
|
||||
//renderer.render(sceneBG, cameraBG);
|
||||
// render skybox
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
|
||||
if(pointcloud){
|
||||
if(!weightedMaterial){
|
||||
pointcloud.originalMaterial = pointcloud.material;
|
||||
depthMaterial = new Potree.PointCloudMaterial();
|
||||
weightedMaterial = new Potree.PointCloudMaterial();
|
||||
}
|
||||
|
||||
pointcloud.material = depthMaterial;
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
// get rid of this
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = Potree.PointColorType.DEPTH;
|
||||
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolate");
|
||||
pointcloud.material.weighted = false;
|
||||
|
||||
pointcloud.material.minSize = 2;
|
||||
pointcloud.material.screenWidth = width;
|
||||
pointcloud.material.screenHeight = height;
|
||||
|
||||
pointcloud.update(camera, renderer);
|
||||
|
||||
renderer.clearTarget( rtDepth, true, true, true );
|
||||
renderer.clearTarget( rtNormalize, true, true, true );
|
||||
|
||||
var origType = pointcloud.material.pointColorType;
|
||||
renderer.render(scenePointCloud, camera, rtDepth);
|
||||
|
||||
pointcloud.material = weightedMaterial;
|
||||
|
||||
|
||||
|
||||
// get rid of this
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = true;
|
||||
|
||||
pointcloud.material.depthMap = rtDepth;
|
||||
pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20);
|
||||
pointcloud.update(camera, renderer);
|
||||
renderer.render(scenePointCloud, camera, rtNormalize);
|
||||
|
||||
|
||||
volumeTool.render();
|
||||
profileTool.render();
|
||||
renderer.render(sceneNormalize, cameraBG);
|
||||
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
areaTool.render();
|
||||
transformationTool.render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function loop() {
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
|
||||
if(quality === "Splats"){
|
||||
renderHighQuality();
|
||||
}else{
|
||||
render();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
//initGUI();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Lion</title>
|
||||
<title>Viewer</title>
|
||||
<style>canvas { width: 100%; height: 100% }</style>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0">
|
||||
@ -28,6 +28,37 @@
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script id="vs" type="x-shader/x-vertex">
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vUv = uv;
|
||||
|
||||
gl_Position = projectionMatrix *
|
||||
modelViewMatrix *
|
||||
vec4(position,1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fs" type="x-shader/x-vertex">
|
||||
|
||||
#extension GL_EXT_frag_depth : enable
|
||||
|
||||
uniform sampler2D depthMap;
|
||||
uniform sampler2D texture;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2D(texture, vUv);
|
||||
float depth = texture2D(depthMap, vUv).g;
|
||||
color = color / color.w;
|
||||
gl_FragColor = color;
|
||||
|
||||
gl_FragDepthEXT = depth;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
<script src="../libs/plasio/vendor/bluebird.js"></script>
|
||||
@ -38,64 +69,130 @@
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="../build/js/laslaz.js"></script>
|
||||
<script src="js/ProgressBar.js"></script>
|
||||
<script src="../examples/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 id="tools" style="position: fixed; width: 340px; bottom: 10px; right: 10px">
|
||||
|
||||
|
||||
<img src="../resources/icons/fps_controls.png"
|
||||
onclick="useFPSControls()"
|
||||
title="Fly Camera"/>
|
||||
|
||||
<img src="../resources/icons/orbit_controls.png"
|
||||
onclick="useOrbitControls()"
|
||||
title="Orbit Controls"/>
|
||||
|
||||
<img src="../resources/icons/focus.png"
|
||||
onclick="camera.zoomTo(pointcloud)"
|
||||
title="focus on pointcloud"/>
|
||||
|
||||
<img src="../resources/icons/flip_y_z.png"
|
||||
onclick="flipYZ()"
|
||||
title="flip y and z coordinates"/>
|
||||
|
||||
|
||||
<img src="../resources/icons/distance.png"
|
||||
onclick="measuringTool.setEnabled(true)"
|
||||
title="distance measurements"/>
|
||||
<img src="../resources/icons/area.png"
|
||||
onclick="areaTool.setEnabled(true)"
|
||||
title="area measurements"/>
|
||||
|
||||
<img src="../resources/icons/volume.png"
|
||||
onclick="volumeTool.startInsertion()"
|
||||
title="volume measurements"/>
|
||||
|
||||
<img src="../resources/icons/profile.png"
|
||||
onclick="profileTool.startInsertion({width: pointcloud.boundingSphere.radius / 100})"
|
||||
title="height profiles"/>
|
||||
|
||||
<img src="../resources/icons/clip_volume.png"
|
||||
onclick="volumeTool.startInsertion({clip: true})"
|
||||
title="clipping volumes"/>
|
||||
|
||||
|
||||
</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>
|
||||
<a href="http://potree.org" target="_blank">potree.org</a>
|
||||
</div>
|
||||
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
var pointSize = 1;
|
||||
var pointCountTarget = 0.4;
|
||||
var pointSize = 1.0 ;
|
||||
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 clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE;
|
||||
var quality = "Normal";
|
||||
var isFlipYZ = false;
|
||||
|
||||
var showStats = false;
|
||||
var showBoundingBox = false;
|
||||
|
||||
var fpControls;
|
||||
var orbitControls;
|
||||
var controls;
|
||||
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
|
||||
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa_las/cloud.js";
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa_las/cloud.js";
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
var gui;
|
||||
var renderer;
|
||||
var camera;
|
||||
var scene;
|
||||
var scenePointCloud;
|
||||
var sceneBG, cameraBG;
|
||||
var pointcloud;
|
||||
var skybox;
|
||||
var stats;
|
||||
var clock = new THREE.Clock();
|
||||
var showSkybox = false;
|
||||
var measuringTool;
|
||||
var areaTool;
|
||||
var volumeTool;
|
||||
var transformationTool;
|
||||
var referenceFrame;
|
||||
|
||||
function initGUI(){
|
||||
|
||||
// dat.gui
|
||||
var gui = new dat.GUI({
|
||||
gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
params = {
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": opacity,
|
||||
"SizeType" : "Adaptive",
|
||||
"show octree" : false,
|
||||
"Materials" : "RGB",
|
||||
"interpolate": interpolate,
|
||||
"circles": false,
|
||||
"skybox": false
|
||||
"Clip Mode": "Highlight Inside",
|
||||
"quality": "Normal",
|
||||
"skybox": false,
|
||||
"stats": showStats,
|
||||
"BoundingBox": showBoundingBox
|
||||
};
|
||||
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 0.5);
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 2);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value;
|
||||
pointCountTarget = value ;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0, 3);
|
||||
@ -119,7 +216,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Intensity", "Intensity Gradient", "Octree Depth"]);
|
||||
var options = [];
|
||||
if(pointcloud.pcoGeometry.pointAttributes === "LAS" || pointcloud.pcoGeometry.pointAttributes === "LAZ"){
|
||||
options = [
|
||||
"RGB", "Color", "Height", "Intensity", "Intensity Gradient",
|
||||
"Classification", "Return Number", "Source",
|
||||
"Octree Depth"];
|
||||
}else{
|
||||
options = options = [ "RGB", "Color", "Height", "Octree Depth"];
|
||||
}
|
||||
|
||||
pMaterial = gui.add(params, 'Materials',options);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
@ -127,31 +234,36 @@
|
||||
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;
|
||||
}else if(value === "Classification"){
|
||||
pointColorType = Potree.PointColorType.CLASSIFICATION;
|
||||
}else if(value === "Return Number"){
|
||||
pointColorType = Potree.PointColorType.RETURN_NUMBER;
|
||||
}else if(value === "Source"){
|
||||
pointColorType = Potree.PointColorType.SOURCE;
|
||||
}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 pQuality = gui.add(params, 'quality', [ "Normal", "Circles", "Interpolation", "Splats"]);
|
||||
pQuality.onChange(function(value){
|
||||
quality = value;
|
||||
});
|
||||
|
||||
var pCircular = gui.add(params, 'circles');
|
||||
pCircular.onChange(function(value){
|
||||
if(value){
|
||||
pointShape = Potree.PointShape.CIRCLE;
|
||||
}else{
|
||||
pointShape = Potree.PointShape.SQUARE;
|
||||
var pClipMode = gui.add(params, 'Clip Mode', [ "No Clipping", "Clip Outside", "Highlight Inside"]);
|
||||
pClipMode.onChange(function(value){
|
||||
if(value === "No Clipping"){
|
||||
clipMode = Potree.ClipMode.DISABLED;
|
||||
}else if(value === "Clip Outside"){
|
||||
clipMode = Potree.ClipMode.CLIP_OUTSIDE;
|
||||
}else if(value === "Highlight Inside"){
|
||||
clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE;
|
||||
}
|
||||
});
|
||||
|
||||
@ -159,6 +271,16 @@
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
});
|
||||
|
||||
var pStats = gui.add(params, 'stats');
|
||||
pStats.onChange(function(value){
|
||||
showStats = value;
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'BoundingBox');
|
||||
pBoundingBox.onChange(function(value){
|
||||
showBoundingBox = value;
|
||||
});
|
||||
|
||||
// stats
|
||||
stats = new Stats();
|
||||
@ -174,10 +296,19 @@
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
var far = 1000000;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
scenePointCloud = new THREE.Scene();
|
||||
sceneBG = new THREE.Scene();
|
||||
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
//camera = new THREE.OrthographicCamera(-50, 50, 50, -50, 1, 100000);
|
||||
cameraBG = new THREE.Camera();
|
||||
camera.rotation.order = 'ZYX';
|
||||
|
||||
referenceFrame = new THREE.Object3D();
|
||||
scenePointCloud.add(referenceFrame);
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(width, height);
|
||||
@ -187,10 +318,13 @@
|
||||
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);
|
||||
camera.position.set(-304, 372, 318);
|
||||
camera.rotation.y = -Math.PI / 4;
|
||||
camera.rotation.x = -Math.PI / 6;
|
||||
useOrbitControls();
|
||||
|
||||
|
||||
controls.moveSpeed *= 10;
|
||||
|
||||
// enable frag_depth extension for the interpolation shader, if available
|
||||
renderer.context.getExtension("EXT_frag_depth");
|
||||
@ -203,38 +337,147 @@
|
||||
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();
|
||||
referenceFrame.add(pointcloud);
|
||||
|
||||
scene.add(pointcloud);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
var sg = pointcloud.boundingSphere.clone().applyMatrix4(pointcloud.matrixWorld);
|
||||
|
||||
referenceFrame.position.copy(sg.center).multiplyScalar(-1);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
|
||||
controls.moveSpeed = pointcloud.boundingSphere.radius / 2;
|
||||
|
||||
camera.zoomTo(pointcloud, 1.2);
|
||||
|
||||
flipYZ();
|
||||
|
||||
initGUI();
|
||||
useOrbitControls();
|
||||
});
|
||||
|
||||
var grid = Potree.utils.createGrid(5, 5, 2);
|
||||
scene.add(grid);
|
||||
|
||||
measuringTool = new Potree.MeasuringTool(scenePointCloud, camera, renderer);
|
||||
profileTool = new Potree.ProfileTool(scenePointCloud, camera, renderer);
|
||||
areaTool = new Potree.AreaTool(scenePointCloud, camera, renderer);
|
||||
volumeTool = new Potree.VolumeTool(scenePointCloud, camera, renderer);
|
||||
transformationTool = new Potree.TransformationTool(scenePointCloud, camera, renderer);
|
||||
|
||||
|
||||
// background
|
||||
// var texture = THREE.ImageUtils.loadTexture( '../resources/textures/background.gif' );
|
||||
var texture = Potree.utils.createBackgroundTexture(512, 512);
|
||||
|
||||
texture.minFilter = texture.magFilter = THREE.NearestFilter;
|
||||
texture.minFilter = texture.magFilter = THREE.LinearFilter;
|
||||
|
||||
var bg = new THREE.Mesh(
|
||||
new THREE.PlaneBufferGeometry(2, 2, 0),
|
||||
new THREE.MeshBasicMaterial({
|
||||
map: texture
|
||||
})
|
||||
);
|
||||
//bg.position.z = -1;
|
||||
bg.material.depthTest = false;
|
||||
bg.material.depthWrite = false;
|
||||
sceneBG.add(bg);
|
||||
|
||||
|
||||
window.addEventListener( 'keydown', onKeyDown, false );
|
||||
}
|
||||
|
||||
function flipYZ(){
|
||||
isFlipYZ = !isFlipYZ;
|
||||
|
||||
if(isFlipYZ){
|
||||
referenceFrame.matrix.copy(new THREE.Matrix4());
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,0,1,0,
|
||||
0,-1,0,0,
|
||||
0,0,0,1
|
||||
));
|
||||
|
||||
}else{
|
||||
referenceFrame.matrix.copy(new THREE.Matrix4());
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,1,0,0,
|
||||
0,0,1,0,
|
||||
0,0,0,1
|
||||
));
|
||||
}
|
||||
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
pointcloud.updateMatrixWorld();
|
||||
var sg = pointcloud.boundingSphere.clone().applyMatrix4(pointcloud.matrixWorld);
|
||||
referenceFrame.position.copy(sg.center).multiplyScalar(-1);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
referenceFrame.position.y -= pointcloud.getWorldPosition().y;
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
}
|
||||
|
||||
function onKeyDown(event){
|
||||
//console.log(event.keyCode);
|
||||
|
||||
if(event.keyCode === 69){
|
||||
// e pressed
|
||||
|
||||
transformationTool.translate();
|
||||
}else if(event.keyCode === 82){
|
||||
// r pressed
|
||||
|
||||
transformationTool.scale();
|
||||
}else if(event.keyCode === 84){
|
||||
// r pressed
|
||||
|
||||
transformationTool.rotate();
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
//pointcloud.material.size = pointSize;
|
||||
//pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
//pointcloud.material.opacity = opacity;
|
||||
//pointcloud.material.pointSizeType = pointSizeType;
|
||||
////pointcloud.material.pointColorType = pointColorType;
|
||||
//pointcloud.material.pointShape = (quality === "High") ? Potree.PointShape.CIRCLE : pointShape;
|
||||
//pointcloud.material.interpolate = (quality === "High");
|
||||
//pointcloud.material.heightMin = bbWorld.min.y;
|
||||
//pointcloud.material.heightMax = bbWorld.max.y;
|
||||
//pointcloud.material.clipMode = clipMode;
|
||||
////pointcloud.material.weighted = false;
|
||||
|
||||
pointcloud.material.clipMode = clipMode;
|
||||
pointcloud.material.heightMin = bbWorld.min.y;
|
||||
pointcloud.material.heightMax = bbWorld.max.y;
|
||||
pointcloud.material.intensityMin = 0;
|
||||
pointcloud.material.intensityMax = 65000;
|
||||
|
||||
pointcloud.showBoundingBox = showBoundingBox;
|
||||
pointcloud.update(camera, renderer);
|
||||
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
|
||||
stats.update();
|
||||
if(stats && showStats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "";
|
||||
stats.domElement.style.display = "";
|
||||
|
||||
stats.update();
|
||||
|
||||
if(pointcloud){
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
}else if(stats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "none";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "none";
|
||||
stats.domElement.style.display = "none";
|
||||
}
|
||||
|
||||
controls.update(clock.getDelta());
|
||||
|
||||
@ -254,6 +497,77 @@
|
||||
progressBar.show();
|
||||
progressBar.message = "loading metadata";
|
||||
}
|
||||
|
||||
volumeTool.update();
|
||||
transformationTool.update();
|
||||
profileTool.update();
|
||||
|
||||
|
||||
var clipBoxes = [];
|
||||
|
||||
//var profiles = [];
|
||||
//for(var i = 0; i < profileTool.profiles.length; i++){
|
||||
// profiles.push(profileTool.profiles[i]);
|
||||
//}
|
||||
//if(profileTool.activeProfile){
|
||||
// profiles.push(profileTool.activeProfile);
|
||||
//}
|
||||
for(var i = 0; i < profileTool.profiles.length; i++){
|
||||
var profile = profileTool.profiles[i];
|
||||
|
||||
for(var j = 0; j < profile.boxes.length; j++){
|
||||
var box = profile.boxes[j];
|
||||
box.updateMatrixWorld();
|
||||
var boxInverse = new THREE.Matrix4().getInverse(box.matrixWorld);
|
||||
clipBoxes.push(boxInverse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(var i = 0; i < volumeTool.volumes.length; i++){
|
||||
var volume = volumeTool.volumes[i];
|
||||
|
||||
if(volume.clip){
|
||||
volume.updateMatrixWorld();
|
||||
var boxInverse = new THREE.Matrix4().getInverse(volume.matrixWorld);
|
||||
|
||||
clipBoxes.push(boxInverse);
|
||||
}
|
||||
}
|
||||
|
||||
if(pointcloud){
|
||||
pointcloud.material.setClipBoxes(clipBoxes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function useFPSControls(){
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!fpControls){
|
||||
fpControls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = fpControls;
|
||||
controls.enabled = true;
|
||||
}
|
||||
|
||||
function useOrbitControls(){
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!orbitControls){
|
||||
orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = orbitControls;
|
||||
controls.enabled = true;
|
||||
|
||||
if(pointcloud){
|
||||
controls.target.copy(pointcloud.boundingSphere.center.clone().applyMatrix4(pointcloud.matrixWorld));
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
@ -272,21 +586,196 @@
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
|
||||
if(pointcloud){
|
||||
if(pointcloud.originalMaterial){
|
||||
pointcloud.material = pointcloud.originalMaterial;
|
||||
}
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = false;
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(scenePointCloud, camera);
|
||||
|
||||
profileTool.render();
|
||||
volumeTool.render();
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
areaTool.render();
|
||||
transformationTool.render();
|
||||
}
|
||||
|
||||
// high quality rendering using splats
|
||||
//
|
||||
var rtDepth = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.NearestFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
var rtNormalize = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
|
||||
var sceneNormalize;
|
||||
|
||||
var depthMaterial, weightedMaterial;
|
||||
|
||||
// render with splats
|
||||
function renderHighQuality(){
|
||||
|
||||
if(!sceneNormalize){
|
||||
sceneNormalize = new THREE.Scene();
|
||||
|
||||
var vsNormalize = document.getElementById('vs').innerHTML;
|
||||
var fsNormalize = document.getElementById('fs').innerHTML;
|
||||
|
||||
var uniformsNormalize = {
|
||||
depthMap: { type: "t", value: rtDepth },
|
||||
texture: { type: "t", value: rtNormalize }
|
||||
};
|
||||
|
||||
var materialNormalize = new THREE.ShaderMaterial({
|
||||
uniforms: uniformsNormalize,
|
||||
vertexShader: vsNormalize,
|
||||
fragmentShader: fsNormalize
|
||||
});
|
||||
|
||||
var quad = new THREE.Mesh( new THREE.PlaneBufferGeometry(2, 2, 0), materialNormalize);
|
||||
quad.material.depthTest = true;
|
||||
quad.material.depthWrite = true;
|
||||
quad.material.transparent = true;
|
||||
sceneNormalize.add(quad);
|
||||
|
||||
}
|
||||
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
rtDepth.setSize(width, height);
|
||||
rtNormalize.setSize(width, height);
|
||||
|
||||
|
||||
renderer.clear();
|
||||
//renderer.render(sceneBG, cameraBG);
|
||||
// render skybox
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
|
||||
if(pointcloud){
|
||||
if(!weightedMaterial){
|
||||
pointcloud.originalMaterial = pointcloud.material;
|
||||
depthMaterial = new Potree.PointCloudMaterial();
|
||||
weightedMaterial = new Potree.PointCloudMaterial();
|
||||
}
|
||||
|
||||
pointcloud.material = depthMaterial;
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
// get rid of this
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = Potree.PointColorType.DEPTH;
|
||||
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolate");
|
||||
pointcloud.material.weighted = false;
|
||||
|
||||
pointcloud.material.minSize = 2;
|
||||
pointcloud.material.screenWidth = width;
|
||||
pointcloud.material.screenHeight = height;
|
||||
|
||||
pointcloud.update(camera, renderer);
|
||||
|
||||
renderer.clearTarget( rtDepth, true, true, true );
|
||||
renderer.clearTarget( rtNormalize, true, true, true );
|
||||
|
||||
var origType = pointcloud.material.pointColorType;
|
||||
renderer.render(scenePointCloud, camera, rtDepth);
|
||||
|
||||
pointcloud.material = weightedMaterial;
|
||||
|
||||
|
||||
|
||||
// get rid of this
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = true;
|
||||
|
||||
pointcloud.material.depthMap = rtDepth;
|
||||
pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20);
|
||||
pointcloud.update(camera, renderer);
|
||||
renderer.render(scenePointCloud, camera, rtNormalize);
|
||||
|
||||
|
||||
volumeTool.render();
|
||||
profileTool.render();
|
||||
renderer.render(sceneNormalize, cameraBG);
|
||||
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
areaTool.render();
|
||||
transformationTool.render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function loop() {
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
|
||||
if(quality === "Splats"){
|
||||
renderHighQuality();
|
||||
}else{
|
||||
render();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
//initGUI();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>Lion</title>
|
||||
<title>Viewer</title>
|
||||
<style>canvas { width: 100%; height: 100% }</style>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0">
|
||||
@ -28,6 +28,37 @@
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<script id="vs" type="x-shader/x-vertex">
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vUv = uv;
|
||||
|
||||
gl_Position = projectionMatrix *
|
||||
modelViewMatrix *
|
||||
vec4(position,1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="fs" type="x-shader/x-vertex">
|
||||
|
||||
#extension GL_EXT_frag_depth : enable
|
||||
|
||||
uniform sampler2D depthMap;
|
||||
uniform sampler2D texture;
|
||||
|
||||
varying vec2 vUv;
|
||||
|
||||
void main() {
|
||||
vec4 color = texture2D(texture, vUv);
|
||||
float depth = texture2D(depthMap, vUv).g;
|
||||
color = color / color.w;
|
||||
gl_FragColor = color;
|
||||
|
||||
gl_FragDepthEXT = depth;
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
<script src="../libs/plasio/vendor/bluebird.js"></script>
|
||||
@ -38,64 +69,130 @@
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="../build/js/laslaz.js"></script>
|
||||
<script src="js/ProgressBar.js"></script>
|
||||
<script src="../examples/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 id="tools" style="position: fixed; width: 340px; bottom: 10px; right: 10px">
|
||||
|
||||
|
||||
<img src="../resources/icons/fps_controls.png"
|
||||
onclick="useFPSControls()"
|
||||
title="Fly Camera"/>
|
||||
|
||||
<img src="../resources/icons/orbit_controls.png"
|
||||
onclick="useOrbitControls()"
|
||||
title="Orbit Controls"/>
|
||||
|
||||
<img src="../resources/icons/focus.png"
|
||||
onclick="camera.zoomTo(pointcloud)"
|
||||
title="focus on pointcloud"/>
|
||||
|
||||
<img src="../resources/icons/flip_y_z.png"
|
||||
onclick="flipYZ()"
|
||||
title="flip y and z coordinates"/>
|
||||
|
||||
|
||||
<img src="../resources/icons/distance.png"
|
||||
onclick="measuringTool.setEnabled(true)"
|
||||
title="distance measurements"/>
|
||||
<img src="../resources/icons/area.png"
|
||||
onclick="areaTool.setEnabled(true)"
|
||||
title="area measurements"/>
|
||||
|
||||
<img src="../resources/icons/volume.png"
|
||||
onclick="volumeTool.startInsertion()"
|
||||
title="volume measurements"/>
|
||||
|
||||
<img src="../resources/icons/profile.png"
|
||||
onclick="profileTool.startInsertion({width: pointcloud.boundingSphere.radius / 100})"
|
||||
title="height profiles"/>
|
||||
|
||||
<img src="../resources/icons/clip_volume.png"
|
||||
onclick="volumeTool.startInsertion({clip: true})"
|
||||
title="clipping volumes"/>
|
||||
|
||||
|
||||
</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>
|
||||
<a href="http://potree.org" target="_blank">potree.org</a>
|
||||
</div>
|
||||
|
||||
<div id="renderArea"></div>
|
||||
|
||||
<script>
|
||||
var pointSize = 1;
|
||||
var pointCountTarget = 0.4;
|
||||
var pointSize = 1.0 ;
|
||||
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 clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE;
|
||||
var quality = "Normal";
|
||||
var isFlipYZ = false;
|
||||
|
||||
var showStats = false;
|
||||
var showBoundingBox = false;
|
||||
|
||||
var fpControls;
|
||||
var orbitControls;
|
||||
var controls;
|
||||
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
|
||||
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa_laz/cloud.js";
|
||||
|
||||
var pointcloudPath = "../resources/pointclouds/lion_takanawa_laz/cloud.js";
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
var gui;
|
||||
var renderer;
|
||||
var camera;
|
||||
var scene;
|
||||
var scenePointCloud;
|
||||
var sceneBG, cameraBG;
|
||||
var pointcloud;
|
||||
var skybox;
|
||||
var stats;
|
||||
var clock = new THREE.Clock();
|
||||
var showSkybox = false;
|
||||
var measuringTool;
|
||||
var areaTool;
|
||||
var volumeTool;
|
||||
var transformationTool;
|
||||
var referenceFrame;
|
||||
|
||||
function initGUI(){
|
||||
|
||||
// dat.gui
|
||||
var gui = new dat.GUI({
|
||||
gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
params = {
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": opacity,
|
||||
"SizeType" : "Adaptive",
|
||||
"show octree" : false,
|
||||
"Materials" : "RGB",
|
||||
"interpolate": interpolate,
|
||||
"circles": false,
|
||||
"skybox": false
|
||||
"Clip Mode": "Highlight Inside",
|
||||
"quality": "Normal",
|
||||
"skybox": false,
|
||||
"stats": showStats,
|
||||
"BoundingBox": showBoundingBox
|
||||
};
|
||||
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 0.5);
|
||||
var pPoints = gui.add(params, 'points(m)', 0.02, 2);
|
||||
pPoints.onChange(function(value){
|
||||
pointCountTarget = value;
|
||||
pointCountTarget = value ;
|
||||
});
|
||||
|
||||
var pPointSize = gui.add(params, 'PointSize', 0, 3);
|
||||
@ -119,7 +216,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [ "RGB", "Color", "Height", "Intensity", "Intensity Gradient", "Octree Depth"]);
|
||||
var options = [];
|
||||
if(pointcloud.pcoGeometry.pointAttributes === "LAS" || pointcloud.pcoGeometry.pointAttributes === "LAZ"){
|
||||
options = [
|
||||
"RGB", "Color", "Height", "Intensity", "Intensity Gradient",
|
||||
"Classification", "Return Number", "Source",
|
||||
"Octree Depth"];
|
||||
}else{
|
||||
options = options = [ "RGB", "Color", "Height", "Octree Depth"];
|
||||
}
|
||||
|
||||
pMaterial = gui.add(params, 'Materials',options);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
@ -127,31 +234,36 @@
|
||||
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;
|
||||
}else if(value === "Classification"){
|
||||
pointColorType = Potree.PointColorType.CLASSIFICATION;
|
||||
}else if(value === "Return Number"){
|
||||
pointColorType = Potree.PointColorType.RETURN_NUMBER;
|
||||
}else if(value === "Source"){
|
||||
pointColorType = Potree.PointColorType.SOURCE;
|
||||
}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 pQuality = gui.add(params, 'quality', [ "Normal", "Circles", "Interpolation", "Splats"]);
|
||||
pQuality.onChange(function(value){
|
||||
quality = value;
|
||||
});
|
||||
|
||||
var pCircular = gui.add(params, 'circles');
|
||||
pCircular.onChange(function(value){
|
||||
if(value){
|
||||
pointShape = Potree.PointShape.CIRCLE;
|
||||
}else{
|
||||
pointShape = Potree.PointShape.SQUARE;
|
||||
var pClipMode = gui.add(params, 'Clip Mode', [ "No Clipping", "Clip Outside", "Highlight Inside"]);
|
||||
pClipMode.onChange(function(value){
|
||||
if(value === "No Clipping"){
|
||||
clipMode = Potree.ClipMode.DISABLED;
|
||||
}else if(value === "Clip Outside"){
|
||||
clipMode = Potree.ClipMode.CLIP_OUTSIDE;
|
||||
}else if(value === "Highlight Inside"){
|
||||
clipMode = Potree.ClipMode.HIGHLIGHT_INSIDE;
|
||||
}
|
||||
});
|
||||
|
||||
@ -159,6 +271,16 @@
|
||||
pSykbox.onChange(function(value){
|
||||
showSkybox = value;
|
||||
});
|
||||
|
||||
var pStats = gui.add(params, 'stats');
|
||||
pStats.onChange(function(value){
|
||||
showStats = value;
|
||||
});
|
||||
|
||||
var pBoundingBox = gui.add(params, 'BoundingBox');
|
||||
pBoundingBox.onChange(function(value){
|
||||
showBoundingBox = value;
|
||||
});
|
||||
|
||||
// stats
|
||||
stats = new Stats();
|
||||
@ -174,10 +296,19 @@
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
var near = 0.1;
|
||||
var far = 100000;
|
||||
var far = 1000000;
|
||||
|
||||
scene = new THREE.Scene();
|
||||
scenePointCloud = new THREE.Scene();
|
||||
sceneBG = new THREE.Scene();
|
||||
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
//camera = new THREE.OrthographicCamera(-50, 50, 50, -50, 1, 100000);
|
||||
cameraBG = new THREE.Camera();
|
||||
camera.rotation.order = 'ZYX';
|
||||
|
||||
referenceFrame = new THREE.Object3D();
|
||||
scenePointCloud.add(referenceFrame);
|
||||
|
||||
renderer = new THREE.WebGLRenderer();
|
||||
renderer.setSize(width, height);
|
||||
@ -187,10 +318,13 @@
|
||||
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);
|
||||
camera.position.set(-304, 372, 318);
|
||||
camera.rotation.y = -Math.PI / 4;
|
||||
camera.rotation.x = -Math.PI / 6;
|
||||
useOrbitControls();
|
||||
|
||||
|
||||
controls.moveSpeed *= 10;
|
||||
|
||||
// enable frag_depth extension for the interpolation shader, if available
|
||||
renderer.context.getExtension("EXT_frag_depth");
|
||||
@ -203,38 +337,147 @@
|
||||
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();
|
||||
referenceFrame.add(pointcloud);
|
||||
|
||||
scene.add(pointcloud);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
var sg = pointcloud.boundingSphere.clone().applyMatrix4(pointcloud.matrixWorld);
|
||||
|
||||
referenceFrame.position.copy(sg.center).multiplyScalar(-1);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
|
||||
controls.moveSpeed = pointcloud.boundingSphere.radius / 2;
|
||||
|
||||
camera.zoomTo(pointcloud, 1.2);
|
||||
|
||||
flipYZ();
|
||||
|
||||
initGUI();
|
||||
useOrbitControls();
|
||||
});
|
||||
|
||||
var grid = Potree.utils.createGrid(5, 5, 2);
|
||||
scene.add(grid);
|
||||
|
||||
measuringTool = new Potree.MeasuringTool(scenePointCloud, camera, renderer);
|
||||
profileTool = new Potree.ProfileTool(scenePointCloud, camera, renderer);
|
||||
areaTool = new Potree.AreaTool(scenePointCloud, camera, renderer);
|
||||
volumeTool = new Potree.VolumeTool(scenePointCloud, camera, renderer);
|
||||
transformationTool = new Potree.TransformationTool(scenePointCloud, camera, renderer);
|
||||
|
||||
|
||||
// background
|
||||
// var texture = THREE.ImageUtils.loadTexture( '../resources/textures/background.gif' );
|
||||
var texture = Potree.utils.createBackgroundTexture(512, 512);
|
||||
|
||||
texture.minFilter = texture.magFilter = THREE.NearestFilter;
|
||||
texture.minFilter = texture.magFilter = THREE.LinearFilter;
|
||||
|
||||
var bg = new THREE.Mesh(
|
||||
new THREE.PlaneBufferGeometry(2, 2, 0),
|
||||
new THREE.MeshBasicMaterial({
|
||||
map: texture
|
||||
})
|
||||
);
|
||||
//bg.position.z = -1;
|
||||
bg.material.depthTest = false;
|
||||
bg.material.depthWrite = false;
|
||||
sceneBG.add(bg);
|
||||
|
||||
|
||||
window.addEventListener( 'keydown', onKeyDown, false );
|
||||
}
|
||||
|
||||
function flipYZ(){
|
||||
isFlipYZ = !isFlipYZ;
|
||||
|
||||
if(isFlipYZ){
|
||||
referenceFrame.matrix.copy(new THREE.Matrix4());
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,0,1,0,
|
||||
0,-1,0,0,
|
||||
0,0,0,1
|
||||
));
|
||||
|
||||
}else{
|
||||
referenceFrame.matrix.copy(new THREE.Matrix4());
|
||||
referenceFrame.applyMatrix(new THREE.Matrix4().set(
|
||||
1,0,0,0,
|
||||
0,1,0,0,
|
||||
0,0,1,0,
|
||||
0,0,0,1
|
||||
));
|
||||
}
|
||||
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
pointcloud.updateMatrixWorld();
|
||||
var sg = pointcloud.boundingSphere.clone().applyMatrix4(pointcloud.matrixWorld);
|
||||
referenceFrame.position.copy(sg.center).multiplyScalar(-1);
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
referenceFrame.position.y -= pointcloud.getWorldPosition().y;
|
||||
referenceFrame.updateMatrixWorld(true);
|
||||
}
|
||||
|
||||
function onKeyDown(event){
|
||||
//console.log(event.keyCode);
|
||||
|
||||
if(event.keyCode === 69){
|
||||
// e pressed
|
||||
|
||||
transformationTool.translate();
|
||||
}else if(event.keyCode === 82){
|
||||
// r pressed
|
||||
|
||||
transformationTool.scale();
|
||||
}else if(event.keyCode === 84){
|
||||
// r pressed
|
||||
|
||||
transformationTool.rotate();
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
//pointcloud.material.size = pointSize;
|
||||
//pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
//pointcloud.material.opacity = opacity;
|
||||
//pointcloud.material.pointSizeType = pointSizeType;
|
||||
////pointcloud.material.pointColorType = pointColorType;
|
||||
//pointcloud.material.pointShape = (quality === "High") ? Potree.PointShape.CIRCLE : pointShape;
|
||||
//pointcloud.material.interpolate = (quality === "High");
|
||||
//pointcloud.material.heightMin = bbWorld.min.y;
|
||||
//pointcloud.material.heightMax = bbWorld.max.y;
|
||||
//pointcloud.material.clipMode = clipMode;
|
||||
////pointcloud.material.weighted = false;
|
||||
|
||||
pointcloud.material.clipMode = clipMode;
|
||||
pointcloud.material.heightMin = bbWorld.min.y;
|
||||
pointcloud.material.heightMax = bbWorld.max.y;
|
||||
pointcloud.material.intensityMin = 0;
|
||||
pointcloud.material.intensityMax = 65000;
|
||||
|
||||
pointcloud.showBoundingBox = showBoundingBox;
|
||||
pointcloud.update(camera, renderer);
|
||||
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
|
||||
stats.update();
|
||||
if(stats && showStats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "";
|
||||
stats.domElement.style.display = "";
|
||||
|
||||
stats.update();
|
||||
|
||||
if(pointcloud){
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
}else if(stats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "none";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "none";
|
||||
stats.domElement.style.display = "none";
|
||||
}
|
||||
|
||||
controls.update(clock.getDelta());
|
||||
|
||||
@ -254,6 +497,77 @@
|
||||
progressBar.show();
|
||||
progressBar.message = "loading metadata";
|
||||
}
|
||||
|
||||
volumeTool.update();
|
||||
transformationTool.update();
|
||||
profileTool.update();
|
||||
|
||||
|
||||
var clipBoxes = [];
|
||||
|
||||
//var profiles = [];
|
||||
//for(var i = 0; i < profileTool.profiles.length; i++){
|
||||
// profiles.push(profileTool.profiles[i]);
|
||||
//}
|
||||
//if(profileTool.activeProfile){
|
||||
// profiles.push(profileTool.activeProfile);
|
||||
//}
|
||||
for(var i = 0; i < profileTool.profiles.length; i++){
|
||||
var profile = profileTool.profiles[i];
|
||||
|
||||
for(var j = 0; j < profile.boxes.length; j++){
|
||||
var box = profile.boxes[j];
|
||||
box.updateMatrixWorld();
|
||||
var boxInverse = new THREE.Matrix4().getInverse(box.matrixWorld);
|
||||
clipBoxes.push(boxInverse);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for(var i = 0; i < volumeTool.volumes.length; i++){
|
||||
var volume = volumeTool.volumes[i];
|
||||
|
||||
if(volume.clip){
|
||||
volume.updateMatrixWorld();
|
||||
var boxInverse = new THREE.Matrix4().getInverse(volume.matrixWorld);
|
||||
|
||||
clipBoxes.push(boxInverse);
|
||||
}
|
||||
}
|
||||
|
||||
if(pointcloud){
|
||||
pointcloud.material.setClipBoxes(clipBoxes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function useFPSControls(){
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!fpControls){
|
||||
fpControls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = fpControls;
|
||||
controls.enabled = true;
|
||||
}
|
||||
|
||||
function useOrbitControls(){
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!orbitControls){
|
||||
orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = orbitControls;
|
||||
controls.enabled = true;
|
||||
|
||||
if(pointcloud){
|
||||
controls.target.copy(pointcloud.boundingSphere.center.clone().applyMatrix4(pointcloud.matrixWorld));
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
@ -272,21 +586,196 @@
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
|
||||
if(pointcloud){
|
||||
if(pointcloud.originalMaterial){
|
||||
pointcloud.material = pointcloud.originalMaterial;
|
||||
}
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointShape = (quality === "Circles") ? Potree.PointShape.CIRCLE : Potree.PointShape.SQUARE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = false;
|
||||
}
|
||||
|
||||
// render scene
|
||||
renderer.render(scene, camera);
|
||||
renderer.render(scenePointCloud, camera);
|
||||
|
||||
profileTool.render();
|
||||
volumeTool.render();
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
areaTool.render();
|
||||
transformationTool.render();
|
||||
}
|
||||
|
||||
// high quality rendering using splats
|
||||
//
|
||||
var rtDepth = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.NearestFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
var rtNormalize = new THREE.WebGLRenderTarget( 1024, 1024, {
|
||||
minFilter: THREE.LinearFilter,
|
||||
magFilter: THREE.NearestFilter,
|
||||
format: THREE.RGBAFormat,
|
||||
type: THREE.FloatType
|
||||
} );
|
||||
|
||||
var sceneNormalize;
|
||||
|
||||
var depthMaterial, weightedMaterial;
|
||||
|
||||
// render with splats
|
||||
function renderHighQuality(){
|
||||
|
||||
if(!sceneNormalize){
|
||||
sceneNormalize = new THREE.Scene();
|
||||
|
||||
var vsNormalize = document.getElementById('vs').innerHTML;
|
||||
var fsNormalize = document.getElementById('fs').innerHTML;
|
||||
|
||||
var uniformsNormalize = {
|
||||
depthMap: { type: "t", value: rtDepth },
|
||||
texture: { type: "t", value: rtNormalize }
|
||||
};
|
||||
|
||||
var materialNormalize = new THREE.ShaderMaterial({
|
||||
uniforms: uniformsNormalize,
|
||||
vertexShader: vsNormalize,
|
||||
fragmentShader: fsNormalize
|
||||
});
|
||||
|
||||
var quad = new THREE.Mesh( new THREE.PlaneBufferGeometry(2, 2, 0), materialNormalize);
|
||||
quad.material.depthTest = true;
|
||||
quad.material.depthWrite = true;
|
||||
quad.material.transparent = true;
|
||||
sceneNormalize.add(quad);
|
||||
|
||||
}
|
||||
|
||||
// resize
|
||||
var width = elRenderArea.clientWidth;
|
||||
var height = elRenderArea.clientHeight;
|
||||
var aspect = width / height;
|
||||
|
||||
camera.aspect = aspect;
|
||||
camera.updateProjectionMatrix();
|
||||
|
||||
renderer.setSize(width, height);
|
||||
rtDepth.setSize(width, height);
|
||||
rtNormalize.setSize(width, height);
|
||||
|
||||
|
||||
renderer.clear();
|
||||
//renderer.render(sceneBG, cameraBG);
|
||||
// render skybox
|
||||
if(showSkybox){
|
||||
skybox.camera.rotation.copy(camera.rotation);
|
||||
renderer.render(skybox.scene, skybox.camera);
|
||||
}else{
|
||||
renderer.render(sceneBG, cameraBG);
|
||||
}
|
||||
renderer.render(scene, camera);
|
||||
|
||||
if(pointcloud){
|
||||
if(!weightedMaterial){
|
||||
pointcloud.originalMaterial = pointcloud.material;
|
||||
depthMaterial = new Potree.PointCloudMaterial();
|
||||
weightedMaterial = new Potree.PointCloudMaterial();
|
||||
}
|
||||
|
||||
pointcloud.material = depthMaterial;
|
||||
|
||||
var bbWorld = Potree.utils.computeTransformedBoundingBox(pointcloud.boundingBox, pointcloud.matrixWorld);
|
||||
|
||||
// get rid of this
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = Potree.PointColorType.DEPTH;
|
||||
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolate");
|
||||
pointcloud.material.weighted = false;
|
||||
|
||||
pointcloud.material.minSize = 2;
|
||||
pointcloud.material.screenWidth = width;
|
||||
pointcloud.material.screenHeight = height;
|
||||
|
||||
pointcloud.update(camera, renderer);
|
||||
|
||||
renderer.clearTarget( rtDepth, true, true, true );
|
||||
renderer.clearTarget( rtNormalize, true, true, true );
|
||||
|
||||
var origType = pointcloud.material.pointColorType;
|
||||
renderer.render(scenePointCloud, camera, rtDepth);
|
||||
|
||||
pointcloud.material = weightedMaterial;
|
||||
|
||||
|
||||
|
||||
// get rid of this
|
||||
pointcloud.material.size = pointSize;
|
||||
pointcloud.visiblePointsTarget = pointCountTarget * 1000 * 1000;
|
||||
pointcloud.material.opacity = opacity;
|
||||
pointcloud.material.pointSizeType = pointSizeType;
|
||||
pointcloud.material.pointColorType = pointColorType;
|
||||
pointcloud.material.pointShape = Potree.PointShape.CIRCLE;
|
||||
pointcloud.material.interpolate = (quality === "Interpolation");
|
||||
pointcloud.material.weighted = true;
|
||||
|
||||
pointcloud.material.depthMap = rtDepth;
|
||||
pointcloud.material.blendDepth = Math.min(pointcloud.material.spacing, 20);
|
||||
pointcloud.update(camera, renderer);
|
||||
renderer.render(scenePointCloud, camera, rtNormalize);
|
||||
|
||||
|
||||
volumeTool.render();
|
||||
profileTool.render();
|
||||
renderer.render(sceneNormalize, cameraBG);
|
||||
|
||||
|
||||
renderer.clearDepth();
|
||||
measuringTool.render();
|
||||
areaTool.render();
|
||||
transformationTool.render();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function loop() {
|
||||
requestAnimationFrame(loop);
|
||||
|
||||
update();
|
||||
render();
|
||||
|
||||
if(quality === "Splats"){
|
||||
renderHighQuality();
|
||||
}else{
|
||||
render();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
//initGUI();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
|
||||
@ -140,6 +140,7 @@ void main() {
|
||||
|
||||
var fpControls;
|
||||
var orbitControls;
|
||||
var controls;
|
||||
|
||||
var progressBar = new ProgressBar();
|
||||
|
||||
@ -163,15 +164,16 @@ void main() {
|
||||
var pointcloudPath = "../../../../deploy/point_clouds_2014.12.29/vol_total/cloud.js";
|
||||
|
||||
var pointcloudPath = "../../../../pointclouds/surface_and_edge/land_building/_converted/cloud.js";
|
||||
|
||||
|
||||
var pointcloudPath = "../../../../pointclouds/opentopography/lake_tahoe_basin/converted/cloud.js";
|
||||
|
||||
|
||||
var pointcloudPath = "../../../../deploy/point_clouds_2014.12.29/matterhorn/cloud.js";
|
||||
var pointcloudPath = "../../../../pointclouds/mschuetz/lion_takanawa_oriented.las_converted/cloud.js";
|
||||
var pointcloudPath = "../resources/pointclouds/vol_total/cloud.js";
|
||||
|
||||
var elRenderArea = document.getElementById("renderArea");
|
||||
|
||||
var gui;
|
||||
var renderer;
|
||||
var camera;
|
||||
var scene;
|
||||
@ -191,11 +193,11 @@ void main() {
|
||||
function initGUI(){
|
||||
|
||||
// dat.gui
|
||||
var gui = new dat.GUI({
|
||||
gui = new dat.GUI({
|
||||
height : 5 * 32 - 1
|
||||
});
|
||||
|
||||
var params = {
|
||||
params = {
|
||||
"points(m)": pointCountTarget,
|
||||
PointSize: pointSize,
|
||||
"opacity": opacity,
|
||||
@ -235,10 +237,17 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
var pMaterial = gui.add(params, 'Materials', [
|
||||
var options = [];
|
||||
if(pointcloud.pcoGeometry.pointAttributes === "LAS" || pointcloud.pcoGeometry.pointAttributes === "LAZ"){
|
||||
options = [
|
||||
"RGB", "Color", "Height", "Intensity", "Intensity Gradient",
|
||||
"Classification", "Return Number", "Source",
|
||||
"Octree Depth"]);
|
||||
"Octree Depth"];
|
||||
}else{
|
||||
options = options = [ "RGB", "Color", "Height", "Octree Depth"];
|
||||
}
|
||||
|
||||
pMaterial = gui.add(params, 'Materials',options);
|
||||
pMaterial.onChange(function(value){
|
||||
if(value === "RGB"){
|
||||
pointColorType = Potree.PointColorType.RGB;
|
||||
@ -317,6 +326,7 @@ void main() {
|
||||
camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
|
||||
//camera = new THREE.OrthographicCamera(-50, 50, 50, -50, 1, 100000);
|
||||
cameraBG = new THREE.Camera();
|
||||
camera.rotation.order = 'ZYX';
|
||||
|
||||
referenceFrame = new THREE.Object3D();
|
||||
scenePointCloud.add(referenceFrame);
|
||||
@ -332,10 +342,7 @@ void main() {
|
||||
camera.position.set(-304, 372, 318);
|
||||
camera.rotation.y = -Math.PI / 4;
|
||||
camera.rotation.x = -Math.PI / 6;
|
||||
fpControls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
controls = fpControls;
|
||||
orbitControls.enabled = false;
|
||||
useOrbitControls();
|
||||
|
||||
|
||||
controls.moveSpeed *= 10;
|
||||
@ -364,6 +371,8 @@ void main() {
|
||||
camera.zoomTo(pointcloud, 1.2);
|
||||
|
||||
flipYZ();
|
||||
|
||||
initGUI();
|
||||
});
|
||||
|
||||
var grid = Potree.utils.createGrid(5, 5, 2);
|
||||
@ -473,7 +482,7 @@ void main() {
|
||||
pointcloud.update(camera, renderer);
|
||||
}
|
||||
|
||||
if(showStats){
|
||||
if(stats && showStats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "";
|
||||
stats.domElement.style.display = "";
|
||||
@ -484,7 +493,7 @@ void main() {
|
||||
document.getElementById("lblNumVisibleNodes").innerHTML = "visible nodes: " + pointcloud.numVisibleNodes;
|
||||
document.getElementById("lblNumVisiblePoints").innerHTML = "visible points: " + Potree.utils.addCommas(pointcloud.numVisiblePoints);
|
||||
}
|
||||
}else{
|
||||
}else if(stats){
|
||||
document.getElementById("lblNumVisibleNodes").style.display = "none";
|
||||
document.getElementById("lblNumVisiblePoints").style.display = "none";
|
||||
stats.domElement.style.display = "none";
|
||||
@ -554,15 +563,31 @@ void main() {
|
||||
}
|
||||
|
||||
function useFPSControls(){
|
||||
controls.enabled = false;
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!fpControls){
|
||||
fpControls = new THREE.FirstPersonControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = fpControls;
|
||||
controls.enabled = true;
|
||||
}
|
||||
|
||||
function useOrbitControls(){
|
||||
controls.enabled = false;
|
||||
if(controls){
|
||||
controls.enabled = false;
|
||||
}
|
||||
if(!orbitControls){
|
||||
orbitControls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||
}
|
||||
|
||||
controls = orbitControls;
|
||||
controls.enabled = true;
|
||||
|
||||
if(pointcloud){
|
||||
controls.target.copy(pointcloud.boundingSphere.center.clone().applyMatrix4(pointcloud.matrixWorld));
|
||||
}
|
||||
}
|
||||
|
||||
function render(){
|
||||
@ -770,7 +795,7 @@ void main() {
|
||||
|
||||
|
||||
initThree();
|
||||
initGUI();
|
||||
//initGUI();
|
||||
loop();
|
||||
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user