|
@@ -858,6 +858,7 @@ Potree.updateVisibilityStructures = function(pointclouds, camera, areaSize) {
|
|
|
|
|
|
// use close near plane for frustum intersection
|
|
|
let frustumCam = camera.clone();
|
|
|
+ frustumCam.zoom = camera.zoom //add
|
|
|
frustumCam.near = Math.min(camera.near, 0.1);
|
|
|
frustumCam.updateProjectionMatrix();
|
|
|
let proj = camera.projectionMatrix;
|
|
@@ -1177,7 +1178,7 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
let center = sphere.center;
|
|
|
let dd = sphere.center.distanceToSquared(camObjPos);
|
|
|
|
|
|
- let addPow = 0.25 //0-0.5 数字越大近处加载越快。但会造成远处加载慢甚至因pointBudge限制不加载
|
|
|
+ const addPow = 0.25 //0-0.5,正常原本是0. 数字越大近处加载越快。但会造成远处加载慢甚至因pointBudge限制不加载
|
|
|
let distance = Math.pow(dd,0.5+addPow)//Math.sqrt(dd); //提高距离权重,为了提高近处加载速度。 某些场景近处加载慢优化明显,如SS-t-cqCAL6rJ5i
|
|
|
|
|
|
//let attenuateDis = 10;//add
|
|
@@ -1203,12 +1204,18 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
}
|
|
|
} else {
|
|
|
// TODO ortho visibility
|
|
|
- let bb = child.getBoundingBox();
|
|
|
- let distance = child.getBoundingSphere().center.distanceTo(camObjPos); //先加载中间然后四周
|
|
|
- let diagonal = bb.max.clone().sub(bb.min).length();
|
|
|
- //weight = diagonal / distance;
|
|
|
+ //let bb = child.getBoundingBox();
|
|
|
+ let sphere = child.getBoundingSphere();
|
|
|
+ //let diagonal = bb.max.clone().sub(bb.min).length();
|
|
|
+ const reduce = 0 //0-0.5,正常原本是0.
|
|
|
+ if( sphere.radius * /* Math.pow( */camera.zoom/* ,1-reduce) */ < pointcloud.minimumNodePixelSize ){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ let distance = sphere.center.distanceToSquared(camObjPos); //先加载中间然后四周
|
|
|
+ weight = sphere.radius / distance;
|
|
|
|
|
|
- weight = diagonal;
|
|
|
+ //weight = diagonal;
|
|
|
}
|
|
|
|
|
|
priorityQueue.push({pointcloud: element.pointcloud, node: child, parent: node, weight: weight}); //貌似好像二叉堆中子节点和父节点没什么关系,就只是为了方便排序层层遍历
|
|
@@ -1692,21 +1699,20 @@ VolumeTool.prototype.startInsertion = function(args = {}){
|
|
|
}
|
|
|
|
|
|
volume.name = args.name || 'Volume';
|
|
|
-
|
|
|
+ volume.isNew = true
|
|
|
|
|
|
|
|
|
let camera = this.viewer.scene.getActiveCamera();
|
|
|
- let updateScale = ()=>{ //保证在视野中的大小一致:
|
|
|
-
|
|
|
+ let updateScale = ()=>{ //保证在视野中的大小一致:
|
|
|
let w = math.getScaleForConstantSize({
|
|
|
width2d: 300,
|
|
|
camera , position:volume.getWorldPosition(new THREE.Vector3()) ,
|
|
|
resolution: viewer.mainViewport.resolution//2
|
|
|
- })
|
|
|
+ })
|
|
|
/* let wp = volume.getWorldPosition(new THREE.Vector3()).applyMatrix4(camera.matrixWorldInverse);
|
|
|
// let pp = new THREE.Vector4(wp.x, wp.y, wp.z).applyMatrix4(camera.projectionMatrix);
|
|
|
let w = Math.abs((wp.z / 3));*/
|
|
|
- volume.scale.set(w, w, w);
|
|
|
+ if(!isNaN(w))volume.scale.set(w, w, w);
|
|
|
}
|
|
|
|
|
|
this.dispatchEvent({
|
|
@@ -1747,13 +1753,20 @@ VolumeTool.prototype.startInsertion = function(args = {}){
|
|
|
};
|
|
|
|
|
|
let cancel = ()=>{
|
|
|
- end()
|
|
|
+ viewer.scene.removeVolume(volume); //删除没完成的
|
|
|
+ end('remove')
|
|
|
}
|
|
|
- let end = e => {
|
|
|
+ let end = (e) => {
|
|
|
+ if(e != 'remove' && !e.isAtDomElement)return
|
|
|
volume.removeEventListener('drag', drag);
|
|
|
volume.removeEventListener('drop', end);
|
|
|
this.viewer.removeEventListener('cancel_insertions', cancel);
|
|
|
- viewer.transformObject(volume)
|
|
|
+ volume.isNew = false
|
|
|
+ if(e != 'remove'){
|
|
|
+ viewer.transformObject(volume)
|
|
|
+ volume.dispatchEvent('createDone')
|
|
|
+
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
volume.addEventListener('drag', drag);
|
|
@@ -1766,54 +1779,9 @@ VolumeTool.prototype.startInsertion = function(args = {}){
|
|
|
return volume;
|
|
|
}
|
|
|
|
|
|
-VolumeTool.prototype.loadFromData = function(data=[]){
|
|
|
- data.forEach(v=>{
|
|
|
- let volume = new Potree.BoxVolume({clip:true, clipTask:v.clipTask});
|
|
|
- volume.scale.fromArray(v.scale);
|
|
|
- volume.position.fromArray(v.position);
|
|
|
- volume.rotation.fromArray(v.rotation);
|
|
|
- this.viewer.scene.addVolume(volume);
|
|
|
- this.scene.add(volume);
|
|
|
- })
|
|
|
-}
|
|
|
-VolumeTool.prototype.saveClipData = function(){//输出所有的clip volumeBox
|
|
|
- let oldState = !viewer.clipUnabled;
|
|
|
- viewer.setClipState(true)
|
|
|
- let data = viewer.scene.volumes.filter(v=>v.clip && v instanceof Potree.BoxVolume).map(volume=>{
|
|
|
- return {
|
|
|
- clipTask: volume.clipTask,
|
|
|
- position: volume.position.toArray(),
|
|
|
- rotation: volume.rotation.toArray(),
|
|
|
- scale: volume.scale.toArray(),
|
|
|
- }
|
|
|
- })
|
|
|
- console.log(data)
|
|
|
- console.log(JSON.stringify(data))
|
|
|
- viewer.setClipState(oldState)
|
|
|
- return data
|
|
|
-}
|
|
|
-
|
|
|
-LineGeometry.prototype.setPositions = function( array ) {
|
|
|
-
|
|
|
- // converts [ x1, y1, z1, x2, y2, z2, ... ] to pairs format
|
|
|
-
|
|
|
- const length = array.length - 3 > 0 ? array.length - 3 : 0; //xzw改 必须>0
|
|
|
- const points = new Float32Array( 2 * length );
|
|
|
-
|
|
|
- for ( let i = 0; i < length; i += 3 ) {
|
|
|
-
|
|
|
- points[ 2 * i ] = array[ i ];
|
|
|
- points[ 2 * i + 1 ] = array[ i + 1 ];
|
|
|
- points[ 2 * i + 2 ] = array[ i + 2 ];
|
|
|
-
|
|
|
- points[ 2 * i + 3 ] = array[ i + 3 ];
|
|
|
- points[ 2 * i + 4 ] = array[ i + 4 ];
|
|
|
- points[ 2 * i + 5 ] = array[ i + 5 ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- LineSegmentsGeometry.prototype.setPositions.call(this, points );
|
|
|
-
|
|
|
- return this;
|
|
|
-
|
|
|
-}
|
|
|
+LineGeometry.prototype.setPositions = function( array ) { //xzw改成类似LineSegments的多段线 (第二个点和第三个点之间是没有线段的, 所以不用在意线段顺序)
|
|
|
+ const points = new Float32Array( array );
|
|
|
+ LineSegmentsGeometry.prototype.setPositions.call(this, points );
|
|
|
+ return this;
|
|
|
+}
|
|
|
+
|