xzw 1 năm trước cách đây
mục cha
commit
52e1121eb7

+ 198 - 3
libs/gaussian/gaussian-splats-3d.module.js

@@ -1,6 +1,201 @@
-import * as THREE from 'three';
-import { Ray as Ray$1, Plane, MathUtils, EventDispatcher, Vector3, MOUSE, TOUCH, Quaternion, Spherical, Vector2 } from 'three';
 
+
+
+
+import * as THREE from '../three.js/build/three.module.js'; 
+import { Ray as Ray$1, Plane, MathUtils, EventDispatcher, Vector3, MOUSE, TOUCH, Quaternion, Spherical, Vector2 } from '../three.js/build/three.module.js';
+ 
+ 
+/*  
+let Ray$1 = THREE.Ray, Plane = THREE.Plane, MathUtils = THREE.MathUtils,  EventDispatcher = THREE.EventDispatcher,
+    Vector3 = THREE.Vector3, MOUSE = THREE.MOUSE, TOUCH = THREE.TOUCH, Quaternion = THREE.Quaternion,
+    Spherical = THREE.Spherical, Vector2 = THREE.Vector2
+  */
+ 
+    //加 
+    {
+        function _generateTables() {
+
+            // float32 to float16 helpers
+
+            const buffer = new ArrayBuffer( 4 );
+            const floatView = new Float32Array( buffer );
+            const uint32View = new Uint32Array( buffer );
+
+            const baseTable = new Uint32Array( 512 );
+            const shiftTable = new Uint32Array( 512 );
+
+            for ( let i = 0; i < 256; ++ i ) {
+
+                const e = i - 127;
+
+                // very small number (0, -0)
+
+                if ( e < - 27 ) {
+
+                    baseTable[ i ] = 0x0000;
+                    baseTable[ i | 0x100 ] = 0x8000;
+                    shiftTable[ i ] = 24;
+                    shiftTable[ i | 0x100 ] = 24;
+
+                    // small number (denorm)
+
+                } else if ( e < - 14 ) {
+
+                    baseTable[ i ] = 0x0400 >> ( - e - 14 );
+                    baseTable[ i | 0x100 ] = ( 0x0400 >> ( - e - 14 ) ) | 0x8000;
+                    shiftTable[ i ] = - e - 1;
+                    shiftTable[ i | 0x100 ] = - e - 1;
+
+                    // normal number
+
+                } else if ( e <= 15 ) {
+
+                    baseTable[ i ] = ( e + 15 ) << 10;
+                    baseTable[ i | 0x100 ] = ( ( e + 15 ) << 10 ) | 0x8000;
+                    shiftTable[ i ] = 13;
+                    shiftTable[ i | 0x100 ] = 13;
+
+                    // large number (Infinity, -Infinity)
+
+                } else if ( e < 128 ) {
+
+                    baseTable[ i ] = 0x7c00;
+                    baseTable[ i | 0x100 ] = 0xfc00;
+                    shiftTable[ i ] = 24;
+                    shiftTable[ i | 0x100 ] = 24;
+
+                    // stay (NaN, Infinity, -Infinity)
+
+                } else {
+
+                    baseTable[ i ] = 0x7c00;
+                    baseTable[ i | 0x100 ] = 0xfc00;
+                    shiftTable[ i ] = 13;
+                    shiftTable[ i | 0x100 ] = 13;
+
+                }
+
+            }
+
+            // float16 to float32 helpers
+
+            const mantissaTable = new Uint32Array( 2048 );
+            const exponentTable = new Uint32Array( 64 );
+            const offsetTable = new Uint32Array( 64 );
+
+            for ( let i = 1; i < 1024; ++ i ) {
+
+                let m = i << 13; // zero pad mantissa bits
+                let e = 0; // zero exponent
+
+                // normalized
+                while ( ( m & 0x00800000 ) === 0 ) {
+
+                    m <<= 1;
+                    e -= 0x00800000; // decrement exponent
+
+                }
+
+                m &= ~ 0x00800000; // clear leading 1 bit
+                e += 0x38800000; // adjust bias
+
+                mantissaTable[ i ] = m | e;
+
+            }
+
+            for ( let i = 1024; i < 2048; ++ i ) {
+
+                mantissaTable[ i ] = 0x38000000 + ( ( i - 1024 ) << 13 );
+
+            }
+
+            for ( let i = 1; i < 31; ++ i ) {
+
+                exponentTable[ i ] = i << 23;
+
+            }
+
+            exponentTable[ 31 ] = 0x47800000;
+            exponentTable[ 32 ] = 0x80000000;
+
+            for ( let i = 33; i < 63; ++ i ) {
+
+                exponentTable[ i ] = 0x80000000 + ( ( i - 32 ) << 23 );
+
+            }
+
+            exponentTable[ 63 ] = 0xc7800000;
+
+            for ( let i = 1; i < 64; ++ i ) {
+
+                if ( i !== 32 ) {
+
+                    offsetTable[ i ] = 1024;
+
+                }
+
+            }
+
+            return {
+                floatView: floatView,
+                uint32View: uint32View,
+                baseTable: baseTable,
+                shiftTable: shiftTable,
+                mantissaTable: mantissaTable,
+                exponentTable: exponentTable,
+                offsetTable: offsetTable
+            };
+
+        }
+
+        // float32 to float16
+
+        /* function toHalfFloat( val ) {
+
+            if ( Math.abs( val ) > 65504 ) console.warn( 'THREE.DataUtils.toHalfFloat(): Value out of range.' );
+
+            val = clamp( val, - 65504, 65504 );
+
+            _tables.floatView[ 0 ] = val;
+            const f = _tables.uint32View[ 0 ];
+            const e = ( f >> 23 ) & 0x1ff;
+            return _tables.baseTable[ e ] + ( ( f & 0x007fffff ) >> _tables.shiftTable[ e ] );
+
+        } */
+
+        // float16 to float32
+
+        function fromHalfFloat( val ) {
+
+            const m = val >> 10;
+            _tables.uint32View[ 0 ] = _tables.mantissaTable[ _tables.offsetTable[ m ] + ( val & 0x3ff ) ] + _tables.exponentTable[ m ];
+            return _tables.floatView[ 0 ];
+
+        }
+        /* 
+        THREE.DataUtils = {
+            toHalfFloat: toHalfFloat,
+            fromHalfFloat: fromHalfFloat,
+        };
+
+         */
+
+
+        THREE.DataUtils.fromHalfFloat = fromHalfFloat
+
+ 
+    }
+ //---------------------------------------------------
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
+ 
 /**
  * AbortablePromise: A quick & dirty wrapper for JavaScript's Promise class that allows the underlying
  * asynchronous operation to be cancelled. It is only meant for simple situations where no complex promise
@@ -342,7 +537,7 @@ const fromUint8 = (v) => {
 
 
 //xzw 改  暂时没用到  需要更新版本
-const fromHalfFloat = ()=>{}//THREE.DataUtils.fromHalfFloat.bind(THREE.DataUtils);
+const fromHalfFloat = THREE.DataUtils.fromHalfFloat.bind(THREE.DataUtils);
 
 const fromHalfFloatToUint8 = (v) => {
     return Math.floor(fromHalfFloat(v) * 128) + 128;

+ 4 - 1
src/custom/mergeStartTest.js

@@ -321,8 +321,11 @@ var start = function(dom, mapDom, number, fileServer, webSite){ //t-Zvd3w0m
              
          
     let tilesetUrls = [   
-        'https://4dkk.4dage.com/fusion/test/b3dm/modelId_1093/tileset.json',
+        'https://4dkk.4dage.com/scene_view_data/SG-t-Wm2b883yI4z/images/3dtiles/tileset.json',
+    
     
+        'https://4dkk.4dage.com/fusion/test/b3dm/modelId_1093/tileset.json',
+        
         'http://192.168.0.135:14000/oss/fusion/test/b3dm/modelId_1175/tileset.json',
         'http://4dkk.4dage.com/fusion/test/b3dm/modelId_1075/tileset.json', //depth 11 较高  ,为了防止卡顿需要提高maximumScreenSpaceError
         'https://testgis.4dage.com/LVBADUI_qp/tileset.json', //村庄   含rtcCenter  

+ 1 - 1
src/custom/settings.js

@@ -478,7 +478,7 @@ let settings = {//设置   可修改
     
     fastTran: isTest
 }
-
+ 
 
 Potree.config = config
 Potree.settings = settings

+ 13 - 14
src/custom/viewer/ViewerNew.js

@@ -1,17 +1,21 @@
-
-
  
-//---------------------------------
 
+//import * as GaussianSplats3D from "../../../libs/gaussian/gaussian-splats-3d.module.js";
+
+import {Loader3DTiles} from '../../../libs/three.js/3dtiles/three-loader-3dtiles.esm.js'; 
+import {OBJLoader} from "../../../libs/three.js/loaders/OBJLoader.js";
+import {MTLLoader} from "../../../libs/three.js/loaders/MTLLoader.js";
+import {GLTFLoader} from  "../../../libs/three.js/loaders/GLTFLoader.js"; 
+import {PLYLoader} from "../../../libs/three.js/loaders/PLYLoader.js";
+//--------以上文件只在部分工程中添加-------------------------
 
 import * as THREE from "../../../libs/three.js/build/three.module.js";
-import * as GAS from "../../../libs/gaussian/gaussian-splats-3d.module.js";
 import {ClipTask, ClipMethod, CameraMode, LengthUnits, ElevationGradientRepeat} from "../../defines.js";
 import {TagTool} from "../objects/tool/TagTool.js"; 
 import Compass from "../objects/tool/Compass.js";
 import AxisViewer from "../objects/tool/AxisViewer.js";
  
-console.log(GAS)
+  
 
 import {ExtendScene} from '../../viewer/ExtendScene.js' 
 import {transitions, easing, lerp} from '../utils/transitions.js' 
@@ -22,8 +26,7 @@ import {HQSplatRenderer} from "../../viewer/HQSplatRenderer.js";
 import {MapViewer} from "./map/MapViewer.js";
                                                                  
 import {NavigationCube} from '../../viewer/NavigationCube.js'
-  
-console.log(GAS)
+   
 //import {MapView} from "../viewer/map.js"; 
 import {ProfileWindow, ProfileWindowController} from "../../viewer/profile.js";
 
@@ -67,11 +70,7 @@ import Reticule from "../objects/Reticule.js";
 import Viewport from "../viewer/Viewport.js"
 import {ViewerBase} from "../viewer/viewerBase.js"
 
-import {OBJLoader} from "../../../libs/three.js/loaders/OBJLoader.js";
-import {MTLLoader} from "../../../libs/three.js/loaders/MTLLoader.js";
-import {GLTFLoader} from  "../../../libs/three.js/loaders/GLTFLoader.js";
-import {Loader3DTiles} from '../../../libs/three.js/3dtiles/three-loader-3dtiles.esm.js';
-import {PLYLoader} from "../../../libs/three.js/loaders/PLYLoader.js";
+
     
    
 import SSAARenderPass from "../materials/postprocessing/SSAARenderPass.js"
@@ -5496,14 +5495,14 @@ export class Viewer extends ViewerBase{
             
         }else if(fileInfo.fileType == '3dgs'){
             
-            const gsViewer = new Potree.GaussianSplats3D.Viewer({ 
+            const gsViewer = new GaussianSplats3D.Viewer({ 
                 rootElement: this.renderArea,
                 threeScene: this.scene.scene,
                 renderer: this.renderer,
                 camera:  this.mainViewport.camera,
                 useBuiltInControls: false,
                 //dropInMode: true,
-                // sharedMemoryForWorkers:false  //否则 报错 Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': SharedArrayBuffer transfer requires self.crossOriginIsolated. 
+                 sharedMemoryForWorkers:false  //否则 报错 Uncaught (in promise) DOMException: Failed to execute 'postMessage' on 'DedicatedWorkerGlobalScope': SharedArrayBuffer transfer requires self.crossOriginIsolated. 
 
             });
             //let path = Potree.resourcePath+'/models/gaussian/bonsai.ksplat';

+ 23 - 3
src/custom/viewer/map/Map.js

@@ -2,6 +2,10 @@ import * as THREE from "../../../../libs/three.js/build/three.module.js";
 import math from '../../utils/math.js'
 import browser from '../../utils/browser.js'
 
+import BasicMaterial from '../../materials/BasicMaterial.js'  
+    
+
+
 let texLoader = new THREE.TextureLoader() 
     texLoader.crossOrigin = "anonymous" 
 
@@ -659,7 +663,18 @@ export class MapTile{
             opacity: 0,
             side: THREE.DoubleSide,
            
-        });
+        }); 
+        
+        
+        /* var t = new BasicMaterial({
+            transparent: !0,
+            depthWrite: !1,
+            depthTest: !0,
+            opacity: 0,
+            side: THREE.DoubleSide
+        })
+         t.defines.InverseColor = '' */
+        
         if(Potree.settings.isTest) {
             var colorHue = Math.random()
             t.color = new THREE.Color().setHSL(colorHue, 0.6, 0.92) 
@@ -796,11 +811,16 @@ export class TiledMapOpenStreetMap extends TiledMapBase{
                 if(style == 'satellite'){//卫星
                     this.maxDepth = 18
                     this.baseUrl = "https://webst01.is.autonavi.com/appmaptile?lang=zh_cn&style=6&yrs=m&x=${x}&y=${y}&z=${z}"
+                }else if(style == 'roads'){
+                    this.maxDepth = 18
+                    this.baseUrl = "https://wprd01.is.autonavi.com/appmaptile?lang=zh_cn&style=8&yrs=m&x=${x}&y=${y}&z=${z}"    //路网   加上scl=2后去掉名字
                 }else{
                     this.maxDepth = 19
-                    this.baseUrl = "https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&style=7&yrs=m&x=${x}&y=${y}&z=${z}"    // 
+                    this.baseUrl = "https://wprd04.is.autonavi.com/appmaptile?lang=zh_cn&style=7&yrs=m&x=${x}&y=${y}&z=${z}"    //  
+               
+             
                 }
-            }
+            }//详解 https://www.cnblogs.com/lucio110/p/17310054.html
         }
         
         this.style = style

+ 18 - 0
src/materials/shaders/basicTextured.fs

@@ -20,6 +20,24 @@ void main() {
     #ifdef HasMap
         vec4 texColor = texture2D(map, vUv); 
         gl_FragColor = texColor * color_;
+        
+        /*#ifdef InverseColor
+            bool inverse = false; //gl_FragColor.r < 0.3 || gl_FragColor.g < 0.3 || gl_FragColor.b < 0.3 ||
+                              
+                            //深色字和白色地面要反转
+            
+            if(gl_FragColor.r > 0.9 && gl_FragColor.g > 0.9 && gl_FragColor.b > 0.9){
+                //gl_FragColor.r = 1.0 - gl_FragColor.r;
+                //gl_FragColor.g = 1.0 - gl_FragColor.g;
+                //gl_FragColor.b = 1.0 - gl_FragColor.b; 
+                gl_FragColor = vec4(0.07,0.22, 0.5,1.0);
+            }else{//海和草坪颜色加深
+            
+                gl_FragColor = texColor * vec4(0.3,0.5,0.7,1.0);
+            } 
+            
+        #endif*/
+        
     #else
         gl_FragColor = color_;
     #endif