|
@@ -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的缓存比较多在图片中
|
|
|
|
+
|
|
|
|
|
|
},
|
|
},
|
|
}
|
|
}
|