Parcourir la source

更新裁剪 测绘图

xzw il y a 1 mois
Parent
commit
38c5ca18bc

+ 2 - 1
libs/three.js/build/three.module.js

@@ -21645,7 +21645,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 	this.safeSetTexture2D = safeSetTexture2D;
 	this.safeSetTextureCube = safeSetTextureCube;
-
+    this.getInternalFormat = getInternalFormat //xzw add 
 }
 
 function WebGLUtils( gl, extensions, capabilities ) {
@@ -23583,6 +23583,7 @@ function WebGLRenderer( parameters ) {
 
         _this._textures = textures;//xzw add 
         _this._webglUtils = utils;//xzw add 
+      
 	}
 
 	initGLContext();

+ 1 - 1
src/ExtendPointCloudOctree.js

@@ -215,7 +215,7 @@ export class ExtendPointCloudOctree extends PointCloudOctree{
 		material.fov = camera.fov * (Math.PI / 180);
 		/* material.screenWidth = renderer.domElement.clientWidth;
 		material.screenHeight = renderer.domElement.clientHeight; */
-        material.resolution = resolution 
+        material.resolution.copy(resolution)
 		material.spacing = this.pcoGeometry.spacing; // * Math.max(this.scale.x, this.scale.y, this.scale.z); 
 		material.near = camera.near;
 		material.far = camera.far;

+ 9 - 7
src/custom/modules/clipModel/Clip.js

@@ -625,7 +625,7 @@ var Clip = {
             let camera = viewer.mainViewport.camera
             //if(Clip.activeViewName == 'mainView')return reject()
             
-            const maxWidth = 8192, minWidth = Potree.browser.urlHasValue('clipMinWidth',true) || 1024  //图片尺寸最大最小值。
+            const maxWidth = 8192, minWidth = Potree.browser.urlHasValue('clipMinWidth',true) || 512  //图片尺寸最大最小值。
             //Potree.settings.pointDensity = 'ultraHigh'
             
             viewer.inputHandler.deselectAll() 
@@ -635,10 +635,12 @@ var Clip = {
             
             
             let material = new ExtendPointCloudMaterial 
-            material.pointSizeType = Potree.PointSizeType.FIXED  //Potree.PointSizeType
-            material.size = Potree.browser.urlHasValue('clipPointSize',true) || 1  
+            material.pointSizeType = Potree.browser.urlHasValue('clipFixed') ? Potree.PointSizeType.FIXED : Potree.PointSizeType.ATTENUATED  //Potree.PointSizeType
+            material.size = Potree.browser.urlHasValue('clipPointSize',true) || visiPointclouds[0].material.size  //1  
             material.uniforms.minSize.value = 0.1 
+            material.uniforms.orthoMaxSize.value = 6
             material.activeAttributeName = 'rgba'
+            
 			//material.classification = pointcloud.material.classification;
             
             material.clipBoxBig_in = visiPointclouds[0].material.clipBoxBig_in
@@ -664,7 +666,7 @@ var Clip = {
                 bound.expandByPoint(p1)
             }) 
             let boundSize = bound.getSize(new THREE.Vector3) 
-            let minZoom = Potree.browser.urlHasValue('clipZoom',true) || 80 //1px = 1个点 = 1cm , 如果一个点都是1cm的话
+            let minZoom = Potree.browser.urlHasValue('clipZoom',true) || 50 //1px = 1个点 = 1cm , 如果一个点都是1cm的话
             //zoom不宜过大或过小,过小点云重叠、画面模糊;过大点云有间隙,纹理就看不清
             //中间部分75-80为佳,文字100,边缘50. 最好支持调节 . 且当下载尺寸变大往往点云也多,可能冲破pointbudget限制
             //let text = `1 : ${(1 / camera.zoom).toFixed(4)}(像素 : 米)`
@@ -696,7 +698,7 @@ var Clip = {
             
             
             //分块渲染截图,最后拼合图片。需要使每一块的点数不超过pointBudget, 且尺寸不超过4096(会崩溃),过小的话一般不会超过pointBudget,除非是深度较大后排点云多。
-            let r = THREE.Math.clamp(Math.sqrt(3.5e7 / boundSize.z) * s, 1024, 4096);  //每多少米分一块。 推理 wc*hc = w / r * h / r =  zoom * w * s * zoom * h * s / r^2 = xyz / V(常数,每多少立方米会超出pointBudget,就是括号里的数字,给大概值)  
+            let r = THREE.Math.clamp(Math.sqrt(3e7 / boundSize.z) * s, 1024, 4096);  //每多少米分一块。 推理 wc*hc = w / r * h / r =  zoom * w * s * zoom * h * s / r^2 = xyz / V(常数,每多少立方米会超出pointBudget,就是括号里的数字,给大概值)  
             //let r = THREE.Math.clamp(1024 / boundSize.z, 256, 4096); 
              
             let wc = w / r      //横向块数
@@ -716,8 +718,8 @@ var Clip = {
                     //因为focusOnObject时有最小边界,所以当box很小时截图区域不止box
                     let cameraBoundSizeX = ruler.right-ruler.left 
                     meterPerPixel = cameraBoundSizeX / w
-                    let zoom = viewer.mainViewport.camera.zoom 
-                    material.size *= Math.min(zoom / minZoom, 10 );//限制一下,避免测试时界面点云很小,截图点云很大
+                    /* let zoom = viewer.mainViewport.camera.zoom 
+                    material.size *= Math.min(zoom / minZoom, 10 );//if size fixed 限制一下,避免测试时界面点云很小,截图点云很大 */
                 //}
             } 
             

+ 4 - 3
src/custom/potree.shim.js

@@ -1252,9 +1252,10 @@ Potree.updateVisibilityStructures = function(pointclouds, camera, areaSize) {
 		let camObjPos = new THREE.Vector3().setFromMatrixPosition(camMatrixObject);
 		camObjPositions[i] = camObjPos//camObjPositions.push(camObjPos);
   
-        let quaternion = new THREE.Quaternion().setFromRotationMatrix(camMatrixObject)
-        let camDir = (new THREE.Vector3(0,0,-1)).applyQuaternion(quaternion)
-        camObjDirs[i] = camDir
+        /* let quaternion = new THREE.Quaternion().setFromRotationMatrix(camMatrixObject)
+        let camDir = (new THREE.Vector3(0,0,-1)).applyQuaternion(quaternion) */ 
+        let camDir = new THREE.Vector3(0,0,-1).applyMatrix4(camMatrixObject.clone().setPosition(0,0,0))
+        camObjDirs[i] = camDir 
         
 		// hide all previously visible nodes
 		// if(pointcloud.root instanceof PointCloudOctreeNode){

+ 1 - 1
src/custom/utils/Common.js

@@ -126,7 +126,7 @@ var Common = {
         //复制json		result的可能:普通数字或字符串、普通数组、复杂对象 
         judgeSimpleCopyFun || (judgeSimpleCopyFun=()=>{})
         
-        if (!copyObj || typeof copyObj == 'number' || typeof copyObj == 'string' ||copyObj.isObject3D || copyObj instanceof Function || simpleCopyList.some(className => copyObj instanceof className) || judgeSimpleCopyFun(copyObj)) {
+        if (!copyObj || typeof copyObj != 'object' || copyObj.isObject3D || simpleCopyList.some(className => copyObj instanceof className) || judgeSimpleCopyFun(copyObj)) {
             return copyObj
         }
 

+ 2 - 2
src/custom/viewer/Viewport.js

@@ -99,10 +99,10 @@ export default class Viewport extends THREE.EventDispatcher{
         return getChanged()
 	}
     
-    setResolution(w,h, wholeW=0, wholeH=0){
+    setResolution(w,h, wholeW=0, wholeH=0, devicePixelRatio = window.devicePixelRatio){
         this.resolution.set(w,h);//是client的width height
         
-        this.resolution2.copy(this.resolution).multiplyScalar(this.pixelRatio || window.devicePixelRatio)
+        this.resolution2.copy(this.resolution).multiplyScalar(this.pixelRatio || devicePixelRatio )
          
         this.offset.set(wholeW,wholeH).multiply(new THREE.Vector2(this.left,this.bottom))//.multiplyScalar(window.devicePixelRatio) 
     

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

@@ -175,7 +175,7 @@ console.log('antialias',args.antialias)
                 var width_ = width * view.width
                 var height_ = height * view.height
                  
-                view.setResolution(Math.ceil(width_), Math.ceil(height_), width, height ) 
+                view.setResolution(Math.ceil(width_), Math.ceil(height_), width, height, devicePixelRatio ) 
                 
                 
                 if(height_ == 0)return  //avoid NAN

+ 3 - 1
src/materials/ExtendPointCloudMaterial.js

@@ -44,9 +44,11 @@ export class ExtendPointCloudMaterial extends PointCloudMaterial {
         delete this.uniforms.clipPolygonVP
         delete this.uniforms.clipBoxCount
         
+        
+        this.resolution = new THREE.Vector2() 
         //注意:这里修改了uniforms后,还需要在PotreeRender中手动传递到shader, like: gl.uniformMatrix4fv(....
         Object.assign(this.uniforms,{
-            resolution:    { type: 'v2',  value: new THREE.Vector2() },
+            //resolution:    { type: 'v2',  value: new THREE.Vector2() },
             maxSize:			{ type: "f", value: maxSize },
             orthoMaxSize:			{ type: "f", value: orthoMaxSize },
             gradient:			{ type: "t", value: this.gradientTexture },

+ 1 - 1
src/viewer/EDLRendererNew.js

@@ -290,7 +290,7 @@ export class EDLRenderer{//Eye-Dome Lighting 眼罩照明
                 let material = pointcloud.material; 
                 let octreeSize = pointcloud.pcoGeometry.boundingBox.getSize(new THREE.Vector3()).x;
                 material.fov = THREE.Math.degToRad(camera.fov)  
-                material.resolution = resolution  
+                material.resolution.copy(resolution)  
                 material.spacing = pointcloud.pcoGeometry.spacing; // * Math.max(this.scale.x, this.scale.y, this.scale.z);
                 material.near = camera.near;
                 material.far = camera.far;