Restored previous whitespace/tabs

This commit is contained in:
Daniel Šmon 2018-01-15 14:46:44 +11:00
parent 8ac55d5bcd
commit a228347df8
9 changed files with 1850 additions and 1850 deletions

File diff suppressed because it is too large Load Diff

View File

@ -8,9 +8,9 @@
"license": "BSD-2-CLAUSE",
"devDependencies": {
"gulp": "~3.5.2",
"gulp-jshint": "^2.0.4",
"gulp-jshint": "^2.0.4",
"gulp-size": "^2.1.0",
"jshint": "^2.9.5"
"jshint": "^2.9.5",
"gulp-concat": "~2.1.7",
"gulp-connect": "^2.3.1",
"gulp-rename": "~1.0.0",

View File

@ -59,13 +59,13 @@ Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){
Potree.PointCloudOctreeGeometryNode.prototype.getChildren = function(){
var children = [];
for(var i = 0; i < 8; i++){
if(this.children[i]){
children.push(this.children[i]);
}
}
return children;
};
@ -75,9 +75,9 @@ Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function(){
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")){
@ -85,7 +85,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.getURL = function(){
}else if(version.upTo("1.3")){
url = this.pcoGeometry.octreeDir + "/" + this.name;
}
return url;
};
@ -94,12 +94,12 @@ Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath = function(){
var hierarchyStepSize = this.pcoGeometry.hierarchyStepSize;
var indices = this.name.substr(1);
var numParts = Math.floor(indices.length / hierarchyStepSize);
for(var i = 0; i < numParts; i++){
path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + "/";
}
path = path.slice(0,-1);
return path;
@ -114,12 +114,12 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){
if(this.loading === true || this.loaded === true ||this.pcoGeometry.numNodesLoading > 3){
return;
}
this.loading = true;
this.pcoGeometry.numNodesLoading++;
if(this.pcoGeometry.loader.version.equalOrHigher("1.5")){
if((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren){
this.loadHierachyThenPoints();
@ -129,8 +129,8 @@ Potree.PointCloudOctreeGeometryNode.prototype.load = function(){
}else{
this.loadPoints();
}
};
Potree.PointCloudOctreeGeometryNode.prototype.loadPoints = function(){
@ -146,51 +146,51 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function(
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);
node.numPoints = numPoints;
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;
@ -199,7 +199,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function(
var parentNode = nodes[parentName];
var level = name.length-1;
var boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index);
var currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
currentNode.level = level;
currentNode.numPoints = numPoints;
@ -208,14 +208,14 @@ Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function(
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 = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', hurl, true);
xhr.responseType = 'arraybuffer';
@ -250,7 +250,7 @@ Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){
this.geometry.dispose();
this.geometry = null;
this.loaded = false;
//this.dispatchEvent( { type: 'dispose' } );
for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){
var handler = this.oneTimeDisposeHandlers[i];

View File

@ -7,7 +7,7 @@ function Potree(){
Potree.version = {
major: 1,
minor: 5,
suffix: "RC-Synth"
suffix: "RC"
};
console.log("Potree " + Potree.version.major + "." + Potree.version.minor + Potree.version.suffix);
@ -48,17 +48,17 @@ Potree.startQuery = function(name, gl){
if(!Potree.timerQueriesEnabled){
return null;
}
if(Potree.timerQueries[name] === undefined){
Potree.timerQueries[name] = [];
}
let ext = gl.getExtension("EXT_disjoint_timer_query");
let query = ext.createQueryEXT();
ext.beginQueryEXT(ext.TIME_ELAPSED_EXT, query);
Potree.timerQueries[name].push(query);
return query;
};
@ -66,7 +66,7 @@ Potree.endQuery = function(query, gl){
if(!Potree.timerQueriesEnabled){
return;
}
let ext = gl.getExtension("EXT_disjoint_timer_query");
ext.endQueryEXT(ext.TIME_ELAPSED_EXT);
};
@ -75,28 +75,28 @@ Potree.resolveQueries = function(gl){
if(!Potree.timerQueriesEnabled){
return;
}
let ext = gl.getExtension("EXT_disjoint_timer_query");
for(let name in Potree.timerQueries){
let queries = Potree.timerQueries[name];
if(queries.length > 0){
let query = queries[0];
let available = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_AVAILABLE_EXT);
let disjoint = viewer.renderer.getContext().getParameter(ext.GPU_DISJOINT_EXT);
if (available && !disjoint) {
// See how much time the rendering of the object took in nanoseconds.
let timeElapsed = ext.getQueryObjectEXT(query, ext.QUERY_RESULT_EXT);
let miliseconds = timeElapsed / (1000 * 1000);
console.log(name + ": " + miliseconds + "ms");
queries.shift();
}
}
if(queries.length === 0){
delete Potree.timerQueries[name];
}
@ -111,75 +111,75 @@ Potree.MOUSE = {
};
Potree.Points = class Points{
constructor(){
this.boundingBox = new THREE.Box3();
this.numPoints = 0;
this.data = {};
}
add(points){
let currentSize = this.numPoints;
let additionalSize = points.numPoints;
let newSize = currentSize + additionalSize;
let thisAttributes = Object.keys(this.data);
let otherAttributes = Object.keys(points.data);
let attributes = new Set([...thisAttributes, ...otherAttributes]);
for(let attribute of attributes){
if(thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){
// attribute in both, merge
let type = this.data[attribute].constructor;
let merged = new type(this.data[attribute].length + points.data[attribute].length);
merged.set(this.data[attribute], 0);
merged.set(points.data[attribute], this.data[attribute].length);
this.data[attribute] = merged;
}else if(thisAttributes.includes(attribute) && !otherAttributes.includes(attribute)){
// attribute only in this; take over this and expand to new size
let elementsPerPoint = this.data[attribute].length / this.numPoints;
let type = this.data[attribute].constructor;
let expanded = new type(elementsPerPoint * newSize);
expanded.set(this.data[attribute], 0);
this.data[attribute] = expanded;
}else if(!thisAttributes.includes(attribute) && otherAttributes.includes(attribute)){
// attribute only in points to be added; take over new points and expand to new size
let elementsPerPoint = points.data[attribute].length / points.numPoints;
let type = points.data[attribute].constructor;
let expanded = new type(elementsPerPoint * newSize);
expanded.set(points.data[attribute], elementsPerPoint * currentSize);
this.data[attribute] = expanded;
}
}
this.numPoints = newSize;
this.boundingBox.union(points.boundingBox);
}
};
Potree.loadPointCloud = function(path, name, callback){
let loaded = function(pointcloud){
pointcloud.name = name;
callback({type: "pointcloud_loaded", pointcloud: pointcloud});
};
// load pointcloud
if(!path){
}else if(path.indexOf("greyhound://") === 0){
// We check if the path string starts with 'greyhound:', if so we assume it's a greyhound server URL.
Potree.GreyhoundLoader.load(path, function(geometry) {
@ -225,9 +225,9 @@ Potree.updatePointClouds = function(pointclouds, camera, renderer){
pointcloud.profileRequests[j].update();
}
}
let result = Potree.updateVisibility(pointclouds, camera, renderer);
for(let i = 0; i < pointclouds.length; i++){
let pointcloud = pointclouds[i];
pointcloud.updateMaterial(pointcloud.material, pointcloud.visibleNodes, camera, renderer);
@ -252,10 +252,10 @@ function updateVisibilityStructures(pointclouds, camera, renderer){
let frustums = [];
let camObjPositions = [];
let priorityQueue = new BinaryHeap(function(x){return 1 / x.weight;});
for(let i = 0; i < pointclouds.length; i++){
let pointcloud = pointclouds[i];
if(!pointcloud.initialized()){
continue;
}
@ -294,12 +294,12 @@ function updateVisibilityStructures(pointclouds, camera, renderer){
if(pointcloud.root.isTreeNode()){
pointcloud.hideDescendants(pointcloud.root.sceneNode);
}
for(let j = 0; j < pointcloud.boundingBoxNodes.length; j++){
pointcloud.boundingBoxNodes[j].visible = false;
}
}
return {
"frustums": frustums,
"camObjPositions" : camObjPositions,
@ -312,12 +312,12 @@ Potree.getDEMWorkerInstance = function(){
let workerPath = Potree.scriptPath + "/workers/DEMWorker.js";
Potree.DEMWorkerInstance = Potree.workerPool.getWorker(workerPath);
}
return Potree.DEMWorkerInstance;
}
function createDEMMesh(dem){
let box = dem.boundingBox;
let steps = 256;
@ -328,7 +328,7 @@ function createDEMMesh(dem){
let u1 = (i+1) / steps;
let v0 = j / steps;
let v1 = (j+1) / steps;
//let x0 = box.min.x + u0 * box.getSize().x;
//let x1 = box.min.x + u1 * box.getSize().x;
//let y0 = box.min.y + v0 * box.getSize().y;
@ -338,36 +338,36 @@ function createDEMMesh(dem){
//let h10 = dem.height(new THREE.Vector3(x1, y0, 0));
//let h01 = dem.height(new THREE.Vector3(x0, y1, 0));
//let h11 = dem.height(new THREE.Vector3(x1, y1, 0));
let x0 = u0 * box.getSize().x;
let x1 = u1 * box.getSize().x;
let y0 = v0 * box.getSize().y;
let y1 = v1 * box.getSize().y;
//let h00 = demNode.data[(i+0) + tileSize * (j+0)];
//let h10 = demNode.data[(i+1) + tileSize * (j+0)];
//let h01 = demNode.data[(i+0) + tileSize * (j+1)];
//let h11 = demNode.data[(i+1) + tileSize * (j+1)];
let h00 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0));
let h10 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0));
let h01 = dem.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1));
let h11 = dem.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1));
if(![h00, h10, h01, h11].every(n => isFinite(n))){
continue;
}
triangles.push(x0, y0, h00);
triangles.push(x0, y1, h01);
triangles.push(x1, y0, h10);
triangles.push(x0, y1, h01);
triangles.push(x1, y1, h11);
triangles.push(x1, y0, h10);
}
}
let geometry = new THREE.BufferGeometry();
let positions = new Float32Array(triangles);
geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3));
@ -381,10 +381,10 @@ function createDEMMesh(dem){
}
function createDEMMeshNode(dem, demNode){
let box = demNode.box;
let tileSize = dem.tileSize * 1;
let triangles = [];
for(let i = 0; i < tileSize; i++){
//for(let j = 0; j < 1; j++){
@ -393,36 +393,36 @@ function createDEMMeshNode(dem, demNode){
let u1 = (i+1) / tileSize;
let v0 = j / tileSize;
let v1 = (j+1) / tileSize;
let x0 = u0 * box.getSize().x;
let x1 = u1 * box.getSize().x;
let y0 = v0 * box.getSize().y;
let y1 = v1 * box.getSize().y;
//let h00 = demNode.data[(i+0) + tileSize * (j+0)];
//let h10 = demNode.data[(i+1) + tileSize * (j+0)];
//let h01 = demNode.data[(i+0) + tileSize * (j+1)];
//let h11 = demNode.data[(i+1) + tileSize * (j+1)];
let h00 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y0));
let h10 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y0));
let h01 = demNode.height(new THREE.Vector3(box.min.x + x0, box.min.y + y1));
let h11 = demNode.height(new THREE.Vector3(box.min.x + x1, box.min.y + y1));
if(![h00, h10, h01, h11].every(n => isFinite(n))){
continue;
}
triangles.push(x0, y0, h00);
triangles.push(x0, y1, h01);
triangles.push(x1, y0, h10);
triangles.push(x0, y1, h01);
triangles.push(x1, y1, h11);
triangles.push(x1, y0, h10);
}
}
let geometry = new THREE.BufferGeometry();
let positions = new Float32Array(triangles);
geometry.addAttribute( 'position', new THREE.BufferAttribute(positions, 3));
@ -433,10 +433,10 @@ function createDEMMeshNode(dem, demNode){
mesh.position.copy(box.min);
//mesh.position.copy(pointcloud.position);
viewer.scene.scene.add(mesh);
{ // DEBUG code
//let data = demNode.data;
let steps = 64;
let data = new Float32Array(steps * steps);
let imgData = new Uint8Array(data.length * 4);
@ -450,12 +450,12 @@ function createDEMMeshNode(dem, demNode){
v * boxSize.y + box.min.y,
0
);
let height = demNode.height(pos);
let index = i + steps * j;
data[index] = height
//let index = i + steps * j;
//imgData[4*index + 0] = 255 * (height - min) / (max - min);
//imgData[4*index + 1] = 100;
@ -463,97 +463,97 @@ function createDEMMeshNode(dem, demNode){
//imgData[4*index + 3] = 255;
}
}
let [min, max] = [Infinity, -Infinity];
for(let height of data){
if(!isFinite(height)){
continue;
}
min = Math.min(min, height);
max = Math.max(max, height);
}
for(let i = 0; i < data.length; i++){
imgData[4*i + 0] = 255 * (data[i] - min) / (max - min);
imgData[4*i + 1] = 100;
imgData[4*i + 2] = 0;
imgData[4*i + 3] = 255;
}
let img = Potree.utils.pixelsArrayToImage(imgData, steps, steps);
let screenshot = img.src;
if(!this.debugDIV){
this.debugDIV = $(`
<div id="pickDebug"
style="position: absolute;
<div id="pickDebug"
style="position: absolute;
right: 400px; width: 300px;
bottom: 44px; width: 300px;
z-index: 1000;
"></div>`);
$(document.body).append(this.debugDIV);
}
this.debugDIV.empty();
this.debugDIV.append($(`<img src="${screenshot}"
style="transform: scaleY(-1); width: 256px; height: 256px;"/>`));
}
}
Potree.updateVisibility = function(pointclouds, camera, renderer){
let numVisibleNodes = 0;
let numVisiblePoints = 0;
let visibleNodes = [];
let visibleGeometry = [];
let unloadedGeometry = [];
let lowestSpacing = Infinity;
// calculate object space frustum and cam pos and setup priority queue
let s = updateVisibilityStructures(pointclouds, camera, renderer);
let frustums = s.frustums;
let camObjPositions = s.camObjPositions;
let priorityQueue = s.priorityQueue;
let loadedToGPUThisFrame = 0;
while(priorityQueue.size() > 0){
let element = priorityQueue.pop();
let node = element.node;
let parent = element.parent;
let pointcloud = pointclouds[element.pointcloud];
//{ // restrict to certain nodes for debugging
// let allowedNodes = ["r", "r0", "r4"];
// if(!allowedNodes.includes(node.name)){
// continue;
// }
//}
let box = node.getBoundingBox();
let frustum = frustums[element.pointcloud];
let camObjPos = camObjPositions[element.pointcloud];
let insideFrustum = frustum.intersectsBox(box);
let maxLevel = pointcloud.maxLevel || Infinity;
let level = node.getLevel();
let visible = insideFrustum;
visible = visible && !(numVisiblePoints + node.getNumPoints() > Potree.pointBudget);
visible = visible && level < maxLevel;
if (pointcloud.material.numClipBoxes > 0 && visible && pointcloud.material.clipMode == Potree.ClipMode.CLIP_OUTSIDE) {
let box2 = box.clone();
let box2 = box.clone();
pointcloud.updateMatrixWorld(true);
box2.applyMatrix4(pointcloud.matrixWorld);
let intersectsClipBoxes = false;
for(let clipBox of pointcloud.material.clipBoxes) {
let clipMatrixWorld = clipBox.matrix;
let clipBoxWorld = new THREE.Box3(
new THREE.Vector3(-0.5, -0.5, -0.5),
new THREE.Vector3(-0.5, -0.5, -0.5),
new THREE.Vector3(0.5, 0.5, 0.5))
.applyMatrix4(clipMatrixWorld);
if (box2.intersectsBox(clipBoxWorld)) {
@ -563,21 +563,21 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){
}
visible = visible && intersectsClipBoxes;
}
//visible = ["r", "r0", "r06", "r060"].includes(node.name);
//visible = ["r"].includes(node.name);
if(node.spacing){
lowestSpacing = Math.min(lowestSpacing, node.spacing);
}else if(node.geometryNode && node.geometryNode.spacing){
lowestSpacing = Math.min(lowestSpacing, node.geometryNode.spacing);
}
if(numVisiblePoints + node.getNumPoints() > Potree.pointBudget){
break;
}
if(!visible){
continue;
}
@ -622,27 +622,27 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){
}else if(!pointcloud.showBoundingBox && node.boundingBoxNode){
node.boundingBoxNode.visible = false;
}
}
// add child nodes to priorityQueue
let children = node.getChildren();
for(let i = 0; i < children.length; i++){
let child = children[i];
let sphere = child.getBoundingSphere();
let distance = sphere.center.distanceTo(camObjPos);
let radius = sphere.radius;
let fov = (camera.fov * Math.PI) / 180;
let slope = Math.tan(fov / 2);
let projFactor = (0.5 * renderer.domElement.clientHeight) / (slope * distance);
let screenPixelRadius = radius * projFactor;
if(screenPixelRadius < pointcloud.minimumNodePixelSize){
continue;
}
let weight = screenPixelRadius;
if(distance - radius < 0){
@ -654,7 +654,7 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){
}// end priority queue loop
{ // update DEM
let maxDEMLevel = 4;
let candidates = pointclouds
@ -664,25 +664,25 @@ Potree.updateVisibility = function(pointclouds, camera, renderer){
pointcloud.dem.update(updatingNodes);
}
}
for(let i = 0; i < Math.min(5, unloadedGeometry.length); i++){
unloadedGeometry[i].load();
}
//for(let node of visibleNodes){
// let allowedNodes = ["r", "r0", "r4"];
// node.sceneNode.visible = allowedNodes.includes(node.geometryNode.name);
//
//
// if(node.boundingBoxNode){
// node.boundingBoxNode.visible = node.boundingBoxNode.visible && node.sceneNode.visible;
// }
//}
//Potree.updateDEMs(renderer, visibleNodes);
return {
visibleNodes: visibleNodes,
visibleNodes: visibleNodes,
numVisiblePoints: numVisiblePoints,
lowestSpacing: lowestSpacing
};
@ -725,144 +725,144 @@ Potree.XHRFactory = {
Potree.DEMRenderer = class{
constructor(renderer){
this.renderer = renderer;
this.tileWidth = 64;
this.tileHeight = 64;
//this.target = new THREE.WebGLRenderTarget( 64, 64, {
// minFilter: THREE.NearestFilter,
// magFilter: THREE.NearestFilter,
// format: THREE.RGBAFormat,
//this.target = new THREE.WebGLRenderTarget( 64, 64, {
// minFilter: THREE.NearestFilter,
// magFilter: THREE.NearestFilter,
// format: THREE.RGBAFormat,
// type: THREE.FloatType
//} );
//this.target.depthTexture = new THREE.DepthTexture();
//this.target.depthTexture.type = THREE.UnsignedIntType;
this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, {
minFilter: THREE.NearestFilter,
magFilter: THREE.NearestFilter,
this.targetElevation = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, {
minFilter: THREE.NearestFilter,
magFilter: THREE.NearestFilter,
format: THREE.RGBAFormat,
//type: THREE.FloatType
});
this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, {
minFilter: THREE.NearestFilter,
magFilter: THREE.NearestFilter,
this.targetMedian = new THREE.WebGLRenderTarget( this.tileWidth, this.tileHeight, {
minFilter: THREE.NearestFilter,
magFilter: THREE.NearestFilter,
format: THREE.RGBAFormat,
//type: THREE.FloatType
});
this.vsElevation = `
precision mediump float;
precision mediump int;
attribute vec3 position;
uniform mat4 modelMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
varying float vElevation;
void main(){
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
gl_Position = projectionMatrix * mvPosition;
gl_PointSize = 1.0;
vElevation = position.z;
}
`;
this.fsElevation = `
precision mediump float;
precision mediump int;
varying float vElevation;
void main(){
gl_FragColor = vec4(vElevation, 0.0, 0.0, 1.0);
}
`;
this.vsMedian = `
precision mediump float;
precision mediump int;
attribute vec3 position;
attribute vec2 uv;
uniform mat4 modelMatrix;
uniform mat4 modelViewMatrix;
uniform mat4 projectionMatrix;
varying vec2 vUV;
void main() {
vUV = uv;
vec4 mvPosition = modelViewMatrix * vec4(position,1.0);
gl_Position = projectionMatrix * mvPosition;
}
`;
this.fsMedian = `
precision mediump float;
precision mediump int;
uniform float uWidth;
uniform float uHeight;
uniform float uHeight;
uniform sampler2D uTexture;
varying vec2 vUV;
void main(){
vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight);
vec2 uv = gl_FragCoord.xy / vec2(uWidth, uHeight);
vec4 color = texture2D(uTexture, uv);
gl_FragColor = color;
if(color.a == 0.0){
vec4 sum;
float minVal = 1.0 / 0.0;
float sumA = 0.0;
for(int i = -1; i <= 1; i++){
for(int j = -1; j <= 1; j++){
vec2 n = gl_FragCoord.xy + vec2(i, j);
vec2 uv = n / vec2(uWidth, uHeight);
vec2 uv = n / vec2(uWidth, uHeight);
vec4 c = texture2D(uTexture, uv);
if(c.a == 1.0){
minVal = min(c.r, minVal);
}
sumA += c.a;
}
}
if(sumA > 0.0){
gl_FragColor = vec4(minVal, 0.0, 0.0, 1.0);
}else{
discard;
discard;
}
}else{
//gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);
gl_FragColor = vec4(color.rgb, 1.0);
}
}
`;
this.elevationMaterial = new THREE.RawShaderMaterial( {
vertexShader: this.vsElevation,
fragmentShader: this.fsElevation,
} );
this.medianFilterMaterial = new THREE.RawShaderMaterial( {
uniforms: {
uWidth: {value: 1.0},
@ -872,28 +872,28 @@ Potree.DEMRenderer = class{
vertexShader: this.vsMedian,
fragmentShader: this.fsMedian,
});
this.camera = new THREE.OrthographicCamera(0, 1, 1, 0, 0, 1);
}
render(pointcloud, node){
if(!node.geometryNode){
return;
}
Potree.timerQueriesEnabled = true;
let start = new Date().getTime();
let queryAll = Potree.startQuery("All", this.renderer.getContext());
this.renderer.setClearColor(0x0000FF, 0);
this.renderer.clearTarget( this.target, true, true, true );
this.renderer.clearTarget(this.targetElevation, true, true, false );
this.renderer.clearTarget(this.targetMedian, true, true, false );
let box = node.geometryNode.boundingBox;
this.camera.up.set(0, 0, 1);
//this.camera.rotation.x = Math.PI / 2;
this.camera.left = box.min.x;
@ -903,53 +903,53 @@ Potree.DEMRenderer = class{
this.camera.near = -1000;
this.camera.far = 1000;
this.camera.updateProjectionMatrix();
let scene = new THREE.Scene();
//let material = new THREE.PointsMaterial({color: 0x00ff00, size: 0.0001});
let material = this.elevationMaterial;
let points = new THREE.Points(node.geometryNode.geometry, material);
scene.add(points);
this.renderer.render(points, this.camera, this.targetElevation);
this.medianFilterMaterial.uniforms.uWidth.value = this.targetMedian.width;
this.medianFilterMaterial.uniforms.uHeight.value = this.targetMedian.height;
this.medianFilterMaterial.uniforms.uTexture.value = this.targetElevation.texture;
Potree.utils.screenPass.render(this.renderer, this.medianFilterMaterial, this.targetMedian);
Potree.endQuery(queryAll, this.renderer.getContext());
Potree.resolveQueries(this.renderer.getContext());
Potree.timerQueriesEnabled = false;
setTimeout( () => {
let start = new Date().getTime();
let pixelCount = this.tileWidth * this.tileHeight;
let buffer = new Uint8Array(4 * pixelCount);
this.renderer.readRenderTargetPixels(this.targetMedian,
0, 0, this.tileWidth, this.tileHeight,
this.renderer.readRenderTargetPixels(this.targetMedian,
0, 0, this.tileWidth, this.tileHeight,
buffer);
let end = new Date().getTime();
let duration = end - start;
console.log(`read duration: ${duration}ms`);
}, 3000);
let end = new Date().getTime();
let duration = end - start;
console.log(`duration: ${duration}ms`);
//{ // open window with image
//
// let pixelCount = this.tileWidth * this.tileHeight;
// let buffer = new Float32Array(4 * pixelCount);
// this.renderer.readRenderTargetPixels(this.targetMedian,
// 0, 0, this.tileWidth, this.tileHeight,
// this.renderer.readRenderTargetPixels(this.targetMedian,
// 0, 0, this.tileWidth, this.tileHeight,
// buffer);
//
//
// let uiBuffer = new Uint8Array(4 * pixelCount);
// for(let i = 0; i < pixelCount; i++){
// uiBuffer[i] = buffer[i] / 1.0;
@ -957,18 +957,18 @@ Potree.DEMRenderer = class{
//
// let img = Potree.utils.pixelsArrayToImage(uiBuffer, this.tileWidth, this.tileHeight);
// let screenshot = img.src;
//
//
// if(!this.debugDIV){
// this.debugDIV = $(`
// <div id="pickDebug"
// style="position: absolute;
// <div id="pickDebug"
// style="position: absolute;
// right: 400px; width: 300px;
// bottom: 44px; width: 300px;
// z-index: 1000;
// "></div>`);
// $(document.body).append(this.debugDIV);
// }
//
//
// this.debugDIV.empty();
// this.debugDIV.append($(`<img src="${screenshot}"
// style="transform: scaleY(-1);"/>`));

View File

@ -39,15 +39,15 @@ Potree.PointCloudArena4DGeometryNode.prototype.getBoundingBox = function(){
Potree.PointCloudArena4DGeometryNode.prototype.getChildren = function(){
var children = [];
if(this.left){
children.push(this.left);
}
}
if(this.right){
children.push(this.right);
}
return children;
};
@ -64,36 +64,36 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){
if(this.loaded || this.loading){
return;
}
if(Potree.PointCloudArena4DGeometryNode.nodesLoading >= 5){
return;
}
this.loading = true;
Potree.PointCloudArena4DGeometryNode.nodesLoading++;
var url = this.pcoGeometry.url + "?node=" + this.number;
var xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "arraybuffer";
var scope = this;
xhr.onreadystatechange = function(){
if(!(xhr.readyState === 4 && xhr.status === 200)){
return;
}
var buffer = xhr.response;
var view = new DataView(buffer);
var numPoints = buffer.byteLength / 17;
var positions = new Float32Array(numPoints*3);
var colors = new Uint8Array(numPoints*3);
var indices = new ArrayBuffer(numPoints*4);
var iIndices = new Uint32Array(indices);
for(var i = 0; i < numPoints; i++){
var x = view.getFloat32(i*17 + 0, true) + scope.boundingBox.min.x;
var y = view.getFloat32(i*17 + 4, true) + scope.boundingBox.min.y;
@ -101,40 +101,40 @@ Potree.PointCloudArena4DGeometryNode.prototype.load = function(){
var r = view.getUint8(i*17 + 12, true);
var g = view.getUint8(i*17 + 13, true);
var b = view.getUint8(i*17 + 14, true);
positions[i*3+0] = x;
positions[i*3+1] = y;
positions[i*3+2] = z;
colors[i*3+0] = r;
colors[i*3+1] = g;
colors[i*3+2] = b;
iIndices[i] = i;
}
var geometry = new THREE.BufferGeometry();
geometry.addAttribute("position", new THREE.BufferAttribute(positions, 3));
geometry.addAttribute("color", new THREE.BufferAttribute(colors, 3, true));
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3));
let indicesAttribute = new THREE.Uint8BufferAttribute(indices, 4);
indicesAttribute.normalized = true;
geometry.addAttribute("indices", indicesAttribute);
scope.geometry = geometry;
scope.loaded = true;
Potree.PointCloudArena4DGeometryNode.nodesLoading--;
geometry.boundingBox = scope.boundingBox;
geometry.boundingSphere = scope.boundingSphere;
scope.numPoints = numPoints;
scope.loading = false;
};
xhr.send(null);
};
@ -143,7 +143,7 @@ Potree.PointCloudArena4DGeometryNode.prototype.dispose = function(){
this.geometry.dispose();
this.geometry = null;
this.loaded = false;
//this.dispatchEvent( { type: 'dispose' } );
for(var i = 0; i < this.oneTimeDisposeHandlers.length; i++){
var handler = this.oneTimeDisposeHandlers[i];
@ -183,12 +183,12 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){
var xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', url + "?info", true);
xhr.onreadystatechange = function(){
try{
if(xhr.readyState === 4 && xhr.status === 200){
var response = JSON.parse(xhr.responseText);
var geometry = new Potree.PointCloudArena4DGeometry();
geometry.url = url;
geometry.name = response.Name;
@ -203,19 +203,19 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){
if(response.Spacing){
geometry.spacing = response.Spacing;
}
var offset = geometry.boundingBox.min.clone().multiplyScalar(-1);
geometry.boundingBox.min.add(offset);
geometry.boundingBox.max.add(offset);
geometry.offset = offset;
var center = geometry.boundingBox.getCenter();
var radius = geometry.boundingBox.getSize().length() / 2;
geometry.boundingSphere = new THREE.Sphere(center, radius);
geometry.loadHierarchy();
callback(geometry);
}else if(xhr.readyState === 4){
callback(null);
@ -225,39 +225,39 @@ Potree.PointCloudArena4DGeometry.load = function(url, callback){
callback(null);
}
};
xhr.send(null);
};
Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){
var url = this.url + "?tree";
var url = this.url + "?tree";
var xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open("GET", url, true);
xhr.responseType = "arraybuffer";
var scope = this;
xhr.onreadystatechange = function(){
if(!(xhr.readyState === 4 && xhr.status === 200)){
return;
}
var buffer = xhr.response;
var numNodes = buffer.byteLength / 3;
var view = new DataView(buffer);
var stack = [];
var root = null;
var levels = 0;
var start = new Date().getTime();
// read hierarchy
for(var i = 0; i < numNodes; i++){
var mask = view.getUint8(i*3+0, true);
var numPoints = view.getUint16(i*3+1, true);
var hasLeft = (mask & 1) > 0;
var hasRight = (mask & 2) > 0;
var splitX = (mask & 4) > 0;
@ -271,8 +271,8 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){
}if(splitZ){
split = "Z";
}
var node = new Potree.PointCloudArena4DGeometryNode();
node.hasLeft = hasLeft;
node.hasRight = hasRight;
@ -284,16 +284,16 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){
node.pcoGeometry = scope;
node.level = stack.length;
levels = Math.max(levels, node.level);
if(stack.length > 0){
var parent = stack[stack.length-1];
node.boundingBox = parent.boundingBox.clone();
var parentBBSize = parent.boundingBox.getSize();
if(parent.hasLeft && !parent.left){
parent.left = node;
parent.children.push(node);
if(parent.split === "X"){
node.boundingBox.max.x = node.boundingBox.min.x + parentBBSize.x / 2;
}else if(parent.split === "Y"){
@ -301,15 +301,15 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){
}else if(parent.split === "Z"){
node.boundingBox.max.z = node.boundingBox.min.z + parentBBSize.z / 2;
}
var center = node.boundingBox.getCenter();
var radius = node.boundingBox.getSize().length() / 2;
node.boundingSphere = new THREE.Sphere(center, radius);
}else{
parent.right = node;
parent.children.push(node);
if(parent.split === "X"){
node.boundingBox.min.x = node.boundingBox.min.x + parentBBSize.x / 2;
}else if(parent.split === "Y"){
@ -317,7 +317,7 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){
}else if(parent.split === "Z"){
node.boundingBox.min.z = node.boundingBox.min.z + parentBBSize.z / 2;
}
var center = node.boundingBox.getCenter();
var radius = node.boundingBox.getSize().length() / 2;
node.boundingSphere = new THREE.Sphere(center, radius);
@ -329,19 +329,19 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){
var radius = root.boundingBox.getSize().length() / 2;
root.boundingSphere = new THREE.Sphere(center, radius);
}
var bbSize = node.boundingBox.getSize();
node.spacing = ((bbSize.x + bbSize.y + bbSize.z) / 3) / 75;
stack.push(node);
if(node.isLeaf){
var done = false;
while(!done && stack.length > 0){
stack.pop();
var top = stack[stack.length-1];
done = stack.length > 0 && top.hasRight && top.right == null;
}
}
@ -350,18 +350,18 @@ Potree.PointCloudArena4DGeometry.prototype.loadHierarchy = function(){
var parseDuration = end - start;
var msg = parseDuration;
//document.getElementById("lblDebug").innerHTML = msg;
scope.root = root;
scope.levels = levels;
//console.log(this.root);
scope.dispatchEvent({type: "hierarchy_loaded"});
};
xhr.send(null);
};
Object.defineProperty(Potree.PointCloudArena4DGeometry.prototype, "spacing", {

View File

@ -7,7 +7,7 @@
*/
class GreyhoundUtils{
static getQueryParam(name) {
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
@ -16,7 +16,7 @@ class GreyhoundUtils{
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
static createSchema(attributes) {
var schema = [
{ "name": "X", "size": 4, "type": "signed" },
@ -46,7 +46,7 @@ class GreyhoundUtils{
return schema;
}
static fetch(url, cb) {
var xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', url, true);
@ -129,7 +129,7 @@ class GreyhoundUtils{
cb(null, { color: colorNorm, intensity: intensityNorm });
});
};
};
Potree.GreyhoundLoader = function() { };

View File

@ -7,9 +7,9 @@
* Thanks to Uday Verma and Howard Butler
*
*/
Potree.LasLazLoader = class LasLazLoader{
constructor(version){
if(typeof(version) === "string"){
this.version = new Potree.Version(version);
@ -17,27 +17,27 @@ Potree.LasLazLoader = class LasLazLoader{
this.version = version;
}
}
static progressCB(){
}
load(node){
if(node.loaded){
return;
}
let pointAttributes = node.pcoGeometry.pointAttributes;
let url = node.getURL();
if(this.version.equalOrHigher("1.4")){
url += "." + pointAttributes.toLowerCase();
}
let scope = this;
let xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
@ -52,14 +52,14 @@ Potree.LasLazLoader = class LasLazLoader{
}
}
};
xhr.send(null);
}
parse(node, buffer){
let lf = new LASFile(buffer);
let handler = new Potree.LasLazBatcher(node);
return Promise.resolve(lf).cancellable().then(function(lf) {
return lf.open().then(function() {
lf.isOpen = true;
@ -79,7 +79,7 @@ Potree.LasLazLoader = class LasLazLoader{
}).then(function(v) {
let lf = v[0];
let header = v[1];
let skip = 1;
let totalRead = 0;
let totalToRead = (skip <= 1 ? header.pointsCount : header.pointsCount / skip);
@ -108,7 +108,7 @@ Potree.LasLazLoader = class LasLazLoader{
}
});
};
return reader();
}).then(function(v) {
let lf = v[0];
@ -130,7 +130,7 @@ Potree.LasLazLoader = class LasLazLoader{
}).catch(Promise.CancellationError, function(e) {
// If there was a cancellation, make sure the file is closed, if the file is open
// close and then fail
if (lf.isOpen)
if (lf.isOpen)
return lf.close().then(function() {
lf.isOpen = false;
throw e;
@ -138,32 +138,32 @@ Potree.LasLazLoader = class LasLazLoader{
throw e;
});
}
handle(node, url){
}
};
Potree.LasLazBatcher = class LasLazBatcher{
constructor(node){
constructor(node){
this.node = node;
}
push(lasBuffer){
let workerPath = Potree.scriptPath + "/workers/LASDecoderWorker.js";
let worker = Potree.workerPool.getWorker(workerPath);
worker.onmessage = (e) => {
let geometry = new THREE.BufferGeometry();
let numPoints = lasBuffer.pointsCount;
let endsWith = function(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
};
let positions = e.data.position;
let colors = new Uint8Array(e.data.color);
let intensities = e.data.intensity;
@ -173,14 +173,14 @@ Potree.LasLazBatcher = class LasLazBatcher{
let pointSourceIDs = new Uint16Array(e.data.pointSourceID);
//let indices = new ArrayBuffer(numPoints*4);
//let iIndices = new Uint32Array(indices);
//let box = new THREE.Box3();
//
//let fPositions = new Float32Array(positions);
//for(let i = 0; i < numPoints; i++){
//for(let i = 0; i < numPoints; i++){
// box.expandByPoint(new THREE.Vector3(fPositions[3*i+0], fPositions[3*i+1], fPositions[3*i+2]));
//}
geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(positions), 3));
geometry.addAttribute('color', new THREE.BufferAttribute(colors, 3, true));
geometry.addAttribute('intensity', new THREE.BufferAttribute(new Float32Array(intensities), 1));
@ -189,28 +189,28 @@ Potree.LasLazBatcher = class LasLazBatcher{
geometry.addAttribute('numberOfReturns', new THREE.BufferAttribute(numberOfReturns, 1));
geometry.addAttribute('pointSourceID', new THREE.BufferAttribute(pointSourceIDs, 1));
geometry.addAttribute("normal", new THREE.BufferAttribute(new Float32Array(numPoints*3), 3));
let indicesAttribute = new THREE.Uint8BufferAttribute(e.data.indices, 4);
indicesAttribute.normalized = true;
geometry.addAttribute("indices", indicesAttribute);
let tightBoundingBox = new THREE.Box3(
new THREE.Vector3().fromArray(e.data.tightBoundingBox.min),
new THREE.Vector3().fromArray(e.data.tightBoundingBox.max)
);
geometry.boundingBox = this.node.boundingBox;
this.node.tightBoundingBox = tightBoundingBox;
this.node.geometry = geometry;
this.node.loaded = true;
this.node.loading = false;
this.node.pcoGeometry.numNodesLoading--;
this.node.mean = new THREE.Vector3(...e.data.mean);
Potree.workerPool.returnWorker(workerPath, worker);
};
let message = {
buffer: lasBuffer.arrayb,
numPoints: lasBuffer.pointsCount,

View File

@ -1,15 +1,15 @@
Potree.utils = class{
static loadShapefileFeatures(file, callback){
let features = [];
let handleFinish = () => {
callback(features);
};
shapefile.open(file)
.then(source => {source.read()
.then(function log(result){
@ -17,18 +17,18 @@ Potree.utils = class{
handleFinish();
return;
}
//console.log(result.value);
if(result.value && result.value.type === "Feature" && result.value.geometry !== undefined){
features.push(result.value);
}
return source.read().then(log);
})
});
}
static toString(value){
if(value instanceof THREE.Vector3){
return value.x.toFixed(2) + ", " + value.y.toFixed(2) + ", " + value.z.toFixed(2);
@ -36,10 +36,10 @@ Potree.utils = class{
return "" + value + "";
}
}
static normalizeURL(url){
let u = new URL(url);
return u.protocol + "//" + u.hostname + u.pathname.replace(/\/+/g, "/");
};
@ -69,16 +69,16 @@ Potree.utils = class{
new THREE.Vector3(box.max.x, box.min.y, box.max.z).applyMatrix4(transform),
new THREE.Vector3(box.max.x, box.max.y, box.max.z).applyMatrix4(transform)
];
let boundingBox = new THREE.Box3();
boundingBox.setFromPoints( vertices );
return boundingBox;
};
/**
* add separators to large numbers
*
*
* @param nStr
* @returns
*/
@ -93,7 +93,7 @@ Potree.utils = class{
}
return x1 + x2;
};
static removeCommas(str){
return str.replace(/,/g, "");
}
@ -106,7 +106,7 @@ Potree.utils = class{
static createWorker(code){
let blob = new Blob([code], {type: 'application/javascript'});
let worker = new Worker(URL.createObjectURL(blob));
return worker;
};
@ -121,7 +121,7 @@ Potree.utils = class{
path + 'py' + format, path + 'ny' + format,
path + 'pz' + format, path + 'nz' + format
];
//var materialArray = [];
//for (var i = 0; i < 6; i++){
// materialArray.push( new THREE.MeshBasicMaterial({
@ -132,20 +132,20 @@ Potree.utils = class{
// })
// );
//}
let materialArray = [];
{
for (let i = 0; i < 6; i++){
let material = new THREE.MeshBasicMaterial({
map: null,
side: THREE.BackSide,
depthTest: false,
depthWrite: false
});
materialArray.push(material);
let loader = new THREE.TextureLoader();
loader.load( urls[i],
function loaded(texture){
@ -158,18 +158,18 @@ Potree.utils = class{
}
);
}
}
var skyGeometry = new THREE.CubeGeometry( 5000, 5000, 5000 );
var skybox = new THREE.Mesh( skyGeometry, materialArray );
scene.add(skybox);
// z up
scene.rotation.x = Math.PI / 2;
return {"camera": camera, "scene": scene};
};
@ -177,18 +177,18 @@ Potree.utils = class{
let material = new THREE.LineBasicMaterial({
color: color || 0x888888
});
let geometry = new THREE.Geometry();
for(let i = 0; i <= length; i++){
geometry.vertices.push(new THREE.Vector3(-(spacing*width)/2, i*spacing-(spacing*length)/2, 0));
geometry.vertices.push(new THREE.Vector3(+(spacing*width)/2, i*spacing-(spacing*length)/2, 0));
}
for(let i = 0; i <= width; i++){
geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, -(spacing*length)/2, 0));
geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, +(spacing*length)/2, 0));
}
let line = new THREE.LineSegments(geometry, material, THREE.LinePieces);
line.receiveShadow = true;
return line;
@ -212,24 +212,24 @@ Potree.utils = class{
for(let y = 0; y < height; y++){
let u = 2 * (x / width) - 1;
let v = 2 * (y / height) - 1;
let i = x + width*y;
let d = gauss(2*u, 2*v) / max;
let r = (Math.random() + Math.random() + Math.random()) / 3;
r = (d * 0.5 + 0.5) * r * 0.03;
r = r * 0.4;
//d = Math.pow(d, 0.6);
data[3*i+0] = 255 * (d / 15 + 0.05 + r) * chroma[0];
data[3*i+1] = 255 * (d / 15 + 0.05 + r) * chroma[1];
data[3*i+2] = 255 * (d / 15 + 0.05 + r) * chroma[2];
}
}
let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat );
texture.needsUpdate = true;
return texture;
};
@ -238,31 +238,31 @@ Potree.utils = class{
x: (mouse.x / renderer.domElement.clientWidth ) * 2 - 1,
y: - (mouse.y / renderer.domElement.clientHeight ) * 2 + 1
};
//let vector = new THREE.Vector3( nmouse.x, nmouse.y, 0.5 );
//vector.unproject(camera);
//let direction = vector.sub(camera.position).normalize();
//let ray = new THREE.Ray(camera.position, direction);
let raycaster = new THREE.Raycaster();
raycaster.setFromCamera(nmouse, camera);
let ray = raycaster.ray;
let selectedPointcloud = null;
let closestDistance = Infinity;
let closestIntersection = null;
let closestPoint = null;
for(let pointcloud of pointclouds){
let point = pointcloud.pick(renderer, camera, ray);
if(!point){
continue;
}
let distance = camera.position.distanceTo(point.position);
if(distance < closestDistance){
closestDistance = distance;
selectedPointcloud = pointcloud;
@ -270,7 +270,7 @@ Potree.utils = class{
closestPoint = point;
}
}
if(selectedPointcloud){
return {
location: closestIntersection,
@ -281,17 +281,17 @@ Potree.utils = class{
}else{
return null;
}
};
};
static pixelsArrayToImage(pixels, width, height){
let canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
let context = canvas.getContext('2d');
pixels = new pixels.constructor(pixels);
for(let i = 0; i < pixels.length; i++){
pixels[i*4 + 3] = 255;
}
@ -303,18 +303,18 @@ Potree.utils = class{
let img = new Image();
img.src = canvas.toDataURL();
//img.style.transform = "scaleY(-1)";
return img;
};
static projectedRadius(radius, fov, distance, screenHeight){
let projFactor = (1 / Math.tan(fov / 2)) / distance;
projFactor = projFactor * screenHeight / 2;
return radius * projFactor;
};
static topView(camera, node){
camera.position.set(0, 1, 0);
camera.rotation.set(-Math.PI / 2, 0, 0);
@ -339,9 +339,9 @@ Potree.utils = class{
camera.rotation.set(0, Math.PI / 2, 0);
camera.zoomTo(node, 1);
};
/**
*
*
* 0: no intersection
* 1: intersection
* 2: fully inside
@ -352,7 +352,7 @@ Potree.utils = class{
let negRadius = - sphere.radius;
let minDistance = Number.MAX_VALUE;
for ( let i = 0; i < 6; i ++ ) {
let distance = planes[ i ].distanceToPoint( center );
@ -362,47 +362,47 @@ Potree.utils = class{
return 0;
}
minDistance = Math.min(minDistance, distance);
}
return (minDistance >= sphere.radius) ? 2 : 1;
};
// code taken from three.js
// ImageUtils - generateDataTexture()
static generateDataTexture(width, height, color){
let size = width * height;
let data = new Uint8Array(3 * width * height);
let r = Math.floor( color.r * 255 );
let g = Math.floor( color.g * 255 );
let b = Math.floor( color.b * 255 );
for ( let i = 0; i < size; i ++ ) {
data[ i * 3 ] = r;
data[ i * 3 + 1 ] = g;
data[ i * 3 + 2 ] = b;
}
let texture = new THREE.DataTexture( data, width, height, THREE.RGBFormat );
texture.needsUpdate = true;
texture.magFilter = THREE.NearestFilter;
return texture;
};
// from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
static getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
let regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search);
return results === null ? null : decodeURIComponent(results[1].replace(/\+/g, " "));
}
static setParameter(name, value){
//value = encodeURIComponent(value);
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
let regex = new RegExp("([\\?&])(" + name + "=([^&#]*))");
let results = regex.exec(location.search);
@ -422,7 +422,7 @@ Potree.utils = class{
}
window.history.replaceState({}, "", url);
}
};
Potree.utils.screenPass = new function(){
@ -434,10 +434,10 @@ Potree.utils.screenPass = new function(){
this.screenQuad.material.transparent = true;
this.screenScene.add(this.screenQuad);
this.camera = new THREE.Camera();
this.render = function(renderer, material, target){
this.screenQuad.material = material;
if(typeof target === "undefined"){
renderer.render(this.screenScene, this.camera);
}else{

File diff suppressed because it is too large Load Diff