xzw 2 năm trước cách đây
mục cha
commit
86a1967627

+ 3 - 3
libs/three.js/3dtiles/three-loader-3dtiles.esm.js

@@ -23,8 +23,8 @@ PERFORMANCE OF THIS SOFTWARE.
 ***************************************************************************** */
 ***************************************************************************** */
 
 
 
 
-window.visiVertexCount = 0
-window.visiGeoCount = 0
+let visiVertexCount = 0
+let visiGeoCount = 0
 const maxVertexVisi = 5e6
 const maxVertexVisi = 5e6
 const maxTexVisi = 500
 const maxTexVisi = 500
 
 
@@ -44,7 +44,7 @@ function getGpuMemoryUsage(win = window){//总的
     } 
     } 
     
     
     viewer.tiles3dMemoryUsage = c
     viewer.tiles3dMemoryUsage = c
-    
+    viewer.tiles3dVisiVCount = visiVertexCount
     return  c
     return  c
 }
 }
 
 

+ 37 - 16
src/custom/modules/mergeModel/MergeEditor.js

@@ -677,38 +677,59 @@ let MergeEditor = {
         })
         })
         this.updateMemoryUsage()
         this.updateMemoryUsage()
     },
     },
+    
+    
+    
     updateMemoryUsage(){
     updateMemoryUsage(){
+        
         //obj暂时不管其贴图大小, 因为顶点造成的不仅是内存还有卡顿所以先只看顶点
         //obj暂时不管其贴图大小, 因为顶点造成的不仅是内存还有卡顿所以先只看顶点
-        let maxMemory = 1000 //M 
-        let eachObjPosWeight = 40/1000/1000  //M  每个顶点pos是3*4个字节?法线3*4和uv2*4  其实还有贴图,姑且算10*4个字节,
-        let posCoyunt=0, hasGltf=0      
+        const maxMemory = Potree.config.tiles3DMaxMemory + 100 //M  实际估计是这个的10倍
+        const eachObjPosWeight = 100/1000/1000  //M  每个顶点pos是3*4个字节?法线3*4和uv2*4  其实还有贴图 
+        const eachCloudPointWeight = 12/1000/1000 //M 每个点 pos + 颜色 + 法线 大概  
+        const eachVisiCPointWeight = eachCloudPointWeight * 5    // 或 maxMemory / (6*1000*1000) 大概值接近 (再除以一个数是因为显示的要比内存中的耗更多资源
+        const eachGltfPosWeight = 100/1000/1000  //M  每个顶点pos是3*4个字节?法线3*4和uv2*4  其实还有贴图 
+        let posCount=0
+
+        
         viewer.objs.children.forEach(e=>{
         viewer.objs.children.forEach(e=>{
-            if(e.name == 'glb' || e.name == 'obj'){
+            if(e.fileType == 'glb' || e.fileType == 'obj'){
                 e.traverse((mesh)=>{
                 e.traverse((mesh)=>{
-                    /* if(mesh.geometry){
+                    if(mesh.geometry){
                         posCount += mesh.geometry.attributes.position.count
                         posCount += mesh.geometry.attributes.position.count
-                    } */
+                    } 
                 })
                 })
-            }else if(e.name == 'gltf'){
+            }else if(e.fileType == '3dTiles'){
                   
                   
             }
             }
         })
         })
         
         
         //获取点云的内存限制
         //获取点云的内存限制
-        let weight = posCount*eachObjPosWeight + viewer.tiles3dMemoryUsage/1024/1024  //M
-        let min = 0.1, max = 6, minP = 100, maxP = 1000000; 
-        let ratio = Math.round(math.linearClamp(score, minP, maxP, max, min )); 
-	    let rest = maxMemory - weight         
-        Potree.pointBudget = rest*1000*1000 
-        
-        //获取3dTiles的内存限制
-        let tiles3DMaxMemory = Potree.config.tiles3DMaxMemory -  Math.round((posCount + Potree.numVisiblePoints) / 100000 )
+        let objWeight = posCount*eachObjPosWeight
+        let laserWeight = Potree.numVisiblePoints  * eachCloudPointWeight //点云实际显示所占大小
+        let laserMemoryWeight =  Potree.lru.numPoints * eachCloudPointWeight   //点云所使用内存大小
+        let tiles3DWeight = viewer.tiles3dVisiVCount * eachGltfPosWeight //M   3dTiles所占内存大小
+        let tiles3DMemoryWeight = viewer.tiles3dMemoryUsage / 1000 / 1000  //M   3dTiles显示的所占内存大小
+        
+        /* let min = 0.1, max = 6, minP = 100, maxP = 1000000; 
+        let ratio = Math.round(math.linearClamp(score, minP, maxP, max, min ));  */
+	    let rest = maxMemory - objWeight - tiles3DWeight         
+        Potree.pointBudget = Math.max(30000, Math.round(rest/eachVisiCPointWeight)) 
+        
+        //获取3dTiles的内存限制 
+        let tiles3DMaxMemory = maxMemory - Math.round(objWeight + laserWeight)
         Potree.settings.tiles3DMaxMemory = THREE.Math.clamp(tiles3DMaxMemory , 30, Potree.config.tiles3DMaxMemory )
         Potree.settings.tiles3DMaxMemory = THREE.Math.clamp(tiles3DMaxMemory , 30, Potree.config.tiles3DMaxMemory )
         
         
         
         
         
         
+        //还存在的问题:仍然有隐患,因为没用到真实缓存的大小: tiles3DMemoryWeight  laserMemoryWeight, 它们比真实可见的要多。不使用是因为它们无法反应出实际需要的内存量,缓存是只增不减
         //obj等普通mesh限制不了
         //obj等普通mesh限制不了
-        console.log(ratio, tiles3DMaxMemory)
+        
+        
+        //console.log('objWeight',objWeight.toFixed(1), 'laserMemoryWeight',laserMemoryWeight.toFixed(1), 'tiles3DWeight',tiles3DWeight.toFixed(1),  'pointBudget',Potree.pointBudget, 'tiles3DMaxMemory',tiles3DMaxMemory)
+        
+        
+        //总内存 = 内存占用空间+图片缓存 , obj的缓存比较多在图片中
+        
         
         
     },
     },
 }   
 }   

+ 9 - 4
src/custom/settings.js

@@ -66,13 +66,12 @@ const config = {//配置参数   不可修改
     
     
     urls:{
     urls:{
         //localTextures:'../resources/textures/', 
         //localTextures:'../resources/textures/', 
-        prefix1: 'https://laser-oss.4dkankan.com',//oss
+        prefix1: 'https://laser-oss.4dkankan.com',//oss 
         prefix2: 'https://testlaser.4dkankan.com',
         prefix2: 'https://testlaser.4dkankan.com',
         prefix3: 'https://4dkk.4dage.com',
         prefix3: 'https://4dkk.4dage.com',
         prefix4: 'https://uat-laser.4dkankan.com',//test.4dkankan
         prefix4: 'https://uat-laser.4dkankan.com',//test.4dkankan
-        prefix5: 'https://laser.4dkankan.com',
-        prefix6: 'https://mix3d.4dkankan.com/backend',
-        
+        prefix5: 'https://laser.4dkankan.com/backend',
+        prefix6: 'https://mix3d.4dkankan.com/backend', 
     },
     },
     
     
     transitionsTime:{
     transitionsTime:{
@@ -443,6 +442,12 @@ let settings = {//设置   可修改
  
  
 settings.isLocalhost = settings.prefix.includes('localhost')
 settings.isLocalhost = settings.prefix.includes('localhost')
 
 
+settings.isFormal = browser.urlHasValue('formal')//正式环境 本地测试
+if(settings.isFormal){ 
+    settings.urls.prefix = settings.urls.prefix5
+    settings.webSite = 'datav1'
+}
+
 console.log('2023-1')
 console.log('2023-1')
  
  
 export {config, settings}
 export {config, settings}

+ 1 - 0
src/custom/viewer/ViewerNew.js

@@ -164,6 +164,7 @@ export class Viewer extends ViewerBase{
         this.objs = new THREE.Object3D
         this.objs = new THREE.Object3D
         
         
         this.testMaxNodeCount = 0
         this.testMaxNodeCount = 0
+        this.tiles3dVisiVCount = 0
         //this.lastPos = new THREE.Vector3(Infinity,Infinity,Infinity) 
         //this.lastPos = new THREE.Vector3(Infinity,Infinity,Infinity) 
 		//-------------
 		//-------------