|
@@ -252,7 +252,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
let old_clipBoxes_in = new Map()
|
|
|
let old_clipBoxes_out = new Map()
|
|
|
let old_bigClipInBox = new Map()
|
|
|
-
|
|
|
+ let old_highlightBoxes = new Map()
|
|
|
|
|
|
//bigClipInBox 最好也写下
|
|
|
let density
|
|
@@ -289,7 +289,8 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
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, [],[])
|
|
|
+ old_highlightBoxes.set(pointcloud, pointcloud.highlightBoxes)
|
|
|
+ pointcloud.material.setClipBoxes(null, [],[],[])
|
|
|
}
|
|
|
needsUpdate = true
|
|
|
}
|
|
@@ -341,7 +342,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
|
|
|
}
|
|
|
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))
|
|
|
+ pointcloud.material.setClipBoxes(old_bigClipInBox.get(pointcloud), old_clipBoxes_in.get(pointcloud), old_clipBoxes_out.get(pointcloud), old_highlightBoxes.get(pointcloud))
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1691,19 +1692,19 @@ VolumeTool.prototype.update = function(){}
|
|
|
|
|
|
VolumeTool.prototype.startInsertion = function(args = {}){
|
|
|
|
|
|
- let volume;
|
|
|
+ let volume;
|
|
|
+ let camera = this.viewer.scene.getActiveCamera();
|
|
|
if(args.type){
|
|
|
volume = new args.type();
|
|
|
}else{
|
|
|
- volume = new Potree.BoxVolume(args/* {clip:args.clip, clipTask:ClipTask.SHOW_OUTSIDE} */);
|
|
|
+ volume = new Potree.BoxVolume(Object.assign(args,{clip:true}) );
|
|
|
}
|
|
|
-
|
|
|
- volume.name = args.name || 'Volume';
|
|
|
+ volume.highlight = true
|
|
|
+ volume.name = args.name || 'Volume-'+args.clipTask;
|
|
|
volume.isNew = true
|
|
|
-
|
|
|
+ viewer.transformObject(null)//先清空
|
|
|
|
|
|
- let camera = this.viewer.scene.getActiveCamera();
|
|
|
- let updateScale = ()=>{ //保证在视野中的大小一致:
|
|
|
+ let updatePose = ()=>{ //保证在视野中的大小一致:
|
|
|
let w = math.getScaleForConstantSize({
|
|
|
width2d: 300,
|
|
|
camera , position:volume.getWorldPosition(new THREE.Vector3()) ,
|
|
@@ -1712,18 +1713,21 @@ VolumeTool.prototype.startInsertion = function(args = {}){
|
|
|
/* 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));*/
|
|
|
- if(!isNaN(w))volume.scale.set(w, w, w);
|
|
|
+ if(!isNaN(w))volume.scale.set(w, w, w);
|
|
|
+
|
|
|
+
|
|
|
+ {//使水平朝向与camera一致
|
|
|
+ let direction = viewer.mainViewport.view.direction.setZ(0)
|
|
|
+ volume.quaternion.copy(math.getQuaByAim(direction))
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
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()
|
|
|
+ });
|
|
|
+ updatePose()
|
|
|
this.viewer.scene.addVolume(volume);
|
|
|
this.scene.add(volume);
|
|
|
|
|
@@ -1749,32 +1753,52 @@ VolumeTool.prototype.startInsertion = function(args = {}){
|
|
|
|
|
|
volume.position.copy(worldPos);
|
|
|
|
|
|
- updateScale()
|
|
|
+ updatePose()
|
|
|
};
|
|
|
+
|
|
|
|
|
|
- let cancel = ()=>{
|
|
|
- viewer.scene.removeVolume(volume); //删除没完成的
|
|
|
- end('remove')
|
|
|
+
|
|
|
+
|
|
|
+ let cancel = ()=>{
|
|
|
+ end('remove')
|
|
|
}
|
|
|
let end = (e) => {
|
|
|
- if(e != 'remove' && !e.isAtDomElement)return
|
|
|
+ if(e.button == THREE.MOUSE.RIGHT && e.pressDistance<=Potree.config.clickMaxDragDis) {//remove
|
|
|
+ e = 'remove'
|
|
|
+ }
|
|
|
+ if(e != 'remove' && (!e.isAtDomElement || e.pressDistance>Potree.config.clickMaxDragDis))return continueDrag()
|
|
|
volume.removeEventListener('drag', drag);
|
|
|
volume.removeEventListener('drop', end);
|
|
|
this.viewer.removeEventListener('cancel_insertions', cancel);
|
|
|
volume.isNew = false
|
|
|
- if(e != 'remove'){
|
|
|
- viewer.transformObject(volume)
|
|
|
- volume.dispatchEvent('createDone')
|
|
|
-
|
|
|
+ viewer.removeEventListener('camera_changed', updatePose)
|
|
|
+ if(e == 'remove'){
|
|
|
+ viewer.scene.removeVolume(volume); //删除没完成的
|
|
|
+ }else{
|
|
|
+ viewer.transformObject(volume)
|
|
|
+ volume.highlight = false
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+ volume.dispatchEvent({type:'createFinish', success:e != 'remove'})
|
|
|
};
|
|
|
+
|
|
|
+ let continueDrag = ( )=>{
|
|
|
+ var timer = setTimeout(()=>{//等 drag=null之后 //右键拖拽结束后需要重新得到drag
|
|
|
+ viewer.inputHandler.startDragging( volume , {notPressMouse:true}
|
|
|
+ /* {endDragFun: e.drag.endDragFun, notPressMouse:e.drag.notPressMouse, dragViewport:e.drag.dragViewport} */
|
|
|
+ )
|
|
|
+ },1)
|
|
|
+ return timer
|
|
|
+ }
|
|
|
|
|
|
volume.addEventListener('drag', drag);
|
|
|
volume.addEventListener('drop', end);
|
|
|
|
|
|
this.viewer.addEventListener('cancel_insertions', cancel);
|
|
|
-
|
|
|
- this.viewer.inputHandler.startDragging(volume);
|
|
|
+ viewer.addEventListener('camera_changed', updatePose)
|
|
|
+
|
|
|
+ this.viewer.inputHandler.startDragging(volume, {notPressMouse:true});
|
|
|
|
|
|
return volume;
|
|
|
}
|