浏览代码

fix: 更改成功

xzw 1 年之前
父节点
当前提交
d6f2cbe97f

+ 2 - 2
examples/lion_laz.html

@@ -56,8 +56,8 @@
 			$("#menu_appearance").next().show();
 			//viewer.toggleSidebar();
 		});
-		
-		Potree.loadPointCloud("../pointclouds/lion_takanawa_laz/cloud.js", "lion", function(e){
+		//cloudPath, dataset.name ,datasetCode, timeStamp, 
+		Potree.loadPointCloud("../pointclouds/lion_takanawa_laz/cloud.js", "lion", "lion", 0, function(e){
 			viewer.scene.addPointCloud(e.pointcloud);
 			
 			let material = e.pointcloud.material;

+ 18 - 1
gulpfile.js

@@ -12,6 +12,7 @@ const {watch} = gulp;
 const {createExamplesPage} = require("./src/tools/create_potree_page");
 const {createGithubPage} = require("./src/tools/create_github_page");
 const {createIconsPage} = require("./src/tools/create_icons_page");
+const serveStatic = require('serve-static'); // 引入serve-static
 
 
 let paths = {
@@ -86,13 +87,29 @@ let shaders = [
 
 'src/**/*.js',
 
+
+
+
+
 // For development, it is now possible to use 'gulp webserver'
 // from the command line to start the server (default port is 8080)
 gulp.task('webserver', gulp.series(async function() {
 	server = connect.server({
 		port: 1234,
         host:'192.168.0.113',
-		https: false,
+		https: true,
+        middleware: function(connect, opt) {
+          return [
+            // 首先,使用addResponseHeaders中间件来设置响应头
+            function setCustomHeaders(req, res, next) {
+              res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
+              res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
+              next();
+            },
+             // 任何其他中间件,如serveStatic
+            serveStatic('./public')
+          ];
+        }
 	});
 }));
 

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

@@ -311,7 +311,7 @@ ShaderLib[ 'line' ] = {
 		#endif
  
         //加
-        #if defined(GL_EXT_frag_depth) && defined(useDepth)    
+        #if defined(useDepth)    // defined(GL_EXT_frag_depth) && 
             uniform sampler2D depthTexture;
             uniform float nearPlane;
             uniform float farPlane; 
@@ -353,7 +353,7 @@ ShaderLib[ 'line' ] = {
 		#include <clipping_planes_pars_fragment>
 
 
-        #if defined(GL_EXT_frag_depth) && defined(useDepth)  
+        #if defined(useDepth)   //defined(GL_EXT_frag_depth) &&
             float convertToLinear(float zValue)
             {
                 //if(uUseOrthographicCamera){
@@ -493,7 +493,7 @@ ShaderLib[ 'line' ] = {
 
 
             //加
-            #if defined(GL_EXT_frag_depth) && defined(useDepth)    
+            #if defined(useDepth)    //defined(GL_EXT_frag_depth) &&
                
                 float mixFactor = 0.0;
                 float clipFactor = 0.0;

+ 1 - 0
package.json

@@ -34,6 +34,7 @@
     "rollup": "^1.31.1",
     "rollup-plugin-babel": "^4.4.0",
     "rollup-plugin-uglify": "^6.0.4",
+    "serve-static": "^1.15.0",
     "through": "~2.3.4"
   },
   "author": "Markus Schütz",

+ 8 - 1
src/ExtendPointCloudOctree.js

@@ -22,6 +22,11 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
         this.boundingBox = this.pcoGeometry.tightBoundingBox//this.pcoGeometry.boundingBox;  //boundingBox是正方体,所以换掉
 		this.boundingSphere = this.boundingBox.getBoundingSphere(new THREE.Sphere());
         this.nodeMaxLevel = 0;//add
+        if (!this.pcoGeometry.loader.version.equalOrHigher('1.5')) {//las 一级一级增长的,但是testNodeMaxLevel时需要大于0
+            this.nodeMaxLevel = 1;//add
+        }
+        
+        
         this.maxLevel = Infinity;
         this.temp = { sizeFitToLevel:{}, opacity:{}}//add
         //add 
@@ -78,7 +83,9 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
              
              console.log('updateNodeMaxLevel ' + this.dataset_id + " : "+ this.nodeMaxLevel)                
               
-            this.setPointLevel()//重新计算
+            setTimeout(()=>{
+               this.setPointLevel()//重新计算    延迟是因为testNodeMax会变回旧的
+            },1)
              
             if(!Potree.settings.sizeFitToLevel){
                 this.changePointSize() 

+ 1 - 0
src/PointCloudOctreeGeometry.js

@@ -133,6 +133,7 @@ export class PointCloudOctreeGeometryNode extends PointCloudTreeNode{
 				this.loadPoints();
 			}
 		} else {
+            this.pcoGeometry.dispatchEvent({type:'updateNodeMaxLevel',level:this.level});//add
 			this.loadPoints();
 		}
 	}

+ 3 - 0
src/Potree.js

@@ -2,6 +2,9 @@
 //export * from "./Potree_update_visibility.js";  //因加载顺序问题,该文件直接在shim中重写
 export * from "./custom/start.js";
 export {settings, config} from './custom/settings.js'  
+export * from './custom/viewer/map/MapViewer.js'  
+   
+   
    
 export * from "./Actions.js"; 
 export * from "./Annotation.js";

+ 21 - 19
src/custom/materials/ModelTextureMaterial.js

@@ -3,7 +3,7 @@ import Common from '../utils/Common.js'
 import {Features} from "../../Features.js";
                                       
 
-const prefixVertex ="precision highp float;\nprecision highp int;\n\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n"
+const prefixVertex ="precision highp float;\nprecision highp int;\n\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;\nuniform vec3 cameraPosition;\n in vec3 position;\n in vec3 normal;\n in vec2 uv;\n"
 const prefixFragment ="precision highp float;\nprecision highp int;\n\nuniform mat4 viewMatrix;\nuniform vec3 cameraPosition;\n"
  
 let shader = {
@@ -97,10 +97,10 @@ let shader = {
             //uniform mat4 pano1Matrix2;
 
            
-            varying vec2 vUv; 
-            varying vec3 vWorldPosition0;
-            varying vec3 vWorldPosition1;
-            varying vec3 vWorldPosition12;
+            out vec2 vUv; 
+            out vec3 vWorldPosition0;
+            out vec3 vWorldPosition1;
+            out vec3 vWorldPosition12;
             
             vec3 transformAxis( vec3 direction ) //navvis->4dkk
             {
@@ -143,7 +143,8 @@ let shader = {
 
         `,
         fragmentShader: prefixFragment + `
-            #extension GL_EXT_frag_depth : enable
+            //#extension GL_EXT_frag_depth : enable
+            
             #define PI 3.141592653 
             
              
@@ -165,10 +166,11 @@ let shader = {
             uniform samplerCube pano1Map;
           
             
-            varying vec2 vUv; 
-            varying vec3 vWorldPosition0;
-            varying vec3 vWorldPosition1;
+            in vec2 vUv; 
+            in vec3 vWorldPosition0;
+            in vec3 vWorldPosition1;
             //varying vec3 vWorldPosition12;
+            out vec4 fragColor;
           
             /* vec2 getSamplerCoord( vec3 direction ) 
             {
@@ -189,7 +191,7 @@ let shader = {
             }
             
             
-            #if defined(GL_EXT_frag_depth) && defined(hasDepthTex)  
+            #if defined(hasDepthTex)  //defined(GL_EXT_frag_depth) && 
                 uniform sampler2D depthMap0;
                 uniform sampler2D depthMap1;
                 uniform mat4 inverseProjectionMatrix;
@@ -205,7 +207,7 @@ let shader = {
                     vec2 depthValue = vec2(0.0, 0.0);
                     vec2 uv2 = getSamplerCoord2( dir.xyz);  //暂时只用基于目标漫游点的方向
                     uv2.x -= 0.25;    //全景图和Cube的水平采样起始坐标相差90度,这里矫正 0.25 个采样偏移
-                    vec4 depth = texture2D(depthMap, uv2);
+                    vec4 depth = texture(depthMap, uv2);
                     //float distance = depth.r + 256. * (depth.g + 256. * depth.b);
                     //distance *= 255. * .001;           // distance is now in meters
                     
@@ -246,18 +248,18 @@ let shader = {
                 vec4 colorFromPano0 = vec4(0.0,0.0,0.0,0.0);
                 #if defined(usePanoMap0)
                     //即progress < 1.0   通常是1
-                    colorFromPano0=textureCube(pano0Map,vWorldPosition0N.xyz);
+                    colorFromPano0=texture(pano0Map,vWorldPosition0N.xyz);
                 #endif
-                vec4 colorFromPano1=textureCube(pano1Map,vWorldPosition1N.xyz);
+                vec4 colorFromPano1=texture(pano1Map,vWorldPosition1N.xyz);
  
-                gl_FragColor=mix(colorFromPano0,colorFromPano1,progress);
+                fragColor=mix(colorFromPano0,colorFromPano1,progress);
               
               
                 
               
                 //深度图修改深度
               
-                #if defined(GL_EXT_frag_depth) && defined(hasDepthTex)  
+                #if defined(hasDepthTex)  //defined(GL_EXT_frag_depth) && 
                     vec4 ndcPos;
                     ndcPos.xy = ((2.0 * gl_FragCoord.xy) - (2.0 * viewport.xy)) / (viewport.zw) - 1.;
                     ndcPos.z = (2.0 * gl_FragCoord.z - gl_DepthRange.near - gl_DepthRange.far) /
@@ -273,8 +275,8 @@ let shader = {
                     vec2 depth1 = getDepth(vWorldPosition1N, depthMap1, cameraHeight1, ceilHeight1, eyePos);
                     
                     
-                    gl_FragDepthEXT = mix(depth0.y,depth1.y,progress); 
-                    gl_FragDepthEXT = clamp(gl_FragDepthEXT, 0.0, 1.0);    //防止部分手机出现黑块。ios 16  。 因为我给的超远值超出范围
+                    gl_FragDepth = mix(depth0.y,depth1.y,progress); 
+                    gl_FragDepth = clamp(gl_FragDepth, 0.0, 1.0);    //防止部分手机出现黑块。ios 16  。 因为我给的超远值超出范围
                     
 
                 #endif
@@ -299,10 +301,10 @@ export default class ModelTextureMaterial extends THREE.RawShaderMaterial {
 			uniforms: THREE.UniformsUtils.clone(shader.uniforms),
             side:THREE.DoubleSide,
 			name: "ModelTextureMaterial",
-            defines
+            defines,  
         })
     
-        
+        this.glslVersion = '300 es'
             
         let setSize = (e)=>{ 
             let viewport = e.viewport

+ 47 - 0
src/custom/modules/mergeModel/MergeEditor.js

@@ -654,6 +654,7 @@ let MergeEditor = {
         
         model.lastMatrixWorld = model.matrixWorld.clone()
         viewer.dispatchEvent('content_changed')
+        viewer.mapViewer && Potree.settings.showObjectsOnMap && viewer.mapViewer.dispatchEvent('content_changed')
     },
     
     
@@ -765,6 +766,52 @@ let MergeEditor = {
         
         
     },
+    
+    
+    setGroundPlaneImg(src,scale){//设置地面图
+        
+        this.goundScale = scale
+        let oldSrc = this.curGroundImgSrc
+        this.curGroundImgSrc = src
+        const ratio = 0.04
+        
+        
+        if(src){
+            if(oldSrc == src && this.groundPlane.material.map.image){ //仅修改大小
+                const s = ratio * this.goundScale
+                let {width, height} = this.groundPlane.material.map.image
+                this.groundPlane.scale.set(width*s, height*s)  
+                viewer.dispatchEvent('content_changed')
+                
+                return
+            }
+            
+            let map = texLoader.load(src,(tex)=>{
+                if(this.curGroundImgSrc == src){
+                    const s = ratio * this.goundScale
+                    this.groundPlane.scale.set(tex.image.width*s, tex.image.height*s)  
+                    viewer.dispatchEvent('content_changed')
+                } 
+            })
+            Potree.Utils.makeTexDontResize(map)          
+            if(!this.groundPlane){
+                this.groundPlane = new THREE.Mesh(new THREE.PlaneBufferGeometry(1,1,1), new THREE.MeshBasicMaterial({
+                    map,  
+                    side : 2,
+                    
+                }))
+                viewer.scene.scene.add(this.groundPlane)
+                this.groundPlane.position.z = -1
+            }else{
+                this.groundPlane.material.map = map
+            }
+            
+            Potree.Utils.updateVisible(this.groundPlane,'show',true )
+        }else{
+            this.groundPlane && Potree.Utils.updateVisible(this.groundPlane,'show',false )
+        }  
+    }
+    
 }   
     
     

+ 6 - 3
src/custom/objects/tool/Measure.js

@@ -376,7 +376,9 @@ export class Measure extends ctrlPolygon{
         
     getArea(){ 
         let area
-        if(this.point2dInfo){
+        if(this._area != void 0){
+            area = this._area
+        }else if(this.point2dInfo){
             area = Math.abs(math.getArea(this.point2dInfo.points2d))//this.getArea();
         }else{//mulDistance Ring 2d面
             area = Math.abs(math.getArea(this.points))
@@ -1159,13 +1161,14 @@ export class Measure extends ctrlPolygon{
                 side:THREE.DoubleSide,
                 opacity:0.2,
                 transparent:true,
-                useDepth:true 
+                useDepth:true,             
             })), 
             selected: new THREE.MeshBasicMaterial({
                 color:  color ,
                 side:THREE.DoubleSide,
                 opacity:0.3,
                 transparent:true, 
+                //wireframe:true                
             })
         },Measure.planeMats = planeMats)
         return super.createAreaPlane(planeMats.default)
@@ -1257,7 +1260,7 @@ export class Measure extends ctrlPolygon{
                    
         }else if(prop.measureType == 'Area'){
             prop.showDistances = true,  
-            prop.atPlane = true,                
+            Potree.settings.areaAtNotPlane || (prop.atPlane = true)                
             prop.showEdges = true,
             prop.closed = true, 
             prop.minMarkers = 3  

+ 63 - 23
src/custom/objects/tool/ctrlPolygon.js

@@ -1,9 +1,7 @@
 import * as THREE from "../../../../libs/three.js/build/three.module.js";
 
-
-
-
-
+//import  "../../../../libs/d3/d3-delaunay.js";
+ 
 import {LineDraw, MeshDraw} from "../../utils/DrawUtil.js";
 import math from "../../utils/math.js";
 
@@ -22,7 +20,7 @@ export class ctrlPolygon extends THREE.Object3D {
         this.type = type
         
         this.maxMarkers = Number.MAX_SAFE_INTEGER;
-      
+       
          
         this.transformData(prop);
         for(let i in prop){
@@ -547,10 +545,13 @@ export class ctrlPolygon extends THREE.Object3D {
     
     }
     
-    getPoint2dInfo(points){ //在更新areaplane之前必须更新过point2dInfo
-        if(this.facePlane && this.atPlane){ 
+    getPoint2dInfo(points){ //在更新areaplane之前必须更新过point2dInfo (针对所有点在同一平面上的)
+        if(this.facePlane && (this.atPlane || Potree.settings.areaAtNotPlane)){
+ 
+            let facePlane = this.getFacePlane()  
+            
             var originPoint0 = points[0].clone() 
-            var qua = math.getQuaBetween2Vector(this.facePlane.normal, new THREE.Vector3(0,0,1), new THREE.Vector3(0,0,1));
+            var qua = math.getQuaBetween2Vector(facePlane.normal, new THREE.Vector3(0,0,1), new THREE.Vector3(0,0,1));
             let points2d = points.map(e=>e.clone().applyQuaternion(qua))  
         
             this.point2dInfo = {
@@ -652,31 +653,70 @@ export class ctrlPolygon extends THREE.Object3D {
          
         
         if(this.points.length>2){
-            if(this.point2dInfo){
-                this.areaPlane.geometry = MeshDraw.getShapeGeo(this.point2dInfo.points2d)
-                let center = math.getCenterOfGravityPoint(this.point2dInfo.points2d) //重心 
-                      
-                let firstPos =  this.point2dInfo.points2d[0].clone()
-                firstPos.z = 0                  //因为shape只读取了xy,所以位移下, 再算出最终位置,得到差距
-                firstPos.applyQuaternion(this.point2dInfo.quaInverse)
-                let vec = this.point2dInfo.originPoint0.clone().sub(firstPos)
-                center = new THREE.Vector3(center.x, center.y, 0)
-                center.applyQuaternion(this.point2dInfo.quaInverse)
-                this.areaPlane.quaternion.copy(this.point2dInfo.quaInverse) 
-                this.areaPlane.position.copy(vec)       
-                center.add(vec)
-                this.center = center 
-            }else{//prism 
             
+            if(this.isPrism){
                 let z = this.horizonZ || 0
                 let points2d = this.points.map(e=>e.clone().setZ(z))
                 this.areaPlane.geometry = MeshDraw.getShapeGeo(points2d) //z=0
                 let center = math.getCenterOfGravityPoint(points2d) //重心 
                 this.areaPlaneCenter = new THREE.Vector3(center.x, center.y, z)
                 this.areaPlane.position.z = z
+            }else if(this.point2dInfo){
+            
+                if(Potree.settings.areaAtNotPlane){
+                    //测点不在同一平面的面积.   (缺点:容易出现三角缺块, 以及搭错线导致超出理想边界外。在平面上n个点能构成n-2个三角形,但空间中更多个,所以若要指定出类似平面那样n-2个三角形是有多种可能的。故暂不开放。 用d3.Delaunay结果更差) //测试桥面 SG-arqnGgAR7om&formal
+                    //参考 http://indoor.popsmart.cn:8084/sxswsw-sx/   找到场景中面积测量线的方法:window.scene.children[18].children[0].material.color.r = 1
+                    let geometry = new THREE.Geometry   
+                    let faceArray = [], triangles = THREE.ShapeUtils.triangulateShape(this.point2dInfo.points2d, [] ); //因为它只关注xy平面,垂直画就容易错,所以用转到平面的points2d来识别三角。
+                        
+                      
+                    if(triangles.length == 0)return
+                    this._area = 0
+                    for( var i = 0; i < triangles.length; i++ ){
+                        faceArray[i] = new THREE.Face3( triangles[i][0], triangles[i][1], triangles[i][2] )
+                        let nor = new THREE.Vector3().crossVectors(
+                            new THREE.Vector3().subVectors(this.points[triangles[i][0]], this.points[triangles[i][2]] ),
+                            new THREE.Vector3().subVectors(this.points[triangles[i][1]], this.points[triangles[i][2]])
+                        ) 
+                        this._area += nor.length() / 2;
+                        nor.normalize()
+                        faceArray[i].normal.copy(nor)
+                    }
+                    geometry.vertices = this.points;
+                    geometry.faces = faceArray;
+                   
+
+                    this.areaPlane.geometry = new THREE.BufferGeometry().fromGeometry(geometry) //不知道为何不转为bufferGeometry显示不出
+                    
+                    //this.center
+                    //参考getFacePlane  在这里建立_normal?
+                    
+                }else{
+                    //if(this.point2dInfo){//旧的。 之前的规定点要在同一平面
+                        this.areaPlane.geometry = MeshDraw.getShapeGeo(this.point2dInfo.points2d)
+                        let center = math.getCenterOfGravityPoint(this.point2dInfo.points2d) //重心 
+                              
+                        let firstPos =  this.point2dInfo.points2d[0].clone()
+                        firstPos.z = 0                  //因为shape只读取了xy,所以位移下, 再算出最终位置,得到差距
+                        firstPos.applyQuaternion(this.point2dInfo.quaInverse)
+                        let vec = this.point2dInfo.originPoint0.clone().sub(firstPos)
+                        center = new THREE.Vector3(center.x, center.y, 0)
+                        center.applyQuaternion(this.point2dInfo.quaInverse)
+                        this.areaPlane.quaternion.copy(this.point2dInfo.quaInverse) 
+                        this.areaPlane.position.copy(vec)       
+                        center.add(vec)
+                        this.center = center
+                    
+                    //}
+                    
+                }
                 
+          
+             
+                 
             }
         }else{
+             
             this.areaPlane.geometry = new THREE.Geometry()
             
         } 

+ 2 - 2
src/custom/potree.shim.js

@@ -38,7 +38,7 @@ KeyCodes.BACKSPACE = 8
 //注意,这时候Potree.js中export的内容还不在Potree变量中
 
 var texLoader = new THREE.TextureLoader()
-
+    texLoader.crossOrigin = "anonymous" 
 {//defines:
     Potree.defines = {}
     Potree.defines.Buttons = {// MouseEvent.buttons
@@ -407,7 +407,7 @@ Utils.getMousePointCloudIntersection = function(viewport, mouse, pointer, camera
             pointcloud: selectedPointcloud,
             point: closestPoint,
             pointclouds: allPointclouds, //add  
-            normal:new THREE.Vector3().fromArray(closestPoint.normal ).applyMatrix4(selectedPointcloud.rotateMatrix)//add
+            normal: closestPoint.normal && new THREE.Vector3().fromArray(closestPoint.normal ).applyMatrix4(selectedPointcloud.rotateMatrix)//add
         };
     } else {
         return null;

+ 1 - 1
src/custom/settings.js

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

+ 5 - 5
src/custom/start.js

@@ -864,7 +864,7 @@ export function panoEditStart(dom, number, fileServer){
 
   
 
-export function mergeEditStart(dom){
+export function mergeEditStart(dom, mapDom){
     Potree.settings.editType = 'merge' 
     Potree.settings.intersectOnObjs = true
     Potree.settings.boundAddObjs = true
@@ -872,7 +872,7 @@ export function mergeEditStart(dom){
    
     
     
-    let viewer = new Potree.Viewer(dom );
+    let viewer = new Potree.Viewer(dom, mapDom );
    
     let Alignment = viewer.modules.Alignment
      
@@ -1174,10 +1174,10 @@ export function mergeEditStart(dom){
             }    
               
             viewer.loadModel(info , callback, onProgress, onError)
+               
             
             
-            
-        }else if(prop.type == 'obsg' || prop.type == 'b3dm'){  //3d tiles  
+        }else if(prop.type == 'osgb' || prop.type == 'b3dm'){  //3d tiles  
         
             let callback = (object)=>{
                  
@@ -1211,7 +1211,7 @@ export function mergeEditStart(dom){
             
         }else{  
             
-             //else if(prop.type == 'las' || prop.type == 'ply')
+             //else if(prop.type == 'las' || prop.type == 'ply' || prop.type == 'laz' ) 
  
             Potree.loadPointCloudScene(prop.url, prop.type, prop.modelId, prop.title, (pointcloud)=>{  
                 pointcloud.matrixAutoUpdate = true

+ 12 - 1
src/custom/three.shim.js

@@ -373,4 +373,15 @@ THREE.Object3D.prototype.realVisible = function(){
         v = false
     }   
     return v                                
-}
+}
+
+
+
+
+
+
+
+
+
+
+

+ 8 - 8
src/custom/viewer/ViewerNew.js

@@ -245,7 +245,7 @@ export class Viewer extends ViewerBase{
                 //add
                 { 
                     $(domElement).append($("<div id='potree_labels'></div>"));
-                    if(!mapArea && Potree.settings.editType != 'merge'){
+                    if(!mapArea && (Potree.settings.editType != 'merge' /* || Potree.settings.showObjectsOnMap */)){
                         mapArea = $("<div id='mapGaode'></div>");
                         $(domElement).append(mapArea);
                         mapArea = mapArea[0];
@@ -473,7 +473,7 @@ export class Viewer extends ViewerBase{
                 this.scene.scene.add(this.reticule)
                 
                 
-                if(Potree.settings.editType != "pano" && Potree.settings.editType != 'merge'){
+                if(Potree.settings.editType != "pano" && (Potree.settings.editType != 'merge' /* || Potree.settings.showObjectsOnMap */)){
                     this.mapViewer = new MapViewer(mapArea/* $('#mapGaode')[0] */)
                 }
                 
@@ -2359,7 +2359,7 @@ export class Viewer extends ViewerBase{
 	}
 
 	loadGUI(callback){
-
+        
 		if(callback){
 			this.onGUILoaded(callback);
 		}
@@ -2872,10 +2872,10 @@ export class Viewer extends ViewerBase{
         
  	
         if(Potree.settings.editType != 'pano' && Potree.settings.editType != 'merge'){
-            this.modules.ParticleEditor.update(delta) 
-            this.mapViewer.update(delta)     //地图更新       
+            this.modules.ParticleEditor.update(delta)  
         }
-    
+        this.mapViewer && this.mapViewer.update(delta)     //地图更新
+        
 		this.dispatchEvent({ type: 'update', delta: delta, timestamp: timestamp});  //在有sidebar时耗高cpu,占本update函数80%
          
 		 
@@ -5161,7 +5161,7 @@ export class Viewer extends ViewerBase{
             fileInfo_.parentInfo.loadedCount ++
             fileInfo_.parentInfo.modelGroup.add(object) 
             if(fileInfo_.parentInfo.loadedCount == fileInfo_.parentInfo.url.length){ 
-                return loadDone(fileInfo_.parentInfo.modelGroup, fileInfo_.parentInfo)
+                return this.modelLoaded(fileInfo_.parentInfo.modelGroup, fileInfo_.parentInfo, done)
             }else{ 
                 return
             }   
@@ -5233,7 +5233,7 @@ export class Viewer extends ViewerBase{
             json.root.refine = 'ADD';
             json.refine = 'ADD';
         }else { 
-            Potree.Utils.setObjectLayers(object,'model')  
+            Potree.Utils.setObjectLayers(object, Potree.settings.showObjectsOnMap ? 'bothMapAndScene' : 'model')  
             
             
             object.traverse( ( child )=>{ 

+ 2 - 2
src/custom/viewer/map/MapViewer.js

@@ -767,9 +767,9 @@ export class MapViewer extends ViewerBase{
         //绘制其他物体
         Potree.Utils.setCameraLayers(this.camera, ['mapObjects'  , 'bothMapAndScene'  ])
         viewer.dispatchEvent({type: "render.begin",  viewer: this, viewport:this.viewports[0], params }); 
-        renderer.render(this.scene, this.camera);
-        this.attachedToViewer || renderer.render(viewer.scene.scene, this.camera); //类同renderOverlay
         
+        this.attachedToViewer || renderer.render(viewer.scene.scene, this.camera); //类同renderOverlay
+        renderer.render(this.scene, this.camera);
         if(!this.attachedToViewer && this.renderMeasure){//在未attach到主页面时也要渲染测量线
             viewer.dispatchEvent({type: "render.pass.perspective_overlay", camera:this.camera, /* screenshot:params.screenshot, */viewport:this.viewports[0], renderer});
         }

+ 1 - 1
src/custom/viewer/viewerBase.js

@@ -49,7 +49,7 @@ export class ViewerBase extends THREE.EventDispatcher{
         let canvas = document.createElement("canvas");
                                                              
 
-        let context = canvas.getContext('webgl', contextAttributes );   //不用webgl2是因为有的写法在webgl2不支持 如gl_FragDepthEXT 
+        let context = canvas.getContext('webgl2', contextAttributes );   //不用webgl2是因为有的写法在webgl2不支持 如gl_FragDepthEXT 
         
 
         this.renderer = new THREE.WebGLRenderer({ 

+ 6 - 3
src/loader/LasLazLoader.js

@@ -29,7 +29,7 @@ export class LasLazLoader {
 
 	}
 
-	load (node) {
+	load (node, callback) {
 		if (node.loaded) {
 			return;
 		}
@@ -48,7 +48,7 @@ export class LasLazLoader {
 			if (xhr.readyState === 4) {
 				if (xhr.status === 200 || xhr.status === 0) {
 					let buffer = xhr.response;
-					this.parse(node, buffer);
+					this.parse(node, buffer, callback);
 				} else {
 					console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + url);
 				}
@@ -58,7 +58,7 @@ export class LasLazLoader {
 		xhr.send(null);
 	}
 
-	async parse(node, buffer){
+	async parse(node, buffer, callback){//add callback
 		let lf = new LASFile(buffer);
 		let handler = new LasLazBatcher(node);
 
@@ -106,11 +106,14 @@ export class LasLazLoader {
 			await lf.close();
 
 			lf.isOpen = false;
+            
 		}catch(e){
 			console.error("failed to close las/laz file!!!");
 			
 			throw e;
 		}
+        
+        callback() //add
 	}
 
 	handle (node, url) {

+ 3 - 2
src/materials/shaders/depthBasic.fs

@@ -23,7 +23,8 @@ uniform vec3 baseColor;
     }
 #endif
  
-#if defined(GL_EXT_frag_depth) && defined(useDepth)  
+
+  #if defined(useDepth)                         //#if defined(GL_EXT_frag_depth) && defined(useDepth)
     //似乎通过gl.getExtension('EXT_frag_depth')得到的GL_EXT_frag_depth
      
     uniform sampler2D depthTexture;
@@ -58,7 +59,7 @@ void main() {
     
     
     
-    #if defined(GL_EXT_frag_depth) && defined(useDepth)
+    #if defined(useDepth)    // defined(GL_EXT_frag_depth) 
         // mixFactor and clipFactor define the color mixing proportion between the states of
         // full visibility and occluded visibility
         // and

+ 3 - 3
src/materials/shaders/otherShaders.js

@@ -21,16 +21,16 @@ export const copyShader = {
         }
     `,
     fragmentShader: `
-        #extension GL_EXT_frag_depth : enable
+        //#extension GL_EXT_frag_depth : enable
         uniform float opacity;
         uniform sampler2D tDiffuse;
-        #if defined(GL_EXT_frag_depth) && defined(useDepth)
+        #if defined(useDepth)   // defined(GL_EXT_frag_depth) && 
             uniform sampler2D depthTex;
         #endif
         
         varying vec2 vUv;
         void main() { 
-            #if defined(GL_EXT_frag_depth) && defined(useDepth)
+            #if defined(useDepth) //defined(GL_EXT_frag_depth) && 
                 float depth = texture2D(depthTex, vUv).r;
                 /* if(depth >= 1.0){ //超级远(但是在modelTex里我把天空距离超出far了,所以不删)
                     discard;

+ 25 - 22
src/materials/shaders/pointcloud_new.fs

@@ -1,7 +1,9 @@
+#version 300 es
+//#if defined paraboloid_point_shape
+//	#extension GL_EXT_frag_depth : enable
+//#endif
+
 
-#if defined paraboloid_point_shape
-	#extension GL_EXT_frag_depth : enable
-#endif
 #define PI 3.141592653589793
 
 
@@ -23,13 +25,13 @@ precision highp int;
     uniform mat4 pano0Matrix; 
     uniform vec3 pano1Position;
     uniform mat4 pano1Matrix;
-    varying vec3 vWorldPosition0;
-    varying vec3 vWorldPosition1;
+    in vec3 vWorldPosition0;
+    in vec3 vWorldPosition1;
 
 #endif 
 */
 
-
+out vec4 fragColor;
 
 //------------
 
@@ -45,7 +47,7 @@ uniform vec3 cameraPosition;
 
 uniform mat4 projectionMatrix;
 //uniform float uOpacity;
-varying float vOpacity; //add
+in float vOpacity; //add
 
 uniform float blendHardness;
 uniform float blendDepthSupplement;
@@ -57,12 +59,12 @@ uniform float uPCIndex;
 uniform float uScreenWidth;
 uniform float uScreenHeight;
 
-varying vec3	vColor;
-varying float	vLogDepth;
-varying vec3	vViewPosition;
-varying float	vRadius;
-varying float 	vPointSize;
-varying vec3 	vPosition;
+in vec3	vColor;
+in float	vLogDepth;
+in vec3	vViewPosition;
+in float	vRadius;
+in float 	vPointSize;
+in vec3 	vPosition;
 
 
 float specularStrength = 1.0;
@@ -130,9 +132,9 @@ void main() {
 	
  
     #if defined color_type_indices    //pick point recognize
-		gl_FragColor = vec4(color, uPCIndex / 255.0); //uPCIndex : node Index
+		fragColor = vec4(color, uPCIndex / 255.0); //uPCIndex : node Index
 	#else
-		gl_FragColor = vec4(color, vOpacity);
+		fragColor = vec4(color, vOpacity);
 	#endif
     
     
@@ -152,8 +154,9 @@ void main() {
 		pos = pos / pos.w;
 		float expDepth = pos.z;
 		depth = (pos.z + 1.0) / 2.0;
-		gl_FragDepthEXT = depth;
-		gl_FragDepthEXT = clamp(gl_FragDepthEXT, 0.0, 1.0);  //add
+		gl_FragDepth = depth;//gl_FragDepthEXT = depth;
+		gl_FragDepth = clamp(gl_FragDepth, 0.0, 1.0);//gl_FragDepthEXT = clamp(gl_FragDepthEXT, 0.0, 1.0);  //add
+        
         
         
 		#if defined(color_type_depth)
@@ -162,12 +165,12 @@ void main() {
 		#endif
 		
 		#if defined(use_edl)
-			gl_FragColor.a = log2(linearDepth);
+			fragColor.a = log2(linearDepth);
 		#endif
 		
 	#else
 		#if defined(use_edl)
-			gl_FragColor.a = vLogDepth;
+			fragColor.a = vLogDepth;
 		#endif
 	#endif
 
@@ -176,11 +179,11 @@ void main() {
 		float weight = max(0.0, 1.0 - distance);
 		weight = pow(weight, 1.5);
 
-		gl_FragColor.a = weight;
-		gl_FragColor.xyz = gl_FragColor.xyz * weight;
+		fragColor.a = weight;
+		fragColor.xyz = fragColor.xyz * weight;
 	#endif
 
-	//gl_FragColor = vec4(0.0, 0.7, 0.0, 1.0);
+	//fragColor = vec4(0.0, 0.7, 0.0, 1.0);
 	
 }
 

+ 42 - 42
src/materials/shaders/pointcloud_new.vs

@@ -1,4 +1,4 @@
-
+#version 300 es
 precision highp float;
 precision highp int;
  
@@ -22,8 +22,8 @@ precision highp int;
     uniform vec3 pano1Position;
     uniform mat4 pano1Matrix;
     /*
-    varying vec3 vWorldPosition0;
-    varying vec3 vWorldPosition1;
+    out vec3 vWorldPosition0;
+    out vec3 vWorldPosition1;
     */
 #endif 
 
@@ -38,18 +38,18 @@ precision highp int;
 
 
 
-attribute vec3 position;
-attribute vec3 color;
-attribute float intensity;
-attribute float classification;
-attribute float returnNumber;
-attribute float numberOfReturns;
-attribute float pointSourceID;
-attribute vec4 indices;    //每个点的index
-attribute float spacing;
-attribute float gpsTime;
-attribute vec3 normal;
-attribute float aExtra;
+in vec3 position;
+in vec3 color;
+in float intensity;
+in float classification;
+in float returnNumber;
+in float numberOfReturns;
+in float pointSourceID;
+in vec4 indices;    //每个点的index
+in float spacing;
+in float gpsTime;
+in vec3 normal;
+in float aExtra;
 
 uniform mat4 modelMatrix;
 uniform mat4 modelViewMatrix;
@@ -135,7 +135,7 @@ uniform bool uIsLeafNode;
 
 uniform vec3 uColor;
 uniform float uOpacity; 
-varying float vOpacity; //add
+out float vOpacity; //add
 
 
 
@@ -189,16 +189,16 @@ uniform mat4 uShadowProj[num_shadowmaps];
 
 
 
-varying vec3	vColor;
-varying float	vLogDepth;
-varying vec3	vViewPosition;
-varying float 	vRadius;
-varying float 	vPointSize;
+out vec3	vColor;
+out float	vLogDepth;
+out vec3	vViewPosition;
+out float 	vRadius;
+out float 	vPointSize;
 
 
-float round(float number){
+/*float round(float number){
 	return floor(number + 0.5);
-}
+}*/
 
 // 
 //    ###    ########     ###    ########  ######## #### ##     ## ########     ######  #### ######## ########  ######  
@@ -291,7 +291,7 @@ float getLOD(){//////we use this
 		index3d = floor(index3d + 0.5);
 		int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
 		
-		vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
+		vec4 value = texture(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
 		int mask = int(round(value.r * 255.0));
 
 		if(isBitSet(mask, index)){
@@ -331,7 +331,7 @@ float getSpacing(){
 		index3d = floor(index3d + 0.5);
 		int index = int(round(4.0 * index3d.x + 2.0 * index3d.y + index3d.z));
 		
-		vec4 value = texture2D(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
+		vec4 value = texture(visibleNodes, vec2(float(iOffset) / 2048.0, 0.0));
 		int mask = int(round(value.r * 255.0));
 		float spacingFactor = value.a;
 
@@ -389,7 +389,7 @@ float getLOD(){
 		
 	for(float i = 0.0; i <= 1000.0; i++){
 		
-		vec4 value = texture2D(visibleNodes, vec2(iOffset / 2048.0, 0.0));
+		vec4 value = texture(visibleNodes, vec2(iOffset / 2048.0, 0.0));
 		
 		int children = int(value.r * 255.0);
 		float next = value.g * 255.0;
@@ -486,26 +486,26 @@ vec3 getGpsTime(){
 	float w = (gpsTime + uGpsOffset) * uGpsScale;
 
 
-	vec3 c = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
+	vec3 c = texture(gradient, vec2(w, 1.0 - w)).rgb;
 
 
 	// vec2 r = uNormalizedGpsBufferRange;
 	// float w = gpsTime * (r.y - r.x) + r.x;
 	// w = clamp(w, 0.0, 1.0);
-	// vec3 c = texture2D(gradient, vec2(w,1.0-w)).rgb;
+	// vec3 c = texture(gradient, vec2(w,1.0-w)).rgb;
 	
 	return c;
 }
 
 vec3 getElevation(vec4 world){  
 	float w = (world.z - elevationRange.x) / (elevationRange.y - elevationRange.x);
-	vec3 cElevation = texture2D(gradient, vec2(w,1.0-w)).rgb;
+	vec3 cElevation = texture(gradient, vec2(w,1.0-w)).rgb;
 	return cElevation;
 }
 
 vec4 getClassification(){
 	vec2 uv = vec2(classification / 255.0, 0.5);
-	vec4 classColor = texture2D(classificationLUT, uv);
+	vec4 classColor = texture(classificationLUT, uv);
 	
 	return classColor;
 }
@@ -569,14 +569,14 @@ vec3 getNumberOfReturns(){
 
 	float w = value / 6.0;
 
-	vec3 color = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
+	vec3 color = texture(gradient, vec2(w, 1.0 - w)).rgb;
 
 	return color;
 }
 
 vec3 getSourceID(){
 	float w = mod(pointSourceID, 10.0) / 10.0;
-	return texture2D(gradient, vec2(w,1.0 - w)).rgb;
+	return texture(gradient, vec2(w,1.0 - w)).rgb;
 }
 
 vec3 getCompositeColor(vec4 world){
@@ -641,7 +641,7 @@ vec3 getMatcap(){
 	vec3 r_en = reflect( eye, getNormal() ); // or r_en = e - 2. * dot( n, e ) * n;
 	float m = 2. * sqrt(pow( r_en.x, 2. ) + pow( r_en.y, 2. ) + pow( r_en.z + 1., 2. ));
 	vec2 vN = r_en.xy / m + .5;
-	return texture2D(matcapTextureUniform, vN).rgb; 
+	return texture(matcapTextureUniform, vN).rgb; 
 }
 #endif
 
@@ -650,7 +650,7 @@ vec3 getExtra(){
 	float w = (aExtra + uExtraOffset) * uExtraScale;
 	w = clamp(w, 0.0, 1.0);
 
-	vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+	vec3 color = texture(gradient, vec2(w,1.0-w)).rgb;
 
 	// vec2 r = uExtraNormalizedRange;
 
@@ -660,7 +660,7 @@ vec3 getExtra(){
 
 	// w = clamp(w, 0.0, 1.0);
 
-	// vec3 color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+	// vec3 color = texture(gradient, vec2(w,1.0-w)).rgb;
 
 	return color;
 }
@@ -689,13 +689,13 @@ vec3 getColor(vec4 world){
 		color = getGpsTime();
 	#elif defined color_type_intensity_gradient
 		float w = getIntensity();
-		color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+		color = texture(gradient, vec2(w,1.0-w)).rgb;
 	#elif defined color_type_color
 		color = uColor;
 	#elif defined color_type_level_of_detail
 		float depth = getLOD();
 		float w = depth / 10.0;
-		color = texture2D(gradient, vec2(w,1.0-w)).rgb;
+		color = texture(gradient, vec2(w,1.0-w)).rgb;
 	#elif defined color_type_indices
 		color = indices.rgb;
 	#elif defined color_type_classification
@@ -1071,7 +1071,7 @@ void doClipping(vec4 world){
             }else{
                 vec2 uv = vec2((world.x - xMin) / (xMax - xMin),  (world.y - yMin) / (yMax - yMin) );
                 
-                vec4 color = texture2D(baseHeightAreaMap,uv);
+                vec4 color = texture(baseHeightAreaMap,uv);
                 //抗锯齿待写
                  
                 
@@ -1197,8 +1197,8 @@ void main() {
         /*
         vec2 samplerCoord0 = getSamplerCoord(vWorldPosition0.xyz);
         vec2 samplerCoord1 = getSamplerCoord(vWorldPosition1.xyz); 
-        vec4 colorFromPano0 = texture2D(pano0Map,samplerCoord0);
-        vec4 colorFromPano1 = texture2D(pano1Map,samplerCoord1);
+        vec4 colorFromPano0 = texture(pano0Map,samplerCoord0);
+        vec4 colorFromPano1 = texture(pano1Map,samplerCoord1);
         */
         
         
@@ -1295,7 +1295,7 @@ void main() {
 
             if(distance < 1.0){
                 float w = distance;
-                vec3 cGradient = texture2D(gradient, vec2(w, 1.0 - w)).rgb;
+                vec3 cGradient = texture(gradient, vec2(w, 1.0 - w)).rgb;
                 
                 vColor = cGradient;
                 //vColor = cGradient * 0.7 + vColor * 0.3;
@@ -1337,7 +1337,7 @@ void main() {
             float bias = vRadius * 2.0;
 
             for(int j = 0; j < 9; j++){
-                vec4 depthMapValue = texture2D(uShadowMap[i], vec2(u, v) + sampleLocations[j]);
+                vec4 depthMapValue = texture(uShadowMap[i], vec2(u, v) + sampleLocations[j]);
 
                 float linearDepthFromSM = depthMapValue.x + bias;
                 float linearDepthFromViewer = distanceToLight;

+ 1 - 1
src/navigation/InputHandlerNew.js

@@ -1430,7 +1430,7 @@ export class InputHandler extends THREE.EventDispatcher {
         
         //raycaster.layers.enableAll()//add
         Potree.Utils.setCameraLayers(raycaster,   //设置能识别到的layers(如空间模型里只有mapViewer能识别到marker)
-            ['sceneObjects','mapObjects','measure',  'transformationTool', 'model'],
+            ['sceneObjects','mapObjects','measure',  'transformationTool', 'model', 'bothMapAndScene'],
             this.hoverViewport && this.hoverViewport.extraEnableLayers
         )
         //this.hoverViewport.beforeRender && this.hoverViewport.beforeRender()

+ 6 - 4
src/viewer/ExtendView.js

@@ -212,7 +212,7 @@ class ExtendView extends View {
             
             let f = ()=>{ 
                 this.position.copy(endPosition)  //因为延时1后control的update会导致位置改变
-                info.callback && info.callback()  
+                info.callback && info.callback()   
                 this.dispatchEvent('flyingDone')  
             }
             if(info.duration){
@@ -225,15 +225,17 @@ class ExtendView extends View {
         
         let endPosition = new THREE.Vector3().copy(info.position)
         let startPosition = this.position.clone();
-		let startQuaternion, endQuaternion, endTarget = null,  
+		let startQuaternion, endQuaternion, endTarget = info.target && new THREE.Vector3().copy(info.target)  ,  
             endYaw, startYaw, endPitch, startPitch ;
         
         
         this.restrictPos(endPosition)
          
+         
+         
+         
         if(info.endYaw == void 0){
-            if(info.target ){
-                endTarget = new THREE.Vector3().copy(info.target)  
+            if(info.target ){ 
                 endQuaternion = math.getQuaFromPosAim(endPosition,endTarget) //若为垂直,会自动偏向x负的方向
            
             }else if(info.quaternion){

文件差异内容过多而无法显示
+ 3227 - 3362
yarn.lock