xzw 1 年之前
父节点
当前提交
4cd6cb09d6

+ 1 - 1
src/custom/modules/clipModel/Clip.js

@@ -548,7 +548,7 @@ var Clip = {
             let camera = viewer.mainViewport.camera
             let camera = viewer.mainViewport.camera
             //if(Clip.activeViewName == 'mainView')return reject()
             //if(Clip.activeViewName == 'mainView')return reject()
             
             
-            const maxWidth = 8192, minWidth = 1024  //图片尺寸最大最小值。
+            const maxWidth = 8192, minWidth = Potree.browser.urlHasValue('clipMinWidth',true) || 1024  //图片尺寸最大最小值。
             //Potree.settings.pointDensity = 'ultraHigh'
             //Potree.settings.pointDensity = 'ultraHigh'
             
             
             viewer.inputHandler.deselectAll() 
             viewer.inputHandler.deselectAll() 

+ 1 - 1
src/custom/modules/panos/Images360.js

@@ -1232,7 +1232,7 @@ export class Images360 extends THREE.EventDispatcher{
         if(math.closeTo(dis,0) ){//两个点相同
         if(math.closeTo(dis,0) ){//两个点相同
             ifNeighbour = map1[pano0.id] = map0[pano1.id] = true
             ifNeighbour = map1[pano0.id] = map0[pano1.id] = true
             return true
             return true
-        } 
+        }
           
           
         if(dontCompute)  return ifNeighbour 
         if(dontCompute)  return ifNeighbour 
         
         

+ 1 - 1
src/custom/settings.js

@@ -473,7 +473,7 @@ let settings = {//设置   可修改
     pickFrontPointRatio:config.pickFrontPointRatio, //默认pick点云时选中靠近镜头的点的偏向
     pickFrontPointRatio:config.pickFrontPointRatio, //默认pick点云时选中靠近镜头的点的偏向
     dragPolyBeyondPoint: browser.urlHasValue('dragPolyBeyondPoint'),  //ctrlPolygon是否可以拖拽到没点云的地方
     dragPolyBeyondPoint: browser.urlHasValue('dragPolyBeyondPoint'),  //ctrlPolygon是否可以拖拽到没点云的地方
     panoZoomByPointer: false,//全景图是否定点缩放
     panoZoomByPointer: false,//全景图是否定点缩放
-    
+
 }
 }
 
 
 
 

+ 161 - 0
src/custom/start.js

@@ -31,6 +31,167 @@ export function start(dom, mapDom, number ){ //t-Zvd3w0m
     
     
     let viewer = new Potree.Viewer(dom , mapDom);
     let viewer = new Potree.Viewer(dom , mapDom);
     
     
+    
+    
+    
+    
+    
+    
+    
+    
+    /* viewer.addEventListener('allLoaded',()=>{
+        
+        
+        
+            const baseGeometry = new THREE.BufferGeometry();
+            baseGeometry.setIndex([0, 1, 2, 0, 2, 3]);
+         
+            const positionsArray = new Float32Array(4 * 3);
+            const positions = new THREE.BufferAttribute(positionsArray, 3);
+            baseGeometry.setAttribute('position', positions);
+            positions.setXYZ(0, -1.0, -1.0, 0.0);
+            positions.setXYZ(1, -1.0, 1.0, 0.0);
+            positions.setXYZ(2, 1.0, 1.0, 0.0);
+            positions.setXYZ(3, 1.0, -1.0, 0.0);
+            positions.needsUpdate = true;
+            const geometry = new THREE.InstancedBufferGeometry().copy(baseGeometry);
+            let maxSplatCount = 8
+            // Splat index buffer
+            const splatIndexArray = new Uint32Array(maxSplatCount);
+            const splatIndexes = new THREE.InstancedBufferAttribute(splatIndexArray, 1, false);
+            splatIndexes.setUsage(THREE.DynamicDrawUsage);
+            geometry.setAttribute('splatIndex', splatIndexes);
+            
+            const splatPosArray = new Float32Array(maxSplatCount*3);
+            const splatPoses = new THREE.InstancedBufferAttribute(splatPosArray, 3, false);
+            splatPoses.setUsage(THREE.DynamicDrawUsage);
+            geometry.setAttribute('splatCenter', splatPoses);
+            
+            splatPosArray.set([0,0,0,
+            1,1,1,
+            2,2,2,
+            3,3,3,
+            4,4,4,
+            5,5,5,
+            6,6,6,
+            7,7,7])
+            
+            let vertexShaderSource = ` 
+                precision highp float;
+                #include <common>
+                attribute vec3 splatCenter;
+                
+                attribute float splatIndex;
+                  
+                varying vec2 vPosition;
+
+                const float sqrt8 = sqrt(8.0);
+                const float minAlpha = 1.0 / 255.0;
+ 
+                void main () {
+
+                    mat4 transformModelViewMatrix = modelViewMatrix;
+                    vec4 viewCenter = transformModelViewMatrix * vec4(splatCenter, 1.0);
+                    vec4 clipCenter = projectionMatrix * viewCenter;
+
+                    float clip = 1.2 * clipCenter.w;
+                    if (clipCenter.z < -clip || clipCenter.x < -clip || clipCenter.x > clip || clipCenter.y < -clip || clipCenter.y > clip) {
+                        gl_Position = vec4(0.0, 0.0, 2.0, 1.0);
+                        return;
+                    }
+
+                    vPosition = position.xy;
+                     
+                    vec3 ndcCenter = clipCenter.xyz / clipCenter.w;
+ 
+                    float eigenValue1 = 0.2;
+                    float eigenValue2 = 0.2;
+                    
+                    //vec2 eigenVector1 = normalize(vec2(b, eigenValue1 - a)); 
+                    vec2 eigenVector1 = normalize(vec2(0.5, 0.5));
+                    vec2 eigenVector2 = vec2(eigenVector1.y, -eigenVector1.x);
+
+                    vec2 basisVector1 = eigenVector1  * min(sqrt8 * sqrt(eigenValue1), 2048.0);
+                    vec2 basisVector2 = eigenVector2  * min(sqrt8 * sqrt(eigenValue2), 2048.0);
+ 
+
+                    vec2 ndcOffset = vec2(vPosition.x * basisVector1 + vPosition.y * basisVector2) / viewport * 2.0  ;
+
+                    gl_Position = vec4(ndcCenter.xy + ndcOffset,  ndcCenter.z , 1.0);
+                     
+                    vPosition *= sqrt8;
+                }`;
+
+            //面片模拟椭球,总是有厚度
+            const fragmentShaderSource = `
+                precision highp float;
+                #include <common>
+                
+                uniform vec3 color;
+                varying vec2 vPosition;
+
+                void main () {
+                    float A = dot(vPosition, vPosition);
+                    
+                    if (A > 8.0) discard;            //position的范围半径为1。指一个rectangle面中的范围。椭圆外的完全透明
+                     
+                    float opacity = exp(-0.5 * A) * vColor.a;   //周围的透明度降低
+
+                    gl_FragColor = vec4(color.rgb, opacity);
+                }`;
+
+            const uniforms = { 
+                'viewport': {
+                    'type': 'v2',
+                    'value': new THREE.Vector2()
+                } ,
+                color:{
+                    'type': 'v3',
+                    'value': new THREE.Color()
+                }
+            };
+
+             
+
+            const material = new THREE.ShaderMaterial({
+                uniforms: uniforms,
+                vertexShader: vertexShaderSource,
+                fragmentShader: fragmentShaderSource,
+                transparent: true,
+                alphaTest: 1.0,
+                blending: THREE.NormalBlending,
+                depthTest: true,
+                depthWrite: false,
+                side: THREE.DoubleSide
+            });
+            
+            window.splatMesh = new THREE.Mesh(geometry, material)
+        
+            viewer.scene.scene.add(window.splatMesh)
+            
+            
+            viewer.addEventListener('resize',(e)=>{
+                if(e.viewport.name == 'mainViewport'){
+                    uniforms.viewport.copy(e.viewport.resolution)
+                }
+            })
+            
+            window.setSplatIndexes = (globalIndexes)=>{ 
+                geometry.attributes.splatIndex.set(globalIndexes);  
+                geometry.attributes.splatIndex.needsUpdate = true;
+                geometry.instanceCount = globalIndexes.length
+            }
+    })
+    
+    
+     */
+    
+    
+    
+    
+    
+    
+    
     let Alignment = viewer.modules.Alignment
     let Alignment = viewer.modules.Alignment
      
      
 	viewer.setEDLEnabled(false);
 	viewer.setEDLEnabled(false);

+ 43 - 0
src/custom/utils/math.js

@@ -656,7 +656,50 @@ var math = {
     } 
     } 
 };
 };
 
 
+/* 
+
+ 如何将若干个点拟合出线段
+
+ // 假设你有一个点数组,每个点表示为一个包含x和y坐标的对象
+const points = [
+  { x: 1, y: 2 },
+  { x: 2, y: 3 },
+  { x: 3, y: 4 },
+  { x: 4, y: 5 },
+  // ... 更多点
+];
+
+// 定义用于计算最小二乘法参数的函数
+function leastSquares( ) {
+  let sumX = 0;
+  let sumY = 0;
+  let sumXY = 0;
+  let sumX2 = 0;
+  let n = points.length;
+
+  for (const point of points) {
+    sumX += point.x;
+    sumY += point.y;
+    sumXY += point.x * point.y;
+    sumX2 += point.x * point.x;
+  }
+
+  const k = (n * sumXY - sumX * sumY) / (n * sumX2 - sumX * sumX);  //不知道为何这样算,自己解不出来(使点到直线距离之和平方最小),但测了下似乎是准的
+  const b = (sumY - k * sumX) / n;
+
+  return { k, b };
+}
+
+// 使用上述函数计算拟合直线的参数
+const { k, b } = leastSquares(points);
+
+// 现在你可以使用这些参数来表示拟合出的线段 
+console.log(`拟合线段的方程为: y = ${k}x + ${b}`);
+ */
+ 
  
  
+ 
+
 Potree.math = math
 Potree.math = math
 
 
 
 

+ 10 - 4
src/custom/viewer/ViewerNew.js

@@ -1151,7 +1151,12 @@ export class Viewer extends ViewerBase{
                 if(Common.getDifferenceSet(at, this.atDatasets).length){
                 if(Common.getDifferenceSet(at, this.atDatasets).length){
                     //console.log('atDatasets', at) 
                     //console.log('atDatasets', at) 
                     this.atDatasets = at
                     this.atDatasets = at
-                    if(Potree.settings.editType != 'pano' && Potree.settings.editType != 'merge')this.updateFpVisiDatasets()
+                    if(Potree.settings.editType != 'pano' && Potree.settings.editType != 'merge'){
+                        this.updateFpVisiDatasets()
+                        if(!viewer.modules.SiteModel.currentFloor){
+                            this.updatePanosVisibles() //所在数据集的点位显示
+                        }
+                    }
                     this.dispatchEvent({type:'pointcloudAtChange',pointclouds:at}) 
                     this.dispatchEvent({type:'pointcloudAtChange',pointclouds:at}) 
                 }
                 }
                 force = false 
                 force = false 
@@ -1166,8 +1171,9 @@ export class Viewer extends ViewerBase{
     
     
     updatePanosVisibles(currentFloor){//显示当前楼层的所有panos  
     updatePanosVisibles(currentFloor){//显示当前楼层的所有panos  
         if(!Potree.settings.ifShowMarker)return
         if(!Potree.settings.ifShowMarker)return
-        let inEntity = currentFloor
+        let inEntity = currentFloor 
         
         
+        //console.error('updatePanosVisibles', currentFloor)
         
         
         viewer.images360.panos.forEach(pano=>{
         viewer.images360.panos.forEach(pano=>{
             let visible = inEntity ? inEntity.panos.includes(pano) : this.atDatasets.some(e=>e.panos.includes(pano))
             let visible = inEntity ? inEntity.panos.includes(pano) : this.atDatasets.some(e=>e.panos.includes(pano))
@@ -1392,7 +1398,7 @@ export class Viewer extends ViewerBase{
     updateCadVisibles(visiClouds, force){
     updateCadVisibles(visiClouds, force){
         
         
         
         
-        console.log('visiClouds',visiClouds)
+        //console.log('visiClouds',visiClouds)
         
         
         let oldVisi = this.fpVisiDatasets
         let oldVisi = this.fpVisiDatasets
         var visiClouds = this.fpVisiDatasets = visiClouds
         var visiClouds = this.fpVisiDatasets = visiClouds
@@ -3343,7 +3349,7 @@ export class Viewer extends ViewerBase{
     renderBG(viewport){ 
     renderBG(viewport){ 
         let background = viewport.background || viewer.background;
         let background = viewport.background || viewer.background;
         let backgroundOpacity = viewport.backgroundOpacity == void 0 ? viewer.backgroundOpacity : viewport.backgroundOpacity//如果想完全透明,只需要backgroundOpacity为0
         let backgroundOpacity = viewport.backgroundOpacity == void 0 ? viewer.backgroundOpacity : viewport.backgroundOpacity//如果想完全透明,只需要backgroundOpacity为0
-        if(backgroundOpacity != 0){//绘制背景
+        if(backgroundOpacity != 0){//绘制背景. 为了防止相机移动后天空不动有点死板,做一定的动态
             if(background === "skybox"){
             if(background === "skybox"){
                 //限制相机到原点的距离。 
                 //限制相机到原点的距离。 
                 let skyCamera = viewport.camera.type == "OrthographicCamera" ? viewer.skybox.cameraOrtho : viewer.skybox.camera
                 let skyCamera = viewport.camera.type == "OrthographicCamera" ? viewer.skybox.cameraOrtho : viewer.skybox.camera

+ 18 - 6
src/custom/viewer/map/Map.js

@@ -754,6 +754,9 @@ export class TiledMapOpenStreetMap extends TiledMapBase{
         //if(Potree.settings.mapCompany == 'google')return 
         //if(Potree.settings.mapCompany == 'google')return 
         if(style == this.style)return
         if(style == this.style)return
         
         
+        
+        
+        
         if(Potree.settings.mapCompany == 'google'){
         if(Potree.settings.mapCompany == 'google'){
             if(style == 'satellite'){//卫星
             if(style == 'satellite'){//卫星
                 this.baseUrl = "https://mt2.google.com/vt/lyrs=y@159000000&hl=zh-CN&gl=cn&x=${x}&y=${y}&z=${z}&s=mt1"  /* "http://mt2.google.cn/vt/lyrs=m@177000000&hl=zh-CN&gl=cn&src=app&x=${x}&y=${y}&z=${z}"  */   //最高只到19
                 this.baseUrl = "https://mt2.google.com/vt/lyrs=y@159000000&hl=zh-CN&gl=cn&x=${x}&y=${y}&z=${z}&s=mt1"  /* "http://mt2.google.cn/vt/lyrs=m@177000000&hl=zh-CN&gl=cn&src=app&x=${x}&y=${y}&z=${z}"  */   //最高只到19
@@ -781,13 +784,22 @@ export class TiledMapOpenStreetMap extends TiledMapBase{
         }else{
         }else{
             //baseUrl = "https://webst01.is.autonavi.com/appmaptile?lang=zh_cn&style=6&yrs=m&x=${x}&y=${y}&z=${z}"    //卫星 maxDepth = 18   
             //baseUrl = "https://webst01.is.autonavi.com/appmaptile?lang=zh_cn&style=6&yrs=m&x=${x}&y=${y}&z=${z}"    //卫星 maxDepth = 18   
             //搜索高德地图瓦片url 
             //搜索高德地图瓦片url 
-              
-            if(style == 'satellite'){//卫星
-                this.maxDepth = 18
-                this.baseUrl = "https://webst01.is.autonavi.com/appmaptile?lang=zh_cn&style=6&yrs=m&x=${x}&y=${y}&z=${z}"
+            if(Potree.settings.isJiangMen){
+                if(style == 'satellite'){//卫星
+                    this.maxDepth = 18
+                    this.baseUrl = "http://a.map.jms.gd/tile/weixing/${z}/${x}/${y}.png"
+                }else{
+                    this.maxDepth = 19
+                    this.baseUrl = "http://a.map.jms.gd/tile/gd_xiangtu/${z}/${x}/${y}.png"     
+                }
             }else{
             }else{
-                this.maxDepth = 19
-                this.baseUrl = "https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&style=7&yrs=m&x=${x}&y=${y}&z=${z}"    // 
+                if(style == 'satellite'){//卫星
+                    this.maxDepth = 18
+                    this.baseUrl = "https://webst01.is.autonavi.com/appmaptile?lang=zh_cn&style=6&yrs=m&x=${x}&y=${y}&z=${z}"
+                }else{
+                    this.maxDepth = 19
+                    this.baseUrl = "https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&style=7&yrs=m&x=${x}&y=${y}&z=${z}"    // 
+                }
             }
             }
         }
         }