|
@@ -30,7 +30,7 @@ class DepthImageSampler extends THREE.EventDispatcher{
|
|
|
}
|
|
|
|
|
|
changeImg(img, pano){
|
|
|
-
|
|
|
+ console.warn('changeImg', pano.id)
|
|
|
this.pano = pano
|
|
|
let item = this.imgDatas.find(p=>p.pano == pano)
|
|
|
if(/* this.img == img || */item){
|
|
@@ -42,28 +42,32 @@ class DepthImageSampler extends THREE.EventDispatcher{
|
|
|
//console.log('重复使用',item.pano.id)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
- viewer.addTimeMark('depthSampler','start')
|
|
|
- this.canvas.width = img.width
|
|
|
- this.canvas.height = img.height
|
|
|
- this.context.drawImage(img, 0, 0)
|
|
|
- let data = this.context.getImageData(0, 0, img.width , img.height ).data; //getImageData 1px时 : pc chrome 耗时0.01毫秒左右(排除第一次的50) , 但firefox: 4。但换贴图之后就多达5甚至几十
|
|
|
- //console.log('changeImg',pano.id )
|
|
|
- //this.img = img
|
|
|
-
|
|
|
-
|
|
|
- if(this.imgDatas.length >= this.maxDataCount){
|
|
|
- let old = this.imgDatas.find(e=>!this.nearPanos.includes(e.pano))
|
|
|
- //console.log('推出',old.pano.id)
|
|
|
- this.imgDatas.splice(this.imgDatas.indexOf(old), 1)//推出使用时间最早的一个非nearPano
|
|
|
- }
|
|
|
- this.imgDatas.push({pano, data})
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- this.dispatchEvent({type:'changeImg',pano})
|
|
|
- viewer.addTimeMark('depthSampler','end') //耗时chrome 25ms,firefox: 38ms, iphoneX:33ms
|
|
|
-
|
|
|
+ try{
|
|
|
+ viewer.addTimeMark('depthSampler','start')
|
|
|
+ this.canvas.width = img.width
|
|
|
+ this.canvas.height = img.height
|
|
|
+ this.context.drawImage(img, 0, 0)
|
|
|
+ let data = this.context.getImageData(0, 0, img.width , img.height ).data; //getImageData 1px时 : pc chrome 耗时0.01毫秒左右(排除第一次的50) , 但firefox: 4。但换贴图之后就多达5甚至几十
|
|
|
+ //console.log('changeImg',pano.id )
|
|
|
+ //this.img = img
|
|
|
+
|
|
|
+
|
|
|
+ if(this.imgDatas.length >= this.maxDataCount){
|
|
|
+ let old = this.imgDatas.find(e=>!this.nearPanos.includes(e.pano))
|
|
|
+ //console.log('推出',old.pano.id)
|
|
|
+ this.imgDatas.splice(this.imgDatas.indexOf(old), 1)//推出使用时间最早的一个非nearPano
|
|
|
+ }
|
|
|
+ this.imgDatas.push({pano, data})
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ this.dispatchEvent({type:'changeImg',pano})
|
|
|
+ viewer.addTimeMark('depthSampler','end') //耗时chrome 25ms,firefox: 38ms, iphoneX:33ms
|
|
|
+ }catch(e){
|
|
|
+ console.error(e ); //内存不足 Failed to execute 'getImageData' on 'CanvasRenderingContext2D': Out of memory at ImageData creation
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/* pano.depthData = {}
|