فهرست منبع

温度颜色分段可调

xzw 2 ماه پیش
والد
کامیت
168d44cc32

+ 1 - 0
examples/4dkk.html

@@ -29,6 +29,7 @@
 	<script src="../../libs/jstree/jstree.js"></script>
 	<script src="../../build/potree/potree.js"></script>
 	<script src="../../libs/plasio/js/laslaz.js"></script>
+	<script src="../../libs/other/UPNG.js"></script>
 	
 	<!-- <script src="../../libs/stats.js/stats.js"></script> -->
 	<div class="potree_container" style="position: absolute; width: 100%; height: 100%; left: 0px; top: 0px; ">

+ 12 - 3
src/custom/materials/ModelTextureMaterial.js

@@ -298,13 +298,22 @@ let shader = {
                 //注:未加载好的话,depth为0,导致第一次漫游过去的时候许多mesh会立刻被遮挡,所以要确保加载完
             #endif
             
-            
+            int unpack16(vec2 channels){
+                return int(round(channels.y * 255.0)) + (int(round(channels.x * 255.0)) << 8)  ;   //some phone needs round,such as vivo x30
+            }
             
             int getIntFromColor(sampler2D map, vec3 dir){//uint16-> int  0-65536 
+                //float texWidth = 1024.;
                 vec2 uv = getSamplerCoord2(dir.xyz);  
                 uv.x -= 0.25;    
                 vec4 color = texture2D(map, uv); 
-                return int(round(color.r * 255.0)) + (int(round(color.g * 255.0)) << 8)  ;   //some phone needs round,such as vivo x30
+                return unpack16(color.rg); 
+                /* if( fract(uv.x * texWidth) > 0.5){
+                    return unpack16(color.rg);
+                }else{
+                    return unpack16(color.ba);
+                }   */
+                 
             } 
             
             
@@ -465,7 +474,7 @@ export default class ModelTextureMaterial extends THREE.RawShaderMaterial {
         let {vs,fs} = Common.changeShaderToWebgl2(shader.vertexShader, shader.fragmentShader, 'RawShaderMaterial')
         if(!Potree.settings.isWebgl2){
             defines['round(x)'] = 'floor(x + 0.5)'   //webgl1 unsupport round
-            fs = fs.replace('int(round(color.g * 255.0)) << 8', 'int(round(color.g * 255.0 * pow(2.0, 8.0)))')  //unsupport <<
+            fs = fs.replace('int(round(channels.x * 255.0)) << 8', 'int(round(channels.x * 255.0 * pow(2.0, 8.0)))')  //unsupport <<
         }
         super({
             fragmentShader: fs,

+ 14 - 1
src/custom/modules/panos/Images360.js

@@ -71,7 +71,7 @@ export class Images360 extends THREE.EventDispatcher{
          
         this.cubePanos = [];
         this.fastTranMaskPass = new FastTranPass(viewer.renderer)
-        
+        this.waitDelTexDataList = []
         {
             this.cube = new THREE.Mesh(new THREE.BoxBufferGeometry(1,1,1,1),new ModelTextureMaterial());
             Potree.Utils.updateVisible(this.cube,'showSkybox', false )
@@ -762,6 +762,19 @@ export class Images360 extends THREE.EventDispatcher{
                 } 
             }
         }) 
+        
+        this.cube.onBeforeRender = ()=>{
+            this.waitDelTexDataList.slice().forEach(tex=>{
+                if( viewer.renderer.properties.get(tex)?.__webglTexture){
+                    delete tex.data 
+                    //console.log('delete tex.data',tex.image.src) 
+                    let index = this.waitDelTexDataList.indexOf(tex)
+                    this.waitDelTexDataList.splice(index,1)
+                }
+            })
+              
+        }
+         
   
 	}; 
     

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

@@ -372,7 +372,7 @@ class Panorama extends THREE.EventDispatcher{
                         groups2.sort((b,a)=>{return a.score - b.score})
                         range[name+'Pixel'] = groups2[0]?.center  
                         //range[name+'PixelGroup'] = groups2
-                        console.log('groups2', this.id, name,groups2)
+                        //console.log('groups2', this.id, name,groups2)
                     })  
                     
                 }
@@ -381,6 +381,11 @@ class Panorama extends THREE.EventDispatcher{
                 viewer.gatherTempRange(type,range)
                 
             }
+            
+             
+            
+            
+            this.images360.waitDelTexDataList.push(texture)
             this.dispatchEvent({type:'loaded_'+type,  loaded:true})
             this.images360.dispatchEvent({type:'loaded_'+type,  pano:this})
             this[type+'Loading'] = false 

+ 12 - 12
src/custom/utils/Common.js

@@ -698,28 +698,28 @@ var Common = {
             }).then(arrayBuffer => { //文件数据
                 const png = UPNG.decode(arrayBuffer); //解析出像素数据
                 
-                let pixelCount = png.width * png.height
-                let data = new Uint8Array(pixelCount * 4)
-                
+                let pixelCount = png.width * png.height  
+                let data = new Uint8Array(pixelCount * 4)   
                 
                 let view = new DataView(data.buffer);
-                for(let i=0;i<pixelCount;i++){ //将uint16的只有两个byte的扩充到四个byte,因为贴图只支持4个byte的
+                for(let i=0;i<pixelCount;i++){ //将uint16的只有两个byte的扩充到四个byte,因单通道webgl1需要支持OES_texture_half_float,万一不支持……。
                     let r = png.data[i*2]
                     let g = png.data[i*2+1]
-                    data[i*4+0] = g //反了
-                    data[i*4+1] = r 
-                    data[i*4+2] = data[i*4+3] = 255; //无用值填充
+                    data[i*4+0] = r  
+                    data[i*4+1] = g 
+                    data[i*4+2] = data[i*4+3] = 255; //无用值填充    return unpack16(color.rg);
                     
                     if(pixelFun){
-                        pixelFun(view.getUint16(i*4,true), i , pixelCount) //原值
+                        pixelFun(view.getUint16(i*4/* ,true */), i , pixelCount) //原值
                     }
                     
-                }
-                texture.image.data = data
-                texture.image.width = png.width;
+                }  
+                texture.image.data = data 
+                texture.image.width = png.width  ;
                 texture.image.height = png.height; 
                 texture.image.src = src 
-                
+                /* texture.wrapS = THREE.ClampToEdgeWrapping
+                texture.wrapT = THREE.ClampToEdgeWrapping */
                 texture.needsUpdate = true;
                  
                 onLoad && onLoad()

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

@@ -6671,7 +6671,10 @@ export class Viewer extends ViewerBase{
     
     
     
-    
+    changeHotGradient(segs){ 
+        Gradients.ir = segs 
+        this.switchHotType()
+    }
      
     
 };