commit
0489a542ef
File diff suppressed because it is too large
Load Diff
8
build/js/potree.min.js
vendored
8
build/js/potree.min.js
vendored
File diff suppressed because one or more lines are too long
@ -60,15 +60,12 @@ void main() {
|
||||
}
|
||||
</script>
|
||||
|
||||
<script src="../libs/plasio/js/laslaz.js"></script>
|
||||
<script src="../libs/plasio/vendor/bluebird.js"></script>
|
||||
<script src="../libs/three.js/build/three.js"></script>
|
||||
<script src="../libs/other/OrbitControls.js"></script>
|
||||
<script src="../libs/other/stats.min.js"></script>
|
||||
<script src="../libs/other/dat.gui.min.js"></script>
|
||||
|
||||
<script src="../build/js/potree.js"></script>
|
||||
<script src="../build/js/laslaz.js"></script>
|
||||
<script src="./js/ProgressBar.js"></script>
|
||||
|
||||
<div id="lblNumVisibleNodes" class="info" style="position: absolute; left: 10px; top: 80px; width: 400px; color:white"></div>
|
||||
@ -274,7 +271,16 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
var pQuality = gui.add(params, 'quality', [ "Normal", "Circles", "Interpolation", "Splats"]);
|
||||
var qualityOptions = ["Squares", "Circles"];
|
||||
if(Potree.Features.SHADER_INTERPOLATION.isSupported()){
|
||||
qualityOptions.push("Interpolation");
|
||||
params.quality = "Interpolation";
|
||||
quality = params.quality;
|
||||
}
|
||||
if(Potree.Features.SHADER_SPLATS.isSupported()){
|
||||
qualityOptions.push("Splats");
|
||||
}
|
||||
var pQuality = gui.add(params, 'quality', qualityOptions);
|
||||
pQuality.onChange(function(value){
|
||||
quality = value;
|
||||
});
|
||||
|
||||
@ -24,10 +24,12 @@ var paths = {
|
||||
"src/loader/LasLazLoader.js",
|
||||
"src/materials/PointCloudMaterial.js",
|
||||
"src/FirstPersonControls.js",
|
||||
"src/EarthControls.js",
|
||||
"src/LRU.js",
|
||||
"src/PointCloudOctree.js",
|
||||
"src/PointCloudOctreeGeometry.js",
|
||||
"src/utils.js",
|
||||
"src/Features.js",
|
||||
"src/TextSprite.js",
|
||||
"src/Version.js",
|
||||
"src/utils/AreaTool.js",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
923
libs/three.js/build/three.min.js
vendored
923
libs/three.js/build/three.min.js
vendored
File diff suppressed because one or more lines are too long
BIN
resources/icons/sphere.png
Normal file
BIN
resources/icons/sphere.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 939 B |
123
resources/icons/sphere.svg
Normal file
123
resources/icons/sphere.svg
Normal file
@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="32px"
|
||||
height="32px"
|
||||
id="svg3797"
|
||||
version="1.1"
|
||||
inkscape:version="0.48.5 r10040"
|
||||
sodipodi:docname="focus_2.svg"
|
||||
inkscape:export-filename="D:\dev\workspaces\potree\develop\resources\icons\focus.png"
|
||||
inkscape:export-xdpi="90"
|
||||
inkscape:export-ydpi="90">
|
||||
<defs
|
||||
id="defs3799">
|
||||
<linearGradient
|
||||
id="linearGradient3789">
|
||||
<stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop3791" />
|
||||
<stop
|
||||
style="stop-color:#000000;stop-opacity:1;"
|
||||
offset="1"
|
||||
id="stop3793" />
|
||||
</linearGradient>
|
||||
<marker
|
||||
inkscape:stockid="Arrow1Lstart"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="Arrow1Lstart"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3832"
|
||||
d="M 0.0,0.0 L 5.0,-5.0 L -12.5,0.0 L 5.0,5.0 L 0.0,0.0 z "
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
|
||||
transform="scale(0.8) translate(12.5,0)" />
|
||||
</marker>
|
||||
<marker
|
||||
inkscape:stockid="DotL"
|
||||
orient="auto"
|
||||
refY="0.0"
|
||||
refX="0.0"
|
||||
id="DotL"
|
||||
style="overflow:visible">
|
||||
<path
|
||||
id="path3893"
|
||||
d="M -2.5,-1.0 C -2.5,1.7600000 -4.7400000,4.0 -7.5,4.0 C -10.260000,4.0 -12.5,1.7600000 -12.5,-1.0 C -12.5,-3.7600000 -10.260000,-6.0 -7.5,-6.0 C -4.7400000,-6.0 -2.5,-3.7600000 -2.5,-1.0 z "
|
||||
style="fill-rule:evenodd;stroke:#000000;stroke-width:1.0pt"
|
||||
transform="scale(0.8) translate(7.4, 1)" />
|
||||
</marker>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#linearGradient3789"
|
||||
id="radialGradient3797"
|
||||
cx="19.276922"
|
||||
cy="8.2230759"
|
||||
fx="19.276922"
|
||||
fy="8.2230759"
|
||||
r="14"
|
||||
gradientTransform="matrix(1.3,0,0,1.2535715,-5.4599991,-2.2082142)"
|
||||
gradientUnits="userSpaceOnUse" />
|
||||
</defs>
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="22.395604"
|
||||
inkscape:cx="4.3873333"
|
||||
inkscape:cy="18.394162"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
inkscape:grid-bbox="true"
|
||||
inkscape:document-units="px"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1138"
|
||||
inkscape:window-x="-8"
|
||||
inkscape:window-y="-8"
|
||||
inkscape:window-maximized="1">
|
||||
<inkscape:grid
|
||||
type="xygrid"
|
||||
id="grid3805" />
|
||||
</sodipodi:namedview>
|
||||
<metadata
|
||||
id="metadata3802">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
id="layer1"
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer">
|
||||
<path
|
||||
sodipodi:type="arc"
|
||||
style="fill-opacity:1.0;stroke:none;stroke-width:14;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0.40000000000000002;opacity:1;fill:url(#radialGradient3797)"
|
||||
id="path2989"
|
||||
sodipodi:cx="14"
|
||||
sodipodi:cy="13.5"
|
||||
sodipodi:rx="14"
|
||||
sodipodi:ry="13.5"
|
||||
d="m 28,13.5 a 14,13.5 0 1 1 -28,0 14,13.5 0 1 1 28,0 z"
|
||||
transform="matrix(0.71428571,0,0,0.74074075,6.0000003,6)" />
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
251
src/EarthControls.js
Normal file
251
src/EarthControls.js
Normal file
@ -0,0 +1,251 @@
|
||||
|
||||
|
||||
/**
|
||||
* @author mschuetz / http://mschuetz.at
|
||||
*
|
||||
*
|
||||
* Navigation similar to Google Earth.
|
||||
*
|
||||
* left mouse: Drag with respect to intersection
|
||||
* wheel: zoom towards/away from intersection
|
||||
* right mouse: Rotate camera around intersection
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
THREE.EarthControls = function ( camera, domElement, renderer, resourcePath ) {
|
||||
this.camera = camera;
|
||||
this.renderer = renderer;
|
||||
this.pointclouds = [];
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
// Set to false to disable this control
|
||||
this.enabled = true;
|
||||
|
||||
var scope = this;
|
||||
|
||||
|
||||
var STATE = { NONE : -1, DRAG : 0, ROTATE: 1 };
|
||||
|
||||
var state = STATE.NONE;
|
||||
|
||||
var dragStart = new THREE.Vector2();
|
||||
var dragEnd = new THREE.Vector2();
|
||||
this.dragStartIndicator = document.createElement("img");
|
||||
this.dragStartIndicator.src = resourcePath + "/icons/sphere.png";
|
||||
this.dragStartIndicator.style.width = "32px";
|
||||
this.dragStartIndicator.style.height = "32px";
|
||||
this.dragStartIndicator.style.position = "absolute";
|
||||
this.dragStartIndicator.style.display = "none";
|
||||
this.dragStartIndicator.style.opacity = "0.6";
|
||||
this.dragStartIndicator.style.pointerEvents = "none";
|
||||
document.body.appendChild(this.dragStartIndicator);
|
||||
|
||||
var mouseDelta = new THREE.Vector2();
|
||||
|
||||
var camStart = null;
|
||||
var pivot = null;
|
||||
|
||||
|
||||
this.minAngle = (10 / 180) * Math.PI; // 10°
|
||||
this.maxAngle = (70 / 180) * Math.PI; // 70°
|
||||
|
||||
this.update = function (delta) {
|
||||
var position = this.camera.position;
|
||||
|
||||
if(pivot){
|
||||
if(state === STATE.DRAG){
|
||||
var plane = new THREE.Plane().setFromNormalAndCoplanarPoint(new THREE.Vector3(0, 1, 0), pivot);
|
||||
var mouse = {
|
||||
x: ( dragEnd.x / this.domElement.clientWidth ) * 2 - 1,
|
||||
y: - ( dragEnd.y / this.domElement.clientHeight ) * 2 + 1
|
||||
};
|
||||
|
||||
var vec = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
|
||||
vec.unproject(camStart);
|
||||
var dir = vec.sub(camStart.position).normalize();
|
||||
|
||||
var ray = new THREE.Ray(camStart.position, dir);
|
||||
var distanceToPlane = ray.distanceToPlane(plane);
|
||||
|
||||
var newCamPos = new THREE.Vector3().subVectors(pivot, dir.clone().multiplyScalar(distanceToPlane));
|
||||
this.camera.position.copy(newCamPos);
|
||||
|
||||
this.dragStartIndicator.style.left = dragEnd.x - scope.dragStartIndicator.clientWidth / 2;
|
||||
this.dragStartIndicator.style.top = dragEnd.y - scope.dragStartIndicator.clientHeight / 2;
|
||||
}else if(state === STATE.ROTATE){
|
||||
// rotate around pivot point
|
||||
|
||||
var diff = mouseDelta.clone().multiplyScalar(delta);
|
||||
|
||||
this.camera.updateMatrixWorld();
|
||||
|
||||
// do calculations on fresh nodes
|
||||
var p = new THREE.Object3D();
|
||||
var c = new THREE.Object3D();
|
||||
p.add(c);
|
||||
p.position.copy(pivot);
|
||||
c.position.copy(this.camera.position).sub(pivot);
|
||||
c.rotation.copy(this.camera.rotation);
|
||||
|
||||
|
||||
// rotate left/right
|
||||
p.rotation.y += -diff.x;
|
||||
|
||||
|
||||
// rotate up/down
|
||||
var dir = this.camera.getWorldDirection();
|
||||
var up = new THREE.Vector3(0,1,0);
|
||||
var side = new THREE.Vector3().crossVectors(up, dir);
|
||||
|
||||
var dirp = c.position.clone();
|
||||
dirp.y = 0;
|
||||
dirp.normalize();
|
||||
var ac = dirp.dot(c.position.clone().normalize());
|
||||
var angle = Math.acos(ac);
|
||||
if(c.position.y < 0){
|
||||
angle = -angle;
|
||||
}
|
||||
|
||||
var amount = 0;
|
||||
if(diff.y > 0){
|
||||
// rotate downwards and apply minAngle limit
|
||||
amount = diff.y - Math.max(0, this.minAngle - (angle - diff.y));
|
||||
}else{
|
||||
// rotate upwards and apply maxAngle limit
|
||||
amount = diff.y + Math.max(0, (angle - diff.y) - this.maxAngle);
|
||||
}
|
||||
p.rotateOnAxis(side, -amount);
|
||||
|
||||
// apply changes to object
|
||||
p.updateMatrixWorld();
|
||||
|
||||
this.camera.position.copy(c.getWorldPosition());
|
||||
this.camera.quaternion.copy(c.getWorldQuaternion());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mouseDelta.set(0,0);
|
||||
};
|
||||
|
||||
|
||||
this.reset = function () {
|
||||
state = STATE.NONE;
|
||||
|
||||
this.camera.position.copy( this.position0 );
|
||||
};
|
||||
|
||||
function onMouseDown( event ) {
|
||||
if ( scope.enabled === false ) return;
|
||||
event.preventDefault();
|
||||
|
||||
var accuracy = 1;
|
||||
var mouse = {
|
||||
x: ( event.clientX / scope.domElement.clientWidth ) * 2 - 1,
|
||||
y: - ( event.clientY / scope.domElement.clientHeight ) * 2 + 1
|
||||
};
|
||||
var I = getMousePointCloudIntersection(mouse, scope.camera, scope.renderer, scope.pointclouds, accuracy)
|
||||
if(!I){
|
||||
return;
|
||||
}
|
||||
|
||||
//var sg = new THREE.SphereGeometry();
|
||||
//var sm = new THREE.Mesh(sg);
|
||||
//sm.scale.set(20, 20, 20);
|
||||
//sm.position.copy(I);
|
||||
//scene.add(sm);
|
||||
|
||||
var plane = new THREE.Plane().setFromNormalAndCoplanarPoint(new THREE.Vector3(0, 1, 0), I);
|
||||
|
||||
var vec = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
|
||||
vec.unproject(scope.camera);
|
||||
var dir = vec.sub(scope.camera.position).normalize();
|
||||
|
||||
var ray = new THREE.Ray(scope.camera.position, dir);
|
||||
pivot = ray.intersectPlane(plane);
|
||||
|
||||
//pivot = I;
|
||||
camStart = scope.camera.clone();
|
||||
camStart.rotation.copy(scope.camera.rotation);
|
||||
dragStart.set( event.clientX, event.clientY );
|
||||
dragEnd.set(event.clientX, event.clientY);
|
||||
scope.dragStartIndicator.style.display = "initial";
|
||||
scope.dragStartIndicator.style.left = event.clientX - scope.dragStartIndicator.clientWidth / 2;
|
||||
scope.dragStartIndicator.style.top = event.clientY - scope.dragStartIndicator.clientHeight / 2;
|
||||
|
||||
|
||||
if ( event.button === 0 ) {
|
||||
state = STATE.DRAG;
|
||||
} else if ( event.button === 2 ) {
|
||||
state = STATE.ROTATE;
|
||||
}
|
||||
|
||||
scope.domElement.addEventListener( 'mousemove', onMouseMove, false );
|
||||
scope.domElement.addEventListener( 'mouseup', onMouseUp, false );
|
||||
}
|
||||
|
||||
function onMouseMove( event ) {
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
|
||||
|
||||
mouseDelta.set(event.clientX - dragEnd.x, event.clientY - dragEnd.y);
|
||||
dragEnd.set(event.clientX, event.clientY);
|
||||
|
||||
}
|
||||
|
||||
function onMouseUp() {
|
||||
if ( scope.enabled === false ) return;
|
||||
|
||||
scope.domElement.removeEventListener( 'mousemove', onMouseMove, false );
|
||||
scope.domElement.removeEventListener( 'mouseup', onMouseUp, false );
|
||||
state = STATE.NONE;
|
||||
|
||||
scope.dragStartIndicator.style.display = "none";
|
||||
|
||||
}
|
||||
|
||||
function onMouseWheel(event) {
|
||||
if ( scope.enabled === false || scope.noZoom === true ) return;
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
var amount = (event.detail<0 || event.wheelDelta>0) ? 1 : -1;
|
||||
var accuracy = 1;
|
||||
var mouse = {
|
||||
x: ( event.clientX / scope.domElement.clientWidth ) * 2 - 1,
|
||||
y: - ( event.clientY / scope.domElement.clientHeight ) * 2 + 1
|
||||
};
|
||||
var I = getMousePointCloudIntersection(mouse, scope.camera, scope.renderer, scope.pointclouds, accuracy)
|
||||
|
||||
//scope.dragStartIndicator.style.left = event.clientX - scope.dragStartIndicator.clientWidth / 2;
|
||||
//scope.dragStartIndicator.style.top = event.clientY - scope.dragStartIndicator.clientHeight / 2;
|
||||
//scope.dragStartIndicator.style.display = "initial";
|
||||
|
||||
if(I){
|
||||
var distance = I.distanceTo(scope.camera.position);
|
||||
var dir = new THREE.Vector3().subVectors(I, scope.camera.position).normalize();
|
||||
scope.camera.position.add(dir.multiplyScalar(distance * 0.1 * amount));
|
||||
|
||||
|
||||
//var sg = new THREE.SphereGeometry();
|
||||
//var sm = new THREE.Mesh(sg);
|
||||
//sm.scale.set(20, 20, 20);
|
||||
//sm.position.copy(I);
|
||||
//scene.add(sm);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
|
||||
this.domElement.addEventListener( 'mousedown', onMouseDown, false );
|
||||
this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
|
||||
this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
|
||||
};
|
||||
|
||||
THREE.EarthControls.prototype = Object.create( THREE.EventDispatcher.prototype );
|
||||
35
src/Features.js
Normal file
35
src/Features.js
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
Potree.Features = function(){
|
||||
|
||||
var gl = document.createElement("canvas").getContext("webgl");
|
||||
|
||||
return {
|
||||
SHADER_INTERPOLATION: {
|
||||
isSupported: function(){
|
||||
|
||||
var supported = true;
|
||||
|
||||
supported = supported && gl.getExtension("EXT_frag_depth");
|
||||
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
|
||||
|
||||
return supported;
|
||||
|
||||
}
|
||||
},
|
||||
SHADER_SPLATS: {
|
||||
isSupported: function(){
|
||||
|
||||
var supported = true;
|
||||
|
||||
supported = supported && gl.getExtension("EXT_frag_depth");
|
||||
supported = supported && gl.getExtension("OES_texture_float");
|
||||
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
|
||||
|
||||
return supported;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}();
|
||||
@ -180,6 +180,7 @@ Potree.PointCloudOctree.prototype.update = function(camera, renderer){
|
||||
}
|
||||
|
||||
this.material.octreeLevels = this.maxLevel;
|
||||
this.material.octreeLevels = 5;
|
||||
|
||||
// check profile cut plane intersections
|
||||
for(var i = 0; i < this.profileRequests.length; i++){
|
||||
@ -290,15 +291,19 @@ Potree.PointCloudOctree.prototype.update = function(camera, renderer){
|
||||
}
|
||||
}
|
||||
|
||||
var vn = [];
|
||||
this.hideDescendants(this.children[0]);
|
||||
for(var i = 0; i < this.visibleNodes.length; i++){
|
||||
this.visibleNodes[i].node.visible = true;
|
||||
vn.push(this.visibleNodes[i].node);
|
||||
}
|
||||
|
||||
if(this.material.pointSizeType){
|
||||
if(this.material.pointSizeType === Potree.PointSizeType.ADAPTIVE
|
||||
|| this.material.pointColorType === Potree.PointColorType.OCTREE_DEPTH){
|
||||
this.updateVisibilityTexture();
|
||||
|
||||
|
||||
this.updateVisibilityTexture(this.material, vn);
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -348,7 +353,8 @@ Potree.PointCloudOctree.prototype.getVisibleGeometry = function(camera){
|
||||
|
||||
|
||||
var visible = insideFrustum; // && node.level <= 3;
|
||||
//visible = visible && "r7".indexOf(node.name) === 0;
|
||||
//visible = visible && "r0".indexOf(node.name) === 0;
|
||||
//visible = visible && node.level === 0;
|
||||
|
||||
if(!visible){
|
||||
continue;
|
||||
@ -420,22 +426,17 @@ Potree.PointCloudOctree.prototype.getVisibleGeometry = function(camera){
|
||||
return visibleGeometry;
|
||||
};
|
||||
|
||||
Potree.PointCloudOctree.prototype.updateVisibilityTexture = function(){
|
||||
Potree.PointCloudOctree.prototype.updateVisibilityTexture = function(material, visibleNodes){
|
||||
|
||||
if(!this.material){
|
||||
if(!material){
|
||||
return;
|
||||
}
|
||||
|
||||
var texture = this.material.visibleNodesTexture;
|
||||
var texture = material.visibleNodesTexture;
|
||||
var data = texture.image.data;
|
||||
|
||||
var visibleNodes = [];
|
||||
for(var i = 0; i < this.visibleNodes.length; i++){
|
||||
visibleNodes.push(this.visibleNodes[i].node);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// copy array
|
||||
visibleNodes = visibleNodes.slice();
|
||||
|
||||
// sort by level and index, e.g. r, r0, r3, r4, r01, r07, r30, ...
|
||||
var sort = function(a, b){
|
||||
@ -448,28 +449,18 @@ Potree.PointCloudOctree.prototype.updateVisibilityTexture = function(){
|
||||
};
|
||||
visibleNodes.sort(sort);
|
||||
|
||||
//var r = [];
|
||||
//for(var i = 0; i < visibleNodes.length; i++){
|
||||
// var node = visibleNodes[i];
|
||||
//
|
||||
// if(node.level < 2){
|
||||
// r.push(node);
|
||||
// }else{
|
||||
//
|
||||
// ß0
|
||||
//
|
||||
// //if(node.numPoints > 5000){
|
||||
// // r.push(node);
|
||||
// //}
|
||||
//}
|
||||
//visibleNodes = r;
|
||||
var visibleNodeNames = {};
|
||||
for(var i = 0; i < visibleNodes.length; i++){
|
||||
visibleNodeNames[visibleNodes[i].name] = true;
|
||||
}
|
||||
|
||||
for(var i = 0; i < visibleNodes.length; i++){
|
||||
var node = visibleNodes[i];
|
||||
|
||||
var children = [];
|
||||
for(var j = 0; j < node.children.length; j++){
|
||||
var child = node.children[j];
|
||||
if(child instanceof THREE.PointCloud && child.visible){
|
||||
if(child instanceof THREE.PointCloud && child.visible && visibleNodeNames[child.name]){
|
||||
children.push(child);
|
||||
}
|
||||
}
|
||||
@ -496,7 +487,7 @@ Potree.PointCloudOctree.prototype.updateVisibilityTexture = function(){
|
||||
}
|
||||
|
||||
|
||||
this.material.uniforms.nodeSize.value = this.pcoGeometry.boundingBox.size().x;
|
||||
material.uniforms.nodeSize.value = this.pcoGeometry.boundingBox.size().x;
|
||||
texture.needsUpdate = true;
|
||||
}
|
||||
|
||||
@ -506,14 +497,11 @@ Potree.PointCloudOctree.prototype.nodesOnRay = function(nodes, ray){
|
||||
var _ray = ray.clone();
|
||||
for(var i = 0; i < nodes.length; i++){
|
||||
var node = nodes[i].node;
|
||||
var inverseWorld = new THREE.Matrix4().getInverse(node.matrixWorld);
|
||||
//var inverseWorld = new THREE.Matrix4().getInverse(node.matrixWorld);
|
||||
var sphere = node.boundingSphere.clone().applyMatrix4(node.matrixWorld);
|
||||
|
||||
if(_ray.isIntersectionSphere(sphere)){
|
||||
nodesOnRay.push(nodes[i]);
|
||||
//node.visible = true;
|
||||
}else{
|
||||
//node.visible = false;
|
||||
nodesOnRay.push(node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -761,9 +749,26 @@ Potree.PointCloudOctree.prototype.getVisibleExtent = function(){
|
||||
return this.visibleBounds.applyMatrix4(this.matrixWorld);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* params.pickWindowSize: Look for points inside a pixel window of this size.
|
||||
* Use odd values: 1, 3, 5, ...
|
||||
*
|
||||
*
|
||||
* TODO: only draw pixels that are actually read with readPixels().
|
||||
*
|
||||
*/
|
||||
var point = Potree.PointCloudOctree.prototype.pick = function(renderer, camera, ray, params){
|
||||
// this function finds intersections by rendering point indices and then checking the point index at the mouse location.
|
||||
// point indices are 3 byte and rendered to the RGB component.
|
||||
// point cloud node indices are 1 byte and stored in the ALPHA component.
|
||||
// this limits picking capabilities to 256 nodes and 2^24 points per node.
|
||||
|
||||
var params = params || {};
|
||||
var accuracy = params.accuracy || 0.5;
|
||||
var accuracy = params.accuracy || 1;
|
||||
var pickWindowSize = params.pickWindowSize || 17;
|
||||
|
||||
var nodes = this.nodesOnRay(this.visibleNodes, ray);
|
||||
|
||||
@ -783,31 +788,38 @@ var point = Potree.PointCloudOctree.prototype.pick = function(renderer, camera,
|
||||
);
|
||||
}
|
||||
|
||||
// setup pick material.
|
||||
// use the same point size functions as the main material to get the same point sizes.
|
||||
if(!this.pickMaterial){
|
||||
//this.pickMaterial = new Potree.PointCloudIndexMaterial({ size: 0.01, minSize: 3});
|
||||
this.pickMaterial = new Potree.PointCloudMaterial();
|
||||
this.pickMaterial.pointColorType = Potree.PointColorType.POINT_INDEX;
|
||||
this.pickMaterial.pointSizeType = Potree.PointSizeType.FIXED;
|
||||
this.pickMaterial.size = accuracy * 5;
|
||||
this.pickMaterial.size = accuracy;
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Right now point size for picking is fixed
|
||||
// To work with adaptive size, the pick hierarchy texture must
|
||||
// be updated to the hierarchy that is rendered during picking
|
||||
this.pickMaterial.pointSizeType = this.material.pointSizeType;
|
||||
this.pickMaterial.size = this.material.size;
|
||||
|
||||
if(this.pickMaterial.pointSizeType === Potree.PointSizeType.ADAPTIVE){
|
||||
this.updateVisibilityTexture(this.pickMaterial, nodes);
|
||||
}
|
||||
|
||||
this.pickMaterial.fov = this.material.fov;
|
||||
this.pickMaterial.screenWidth = this.material.screenWidth;
|
||||
this.pickMaterial.screenHeight = this.material.screenHeight;
|
||||
this.pickMaterial.spacing = this.material.spacing;
|
||||
this.pickMaterial.near = this.material.near;
|
||||
this.pickMaterial.far = this.material.far;
|
||||
this.pickMaterial.octreeLevels = this.material.octreeLevels;
|
||||
|
||||
this.pickTarget.setSize(width, height);
|
||||
|
||||
//this.pickMaterial.size = accuracy * (this.material.size || 0.01);
|
||||
//this.pickMaterial.minSize = accuracy * (this.material.minSize || 1);
|
||||
//this.pickMaterial.pointColorType = this.material.pointColorType;
|
||||
//this.pickMaterial.pointSizeType = this.material.pointSizeType;
|
||||
//this.pickMaterial.pointShape = this.material.pointShape;
|
||||
|
||||
var _gl = renderer.context;
|
||||
|
||||
var material = this.pickMaterial;
|
||||
|
||||
//renderer.uploadTexture(material.visibleNodesTexture);
|
||||
|
||||
renderer.setRenderTarget( this.pickTarget );
|
||||
|
||||
renderer.setDepthTest( material.depthTest );
|
||||
@ -816,8 +828,13 @@ var point = Potree.PointCloudOctree.prototype.pick = function(renderer, camera,
|
||||
|
||||
renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
|
||||
|
||||
//TODO: UGLY HACK CHAMPIONSHIP SUBMISSION!! drawing first node does not work properly so we draw it twice.
|
||||
if(nodes.length > 0){
|
||||
nodes.push(nodes[0]);
|
||||
}
|
||||
|
||||
for(var i = 0; i < nodes.length; i++){
|
||||
var object = nodes[i].node;
|
||||
var object = nodes[i];
|
||||
var geometry = object.geometry;
|
||||
|
||||
if(!geometry.attributes.indices.buffer){
|
||||
@ -847,41 +864,67 @@ var point = Potree.PointCloudOctree.prototype.pick = function(renderer, camera,
|
||||
renderer.renderBufferDirect(camera, [], null, material, geometry, object);
|
||||
}
|
||||
|
||||
|
||||
//_gl.bindTexture( _gl.TEXTURE_2D, this.pickTarget.__webglTexture );
|
||||
//_gl.generateMipmap( _gl.TEXTURE_2D );
|
||||
//_gl.bindTexture( _gl.TEXTURE_2D, null );
|
||||
|
||||
|
||||
var ps = new THREE.Vector3().addVectors(camera.position, ray.direction).project(camera);
|
||||
ps.addScalar(1).multiplyScalar(0.5);
|
||||
|
||||
var buffer = new ArrayBuffer(4);
|
||||
var pickWindowSize = 17;
|
||||
var pixelCount = pickWindowSize * pickWindowSize;
|
||||
var buffer = new ArrayBuffer(pixelCount*4);
|
||||
var pixels = new Uint8Array(buffer);
|
||||
var ibuffer = new Uint32Array(buffer);
|
||||
renderer.context.readPixels(
|
||||
ps.x * width, ps.y * height,
|
||||
1, 1,
|
||||
ps.x * width - (pickWindowSize-1) / 2, ps.y * height - (pickWindowSize-1) / 2,
|
||||
pickWindowSize, pickWindowSize,
|
||||
renderer.context.RGBA, renderer.context.UNSIGNED_BYTE, pixels);
|
||||
var pcIndex = pixels[3];
|
||||
pixels[3] = 0;
|
||||
var pIndex = ibuffer[0];
|
||||
|
||||
//console.log(pcIndex);
|
||||
|
||||
|
||||
//var img = pixelsArrayToImage(pixels, pickWindowSize, pickWindowSize);
|
||||
//document.body.appendChild(img);
|
||||
//img.style.position = "absolute";
|
||||
//img.style.top = height - ps.y * height - pickWindowSize / 2;
|
||||
//img.style.left = ps.x * width - pickWindowSize / 2;
|
||||
//img.style.pointerEvents = "none";
|
||||
//
|
||||
//return null;
|
||||
|
||||
var pc = nodes[pcIndex].node;
|
||||
var positionArray = pc.geometry.attributes.position.array;
|
||||
var x = positionArray[3*pIndex+0];
|
||||
var y = positionArray[3*pIndex+1];
|
||||
var z = positionArray[3*pIndex+2];
|
||||
var position = new THREE.Vector3(x, y, z);
|
||||
position.applyMatrix4(this.matrixWorld);
|
||||
|
||||
// find closest hit inside pixelWindow boundaries
|
||||
var min = Number.MAX_VALUE;
|
||||
var hit = null;
|
||||
//console.log("finding closest hit");
|
||||
for(var u = 0; u < pickWindowSize; u++){
|
||||
for(var v = 0; v < pickWindowSize; v++){
|
||||
var offset = (u + v*pickWindowSize);
|
||||
var distance = Math.pow(u - (pickWindowSize-1) / 2, 2) + Math.pow(v - (pickWindowSize-1) / 2, 2);
|
||||
|
||||
var pcIndex = pixels[4*offset + 3];
|
||||
pixels[4*offset + 3] = 0;
|
||||
var pIndex = ibuffer[offset];
|
||||
|
||||
if((pIndex !== 0 || pcIndex !== 0) && distance < min){
|
||||
|
||||
hit = {
|
||||
pIndex: pIndex,
|
||||
pcIndex: pcIndex
|
||||
};
|
||||
//console.log(hit);
|
||||
min = distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(pIndex === 0 && pcIndex === 0){
|
||||
if(hit){
|
||||
//console.log(hit);
|
||||
var pc = nodes[hit.pcIndex];
|
||||
var positionArray = pc.geometry.attributes.position.array;
|
||||
var x = positionArray[3*hit.pIndex+0];
|
||||
var y = positionArray[3*hit.pIndex+1];
|
||||
var z = positionArray[3*hit.pIndex+2];
|
||||
var position = new THREE.Vector3(x, y, z);
|
||||
position.applyMatrix4(this.matrixWorld);
|
||||
|
||||
return {position: position};
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
|
||||
return {position: position};
|
||||
}
|
||||
@ -12,6 +12,8 @@ Potree.PointCloudOctreeGeometry = function(){
|
||||
this.numNodesLoading = 0;
|
||||
this.nodes = null;
|
||||
this.pointAttributes = null;
|
||||
this.hierarchyStepSize = -1;
|
||||
this.loader = null;
|
||||
}
|
||||
|
||||
Potree.PointCloudOctreeGeometryNode = function(name, pcoGeometry, boundingBox){
|
||||
@ -23,7 +25,46 @@ Potree.PointCloudOctreeGeometryNode = function(name, pcoGeometry, boundingBox){
|
||||
this.children = {};
|
||||
this.numPoints = 0;
|
||||
this.level = null;
|
||||
}
|
||||
|
||||
Potree.PointCloudOctreeGeometryNode.prototype.getURL = function(){
|
||||
var url = "";
|
||||
|
||||
var version = this.pcoGeometry.loader.version;
|
||||
|
||||
if(version.equalOrHigher("1.5")){
|
||||
url = this.pcoGeometry.octreeDir + "/" + this.getHierarchyPath() + "/" + this.name;
|
||||
}else if(version.equalOrHigher("1.4")){
|
||||
url = this.pcoGeometry.octreeDir + "/" + this.name;
|
||||
}else if(version.upTo("1.3")){
|
||||
url = this.pcoGeometry.octreeDir + "/" + this.name;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath = function(){
|
||||
var path = "";
|
||||
|
||||
var hierachyStepSize = this.pcoGeometry.hierarchyStepSize;
|
||||
var indices = this.name.substr(1);
|
||||
var numParts;
|
||||
if(indices.length == 0){
|
||||
numParts = 0;
|
||||
}else{
|
||||
numParts = Math.ceil(indices.length / hierachyStepSize);
|
||||
}
|
||||
|
||||
if(numParts == 0){
|
||||
path = "";
|
||||
}else{
|
||||
path = "";
|
||||
for(var i = 0; i < numParts; i++){
|
||||
path += "r" + indices.substr(0, i*hierachyStepSize) + "/";
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
Potree.PointCloudOctreeGeometryNode.prototype.addChild = function(child){
|
||||
@ -34,50 +75,135 @@ Potree.PointCloudOctreeGeometryNode.prototype.addChild = function(child){
|
||||
Potree.PointCloudOctreeGeometryNode.prototype.load = function(){
|
||||
if(this.loading === true || this.pcoGeometry.numNodesLoading > 1){
|
||||
return;
|
||||
}else{
|
||||
this.loading = true;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
|
||||
if(Potree.PointCloudOctree.lru.numPoints + this.numPoints >= Potree.pointLoadLimit){
|
||||
Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints);
|
||||
}
|
||||
|
||||
|
||||
this.pcoGeometry.numNodesLoading++;
|
||||
|
||||
this.pcoGeometry.loader.load(this);
|
||||
}
|
||||
|
||||
Potree.BinaryNodeLoader = function(){
|
||||
|
||||
}
|
||||
|
||||
Potree.BinaryNodeLoader.load = function(node, extension, callback){
|
||||
var url = node.pcoGeometry.octreeDir + "/" + node.name;
|
||||
if(extension !== undefined && extension.length > 0){
|
||||
url += "." + extension;
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200 || xhr.status === 0) {
|
||||
var buffer = xhr.response;
|
||||
callback(node, buffer);
|
||||
} else {
|
||||
console.log('Failed to load file! HTTP status: ' + xhr.status + ", file: " + url);
|
||||
}
|
||||
|
||||
if(this.pcoGeometry.loader.version.equalOrHigher("1.5")){
|
||||
if((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren){
|
||||
this.loadHierachyThenPoints();
|
||||
}else{
|
||||
this.loadPoints();
|
||||
}
|
||||
};
|
||||
try{
|
||||
xhr.send(null);
|
||||
}catch(e){
|
||||
console.log("fehler beim laden der punktwolke: " + e);
|
||||
}else{
|
||||
this.loadPoints();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Potree.PointCloudOctreeGeometryNode.prototype.loadPoints = function(){
|
||||
this.pcoGeometry.loader.load(this);
|
||||
};
|
||||
|
||||
|
||||
Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function(){
|
||||
|
||||
var node = this;
|
||||
|
||||
// load hierarchy
|
||||
var callback = function(node, hbuffer){
|
||||
var count = hbuffer.byteLength / 5;
|
||||
var view = new DataView(hbuffer);
|
||||
|
||||
var stack = [];
|
||||
var children = view.getUint8(0);
|
||||
var numPoints = view.getUint32(1, true);
|
||||
stack.push({children: children, numPoints: numPoints, name: node.name});
|
||||
|
||||
var decoded = [];
|
||||
|
||||
var offset = 5;
|
||||
while(stack.length > 0){
|
||||
|
||||
var snode = stack.shift();
|
||||
var mask = 1;
|
||||
for(var i = 0; i < 8; i++){
|
||||
if((snode.children & mask) !== 0){
|
||||
var childIndex = i;
|
||||
var childName = snode.name + i;
|
||||
|
||||
var childChildren = view.getUint8(offset);
|
||||
var childNumPoints = view.getUint32(offset + 1, true);
|
||||
|
||||
stack.push({children: childChildren, numPoints: childNumPoints, name: childName});
|
||||
|
||||
decoded.push({children: childChildren, numPoints: childNumPoints, name: childName});
|
||||
|
||||
offset += 5;
|
||||
}
|
||||
|
||||
mask = mask * 2;
|
||||
}
|
||||
|
||||
if(offset === hbuffer.byteLength){
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//console.log(decoded);
|
||||
|
||||
var nodes = {};
|
||||
nodes[node.name] = node;
|
||||
var pco = node.pcoGeometry;
|
||||
|
||||
|
||||
for( var i = 0; i < decoded.length; i++){
|
||||
var name = decoded[i].name;
|
||||
var numPoints = decoded[i].numPoints;
|
||||
var index = parseInt(name.charAt(name.length-1));
|
||||
var parentName = name.substring(0, name.length-1);
|
||||
var parentNode = nodes[parentName];
|
||||
var level = name.length-1;
|
||||
var boundingBox = POCLoader.createChildAABB(parentNode.boundingBox, index);
|
||||
|
||||
var currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
|
||||
currentNode.level = level;
|
||||
currentNode.numPoints = numPoints;
|
||||
currentNode.hasChildren = decoded[i].children > 0;
|
||||
parentNode.addChild(currentNode);
|
||||
nodes[name] = currentNode;
|
||||
}
|
||||
|
||||
node.loadPoints();
|
||||
|
||||
};
|
||||
if((node.level % node.pcoGeometry.hierarchyStepSize) === 0){
|
||||
//var hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc";
|
||||
var hurl = node.pcoGeometry.octreeDir + "/" + node.getHierarchyPath() + "/" + node.name + ".hrc";
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', hurl, true);
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 200 || xhr.status === 0) {
|
||||
var hbuffer = xhr.response;
|
||||
callback(node, hbuffer);
|
||||
} else {
|
||||
console.log('Failed to load file! HTTP status: ' + xhr.status + ", file: " + url);
|
||||
}
|
||||
}
|
||||
};
|
||||
try{
|
||||
xhr.send(null);
|
||||
}catch(e){
|
||||
console.log("fehler beim laden der punktwolke: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){
|
||||
delete this.geometry;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
|
||||
|
||||
|
||||
function Potree(){
|
||||
|
||||
}
|
||||
@ -10,7 +11,3 @@ Potree.pointLoadLimit = 50*1000*1000;
|
||||
Potree.workers = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
Potree.Version = function(version){
|
||||
this.version = version;
|
||||
var vmLength = (version.indexOf(".") === -1) ? version.length : version.indexOf(".");
|
||||
this.versionMajor = version.substr(0, vmLength);
|
||||
this.versionMinor = version.substr(vmLength + 1);
|
||||
this.versionMajor = parseInt(version.substr(0, vmLength));
|
||||
this.versionMinor = parseInt(version.substr(vmLength + 1));
|
||||
if(this.versionMinor.length === 0){
|
||||
this.versionMinor = 0;
|
||||
}
|
||||
@ -21,3 +21,19 @@ Potree.Version.prototype.newerThan = function(version){
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Potree.Version.prototype.equalOrHigher = function(version){
|
||||
var v = new Potree.Version(version);
|
||||
|
||||
if( this.versionMajor > v.versionMajor){
|
||||
return true;
|
||||
}else if( this.versionMajor === v.versionMajor && this.versionMinor >= v.versionMinor){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
Potree.Version.prototype.upTo = function(version){
|
||||
return !this.newerThan(version);
|
||||
}
|
||||
@ -10,22 +10,23 @@ Potree.BinaryLoader = function(version, boundingBox, scale){
|
||||
this.scale = scale;
|
||||
};
|
||||
|
||||
Potree.BinaryLoader.prototype.newerVersion = function(version){
|
||||
|
||||
};
|
||||
|
||||
Potree.BinaryLoader.prototype.load = function(node){
|
||||
|
||||
if(node.loaded){
|
||||
return;
|
||||
}
|
||||
|
||||
var url = node.pcoGeometry.octreeDir + "/" + node.name;
|
||||
if(this.version.newerThan("1.3")){
|
||||
url += ".bin";
|
||||
}
|
||||
|
||||
var scope = this;
|
||||
|
||||
//var url = node.pcoGeometry.octreeDir + "/" + node.getHierarchyPath() + "/" + node.name;
|
||||
//if(this.version.newerThan("1.3")){
|
||||
// url += ".bin";
|
||||
//}
|
||||
|
||||
var url = node.getURL();
|
||||
|
||||
if(this.version.equalOrHigher("1.4")){
|
||||
url += ".bin";
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', url, true);
|
||||
@ -46,7 +47,6 @@ Potree.BinaryLoader.prototype.load = function(node){
|
||||
}catch(e){
|
||||
console.log("fehler beim laden der punktwolke: " + e);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Potree.BinaryLoader.prototype.parse = function(node, buffer){
|
||||
|
||||
@ -24,7 +24,13 @@ Potree.LasLazLoader.prototype.load = function(node){
|
||||
|
||||
//var url = node.pcoGeometry.octreeDir + "/" + node.name;
|
||||
var pointAttributes = node.pcoGeometry.pointAttributes;
|
||||
var url = node.pcoGeometry.octreeDir + "/" + node.name + "." + pointAttributes.toLowerCase()
|
||||
//var url = node.pcoGeometry.octreeDir + "/" + node.name + "." + pointAttributes.toLowerCase()
|
||||
|
||||
var url = node.getURL();
|
||||
|
||||
if(this.version.equalOrHigher("1.4")){
|
||||
url += "." + pointAttributes.toLowerCase();
|
||||
}
|
||||
|
||||
var scope = this;
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ POCLoader.load = function load(url, callback) {
|
||||
}
|
||||
|
||||
pco.spacing = fMno.spacing;
|
||||
pco.hierarchyStepSize = fMno.hierarchyStepSize;
|
||||
|
||||
pco.pointAttributes = fMno.pointAttributes;
|
||||
|
||||
@ -78,6 +79,7 @@ POCLoader.load = function load(url, callback) {
|
||||
|
||||
var root = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
|
||||
root.level = 0;
|
||||
root.hasChildren = true;
|
||||
root.numPoints = fMno.hierarchy[0][1];
|
||||
pco.root = root;
|
||||
pco.root.load();
|
||||
@ -85,20 +87,22 @@ POCLoader.load = function load(url, callback) {
|
||||
}
|
||||
|
||||
// load remaining hierarchy
|
||||
for( var i = 1; i < fMno.hierarchy.length; i++){
|
||||
var name = fMno.hierarchy[i][0];
|
||||
var numPoints = fMno.hierarchy[i][1];
|
||||
var index = parseInt(name.charAt(name.length-1));
|
||||
var parentName = name.substring(0, name.length-1);
|
||||
var parentNode = nodes[parentName];
|
||||
var level = name.length-1;
|
||||
var boundingBox = POCLoader.createChildAABB(parentNode.boundingBox, index);
|
||||
|
||||
var node = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
|
||||
node.level = level;
|
||||
node.numPoints = numPoints;
|
||||
parentNode.addChild(node);
|
||||
nodes[name] = node;
|
||||
if(pco.loader.version.upTo("1.4")){
|
||||
for( var i = 1; i < fMno.hierarchy.length; i++){
|
||||
var name = fMno.hierarchy[i][0];
|
||||
var numPoints = fMno.hierarchy[i][1];
|
||||
var index = parseInt(name.charAt(name.length-1));
|
||||
var parentName = name.substring(0, name.length-1);
|
||||
var parentNode = nodes[parentName];
|
||||
var level = name.length-1;
|
||||
var boundingBox = POCLoader.createChildAABB(parentNode.boundingBox, index);
|
||||
|
||||
var node = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
|
||||
node.level = level;
|
||||
node.numPoints = numPoints;
|
||||
parentNode.addChild(node);
|
||||
nodes[name] = node;
|
||||
}
|
||||
}
|
||||
|
||||
pco.nodes = nodes;
|
||||
|
||||
71
src/utils.js
71
src/utils.js
@ -77,7 +77,7 @@ Potree.utils.loadSkybox = function(path){
|
||||
path + 'pz' + format, path + 'nz' + format
|
||||
];
|
||||
|
||||
var textureCube = THREE.ImageUtils.loadTextureCube(urls, new THREE.CubeRefractionMapping());
|
||||
var textureCube = THREE.ImageUtils.loadTextureCube(urls, THREE.CubeRefractionMapping );
|
||||
|
||||
var shader = {
|
||||
uniforms: {
|
||||
@ -95,7 +95,7 @@ Potree.utils.loadSkybox = function(path){
|
||||
depthWrite: false,
|
||||
side: THREE.BackSide
|
||||
});
|
||||
var mesh = new THREE.Mesh(new THREE.CubeGeometry(100, 100, 100), material);
|
||||
var mesh = new THREE.Mesh(new THREE.BoxGeometry(100, 100, 100), material);
|
||||
scene.add(mesh);
|
||||
|
||||
return {"camera": camera, "scene": scene};
|
||||
@ -160,4 +160,69 @@ Potree.utils.createBackgroundTexture = function(width, height){
|
||||
}
|
||||
|
||||
return map;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
function getMousePointCloudIntersection(mouse, camera, renderer, pointclouds, accuracy){
|
||||
var vector = new THREE.Vector3( mouse.x, mouse.y, 0.5 );
|
||||
vector.unproject(camera);
|
||||
|
||||
var direction = vector.sub(camera.position).normalize();
|
||||
var ray = new THREE.Ray(camera.position, direction);
|
||||
|
||||
var closestPoint = null;
|
||||
var closestPointDistance = null;
|
||||
|
||||
for(var i = 0; i < pointclouds.length; i++){
|
||||
var pointcloud = pointclouds[i];
|
||||
var point = pointcloud.pick(renderer, camera, ray, {accuracy: accuracy});
|
||||
|
||||
if(!point){
|
||||
continue;
|
||||
}
|
||||
|
||||
var distance = camera.position.distanceTo(point.position);
|
||||
|
||||
if(!closestPoint || distance < closestPointDistance){
|
||||
closestPoint = point;
|
||||
closestPointDistance = distance;
|
||||
}
|
||||
}
|
||||
|
||||
return closestPoint ? closestPoint.position : null;
|
||||
}
|
||||
|
||||
|
||||
function pixelsArrayToImage(pixels, width, height){
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
var context = canvas.getContext('2d');
|
||||
|
||||
pixels = new pixels.constructor(pixels);
|
||||
|
||||
for(var i = 0; i < pixels.length; i++){
|
||||
pixels[i*4 + 3] = 255;
|
||||
}
|
||||
|
||||
var imageData = context.createImageData(width, height);
|
||||
imageData.data.set(pixels);
|
||||
context.putImageData(imageData, 0, 0);
|
||||
|
||||
var img = new Image();
|
||||
img.src = canvas.toDataURL();
|
||||
img.style.transform = "scaleY(-1)";
|
||||
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ Potree.MeasuringTool = function(scene, camera, renderer){
|
||||
this.renderer = renderer;
|
||||
this.domElement = renderer.domElement;
|
||||
this.mouse = {x: 0, y: 0};
|
||||
this.accuracy = 0.5;
|
||||
this.accuracy = 1;
|
||||
|
||||
var STATE = {
|
||||
DEFAULT: 0,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user