|
@@ -13,19 +13,21 @@ import {PointAttribute,PointAttributeTypes} from "../loader/PointAttributes.js";
|
|
|
import {ProfileWindow} from "../viewer/profile.js";
|
|
|
import {XHRFactory} from "../XHRFactory.js";
|
|
|
import {ClipTask, ClipMethod} from "../defines.js";
|
|
|
+
|
|
|
+import {VolumeTool} from "../utils/VolumeTool.js";
|
|
|
import {Box3Helper} from "../utils/Box3Helper.js";
|
|
|
import {KeyCodes} from "../KeyCodes.js";
|
|
|
import {HQSplatRenderer} from "../viewer/HQSplatRenderer.js";
|
|
|
import {LRU} from "../LRU.js";
|
|
|
-import {PointCloudMaterial} from '../materials/PointCloudMaterial.js'
|
|
|
+import {ExtendPointCloudMaterial} from '../materials/ExtendPointCloudMaterial.js'
|
|
|
|
|
|
import {PointCloudOctreeGeometry, PointCloudOctreeGeometryNode} from '../PointCloudOctreeGeometry.js'
|
|
|
import {Shaders} from "../../build/shaders/shaders.js";
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+import {LineSegmentsGeometry} from '../../libs/three.js/lines/LineSegmentsGeometry.js'
|
|
|
+import {LineGeometry} from '../../libs/three.js/lines/LineGeometry.js'
|
|
|
KeyCodes.BACKSPACE = 8
|
|
|
|
|
|
-
|
|
|
{//defines:
|
|
|
Potree.defines = {}
|
|
|
Potree.defines.Buttons = {// MouseEvent.buttons
|
|
@@ -121,7 +123,7 @@ KeyCodes.BACKSPACE = 8
|
|
|
VideoRendered: "panorama.video.rendered"
|
|
|
};
|
|
|
|
|
|
-
|
|
|
+ ClipTask.SHOW_INSIDE_Big = 4
|
|
|
}
|
|
|
|
|
|
|
|
@@ -213,9 +215,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
|
|
|
|
|
|
if(viewport){ //转换到类似整个画面时
|
|
|
-
|
|
|
- /*let mouseInViewport = Utils.convertNDCToScreenPosition(pointer, null, viewport.resolution.x, viewport.resolution.y)
|
|
|
-
|
|
|
+ /*let mouseInViewport = Utils.convertNDCToScreenPosition(pointer, null, viewport.resolution.x, viewport.resolution.y)
|
|
|
pickParams.x = mouseInViewport.x //mouse.x / viewport.width;
|
|
|
pickParams.y = mouseInViewport.y //renderer.domElement.clientHeight - mouse.y / viewport.height; */
|
|
|
pickParams.x = mouse.x;
|
|
@@ -226,10 +226,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
}
|
|
|
|
|
|
//console.log('getMousePointCloudIntersection')
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
/* if(!raycaster){
|
|
|
raycaster = new THREE.Raycaster();
|
|
|
raycaster.setFromCamera(pointer, camera);
|
|
@@ -245,9 +242,19 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
let closestPoint = null;
|
|
|
|
|
|
|
|
|
+
|
|
|
+ //-----------add--------------------
|
|
|
+ let old_clipBoxes_in = new Map()
|
|
|
+ let old_clipBoxes_out = new Map()
|
|
|
+ let old_bigClipInBox = new Map()
|
|
|
+
|
|
|
+
|
|
|
+ //bigClipInBox 最好也写下
|
|
|
let density
|
|
|
let sizeType
|
|
|
let size = new Map()
|
|
|
+ let needsUpdate = false;
|
|
|
+
|
|
|
if(pickParams.isMeasuring || Potree.settings.displayMode == 'showPanos'){ //测量或全景模式提高精准度
|
|
|
density = Potree.settings.pointDensity
|
|
|
Potree.settings.pointDensity = 'magnifier'
|
|
@@ -259,16 +266,31 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
|
|
|
e.changePointSize(Potree.config.material.realPointSize*2, true)//更改点云大小到能铺满为止,否则容易识别不到
|
|
|
})
|
|
|
- Potree.updatePointClouds(pointclouds, camera, viewport.resolution );
|
|
|
+ needsUpdate = true
|
|
|
}else{
|
|
|
if(viewer.viewports.filter(e=>!e.noPointcloud && e.active).length>1 || pickParams.cameraChanged){
|
|
|
viewport.beforeRender && viewport.beforeRender()
|
|
|
- Potree.updatePointClouds(pointclouds, camera, viewport.resolution ); //不加这句的话hover久了会不准 因node是错的
|
|
|
+ needsUpdate = true //不updatePointClouds的话hover久了会不准 因node是错的
|
|
|
//但依旧需要camera真的移动到那个位置才能加载出点云
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!pickParams.pickClipped){// 无视clipBoxes
|
|
|
+ for(let pointcloud of pointclouds){
|
|
|
+ old_clipBoxes_in.set(pointcloud, pointcloud.clipBoxes_in)
|
|
|
+ old_clipBoxes_out.set(pointcloud, pointcloud.clipBoxes_in)
|
|
|
+ old_bigClipInBox.set(pointcloud, pointcloud.bigClipInBox)
|
|
|
+ pointcloud.material.setClipBoxes(null, [],[])
|
|
|
}
|
|
|
-
|
|
|
+ needsUpdate = true
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ if(needsUpdate){
|
|
|
+ Potree.updatePointClouds(pointclouds, camera, viewport.resolution );
|
|
|
+ }
|
|
|
+ //------------------------------------------------
|
|
|
+
|
|
|
+
|
|
|
let allPointclouds = []
|
|
|
for(let pointcloud of pointclouds){
|
|
|
|
|
@@ -306,7 +328,11 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
viewport.afterRender && viewport.afterRender()
|
|
|
} */
|
|
|
}
|
|
|
-
|
|
|
+ if(!pickParams.pickClipped){//add
|
|
|
+ for(let pointcloud of pointclouds){
|
|
|
+ pointcloud.material.setClipBoxes(old_bigClipInBox.get(pointcloud), old_clipBoxes_in.get(pointcloud), old_clipBoxes_out.get(pointcloud))
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (selectedPointcloud) {
|
|
|
return {
|
|
@@ -608,7 +634,7 @@ Utils.isInsideBox = function(object, boxMatrixInverse){//object可以是点或
|
|
|
frustum.setFromProjectionMatrix(boxMatrixInverse)
|
|
|
|
|
|
if(object instanceof THREE.Box3){
|
|
|
- return frustum.intersectsSphere(object)
|
|
|
+ return frustum.intersectsBox(object)
|
|
|
}else if(object instanceof Array){//点合集,先求Sphere setFromPoints
|
|
|
let sphere = new THREE.Sphere()
|
|
|
sphere.setFromPoints(object)
|
|
@@ -618,7 +644,7 @@ Utils.isInsideBox = function(object, boxMatrixInverse){//object可以是点或
|
|
|
return frustum.intersectsSphere(object)
|
|
|
}else if(object instanceof THREE.Vector3){
|
|
|
return frustum.containsPoint(object)
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
/* containsPoint: ƒ containsPoint( point )
|
|
|
intersectsBox: ƒ intersectsBox( box )
|
|
@@ -734,7 +760,7 @@ ProfileWindow.prototype.initTHREE = function(){
|
|
|
}
|
|
|
|
|
|
//Potree_update_visibility
|
|
|
-Potree.updatePointClouds = function(pointclouds,camera, areaSize /* renderer */){
|
|
|
+Potree.updatePointClouds = function(pointclouds,camera, areaSize ){
|
|
|
|
|
|
for (let pointcloud of pointclouds) {
|
|
|
let start = performance.now();
|
|
@@ -916,8 +942,110 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
visible = visible && level <= maxLevel; //< 改为 <=
|
|
|
//visible = visible || node.getLevel() <= 2;
|
|
|
|
|
|
- let clipBoxes = pointcloud.material.clipBoxes;
|
|
|
- if(true && clipBoxes.length > 0){
|
|
|
+
|
|
|
+ let insideBox = (clipBox)=>{
|
|
|
+
|
|
|
+ let pcWorldInverse = pointcloud.matrixWorld.clone().invert();
|
|
|
+ let toPCObject = pcWorldInverse.multiply(clipBox.box.matrixWorld);
|
|
|
+
|
|
|
+ let px = new THREE.Vector3(+0.5, 0, 0).applyMatrix4(pcWorldInverse);
|
|
|
+ let nx = new THREE.Vector3(-0.5, 0, 0).applyMatrix4(pcWorldInverse);
|
|
|
+ let py = new THREE.Vector3(0, +0.5, 0).applyMatrix4(pcWorldInverse);
|
|
|
+ let ny = new THREE.Vector3(0, -0.5, 0).applyMatrix4(pcWorldInverse);
|
|
|
+ let pz = new THREE.Vector3(0, 0, +0.5).applyMatrix4(pcWorldInverse);
|
|
|
+ let nz = new THREE.Vector3(0, 0, -0.5).applyMatrix4(pcWorldInverse);
|
|
|
+
|
|
|
+ let pxN = new THREE.Vector3().subVectors(nx, px).normalize();
|
|
|
+ let nxN = pxN.clone().multiplyScalar(-1);
|
|
|
+ let pyN = new THREE.Vector3().subVectors(ny, py).normalize();
|
|
|
+ let nyN = pyN.clone().multiplyScalar(-1);
|
|
|
+ let pzN = new THREE.Vector3().subVectors(nz, pz).normalize();
|
|
|
+ let nzN = pzN.clone().multiplyScalar(-1);
|
|
|
+
|
|
|
+ let pxPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(pxN, px);
|
|
|
+ let nxPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(nxN, nx);
|
|
|
+ let pyPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(pyN, py);
|
|
|
+ let nyPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(nyN, ny);
|
|
|
+ let pzPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(pzN, pz);
|
|
|
+ let nzPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(nzN, nz);
|
|
|
+
|
|
|
+ //if(window.debugdraw !== undefined && window.debugdraw === true && node.name === "r60"){
|
|
|
+
|
|
|
+ // Potree.utils.debugPlane(viewer.scene.scene, pxPlane, 1, 0xFF0000);
|
|
|
+ // Potree.utils.debugPlane(viewer.scene.scene, nxPlane, 1, 0x990000);
|
|
|
+ // Potree.utils.debugPlane(viewer.scene.scene, pyPlane, 1, 0x00FF00);
|
|
|
+ // Potree.utils.debugPlane(viewer.scene.scene, nyPlane, 1, 0x009900);
|
|
|
+ // Potree.utils.debugPlane(viewer.scene.scene, pzPlane, 1, 0x0000FF);
|
|
|
+ // Potree.utils.debugPlane(viewer.scene.scene, nzPlane, 1, 0x000099);
|
|
|
+
|
|
|
+ // Potree.utils.debugBox(viewer.scene.scene, box, new THREE.Matrix4(), 0x00FF00);
|
|
|
+ // Potree.utils.debugBox(viewer.scene.scene, box, pointcloud.matrixWorld, 0xFF0000);
|
|
|
+ // Potree.utils.debugBox(viewer.scene.scene, clipBox.box.boundingBox, clipBox.box.matrixWorld, 0xFF0000);
|
|
|
+
|
|
|
+ // window.debugdraw = false;
|
|
|
+ //}
|
|
|
+
|
|
|
+ let frustum = new THREE.Frustum(pxPlane, nxPlane, pyPlane, nyPlane, pzPlane, nzPlane);
|
|
|
+ let intersects = frustum.intersectsBox(box);
|
|
|
+
|
|
|
+ /* if(intersects){
|
|
|
+ numIntersecting++;
|
|
|
+ }
|
|
|
+ numIntersectionVolumes++;
|
|
|
+ */
|
|
|
+ return !!intersects
|
|
|
+ }
|
|
|
+
|
|
|
+ //改 总共两种box : 可见和不可见(都是并集)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let clipBoxes_in = pointcloud.material.clipBoxes_in;
|
|
|
+ let clipBoxes_out = pointcloud.material.clipBoxes_out;
|
|
|
+ let bigClipInBox = pointcloud.material.bigClipInBox
|
|
|
+
|
|
|
+ if(visible && bigClipInBox){//不在剪裁下载的框内
|
|
|
+ if(!insideBox(bigClipInBox)){
|
|
|
+ visible = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(visible && clipBoxes_in.length > 0){//当有可见box时,需要在任一可见box内才可见
|
|
|
+ let visi = false;
|
|
|
+ for(let i = 0, length=clipBoxes_in.length; i < length; i++){
|
|
|
+ if(insideBox(clipBoxes_in[i])){
|
|
|
+ visi = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!visi){
|
|
|
+ visible = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //outside不做处理。因为node必须完全在clipBox内才能完全隐藏,而这里的intersect只能识别出部分在clipBox内
|
|
|
+ /* if(visible && clipBoxes_out.length > 0){ //当有不可见box时,不在所有不可见box内才可见
|
|
|
+ let visi = true;
|
|
|
+ for(let i = 0,length=clipBoxes_out.length; i < length; i++){
|
|
|
+ if(insideBox(clipBoxes_out[i])){
|
|
|
+ visi = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!visi){
|
|
|
+ visible = false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /*let clipBoxes = pointcloud.material.clipBoxes;
|
|
|
+ if(true && clipBoxes.length > 0){
|
|
|
|
|
|
//node.debug = false;
|
|
|
|
|
@@ -929,54 +1057,6 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
//}
|
|
|
|
|
|
for(let clipBox of clipBoxes){
|
|
|
-
|
|
|
- let pcWorldInverse = pointcloud.matrixWorld.clone().invert();
|
|
|
- let toPCObject = pcWorldInverse.multiply(clipBox.box.matrixWorld);
|
|
|
-
|
|
|
- let px = new THREE.Vector3(+0.5, 0, 0).applyMatrix4(pcWorldInverse);
|
|
|
- let nx = new THREE.Vector3(-0.5, 0, 0).applyMatrix4(pcWorldInverse);
|
|
|
- let py = new THREE.Vector3(0, +0.5, 0).applyMatrix4(pcWorldInverse);
|
|
|
- let ny = new THREE.Vector3(0, -0.5, 0).applyMatrix4(pcWorldInverse);
|
|
|
- let pz = new THREE.Vector3(0, 0, +0.5).applyMatrix4(pcWorldInverse);
|
|
|
- let nz = new THREE.Vector3(0, 0, -0.5).applyMatrix4(pcWorldInverse);
|
|
|
-
|
|
|
- let pxN = new THREE.Vector3().subVectors(nx, px).normalize();
|
|
|
- let nxN = pxN.clone().multiplyScalar(-1);
|
|
|
- let pyN = new THREE.Vector3().subVectors(ny, py).normalize();
|
|
|
- let nyN = pyN.clone().multiplyScalar(-1);
|
|
|
- let pzN = new THREE.Vector3().subVectors(nz, pz).normalize();
|
|
|
- let nzN = pzN.clone().multiplyScalar(-1);
|
|
|
-
|
|
|
- let pxPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(pxN, px);
|
|
|
- let nxPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(nxN, nx);
|
|
|
- let pyPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(pyN, py);
|
|
|
- let nyPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(nyN, ny);
|
|
|
- let pzPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(pzN, pz);
|
|
|
- let nzPlane = new THREE.Plane().setFromNormalAndCoplanarPoint(nzN, nz);
|
|
|
-
|
|
|
- //if(window.debugdraw !== undefined && window.debugdraw === true && node.name === "r60"){
|
|
|
-
|
|
|
- // Potree.utils.debugPlane(viewer.scene.scene, pxPlane, 1, 0xFF0000);
|
|
|
- // Potree.utils.debugPlane(viewer.scene.scene, nxPlane, 1, 0x990000);
|
|
|
- // Potree.utils.debugPlane(viewer.scene.scene, pyPlane, 1, 0x00FF00);
|
|
|
- // Potree.utils.debugPlane(viewer.scene.scene, nyPlane, 1, 0x009900);
|
|
|
- // Potree.utils.debugPlane(viewer.scene.scene, pzPlane, 1, 0x0000FF);
|
|
|
- // Potree.utils.debugPlane(viewer.scene.scene, nzPlane, 1, 0x000099);
|
|
|
-
|
|
|
- // Potree.utils.debugBox(viewer.scene.scene, box, new THREE.Matrix4(), 0x00FF00);
|
|
|
- // Potree.utils.debugBox(viewer.scene.scene, box, pointcloud.matrixWorld, 0xFF0000);
|
|
|
- // Potree.utils.debugBox(viewer.scene.scene, clipBox.box.boundingBox, clipBox.box.matrixWorld, 0xFF0000);
|
|
|
-
|
|
|
- // window.debugdraw = false;
|
|
|
- //}
|
|
|
-
|
|
|
- let frustum = new THREE.Frustum(pxPlane, nxPlane, pyPlane, nyPlane, pzPlane, nzPlane);
|
|
|
- let intersects = frustum.intersectsBox(box);
|
|
|
-
|
|
|
- if(intersects){
|
|
|
- numIntersecting++;
|
|
|
- }
|
|
|
- numIntersectionVolumes++;
|
|
|
}
|
|
|
|
|
|
let insideAny = numIntersecting > 0;
|
|
@@ -1001,9 +1081,9 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
// visible = false;
|
|
|
//}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
// visible = ["r", "r0", "r06", "r060"].includes(node.name);
|
|
|
// visible = ["r"].includes(node.name);
|
|
@@ -1061,7 +1141,7 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
node._transformVersion = transformVersion.number;
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (pointcloud.showBoundingBox && !node.boundingBoxNode && node.getBoundingBox) {
|
|
|
let boxHelper = new Box3Helper(node.getBoundingBox());
|
|
|
boxHelper.matrixAutoUpdate = false;
|
|
@@ -1073,7 +1153,7 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
node.boundingBoxNode.matrix.copy(pointcloud.matrixWorld);
|
|
|
} else if (!pointcloud.showBoundingBox && node.boundingBoxNode) {
|
|
|
node.boundingBoxNode.visible = false;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
// if(node.boundingBoxNode !== undefined && exports.debug.allowedNodes !== undefined){
|
|
|
// if(!exports.debug.allowedNodes.includes(node.name)){
|
|
@@ -1207,12 +1287,12 @@ Potree.updateVisibility = function(pointclouds, camera, areaSize){
|
|
|
originalMaterials.set(pointcloud, pointcloud.material);
|
|
|
|
|
|
if(!this.attributeMaterials.has(pointcloud)){
|
|
|
- let attributeMaterial = new PointCloudMaterial();
|
|
|
+ let attributeMaterial = new ExtendPointCloudMaterial();
|
|
|
this.attributeMaterials.set(pointcloud, attributeMaterial);
|
|
|
}
|
|
|
|
|
|
if(!this.depthMaterials.has(pointcloud)){
|
|
|
- let depthMaterial = new PointCloudMaterial();
|
|
|
+ let depthMaterial = new ExtendPointCloudMaterial();
|
|
|
|
|
|
depthMaterial.setDefine("depth_pass", "#define hq_depth_pass");
|
|
|
depthMaterial.setDefine("use_edl", "#define use_edl");
|
|
@@ -1585,3 +1665,139 @@ LRU.prototype.disposeSubtree = function(t) {//add from navvis 25.js
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+VolumeTool.prototype.update = function(){}
|
|
|
+
|
|
|
+VolumeTool.prototype.startInsertion = function(args = {}){
|
|
|
+
|
|
|
+ let volume;
|
|
|
+ if(args.type){
|
|
|
+ volume = new args.type();
|
|
|
+ }else{
|
|
|
+ volume = new Potree.BoxVolume({clip:args.clip, clipTask:ClipTask.SHOW_OUTSIDE});
|
|
|
+ }
|
|
|
+
|
|
|
+ volume.name = args.name || 'Volume';
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let camera = this.viewer.scene.getActiveCamera();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.dispatchEvent({
|
|
|
+ type: 'start_inserting_volume',
|
|
|
+ volume: volume
|
|
|
+ });
|
|
|
+
|
|
|
+ if(viewer.scene.volumes.length>0){
|
|
|
+ volume.rotation.copy(viewer.scene.volumes[viewer.scene.volumes.length-1].rotation); //使用上一个的旋转值
|
|
|
+ }
|
|
|
+ updateScale()
|
|
|
+ this.viewer.scene.addVolume(volume);
|
|
|
+ this.scene.add(volume);
|
|
|
+ viewer.transformObject(volume)
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let drag = e => {
|
|
|
+
|
|
|
+ let I = Utils.getMousePointCloudIntersection(
|
|
|
+ viewer.mainViewport,
|
|
|
+ viewer.inputHandler.mouse,
|
|
|
+ viewer.inputHandler.pointer,
|
|
|
+ this.viewer.scene.getActiveCamera(),
|
|
|
+ this.viewer,
|
|
|
+ this.viewer.scene.pointclouds,
|
|
|
+ {pickClipped: false} //无视clip状态
|
|
|
+ );
|
|
|
+
|
|
|
+ var worldPos = I && I.location
|
|
|
+ if(!worldPos){
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ volume.position.copy(worldPos);
|
|
|
+
|
|
|
+ updateScale()
|
|
|
+ };
|
|
|
+
|
|
|
+ let cancel = ()=>{
|
|
|
+ end()
|
|
|
+ }
|
|
|
+ let end = e => {
|
|
|
+ volume.removeEventListener('drag', drag);
|
|
|
+ volume.removeEventListener('drop', end);
|
|
|
+ this.viewer.removeEventListener('cancel_insertions', cancel);
|
|
|
+ };
|
|
|
+
|
|
|
+ volume.addEventListener('drag', drag);
|
|
|
+ volume.addEventListener('drop', end);
|
|
|
+
|
|
|
+ this.viewer.addEventListener('cancel_insertions', cancel);
|
|
|
+
|
|
|
+ this.viewer.inputHandler.startDragging(volume);
|
|
|
+
|
|
|
+ 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;
|
|
|
+
|
|
|
+}
|