xzw 1 месяц назад
Родитель
Сommit
ed2456446a

BIN
build/potree/workers/7za.wasm


Разница между файлами не показана из-за своего большого размера
+ 280 - 0
src/custom/objects/3dgs/splatter/7zCps.js


+ 88 - 11
src/custom/objects/3dgs/splatter/SplatterThree.js

@@ -3,6 +3,8 @@ import * as THREE from "../../../../../libs/three.js/build/three.module.js";
 
 import browser from '../../../utils/browser.js'
 
+import getWorker7z from './7zCps.js'
+
 //2025.11 下载   Ver2
 let lastLodTime = 0 , lastCanSort = 0, lastRender = 0, lastHit = 0
 function getData(A, tree1Byte8){//A is arraybuffer 
@@ -313,15 +315,83 @@ function inlineWorker(A) {
 
 
 
-/* 
+ 
 var Decoder7z = class {//7z解压
-    constructor( ) {
-        
-        
+    constructor(tree1Byte8) { 
+        this.workers = []
+        this.promiseList = new Map
+        this.version = 0
+        this.tree1Byte8 = tree1Byte8
+        const max = 1
+        const wasmUrl = Potree.scriptPath + '/workers/'
+        for (let g = 0; g < max; g++) {
+            //let worker = new Worker(Potree.scriptPath + '/src/custom/objects/3dgs/splatter/7z/worker.js');   
+            let worker = inlineWorker(getWorker7z)
+            
+            worker.postMessage({
+                t: 'init',
+                wasmUrl  
+            }) 
+            
+            worker.onmessage = function({data,t:type}){ 
+                let w = this 
+                if(type == 'opened'){
+                    var curr = data.data.fileList[0]
+                    w.postMessage({
+                        t: 'extract',
+                        idx: curr.idx,
+                        name: curr.name,
+                        id: data.id //标识
+                    })
+                }else{
+                    this[type](data)
+                }
+            }
+            ,
+            this.workers.push(worker)
+        }
         
+    } 
+    decode(blob ) {//请求
+        return new Promise((resolve => {
+            let id = this.version++;
+            this.promiseList.set(id, {blob,resolve})  
+            this.decodeNext() 
+        }))
     }
+    extracted({id, data}){ 
+        if (!this.promiseList.has(id))
+            throw Error("decode: internal error");
+        let ab = data.blob.arrayBuffer()
+        let result = getData(r, this.tree1Byte8)
+         
+        this.promiseList.get(id).resolve(result)  
+        this.promiseList.delete(id)
+        this.decodeNext() 
+    }
+    
+    ready(){
+        this.wasmReady = true
+        this.decodeNext()
+    }
+    decodeNext(){
+        if(!this.wasmReady)return
+        let waitDecode = this.promiseList.entries().next().value
+        if(waitDecode){
+            let id = waitDecode[0]
+            let worker = this.workers.find(e=>!e.inUse)
+            if(worker){
+                worker.postMessage({
+                    t: 'open',
+                    blob: blob,
+                    id
+                });
+            } 
+        }
+    }
+     
 }
- */
+  
 
 
 
@@ -586,6 +656,7 @@ var maxTexSize = isMobile() ? 4096 : 8192
         this.ready = ((A.root || A.level_0) ? Promise.resolve(A) : this.loadMeta(`${this.path}/data.json`)).then((A => {
            
             this.originGsData = A.originGsData
+            this.cps7z = A.cps7z
             this.suffix = A.suffix == void 0 ? (A.originGsData ? '' : '.gs' ) : A.suffix
             this.tree1Byte8 = A.tree1Byte8
             this.size = A.size|| A.files*65536,
@@ -607,7 +678,13 @@ var maxTexSize = isMobile() ? 4096 : 8192
             this.maxCacheFile = this.texHeight / this.blockHeight   //8192=>512
         } )),
         this.ready.then(( () => {
-            A.originGsData && (this.decoder = new Decoder(this.texWidth,this.blockHeight,4))
+            if(this.originGsData){
+                this.decoder = new Decoder(this.texWidth,this.blockHeight,4)
+            }else if(this.cps7z){
+                this.decoder = new Decoder7z(this.tree1Byte8)
+            }
+            
+        
         } ))
     }
     loadMeta(A) {
@@ -689,7 +766,7 @@ var maxTexSize = isMobile() ? 4096 : 8192
         return fetch(url).then((A => {
             if (!A.ok)
                 throw Error(`Error fetching ${g}: ${A.status} ${A.statusText}`);
-            return A.arrayBuffer()
+            return this.cps7z ? A.blob() : A.arrayBuffer()
         })).then((A => { 
         
             if(this.originGsData){
@@ -697,7 +774,7 @@ var maxTexSize = isMobile() ? 4096 : 8192
                 return this.decoder.decode(g) 
             }else{  
                 if(this.cps7z){
-                    return this.decoder7z.decode(A, this.tree1Byte8)
+                    return this.decoder.decode(A)
                 }else{
                     return getData(A, this.tree1Byte8)
                 }
@@ -1278,7 +1355,7 @@ var Lodder = class {
         if(!this.worker.working ){
             if(distanceSq(camera.eye, this.eye2) > .001 || distanceSq(camera.look, this.look2) > .001 || this.version != this.sortVersion){
                 this.worker.working = !0  
-                console.log('lod')
+                 
                 /* console.log('lod', Date.now() - lastLodTime), 
                 lastLodTime = Date.now(),
                  */ 
@@ -1296,7 +1373,7 @@ var Lodder = class {
             }
         }else{
             //add
-            console.log('request lod')
+            //console.log('request lod')
         }
          
         this.version != this.sortVersion && this.update()
@@ -2878,7 +2955,7 @@ function P(A) {
  现在有一个问题是 滚轮快速向后会有一部分后方的点显示到前方,过一会儿再消失,但似乎有不消失的时候,需要下次渲染才消失.
  原版也会这样,只是因为滚动移动速度慢所以不出现。
 
-
+暂不支持4096以外宽度的贴图,如果设备支持最大的尺寸为2048将无法运行
 
 发现: 将窗口拉宽,并没有因多显示出高斯点而重新lod,说明每次lod都是全局,无视是否在视图内
  */