ES6ify, update README

This commit is contained in:
m-schuetz 2018-02-16 18:29:08 +01:00
parent 6d653dc9ed
commit ac7ea42101
38 changed files with 876 additions and 890 deletions

View File

@ -1,4 +1,3 @@
[![Build Status](https://travis-ci.org/potree/potree.svg?branch=master)](https://travis-ci.org/potree/potree) [![js-happiness-style](https://img.shields.io/badge/code%20style-happiness-brightgreen.svg)](https://github.com/JedWatson/happiness) [![Gitter potree/Lobby](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/potree/Lobby)
# README
@ -31,13 +30,14 @@ Take a look at the [potree showcase](http://potree.org/wp/demo/) for some live e
## Compatibility
| Browser | OS | Result |
| -------------------- |:-------:|:-------------:|
| Chrome 56 | Win7 | works |
| Firefox 51 | Win7 | works |
| Internet Explorer 11 | Win7 | not supported |
| Chrome | Android | works |
| Opera | Android | not supported |
| Browser | OS | Result | |
| -------------------- |:-------:|:-------------:|:-:|
| Chrome 64 | Win10 | works | |
| Firefox 58 | Win10 | works | |
| Edge | Win10 | not supported | |
| Internet Explorer 11 | Win7 | not supported | |
| Chrome | Android | works | Reduced functionality due to unsupported WebGL extensions |
| Opera | Android | works | Reduced functionality due to unsupported WebGL extensions |
## Credits

View File

@ -239,7 +239,8 @@ gulp.task('examples_page', function() {
{
for(let example of settings.examples){
exampleCode += `<a href="${example.url}" target="_blank" style="display: inline-block">
exampleCode += `
<a href="${example.url}" target="_blank" style="display: inline-block">
<div class="thumb" style="background-image: url('${example.thumb}'); ">
<div class="thumb-label">${example.label}</div>
</div>
@ -268,6 +269,7 @@ gulp.task('examples_page', function() {
body{
background: #ECE9E9;
padding: 30px;
}
.thumb{

View File

@ -304,8 +304,8 @@ Potree.Annotation = class extends THREE.EventDispatcher {
}
let view = this.scene.view;
var animationDuration = 500;
var easing = TWEEN.Easing.Quartic.Out;
let animationDuration = 500;
let easing = TWEEN.Easing.Quartic.Out;
let endTarget;
if (this.cameraTarget) {
@ -328,12 +328,12 @@ Potree.Annotation = class extends THREE.EventDispatcher {
//}
//{ // animate camera target
// var camTargetDistance = camera.position.distanceTo(endTarget);
// var target = new THREE.Vector3().addVectors(
// let camTargetDistance = camera.position.distanceTo(endTarget);
// let target = new THREE.Vector3().addVectors(
// camera.position,
// camera.getWorldDirection().clone().multiplyScalar(camTargetDistance)
// );
// var tween = new TWEEN.Tween(target).to(endTarget, animationDuration);
// let tween = new TWEEN.Tween(target).to(endTarget, animationDuration);
// tween.easing(easing);
// tween.onUpdate(() => {
// view.lookAt(target);

View File

@ -19,11 +19,11 @@
*
*/
BitReader = function (buf) {
var buffer = new Uint32Array(buf);
var bitOffset = 0;
let buffer = new Uint32Array(buf);
let bitOffset = 0;
this.read = function (bits) {
var result;
let result;
// TODO val & leftGap seem to be duplicate code? Move out of if-block
if ((bitOffset % 32) + bits <= 32) {

View File

@ -1,23 +1,23 @@
Potree.Features = (function () {
var ftCanvas = document.createElement('canvas');
var gl = ftCanvas.getContext('webgl') || ftCanvas.getContext('experimental-webgl');
let ftCanvas = document.createElement('canvas');
let gl = ftCanvas.getContext('webgl') || ftCanvas.getContext('experimental-webgl');
if (gl === null) { return null; }
// -- code taken from THREE.WebGLRenderer --
var _vertexShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT);
var _vertexShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT);
// Unused: var _vertexShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
let _vertexShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT);
let _vertexShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.MEDIUM_FLOAT);
// Unused: let _vertexShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.LOW_FLOAT);
var _fragmentShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
var _fragmentShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT);
// Unused: var _fragmentShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT);
let _fragmentShaderPrecisionHighpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.HIGH_FLOAT);
let _fragmentShaderPrecisionMediumpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT);
// Unused: let _fragmentShaderPrecisionLowpFloat = gl.getShaderPrecisionFormat(gl.FRAGMENT_SHADER, gl.LOW_FLOAT);
var highpAvailable = _vertexShaderPrecisionHighpFloat.precision > 0 && _fragmentShaderPrecisionHighpFloat.precision > 0;
var mediumpAvailable = _vertexShaderPrecisionMediumpFloat.precision > 0 && _fragmentShaderPrecisionMediumpFloat.precision > 0;
let highpAvailable = _vertexShaderPrecisionHighpFloat.precision > 0 && _fragmentShaderPrecisionHighpFloat.precision > 0;
let mediumpAvailable = _vertexShaderPrecisionMediumpFloat.precision > 0 && _fragmentShaderPrecisionMediumpFloat.precision > 0;
// -----------------------------------------
var precision;
let precision;
if (highpAvailable) {
precision = 'highp';
} else if (mediumpAvailable) {
@ -29,7 +29,7 @@ Potree.Features = (function () {
return {
SHADER_INTERPOLATION: {
isSupported: function () {
var supported = true;
let supported = true;
supported = supported && gl.getExtension('EXT_frag_depth');
supported = supported && gl.getParameter(gl.MAX_VARYING_VECTORS) >= 8;
@ -39,7 +39,7 @@ Potree.Features = (function () {
},
SHADER_SPLATS: {
isSupported: function () {
var supported = true;
let supported = true;
supported = supported && gl.getExtension('EXT_frag_depth');
supported = supported && gl.getExtension('OES_texture_float');
@ -51,7 +51,7 @@ Potree.Features = (function () {
},
SHADER_EDL: {
isSupported: function () {
var supported = true;
let supported = true;
//supported = supported && gl.getExtension('EXT_frag_depth');
supported = supported && gl.getExtension('OES_texture_float');

View File

@ -48,7 +48,7 @@ LRU.prototype.touch = function (node) {
return;
}
var item;
let item;
if (this.items[node.id] == null) {
// add to list
item = new LRUItem(node);
@ -92,35 +92,8 @@ LRU.prototype.touch = function (node) {
}
};
/// **
// * removes the least recently used item from the list and returns it.
// * if the list was empty, null will be returned.
// */
// LRU.prototype.remove = function remove(){
// if(this.first === null){
// return null;
// }
// var lru = this.first;
//
// // if the lru list contains at least 2 items, the item after the least recently used elemnt will be the new lru item.
// if(lru.next !== null){
// this.first = lru.next;
// this.first.previous = null;
// }else{
// this.first = null;
// this.last = null;
// }
//
// delete this.items[lru.node.id];
// this.elements--;
// this.numPoints -= lru.node.numPoints;
//
/// / Logger.info("removed node: " + lru.node.id);
// return lru.node;
// };
LRU.prototype.remove = function remove (node) {
var lruItem = this.items[node.id];
let lruItem = this.items[node.id];
if (lruItem) {
if (this.elements === 1) {
this.first = null;
@ -150,14 +123,14 @@ LRU.prototype.getLRUItem = function () {
if (this.first === null) {
return null;
}
var lru = this.first;
let lru = this.first;
return lru.node;
};
LRU.prototype.toString = function () {
var string = '{ ';
var curr = this.first;
let string = '{ ';
let curr = this.first;
while (curr !== null) {
string += curr.node.id;
if (curr.next !== null) {
@ -176,26 +149,26 @@ LRU.prototype.freeMemory = function () {
}
while (this.numPoints > Potree.pointLoadLimit) {
var element = this.first;
var node = element.node;
let element = this.first;
let node = element.node;
this.disposeDescendants(node);
}
};
LRU.prototype.disposeDescendants = function (node) {
var stack = [];
let stack = [];
stack.push(node);
while (stack.length > 0) {
var current = stack.pop();
let current = stack.pop();
// console.log(current);
current.dispose();
this.remove(current);
for (var key in current.children) {
for (let key in current.children) {
if (current.children.hasOwnProperty(key)) {
var child = current.children[key];
let child = current.children[key];
if (child.loaded) {
stack.push(current.children[key]);
}

View File

@ -68,9 +68,9 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.getLevel = function () {
};
Potree.PointCloudGreyhoundGeometryNode.prototype.getChildren = function () {
var children = [];
let children = [];
for (var i = 0; i < 8; ++i) {
for (let i = 0; i < 8; ++i) {
if (this.children[i]) {
children.push(this.children[i]);
}
@ -80,14 +80,14 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.getChildren = function () {
};
Potree.PointCloudGreyhoundGeometryNode.prototype.getURL = function () {
var schema = this.pcoGeometry.schema;
let schema = this.pcoGeometry.schema;
let bounds = this.greyhoundBounds;
var boundsString =
let boundsString =
bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' +
bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z;
var url = '' + this.pcoGeometry.serverURL +
let url = '' + this.pcoGeometry.serverURL +
'read?depthBegin=' +
(this.baseLoaded ? (this.level + this.pcoGeometry.baseDepth) : 0) +
'&depthEnd=' + (this.level + this.pcoGeometry.baseDepth + 1) +
@ -140,10 +140,10 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.loadPoints = function () {
Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = function () {
// From Greyhound (Cartesian) ordering for the octree to Potree-default
var transform = [0, 2, 1, 3, 4, 6, 5, 7];
let transform = [0, 2, 1, 3, 4, 6, 5, 7];
var makeBitMask = function (node) {
var mask = 0;
let makeBitMask = function (node) {
let mask = 0;
Object.keys(node).forEach(function (key) {
if (key === 'swd') mask += 1 << transform[0];
else if (key === 'nwd') mask += 1 << transform[1];
@ -157,10 +157,10 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = funct
return mask;
};
var parseChildrenCounts = function (base, parentName, stack) {
var keys = Object.keys(base);
var child;
var childName;
let parseChildrenCounts = function (base, parentName, stack) {
let keys = Object.keys(base);
let child;
let childName;
keys.forEach(function (key) {
if (key === 'n') return;
@ -204,26 +204,26 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = funct
};
// Load hierarchy.
var callback = function (node, greyhoundHierarchy) {
var decoded = [];
let callback = function (node, greyhoundHierarchy) {
let decoded = [];
node.numPoints = greyhoundHierarchy.n;
parseChildrenCounts(greyhoundHierarchy, node.name, decoded);
var nodes = {};
let nodes = {};
nodes[node.name] = node;
var pgg = node.pcoGeometry;
let pgg = 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 = Potree.GreyhoundLoader.createChildAABB(
for (let i = 0; i < decoded.length; i++) {
let name = decoded[i].name;
let numPoints = decoded[i].numPoints;
let index = parseInt(name.charAt(name.length - 1));
let parentName = name.substring(0, name.length - 1);
let parentNode = nodes[parentName];
let level = name.length - 1;
let boundingBox = Potree.GreyhoundLoader.createChildAABB(
parentNode.boundingBox, index);
var currentNode = new Potree.PointCloudGreyhoundGeometryNode(
let currentNode = new Potree.PointCloudGreyhoundGeometryNode(
name, pgg, boundingBox, node.scale, node.offset);
currentNode.level = level;
@ -238,16 +238,16 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = funct
};
if (this.level % this.pcoGeometry.hierarchyStepSize === 0) {
var depthBegin = this.level + this.pcoGeometry.baseDepth;
var depthEnd = depthBegin + this.pcoGeometry.hierarchyStepSize + 2;
let depthBegin = this.level + this.pcoGeometry.baseDepth;
let depthEnd = depthBegin + this.pcoGeometry.hierarchyStepSize + 2;
let bounds = this.greyhoundBounds;
var boundsString =
let boundsString =
bounds.min.x + ',' + bounds.min.y + ',' + bounds.min.z + ',' +
bounds.max.x + ',' + bounds.max.y + ',' + bounds.max.z;
var hurl = '' + this.pcoGeometry.serverURL +
let hurl = '' + this.pcoGeometry.serverURL +
'hierarchy?bounds=[' + boundsString + ']' +
'&depthBegin=' + depthBegin +
'&depthEnd=' + depthEnd;
@ -261,14 +261,14 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.loadHierarchyThenPoints = funct
hurl += '&offset=[' + offset.x + ',' + offset.y + ',' + offset.z + ']';
}
var xhr = Potree.XHRFactory.createXMLHttpRequest();
let xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', hurl, true);
var that = this;
let that = this;
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 0) {
var greyhoundHierarchy = JSON.parse(xhr.responseText) || { };
let greyhoundHierarchy = JSON.parse(xhr.responseText) || { };
callback(that, greyhoundHierarchy);
} else {
console.log(
@ -298,8 +298,8 @@ Potree.PointCloudGreyhoundGeometryNode.prototype.dispose = function () {
this.loaded = false;
// this.dispatchEvent( { type: 'dispose' } );
for (var i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
var handler = this.oneTimeDisposeHandlers[i];
for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
let handler = this.oneTimeDisposeHandlers[i];
handler();
}
this.oneTimeDisposeHandlers = [];

View File

@ -356,7 +356,7 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree {
let _ray = ray.clone();
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
// var inverseWorld = new THREE.Matrix4().getInverse(node.matrixWorld);
// let inverseWorld = new THREE.Matrix4().getInverse(node.matrixWorld);
// let sphere = node.getBoundingSphere().clone().applyMatrix4(node.sceneNode.matrixWorld);
let sphere = node.getBoundingSphere().clone().applyMatrix4(this.matrixWorld);
@ -440,7 +440,7 @@ Potree.PointCloudOctree = class extends Potree.PointCloudTree {
*
*
* The return value is an array with all segments of the profile path
* var segment = {
* let segment = {
* start: THREE.Vector3,
* end: THREE.Vector3,
* points: {}

View File

@ -1,247 +1,253 @@
Potree.PointCloudOctreeGeometry = function () {
this.url = null;
this.octreeDir = null;
this.spacing = 0;
this.boundingBox = null;
this.root = null;
this.nodes = null;
this.pointAttributes = null;
this.hierarchyStepSize = -1;
this.loader = null;
Potree.PointCloudOctreeGeometry = class PointCloudOctreeGeometry{
constructor(){
this.url = null;
this.octreeDir = null;
this.spacing = 0;
this.boundingBox = null;
this.root = null;
this.nodes = null;
this.pointAttributes = null;
this.hierarchyStepSize = -1;
this.loader = null;
}
};
Potree.PointCloudOctreeGeometryNode = function (name, pcoGeometry, boundingBox) {
this.id = Potree.PointCloudOctreeGeometryNode.IDCount++;
this.name = name;
this.index = parseInt(name.charAt(name.length - 1));
this.pcoGeometry = pcoGeometry;
this.geometry = null;
this.boundingBox = boundingBox;
this.boundingSphere = boundingBox.getBoundingSphere();
this.children = {};
this.numPoints = 0;
this.level = null;
this.loaded = false;
this.oneTimeDisposeHandlers = [];
};
Potree.PointCloudOctreeGeometryNode = class PointCloudOctreeGeometryNode extends Potree.PointCloudTreeNode{
Potree.PointCloudOctreeGeometryNode.IDCount = 0;
constructor(name, pcoGeometry, boundingBox){
super();
Potree.PointCloudOctreeGeometryNode.prototype = Object.create(Potree.PointCloudTreeNode.prototype);
this.id = Potree.PointCloudOctreeGeometryNode.IDCount++;
this.name = name;
this.index = parseInt(name.charAt(name.length - 1));
this.pcoGeometry = pcoGeometry;
this.geometry = null;
this.boundingBox = boundingBox;
this.boundingSphere = boundingBox.getBoundingSphere();
this.children = {};
this.numPoints = 0;
this.level = null;
this.loaded = false;
this.oneTimeDisposeHandlers = [];
}
Potree.PointCloudOctreeGeometryNode.prototype.isGeometryNode = function () {
return true;
};
isGeometryNode(){
return true;
}
Potree.PointCloudOctreeGeometryNode.prototype.getLevel = function () {
return this.level;
};
getLevel(){
return this.level;
}
Potree.PointCloudOctreeGeometryNode.prototype.isTreeNode = function () {
return false;
};
isTreeNode(){
return false;
}
Potree.PointCloudOctreeGeometryNode.prototype.isLoaded = function () {
return this.loaded;
};
isLoaded(){
return this.loaded;
}
Potree.PointCloudOctreeGeometryNode.prototype.getBoundingSphere = function () {
return this.boundingSphere;
};
getBoundingSphere(){
return this.boundingSphere;
}
Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function () {
return this.boundingBox;
};
getBoundingBox(){
return this.boundingBox;
}
Potree.PointCloudOctreeGeometryNode.prototype.getChildren = function () {
var children = [];
getChildren(){
let children = [];
for (var i = 0; i < 8; i++) {
if (this.children[i]) {
children.push(this.children[i]);
for (let i = 0; i < 8; i++) {
if (this.children[i]) {
children.push(this.children[i]);
}
}
return children;
}
return children;
};
Potree.PointCloudOctreeGeometryNode.prototype.getBoundingBox = function () {
return this.boundingBox;
};
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;
getBoundingBox(){
return this.boundingBox;
}
return url;
};
getURL(){
let url = '';
Potree.PointCloudOctreeGeometryNode.prototype.getHierarchyPath = function () {
var path = 'r/';
let version = this.pcoGeometry.loader.version;
var hierarchyStepSize = this.pcoGeometry.hierarchyStepSize;
var indices = this.name.substr(1);
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;
}
var numParts = Math.floor(indices.length / hierarchyStepSize);
for (var i = 0; i < numParts; i++) {
path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + '/';
return url;
}
path = path.slice(0, -1);
getHierarchyPath(){
let path = 'r/';
return path;
};
let hierarchyStepSize = this.pcoGeometry.hierarchyStepSize;
let indices = this.name.substr(1);
Potree.PointCloudOctreeGeometryNode.prototype.addChild = function (child) {
this.children[child.index] = child;
child.parent = this;
};
let numParts = Math.floor(indices.length / hierarchyStepSize);
for (let i = 0; i < numParts; i++) {
path += indices.substr(i * hierarchyStepSize, hierarchyStepSize) + '/';
}
Potree.PointCloudOctreeGeometryNode.prototype.load = function () {
if (this.loading === true || this.loaded === true || Potree.numNodesLoading >= Potree.maxNodesLoading) {
return;
path = path.slice(0, -1);
return path;
}
this.loading = true;
addChild(child) {
this.children[child.index] = child;
child.parent = this;
}
Potree.numNodesLoading++;
load(){
if (this.loading === true || this.loaded === true || Potree.numNodesLoading >= Potree.maxNodesLoading) {
return;
}
if (this.pcoGeometry.loader.version.equalOrHigher('1.5')) {
if ((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren) {
this.loadHierachyThenPoints();
this.loading = true;
Potree.numNodesLoading++;
if (this.pcoGeometry.loader.version.equalOrHigher('1.5')) {
if ((this.level % this.pcoGeometry.hierarchyStepSize) === 0 && this.hasChildren) {
this.loadHierachyThenPoints();
} else {
this.loadPoints();
}
} else {
this.loadPoints();
}
} else {
this.loadPoints();
}
};
Potree.PointCloudOctreeGeometryNode.prototype.loadPoints = function () {
this.pcoGeometry.loader.load(this);
};
loadPoints(){
this.pcoGeometry.loader.load(this);
}
Potree.PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function () {
var node = this;
loadHierachyThenPoints(){
let node = this;
// load hierarchy
var callback = function (node, hbuffer) {
var view = new DataView(hbuffer);
// load hierarchy
let callback = function (node, hbuffer) {
let 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});
let stack = [];
let children = view.getUint8(0);
let numPoints = view.getUint32(1, true);
node.numPoints = numPoints;
stack.push({children: children, numPoints: numPoints, name: node.name});
var decoded = [];
let decoded = [];
var offset = 5;
while (stack.length > 0) {
var snode = stack.shift();
var mask = 1;
for (let i = 0; i < 8; i++) {
if ((snode.children & mask) !== 0) {
var childName = snode.name + i;
let offset = 5;
while (stack.length > 0) {
let snode = stack.shift();
let mask = 1;
for (let i = 0; i < 8; i++) {
if ((snode.children & mask) !== 0) {
let childName = snode.name + i;
var childChildren = view.getUint8(offset);
var childNumPoints = view.getUint32(offset + 1, true);
let childChildren = view.getUint8(offset);
let childNumPoints = view.getUint32(offset + 1, true);
stack.push({children: childChildren, numPoints: childNumPoints, name: childName});
stack.push({children: childChildren, numPoints: childNumPoints, name: childName});
decoded.push({children: childChildren, numPoints: childNumPoints, name: childName});
decoded.push({children: childChildren, numPoints: childNumPoints, name: childName});
offset += 5;
offset += 5;
}
mask = mask * 2;
}
mask = mask * 2;
}
if (offset === hbuffer.byteLength) {
break;
}
}
// console.log(decoded);
var nodes = {};
nodes[node.name] = node;
var pco = node.pcoGeometry;
for (let i = 0; i < decoded.length; i++) {
var name = decoded[i].name;
var decodedNumPoints = 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 = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index);
var currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
currentNode.level = level;
currentNode.numPoints = decodedNumPoints;
currentNode.hasChildren = decoded[i].children > 0;
currentNode.spacing = pco.spacing / Math.pow(2, level);
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';
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: ' + hurl);
if (offset === hbuffer.byteLength) {
break;
}
}
// console.log(decoded);
let nodes = {};
nodes[node.name] = node;
let pco = node.pcoGeometry;
for (let i = 0; i < decoded.length; i++) {
let name = decoded[i].name;
let decodedNumPoints = decoded[i].numPoints;
let index = parseInt(name.charAt(name.length - 1));
let parentName = name.substring(0, name.length - 1);
let parentNode = nodes[parentName];
let level = name.length - 1;
let boundingBox = Potree.POCLoader.createChildAABB(parentNode.boundingBox, index);
let currentNode = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox);
currentNode.level = level;
currentNode.numPoints = decodedNumPoints;
currentNode.hasChildren = decoded[i].children > 0;
currentNode.spacing = pco.spacing / Math.pow(2, level);
parentNode.addChild(currentNode);
nodes[name] = currentNode;
}
node.loadPoints();
};
try {
xhr.send(null);
} catch (e) {
console.log('fehler beim laden der punktwolke: ' + e);
if ((node.level % node.pcoGeometry.hierarchyStepSize) === 0) {
// let hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc";
let hurl = node.pcoGeometry.octreeDir + '/' + node.getHierarchyPath() + '/' + node.name + '.hrc';
let xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', hurl, true);
xhr.responseType = 'arraybuffer';
xhr.overrideMimeType('text/plain; charset=x-user-defined');
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 0) {
let hbuffer = xhr.response;
callback(node, hbuffer);
} else {
console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
}
}
};
try {
xhr.send(null);
} catch (e) {
console.log('fehler beim laden der punktwolke: ' + e);
}
}
}
};
Potree.PointCloudOctreeGeometryNode.prototype.getNumPoints = function () {
return this.numPoints;
};
Potree.PointCloudOctreeGeometryNode.prototype.dispose = function () {
if (this.geometry && this.parent != null) {
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];
handler();
}
this.oneTimeDisposeHandlers = [];
getNumPoints(){
return this.numPoints;
}
};
// THREE.EventDispatcher.prototype.apply( Potree.PointCloudOctreeGeometryNode.prototype );
dispose(){
if (this.geometry && this.parent != null) {
this.geometry.dispose();
this.geometry = null;
this.loaded = false;
// this.dispatchEvent( { type: 'dispose' } );
for (let i = 0; i < this.oneTimeDisposeHandlers.length; i++) {
let handler = this.oneTimeDisposeHandlers[i];
handler();
}
this.oneTimeDisposeHandlers = [];
}
}
}
Potree.PointCloudOctreeGeometryNode.IDCount = 0;
Object.assign(Potree.PointCloudOctreeGeometryNode.prototype, THREE.EventDispatcher.prototype);

View File

@ -336,7 +336,7 @@ Potree.DEM = class DEM {
//
// { // create scene objects for debugging
// //for(let demNode of targetNodes){
// var bb = new Potree.Box3Helper(box);
// let bb = new Potree.Box3Helper(box);
// viewer.scene.scene.add(bb);
//
// createDEMMesh(this, target);

View File

@ -3,7 +3,7 @@
// Copied from three.js: WebGLRenderer.js
Potree.paramThreeToGL = function paramThreeToGL(_gl, p) {
var extension;
let extension;
if (p === THREE.RepeatWrapping) return _gl.REPEAT;
if (p === THREE.ClampToEdgeWrapping) return _gl.CLAMP_TO_EDGE;

View File

@ -2,124 +2,121 @@
* adapted from http://stemkoski.github.io/Three.js/Sprite-Text-Labels.html
*/
Potree.TextSprite = function (text) {
THREE.Object3D.call(this);
Potree.TextSprite = class TextSprite extends THREE.Object3D{
constructor(text){
super();
var texture = new THREE.Texture();
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
var spriteMaterial = new THREE.SpriteMaterial({
map: texture,
// useScreenCoordinates: false,
depthTest: false,
depthWrite: false});
let texture = new THREE.Texture();
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
let spriteMaterial = new THREE.SpriteMaterial({
map: texture,
depthTest: false,
depthWrite: false});
this.material = spriteMaterial;
this.sprite = new THREE.Sprite(spriteMaterial);
this.add(this.sprite);
this.material = spriteMaterial;
this.sprite = new THREE.Sprite(spriteMaterial);
this.add(this.sprite);
// THREE.Sprite.call(this, spriteMaterial);
this.borderThickness = 4;
this.fontface = 'Arial';
this.fontsize = 28;
this.borderColor = { r: 0, g: 0, b: 0, a: 1.0 };
this.backgroundColor = { r: 255, g: 255, b: 255, a: 1.0 };
this.textColor = {r: 255, g: 255, b: 255, a: 1.0};
this.text = '';
this.borderThickness = 4;
this.fontface = 'Arial';
this.fontsize = 28;
this.borderColor = { r: 0, g: 0, b: 0, a: 1.0 };
this.backgroundColor = { r: 255, g: 255, b: 255, a: 1.0 };
this.textColor = {r: 255, g: 255, b: 255, a: 1.0};
this.text = '';
this.setText(text);
}
this.setText(text);
};
setText(text){
if (this.text !== text){
this.text = text;
Potree.TextSprite.prototype = new THREE.Object3D();
this.update();
}
};
Potree.TextSprite.prototype.setText = function (text) {
if (this.text !== text) {
this.text = text;
setTextColor(color){
this.textColor = color;
this.update();
}
};
setBorderColor(color){
this.borderColor = color;
this.update();
};
setBackgroundColor(color){
this.backgroundColor = color;
this.update();
};
update(){
let canvas = document.createElement('canvas');
let context = canvas.getContext('2d');
context.font = 'Bold ' + this.fontsize + 'px ' + this.fontface;
// get size data (height depends only on font size)
let metrics = context.measureText(this.text);
let textWidth = metrics.width;
let margin = 5;
let spriteWidth = 2 * margin + textWidth + 2 * this.borderThickness;
let spriteHeight = this.fontsize * 1.4 + 2 * this.borderThickness;
context.canvas.width = spriteWidth;
context.canvas.height = spriteHeight;
context.font = 'Bold ' + this.fontsize + 'px ' + this.fontface;
// background color
context.fillStyle = 'rgba(' + this.backgroundColor.r + ',' + this.backgroundColor.g + ',' +
this.backgroundColor.b + ',' + this.backgroundColor.a + ')';
// border color
context.strokeStyle = 'rgba(' + this.borderColor.r + ',' + this.borderColor.g + ',' +
this.borderColor.b + ',' + this.borderColor.a + ')';
context.lineWidth = this.borderThickness;
this.roundRect(context, this.borderThickness / 2, this.borderThickness / 2,
textWidth + this.borderThickness + 2 * margin, this.fontsize * 1.4 + this.borderThickness, 6);
// text color
context.strokeStyle = 'rgba(0, 0, 0, 1.0)';
context.strokeText(this.text, this.borderThickness + margin, this.fontsize + this.borderThickness);
context.fillStyle = 'rgba(' + this.textColor.r + ',' + this.textColor.g + ',' +
this.textColor.b + ',' + this.textColor.a + ')';
context.fillText(this.text, this.borderThickness + margin, this.fontsize + this.borderThickness);
let texture = new THREE.Texture(canvas);
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.needsUpdate = true;
this.sprite.material.map = texture;
this.sprite.scale.set(spriteWidth * 0.01, spriteHeight * 0.01, 1.0);
};
roundRect(ctx, x, y, w, h, r){
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
ctx.fill();
ctx.stroke();
};
};
Potree.TextSprite.prototype.setTextColor = function (color) {
this.textColor = color;
this.update();
};
Potree.TextSprite.prototype.setBorderColor = function (color) {
this.borderColor = color;
this.update();
};
Potree.TextSprite.prototype.setBackgroundColor = function (color) {
this.backgroundColor = color;
this.update();
};
Potree.TextSprite.prototype.update = function () {
var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
context.font = 'Bold ' + this.fontsize + 'px ' + this.fontface;
// get size data (height depends only on font size)
var metrics = context.measureText(this.text);
var textWidth = metrics.width;
var margin = 5;
var spriteWidth = 2 * margin + textWidth + 2 * this.borderThickness;
var spriteHeight = this.fontsize * 1.4 + 2 * this.borderThickness;
context.canvas.width = spriteWidth;
context.canvas.height = spriteHeight;
context.font = 'Bold ' + this.fontsize + 'px ' + this.fontface;
// background color
context.fillStyle = 'rgba(' + this.backgroundColor.r + ',' + this.backgroundColor.g + ',' +
this.backgroundColor.b + ',' + this.backgroundColor.a + ')';
// border color
context.strokeStyle = 'rgba(' + this.borderColor.r + ',' + this.borderColor.g + ',' +
this.borderColor.b + ',' + this.borderColor.a + ')';
context.lineWidth = this.borderThickness;
this.roundRect(context, this.borderThickness / 2, this.borderThickness / 2,
textWidth + this.borderThickness + 2 * margin, this.fontsize * 1.4 + this.borderThickness, 6);
// text color
context.strokeStyle = 'rgba(0, 0, 0, 1.0)';
context.strokeText(this.text, this.borderThickness + margin, this.fontsize + this.borderThickness);
context.fillStyle = 'rgba(' + this.textColor.r + ',' + this.textColor.g + ',' +
this.textColor.b + ',' + this.textColor.a + ')';
context.fillText(this.text, this.borderThickness + margin, this.fontsize + this.borderThickness);
var texture = new THREE.Texture(canvas);
texture.minFilter = THREE.LinearFilter;
texture.magFilter = THREE.LinearFilter;
texture.needsUpdate = true;
// var spriteMaterial = new THREE.SpriteMaterial(
// { map: texture, useScreenCoordinates: false } );
this.sprite.material.map = texture;
this.sprite.scale.set(spriteWidth * 0.01, spriteHeight * 0.01, 1.0);
// this.material = spriteMaterial;
};
Potree.TextSprite.prototype.roundRect = function (ctx, x, y, w, h, r) {
ctx.beginPath();
ctx.moveTo(x + r, y);
ctx.lineTo(x + w - r, y);
ctx.quadraticCurveTo(x + w, y, x + w, y + r);
ctx.lineTo(x + w, y + h - r);
ctx.quadraticCurveTo(x + w, y + h, x + w - r, y + h);
ctx.lineTo(x + r, y + h);
ctx.quadraticCurveTo(x, y + h, x, y + h - r);
ctx.lineTo(x, y + r);
ctx.quadraticCurveTo(x, y, x + r, y);
ctx.closePath();
ctx.fill();
ctx.stroke();
};

View File

@ -1,7 +1,7 @@
Potree.Version = function (version) {
this.version = version;
var vmLength = (version.indexOf('.') === -1) ? version.length : version.indexOf('.');
let vmLength = (version.indexOf('.') === -1) ? version.length : version.indexOf('.');
this.versionMajor = parseInt(version.substr(0, vmLength));
this.versionMinor = parseInt(version.substr(vmLength + 1));
if (this.versionMinor.length === 0) {
@ -10,7 +10,7 @@ Potree.Version = function (version) {
};
Potree.Version.prototype.newerThan = function (version) {
var v = new Potree.Version(version);
let v = new Potree.Version(version);
if (this.versionMajor > v.versionMajor) {
return true;
@ -22,7 +22,7 @@ Potree.Version.prototype.newerThan = function (version) {
};
Potree.Version.prototype.equalOrHigher = function (version) {
var v = new Potree.Version(version);
let v = new Potree.Version(version);
if (this.versionMajor > v.versionMajor) {
return true;

View File

@ -38,7 +38,7 @@ Potree.PointCloudArena4DNode = class PointCloudArena4DNode extends Potree.PointC
}
toTreeNode (child) {
var geometryNode = null;
let geometryNode = null;
if (this.left === child) {
geometryNode = this.left;
@ -50,8 +50,8 @@ Potree.PointCloudArena4DNode = class PointCloudArena4DNode extends Potree.PointC
return;
}
var node = new Potree.PointCloudArena4DNode();
var sceneNode = THREE.PointCloud(geometryNode.geometry, this.kdtree.material);
let node = new Potree.PointCloudArena4DNode();
let sceneNode = THREE.PointCloud(geometryNode.geometry, this.kdtree.material);
sceneNode.visible = false;
node.kdtree = this.kdtree;
@ -63,7 +63,7 @@ Potree.PointCloudArena4DNode = class PointCloudArena4DNode extends Potree.PointC
}
getChildren () {
var children = [];
let children = [];
if (this.left) {
children.push(this.left);
@ -77,9 +77,7 @@ Potree.PointCloudArena4DNode = class PointCloudArena4DNode extends Potree.PointC
}
};
Potree.PointCloudOctreeNode.prototype = Object.create(Potree.PointCloudTreeNode.prototype);
Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree {
Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree{
constructor (geometry) {
super();
@ -140,8 +138,8 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree
}
toTreeNode (geometryNode, parent) {
var node = new Potree.PointCloudArena4DNode();
var sceneNode = new THREE.Points(geometryNode.geometry, this.material);
let node = new Potree.PointCloudArena4DNode();
let sceneNode = new THREE.Points(geometryNode.geometry, this.material);
sceneNode.frustumCulled = false;
sceneNode.onBeforeRender = (_this, scene, camera, geometry, material, group) => {
@ -187,7 +185,7 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree
}
}
var disposeListener = function () {
let disposeListener = function () {
parent.sceneNode.remove(node.sceneNode);
if (parent.left === node) {
@ -215,7 +213,7 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree
}
// material.uniforms.octreeSize.value = this.boundingBox.size().x;
var bbSize = this.boundingBox.getSize();
let bbSize = this.boundingBox.getSize();
material.bbSize = [bbSize.x, bbSize.y, bbSize.z];
}
@ -224,7 +222,7 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree
}
hideDescendants (object) {
var stack = [];
let stack = [];
for (let i = 0; i < object.children.length; i++) {
let child = object.children[i];
if (child.visible) {
@ -268,13 +266,13 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree
}
nodesOnRay (nodes, ray) {
var nodesOnRay = [];
let nodesOnRay = [];
var _ray = ray.clone();
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
var sphere = node.getBoundingSphere().clone().applyMatrix4(node.sceneNode.matrixWorld);
// TODO Unused: var box = node.getBoundingBox().clone().applyMatrix4(node.sceneNode.matrixWorld);
let _ray = ray.clone();
for (let i = 0; i < nodes.length; i++) {
let node = nodes[i];
let sphere = node.getBoundingSphere().clone().applyMatrix4(node.sceneNode.matrixWorld);
// TODO Unused: let box = node.getBoundingBox().clone().applyMatrix4(node.sceneNode.matrixWorld);
if (_ray.intersectsSphere(sphere)) {
nodesOnRay.push(node);
@ -515,10 +513,10 @@ Potree.PointCloudArena4D = class PointCloudArena4D extends Potree.PointCloudTree
// sort by level and number
let sort = function (a, b) {
var la = a.geometryNode.level;
var lb = b.geometryNode.level;
var na = a.geometryNode.number;
var nb = b.geometryNode.number;
let la = a.geometryNode.level;
let lb = b.geometryNode.level;
let na = a.geometryNode.number;
let nb = b.geometryNode.number;
if (la !== lb) return la - lb;
if (na < nb) return -1;
if (na > nb) return 1;

View File

@ -68,8 +68,8 @@ Potree.GeoJSONExporter = class GeoJSONExporter {
}
if (measurement.showArea) {
var point = measurement.areaLabel.position;
var labelArea = {
let point = measurement.areaLabel.position;
let labelArea = {
type: 'Feature',
geometry: {
type: 'Point',

View File

@ -10,7 +10,7 @@ THREE.PerspectiveCamera.prototype.zoomTo = function (node, factor) {
node.updateMatrixWorld();
var bs;
let bs;
if (node.boundingSphere) {
bs = node.boundingSphere;
@ -20,18 +20,18 @@ THREE.PerspectiveCamera.prototype.zoomTo = function (node, factor) {
bs = node.boundingBox.getBoundingSphere();
}
var _factor = factor || 1;
let _factor = factor || 1;
bs = bs.clone().applyMatrix4(node.matrixWorld);
var radius = bs.radius;
var fovr = this.fov * Math.PI / 180;
let radius = bs.radius;
let fovr = this.fov * Math.PI / 180;
if (this.aspect < 1) {
fovr = fovr * this.aspect;
}
var distanceFactor = Math.abs(radius / Math.sin(fovr / 2)) * _factor;
let distanceFactor = Math.abs(radius / Math.sin(fovr / 2)) * _factor;
var offset = this.getWorldDirection().multiplyScalar(-distanceFactor);
let offset = this.getWorldDirection().multiplyScalar(-distanceFactor);
this.position.copy(bs.center.clone().add(offset));
};

View File

@ -1,5 +1,5 @@
THREE.Ray.prototype.distanceToPlaneWithNegative = function (plane) {
var denominator = plane.normal.dot(this.direction);
let denominator = plane.normal.dot(this.direction);
if (denominator === 0) {
// line is coplanar, return origin
if (plane.distanceToPoint(this.origin) === 0) {
@ -9,7 +9,7 @@ THREE.Ray.prototype.distanceToPlaneWithNegative = function (plane) {
// Null is preferable to undefined since undefined means.... it is undefined
return null;
}
var t = -(this.origin.dot(plane.normal) + plane.constant) / denominator;
let t = -(this.origin.dot(plane.normal) + plane.constant) / denominator;
return t;
};

View File

@ -1,126 +1,131 @@
Potree.BinaryLoader = function (version, boundingBox, scale) {
if (typeof (version) === 'string') {
this.version = new Potree.Version(version);
} else {
this.version = version;
}
Potree.BinaryLoader = class BinaryLoader{
this.boundingBox = boundingBox;
this.scale = scale;
};
Potree.BinaryLoader.prototype.load = function(node){
if (node.loaded) {
return;
}
let scope = this;
let url = node.getURL();
if (this.version.equalOrHigher('1.4')) {
url += '.bin';
}
let xhr = Potree.XHRFactory.createXMLHttpRequest();
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) {
let buffer = xhr.response;
scope.parse(node, buffer);
} 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.BinaryLoader.prototype.parse = function(node, buffer){
let pointAttributes = node.pcoGeometry.pointAttributes;
let numPoints = buffer.byteLength / node.pcoGeometry.pointAttributes.byteSize;
if (this.version.upTo('1.5')) {
node.numPoints = numPoints;
}
let workerPath = Potree.scriptPath + '/workers/BinaryDecoderWorker.js';
let worker = Potree.workerPool.getWorker(workerPath);
worker.onmessage = function (e) {
let data = e.data;
let buffers = data.attributeBuffers;
let tightBoundingBox = new THREE.Box3(
new THREE.Vector3().fromArray(data.tightBoundingBox.min),
new THREE.Vector3().fromArray(data.tightBoundingBox.max)
);
Potree.workerPool.returnWorker(workerPath, worker);
let geometry = new THREE.BufferGeometry();
for(let property in buffers){
let buffer = buffers[property].buffer;
if (parseInt(property) === Potree.PointAttributeNames.POSITION_CARTESIAN) {
geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.COLOR_PACKED) {
geometry.addAttribute('color', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
} else if (parseInt(property) === Potree.PointAttributeNames.INTENSITY) {
geometry.addAttribute('intensity', new THREE.BufferAttribute(new Float32Array(buffer), 1));
} else if (parseInt(property) === Potree.PointAttributeNames.CLASSIFICATION) {
geometry.addAttribute('classification', new THREE.BufferAttribute(new Uint8Array(buffer), 1));
} else if (parseInt(property) === Potree.PointAttributeNames.NORMAL_SPHEREMAPPED) {
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.NORMAL_OCT16) {
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.NORMAL) {
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.INDICES) {
let bufferAttribute = new THREE.BufferAttribute(new Uint8Array(buffer), 4);
bufferAttribute.normalized = true;
geometry.addAttribute('indices', bufferAttribute);
} else if (parseInt(property) === Potree.PointAttributeNames.SPACING) {
let bufferAttribute = new THREE.BufferAttribute(new Float32Array(buffer), 1);
geometry.addAttribute('spacing', bufferAttribute);
}
constructor(version, boundingBox, scale){
if (typeof (version) === 'string') {
this.version = new Potree.Version(version);
} else {
this.version = version;
}
this.boundingBox = boundingBox;
this.scale = scale;
}
tightBoundingBox.max.sub(tightBoundingBox.min);
tightBoundingBox.min.set(0, 0, 0);
load(node){
if (node.loaded) {
return;
}
let numPoints = e.data.buffer.byteLength / pointAttributes.byteSize;
let url = node.getURL();
if (this.version.equalOrHigher('1.4')) {
url += '.bin';
}
let xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.overrideMimeType('text/plain; charset=x-user-defined');
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
if (xhr.status === 200 || xhr.status === 0) {
let buffer = xhr.response;
this.parse(node, buffer);
} else {
console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + url);
}
}
};
node.numPoints = numPoints;
node.geometry = geometry;
node.mean = new THREE.Vector3(...data.mean);
node.tightBoundingBox = tightBoundingBox;
node.loaded = true;
node.loading = false;
node.estimatedSpacing = data.estimatedSpacing;
Potree.numNodesLoading--;
try {
xhr.send(null);
} catch (e) {
console.log('fehler beim laden der punktwolke: ' + e);
}
};
let message = {
buffer: buffer,
pointAttributes: pointAttributes,
version: this.version.version,
min: [ node.boundingBox.min.x, node.boundingBox.min.y, node.boundingBox.min.z ],
offset: [node.pcoGeometry.offset.x, node.pcoGeometry.offset.y, node.pcoGeometry.offset.z],
scale: this.scale,
spacing: node.spacing,
hasChildren: node.hasChildren,
name: node.name
parse(node, buffer){
let pointAttributes = node.pcoGeometry.pointAttributes;
let numPoints = buffer.byteLength / node.pcoGeometry.pointAttributes.byteSize;
if (this.version.upTo('1.5')) {
node.numPoints = numPoints;
}
let workerPath = Potree.scriptPath + '/workers/BinaryDecoderWorker.js';
let worker = Potree.workerPool.getWorker(workerPath);
worker.onmessage = function (e) {
let data = e.data;
let buffers = data.attributeBuffers;
let tightBoundingBox = new THREE.Box3(
new THREE.Vector3().fromArray(data.tightBoundingBox.min),
new THREE.Vector3().fromArray(data.tightBoundingBox.max)
);
Potree.workerPool.returnWorker(workerPath, worker);
let geometry = new THREE.BufferGeometry();
for(let property in buffers){
let buffer = buffers[property].buffer;
if (parseInt(property) === Potree.PointAttributeNames.POSITION_CARTESIAN) {
geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.COLOR_PACKED) {
geometry.addAttribute('color', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true));
} else if (parseInt(property) === Potree.PointAttributeNames.INTENSITY) {
geometry.addAttribute('intensity', new THREE.BufferAttribute(new Float32Array(buffer), 1));
} else if (parseInt(property) === Potree.PointAttributeNames.CLASSIFICATION) {
geometry.addAttribute('classification', new THREE.BufferAttribute(new Uint8Array(buffer), 1));
} else if (parseInt(property) === Potree.PointAttributeNames.NORMAL_SPHEREMAPPED) {
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.NORMAL_OCT16) {
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.NORMAL) {
geometry.addAttribute('normal', new THREE.BufferAttribute(new Float32Array(buffer), 3));
} else if (parseInt(property) === Potree.PointAttributeNames.INDICES) {
let bufferAttribute = new THREE.BufferAttribute(new Uint8Array(buffer), 4);
bufferAttribute.normalized = true;
geometry.addAttribute('indices', bufferAttribute);
} else if (parseInt(property) === Potree.PointAttributeNames.SPACING) {
let bufferAttribute = new THREE.BufferAttribute(new Float32Array(buffer), 1);
geometry.addAttribute('spacing', bufferAttribute);
}
}
tightBoundingBox.max.sub(tightBoundingBox.min);
tightBoundingBox.min.set(0, 0, 0);
let numPoints = e.data.buffer.byteLength / pointAttributes.byteSize;
node.numPoints = numPoints;
node.geometry = geometry;
node.mean = new THREE.Vector3(...data.mean);
node.tightBoundingBox = tightBoundingBox;
node.loaded = true;
node.loading = false;
node.estimatedSpacing = data.estimatedSpacing;
Potree.numNodesLoading--;
};
let message = {
buffer: buffer,
pointAttributes: pointAttributes,
version: this.version.version,
min: [ node.boundingBox.min.x, node.boundingBox.min.y, node.boundingBox.min.z ],
offset: [node.pcoGeometry.offset.x, node.pcoGeometry.offset.y, node.pcoGeometry.offset.z],
scale: this.scale,
spacing: node.spacing,
hasChildren: node.hasChildren,
name: node.name
};
worker.postMessage(message, [message.buffer]);
};
worker.postMessage(message, [message.buffer]);
};

View File

@ -9,15 +9,15 @@
class GreyhoundUtils {
static getQueryParam (name) {
name = name.replace(/[[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
var results = regex.exec(window.location.href);
let regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)');
let results = regex.exec(window.location.href);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
static createSchema (attributes) {
var schema = [
let schema = [
{ 'name': 'X', 'size': 4, 'type': 'signed' },
{ 'name': 'Y', 'size': 4, 'type': 'signed' },
{ 'name': 'Z', 'size': 4, 'type': 'signed' }
@ -46,7 +46,7 @@ class GreyhoundUtils {
}
static fetch (url, cb) {
var xhr = Potree.XHRFactory.createXMLHttpRequest();
let xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', url, true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
@ -61,7 +61,7 @@ class GreyhoundUtils {
};
static fetchBinary (url, cb) {
var xhr = Potree.XHRFactory.createXMLHttpRequest();
let xhr = Potree.XHRFactory.createXMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.onreadystatechange = function () {
@ -81,7 +81,7 @@ class GreyhoundUtils {
};
static getNormalization (serverURL, baseDepth, cb) {
var s = [
let s = [
{ 'name': 'X', 'size': 4, 'type': 'floating' },
{ 'name': 'Y', 'size': 4, 'type': 'floating' },
{ 'name': 'Z', 'size': 4, 'type': 'floating' },
@ -91,21 +91,21 @@ class GreyhoundUtils {
{ 'name': 'Intensity', 'size': 2, 'type': 'unsigned' }
];
var url = serverURL + 'read?depth=' + baseDepth +
let url = serverURL + 'read?depth=' + baseDepth +
'&schema=' + JSON.stringify(s);
GreyhoundUtils.fetchBinary(url, function (err, buffer) {
if (err) throw new Error(err);
var view = new DataView(buffer);
var numBytes = buffer.byteLength - 4;
// TODO Unused: var numPoints = view.getUint32(numBytes, true);
var pointSize = GreyhoundUtils.pointSizeFrom(s);
let view = new DataView(buffer);
let numBytes = buffer.byteLength - 4;
// TODO Unused: let numPoints = view.getUint32(numBytes, true);
let pointSize = GreyhoundUtils.pointSizeFrom(s);
var colorNorm = false;
var intensityNorm = false;
let colorNorm = false;
let intensityNorm = false;
for (var offset = 0; offset < numBytes; offset += pointSize) {
for (let offset = 0; offset < numBytes; offset += pointSize) {
if (view.getUint16(offset + 12, true) > 255 ||
view.getUint16(offset + 14, true) > 255 ||
view.getUint16(offset + 16, true) > 255) {
@ -139,11 +139,11 @@ Potree.GreyhoundLoader.loadInfoJSON = function load (url, callback) { };
* finished
*/
Potree.GreyhoundLoader.load = function load (url, callback) {
var HIERARCHY_STEP_SIZE = 5;
let HIERARCHY_STEP_SIZE = 5;
try {
// We assume everything ater the string 'greyhound://' is the server url
var serverURL = url.split('greyhound://')[1];
let serverURL = url.split('greyhound://')[1];
if (serverURL.split('http://').length === 1) {
serverURL = 'http://' + serverURL;
}
@ -170,17 +170,17 @@ Potree.GreyhoundLoader.load = function load (url, callback) {
"type": "octree"
}
*/
var greyhoundInfo = JSON.parse(data);
var version = new Potree.Version('1.4');
let greyhoundInfo = JSON.parse(data);
let version = new Potree.Version('1.4');
var bounds = greyhoundInfo.bounds;
// TODO Unused: var boundsConforming = greyhoundInfo.boundsConforming;
let bounds = greyhoundInfo.bounds;
// TODO Unused: let boundsConforming = greyhoundInfo.boundsConforming;
// TODO Unused: var width = bounds[3] - bounds[0];
// TODO Unused: var depth = bounds[4] - bounds[1];
// TODO Unused: var height = bounds[5] - bounds[2];
// TODO Unused: var radius = width / 2;
var scale = greyhoundInfo.scale || 0.01;
// TODO Unused: let width = bounds[3] - bounds[0];
// TODO Unused: let depth = bounds[4] - bounds[1];
// TODO Unused: let height = bounds[5] - bounds[2];
// TODO Unused: let radius = width / 2;
let scale = greyhoundInfo.scale || 0.01;
if (Array.isArray(scale)) {
scale = Math.min(scale[0], scale[1], scale[2]);
}
@ -189,7 +189,7 @@ Potree.GreyhoundLoader.load = function load (url, callback) {
scale = parseFloat(GreyhoundUtils.getQueryParam('scale'));
}
var baseDepth = Math.max(8, greyhoundInfo.baseDepth);
let baseDepth = Math.max(8, greyhoundInfo.baseDepth);
// Ideally we want to change this bit completely, since
// greyhound's options are wider than the default options for
@ -201,13 +201,13 @@ Potree.GreyhoundLoader.load = function load (url, callback) {
// PointCloudGreyhoundGeometryNode without asking for
// attributes that we are not currently visualizing. We assume
// XYZ are always available.
var attributes = ['POSITION_CARTESIAN'];
let attributes = ['POSITION_CARTESIAN'];
// To be careful, we only add COLOR_PACKED as an option if all
// colors are actually found.
var red = false;
var green = false;
var blue = false;
let red = false;
let green = false;
let blue = false;
greyhoundInfo.schema.forEach(function (entry) {
// Intensity and Classification are optional.
@ -226,24 +226,24 @@ Potree.GreyhoundLoader.load = function load (url, callback) {
if (red && green && blue) attributes.push('COLOR_PACKED');
// Fill in geometry fields.
var pgg = new Potree.PointCloudGreyhoundGeometry();
let pgg = new Potree.PointCloudGreyhoundGeometry();
pgg.serverURL = serverURL;
pgg.spacing = (bounds[3] - bounds[0]) / Math.pow(2, baseDepth);
pgg.baseDepth = baseDepth;
pgg.hierarchyStepSize = HIERARCHY_STEP_SIZE;
pgg.schema = GreyhoundUtils.createSchema(attributes);
var pointSize = GreyhoundUtils.pointSizeFrom(pgg.schema);
let pointSize = GreyhoundUtils.pointSizeFrom(pgg.schema);
pgg.pointAttributes = new Potree.PointAttributes(attributes);
pgg.pointAttributes.byteSize = pointSize;
var boundingBox = new THREE.Box3(
let boundingBox = new THREE.Box3(
new THREE.Vector3().fromArray(bounds, 0),
new THREE.Vector3().fromArray(bounds, 3)
);
var offset = boundingBox.min.clone();
let offset = boundingBox.min.clone();
boundingBox.max.sub(boundingBox.min);
boundingBox.min.set(0, 0, 0);
@ -261,12 +261,12 @@ Potree.GreyhoundLoader.load = function load (url, callback) {
pgg.loader = new Potree.GreyhoundBinaryLoader(version, boundingBox, pgg.scale);
var nodes = {};
let nodes = {};
{ // load root
var name = 'r';
let name = 'r';
var root = new Potree.PointCloudGreyhoundGeometryNode(
let root = new Potree.PointCloudGreyhoundGeometryNode(
name, pgg, boundingBox,
scale, offset
);
@ -300,11 +300,11 @@ Potree.GreyhoundLoader.load = function load (url, callback) {
};
Potree.GreyhoundLoader.loadPointAttributes = function (mno) {
var fpa = mno.pointAttributes;
var pa = new Potree.PointAttributes();
let fpa = mno.pointAttributes;
let pa = new Potree.PointAttributes();
for (var i = 0; i < fpa.length; i++) {
var pointAttribute = Potree.PointAttribute[fpa[i]];
for (let i = 0; i < fpa.length; i++) {
let pointAttribute = Potree.PointAttribute[fpa[i]];
pa.add(pointAttribute);
}
@ -312,15 +312,15 @@ Potree.GreyhoundLoader.loadPointAttributes = function (mno) {
};
Potree.GreyhoundLoader.createChildAABB = function (aabb, childIndex) {
var min = aabb.min;
var max = aabb.max;
var dHalfLength = new THREE.Vector3().copy(max).sub(min).multiplyScalar(0.5);
var xHalfLength = new THREE.Vector3(dHalfLength.x, 0, 0);
var yHalfLength = new THREE.Vector3(0, dHalfLength.y, 0);
var zHalfLength = new THREE.Vector3(0, 0, dHalfLength.z);
let min = aabb.min;
let max = aabb.max;
let dHalfLength = new THREE.Vector3().copy(max).sub(min).multiplyScalar(0.5);
let xHalfLength = new THREE.Vector3(dHalfLength.x, 0, 0);
let yHalfLength = new THREE.Vector3(0, dHalfLength.y, 0);
let zHalfLength = new THREE.Vector3(0, 0, dHalfLength.z);
var cmin = min;
var cmax = new THREE.Vector3().add(min).add(dHalfLength);
let cmin = min;
let cmax = new THREE.Vector3().add(min).add(dHalfLength);
if (childIndex === 1) {
min = new THREE.Vector3().copy(cmin).add(zHalfLength);

View File

@ -36,8 +36,8 @@ Potree.PointAttributeTypes = {
DATA_TYPE_UINT64: {ordinal: 9, size: 8}
};
var i = 0;
for (var obj in Potree.PointAttributeTypes) {
let i = 0;
for (let obj in Potree.PointAttributeTypes) {
Potree.PointAttributeTypes[i] = Potree.PointAttributeTypes[obj];
i++;
}
@ -132,9 +132,9 @@ Potree.PointAttributes = function (pointAttributes) {
this.size = 0;
if (pointAttributes != null) {
for (var i = 0; i < pointAttributes.length; i++) {
var pointAttributeName = pointAttributes[i];
var pointAttribute = Potree.PointAttribute[pointAttributeName];
for (let i = 0; i < pointAttributes.length; i++) {
let pointAttributeName = pointAttributes[i];
let pointAttribute = Potree.PointAttribute[pointAttributeName];
this.attributes.push(pointAttribute);
this.byteSize += pointAttribute.byteSize;
this.size++;
@ -149,8 +149,8 @@ Potree.PointAttributes.prototype.add = function (pointAttribute) {
};
Potree.PointAttributes.prototype.hasColors = function () {
for (var name in this.attributes) {
var pointAttribute = this.attributes[name];
for (let name in this.attributes) {
let pointAttribute = this.attributes[name];
if (pointAttribute.name === Potree.PointAttributeNames.COLOR_PACKED) {
return true;
}
@ -160,8 +160,8 @@ Potree.PointAttributes.prototype.hasColors = function () {
};
Potree.PointAttributes.prototype.hasNormals = function () {
for (var name in this.attributes) {
var pointAttribute = this.attributes[name];
for (let name in this.attributes) {
let pointAttribute = this.attributes[name];
if (
pointAttribute === Potree.PointAttribute.NORMAL_SPHEREMAPPED ||
pointAttribute === Potree.PointAttribute.NORMAL_FLOATS ||

View File

@ -1,24 +1,24 @@
// see http://john-chapman-graphics.blogspot.co.at/2013/01/ssao-tutorial.html
Potree.BlurMaterial = function (parameters) {
THREE.Material.call(this);
Potree.BlurMaterial = class BlurMaterial extends THREE.ShaderMaterial{
parameters = parameters || {};
constructor(parameters = {}){
super();
var uniforms = {
near: { type: 'f', value: 0 },
far: { type: 'f', value: 0 },
screenWidth: { type: 'f', value: 0 },
screenHeight: { type: 'f', value: 0 },
map: { type: 't', value: null }
};
let uniforms = {
near: { type: 'f', value: 0 },
far: { type: 'f', value: 0 },
screenWidth: { type: 'f', value: 0 },
screenHeight: { type: 'f', value: 0 },
map: { type: 't', value: null }
};
this.setValues({
uniforms: uniforms,
vertexShader: Potree.Shaders['blur.vs'],
fragmentShader: Potree.Shaders['blur.fs']
});
this.setValues({
uniforms: uniforms,
vertexShader: Potree.Shaders['blur.vs'],
fragmentShader: Potree.Shaders['blur.fs']
});
}
};
Potree.BlurMaterial.prototype = new THREE.ShaderMaterial();

View File

@ -65,7 +65,7 @@ Potree.EyeDomeLightingMaterial = class EyeDomeLightingMaterial extends THREE.Sha
if (this._neighbourCount !== value) {
this._neighbourCount = value;
this.neighbours = new Float32Array(this._neighbourCount * 2);
for (var c = 0; c < this._neighbourCount; c++) {
for (let c = 0; c < this._neighbourCount; c++) {
this.neighbours[2 * c + 0] = Math.cos(2 * c * Math.PI / this._neighbourCount);
this.neighbours[2 * c + 1] = Math.sin(2 * c * Math.PI / this._neighbourCount);
}

View File

@ -55,7 +55,7 @@ Potree.NormalizationEDLMaterial = class NormalizationEDLMaterial extends THREE.S
if (this._neighbourCount !== value) {
this._neighbourCount = value;
this.neighbours = new Float32Array(this._neighbourCount * 2);
for (var c = 0; c < this._neighbourCount; c++) {
for (let c = 0; c < this._neighbourCount; c++) {
this.neighbours[2 * c + 0] = Math.cos(2 * c * Math.PI / this._neighbourCount);
this.neighbours[2 * c + 1] = Math.sin(2 * c * Math.PI / this._neighbourCount);
}

View File

@ -11,7 +11,7 @@
// to get a ready to use gradient array from a chroma.js gradient:
// http://gka.github.io/chroma.js/
//
// var stops = [];
// let stops = [];
// for(let i = 0; i <= 10; i++){
// let range = chroma.scale(['yellow', 'navy']).mode('lch').domain([10,0])(i)._rgb
// .slice(0, 3)

View File

@ -191,8 +191,8 @@ Potree.EarthControls = class EarthControls extends THREE.EventDispatcher {
let cameraTargetPosition = new THREE.Vector3().addVectors(I.location, d.multiplyScalar(targetRadius));
// TODO Unused: let controlsTargetPosition = I.location;
var animationDuration = 600;
var easing = TWEEN.Easing.Quartic.Out;
let animationDuration = 600;
let easing = TWEEN.Easing.Quartic.Out;
{ // animate
let value = {x: 0};

View File

@ -140,8 +140,8 @@ Potree.FirstPersonControls = class FirstPersonControls extends THREE.EventDispat
let cameraTargetPosition = new THREE.Vector3().addVectors(I.location, d.multiplyScalar(targetRadius));
// TODO Unused: let controlsTargetPosition = I.location;
var animationDuration = 600;
var easing = TWEEN.Easing.Quartic.Out;
let animationDuration = 600;
let easing = TWEEN.Easing.Quartic.Out;
{ // animate
let value = {x: 0};

View File

@ -21,93 +21,113 @@
*
*/
Potree.GeoControls = function (object, domElement) {
this.object = object;
this.domElement = (domElement !== undefined) ? domElement : document;
Potree.GeoControls = class GeoControls extends THREE.EventDispatcher{
// Set to false to disable this control
this.enabled = true;
constructor(object, domElement){
super();
// Set this to a THREE.SplineCurve3 instance
this.track = null;
// position on track in intervall [0,1]
this.trackPos = 0;
console.log("deprecated?");
this.rotateSpeed = 1.0;
this.moveSpeed = 10.0;
this.object = object;
this.domElement = (domElement !== undefined) ? domElement : document;
this.keys = {
LEFT: 37,
UP: 38,
RIGHT: 39,
BOTTOM: 40,
A: 'A'.charCodeAt(0),
S: 'S'.charCodeAt(0),
D: 'D'.charCodeAt(0),
W: 'W'.charCodeAt(0),
Q: 'Q'.charCodeAt(0),
E: 'E'.charCodeAt(0),
R: 'R'.charCodeAt(0),
F: 'F'.charCodeAt(0)
};
// Set to false to disable this control
this.enabled = true;
var scope = this;
// Set this to a THREE.SplineCurve3 instance
this.track = null;
// position on track in intervall [0,1]
this.trackPos = 0;
var rotateStart = new THREE.Vector2();
var rotateEnd = new THREE.Vector2();
var rotateDelta = new THREE.Vector2();
this.rotateSpeed = 1.0;
this.moveSpeed = 10.0;
var panStart = new THREE.Vector2();
var panEnd = new THREE.Vector2();
var panDelta = new THREE.Vector2();
var panOffset = new THREE.Vector3();
this.keys = {
LEFT: 37,
UP: 38,
RIGHT: 39,
BOTTOM: 40,
A: 'A'.charCodeAt(0),
S: 'S'.charCodeAt(0),
D: 'D'.charCodeAt(0),
W: 'W'.charCodeAt(0),
Q: 'Q'.charCodeAt(0),
E: 'E'.charCodeAt(0),
R: 'R'.charCodeAt(0),
F: 'F'.charCodeAt(0)
};
// TODO Unused: var offset = new THREE.Vector3();
let rotateStart = new THREE.Vector2();
let rotateEnd = new THREE.Vector2();
let rotateDelta = new THREE.Vector2();
var phiDelta = 0;
var thetaDelta = 0;
var pan = new THREE.Vector3();
let panStart = new THREE.Vector2();
let panEnd = new THREE.Vector2();
let panDelta = new THREE.Vector2();
let panOffset = new THREE.Vector3();
this.shiftDown = false;
// TODO Unused: let offset = new THREE.Vector3();
var lastPosition = new THREE.Vector3();
let phiDelta = 0;
let thetaDelta = 0;
let pan = new THREE.Vector3();
var STATE = { NONE: -1, ROTATE: 0, SPEEDCHANGE: 1, PAN: 2 };
this.shiftDown = false;
var state = STATE.NONE;
let lastPosition = new THREE.Vector3();
// for reset
this.position0 = this.object.position.clone();
let STATE = { NONE: -1, ROTATE: 0, SPEEDCHANGE: 1, PAN: 2 };
// events
let state = STATE.NONE;
var changeEvent = { type: 'change' };
var startEvent = { type: 'start' };
var endEvent = { type: 'end' };
// for reset
this.position0 = this.object.position.clone();
this.setTrack = function (track) {
// events
let changeEvent = { type: 'change' };
let startEvent = { type: 'start' };
let endEvent = { type: 'end' };
this.domElement.addEventListener('contextmenu', (event) => { event.preventDefault(); }, false);
this.domElement.addEventListener('mousedown', this.onMouseDown.bind(this), false);
this.domElement.addEventListener('mousewheel', this.onMouseWheel.bind(this), false);
this.domElement.addEventListener('DOMMouseScroll', this.onMouseWheel.bind(this), false); // firefox
this.domElement.addEventListener('mousemove', this.onMouseMove.bind(this), false);
this.domElement.addEventListener('mouseup', this.onMouseUp.bind(this), false);
if (this.domElement.tabIndex === -1) {
this.domElement.tabIndex = 2222;
}
this.domElement.addEventListener('keydown', this.onKeyDown.bind(this), false);
this.domElement.addEventListener('keyup', this.onKeyUp.bind(this), false);
}
setTrack(track) {
if (this.track !== track) {
this.track = track;
this.trackPos = null;
}
};
this.setTrackPos = function (trackPos, _preserveRelativeRotation) {
// TODO Unused: var preserveRelativeRotation = _preserveRelativeRotation || false;
setTrackPos(trackPos, _preserveRelativeRotation){
// TODO Unused: let preserveRelativeRotation = _preserveRelativeRotation || false;
var newTrackPos = Math.max(0, Math.min(1, trackPos));
var oldTrackPos = this.trackPos || newTrackPos;
let newTrackPos = Math.max(0, Math.min(1, trackPos));
let oldTrackPos = this.trackPos || newTrackPos;
var newTangent = this.track.getTangentAt(newTrackPos);
var oldTangent = this.track.getTangentAt(oldTrackPos);
let newTangent = this.track.getTangentAt(newTrackPos);
let oldTangent = this.track.getTangentAt(oldTrackPos);
if (newTangent.equals(oldTangent)) {
// no change in direction
} else {
var tangentDiffNormal = new THREE.Vector3().crossVectors(oldTangent, newTangent).normalize();
var angle = oldTangent.angleTo(newTangent);
var rot = new THREE.Matrix4().makeRotationAxis(tangentDiffNormal, angle);
var dir = this.object.getWorldDirection().clone();
let tangentDiffNormal = new THREE.Vector3().crossVectors(oldTangent, newTangent).normalize();
let angle = oldTangent.angleTo(newTangent);
let rot = new THREE.Matrix4().makeRotationAxis(tangentDiffNormal, angle);
let dir = this.object.getWorldDirection().clone();
dir = dir.applyMatrix4(rot);
let target = new THREE.Vector3().addVectors(this.object.position, dir);
this.object.lookAt(target);
@ -117,7 +137,7 @@ Potree.GeoControls = function (object, domElement) {
type: 'path_relative_rotation',
angle: angle,
axis: tangentDiffNormal,
controls: scope
controls: this
};
this.dispatchEvent(event);
}
@ -129,9 +149,9 @@ Potree.GeoControls = function (object, domElement) {
this.trackPos = newTrackPos;
// var pStart = this.track.getPointAt(oldTrackPos);
// var pEnd = this.track.getPointAt(newTrackPos);
// var pDiff = pEnd.sub(pStart);
// let pStart = this.track.getPointAt(oldTrackPos);
// let pEnd = this.track.getPointAt(newTrackPos);
// let pDiff = pEnd.sub(pStart);
if (newTrackPos !== oldTrackPos) {
let event = {
@ -140,52 +160,52 @@ Potree.GeoControls = function (object, domElement) {
};
this.dispatchEvent(event);
}
};
}
this.stop = function(){
stop(){
}
this.getTrackPos = function () {
getTrackPos(){
return this.trackPos;
};
}
this.rotateLeft = function (angle) {
rotateLeft(angle){
thetaDelta -= angle;
};
}
this.rotateUp = function (angle) {
rotateUp(angle){
phiDelta -= angle;
};
}
// pass in distance in world space to move left
this.panLeft = function (distance) {
var te = this.object.matrix.elements;
panLeft(distance){
let te = this.object.matrix.elements;
// get X column of matrix
panOffset.set(te[ 0 ], te[ 1 ], te[ 2 ]);
panOffset.multiplyScalar(-distance);
pan.add(panOffset);
};
}
// pass in distance in world space to move up
this.panUp = function (distance) {
var te = this.object.matrix.elements;
panUp(distance){
let te = this.object.matrix.elements;
// get Y column of matrix
panOffset.set(te[ 4 ], te[ 5 ], te[ 6 ]);
panOffset.multiplyScalar(distance);
pan.add(panOffset);
};
}
// pass in distance in world space to move forward
this.panForward = function (distance) {
panForward(distance){
if (this.track) {
this.setTrackPos(this.getTrackPos() - distance / this.track.getLength());
} else {
var te = this.object.matrix.elements;
let te = this.object.matrix.elements;
// get Y column of matrix
panOffset.set(te[ 8 ], te[ 9 ], te[ 10 ]);
@ -194,37 +214,37 @@ Potree.GeoControls = function (object, domElement) {
pan.add(panOffset);
}
};
}
this.pan = function (deltaX, deltaY) {
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
pan(deltaX, deltaY){
let element = this.domElement === document ? this.domElement.body : this.domElement;
if (scope.object.fov !== undefined) {
if (this.object.fov !== undefined) {
// perspective
var position = scope.object.position;
var offset = position.clone();
var targetDistance = offset.length();
let position = this.object.position;
let offset = position.clone();
let targetDistance = offset.length();
// half of the fov is center to top of screen
targetDistance *= Math.tan((scope.object.fov / 2) * Math.PI / 180.0);
targetDistance *= Math.tan((this.object.fov / 2) * Math.PI / 180.0);
// we actually don't use screenWidth, since perspective camera is fixed to screen height
scope.panLeft(2 * deltaX * targetDistance / element.clientHeight);
scope.panUp(2 * deltaY * targetDistance / element.clientHeight);
} else if (scope.object.top !== undefined) {
this.panLeft(2 * deltaX * targetDistance / element.clientHeight);
this.panUp(2 * deltaY * targetDistance / element.clientHeight);
} else if (this.object.top !== undefined) {
// orthographic
scope.panLeft(deltaX * (scope.object.right - scope.object.left) / element.clientWidth);
scope.panUp(deltaY * (scope.object.top - scope.object.bottom) / element.clientHeight);
this.panLeft(deltaX * (this.object.right - this.object.left) / element.clientWidth);
this.panUp(deltaY * (this.object.top - this.object.bottom) / element.clientHeight);
} else {
// camera neither orthographic or perspective
console.warn('WARNING: GeoControls.js encountered an unknown camera type - pan disabled.');
}
};
}
this.update = function (delta) {
update(delta){
this.object.rotation.order = 'ZYX';
var object = this.object;
let object = this.object;
this.object = new THREE.Object3D();
this.object.position.copy(object.position);
@ -232,10 +252,10 @@ Potree.GeoControls = function (object, domElement) {
this.object.updateMatrix();
this.object.updateMatrixWorld();
var position = this.object.position;
let position = this.object.position;
if (delta !== undefined) {
var multiplier = scope.shiftDown ? 4 : 1;
let multiplier = this.shiftDown ? 4 : 1;
if (this.moveRight) {
this.panLeft(-delta * this.moveSpeed * multiplier);
}
@ -249,18 +269,18 @@ Potree.GeoControls = function (object, domElement) {
this.panForward(delta * this.moveSpeed * multiplier);
}
if (this.rotLeft) {
scope.rotateLeft(-0.5 * Math.PI * delta / scope.rotateSpeed);
this.rotateLeft(-0.5 * Math.PI * delta / this.rotateSpeed);
}
if (this.rotRight) {
scope.rotateLeft(0.5 * Math.PI * delta / scope.rotateSpeed);
this.rotateLeft(0.5 * Math.PI * delta / this.rotateSpeed);
}
if (this.raiseCamera) {
// scope.rotateUp( -0.5 * Math.PI * delta / scope.rotateSpeed );
scope.panUp(delta * this.moveSpeed * multiplier);
// this.rotateUp( -0.5 * Math.PI * delta / this.rotateSpeed );
this.panUp(delta * this.moveSpeed * multiplier);
}
if (this.lowerCamera) {
// scope.rotateUp( 0.5 * Math.PI * delta / scope.rotateSpeed );
scope.panUp(-delta * this.moveSpeed * multiplier);
// this.rotateUp( 0.5 * Math.PI * delta / this.rotateSpeed );
this.panUp(-delta * this.moveSpeed * multiplier);
}
}
@ -284,15 +304,15 @@ Potree.GeoControls = function (object, domElement) {
}
this.object.updateMatrix();
var rot = new THREE.Matrix4().makeRotationY(thetaDelta);
var res = new THREE.Matrix4().multiplyMatrices(rot, this.object.matrix);
let rot = new THREE.Matrix4().makeRotationY(thetaDelta);
let res = new THREE.Matrix4().multiplyMatrices(rot, this.object.matrix);
this.object.quaternion.setFromRotationMatrix(res);
this.object.rotation.x += phiDelta;
this.object.updateMatrixWorld();
// send transformation proposal to listeners
var proposeTransformEvent = {
let proposeTransformEvent = {
type: 'proposeTransform',
oldPosition: object.position,
newPosition: this.object.position,
@ -304,7 +324,7 @@ Potree.GeoControls = function (object, domElement) {
// check some counter proposals if transformation wasn't accepted
if (proposeTransformEvent.objections > 0) {
if (proposeTransformEvent.counterProposals.length > 0) {
var cp = proposeTransformEvent.counterProposals;
let cp = proposeTransformEvent.counterProposals;
this.object.position.copy(cp[0]);
proposeTransformEvent.objections = 0;
@ -334,19 +354,19 @@ Potree.GeoControls = function (object, domElement) {
}
if (this.track) {
var pos = this.track.getPointAt(this.trackPos);
let pos = this.track.getPointAt(this.trackPos);
object.position.copy(pos);
}
};
}
this.reset = function () {
reset(){
state = STATE.NONE;
this.object.position.copy(this.position0);
};
}
function onMouseDown (event) {
if (scope.enabled === false) return;
onMouseDown(){
if (this.enabled === false) return;
event.preventDefault();
if (event.button === 0) {
@ -360,137 +380,122 @@ Potree.GeoControls = function (object, domElement) {
} else if (event.button === 2) {
// state = STATE.PAN;
// panStart.set( event.clientX, event.clientY );
scope.moveForwardMouse = true;
this.moveForwardMouse = true;
}
// scope.domElement.addEventListener( 'mousemove', onMouseMove, false );
// scope.domElement.addEventListener( 'mouseup', onMouseUp, false );
scope.dispatchEvent(startEvent);
// this.domElement.addEventListener( 'mousemove', onMouseMove, false );
// this.domElement.addEventListener( 'mouseup', onMouseUp, false );
this.dispatchEvent(startEvent);
}
function onMouseMove (event) {
if (scope.enabled === false) return;
onMouseMove(event){
if (this.enabled === false) return;
event.preventDefault();
var element = scope.domElement === document ? scope.domElement.body : scope.domElement;
let element = this.domElement === document ? this.domElement.body : this.domElement;
if (state === STATE.ROTATE) {
rotateEnd.set(event.clientX, event.clientY);
rotateDelta.subVectors(rotateEnd, rotateStart);
// rotating across whole screen goes 360 degrees around
scope.rotateLeft(2 * Math.PI * rotateDelta.x / element.clientWidth * scope.rotateSpeed);
this.rotateLeft(2 * Math.PI * rotateDelta.x / element.clientWidth * this.rotateSpeed);
// rotating up and down along whole screen attempts to go 360, but limited to 180
scope.rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight * scope.rotateSpeed);
this.rotateUp(2 * Math.PI * rotateDelta.y / element.clientHeight * this.rotateSpeed);
rotateStart.copy(rotateEnd);
} else if (state === STATE.PAN) {
panEnd.set(event.clientX, event.clientY);
panDelta.subVectors(panEnd, panStart);
// panDelta.multiplyScalar(this.moveSpeed).multiplyScalar(0.0001);
panDelta.multiplyScalar(0.002).multiplyScalar(scope.moveSpeed);
panDelta.multiplyScalar(0.002).multiplyScalar(this.moveSpeed);
scope.pan(panDelta.x, panDelta.y);
this.pan(panDelta.x, panDelta.y);
panStart.copy(panEnd);
}
}
function onMouseUp (event) {
if (scope.enabled === false) return;
onMouseUp(event){
if (this.enabled === false) return;
// console.log(event.which);
if (event.button === 2) {
scope.moveForwardMouse = false;
this.moveForwardMouse = false;
} else {
// scope.domElement.removeEventListener( 'mousemove', onMouseMove, false );
// scope.domElement.removeEventListener( 'mouseup', onMouseUp, false );
scope.dispatchEvent(endEvent);
// this.domElement.removeEventListener( 'mousemove', onMouseMove, false );
// this.domElement.removeEventListener( 'mouseup', onMouseUp, false );
this.dispatchEvent(endEvent);
state = STATE.NONE;
}
}
function onMouseWheel (event) {
if (scope.enabled === false || scope.noZoom === true) return;
onMouseWheel(event){
if (this.enabled === false || this.noZoom === true) return;
event.preventDefault();
var direction = (event.detail < 0 || event.wheelDelta > 0) ? 1 : -1;
var moveSpeed = scope.moveSpeed + scope.moveSpeed * 0.1 * direction;
let direction = (event.detail < 0 || event.wheelDelta > 0) ? 1 : -1;
let moveSpeed = this.moveSpeed + this.moveSpeed * 0.1 * direction;
moveSpeed = Math.max(0.1, moveSpeed);
scope.setMoveSpeed(moveSpeed);
this.setMoveSpeed(moveSpeed);
scope.dispatchEvent(startEvent);
scope.dispatchEvent(endEvent);
this.dispatchEvent(startEvent);
this.dispatchEvent(endEvent);
}
this.setMoveSpeed = function (value) {
if (scope.moveSpeed !== value) {
scope.moveSpeed = value;
scope.dispatchEvent({
setMoveSpeed(value){
if (this.moveSpeed !== value) {
this.moveSpeed = value;
this.dispatchEvent({
type: 'move_speed_changed',
controls: scope
controls: this
});
}
};
}
function onKeyDown (event) {
if (scope.enabled === false) return;
onKeyDown(event){
if (this.enabled === false) return;
scope.shiftDown = event.shiftKey;
this.shiftDown = event.shiftKey;
switch (event.keyCode) {
case scope.keys.UP: scope.moveForward = true; break;
case scope.keys.BOTTOM: scope.moveBackward = true; break;
case scope.keys.LEFT: scope.moveLeft = true; break;
case scope.keys.RIGHT: scope.moveRight = true; break;
case scope.keys.W: scope.moveForward = true; break;
case scope.keys.S: scope.moveBackward = true; break;
case scope.keys.A: scope.moveLeft = true; break;
case scope.keys.D: scope.moveRight = true; break;
case scope.keys.Q: scope.rotLeft = true; break;
case scope.keys.E: scope.rotRight = true; break;
case scope.keys.R: scope.raiseCamera = true; break;
case scope.keys.F: scope.lowerCamera = true; break;
case this.keys.UP: this.moveForward = true; break;
case this.keys.BOTTOM: this.moveBackward = true; break;
case this.keys.LEFT: this.moveLeft = true; break;
case this.keys.RIGHT: this.moveRight = true; break;
case this.keys.W: this.moveForward = true; break;
case this.keys.S: this.moveBackward = true; break;
case this.keys.A: this.moveLeft = true; break;
case this.keys.D: this.moveRight = true; break;
case this.keys.Q: this.rotLeft = true; break;
case this.keys.E: this.rotRight = true; break;
case this.keys.R: this.raiseCamera = true; break;
case this.keys.F: this.lowerCamera = true; break;
}
}
function onKeyUp (event) {
scope.shiftDown = event.shiftKey;
onKeyUp(event){
this.shiftDown = event.shiftKey;
switch (event.keyCode) {
case scope.keys.W: scope.moveForward = false; break;
case scope.keys.S: scope.moveBackward = false; break;
case scope.keys.A: scope.moveLeft = false; break;
case scope.keys.D: scope.moveRight = false; break;
case scope.keys.UP: scope.moveForward = false; break;
case scope.keys.BOTTOM: scope.moveBackward = false; break;
case scope.keys.LEFT: scope.moveLeft = false; break;
case scope.keys.RIGHT: scope.moveRight = false; break;
case scope.keys.Q: scope.rotLeft = false; break;
case scope.keys.E: scope.rotRight = false; break;
case scope.keys.R: scope.raiseCamera = false; break;
case scope.keys.F: scope.lowerCamera = false; break;
case this.keys.W: this.moveForward = false; break;
case this.keys.S: this.moveBackward = false; break;
case this.keys.A: this.moveLeft = false; break;
case this.keys.D: this.moveRight = false; break;
case this.keys.UP: this.moveForward = false; break;
case this.keys.BOTTOM: this.moveBackward = false; break;
case this.keys.LEFT: this.moveLeft = false; break;
case this.keys.RIGHT: this.moveRight = false; break;
case this.keys.Q: this.rotLeft = false; break;
case this.keys.E: this.rotRight = false; break;
case this.keys.R: this.raiseCamera = false; break;
case this.keys.F: this.lowerCamera = false; break;
}
}
}
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
scope.domElement.addEventListener('mousemove', onMouseMove, false);
scope.domElement.addEventListener('mouseup', onMouseUp, false);
if (this.domElement.tabIndex === -1) {
this.domElement.tabIndex = 2222;
}
scope.domElement.addEventListener('keydown', onKeyDown, false);
scope.domElement.addEventListener('keyup', onKeyUp, false);
};
Potree.GeoControls.prototype = Object.create(THREE.EventDispatcher.prototype);

View File

@ -164,8 +164,8 @@ Potree.OrbitControls = class OrbitControls extends THREE.EventDispatcher{
let cameraTargetPosition = new THREE.Vector3().addVectors(I.location, d.multiplyScalar(targetRadius));
// TODO Unused: let controlsTargetPosition = I.location;
var animationDuration = 600;
var easing = TWEEN.Easing.Quartic.Out;
let animationDuration = 600;
let easing = TWEEN.Easing.Quartic.Out;
{ // animate
let value = {x: 0};

View File

@ -202,8 +202,8 @@ Potree.utils = class {
}
}
var skyGeometry = new THREE.CubeGeometry(5000, 5000, 5000);
var skybox = new THREE.Mesh(skyGeometry, materialArray);
let skyGeometry = new THREE.CubeGeometry(5000, 5000, 5000);
let skybox = new THREE.Mesh(skyGeometry, materialArray);
scene.add(skybox);

View File

@ -278,7 +278,7 @@ Potree.ClipVolume = class extends THREE.Object3D{
this.box.raycast(raycaster, is);
if(is.length > 0){
var I = is[0];
let I = is[0];
intersects.push({
distance: I.distance,
object: this,

View File

@ -80,25 +80,25 @@ Potree.Profile = class extends THREE.Object3D {
// edges & boxes
if (this.points.length > 1) {
var lineGeometry = new THREE.Geometry();
let lineGeometry = new THREE.Geometry();
lineGeometry.vertices.push(new THREE.Vector3(), new THREE.Vector3());
lineGeometry.colors.push(this.lineColor, this.lineColor, this.lineColor);
var lineMaterial = new THREE.LineBasicMaterial({
let lineMaterial = new THREE.LineBasicMaterial({
vertexColors: THREE.VertexColors,
linewidth: 2,
transparent: true,
opacity: 0.4
});
lineMaterial.depthTest = false;
var edge = new THREE.Line(lineGeometry, lineMaterial);
let edge = new THREE.Line(lineGeometry, lineMaterial);
edge.visible = false;
this.add(edge);
this.edges.push(edge);
var boxGeometry = new THREE.BoxGeometry(1, 1, 1);
var boxMaterial = new THREE.MeshBasicMaterial({color: 0xff0000, transparent: true, opacity: 0.2});
var box = new THREE.Mesh(boxGeometry, boxMaterial);
let boxGeometry = new THREE.BoxGeometry(1, 1, 1);
let boxMaterial = new THREE.MeshBasicMaterial({color: 0xff0000, transparent: true, opacity: 0.2});
let box = new THREE.Mesh(boxGeometry, boxMaterial);
box.visible = false;
this.add(box);
@ -161,7 +161,7 @@ Potree.Profile = class extends THREE.Object3D {
this.remove(this.spheres[index]);
var edgeIndex = (index === 0) ? 0 : (index - 1);
let edgeIndex = (index === 0) ? 0 : (index - 1);
this.remove(this.edges[edgeIndex]);
this.edges.splice(edgeIndex, 1);
this.remove(this.boxes[edgeIndex]);
@ -261,15 +261,15 @@ Potree.Profile = class extends THREE.Object3D {
}
if (leftBox) {
var start = leftVertex;
var end = point;
var length = start.clone().setZ(0).distanceTo(end.clone().setZ(0));
let start = leftVertex;
let end = point;
let length = start.clone().setZ(0).distanceTo(end.clone().setZ(0));
leftBox.scale.set(length, 1000000, this.width);
leftBox.up.set(0, 0, 1);
var center = new THREE.Vector3().addVectors(start, end).multiplyScalar(0.5);
var diff = new THREE.Vector3().subVectors(end, start);
var target = new THREE.Vector3(diff.y, -diff.x, 0);
let center = new THREE.Vector3().addVectors(start, end).multiplyScalar(0.5);
let diff = new THREE.Vector3().subVectors(end, start);
let target = new THREE.Vector3(diff.y, -diff.x, 0);
leftBox.position.set(0, 0, 0);
leftBox.lookAt(target);
@ -283,7 +283,7 @@ Potree.Profile = class extends THREE.Object3D {
centroid.multiplyScalar(1 / this.points.length);
for (let i = 0; i < this.boxes.length; i++) {
var box = this.boxes[i];
let box = this.boxes[i];
box.position.z = min.z + (max.z - min.z) / 2;
}

View File

@ -72,14 +72,14 @@ Potree.Volume = class extends THREE.Object3D {
this.add(this.label);
this.label.updateMatrixWorld = () => {
var volumeWorldPos = new THREE.Vector3();
let volumeWorldPos = new THREE.Vector3();
volumeWorldPos.setFromMatrixPosition(this.matrixWorld);
this.label.position.copy(volumeWorldPos);
this.label.updateMatrix();
this.label.matrixWorld.copy(this.label.matrix);
this.label.matrixWorldNeedsUpdate = false;
for (var i = 0, l = this.label.children.length; i < l; i++) {
for (let i = 0, l = this.label.children.length; i < l; i++) {
this.label.children[ i ].updateMatrixWorld(true);
}
};
@ -126,7 +126,7 @@ Potree.Volume = class extends THREE.Object3D {
this.box.raycast(raycaster, is);
if (is.length > 0) {
var I = is[0];
let I = is[0];
intersects.push({
distance: I.distance,
object: this,

View File

@ -81,9 +81,9 @@ Potree.VolumeTool = class VolumeTool extends THREE.EventDispatcher {
if (I) {
volume.position.copy(I.location);
var wp = volume.getWorldPosition().applyMatrix4(camera.matrixWorldInverse);
// var pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(camera.projectionMatrix);
var w = Math.abs((wp.z / 5));
let wp = volume.getWorldPosition().applyMatrix4(camera.matrixWorldInverse);
// let pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(camera.projectionMatrix);
let w = Math.abs((wp.z / 5));
volume.scale.set(w, w, w);
}
};

View File

@ -36,7 +36,7 @@ class PotreeRenderer {
pointcloud.material.useEDL = false;
}
//var queryPC = Potree.startQuery("PointCloud", viewer.renderer.getContext());
//let queryPC = Potree.startQuery("PointCloud", viewer.renderer.getContext());
let activeCam = viewer.scene.getActiveCamera();
//viewer.renderer.render(viewer.scene.scenePointCloud, activeCam);

View File

@ -43,7 +43,7 @@ class RepRenderer {
return;
}
// var depthTextureExt = gl.getExtension("WEBGL_depth_texture");
// let depthTextureExt = gl.getExtension("WEBGL_depth_texture");
this.edlMaterial = new Potree.EyeDomeLightingMaterial();

View File

@ -148,7 +148,7 @@ Potree.MapView = class {
}
} else {
let content = '';
for (var i = 0; i < features.length; i++) {
for (let i = 0; i < features.length; i++) {
let feature = features[i];
if (feature.source) {
@ -600,7 +600,7 @@ Potree.MapView = class {
$.getJSON(url, (data) => {
let sources = data.sources;
for (var i = 0; i < sources.length; i++) {
for (let i = 0; i < sources.length; i++) {
let source = sources[i];
let name = source.name;
let bounds = source.bounds;
@ -619,7 +619,7 @@ Potree.MapView = class {
let p3 = this.toMap.forward([bounds.max[0], bounds.max[1]]);
let p4 = this.toMap.forward([bounds.min[0], bounds.max[1]]);
// var feature = new ol.Feature({
// let feature = new ol.Feature({
// 'geometry': new ol.geom.LineString([p1, p2, p3, p4, p1])
// });
let feature = new ol.Feature({
@ -668,17 +668,17 @@ Potree.MapView = class {
}
//
var camera = this.viewer.scene.getActiveCamera();
let camera = this.viewer.scene.getActiveCamera();
var scale = this.map.getView().getResolution();
var campos = camera.position;
var camdir = camera.getWorldDirection();
var sceneLookAt = camdir.clone().multiplyScalar(30 * scale).add(campos);
var geoPos = camera.position;
var geoLookAt = sceneLookAt;
var mapPos = new THREE.Vector2().fromArray(this.toMap.forward([geoPos.x, geoPos.y]));
var mapLookAt = new THREE.Vector2().fromArray(this.toMap.forward([geoLookAt.x, geoLookAt.y]));
var mapDir = new THREE.Vector2().subVectors(mapLookAt, mapPos).normalize();
let scale = this.map.getView().getResolution();
let campos = camera.position;
let camdir = camera.getWorldDirection();
let sceneLookAt = camdir.clone().multiplyScalar(30 * scale).add(campos);
let geoPos = camera.position;
let geoLookAt = sceneLookAt;
let mapPos = new THREE.Vector2().fromArray(this.toMap.forward([geoPos.x, geoPos.y]));
let mapLookAt = new THREE.Vector2().fromArray(this.toMap.forward([geoLookAt.x, geoLookAt.y]));
let mapDir = new THREE.Vector2().subVectors(mapLookAt, mapPos).normalize();
mapLookAt = mapPos.clone().add(mapDir.clone().multiplyScalar(30 * scale));
let mapLength = mapPos.distanceTo(mapLookAt);

View File

@ -65,9 +65,9 @@ Potree.GLProgram = class GLProgram {
let n = gl.getProgramParameter(program, gl.ACTIVE_UNIFORMS);
for (let i = 0; i < n; i++) {
var uniform = gl.getActiveUniform(program, i);
var name = uniform.name;
var loc = gl.getUniformLocation(program, name);
let uniform = gl.getActiveUniform(program, i);
let name = uniform.name;
let loc = gl.getUniformLocation(program, name);
uniforms[name] = loc;
}

View File

@ -5,17 +5,17 @@
// importScripts('laz-perf.js');
var instance = null; // laz-perf instance
let instance = null; // laz-perf instance
function readAs (buf, Type, offset, count) {
count = (count === undefined || count === 0 ? 1 : count);
var sub = buf.slice(offset, offset + Type.BYTES_PER_ELEMENT * count);
let sub = buf.slice(offset, offset + Type.BYTES_PER_ELEMENT * count);
var r = new Type(sub);
let r = new Type(sub);
if (count === undefined || count === 1) { return r[0]; }
var ret = [];
for (var i = 0; i < count; i++) {
let ret = [];
for (let i = 0; i < count; i++) {
ret.push(r[i]);
}
@ -23,18 +23,18 @@ function readAs (buf, Type, offset, count) {
}
function parseLASHeader (arraybuffer) {
var o = {};
let o = {};
o.pointsOffset = readAs(arraybuffer, Uint32Array, 32 * 3);
o.pointsFormatId = readAs(arraybuffer, Uint8Array, 32 * 3 + 8);
o.pointsStructSize = readAs(arraybuffer, Uint16Array, 32 * 3 + 8 + 1);
o.pointsCount = readAs(arraybuffer, Uint32Array, 32 * 3 + 11);
var start = 32 * 3 + 35;
let start = 32 * 3 + 35;
o.scale = readAs(arraybuffer, Float64Array, start, 3); start += 24; // 8*3
o.offset = readAs(arraybuffer, Float64Array, start, 3); start += 24;
var bounds = readAs(arraybuffer, Float64Array, start, 6); start += 48; // 8*6;
let bounds = readAs(arraybuffer, Float64Array, start, 6); start += 48; // 8*6;
o.maxs = [bounds[0], bounds[2], bounds[4]];
o.mins = [bounds[1], bounds[3], bounds[5]];
@ -46,8 +46,8 @@ function handleEvent (msg) {
case 'open':
try {
instance = new Module.LASZip();
var abInt = new Uint8Array(msg.arraybuffer);
var buf = Module._malloc(msg.arraybuffer.byteLength);
let abInt = new Uint8Array(msg.arraybuffer);
let buf = Module._malloc(msg.arraybuffer.byteLength);
instance.arraybuffer = msg.arraybuffer;
instance.buf = buf;
@ -65,7 +65,7 @@ function handleEvent (msg) {
case 'header':
if (!instance) { throw new Error('You need to open the file before trying to read header'); }
var header = parseLASHeader(instance.arraybuffer);
let header = parseLASHeader(instance.arraybuffer);
header.pointsFormatId &= 0x3f;
instance.header = header;
postMessage({ type: 'header', status: 1, header: header });
@ -75,23 +75,23 @@ function handleEvent (msg) {
if (!instance) { throw new Error('You need to open the file before trying to read stuff'); }
// msg.start
var count = msg.count;
var skip = msg.skip;
var o = instance;
let count = msg.count;
let skip = msg.skip;
let o = instance;
if (!o.header) { throw new Error('You need to query header before reading, I maintain state that way, sorry :('); }
var pointsToRead = Math.min(count * skip, o.header.pointsCount - o.readOffset);
var bufferSize = Math.ceil(pointsToRead / skip);
var pointsRead = 0;
let pointsToRead = Math.min(count * skip, o.header.pointsCount - o.readOffset);
let bufferSize = Math.ceil(pointsToRead / skip);
let pointsRead = 0;
var thisBuf = new Uint8Array(bufferSize * o.header.pointsStructSize);
var bufRead = Module._malloc(o.header.pointsStructSize);
for (var i = 0; i < pointsToRead; i++) {
let thisBuf = new Uint8Array(bufferSize * o.header.pointsStructSize);
let bufRead = Module._malloc(o.header.pointsStructSize);
for (let i = 0; i < pointsToRead; i++) {
o.getPoint(bufRead);
if (i % skip === 0) {
var a = new Uint8Array(Module.HEAPU8.buffer, bufRead, o.header.pointsStructSize);
let a = new Uint8Array(Module.HEAPU8.buffer, bufRead, o.header.pointsStructSize);
thisBuf.set(a, pointsRead * o.header.pointsStructSize, o.header.pointsStructSize);
pointsRead++;
}