Browse Source

fix: 触屏的sprite大小

xzw 3 years ago
parent
commit
4cf755fb09

+ 44 - 44
libs/three.js/build/three.module.js

@@ -8696,7 +8696,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		if ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;
 		if ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;
 
-		if ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth;
+		if ( this.lineWidth && this.lineWidth !== 1 ) data.lineWidth = this.lineWidth;
 		if ( this.dashSize !== undefined ) data.dashSize = this.dashSize;
 		if ( this.gapSize !== undefined ) data.gapSize = this.gapSize;
 		if ( this.scale !== undefined ) data.scale = this.scale;
@@ -8707,7 +8707,7 @@ Material.prototype = Object.assign( Object.create( EventDispatcher.prototype ),
 		if ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;
 
 		if ( this.wireframe === true ) data.wireframe = this.wireframe;
-		if ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;
+		if ( this.wireframelineWidth > 1 ) data.wireframelineWidth = this.wireframelineWidth;
 		if ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;
 		if ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;
 
@@ -8881,7 +8881,7 @@ Object.defineProperty( Material.prototype, 'needsUpdate', {
  *  depthWrite: <bool>,
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>,
+ *  wireframelineWidth: <float>,
  *
  *  skinning: <bool>,
  *  morphTargets: <bool>
@@ -8914,7 +8914,7 @@ function MeshBasicMaterial( parameters ) {
 	this.refractionRatio = 0.98;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 	this.wireframeLinecap = 'round';
 	this.wireframeLinejoin = 'round';
 
@@ -8954,7 +8954,7 @@ MeshBasicMaterial.prototype.copy = function ( source ) {
 	this.refractionRatio = source.refractionRatio;
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 	this.wireframeLinecap = source.wireframeLinecap;
 	this.wireframeLinejoin = source.wireframeLinejoin;
 
@@ -11700,7 +11700,7 @@ var default_fragment = "void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0
  *  vertexShader: <string>,
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>,
+ *  wireframelineWidth: <float>,
  *
  *  lights: <bool>,
  *
@@ -11722,10 +11722,10 @@ function ShaderMaterial( parameters ) {
 	this.vertexShader = default_vertex;
 	this.fragmentShader = default_fragment;
 
-	this.linewidth = 1;
+	this.lineWidth = 1;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 
 	this.fog = false; // set to use scene fog
 	this.lights = false; // set to use scene lights
@@ -11786,7 +11786,7 @@ ShaderMaterial.prototype.copy = function ( source ) {
 	this.defines = Object.assign( {}, source.defines );
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 
 	this.lights = source.lights;
 	this.clipping = source.clipping;
@@ -18877,7 +18877,7 @@ function WebGLRenderStates( extensions, capabilities ) {
  *  displacementBias: <float>,
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>
+ *  wireframelineWidth: <float>
  * }
  */
 
@@ -18901,7 +18901,7 @@ function MeshDepthMaterial( parameters ) {
 	this.displacementBias = 0;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 
 	this.fog = false;
 
@@ -18932,7 +18932,7 @@ MeshDepthMaterial.prototype.copy = function ( source ) {
 	this.displacementBias = source.displacementBias;
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 
 	return this;
 
@@ -19377,8 +19377,8 @@ function WebGLShadowMap( _renderer, _objects, maxTextureSize ) {
 		result.clippingPlanes = material.clippingPlanes;
 		result.clipIntersection = material.clipIntersection;
 
-		result.wireframeLinewidth = material.wireframeLinewidth;
-		result.linewidth = material.linewidth;
+		result.wireframelineWidth = material.wireframelineWidth;
+		result.lineWidth = material.lineWidth;
 
 		if ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {
 
@@ -19780,7 +19780,7 @@ function WebGLState( gl, extensions, capabilities ) {
 	let currentFlipSided = null;
 	let currentCullFace = null;
 
-	let currentLineWidth = null;
+	let currentlineWidth = null;
 
 	let currentPolygonOffsetFactor = null;
 	let currentPolygonOffsetUnits = null;
@@ -20149,13 +20149,13 @@ function WebGLState( gl, extensions, capabilities ) {
 
 	}
 
-	function setLineWidth( width ) {
+	function setlineWidth( width ) {
 
-		if ( width !== currentLineWidth ) {
+		if ( width !== currentlineWidth ) {
 
 			if ( lineWidthAvailable ) gl.lineWidth( width );
 
-			currentLineWidth = width;
+			currentlineWidth = width;
 
 		}
 
@@ -20346,7 +20346,7 @@ function WebGLState( gl, extensions, capabilities ) {
 		currentFlipSided = null;
 		currentCullFace = null;
 
-		currentLineWidth = null;
+		currentlineWidth = null;
 
 		currentPolygonOffsetFactor = null;
 		currentPolygonOffsetUnits = null;
@@ -20376,7 +20376,7 @@ function WebGLState( gl, extensions, capabilities ) {
 		setFlipSided: setFlipSided,
 		setCullFace: setCullFace,
 
-		setLineWidth: setLineWidth,
+		setlineWidth: setlineWidth,
 		setPolygonOffset: setPolygonOffset,
 
 		setScissorTest: setScissorTest,
@@ -24102,7 +24102,7 @@ function WebGLRenderer( parameters ) {
 
 			if ( material.wireframe === true ) {
 
-				state.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );
+				state.setlineWidth( material.wireframelineWidth * getTargetPixelRatio() );
 				renderer.setMode( 1 );
 
 			} else {
@@ -24113,11 +24113,11 @@ function WebGLRenderer( parameters ) {
 
 		} else if ( object.isLine ) {
 
-			let lineWidth = material.linewidth;
+			let lineWidth = material.lineWidth;
 
 			if ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material
 
-			state.setLineWidth( lineWidth * getTargetPixelRatio() );
+			state.setlineWidth( lineWidth * getTargetPixelRatio() );
 
 			if ( object.isLineSegments ) {
 
@@ -26784,7 +26784,7 @@ InstancedMesh.prototype = Object.assign( Object.create( Mesh.prototype ), {
  *  color: <hex>,
  *  opacity: <float>,
  *
- *  linewidth: <float>,
+ *  lineWidth: <float>,
  *  linecap: "round",
  *  linejoin: "round"
  * }
@@ -26798,7 +26798,7 @@ function LineBasicMaterial( parameters ) {
 
 	this.color = new Color( 0xffffff );
 
-	this.linewidth = 1;
+	this.lineWidth = 1;
 	this.linecap = 'round';
 	this.linejoin = 'round';
 
@@ -26819,7 +26819,7 @@ LineBasicMaterial.prototype.copy = function ( source ) {
 
 	this.color.copy( source.color );
 
-	this.linewidth = source.linewidth;
+	this.lineWidth = source.lineWidth;
 	this.linecap = source.linecap;
 	this.linejoin = source.linejoin;
 
@@ -33485,7 +33485,7 @@ RawShaderMaterial.prototype.isRawShaderMaterial = true;
  *  refractionRatio: <float>,
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>,
+ *  wireframelineWidth: <float>,
  *
  *  skinning: <bool>,
  *  morphTargets: <bool>,
@@ -33540,7 +33540,7 @@ function MeshStandardMaterial( parameters ) {
 	this.refractionRatio = 0.98;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 	this.wireframeLinecap = 'round';
 	this.wireframeLinejoin = 'round';
 
@@ -33604,7 +33604,7 @@ MeshStandardMaterial.prototype.copy = function ( source ) {
 	this.refractionRatio = source.refractionRatio;
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 	this.wireframeLinecap = source.wireframeLinecap;
 	this.wireframeLinejoin = source.wireframeLinejoin;
 
@@ -33763,7 +33763,7 @@ MeshPhysicalMaterial.prototype.copy = function ( source ) {
  *  refractionRatio: <float>,
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>,
+ *  wireframelineWidth: <float>,
  *
  *  skinning: <bool>,
  *  morphTargets: <bool>,
@@ -33814,7 +33814,7 @@ function MeshPhongMaterial( parameters ) {
 	this.refractionRatio = 0.98;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 	this.wireframeLinecap = 'round';
 	this.wireframeLinejoin = 'round';
 
@@ -33872,7 +33872,7 @@ MeshPhongMaterial.prototype.copy = function ( source ) {
 	this.refractionRatio = source.refractionRatio;
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 	this.wireframeLinecap = source.wireframeLinecap;
 	this.wireframeLinejoin = source.wireframeLinejoin;
 
@@ -33915,7 +33915,7 @@ MeshPhongMaterial.prototype.copy = function ( source ) {
  *  alphaMap: new THREE.Texture( <Image> ),
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>,
+ *  wireframelineWidth: <float>,
  *
  *  skinning: <bool>,
  *  morphTargets: <bool>,
@@ -33960,7 +33960,7 @@ function MeshToonMaterial( parameters ) {
 	this.alphaMap = null;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 	this.wireframeLinecap = 'round';
 	this.wireframeLinejoin = 'round';
 
@@ -34010,7 +34010,7 @@ MeshToonMaterial.prototype.copy = function ( source ) {
 	this.alphaMap = source.alphaMap;
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 	this.wireframeLinecap = source.wireframeLinecap;
 	this.wireframeLinejoin = source.wireframeLinejoin;
 
@@ -34038,7 +34038,7 @@ MeshToonMaterial.prototype.copy = function ( source ) {
  *  displacementBias: <float>,
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>
+ *  wireframelineWidth: <float>
  *
  *  skinning: <bool>,
  *  morphTargets: <bool>,
@@ -34064,7 +34064,7 @@ function MeshNormalMaterial( parameters ) {
 	this.displacementBias = 0;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 
 	this.fog = false;
 
@@ -34097,7 +34097,7 @@ MeshNormalMaterial.prototype.copy = function ( source ) {
 	this.displacementBias = source.displacementBias;
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 
 	this.skinning = source.skinning;
 	this.morphTargets = source.morphTargets;
@@ -34134,7 +34134,7 @@ MeshNormalMaterial.prototype.copy = function ( source ) {
  *  refractionRatio: <float>,
  *
  *  wireframe: <boolean>,
- *  wireframeLinewidth: <float>,
+ *  wireframelineWidth: <float>,
  *
  *  skinning: <bool>,
  *  morphTargets: <bool>,
@@ -34172,7 +34172,7 @@ function MeshLambertMaterial( parameters ) {
 	this.refractionRatio = 0.98;
 
 	this.wireframe = false;
-	this.wireframeLinewidth = 1;
+	this.wireframelineWidth = 1;
 	this.wireframeLinecap = 'round';
 	this.wireframeLinejoin = 'round';
 
@@ -34217,7 +34217,7 @@ MeshLambertMaterial.prototype.copy = function ( source ) {
 	this.refractionRatio = source.refractionRatio;
 
 	this.wireframe = source.wireframe;
-	this.wireframeLinewidth = source.wireframeLinewidth;
+	this.wireframelineWidth = source.wireframelineWidth;
 	this.wireframeLinecap = source.wireframeLinecap;
 	this.wireframeLinejoin = source.wireframeLinejoin;
 
@@ -34335,7 +34335,7 @@ MeshMatcapMaterial.prototype.copy = function ( source ) {
  *  color: <hex>,
  *  opacity: <float>,
  *
- *  linewidth: <float>,
+ *  lineWidth: <float>,
  *
  *  scale: <float>,
  *  dashSize: <float>,
@@ -40379,13 +40379,13 @@ MaterialLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
 		if ( json.stencilZPass !== undefined ) material.stencilZPass = json.stencilZPass;
 
 		if ( json.wireframe !== undefined ) material.wireframe = json.wireframe;
-		if ( json.wireframeLinewidth !== undefined ) material.wireframeLinewidth = json.wireframeLinewidth;
+		if ( json.wireframelineWidth !== undefined ) material.wireframelineWidth = json.wireframelineWidth;
 		if ( json.wireframeLinecap !== undefined ) material.wireframeLinecap = json.wireframeLinecap;
 		if ( json.wireframeLinejoin !== undefined ) material.wireframeLinejoin = json.wireframeLinejoin;
 
 		if ( json.rotation !== undefined ) material.rotation = json.rotation;
 
-		if ( json.linewidth !== 1 ) material.linewidth = json.linewidth;
+		if ( json.lineWidth !== 1 ) material.lineWidth = json.lineWidth;
 		if ( json.dashSize !== undefined ) material.dashSize = json.dashSize;
 		if ( json.gapSize !== undefined ) material.gapSize = json.gapSize;
 		if ( json.scale !== undefined ) material.scale = json.scale;

+ 12 - 12
libs/three.js/lines/LineMaterial.js

@@ -9,7 +9,7 @@ import {
 /**
  * parameters = {
  *  color: <hex>,
- *  linewidth: <float>,
+ *  lineWidth: <float>,
  *  dashed: <boolean>,
  *  dashScale: <float>,
  *  dashSize: <float>,
@@ -21,7 +21,7 @@ import {
 
 UniformsLib.line = {
   
-	linewidth: { value: 1 },
+	lineWidth: { value: 1 },
 	resolution: { value: new Vector2( 1, 1 ) },
     viewportOffset: { value: new Vector2(0, 0 ) }, //left, top    
 	dashScale: { value: 1 },
@@ -51,7 +51,7 @@ ShaderLib[ 'line' ] = {
 		#include <logdepthbuf_pars_vertex>
 		#include <clipping_planes_pars_vertex>
 
-		uniform float linewidth;
+		uniform float lineWidth;
 		uniform vec2 resolution;
 
 		attribute vec3 instanceStart;
@@ -167,8 +167,8 @@ ShaderLib[ 'line' ] = {
 
 			}
 
-			// adjust for linewidth
-			offset *= linewidth;
+			// adjust for lineWidth
+			offset *= lineWidth;
 
 			// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
 			offset /= resolution.y;
@@ -346,7 +346,7 @@ var LineMaterial = function ( parameters ) {
 	} );
 
 	this.dashed = false;
-    
+    this.lineWidth_ = 0
     
 
 
@@ -433,20 +433,20 @@ var LineMaterial = function ( parameters ) {
 
 		},
 
-		linewidth: {
+		lineWidth: {
 
 			enumerable: true,
 
 			get: function () {
 
-				return this.uniforms.linewidth.value;
+				return this.lineWidth_;//this.uniforms.lineWidth.value;
 
 			},
 
 			set: function ( value ) {
-
-				this.uniforms.linewidth.value = value;
-
+ 
+				this.uniforms.lineWidth.value = value * window.devicePixelRatio;
+                this.lineWidth_ = value
 			}
 
 		},
@@ -576,7 +576,7 @@ var LineMaterial = function ( parameters ) {
         let viewportOffset = viewport.offset || new Vector2() 
         this.uniforms.resolution.value.copy(viewport.resolution2) 
         this.uniforms.viewportOffset.value.copy(viewportOffset) 
-         
+        this.lineWidth = this.lineWidth_
     }
     
     let viewport = viewer.mainViewport;

+ 1 - 1
libs/three.js/lines/LineSegments2.js

@@ -90,7 +90,7 @@ LineSegments2.prototype = Object.assign( Object.create( Mesh.prototype ), {
 			var geometry = this.geometry;
 			var material = this.material;
 			var resolution = material.resolution;
-			var lineWidth = material.linewidth + threshold;
+			var lineWidth = material.lineWidth + threshold;
 
 			var instanceStart = geometry.attributes.instanceStart;
 			var instanceEnd = geometry.attributes.instanceEnd;

+ 16 - 2
note笔记笔记笔记.txt

@@ -158,10 +158,24 @@ Bug	|
 
 
 
+
+
+
+检查四倍放大的闪退。手机
+
+
+
+
+
 为了适应触屏,测量估计要改成和navvis一样,没完成前不闭合,点击到开始点时才闭合。
+否则移动端得加一个结束按钮
 
-测量的在点击时也要计算,而非dragChange
 
 
 
-检查四倍放大的闪退。手机
+测量时的拖拽画面
+
+
+getScaleForConstantSize 使用resolution吧,否则手机会变小。
+
+ 

+ 1 - 1
src/loader/GeoPackageLoader.js

@@ -100,7 +100,7 @@ export class GeoPackageLoader{
 
 				const matLine = new LineMaterial( {
 					color: new THREE.Color().setRGB(...getColor(table)),
-					linewidth: 2, 
+					lineWidth: 2, 
 					resolution:  new THREE.Vector2(1000, 1000),
 					dashed: false
 				} );

+ 1 - 1
src/loader/ShapefileLoader.js

@@ -14,7 +14,7 @@ export class ShapefileLoader{
 
 		const matLine = new LineMaterial( {
 			color: 0xff0000,
-			linewidth: 3, // in pixels
+			lineWidth: 3, // in pixels
 			resolution:  new THREE.Vector2(1000, 1000),
 			dashed: false
 		} );

+ 3 - 3
src/modules/CameraAnimation/CameraAnimation.js

@@ -241,7 +241,7 @@ export class CameraAnimation extends EventDispatcher{
 				color: 0x00ff00, 
 				dashSize: 5, 
 				gapSize: 2,
-				linewidth: 2, 
+				lineWidth: 2, 
 				resolution:  new THREE.Vector2(1000, 1000),
 			});
 
@@ -258,7 +258,7 @@ export class CameraAnimation extends EventDispatcher{
 				color: 0x0000ff, 
 				dashSize: 5, 
 				gapSize: 2,
-				linewidth: 2, 
+				lineWidth: 2, 
 				resolution:  new THREE.Vector2(1000, 1000),
 			});
 
@@ -307,7 +307,7 @@ export class CameraAnimation extends EventDispatcher{
 
 		let material = new LineMaterial({ 
 			color: 0xff0000, 
-			linewidth: 2, 
+			lineWidth: 2, 
 			resolution:  new THREE.Vector2(1000, 1000),
 		});
 

+ 2 - 1
src/navigation/FirstPersonControls.js

@@ -365,6 +365,7 @@ export class FirstPersonControls extends EventDispatcher {
         }
         let prepareRotate = (e)=>{ 
             this.pointerDragStart = e.pointer.clone() 
+            console.log('prepareRotate')
         }
         let preparePan = (e)=>{//触屏的pan点云    还是会偏移
             
@@ -381,7 +382,7 @@ export class FirstPersonControls extends EventDispatcher {
             console.log('preparePan '   )
         }
         
-        this.viewer.addEventListener('startDragging', (e)=>{
+        this.viewer.addEventListener('global_mousedown'/* 'startDragging' */, (e)=>{
             this.setCurrentViewport(e)
             prepareRotate(e)
         })

+ 115 - 94
src/navigation/InputHandler.js

@@ -319,12 +319,23 @@ export class InputHandler extends EventDispatcher {
         
         if(isTouch){
             var  {  camera, viewport  } = this.updateTouchesInfo(e) 
+             
         }else{
             var  {  camera, viewport  } = this.getPointerInViewport(x, y ) 
         }
         
         
 		this.hoverViewport = viewport
+        
+        
+        if(isTouch){ 
+            this.hoveredElements = this.getHoveredElements(); 
+              
+            let intersectPoint = this.getIntersect(viewport,camera)
+            
+            
+        }
+        
         if(!viewport)return 
     
 		
@@ -333,14 +344,15 @@ export class InputHandler extends EventDispatcher {
         
 		let consumed = false;
 		let consume = () => { return consumed = true; };
-		if (this.hoveredElements.length === 0) {
-			this.viewer.dispatchEvent({
-                type: 'global_mousedown',
-                viewer: this.viewer,
-                mouse: this.mouse
-            });
+		//if (this.hoveredElements.length === 0) {
+			this.viewer.dispatchEvent($.extend(  
+                this.getEventDesc(e,isTouch),
+                    {
+                        type: 'global_mousedown' 
+                    } 
+            ));
 			
-		}else{
+		 
 			for(let hovered of this.hoveredElements){
 				let object = hovered.object;
 				object.dispatchEvent({
@@ -353,7 +365,7 @@ export class InputHandler extends EventDispatcher {
 					break;
 				}
 			}
-		}
+		 
 
 
         
@@ -401,6 +413,7 @@ export class InputHandler extends EventDispatcher {
             dragViewport : this.dragViewport,
             hoverViewport: this.hoverViewport,
            // button: isTouch ? 0 : e.button,
+            intersectPoint:this.intersectPoint,
             isTouch,
         }
         if(e){
@@ -619,6 +632,61 @@ export class InputHandler extends EventDispatcher {
         }
     }
 
+    getIntersect(viewport,camera,onlyGetIntersect){
+        //add
+        let intersectPoint = viewport.noPointcloud? null : Utils.getMousePointCloudIntersection(
+            viewport,
+            this.mouse,
+            this.pointer, 
+            camera, 
+            this.viewer, 
+            this.viewer.scene.pointclouds,
+            {pickClipped: true});
+            
+          
+        if(viewport.camera.type == 'OrthographicCamera'/*  == 'mapViewport' */){ 
+            let pos3d = new THREE.Vector3(this.pointer.x,this.pointer.y,-1).unproject(viewport.camera); //z:-1朝外   
+            pos3d.setZ(viewer.bound.boundingBox.min.z + 0.2) //大概放地面上
+            if(!intersectPoint){
+                intersectPoint = {}
+            }   
+            intersectPoint.orthoIntersect = pos3d.clone() 
+        } 
+        if(onlyGetIntersect){ 
+            return intersectPoint
+        }
+        
+        if (intersectPoint) { 
+            
+            
+            if(viewer.showCoordType){ //显示坐标位置时
+                let pos = intersectPoint.point.position.toArray()
+                if(viewer.showCoordType == "local"){
+                     
+                }else if(viewer.showCoordType == "lonlat"){
+                    pos = viewer.transform.lonlatToLocal.inverse(pos)
+                }else{
+                    pos = viewer.transform.lonlatToLocal.inverse(pos)
+                    pos = viewer.transform.lonlatTo4550.forward(pos)
+                    
+                }
+                 
+                viewer.dispatchEvent({
+                    type : "coordinateChange", pos
+                })
+            }  
+        }
+        
+        
+        this.intersectPoint = intersectPoint 
+         
+        intersectPoint && (this.hoverViewport.lastIntersect = intersectPoint)
+         
+        return intersectPoint         
+    }
+    
+    
+    
     
     
     onMouseMove (e) { 
@@ -642,27 +710,7 @@ export class InputHandler extends EventDispatcher {
 			let names = hoveredElements.map(h => h.object.name).join(", ");
 			if (this.logMessages) console.log(`${this.constructor.name}: onMouseMove; hovered: '${names}'`);
 		}
-         
-        //add
-        let intersectPoint = viewport.noPointcloud? null : Utils.getMousePointCloudIntersection(
-            viewport,
-            this.mouse,
-            this.pointer, 
-            camera, 
-            this.viewer, 
-            this.viewer.scene.pointclouds,
-            {pickClipped: true});
-            
-          
-        if(viewport.camera.type == 'OrthographicCamera'/*  == 'mapViewport' */){ 
-            let pos3d = new THREE.Vector3(this.pointer.x,this.pointer.y,-1).unproject(viewport.camera); //z:-1朝外   
-            pos3d.setZ(viewer.bound.boundingBox.min.z + 0.2) //大概放地面上
-            if(!intersectPoint){
-                intersectPoint = {}
-            }   
-            intersectPoint.orthoIntersect = pos3d.clone()
-               
-        }    
+        let intersectPoint = this.getIntersect(viewport,camera,e.onlyGetIntersect)
         if(e.onlyGetIntersect){ 
             return intersectPoint
         }
@@ -676,14 +724,13 @@ export class InputHandler extends EventDispatcher {
 			this.drag.end.copy(this.pointer)
             
             
-			if (this.drag.object && (e.buttons == Buttons.NONE || !this.drag.notPressMouse )){//add notPressMouse 如果标记是不需要按鼠标的拖拽,则一旦按下鼠标,就暂停拖拽物体(改为拖拽场景):(如添加测量时突然拖拽画面)
+			if (this.drag.object && (e.buttons == Buttons.NONE || !this.drag.notPressMouse )){//如果是本不需要按鼠标的拖拽,但按下了鼠标,就不执行这段(改为拖拽场景,如添加测量时突然拖拽画面)
 				if (this.logMessages) console.log(this.constructor.name + ': drag: ' + this.drag.object.name);
 				
                 this.drag.object.dispatchEvent($.extend(  
 					this.getEventDesc(e,isTouch),
                     {
-                        type: 'drag',
-                        intersectPoint,
+                        type: 'drag',  //拖拽物体
                     }
                 ))
                 
@@ -697,17 +744,19 @@ export class InputHandler extends EventDispatcher {
 
 				let dragConsumed = false; 
 				this.viewer.dispatchEvent($.extend(  
-					this.getEventDesc(e,isTouch),
+					this.getEventDesc(e,isTouch),   
                     {
-                        type: 'global_drag',
-                        intersectPoint,
+                        type: 'global_drag',        //拖拽画面
                         consume: () => {dragConsumed = true;}
                     }
                 ))
                  
 				
 			}
-		}else{
+		} 
+        
+        if(!this.drag || this.drag.notPressMouse ){
+         
 			let curr = hoveredElements.map(a => a.object).find(a => true);
 			let prev = this.hoveredElements.map(a => a.object).find(a => true);
 
@@ -741,75 +790,47 @@ export class InputHandler extends EventDispatcher {
 				}
 			}
 
-            //仅在鼠标不按下时更新:
-            {
-                let handleState = viewer.modules.Alignment.handleState
-                if(viewport.alignment && handleState && viewport.alignment[handleState]){
-                    if(handleState == 'translate'){
-                        if( intersectPoint && intersectPoint.location ){ 
-                            viewer.dispatchEvent({
-                                type : "CursorChange", action : "add",  name:"movePointcloud"
-                            })
-                        }else{
-                            viewer.dispatchEvent({
-                                type : "CursorChange", action : "remove",  name:"movePointcloud"
-                            })
-                        }
-                    }else if(handleState == 'rotate'){ 
-                        if( intersectPoint && intersectPoint.location ){ 
-                            viewer.dispatchEvent({
-                                type : "CursorChange", action : "add",  name:"rotatePointcloud"
-                            })
-                        }else{
-                            viewer.dispatchEvent({
-                                type : "CursorChange", action : "remove",  name:"rotatePointcloud"
-                            })
-                        }
-                    }  
-                }
-            }
-            
+        }
 
-                
-            
+        //仅在鼠标不按下时更新:
+        if(!this.drag){
+            let handleState = viewer.modules.Alignment.handleState
+            if(viewport.alignment && handleState && viewport.alignment[handleState]){
+                if(handleState == 'translate'){
+                    if( intersectPoint && intersectPoint.location ){ 
+                        viewer.dispatchEvent({
+                            type : "CursorChange", action : "add",  name:"movePointcloud"
+                        })
+                    }else{
+                        viewer.dispatchEvent({
+                            type : "CursorChange", action : "remove",  name:"movePointcloud"
+                        })
+                    }
+                }else if(handleState == 'rotate'){ 
+                    if( intersectPoint && intersectPoint.location ){ 
+                        viewer.dispatchEvent({
+                            type : "CursorChange", action : "add",  name:"rotatePointcloud"
+                        })
+                    }else{
+                        viewer.dispatchEvent({
+                            type : "CursorChange", action : "remove",  name:"rotatePointcloud"
+                        })
+                    }
+                }  
+            }
+        } 
             
-		}
+		 
         
          
         
-		if (intersectPoint) { 
-            
-            
-            if(viewer.showCoordType){ //显示坐标位置时
-                let pos = intersectPoint.point.position.toArray()
-                if(viewer.showCoordType == "local"){
-                     
-                }else if(viewer.showCoordType == "lonlat"){
-                    pos = viewer.transform.lonlatToLocal.inverse(pos)
-                }else{
-                    pos = viewer.transform.lonlatToLocal.inverse(pos)
-                    pos = viewer.transform.lonlatTo4550.forward(pos)
-                    
-                }
-                 
-                viewer.dispatchEvent({
-                    type : "coordinateChange", pos
-                })
-            }  
-        }
-        
-        
-        this.intersectPoint = intersectPoint 
-        
-        
-        intersectPoint && (this.hoverViewport.lastIntersect = intersectPoint)
+		
         
         
         this.viewer.dispatchEvent($.extend(  
             this.getEventDesc(e,isTouch),
             {
                 type: 'global_mousemove',
-                intersectPoint,
                 
             }
         ))

+ 15 - 7
src/navigation/Reticule.js

@@ -33,6 +33,10 @@ export default class Reticule extends THREE.Mesh{
 
         //viewer.inputHandler.addInputListener(this);
         viewer.addEventListener('global_mousemove',this.move.bind(this))
+        //viewer.addEventListener('global_click',this.move.bind(this))
+        viewer.addEventListener('global_mousedown',this.move.bind(this))//主要针对触屏
+        
+        
         
         viewer.addEventListener('measureMovePoint',()=>{
             this.material.map = crosshairTex
@@ -47,13 +51,17 @@ export default class Reticule extends THREE.Mesh{
         viewer.setObjectLayers(this, 'reticule' )
     }
 
-    move(e){
-        if(e.buttons == Buttons.NONE || this.state == 'crosshair' ){//按下时不更新,除非拖拽测量
-            this.hidden = false,
-            this.mouseLastMoveTime = Date.now()
-            
-            this.updatePosition(e.intersectPoint, e.hoverViewport)
-        }
+    move(e){ 
+    
+        if(e.type == "global_mousemove" && (e.isTouch || e.buttons != Buttons.NONE) && this.state != 'crosshair')
+            return//按下时不更新,除非拖拽测量
+    
+        
+        this.hidden = false 
+        this.mouseLastMoveTime = Date.now()
+        
+        this.updatePosition(e.intersectPoint, e.hoverViewport)
+         
     }
 
     hide(){

+ 2 - 2
src/navigation/VRControls.js

@@ -336,7 +336,7 @@ export class VRControls extends EventDispatcher{
 
 				let lineMaterial = new LineMaterial({ 
 					color: 0xff0000, 
-					linewidth: 2, 
+					lineWidth: 2, 
 					resolution:  new THREE.Vector2(1000, 1000),
 				});
 
@@ -387,7 +387,7 @@ export class VRControls extends EventDispatcher{
 
 				let lineMaterial = new LineMaterial({ 
 					color: 0xff0000, 
-					linewidth: 2, 
+					lineWidth: 2, 
 					resolution:  new THREE.Vector2(1000, 1000),
 				});
 

+ 2 - 2
src/utils/DrawUtil.js

@@ -16,7 +16,7 @@ var LineDraw = {
 	createLine: function (posArr, o={}) {
         //多段普通线  (第二个点和第三个点之间是没有线段的, 所以不用在意线段顺序)
         var mat = o.mat || new THREE[o.deshed ? "LineDashedMaterial" : "LineBasicMaterial"]({
-			linewidth: o.linewidth || 1,
+			lineWidth: o.lineWidth || 1,
 			//windows无效。 似乎mac/ios上粗细有效 ? 
 			color: o.color || defaultColor,
 			transparent: o.dontAlwaysSeen ? false : true,
@@ -112,7 +112,7 @@ var LineDraw = {
 	createFatLineMat : function(o){ 
 		var mat = new LineMaterial( { 
 			color: o.color || 0xffffff,
-			linewidth: o.linewidth || 5, // in pixels
+			lineWidth: o.lineWidth || 5, // in pixels
 			//vertexColors: THREE.VertexColors,//THREE.VertexColors,
 			resolution:  o.resolution || new THREE.Vector2(100,100),// to be set by renderer, eventually
 			//viewportOffset:  o.viewportOffset,

+ 7 - 2
src/utils/Magnifier.js

@@ -105,14 +105,19 @@ export default class Magnifier extends THREE.Object3D {//放大镜or望远镜
             this.dontRender = false
         })
         
-        viewer.addEventListener('global_mousemove', (e)=>{
+        var updateVisi = (e)=>{
             if(e.hoverViewport == viewer.mainViewport){
                 viewer.updateVisible(this,"atViewport", true)
                 this.update(e.intersectPoint && e.intersectPoint.location)
             }else{
                 viewer.updateVisible(this,"atViewport", false) //小地图不显示
             }
-        })
+            
+        }
+        
+        viewer.addEventListener('global_mousemove', updateVisi)
+        viewer.addEventListener('global_touchstart', updateVisi)
+      
         
         
         

+ 23 - 20
src/utils/Measure.js

@@ -208,7 +208,7 @@ export class Measure extends ctrlPolygon{
             if(this.showDistances){ // edge labels
                 let edgeLabel = this.edgeLabels[index];
                 let distance = point.distanceTo(nextPoint)
-                edgeLabel.shouldVisi = (index < lastIndex || this.closed && this.points.length > 2) && distance>0 
+                edgeLabel.shouldVisi = (index < lastIndex || this.isRect || this.closed && !this.isNew /* && this.points.length > 2 */) && distance>0 
                 /* this.closed || */edgeLabel.setVisible(edgeLabel.shouldVisi)  
                 if(edgeLabel.visible){
                     setEdgeLabel(edgeLabel,point,nextPoint,distance)
@@ -261,12 +261,21 @@ export class Measure extends ctrlPolygon{
         } 
              
          
-		  
+		
 	};
 
  
-  
+    addHoverEvent(){ //当非isNew时才添加事件
+        super.addHoverEvent()
+        this.edges.forEach(edge=>{ 
+            let mouseover = (e) => {this.setSelected(true, 'edge')};
+			let mouseleave = (e) => {this.setSelected(false, 'edge')};
 
+			 
+			edge.addEventListener('mouseover', mouseover);
+			edge.addEventListener('mouseleave', mouseleave);
+        }) 
+    }
 
 	addMarker (o={}) {
          
@@ -284,13 +293,7 @@ export class Measure extends ctrlPolygon{
 			],{material:this.getLineMat('edgeDefault')} ) 
             viewer.setObjectLayers(edge, 'measure' ) 
             
-            //----
-            let mouseover = (e) => {this.setSelected(true, 'edge')};
-			let mouseleave = (e) => {this.setSelected(false, 'edge')};
-
-			 
-			edge.addEventListener('mouseover', mouseover);
-			edge.addEventListener('mouseleave', mouseleave);
+            
              
             
             
@@ -331,7 +334,7 @@ export class Measure extends ctrlPolygon{
 		this.dispatchEvent(event);
 
 		//this.setMarker(this.points.length - 1, point);
-        
+        this.update()//更新一下倒数第二条线   
         return marker;//add
 	};
 
@@ -683,7 +686,7 @@ export class Measure extends ctrlPolygon{
                     color: color,
                     dashSize: 0.5, 
                     gapSize: 0.2, 
-                    linewidth: config.measure.lineWidth,
+                    lineWidth: config.measure.lineWidth,
                     useDepth :true,
                     dashWithDepth :true,  // 只在被遮住的部分显示虚线,因为实线容易挡住label
                     dashed :true,   
@@ -694,14 +697,14 @@ export class Measure extends ctrlPolygon{
                     color: highLightColor,//'#f0ff00',
                     dashSize: 0.5, 
                     gapSize: 0.2, 
-                    linewidth: config.measure.lineWidth  
+                    lineWidth: config.measure.lineWidth  
                 }),
                 guide:   LineDraw.createFatLineMat({
                     color:config.measure.guideLineColor, 
                     dashSize: 0.1, 
                     gapSize: 0.02,
                     dashed: true,
-                    linewidth: config.measure.lineWidth  
+                    lineWidth: config.measure.lineWidth  
                 }) 
                     
             }
@@ -993,7 +996,7 @@ function createCircleRadiusLine(){
 
 	const lineMaterial = new LineMaterial({ 
 		color: 0xff0000, 
-		linewidth: 2, 
+		lineWidth: 2, 
 		resolution:  new THREE.Vector2(1000, 1000),
 		gapSize: 1,
 		dashed: true,
@@ -1010,7 +1013,7 @@ function createCircleRadiusLine(){
         color:0xff0000,   
         dashSize: 0.5, 
 		gapSize: 0.2, 
-		linewidth: config.measure.lineWidth  
+		lineWidth: config.measure.lineWidth  
     })
     circleRadiusLine.visible = false; 
 	return circleRadiusLine;
@@ -1049,7 +1052,7 @@ function createCircleLine(){
 		color: 0xff0000, 
 		dashSize: 5, 
 		gapSize: 2,
-		linewidth: 2, 
+		lineWidth: 2, 
 		resolution:  new THREE.Vector2(1000, 1000),
 	}); 
 
@@ -1063,7 +1066,7 @@ function createCircleLine(){
         color: 0xff0000,
         dashSize: 0.5, 
 		gapSize: 0.2, 
-		linewidth: config.measure.lineWidth  
+		lineWidth: config.measure.lineWidth  
     })
 
 
@@ -1089,7 +1092,7 @@ function createLine(){
         color: 0xff0000,
         dashSize: 0.5, 
 		gapSize: 0.2, 
-		linewidth: config.measure.lineWidth  
+		lineWidth: config.measure.lineWidth  
     })
     
     
@@ -1129,7 +1132,7 @@ function createCircle(){
         color: 0xff0000,
         dashSize: 0.5, 
 		gapSize: 0.2, 
-		linewidth: config.measure.lineWidth  
+		lineWidth: config.measure.lineWidth  
     })
 	return line;
 

+ 54 - 13
src/utils/MeasuringTool.js

@@ -382,25 +382,33 @@ export class MeasuringTool extends EventDispatcher{
             },1)  
         }
 
-		let endDragFun = (e) => {  
-			if (e.button == THREE.MOUSE.LEFT /* e.drag.mouse == MOUSE.LEFT */) {
-				if (measure.points.length >= measure.maxMarkers) {
+		let endDragFun = (e) => { 
+            let length = measure.points.length
+			if (e.button == THREE.MOUSE.LEFT || e.isTouch) { 
+				if (length >= measure.maxMarkers) {
                     end({finish:true});
-				}else{
-                    if(measure.points.length == 1){//点击第一下,恢复可见
-                        measure.markers[0].visible = true; 
-                    }
+				}else{ 
+                     
+                    
                     
-                    var marker = measure.addMarker({point:measure.points[measure.points.length - 1].clone()})
+                    var marker = measure.addMarker({point:measure.points[length - 1].clone()})
                      
-                    if(args.isRect && measure.markers.length == 3){
+                    if(args.isRect && measure.markers.length == 3){//marker全可见
                         measure.addMarker({point:measure.points[0].clone()})
+                        
+                    }else{ 
+                        measure.markers[length].visible = false
+                        measure.edges[length].visible = false 
                     }
+                    measure.edges[length-1].visible = true 
+                    
+                    measure.markers[length-1].visible = true;
+                    
                     measure.editStateChange(true) //重新激活reticule状态
                     continueDrag(marker) 
                 } 
 				 
-			} else if (e.button === THREE.MOUSE.RIGHT /* e.drag.mouse === MOUSE.RIGHT */) {
+			} else if (e.button === THREE.MOUSE.RIGHT ) { //触屏怎么取消?
 				if(e.pressDistance < Potree.config.clickMaxDragDis )end(e);//非拖拽的话
                 else continueDrag(e.drag.object)
                  
@@ -414,6 +422,7 @@ export class MeasuringTool extends EventDispatcher{
                     //this.viewer.scene.removeMeasurement(measure)
                     //cancelFun && cancelFun()
                     //重新开始画
+                    measure.markers[0].removeEventListener('mousedown',end)
                     measure.reDraw()
                     
                     
@@ -432,8 +441,18 @@ export class MeasuringTool extends EventDispatcher{
             }
             if (!e.finish && measure.markers.length > 3) {
 				measure.removeMarker(measure.points.length - 1); 
+                measure.markers[0].removeEventListener('mouseover', mouseover);
+                measure.markers[0].removeEventListener('mouseleave', mouseleave);
+                measure.markers[0].removeEventListener('mousedown',Exit) 
 			}
             measure.isNew = false
+            let length = measure.points.length 
+            if(length){
+                measure.markers[length-1].visible = true; 
+                measure.edges[length-1].visible = true   
+                
+                measure.addHoverEvent()
+            }
             clearTimeout(timer) 
 			this.viewer.removeEventListener('cancel_insertions', Exit);
             //pressExit && this.viewer.inputHandler.removeEventListener('keydown', pressExit);
@@ -442,6 +461,8 @@ export class MeasuringTool extends EventDispatcher{
             viewer.dispatchEvent({
                 type : "CursorChange", action : "remove",  name:"polygon_AtWrongPlace"
             });
+            
+           
             e.remove || callback && callback()  
             /* this.viewer.dispatchEvent({
                 type: 'finish_inserting_measurement',
@@ -475,7 +496,6 @@ export class MeasuringTool extends EventDispatcher{
             measure.editStateChange(false)
         }
         this.viewer.addEventListener('cancel_insertions', Exit);
-         
         
         /*let pressExit
          if(!Potree.settings.isOfficial){
@@ -487,11 +507,17 @@ export class MeasuringTool extends EventDispatcher{
             } 
             this.viewer.inputHandler.addEventListener('keydown', pressExit) 
         } */ 
-		  
+		let mouseover = (e) => { 
+            measure.setMarkerSelected(e.object, true, 'single'); 
+              
+        };
+        let mouseleave = (e) => { 
+            measure.setMarkerSelected(e.object, false, 'single'); 
+        }  
           
                  
         let click = (e)=>{//一旦点击就立刻增加两marker
-            if(measure.unableDragAtMap && e.viewport.name == 'mapViewport' )return 
+            if(measure.unableDragAtMap && e.hoverViewport.name == 'mapViewport' )return 
             var marker = measure.addMarker({point:new THREE.Vector3(0, 0, 0)})
             this.viewer.inputHandler.startDragging(marker , {endDragFun, notPressMouse:true} ); //notPressMouse代表不是通过按下鼠标来拖拽
             e.drag = this.viewer.inputHandler.drag
@@ -501,10 +527,25 @@ export class MeasuringTool extends EventDispatcher{
             measure.dragMarker(e) 
             measure.dropMarker(e)
             
+            
+            measure.markers[1].visible = false
+            measure.edges[1].visible = false
+            
+            if(measure.maxMarkers>2 && !measure.isRect){ 
+                measure.markers[0].addEventListener('mouseover', mouseover);
+                measure.markers[0].addEventListener('mouseleave', mouseleave);
+                measure.markers[0].addEventListener('mousedown',Exit) //点击到第一个marker就结束 
+            }
+            
+            
             this.viewer.removeEventListener('global_click', click)///* global_drop */
             
             return {stopContinue:true}//防止继续执行别的侦听,如flytopano
         }
+        
+        //点击第n下拥有n+1个marker, n>0
+        
+        
         this.viewer.addEventListener('global_click', click, 10)//add importance:10
             
         let ifAtWrongPlace = (e)=>{

+ 1 - 1
src/utils/Profile.js

@@ -101,7 +101,7 @@ export class Profile extends THREE.Object3D{
 			lineGeometry.colors.push(this.lineColor, this.lineColor, this.lineColor);
 			let lineMaterial = new THREE.LineBasicMaterial({
 				vertexColors: THREE.VertexColors,
-				linewidth: 2,
+				lineWidth: 2,
 				transparent: true,
 				opacity: 0.4
 			});

+ 44 - 25
src/utils/ctrlPolygon.js

@@ -73,11 +73,37 @@ export class ctrlPolygon extends THREE.Object3D {
             this.update(true)
             //this.dragChange(new THREE.Vector3().copy(prop.points[prop.points.length-1]), prop.points.length-1); 
             this.setSelected(false )
-            
+            this.addHoverEvent()
             
         }
     }
     
+    
+    
+    addHoverEvent(){ //当非isNew时才添加事件
+        this.markers.forEach(marker =>{
+            
+            let mouseover = (e) => { 
+                this.setMarkerSelected(e.object, true, 'single');/* console.log('hover')  */
+                viewer.dispatchEvent({
+                    type : "CursorChange", action : "add",  name:"markerMove"
+                }) 
+            };
+            let mouseleave = (e) => { 
+                this.setMarkerSelected(e.object, false, 'single');/* console.log('hoveroff')  */
+                viewer.dispatchEvent({
+                    type : "CursorChange", action : "remove",  name:"markerMove"
+                })
+            }
+
+            
+            marker.addEventListener('mouseover', mouseover);
+            marker.addEventListener('mouseleave', mouseleave);
+        
+        })
+            
+    }
+    
     addMarker(o={}){
         var index = o.index == void 0 ? this.points.length : o.index  //要当第几个
         
@@ -88,25 +114,8 @@ export class ctrlPolygon extends THREE.Object3D {
             this.add(o.marker)
             this.markers = [...this.markers.slice(0,index), o.marker, ...this.markers.slice(index,this.markers.length)]
             this.updateMarker(o.marker, o.point)
-            { // Event Listeners  
-                let mouseover = (e) => {
-                    this.setMarkerSelected(e.object, true, 'single');/* console.log('hover')  */
-                    viewer.dispatchEvent({
-                        type : "CursorChange", action : "add",  name:"markerMove"
-                    }) 
-                };
-                let mouseleave = (e) => {
-                    this.setMarkerSelected(e.object, false, 'single');/* console.log('hoveroff')  */
-                    viewer.dispatchEvent({
-                        type : "CursorChange", action : "remove",  name:"markerMove"
-                    })
-                }
-
-                o.marker.addEventListener('drag', this.dragMarker.bind(this));
-                o.marker.addEventListener('drop', this.dropMarker.bind(this));
-                o.marker.addEventListener('mouseover', mouseover);
-                o.marker.addEventListener('mouseleave', mouseleave);
-            }
+            o.marker.addEventListener('drag', this.dragMarker.bind(this));
+            o.marker.addEventListener('drop', this.dropMarker.bind(this));
             
         } 
         
@@ -114,6 +123,8 @@ export class ctrlPolygon extends THREE.Object3D {
             this.add(o.edge)
             this.edges = [...this.edges.slice(0,index), o.edge, ...this.edges.slice(index,this.edges.length)]
         } 
+        
+        
     }
     
     
@@ -349,13 +360,21 @@ export class ctrlPolygon extends THREE.Object3D {
     }
     
     dropMarker(e){
-        if (this.isNew && e.pressDistance>Potree.config.clickMaxDragDis //拖拽的话返回 
-            || e.button != THREE.MOUSE.RIGHT && (//右键click的话继续执行,因为会停止
+        if (this.isNew && e.pressDistance>Potree.config.clickMaxDragDis){//拖拽的话返回
+            return continueDrag(e, this)   
+        } 
+        
+        if(e.isTouch){
+            this.dragMarker(e) //触屏时必须先更新下点
+        }
+        
+        
+        if (e.button != THREE.MOUSE.RIGHT && (//右键click的话继续执行,因为会停止
                 this.isIntersectSelf && this.isNew //有线相交了
                 || this.isAtWrongPlace && this.isNew
                 || !e.isAtDomElement && this.isNew//如果是刚添加时在其他dom点击, 不要响应
-                ||  e.viewport != viewer.mainViewport && this.unableDragAtMap //垂直的测量线不允许在地图上放点
-                || !getDifferentPoint(this.points, this.points.length) //不允许和之前的点相同
+                ||  e.hoverViewport != viewer.mainViewport && this.unableDragAtMap //垂直的测量线不允许在地图上放点
+                || !getDifferentPoint(this.points, this.points.length) //不允许和之前的点相同 
             ) 
         ){
             return continueDrag(e, this)   
@@ -537,7 +556,7 @@ export class ctrlPolygon extends THREE.Object3D {
                 let edge = this.edges[index]; 
                 if(edge){
                     LineDraw.updateLine(edge, [point, nextPoint]) 
-                    edge.visible = index < lastIndex || this.closed;
+                    //edge.visible = index < lastIndex || this.isRect || (this.closed && !this.isNew);
                 }
                 
                 

+ 1 - 1
src/utils/math.js

@@ -404,7 +404,7 @@ var math = {
             c.set(2 / op.resolution.x, 2 / op.resolution.y, 1).multiply(l), //再转回  -1 到 1的范围
             h.copy(c).unproject(op.camera);//再转成三维坐标,求得tag边缘的位置
             var g = h.distanceTo(op.position)//就能得到tag的三维半径
-        
+            //这里使用的都是resolution2, 好处是手机端不会太小, 坏处是pc更改网页显示百分比时显示的大小会变(或许可以自己算出设备真实的deviceRatio, 因window.screen是不会改变的),但考虑到用户可以自行调节字大小也许是好的
             return g  //可能NAN  当相机和position重叠时
         }
     }()

+ 2 - 2
src/viewer/Sprite.js

@@ -77,10 +77,10 @@ export default class Sprite extends THREE.Mesh{
                 
                 scale = math.getScaleForConstantSize($.extend(info,{//规定下最小最大像素 
                     camera , position:this.getWorldPosition(new THREE.Vector3()) ,
-                    resolution: e.viewport.resolution2
+                    resolution: e.viewport.resolution//2
                 }))
                 
-            }
+            } 
             
             if(!isNaN(scale)){
                 this.root.scale.set(scale, scale, scale); 

+ 1 - 1
src/viewer/map/MapViewer.js

@@ -190,7 +190,7 @@ export class MapViewer extends ViewerBase{
         var scale = math.getScaleForConstantSize( {//规定下最小最大像素
             minSize : 80,  maxSize : 180,   nearBound : initCameraFeildWidth*0.1 , farBound : initCameraFeildWidth*2,
             camera:this.camera , position: this.cursor.getWorldPosition(new THREE.Vector3()),
-            resolution: this.viewports[0].resolution2
+            resolution: this.viewports[0].resolution//2
         })
         this.cursor.scale.set(scale, scale, scale);
         this.cursor.position.copy(viewer.mainViewport.camera.position).setZ(cursorHeight)