|
@@ -62,7 +62,7 @@ let MergeEditor = {
|
|
|
viewer.scene.scene.add(this.boxHelper)
|
|
|
Potree.Utils.updateVisible(this.boxHelper,'unselect',false)
|
|
|
|
|
|
-
|
|
|
+ this.lastMemoryState = {}
|
|
|
|
|
|
|
|
|
this.history = new History({
|
|
@@ -332,9 +332,10 @@ let MergeEditor = {
|
|
|
}) */
|
|
|
|
|
|
|
|
|
- viewer.addEventListener('camera_changed',()=>{
|
|
|
- Common.intervalTool.isWaiting('updateMemoryUsage', ()=>{
|
|
|
- this.updateMemoryUsage()
|
|
|
+ viewer.addEventListener('camera_changed',()=>{//其实静止时内存也会变,因为在加载
|
|
|
+ this.lastMemoryState.history = [] //clear
|
|
|
+ Common.intervalTool.isWaiting('updateMemoryUsage', ()=>{
|
|
|
+ return this.updateMemoryUsage()
|
|
|
}, 1000)
|
|
|
})
|
|
|
|
|
@@ -446,6 +447,35 @@ let MergeEditor = {
|
|
|
let models = this.getAllObjects()
|
|
|
return models.find(e=>e.dataset_id == id)
|
|
|
},
|
|
|
+
|
|
|
+ changeModelPointCount(object, type){
|
|
|
+ let posCount , texArea
|
|
|
+ if(type == 'add'){
|
|
|
+ let o = viewer.getObjectPointCount(object)
|
|
|
+ posCount = o.posCount, texArea = o.texArea
|
|
|
+ object.posCount = posCount, object.texArea = texArea
|
|
|
+ }else{
|
|
|
+ posCount = -object.posCount, texArea = -object.texArea
|
|
|
+ }
|
|
|
+
|
|
|
+ viewer.memoryModelCountInfo.otherPosCount += posCount
|
|
|
+ viewer.memoryModelCountInfo.otherTexArea += texArea
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ modelAdded(model){
|
|
|
+ /* model.addEventListener('isVisible',(e)=>{
|
|
|
+ if(e.reason == "overlinePass")return
|
|
|
+ //console.log(e)
|
|
|
+ viewer.addEventListener('update',()=>{ //下一次更新结束后
|
|
|
+ this.updateMemoryUsage()
|
|
|
+ },{once:true})
|
|
|
+ }) */
|
|
|
+ if(model.fileType != '3dTiles'){
|
|
|
+ this.changeModelPointCount(model,'add')
|
|
|
+ }
|
|
|
+ this.updateMemoryUsage()
|
|
|
+ },
|
|
|
removeModel(model){
|
|
|
if(this.selected == model) this.selectModel(null)
|
|
|
let dispose = (e)=>{
|
|
@@ -460,13 +490,27 @@ let MergeEditor = {
|
|
|
dispose(e)
|
|
|
})
|
|
|
viewer.objs.remove(model)
|
|
|
- this.updateMemoryUsage()
|
|
|
+
|
|
|
}
|
|
|
|
|
|
model.panos?.slice().forEach(e=>{
|
|
|
e.dispose()
|
|
|
})
|
|
|
viewer.images360.tileDownloader.setPanoData(viewer.images360.panos, [] );
|
|
|
+
|
|
|
+ if(model.fileType == '3dTiles'){
|
|
|
+ model.traverse(child=>{
|
|
|
+ if(child.runtime){
|
|
|
+ child.runtime.getTileset().destroy()
|
|
|
+ return {stopContinue:true}
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ if(model.fileType != '3dTiles'){
|
|
|
+ this.changeModelPointCount(model,'sub')
|
|
|
+ }
|
|
|
+ this.updateMemoryUsage()
|
|
|
},
|
|
|
|
|
|
selectModel(model, state=true, fitBound, by2d){
|
|
@@ -775,20 +819,11 @@ let MergeEditor = {
|
|
|
|
|
|
},
|
|
|
|
|
|
- modelAdded(model){
|
|
|
- model.addEventListener('isVisible',(e)=>{
|
|
|
- if(e.reason == "overlinePass")return
|
|
|
- //console.log(e)
|
|
|
- viewer.addEventListener('update',()=>{ //下一次更新结束后
|
|
|
- this.updateMemoryUsage()
|
|
|
- },{once:true})
|
|
|
- })
|
|
|
- this.updateMemoryUsage()
|
|
|
- },
|
|
|
|
|
|
|
|
|
|
|
|
- updateMemoryUsage(){
|
|
|
+
|
|
|
+ updateMemoryUsage1(){
|
|
|
|
|
|
//obj暂时不管其贴图大小, 因为顶点造成的不仅是内存还有卡顿所以先只看顶点
|
|
|
const maxMemory = Potree.config.tiles3DMaxMemory + 100 //M 实际估计是这个的10倍
|
|
@@ -797,7 +832,10 @@ let MergeEditor = {
|
|
|
const eachVisiCPointWeight = eachCloudPointWeight * 5 // 或 maxMemory / (6*1000*1000) 大概值接近 (再除以一个数是因为显示的要比内存中的耗更多资源
|
|
|
const eachGltfPosWeight = 100/1000/1000 //M 每个顶点pos是3*4个字节?法线3*4和uv2*4 其实还有贴图
|
|
|
let posCount=0
|
|
|
-
|
|
|
+
|
|
|
+ let eachTexPxWeight = 1 / 10 / 1000 / 1000 //不知道“图片缓存”会不会引起崩溃, 它不在“内存占用空间”中, 所以单位weight值设置小一点
|
|
|
+ let panosWeight = viewer.images360.panos.filter(e=>e.depthTex).length * 0.7 + viewer.images360.tileDownloader.tilesCount * 512*512 * eachTexPxWeight //深度图和全景图
|
|
|
+ let texArea = 0
|
|
|
|
|
|
viewer.objs.children.forEach(e=>{
|
|
|
if(!e.visible)return
|
|
@@ -805,28 +843,35 @@ let MergeEditor = {
|
|
|
e.traverse((mesh)=>{
|
|
|
if(mesh.geometry){
|
|
|
posCount += mesh.geometry.attributes.position.count
|
|
|
- }
|
|
|
+ }
|
|
|
+ if(mesh.material?.map){
|
|
|
+ texArea += mesh.material?.map.image.width * mesh.material?.map.image.height
|
|
|
+ }
|
|
|
})
|
|
|
}else if(e.fileType == '3dTiles'){
|
|
|
|
|
|
}
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
//获取点云的内存限制
|
|
|
- let objWeight = posCount*eachObjPosWeight
|
|
|
+ let objWeight = posCount*eachObjPosWeight + texArea * eachTexPxWeight
|
|
|
let laserWeight = Potree.numVisiblePoints * eachCloudPointWeight //点云实际显示所占大小
|
|
|
let laserMemoryWeight = Potree.lru.numPoints * eachCloudPointWeight //点云所使用内存大小
|
|
|
- let tiles3DWeight = viewer.tiles3dVisiVCount * eachGltfPosWeight //M 3dTiles所占内存大小
|
|
|
+ let tiles3DWeight = (viewer.visiVertexCount || 0) * 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
|
|
|
+ let rest = maxMemory - objWeight - tiles3DWeight - panosWeight
|
|
|
Potree.pointBudget = THREE.Math.clamp(Math.round(rest/eachVisiCPointWeight), Potree.config.pointDensity.low.pointBudget, 1.5*Potree.config.pointDensity.high.pointBudget)
|
|
|
-
|
|
|
+ //Potree.settings.maxLRUPoints
|
|
|
//获取3dTiles的内存限制
|
|
|
- let tiles3DMaxMemory = maxMemory - Math.round(objWeight + laserWeight)
|
|
|
- Potree.settings.tiles3DMaxMemory = THREE.Math.clamp(tiles3DMaxMemory , 30, Potree.config.tiles3DMaxMemory )
|
|
|
+ let tiles3DMaxMemory = maxMemory - Math.round(objWeight + laserWeight + panosWeight)
|
|
|
+
|
|
|
+ window.cesiumViewer && (tiles3DMaxMemory-=30)
|
|
|
+
|
|
|
+ Potree.settings.tiles3DMaxMemory = THREE.Math.clamp(tiles3DMaxMemory , 30, Potree.config.tiles3DMaxMemory )
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -839,10 +884,262 @@ let MergeEditor = {
|
|
|
|
|
|
//总内存 = 内存占用空间+图片缓存 , obj的缓存比较多在图片中
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ //尽量使任务管理器里的内存占用空间不超过2G
|
|
|
+ /*
|
|
|
+ 崩溃历史:
|
|
|
+
|
|
|
+ cesium容易先崩溃,并弹窗报An error occurred while rendering. Rendering has stopped.
|
|
|
+ 体育中心:http://192.168.0.140/index.html?caseId=1&app=1&token=1#/fuseEdit/path
|
|
|
+ 罗敏电脑崩溃 ,报了ces的崩溃错误。内存占用空间2196M, memory.usedJSheapSize:1812M 崩溃时正在外部浏览模型(导览崩溃过),可能是3dtiles
|
|
|
+
|
|
|
+
|
|
|
+ */
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 0.0000621791536865594
|
|
|
+ 0.00009005265640549425
|
|
|
+ 0.00007493883414610654
|
|
|
+ 0.00006503514775640251
|
|
|
+ 0.000063906496015 */
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ updateMemoryUsage(){//新 注意 模型即使隐藏也不会降低内存占用,只是会降低卡顿。 未支持3dgs
|
|
|
+ //疑问:1 在不超过最大内存的前提下会因为显示太多模型崩溃吗? 2如何获知每个浏览器最大内存支持?看了一圈,jsHeapSizeLimit都一样怎么办?
|
|
|
+ //3dtiles(或模型)的大小是直接用文件大小还是根据点和贴图尺寸计算呢,感觉它会分成两部分,加载的和显示的,都需要考虑。
|
|
|
+ //obj暂时不管其贴图大小, 因为顶点造成的不仅是内存还有卡顿所以先只看顶点
|
|
|
+ if(window.stopUpdateM) return
|
|
|
+
|
|
|
+ //let start = performance.now();
|
|
|
+
|
|
|
+ let old = {
|
|
|
+ pointBudget : Potree.pointBudget,
|
|
|
+ tiles3DMaxMemory: Potree.settings.tiles3DMaxMemory,
|
|
|
+ maxLRUPoints : Potree.settings.maxLRUPoints
|
|
|
+ }
|
|
|
+
|
|
|
+ const maxMemory = 1500 //1500 //M 整体占用内存限制 (不考虑峰值,要等静止后退下来的值) //什么都不加载可能就占了300M
|
|
|
+ const eachObjPosWeight = 100/1000/1000 //M 每个顶点pos是3*4个字节?法线3*4和uv2*4 + faceIndex比较难说
|
|
|
+ const eachCloudPointWeight = 70/1000/1000 //M 每个点 pos + 颜色 + 法线 大概 根据测试算出来也是这个值 0.00007
|
|
|
+ //const eachVisiCPointWeight = eachCloudPointWeight * 5 // 或 maxMemory / (6*1000*1000) 大概值接近 (再除以一个数是因为显示的要比内存中的耗更多资源
|
|
|
+ const eachTexPxWeight = 1 / 10 / 1000 / 1000 //每个模型都不一样只能取个大概
|
|
|
+ const eachTexPxWeightTiles = eachTexPxWeight * 1.5 //感觉3dtiles的比glb和obj都高很多,是因为文件还在缓存里吗
|
|
|
+
|
|
|
+
|
|
|
+ let posCount=0, posCount3dTiles = 0, visiPosCount = 0
|
|
|
+
|
|
|
+
|
|
|
+ let panosWeight = 0.1 * (viewer.images360.panos.filter(e=>e.depthTex).length * 0.7 + viewer.images360.tileDownloader.tilesCount * 512*512 * eachTexPxWeight) //深度图和全景图(但似乎是额外放图片缓存里?因为没有增加tex, panoExit后就dispose了, 所以乘以一个小系数。担心图片缓存也可能导致崩溃)
|
|
|
+ //let texArea = 0, texArea3dTiles = 0, visiTexArea = 0
|
|
|
+ //texArea = viewer.memoryModelCountInfo.otherTexArea + viewer.memoryModelCountInfo.tileTexArea
|
|
|
+ //posCount = viewer.memoryModelCountInfo.otherPosCount + viewer.memoryModelCountInfo.tilePosCount
|
|
|
+ //posCount3dTiles = viewer.memoryModelCountInfo.tilePosCount
|
|
|
+ //texArea3dTiles = viewer.memoryModelCountInfo.tileTexArea
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let otherModelWeight = viewer.memoryModelCountInfo.otherPosCount*eachObjPosWeight + viewer.memoryModelCountInfo.otherTexArea * eachTexPxWeight
|
|
|
+ let tilesWeight = (viewer.memoryModelCountInfo.tilePosCount*eachObjPosWeight + viewer.memoryModelCountInfo.tileTexArea * eachTexPxWeightTiles) * 1.5 //3dtiles太占内存了
|
|
|
+ let modelWeight = tilesWeight + otherModelWeight //posCount*eachObjPosWeight + texArea * eachTexPxWeight
|
|
|
+ //为何obj、glb过后会降很多,而3dtiles降的很少? 不过考虑到glb更卡,且加载瞬间确实占用高,还是不把otherModelWeight改少了吧
|
|
|
+
|
|
|
+ Potree.tilesWeight = tilesWeight
|
|
|
+ Potree.modelWeight = modelWeight//所有模型
|
|
|
+ //Potree.modelVisiWeight = visiPosCount*eachObjPosWeight + visiTexArea * eachTexPxWeight
|
|
|
+
|
|
|
+ //经测试,发现模型并不会因为不可见而降低内存,3dtiles加载满了之后拉远,可见weight下降了但内存没降。
|
|
|
+ //so,需要测试崩溃是否只与内存有关,如果内存爆了,但都不可见,非常流畅,还会崩溃吗
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let laserVisiWeight = Potree.numVisiblePoints * eachCloudPointWeight //点云实际显示所占大小
|
|
|
+ let laserWeight = Potree.lru.numPoints * eachCloudPointWeight //点云所使用内存大小
|
|
|
+ Potree.laserWeight = laserWeight
|
|
|
+
|
|
|
+
|
|
|
+ let fixedPart = modelWeight - tilesWeight + panosWeight + (window.cesiumViewer ? 30:0) //ces:刚加载时60,静止一段时间后20
|
|
|
+ Potree.allWeight = Potree.laserWeight + fixedPart + tilesWeight
|
|
|
+ let tiles3dMemoryUsage = viewer.tiles3dMemoryUsage/1024/1024
|
|
|
+
|
|
|
+
|
|
|
+ let overRatio = Potree.allWeight / maxMemory
|
|
|
+
|
|
|
+ let visiRatio1 = posCount3dTiles == 0 ? Infinity : viewer.visiVertexCount / posCount3dTiles
|
|
|
+ let visiRatio2 = Potree.lru.numPoints == 0 ? Infinity : Potree.numVisiblePoints / Potree.lru.numPoints
|
|
|
+ let resolved
|
|
|
+
|
|
|
+ let restMemory = maxMemory - fixedPart //去除固定的part后
|
|
|
+
|
|
|
+
|
|
|
+ if(overRatio > 1){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ const MinRestMemory = 400
|
|
|
+ if(restMemory < MinRestMemory){
|
|
|
+ Common.intervalTool.isWaiting('updateMemoryUsage', ()=>{
|
|
|
+ let warnText
|
|
|
+ if(this.lastMemoryState.restMemory < 0){
|
|
|
+ warnText = '固定内存已经超额!没有剩余空间给点云和3dtiles。'
|
|
|
+ }else if(this.lastMemoryState.restMemory < MinRestMemory){
|
|
|
+ warnText = '固定内存过多!'
|
|
|
+ }
|
|
|
+ if(warnText){
|
|
|
+ warnText += '请减少glb类模型, 当前固定内存占用大小:' + fixedPart
|
|
|
+ console.error(warnText)
|
|
|
+ }
|
|
|
+ }, 10000)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(visiRatio1 < visiRatio2 || Potree.lru.numPoints <= Potree.config.pointDensity.low.pointBudget / 10 * 1.1 ){//占比小的需要缩减缓存容器
|
|
|
+
|
|
|
+ if(Potree.settings.tiles3DMaxMemory < tiles3dMemoryUsage / 2 && this.lastMemoryState.tiles3dMemoryUsage == tiles3dMemoryUsage //已经很难减少了,这时候tiles3DMaxMemory很可能降到个位数
|
|
|
+ || Potree.settings.tiles3DMaxMemory < 2){
|
|
|
+ resolved = false
|
|
|
+ }else{
|
|
|
+ Potree.settings.tiles3DMaxMemory = Math.min(tiles3dMemoryUsage, Potree.settings.tiles3DMaxMemory)//先降到已使用的数据量
|
|
|
+ Potree.settings.tiles3DMaxMemory > 1 && (Potree.settings.tiles3DMaxMemory *= 0.8 ) //注意,降低该值不一定会降低 tiles3dMemoryUsage,只有后续改变sse才行 viewer.tiles3dMemoryUsage / tiles3DMaxMemory 可能大于1
|
|
|
+ resolved = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!resolved){// visiRatio1 > visiRatio2
|
|
|
+
|
|
|
+ if( visiRatio2 > 0.9){//压缩太小了,或者说没什么缓存就超额了,只能继续减少显示个数
|
|
|
+ if(Potree.pointBudget < Potree.config.pointDensity.low.pointBudget){
|
|
|
+ //console.error('Potree.pointBudget已经很小了!', Potree.pointBudget)
|
|
|
+ }else{
|
|
|
+ Potree.pointBudget *= 0.85
|
|
|
+ resolved = true
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ Potree.pointBudget = THREE.Math.clamp(Potree.numVisiblePoints, Potree.config.pointDensity.low.pointBudget / 10, Potree.pointBudget*0.8 )//先往降到可见数量方向降 (当画面中可见点确实很少时允许降低到low之下)
|
|
|
+
|
|
|
+ Potree.settings.maxLRUPoints = Math.min(Potree.lru.numPoints, Potree.settings.maxLRUPoints);//先降到已使用的数量
|
|
|
+ Potree.settings.maxLRUPoints *= 0.8
|
|
|
+ resolved = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{//恢复部分好难写
|
|
|
+ //优先恢复实际使用(可见)内存,然后是缓存
|
|
|
+ //额外缓存少的,实际使用内存被压缩的概率也大
|
|
|
+ //visiRatio1 == Infinity && (visiRatio1 = 0) //因这里大的才会被改所以改一下
|
|
|
+
|
|
|
+ visiRatio1 *= tiles3dMemoryUsage / Potree.settings.tiles3DMaxMemory //用point数量有时候不准,明明内存不够了不可见的tile还存在,所以×memory的占比
|
|
|
+ visiRatio2 = Potree.pointBudget == 0 ? 0 : Potree.numVisiblePoints / Potree.pointBudget //使用率越高,说明越需要内存. 因为恢复时先提高使用内存所以改一下
|
|
|
+
|
|
|
+ let r = Math.min(1, visiRatio1 , visiRatio2 ) //如果另一个visiRatio 很小,s就可以再小一些,使内存超过一点,然后朝另一方倾斜,另一方去缩减
|
|
|
+ let s = 1 - Math.max(0.8, overRatio * r )
|
|
|
+
|
|
|
+ //太难判断是哪个更需要内存了,所以两个都涨吧
|
|
|
+
|
|
|
+
|
|
|
+ if(visiRatio2 > visiRatio1){
|
|
|
+ let s_ = visiRatio2 / (visiRatio1 + visiRatio2) * s + 1
|
|
|
+ const addCount = 500000 * s_
|
|
|
+ if(Potree.pointBudget < Potree.config.pointDensity.high.pointBudget*0.9){
|
|
|
+ Potree.pointBudget += addCount
|
|
|
+ }else{
|
|
|
+ Potree.settings.maxLRUPoints += addCount
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(Potree.settings.tiles3DMaxMemory < Potree.config.tiles3DMaxMemory ){
|
|
|
+ let s_ = visiRatio1 / (visiRatio1 + visiRatio2) * s + 1
|
|
|
+ const addCount = 20 * s_
|
|
|
+ Potree.settings.tiles3DMaxMemory += addCount
|
|
|
+ Potree.settings.tiles3DMaxMemory = Math.min(Potree.settings.tiles3DMaxMemory, Potree.config.tiles3DMaxMemory)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ resolved = true
|
|
|
+ }
|
|
|
+
|
|
|
+ let min = overRatio > 1 ? 1.1 : 1.5, max = 5;
|
|
|
+ Potree.settings.maxLRUPoints = THREE.Math.clamp(Potree.settings.maxLRUPoints , Potree.pointBudget * min, Potree.pointBudget * max)
|
|
|
+
|
|
|
+ //压缩时先压缩缓存,然后是使用内存; 恢复时相反。
|
|
|
+
|
|
|
+ //3dtiles不像点云那样可以在加载时拦截,使不高于tiles3DMaxMemory,只能自动动态调节maxSSE,所以有可能调节完还是降低不了
|
|
|
+
|
|
|
+ //一次只更新一点,一点点调节,因为可能不是一个原因造成
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let changed
|
|
|
+ if(old.pointBudget != Potree.pointBudget || old.tiles3DMaxMemory != Potree.settings.tiles3DMaxMemory || old.maxLRUPoints != Potree.settings.maxLRUPoints ){
|
|
|
+
|
|
|
+ if(old.tiles3DMaxMemory != Potree.settings.tiles3DMaxMemory){
|
|
|
+ viewer.setAllTilesets(model=>{
|
|
|
+ model.runtime.getTileset().nextForceUpdate = true
|
|
|
+ model.runtime.getTileset().needRenderNext = true
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ viewer.dispatchEvent('content_changed')
|
|
|
+ }
|
|
|
+ changed = true
|
|
|
+ }
|
|
|
+
|
|
|
+ {
|
|
|
+
|
|
|
+ let mSSE = math.linearClamp(Potree.fpsRendered2, [2, 52], [500, 70]) //有效降低卡顿 和贴图变白概率。越卡越提高msse
|
|
|
+ let r = tiles3dMemoryUsage / Potree.settings.tiles3DMaxMemory
|
|
|
+ viewer.setAllTilesets(model=>{
|
|
|
+ let tileset = model.runtime.getTileset()
|
|
|
+ tileset.options.initialMaxSSE = mSSE
|
|
|
+ let e = tileset.options.maximumScreenSpaceError * THREE.Math.clamp(r, 0.8, 1.2)
|
|
|
+ e = THREE.Math.clamp(e, mSSE, mSSE+400) //如果有很卡的模型可能需要1000,但太高了降回来很慢,就假设模型都正常的吧
|
|
|
+ tileset.options.maximumScreenSpaceError = e
|
|
|
+
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ //针对很卡的设备:(卡的也容易崩溃)
|
|
|
+ Potree.config.pointDensity.high.pointBudget = math.linearClamp(Potree.fpsRendered2, [2, 50], [1e6, 6e6])
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ let history = this.lastMemoryState.history || []
|
|
|
+ history.push(overRatio)
|
|
|
+ this.lastMemoryState = {
|
|
|
+ tiles3dMemoryUsage,
|
|
|
+ history,
|
|
|
+ restMemory
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
+ //console.log('cost', performance.now() - start)
|
|
|
+ return changed && ((overRatio > 1.1 || overRatio < 0.9) ||
|
|
|
+ history.slice(-7).length < 7 || history.slice(-7).some(overRatio=>overRatio > 1.1 || overRatio < 0.9) //后十个都在最大内存范围左右抖动,则不继续更新,直到相机变化
|
|
|
+ )
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //难点:要防止抖动,否则3dtiles的sse变大变小,相机静止时还在清晰和模糊间变来变去。好在点云是可以较精细调节,tile是间接控制的
|
|
|
+
|
|
|
+ //模型删除后还会占用一定内存,尤其是3dtile几乎降不了,怎么回事?是否删除的模型还要算进来
|
|
|
},
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
setGroundPlaneImg(src,scale,angle){//设置地面图
|
|
|
|
|
|
this.goundScale = scale || 1, this.goundAngle = angle || 0
|
|
@@ -890,17 +1187,29 @@ let MergeEditor = {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ /*
|
|
|
+ watch:
|
|
|
+ performance.memory.usedJSHeapSize / 1e6
|
|
|
+ Potree.settings.tiles3DMaxMemory
|
|
|
+ viewer.tiles3dMemoryUsage
|
|
|
+ Potree.tilesWeight
|
|
|
+ Potree.modelWeight
|
|
|
+ Potree.modelVisiWeight
|
|
|
+ Potree.allWeight
|
|
|
+ Potree.lru.numPoints
|
|
|
+ Potree.pointBudget
|
|
|
+ Potree.numVisiblePoints
|
|
|
+ Potree.settings.maxLRUPoints
|
|
|
+
|
|
|
+
|
|
|
+ */
|
|
|
|
|
|
export default MergeEditor
|
|
|
|
|
|
-
|
|
|
-/*
|
|
|
+
|
|
|
+/*
|
|
|
|
|
|
-note:
|
|
|
+note:
|
|
|
|
|
|
要注意getHoveredElements只在getIntersect时才使interactables包含加载的model, 也就是model上不能有使之成为interactables的事件,否则在鼠标hover到模型上开始转动的一瞬间很卡。
|
|
|
|
|
@@ -910,4 +1219,9 @@ window.pano2 = viewer.modules.PanoEditor.selectedPano //选中第二个点后输
|
|
|
viewer.modules.PanoEditor.linkChange(window.pano1, window.pano2, 'remove') //断开链接
|
|
|
|
|
|
|
|
|
+如果直接刷新,内存管理器中的内存会有之前的残留。不知道是不是真实的加入这次的内存了。
|
|
|
+并且,如果第一次加载的是几乎不占内存的模型,如glb,内存也会一下子涨30,不过等一会儿会降。4M的3dtiles会涨60. 每次加载模型后都会内存突增,但过后会降。 为何obj、glb过后会降很多,而3dtiles降的很少。?
|
|
|
+
|
|
|
+国产系统8192贴图直接出错,4096的贴图过多也出错。texImage: Driver ran out of memory during upload.
|
|
|
+
|
|
|
*/
|