xzw 4 ay önce
ebeveyn
işleme
891ddcf882

+ 6 - 3
src/custom/modules/panos/Images360.js

@@ -15,6 +15,9 @@ import PanoRenderer from './tile/PanoRenderer.js'
 import TilePrioritizer from './tile/TilePrioritizer.js'  
 import {transitions, easing, lerp} from "../../utils/transitions.js";
 import DepthImageSampler from './DepthImageSampler.js' 
+import TempImageSampler from './TempImageSampler.js' 
+
+
 let {PanoSizeClass,Vectors,GLCubeFaces, PanoramaEvents} = Potree.defines
  
     
@@ -150,7 +153,7 @@ export class Images360 extends THREE.EventDispatcher{
         
         
         this.depthSampler = new DepthImageSampler(); 
- 
+        this.tempSampler = new TempImageSampler(); 
         
         
  
@@ -763,7 +766,7 @@ export class Images360 extends THREE.EventDispatcher{
             }
         }) 
         
-        this.cube.onBeforeRender = ()=>{
+       /*  this.cube.onBeforeRender = ()=>{ //现在需要显示鼠标所在温度,不能删了,除非改类似depthSampler
             this.waitDelTexDataList.slice().forEach(tex=>{
                 if( viewer.renderer.properties.get(tex)?.__webglTexture){
                     delete tex.data 
@@ -773,7 +776,7 @@ export class Images360 extends THREE.EventDispatcher{
                 }
             })
               
-        }
+        } */
          
   
 	}; 

+ 6 - 6
src/custom/modules/panos/Panorama.js

@@ -305,13 +305,13 @@ class Panorama extends THREE.EventDispatcher{
          
         let range = {min:Infinity, max:-Infinity, minPixel:null, maxPixel:null}  
         let pixels 
-        let getRangeFun = (type == 'ir' || type == 'temp') && function(uint16Value, index, pixelCount){ 
-            if(type == 'ir'){
+        let getRangeFun = (type == 'ir' || type == 'temp') && function(uint16Value, index, pixelCount){ //温度值是uint16Value/10
+            if(type == 'ir'){   
                 pixels || (pixels = new Uint16Array(pixelCount))
                 pixels[index] = uint16Value
             }
             
-            
+            //收集最大最小温度
             if(uint16Value != 0 && uint16Value < range.min){
                 range.min = uint16Value 
                 range.minPixel_ = index
@@ -342,7 +342,7 @@ class Panorama extends THREE.EventDispatcher{
                     
                    (['min','max']).forEach(name =>{
                         let value = range[name]
-                        let groups = []
+                        /* let groups = []
                         let isNeigh = (A,B)=>{
                             return (Math.abs(A.x - B.x)<=1 || Math.abs(A.x - B.x) == texture.image.width-1) && Math.abs(A.y - B.y)<=1
                         }
@@ -356,7 +356,7 @@ class Panorama extends THREE.EventDispatcher{
                                     break
                                 }
                             }
-                        } 
+                        }  
                         let groups2 = groups.filter(e=>e.length>1)
                         if(groups2.length < 3) groups2 = groups
                         groups2.forEach(group=>{//x的因边界不好写,就只判断y尽量接近中间且范围不大不小即可
@@ -370,7 +370,7 @@ class Panorama extends THREE.EventDispatcher{
                             group.center = group[Math.floor(group.length/2)] //忽略是否横向的中间
                         })
                         groups2.sort((b,a)=>{return a.score - b.score})
-                        range[name+'Pixel'] = groups2[0]?.center  
+                        range[name+'Pixel'] = groups2[0]?.center  */
                         //range[name+'PixelGroup'] = groups2
                         //console.log('groups2', this.id, name,groups2)
                     })  

+ 120 - 0
src/custom/modules/panos/TempImageSampler.js

@@ -0,0 +1,120 @@
+
+import * as THREE from "../../../../libs/three.js/build/three.module.js"; 
+import math from "../../utils/math.js";
+import browser from "../../utils/browser.js";
+
+ 
+
+class TempImageSampler extends THREE.EventDispatcher{
+    
+    constructor(){ 
+        super() 
+    }
+  
+     
+    getValue({data, width, height}, UVx, UVy, useNeighIfZero) {//根据图片像素获取深度值 
+        var x = Math.round(UVx * (width - 1))
+          , y = Math.round(UVy * (height - 1));
+        
+        let get = (x,y)=>{  
+            let blockIndex = width * y + x
+            let color = data.slice(blockIndex*4, (blockIndex+1)*4)
+            return color[1] + (color[0] << 8)           //为什么不是除以255见聊天记录.(验证过比点云的远一点点) 
+        }
+       
+        let value = get(x,y)
+        if(!value && useNeighIfZero){ //遇到过有的相隔很远且有阻挡的两个漫游点间居然depth为0,没有阻挡?但是周围点有四个非零。所以为了修正会飞到很远的点加个识别周围像素的depth 。 2024.3.19
+            
+            let results = [] 
+            let d = 0, sum = 0, count = 0, maxResDis = 1, padding = 2 //间隔
+            outer2: while(d++<maxResDis){
+                outer: for(let i=-d;i<=d;i++){
+                    for(let j=-d;j<=d;j++){
+                        if(i==-d || i==d || j==-d || j==d ){//外围
+                             let v2 = get(x+i*padding,y+j*padding)
+                             if(v2!=0){
+                                 results.push(v2)
+                             }
+                        }
+                    }
+                }
+            }
+            if(results.length){ 
+                value = results.reduce((w,c)=>{return w+c},0) / results.length 
+                //console.error('useNeighIfZero', results, depth)
+            }
+            //console.log('useNeighIfZero', results, depth)
+        }
+        value/=10
+        return {value,x,y}
+            
+        
+    } 
+
+
+    
+    
+    
+    sample( intersect,  type, currentPano, useNeighIfZero, celsius  ) {//通过和skybox的intersect得到真实的intersect的位置
+        if(!intersect)return
+        let uv 
+      
+        
+        if(intersect.uv){
+            uv = intersect.uv 
+        }else{
+            let origin = currentPano.position
+            let dir = intersect.dir || new THREE.Vector3().subVectors(intersect.point, origin).normalize()
+            //var uv = intersect.uv 
+            //let dirInPano = math.getNormalDir(dir, currentPano)//转化为考虑漫游点旋转的方向
+            
+            let dirInPano = dir.clone().applyMatrix4(currentPano.panoMatrix2Inverse).normalize(); //转化为考虑漫游点旋转的方向
+            uv = math.getUVfromDir(dirInPano)//转化为uv
+        }
+        
+        let image = currentPano[type+'Tex']?.image
+        if(!image)return console.error( 'no'+ type+'Tex', currentPano)
+        let {value,x,y} = this.getValue(image, uv.x, uv.y, useNeighIfZero);
+         
+        
+        celsius && (value = math.getCelsiusFromKelvin(value))
+        
+        if (!value ){
+            if(this.ignoreTopAndBtmHole){
+                return null 
+            }
+            const margin =  0.1
+            /* if(uv.y > 1-Potree.config.depthTexUVyLimit){//漫游点底部识别不到的区域,给一个地板高度
+                
+                depth = (currentPano.floorPosition.z - origin.z - margin) / dir.z
+                location.copy(dir).multiplyScalar(depth).add(origin);
+                let normal = new THREE.Vector3(0,0,1)
+                
+                return {location, normal, distance:depth,  uv} 
+            }else if(uv.y < Potree.config.depthTexUVyLimit){
+                let ceilZ = currentPano.getCeilHeight()
+                if(ceilZ == Infinity)return !1
+                else{ 
+                    depth = (ceilZ - origin.z - margin) / dir.z
+                    location.copy(dir).multiplyScalar(depth).add(origin);
+                    let normal = new THREE.Vector3(0,0,-1)
+                    return {location, normal, distance:depth,  uv} 
+                } 
+            } */
+            //console.log('无穷远')
+            return !1;  //应该是天空或模型外 , 因为很少有漫游点的地方还拍不到地板
+        }   
+        
+        console.log('value',  value )  
+        return {  value,  x,y, uv } 
+    }
+    
+     
+    
+}
+
+ 
+
+export default TempImageSampler
+
+