From 61ad1e0ddd6019d0a37e47dd24c4d73e8406850c Mon Sep 17 00:00:00 2001 From: mschuetz Date: Thu, 10 Jul 2014 17:30:51 +0200 Subject: [PATCH] added single file and minify build --- build/js/potree.js | 1278 +++++++++++++++++++++++++++++++++++ build/js/potree.min.js | 1 + examples/point_picking.html | 6 +- gulpfile.js | 40 ++ package.json | 21 + 5 files changed, 1341 insertions(+), 5 deletions(-) create mode 100644 build/js/potree.js create mode 100644 build/js/potree.min.js create mode 100644 gulpfile.js create mode 100644 package.json diff --git a/build/js/potree.js b/build/js/potree.js new file mode 100644 index 00000000..d341b74b --- /dev/null +++ b/build/js/potree.js @@ -0,0 +1,1278 @@ + + +function Potree(){ + +} + +Potree.pointLoadLimit = 50*1000*1000; + + + + + + + + + + +THREE.PerspectiveCamera.prototype.zoomTo = function(node, factor){ + if(factor === undefined){ + factor = 1; + } + + node.updateMatrixWorld(); + this.updateMatrix(); + this.updateMatrixWorld(); + + var box = Potree.utils.computeTransformedBoundingBox(node.boundingBox, node.matrixWorld); + var dir = new THREE.Vector3(0, 0, -1).applyQuaternion(this.quaternion); + var pos = box.center().sub(dir); + + var ps = [ + new THREE.Vector3(box.min.x, box.min.y, box.min.z), + new THREE.Vector3(box.min.x, box.min.y, box.min.z), + new THREE.Vector3(box.max.x, box.min.y, box.min.z), + new THREE.Vector3(box.min.x, box.max.y, box.min.z), + new THREE.Vector3(box.min.x, box.min.y, box.max.z), + new THREE.Vector3(box.min.x, box.max.y, box.max.z), + new THREE.Vector3(box.max.x, box.max.y, box.min.z), + new THREE.Vector3(box.max.x, box.min.y, box.max.z), + new THREE.Vector3(box.max.x, box.max.y, box.max.z) + ]; + + var frustum = new THREE.Frustum(); + frustum.setFromMatrix(new THREE.Matrix4().multiplyMatrices(this.projectionMatrix, this.matrixWorldInverse)); + + var max = Number.MIN_VALUE; + for(var i = 0; i < ps.length; i++){ + var p = ps[i]; + + var distance = Number.MIN_VALUE; + // iterate through left, right, top and bottom planes + for(var j = 0; j < frustum.planes.length-2; j++){ + var plane = frustum.planes[j]; + var ray = new THREE.Ray(p, dir); + var dI = ray.distanceToPlaneWithNegative(plane); + distance = Math.max(distance, dI); + } + max = Math.max(max, distance); + } + var offset = dir.clone().multiplyScalar(-max); + offset.multiplyScalar(factor); + pos.add(offset); + this.position.copy(pos); + +} +THREE.Ray.prototype.distanceToPlaneWithNegative = function ( plane ) { + var denominator = plane.normal.dot( this.direction ); + if ( denominator == 0 ) { + + // line is coplanar, return origin + if( plane.distanceToPoint( this.origin ) == 0 ) { + return 0; + } + + // Null is preferable to undefined since undefined means.... it is undefined + return null; + } + var t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator; + + return t; +} + + +/** + * @class Loads mno files and returns a PointcloudOctree + * for a description of the mno binary file format, read mnoFileFormat.txt + * + * @author Markus Schuetz + */ +function POCLoader(){ + +} + +/** + * @return a point cloud octree with the root node data loaded. + * loading of descendants happens asynchronously when they're needed + * + * @param url + * @param loadingFinishedListener executed after loading the binary has been finished + */ +POCLoader.load = function load(url) { + try{ + var pco = new Potree.PointCloudOctreeGeometry(); + pco.url = url; + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, false); + xhr.send(null); + if(xhr.status === 200 || xhr.status === 0){ + var fMno = JSON.parse(xhr.responseText); + if(Potree.utils.pathExists(fMno.octreeDir + "/r")){ + pco.octreeDir = fMno.octreeDir; + }else{ + pco.octreeDir = url + "/../" + fMno.octreeDir; + } + + pco.spacing = fMno.spacing; + + var nodes = {}; + + { // load root + var name = "r"; + var min = new THREE.Vector3(fMno.boundingBox.lx, fMno.boundingBox.ly, fMno.boundingBox.lz); + var max = new THREE.Vector3(fMno.boundingBox.ux, fMno.boundingBox.uy, fMno.boundingBox.uz); + var boundingBox = new THREE.Box3(min, max); + pco.boundingBox = boundingBox; + + var root = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); + root.level = 0; + root.numPoints = fMno.hierarchy[0][1]; + pco.root = root; + pco.root.load(); + nodes[name] = root; + } + + // load remaining hierarchy + for( var i = 1; i < fMno.hierarchy.length; i++){ + var name = fMno.hierarchy[i][0]; + var numPoints = fMno.hierarchy[i][1]; + var index = parseInt(name.charAt(name.length-1)); + var parentName = name.substring(0, name.length-1); + var parentNode = nodes[parentName]; + var points = fMno.hierarchy[i][1]; + var level = name.length-1; + var boundingBox = POCLoader.createChildAABB(parentNode.boundingBox, index); + + var node = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); + node.level = level; + node.numPoints = numPoints; + parentNode.addChild(node); + nodes[name] = node; + } + + pco.nodes = nodes; + + } + + return pco; + }catch(e){ + console.log("loading failed: '" + url + "'"); + console.log(e); + } +}; + +POCLoader.loadPointAttributes = function(mno){ + + var fpa = mno.pointAttributes; + var pa = new PointAttributes(); + + for(var i = 0; i < fpa.length; i++){ + var pointAttribute = PointAttribute[fpa[i]]; + pa.add(pointAttribute); + } + + return pa; +}; + + +POCLoader.createChildAABB = function(aabb, childIndex){ + var V3 = THREE.Vector3; + 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); + + var cmin = min; + var cmax = new THREE.Vector3().add(min).add(dHalfLength); + + var min, max; + if (childIndex === 1) { + min = new THREE.Vector3().copy(cmin).add(zHalfLength); + max = new THREE.Vector3().copy(cmax).add(zHalfLength); + }else if (childIndex === 3) { + min = new THREE.Vector3().copy(cmin).add(zHalfLength).add(yHalfLength); + max = new THREE.Vector3().copy(cmax).add(zHalfLength).add(yHalfLength); + }else if (childIndex === 0) { + min = cmin; + max = cmax; + }else if (childIndex === 2) { + min = new THREE.Vector3().copy(cmin).add(yHalfLength); + max = new THREE.Vector3().copy(cmax).add(yHalfLength); + }else if (childIndex === 5) { + min = new THREE.Vector3().copy(cmin).add(zHalfLength).add(xHalfLength); + max = new THREE.Vector3().copy(cmax).add(zHalfLength).add(xHalfLength); + }else if (childIndex === 7) { + min = new THREE.Vector3().copy(cmin).add(dHalfLength); + max = new THREE.Vector3().copy(cmax).add(dHalfLength); + }else if (childIndex === 4) { + min = new THREE.Vector3().copy(cmin).add(xHalfLength); + max = new THREE.Vector3().copy(cmax).add(xHalfLength); + }else if (childIndex === 6) { + min = new THREE.Vector3().copy(cmin).add(xHalfLength).add(yHalfLength); + max = new THREE.Vector3().copy(cmax).add(xHalfLength).add(yHalfLength); + } + + return new THREE.Box3(min, max); +}; + + + + + +///** +// * Some types of possible point attributes +// * +// * @class +// */ +//var PointAttributeNames = { +// POSITION_CARTESIAN : 0, // float x, y, z; +// COLOR_PACKED : 1, // byte r, g, b, a; I = [0,1] +// COLOR_FLOATS_1 : 2, // float r, g, b; I = [0,1] +// COLOR_FLOATS_255 : 3, // float r, g, b; I = [0,255] +// NORMAL_FLOATS : 4, // float x, y, z; +// FILLER : 5 +//}; +// +//var i = 0; +//for(var obj in PointAttributeNames){ +// PointAttributeNames[i] = PointAttributeNames[obj]; +// i++; +//} + +function PointAttributeNames(){ + +} + +PointAttributeNames.POSITION_CARTESIAN = 0; // float x, y, z; +PointAttributeNames.COLOR_PACKED = 1; // byte r, g, b, a; I = [0,1] +PointAttributeNames.COLOR_FLOATS_1 = 2; // float r, g, b; I = [0,1] +PointAttributeNames.COLOR_FLOATS_255 = 3; // float r, g, b; I = [0,255] +PointAttributeNames.NORMAL_FLOATS = 4; // float x, y, z; +PointAttributeNames.FILLER = 5; +/** + * Some types of possible point attribute data formats + * + * @class + */ +var PointAttributeTypes = { + DATA_TYPE_DOUBLE : {ordinal : 0, size: 8}, + DATA_TYPE_FLOAT : {ordinal : 1, size: 4}, + DATA_TYPE_INT8 : {ordinal : 2, size: 1}, + DATA_TYPE_UINT8 : {ordinal : 3, size: 1}, + DATA_TYPE_INT16 : {ordinal : 4, size: 2}, + DATA_TYPE_UINT16 : {ordinal : 5, size: 2}, + DATA_TYPE_INT32 : {ordinal : 6, size: 4}, + DATA_TYPE_UINT32 : {ordinal : 7, size: 4}, + DATA_TYPE_INT64 : {ordinal : 8, size: 8}, + DATA_TYPE_UINT64 : {ordinal : 9, size: 8} +}; + +var i = 0; +for(var obj in PointAttributeTypes){ + PointAttributeTypes[i] = PointAttributeTypes[obj]; + i++; +} + +/** + * A single point attribute such as color/normal/.. and its data format/number of elements/... + * + * @class + * @param name + * @param type + * @param size + * @returns + */ +function PointAttribute(name, type, numElements){ + this.name = name; + this.type = type; + this.numElements = numElements; + this.byteSize = this.numElements * this.type.size; +} + +PointAttribute.POSITION_CARTESIAN = new PointAttribute( + PointAttributeNames.POSITION_CARTESIAN, + PointAttributeTypes.DATA_TYPE_FLOAT, 3); + +PointAttribute.RGBA_PACKED = new PointAttribute( + PointAttributeNames.COLOR_PACKED, + PointAttributeTypes.DATA_TYPE_INT8, 4); + +PointAttribute.COLOR_PACKED = PointAttribute.RGBA_PACKED; + +PointAttribute.RGB_PACKED = new PointAttribute( + PointAttributeNames.COLOR_PACKED, + PointAttributeTypes.DATA_TYPE_INT8, 3); + +PointAttribute.NORMAL_FLOATS = new PointAttribute( + PointAttributeNames.NORMAL_FLOATS, + PointAttributeTypes.DATA_TYPE_FLOAT, 3); + +PointAttribute.FILLER_1B = new PointAttribute( + PointAttributeNames.FILLER, + PointAttributeTypes.DATA_TYPE_UINT8, 1); + +/** + * Ordered list of PointAttributes used to identify how points are aligned in a buffer. + * + * @class + * + */ +function PointAttributes(pointAttributes){ + this.attributes = new Array(); + this.byteSize = 0; + this.size = 0; + + if(pointAttributes != null){ + // does not work in chrome v24 +// for(var pointAttribute of pointAttributes){ +// this.attributes.push(pointAttribute); +// this.byteSize += pointAttribute.byteSize; +// this.size++; +// } + + for(var name in pointAttributes){ + var pointAttribute = pointAttributes[name]; + this.attributes.push(pointAttribute); + this.byteSize += pointAttribute.byteSize; + this.size++; + } + } +} + +PointAttributes.prototype.add = function(pointAttribute){ + this.attributes.push(pointAttribute); + this.byteSize += pointAttribute.byteSize; + this.size++; +}; + +PointAttributes.prototype.hasColors = function(){ + for(var name in this.attributes){ + var pointAttribute = this.attributes[name]; + if(pointAttribute.name === PointAttributeNames.COLOR_PACKED){ + return true; + } + } + + return false; +}; + +PointAttributes.prototype.hasNormals = function(){ + for(var name in this.attributes){ + var pointAttribute = this.attributes[name]; + if(pointAttribute === PointAttribute.NORMAL_FLOATS){ + return true; + } + } + + return false; +}; + + + + + +/** + * @author mschuetz / http://mschuetz.at + * + * adapted from THREE.OrbitControls by + * + * @author qiao / https://github.com/qiao + * @author mrdoob / http://mrdoob.com + * @author alteredq / http://alteredqualia.com/ + * @author WestLangley / http://github.com/WestLangley + * @author erich666 / http://erichaines.com + * + * This set of controls performs first person navigation without mouse lock. + * Instead, rotating the camera is done by dragging with the left mouse button. + * + * move: a/s/d/w or up/down/left/right + * rotate: left mouse + * pan: right mouse + * change speed: mouse wheel + * + * + */ + + + +THREE.FirstPersonControls = function ( object, domElement ) { + this.object = object; + this.domElement = ( domElement !== undefined ) ? domElement : document; + + // Set to false to disable this control + this.enabled = true; + + this.rotateSpeed = 1.0; + this.moveSpeed = 10.0; + + 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) + }; + + var scope = this; + + var rotateStart = new THREE.Vector2(); + var rotateEnd = new THREE.Vector2(); + var rotateDelta = new THREE.Vector2(); + + var panStart = new THREE.Vector2(); + var panEnd = new THREE.Vector2(); + var panDelta = new THREE.Vector2(); + var panOffset = new THREE.Vector3(); + + var offset = new THREE.Vector3(); + + var phiDelta = 0; + var thetaDelta = 0; + var scale = 1; + var pan = new THREE.Vector3(); + + var lastPosition = new THREE.Vector3(); + + var STATE = { NONE : -1, ROTATE : 0, SPEEDCHANGE : 1, PAN : 2 }; + + var state = STATE.NONE; + + // for reset + this.position0 = this.object.position.clone(); + + // events + + var changeEvent = { type: 'change' }; + var startEvent = { type: 'start'}; + var endEvent = { type: 'end'}; + + this.rotateLeft = function ( angle ) { + thetaDelta -= angle; + }; + + this.rotateUp = function ( angle ) { + phiDelta -= angle; + }; + + // pass in distance in world space to move left + this.panLeft = function ( distance ) { + + var 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; + + // 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 ) { + + var te = this.object.matrix.elements; + + // get Y column of matrix + panOffset.set( te[ 8 ], te[ 9 ], te[ 10 ] ); + panOffset.multiplyScalar( distance ); + + pan.add( panOffset ); + + }; + + this.pan = function ( deltaX, deltaY ) { + + var element = scope.domElement === document ? scope.domElement.body : scope.domElement; + + if ( scope.object.fov !== undefined ) { + // perspective + var position = scope.object.position; + var offset = position.clone(); + var targetDistance = offset.length(); + + // half of the fov is center to top of screen + targetDistance *= Math.tan( ( scope.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 ) { + + // orthographic + scope.panLeft( deltaX * (scope.object.right - scope.object.left) / element.clientWidth ); + scope.panUp( deltaY * (scope.object.top - scope.object.bottom) / element.clientHeight ); + } else { + + // camera neither orthographic or perspective + console.warn( 'WARNING: FirstPersonControls.js encountered an unknown camera type - pan disabled.' ); + } + }; + + this.update = function (delta) { + var position = this.object.position; + + if(delta !== undefined){ + if(this.moveRight){ + this.panLeft(-delta * this.moveSpeed); + } + if(this.moveLeft){ + this.panLeft(delta * this.moveSpeed); + } + if(this.moveForward){ + this.panForward(-delta * this.moveSpeed); + } + if(this.moveBackward){ + this.panForward(delta * this.moveSpeed); + } + } + + if(!pan.equals(new THREE.Vector3(0,0,0))){ + var event = { + type: 'move', + translation: pan.clone() + }; + this.dispatchEvent(event); + } + + position.add(pan); + + this.object.updateMatrix(); + var rot = new THREE.Matrix4().makeRotationY(thetaDelta); + var res = new THREE.Matrix4().multiplyMatrices(rot, this.object.matrix); + this.object.quaternion.setFromRotationMatrix(res); + + this.object.rotation.x += phiDelta; + + thetaDelta = 0; + phiDelta = 0; + scale = 1; + pan.set( 0, 0, 0 ); + + if ( lastPosition.distanceTo( this.object.position ) > 0 ) { + this.dispatchEvent( changeEvent ); + + lastPosition.copy( this.object.position ); + } + }; + + + this.reset = function () { + state = STATE.NONE; + + this.object.position.copy( this.position0 ); + }; + + function onMouseDown( event ) { + if ( scope.enabled === false ) return; + event.preventDefault(); + + if ( event.button === 0 ) { + state = STATE.ROTATE; + + rotateStart.set( event.clientX, event.clientY ); + } else if ( event.button === 2 ) { + state = STATE.PAN; + + panStart.set( event.clientX, event.clientY ); + } + + scope.domElement.addEventListener( 'mousemove', onMouseMove, false ); + scope.domElement.addEventListener( 'mouseup', onMouseUp, false ); + scope.dispatchEvent( startEvent ); + } + + function onMouseMove( event ) { + if ( scope.enabled === false ) return; + + event.preventDefault(); + + var element = scope.domElement === document ? scope.domElement.body : scope.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 ); + + // 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 ); + + rotateStart.copy( rotateEnd ); + + } else if ( state === STATE.PAN ) { + panEnd.set( event.clientX, event.clientY ); + panDelta.subVectors( panEnd, panStart ); + + scope.pan( panDelta.x, panDelta.y ); + + panStart.copy( panEnd ); + } + } + + function onMouseUp() { + if ( scope.enabled === false ) return; + + scope.domElement.removeEventListener( 'mousemove', onMouseMove, false ); + scope.domElement.removeEventListener( 'mouseup', onMouseUp, false ); + scope.dispatchEvent( endEvent ); + state = STATE.NONE; + + } + + function onMouseWheel(event) { + if ( scope.enabled === false || scope.noZoom === true ) return; + + event.preventDefault(); + + var delta = 0; + if ( event.wheelDelta !== undefined ) { // WebKit / Opera / Explorer 9 + delta = event.wheelDelta; + } else if ( event.detail !== undefined ) { // Firefox + delta = - event.detail; + } + + scope.moveSpeed += scope.moveSpeed * 0.001 * delta; + scope.moveSpeed = Math.max(0.1, scope.moveSpeed); + + scope.dispatchEvent( startEvent ); + scope.dispatchEvent( endEvent ); + } + + function onKeyDown( event ) { + if ( scope.enabled === false) return; + + 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; + } + } + + function onKeyUp( event ) { + 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; + } + } + + 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 + + window.addEventListener( 'keydown', onKeyDown, false ); + window.addEventListener( 'keyup', onKeyUp, false ); + +}; + +THREE.FirstPersonControls.prototype = Object.create( THREE.EventDispatcher.prototype ); + + +/** + * + * @param node + * @class an item in the lru list. + */ +function LRUItem(node){ + this.previous = null; + this.next = null; + this.node = node; +} + +/** + * + * @class A doubly-linked-list of the least recently used elements. + */ +function LRU(){ + // the least recently used item + this.first = null; + // the most recently used item + this.last = null; + // a list of all items in the lru list + this.items = {}; + this.elements = 0; + this.numPoints = 0; +} + +/** + * number of elements in the list + * + * @returns {Number} + */ +LRU.prototype.size = function(){ + return this.elements; +}; + +LRU.prototype.contains = function(node){ + return this.items[node.id] == null; +}; + +/** + * makes node the most recently used item. if the list does not contain node, it will be added. + * + * @param node + */ +LRU.prototype.touch = function(node){ + var item; + if(this.items[node.id] == null){ + // add to list + item = new LRUItem(node); + item.previous = this.last; + this.last = item; + if(item.previous !== null){ + item.previous.next = item; + } + + this.items[node.id] = item; + this.elements++; + + if(this.first === null){ + this.first = item; + } + this.numPoints += node.numPoints; + }else{ + // update in list + item = this.items[node.id]; + if(item.previous === null){ + // handle touch on first element + if(item.next !== null){ + this.first = item.next; + this.first.previous = null; + item.previous = this.last; + item.next = null; + this.last = item; + item.previous.next = item; + } + }else if(item.next === null){ + // handle touch on last element + }else{ + // handle touch on any other element + item.previous.next = item.next; + item.next.previous = item.previous; + item.previous = this.last; + item.next = null; + this.last = item; + item.previous.next = item; + } + + + } +}; + +/** + * 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.getLRUItem = function(){ + if(this.first === null){ + return null; + } + var lru = this.first; + + return lru.node; +}; + +LRU.prototype.toString = function(){ + var string = "{ "; + var curr = this.first; + while(curr !== null){ + string += curr.node.id; + if(curr.next !== null){ + string += ", "; + } + curr = curr.next; + } + string += "}"; + string += "(" + this.size() + ")"; + return string; +}; + + + +/** + * Stands in place for invisible or unloaded octree nodes. + * If a proxy node becomes visible and its geometry has not been loaded, + * loading will begin. + * If it is visible and the geometry has been loaded, the proxy node will + * be replaced with a point cloud node (THREE.PointCloud as of now) + */ +Potree.PointCloudOctreeProxyNode = function(geometryNode){ + THREE.Object3D.call( this ); + + this.geometryNode = geometryNode; + this.boundingBox = geometryNode.boundingBox; + this.name = geometryNode.name; + this.level = geometryNode.level; + this.numPoints = geometryNode.numPoints; +} + +Potree.PointCloudOctreeProxyNode.prototype = Object.create(THREE.Object3D.prototype); + +Potree.PointCloudOctree = function(geometry, material){ + THREE.Object3D.call( this ); + + Potree.PointCloudOctree.lru = Potree.PointCloudOctree.lru || new LRU(); + + this.pcoGeometry = geometry; + this.boundingBox = this.pcoGeometry.boundingBox; + this.material = material; + this.maxVisibleNodes = 2000; + this.maxVisiblePoints = 20*1000*1000; + this.level = 0; + + this.LODDistance = 20; + this.LODFalloff = 1.3; + this.LOD = 4; + + + var rootProxy = new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root); + this.add(rootProxy); +} + +Potree.PointCloudOctree.prototype = Object.create(THREE.Object3D.prototype); + +Potree.PointCloudOctree.prototype.update = function(camera){ + this.numVisibleNodes = 0; + this.numVisiblePoints = 0; + + // create frustum in object space + var frustum = new THREE.Frustum(); + var viewI = camera.matrixWorldInverse; + var world = this.matrixWorld; + var proj = camera.projectionMatrix; + var fm = new THREE.Matrix4().multiply(proj).multiply(viewI).multiply(world); + frustum.setFromMatrix( fm ); + + // calculate camera position in object space + var view = camera.matrixWorld; + var worldI = new THREE.Matrix4().getInverse(world); + var camMatrixObject = new THREE.Matrix4().multiply(worldI).multiply(view); + var camObjPos = new THREE.Vector3().setFromMatrixPosition( camMatrixObject ); + // check visibility + var stack = []; + stack.push(this); + while(stack.length > 0){ + var object = stack.shift(); + + var box = object.boundingBox; + var distance = box.center().distanceTo(camObjPos); + var radius = box.size().length() * 0.5; + + var visible = true; + visible = visible && frustum.intersectsBox(box); + if(object.level > 0){ + visible = visible && radius / distance > (1 / this.LOD); + visible = visible && (this.numVisiblePoints + object.numPoints < Potree.pointLoadLimit); + visible = visible && (this.numVisibleNodes <= this.maxVisibleNodes); + visible = visible && (this.numVisiblePoints <= this.maxVisiblePoints); + }else{ + visible = true; + } + object.visible = visible; + + if(!visible){ + this.hideDescendants(object); + continue; + } + + if(object instanceof THREE.PointCloud){ + this.numVisibleNodes++; + this.numVisiblePoints += object.numPoints; + Potree.PointCloudOctree.lru.touch(object); + }else if (object instanceof Potree.PointCloudOctreeProxyNode) { + this.replaceProxy(object); + } + + for(var i = 0; i < object.children.length; i++){ + stack.push(object.children[i]); + } + } +} + + +Potree.PointCloudOctree.prototype.replaceProxy = function(proxy){ + + var geometryNode = proxy.geometryNode; + if(geometryNode.loaded === true){ + var geometry = geometryNode.geometry; + var node = new THREE.PointCloud(geometry, this.material); + node.name = proxy.name; + node.level = proxy.level; + node.numPoints = proxy.numPoints; + node.boundingBox = geometry.boundingBox; + node.pcoGeometry = geometryNode; + var parent = proxy.parent; + parent.remove(proxy); + parent.add(node); + + for(var i = 0; i < 8; i++){ + if(geometryNode.children[i] !== undefined){ + var child = geometryNode.children[i]; + var childProxy = new Potree.PointCloudOctreeProxyNode(child); + node.add(childProxy); + } + } + }else{ + geometryNode.load(); + } +} + +Potree.PointCloudOctree.prototype.hideDescendants = function(object){ + var stack = []; + for(var i = 0; i < object.children.length; i++){ + var child = object.children[i]; + if(child.visible){ + stack.push(child); + } + } + + while(stack.length > 0){ + var object = stack.shift(); + + object.visible = false; + + for(var i = 0; i < object.children.length; i++){ + var child = object.children[i]; + if(child.visible){ + stack.push(child); + } + } + } +} + +Potree.PointCloudOctree.prototype.moveToOrigin = function(){ + this.position.set(0,0,0); + this.updateMatrixWorld(); + var box = this.boundingBox; + var transform = this.matrixWorld; + var tBox = Potree.utils.computeTransformedBoundingBox(box, transform); + this.position.set(0,0,0).sub(tBox.center()); +} + +Potree.PointCloudOctree.prototype.moveToGroundPlane = function(){ + this.updateMatrixWorld(); + var box = this.boundingBox; + var transform = this.matrixWorld; + var tBox = Potree.utils.computeTransformedBoundingBox(box, transform); + this.position.y += -tBox.min.y; +} + + +/** + * + * amount: minimum number of points to remove + */ +Potree.PointCloudOctree.disposeLeastRecentlyUsed = function(amount){ + + + var freed = 0; + do{ + var node = this.lru.first.node; + var parent = node.parent; + var geometry = node.geometry; + var pcoGeometry = node.pcoGeometry; + var proxy = new Potree.PointCloudOctreeProxyNode(pcoGeometry); + + var result = Potree.PointCloudOctree.disposeNode(node); + freed += result.freed; + + parent.add(proxy); + + if(result.numDeletedNodes == 0){ + break; + } + }while(freed < amount); +} + +Potree.PointCloudOctree.disposeNode = function(node){ + + var freed = 0; + var numDeletedNodes = 0; + var descendants = []; + + node.traverse(function(object){ + descendants.push(object); + }); + + for(var i = 0; i < descendants.length; i++){ + var descendant = descendants[i]; + if(descendant instanceof THREE.PointCloud){ + freed += descendant.pcoGeometry.numPoints; + descendant.pcoGeometry.dispose(); + descendant.geometry.dispose(); + Potree.PointCloudOctree.lru.remove(descendant); + numDeletedNodes++; + } + } + + Potree.PointCloudOctree.lru.remove(node); + node.parent.remove(node); + + return { + "freed": freed, + "numDeletedNodes": numDeletedNodes + }; +} + + + +Potree.PointCloudOctreeGeometry = function(){ + Potree.PointCloudOctree.lru = Potree.PointCloudOctree.lru || new LRU(); + + this.numNodesLoading = 0; +} + +Potree.PointCloudOctreeGeometryNode = function(name, pcoGeometry, boundingBox){ + this.name = name; + this.index = parseInt(name.charAt(name.length-1)); + this.pcoGeometry = pcoGeometry; + this.boundingBox = boundingBox; + this.children = {}; + this.numPoints = 0; + this.level = null; + +} + +Potree.PointCloudOctreeGeometryNode.prototype.addChild = function(child){ + this.children[child.index] = child; + child.parent = this; +} + +Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ + if(this.loading === true || this.pcoGeometry.numNodesLoading > 3){ + return; + } + + if(Potree.PointCloudOctree.lru.numPoints + this.numPoints >= Potree.pointLoadLimit){ + Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints); + } + + + this.pcoGeometry.numNodesLoading++; + this.loading = true; + var url = this.pcoGeometry.octreeDir + "/" + this.name; + var node = this; + var xhr = new XMLHttpRequest(); + xhr.open('GET', url, true); + xhr.responseType = 'arraybuffer'; + xhr.overrideMimeType('text/plain; charset=x-user-defined'); + xhr.onreadystatechange = function() { + if (xhr.readyState === 4) { + if (xhr.status === 200 || xhr.status === 0) { + var buffer = xhr.response; + node.bufferLoaded(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.PointCloudOctreeGeometryNode.prototype.bufferLoaded = function(buffer){ + //console.log("loaded: " + this.name); + + var geometry = new THREE.BufferGeometry(); + var numPoints = buffer.byteLength / 16; + + var positions = new Float32Array(numPoints*3); + var colors = new Float32Array(numPoints*3); + var color = new THREE.Color(); + + var fView = new Float32Array(buffer); + var uiView = new Uint8Array(buffer); + + for(var i = 0; i < numPoints; i++){ + positions[3*i] = fView[4*i]; + positions[3*i+1] = fView[4*i+1]; + positions[3*i+2] = fView[4*i+2]; + + color.setRGB(uiView[16*i+12], uiView[16*i+13], uiView[16*i+14]); + colors[3*i] = color.r /255; + colors[3*i+1] = color.g / 255; + colors[3*i+2] = color.b / 255; + } + + geometry.addAttribute('position', new THREE.Float32Attribute(positions, 3)); + geometry.addAttribute('color', new THREE.Float32Attribute(colors, 3)); + geometry.boundingBox = this.boundingBox; + this.geometry = geometry; + this.loaded = true; + this.loading = false; + this.pcoGeometry.numNodesLoading--; +} + +Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){ + delete this.geometry; + this.loaded = false; + + //console.log("dispose: " + this.name); +} + +Potree.utils = function(){ + +}; + +Potree.utils.pathExists = function(url){ + var req = new XMLHttpRequest(); + req.open('GET', url, false); + req.send(null); + if (req.status !== 200) { + return false; + } + return true; +} + +/** + * adapted from mhluska at https://github.com/mrdoob/three.js/issues/1561 + */ +Potree.utils.computeTransformedBoundingBox = function (box, transform) { + + var vertices = [ + new THREE.Vector3(box.min.x, box.min.y, box.min.z).applyMatrix4(transform), + new THREE.Vector3(box.min.x, box.min.y, box.min.z).applyMatrix4(transform), + new THREE.Vector3(box.max.x, box.min.y, box.min.z).applyMatrix4(transform), + new THREE.Vector3(box.min.x, box.max.y, box.min.z).applyMatrix4(transform), + new THREE.Vector3(box.min.x, box.min.y, box.max.z).applyMatrix4(transform), + new THREE.Vector3(box.min.x, box.max.y, box.max.z).applyMatrix4(transform), + new THREE.Vector3(box.max.x, box.max.y, box.min.z).applyMatrix4(transform), + 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) + ]; + + var boundingBox = new THREE.Box3(); + boundingBox.setFromPoints( vertices ); + + return boundingBox; +} + +/** + * add separators to large numbers + * + * @param nStr + * @returns + */ +Potree.utils.addCommas = function(nStr){ + nStr += ''; + x = nStr.split('.'); + x1 = x[0]; + x2 = x.length > 1 ? '.' + x[1] : ''; + var rgx = /(\d+)(\d{3})/; + while (rgx.test(x1)) { + x1 = x1.replace(rgx, '$1' + ',' + '$2'); + } + return x1 + x2; +} + +Potree.utils.loadSkybox = function(path){ + var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 100000 ); + var scene = new THREE.Scene(); + + var format = ".jpg"; + var urls = [ + path + 'px' + format, path + 'nx' + format, + path + 'py' + format, path + 'ny' + format, + path + 'pz' + format, path + 'nz' + format + ]; + + var textureCube = THREE.ImageUtils.loadTextureCube( urls, new THREE.CubeRefractionMapping() ); + var material = new THREE.MeshBasicMaterial( { color: 0xffffff, envMap: textureCube, refractionRatio: 0.95 } ); + + var shader = THREE.ShaderLib[ "cube" ]; + shader.uniforms[ "tCube" ].value = textureCube; + + var material = new THREE.ShaderMaterial( { + + fragmentShader: shader.fragmentShader, + vertexShader: shader.vertexShader, + uniforms: shader.uniforms, + depthWrite: false, + side: THREE.BackSide + + } ), + + mesh = new THREE.Mesh( new THREE.BoxGeometry( 100, 100, 100 ), material ); + scene.add( mesh ); + + return {"camera": camera, "scene": scene}; +} + + +Potree.utils.createGrid = function createGrid(width, length, spacing){ + var material = new THREE.LineBasicMaterial({ + color: 0xBBBBBB + }); + + var geometry = new THREE.Geometry(); + for(var i = 0; i <= length; i++){ + geometry.vertices.push(new THREE.Vector3(-(spacing*width)/2, 0, i*spacing-(spacing*length)/2)); + geometry.vertices.push(new THREE.Vector3(+(spacing*width)/2, 0, i*spacing-(spacing*length)/2)); + } + + for(var i = 0; i <= width; i++){ + geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, 0, -(spacing*length)/2)); + geometry.vertices.push(new THREE.Vector3(i*spacing-(spacing*width)/2, 0, +(spacing*length)/2)); + } + + var line = new THREE.Line(geometry, material, THREE.LinePieces); + line.receiveShadow = true; + return line; +} + diff --git a/build/js/potree.min.js b/build/js/potree.min.js new file mode 100644 index 00000000..578ebd23 --- /dev/null +++ b/build/js/potree.min.js @@ -0,0 +1 @@ +function Potree(){}function POCLoader(){}function PointAttributeNames(){}function PointAttribute(e,t,o){this.name=e,this.type=t,this.numElements=o,this.byteSize=this.numElements*this.type.size}function PointAttributes(e){if(this.attributes=new Array,this.byteSize=0,this.size=0,null!=e)for(var t in e){var o=e[t];this.attributes.push(o),this.byteSize+=o.byteSize,this.size++}}function LRUItem(e){this.previous=null,this.next=null,this.node=e}function LRU(){this.first=null,this.last=null,this.items={},this.elements=0,this.numPoints=0}Potree.pointLoadLimit=5e7,THREE.PerspectiveCamera.prototype.zoomTo=function(e,t){void 0===t&&(t=1),e.updateMatrixWorld(),this.updateMatrix(),this.updateMatrixWorld();var o=Potree.utils.computeTransformedBoundingBox(e.boundingBox,e.matrixWorld),i=new THREE.Vector3(0,0,-1).applyQuaternion(this.quaternion),n=o.center().sub(i),r=[new THREE.Vector3(o.min.x,o.min.y,o.min.z),new THREE.Vector3(o.min.x,o.min.y,o.min.z),new THREE.Vector3(o.max.x,o.min.y,o.min.z),new THREE.Vector3(o.min.x,o.max.y,o.min.z),new THREE.Vector3(o.min.x,o.min.y,o.max.z),new THREE.Vector3(o.min.x,o.max.y,o.max.z),new THREE.Vector3(o.max.x,o.max.y,o.min.z),new THREE.Vector3(o.max.x,o.min.y,o.max.z),new THREE.Vector3(o.max.x,o.max.y,o.max.z)],s=new THREE.Frustum;s.setFromMatrix((new THREE.Matrix4).multiplyMatrices(this.projectionMatrix,this.matrixWorldInverse));for(var a=Number.MIN_VALUE,d=0;d0&&(this.dispatchEvent(R),b.copy(this.object.position))},this.reset=function(){f=x.NONE,this.object.position.copy(this.position0)},this.domElement.addEventListener("contextmenu",function(e){e.preventDefault()},!1),this.domElement.addEventListener("mousedown",o,!1),this.domElement.addEventListener("mousewheel",r,!1),this.domElement.addEventListener("DOMMouseScroll",r,!1),window.addEventListener("keydown",s,!1),window.addEventListener("keyup",a,!1)},THREE.FirstPersonControls.prototype=Object.create(THREE.EventDispatcher.prototype),LRU.prototype.size=function(){return this.elements},LRU.prototype.contains=function(e){return null==this.items[e.id]},LRU.prototype.touch=function(e){var t;null==this.items[e.id]?(t=new LRUItem(e),t.previous=this.last,this.last=t,null!==t.previous&&(t.previous.next=t),this.items[e.id]=t,this.elements++,null===this.first&&(this.first=t),this.numPoints+=e.numPoints):(t=this.items[e.id],null===t.previous?null!==t.next&&(this.first=t.next,this.first.previous=null,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t):null===t.next||(t.previous.next=t.next,t.next.previous=t.previous,t.previous=this.last,t.next=null,this.last=t,t.previous.next=t))},LRU.prototype.remove=function(){if(null===this.first)return null;var e=this.first;return null!==e.next?(this.first=e.next,this.first.previous=null):(this.first=null,this.last=null),delete this.items[e.node.id],this.elements--,this.numPoints-=e.node.numPoints,e.node},LRU.prototype.getLRUItem=function(){if(null===this.first)return null;var e=this.first;return e.node},LRU.prototype.toString=function(){for(var e="{ ",t=this.first;null!==t;)e+=t.node.id,null!==t.next&&(e+=", "),t=t.next;return e+="}",e+="("+this.size()+")"},Potree.PointCloudOctreeProxyNode=function(e){THREE.Object3D.call(this),this.geometryNode=e,this.boundingBox=e.boundingBox,this.name=e.name,this.level=e.level,this.numPoints=e.numPoints},Potree.PointCloudOctreeProxyNode.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree=function(e,t){THREE.Object3D.call(this),Potree.PointCloudOctree.lru=Potree.PointCloudOctree.lru||new LRU,this.pcoGeometry=e,this.boundingBox=this.pcoGeometry.boundingBox,this.material=t,this.maxVisibleNodes=2e3,this.maxVisiblePoints=2e7,this.level=0,this.LODDistance=20,this.LODFalloff=1.3,this.LOD=4;var o=new Potree.PointCloudOctreeProxyNode(this.pcoGeometry.root);this.add(o)},Potree.PointCloudOctree.prototype=Object.create(THREE.Object3D.prototype),Potree.PointCloudOctree.prototype.update=function(e){this.numVisibleNodes=0,this.numVisiblePoints=0;var t=new THREE.Frustum,o=e.matrixWorldInverse,i=this.matrixWorld,n=e.projectionMatrix,r=(new THREE.Matrix4).multiply(n).multiply(o).multiply(i);t.setFromMatrix(r);var s=e.matrixWorld,a=(new THREE.Matrix4).getInverse(i),d=(new THREE.Matrix4).multiply(a).multiply(s),l=(new THREE.Vector3).setFromMatrixPosition(d),u=[];for(u.push(this);u.length>0;){var c=u.shift(),m=c.boundingBox,h=m.center().distanceTo(l),p=.5*m.size().length(),E=!0;if(E=E&&t.intersectsBox(m),c.level>0?(E=E&&p/h>1/this.LOD,E=E&&this.numVisiblePoints+c.numPointsr;r++)if(void 0!==t.children[r]){var s=t.children[r],a=new Potree.PointCloudOctreeProxyNode(s);i.add(a)}}else t.load()},Potree.PointCloudOctree.prototype.hideDescendants=function(e){for(var t=[],o=0;o0;){var e=t.shift();e.visible=!1;for(var o=0;ot)},Potree.PointCloudOctree.disposeNode=function(e){var t=0,o=0,i=[];e.traverse(function(e){i.push(e)});for(var n=0;n3)){Potree.PointCloudOctree.lru.numPoints+this.numPoints>=Potree.pointLoadLimit&&Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints),this.pcoGeometry.numNodesLoading++,this.loading=!0;var e=this.pcoGeometry.octreeDir+"/"+this.name,t=this,o=new XMLHttpRequest;o.open("GET",e,!0),o.responseType="arraybuffer",o.overrideMimeType("text/plain; charset=x-user-defined"),o.onreadystatechange=function(){if(4===o.readyState)if(200===o.status||0===o.status){var i=o.response;t.bufferLoaded(i)}else console.log("Failed to load file! HTTP status: "+o.status+", file: "+e)};try{o.send(null)}catch(i){console.log("fehler beim laden der punktwolke: "+i)}}},Potree.PointCloudOctreeGeometryNode.prototype.bufferLoaded=function(e){for(var t=new THREE.BufferGeometry,o=e.byteLength/16,i=new Float32Array(3*o),n=new Float32Array(3*o),r=new THREE.Color,s=new Float32Array(e),a=new Uint8Array(e),d=0;o>d;d++)i[3*d]=s[4*d],i[3*d+1]=s[4*d+1],i[3*d+2]=s[4*d+2],r.setRGB(a[16*d+12],a[16*d+13],a[16*d+14]),n[3*d]=r.r/255,n[3*d+1]=r.g/255,n[3*d+2]=r.b/255;t.addAttribute("position",new THREE.Float32Attribute(i,3)),t.addAttribute("color",new THREE.Float32Attribute(n,3)),t.boundingBox=this.boundingBox,this.geometry=t,this.loaded=!0,this.loading=!1,this.pcoGeometry.numNodesLoading--},Potree.PointCloudOctreeGeometryNode.prototype.dispose=function(){delete this.geometry,this.loaded=!1},Potree.utils=function(){},Potree.utils.pathExists=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),200!==t.status?!1:!0},Potree.utils.computeTransformedBoundingBox=function(e,t){var o=[new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.min.x,e.max.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.min.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.min.y,e.max.z).applyMatrix4(t),new THREE.Vector3(e.max.x,e.max.y,e.max.z).applyMatrix4(t)],i=new THREE.Box3;return i.setFromPoints(o),i},Potree.utils.addCommas=function(e){e+="",x=e.split("."),x1=x[0],x2=x.length>1?"."+x[1]:"";for(var t=/(\d+)(\d{3})/;t.test(x1);)x1=x1.replace(t,"$1,$2");return x1+x2},Potree.utils.loadSkybox=function(e){var t=new THREE.PerspectiveCamera(75,window.innerWidth/window.innerHeight,1,1e5),o=new THREE.Scene,i=".jpg",n=[e+"px"+i,e+"nx"+i,e+"py"+i,e+"ny"+i,e+"pz"+i,e+"nz"+i],r=THREE.ImageUtils.loadTextureCube(n,new THREE.CubeRefractionMapping),s=new THREE.MeshBasicMaterial({color:16777215,envMap:r,refractionRatio:.95}),a=THREE.ShaderLib.cube;a.uniforms.tCube.value=r;var s=new THREE.ShaderMaterial({fragmentShader:a.fragmentShader,vertexShader:a.vertexShader,uniforms:a.uniforms,depthWrite:!1,side:THREE.BackSide}),d=new THREE.Mesh(new THREE.BoxGeometry(100,100,100),s);return o.add(d),{camera:t,scene:o}},Potree.utils.createGrid=function(e,t,o){for(var i=new THREE.LineBasicMaterial({color:12303291}),n=new THREE.Geometry,r=0;t>=r;r++)n.vertices.push(new THREE.Vector3(-(o*e)/2,0,r*o-o*t/2)),n.vertices.push(new THREE.Vector3(+(o*e)/2,0,r*o-o*t/2));for(var r=0;e>=r;r++)n.vertices.push(new THREE.Vector3(r*o-o*e/2,0,-(o*t)/2)),n.vertices.push(new THREE.Vector3(r*o-o*e/2,0,+(o*t)/2));var s=new THREE.Line(n,i,THREE.LinePieces);return s.receiveShadow=!0,s}; \ No newline at end of file diff --git a/examples/point_picking.html b/examples/point_picking.html index 9b85e773..5dbdfe19 100644 --- a/examples/point_picking.html +++ b/examples/point_picking.html @@ -3,11 +3,7 @@ - - - - - + diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 00000000..d8552a27 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,40 @@ + +var path = require('path'); +var gulp = require('gulp'); + +var concat = require('gulp-concat'); +var size = require('gulp-size'); +var rename = require('gulp-rename'); +var uglify = require('gulp-uglify'); + +var paths = { + potree : [ + "src/Potree.js", + "src/extensions/PerspectiveCamera.js", + "src/extensions/Ray.js", + "src/loader/POCLoader.js", + "src/loader/PointAttributes.js", + "src/FirstPersonControls.js", + "src/LRU.js", + "src/PointCloudOctree.js", + "src/PointCloudOctreeGeometry.js", + "src/utils.js" + ] + +}; + + + + +gulp.task("scripts", function(){ + gulp.src(paths.potree) + .pipe(concat('potree.js')) + .pipe(size({showFiles: true})) + .pipe(gulp.dest('build/js')) + .pipe(rename({suffix: '.min'})) + .pipe(uglify({preserveComments: 'some'})) + .pipe(size({showFiles: true})) + .pipe(gulp.dest('build/js')); + + return; +}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..86a06322 --- /dev/null +++ b/package.json @@ -0,0 +1,21 @@ +{ + "name": "potree", + "private": true, + "version": "0.0.1", + "description": "WebGL point cloud viewer", + "dependencies": { + "gulp": "*", + "gulp-size": "*", + "gulp-concat": "*", + "gulp-uglify": "*", + "gulp-rename": "*" + }, + "author": {}, + "license": "", + "devDependencies": { + "gulp": "~3.5.2", + "gulp-rename": "~1.0.0", + "gulp-concat": "~2.1.7", + "gulp-uglify": "~0.2.1" + } +} \ No newline at end of file