|
@@ -324,27 +324,28 @@ var Decoder7z = class {//7z解压
|
|
|
this.tree1Byte8 = tree1Byte8
|
|
this.tree1Byte8 = tree1Byte8
|
|
|
const max = 1
|
|
const max = 1
|
|
|
const wasmUrl = Potree.scriptPath + '/workers/'
|
|
const wasmUrl = Potree.scriptPath + '/workers/'
|
|
|
|
|
+
|
|
|
|
|
+ let this_ = this
|
|
|
for (let g = 0; g < max; g++) {
|
|
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)
|
|
let worker = inlineWorker(getWorker7z)
|
|
|
-
|
|
|
|
|
|
|
+ worker.index = g
|
|
|
worker.postMessage({
|
|
worker.postMessage({
|
|
|
t: 'init',
|
|
t: 'init',
|
|
|
wasmUrl
|
|
wasmUrl
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- worker.onmessage = function({data,t:type}){
|
|
|
|
|
- let w = this
|
|
|
|
|
|
|
+ })
|
|
|
|
|
+ worker.onmessage = function({data}){
|
|
|
|
|
+ console.log('worker'+ this.index+'onmessage', data )
|
|
|
|
|
+ let type = data.t
|
|
|
if(type == 'opened'){
|
|
if(type == 'opened'){
|
|
|
var curr = data.data.fileList[0]
|
|
var curr = data.data.fileList[0]
|
|
|
- w.postMessage({
|
|
|
|
|
|
|
+ this.postMessage({
|
|
|
t: 'extract',
|
|
t: 'extract',
|
|
|
idx: curr.idx,
|
|
idx: curr.idx,
|
|
|
name: curr.name,
|
|
name: curr.name,
|
|
|
- id: data.id //标识
|
|
|
|
|
|
|
+ id: data.data.id //标识
|
|
|
})
|
|
})
|
|
|
}else{
|
|
}else{
|
|
|
- this[type](data)
|
|
|
|
|
|
|
+ this_[type](data, this)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
,
|
|
,
|
|
@@ -353,27 +354,13 @@ var Decoder7z = class {//7z解压
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
decode(blob ) {//请求
|
|
decode(blob ) {//请求
|
|
|
- return new Promise((resolve => {
|
|
|
|
|
|
|
+ return new Promise((resolve => {
|
|
|
let id = this.version++;
|
|
let id = this.version++;
|
|
|
|
|
+ console.log('请求decode', id)
|
|
|
this.promiseList.set(id, {blob,resolve})
|
|
this.promiseList.set(id, {blob,resolve})
|
|
|
this.decodeNext()
|
|
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(){
|
|
decodeNext(){
|
|
|
if(!this.wasmReady)return
|
|
if(!this.wasmReady)return
|
|
|
let waitDecode = this.promiseList.entries().next().value
|
|
let waitDecode = this.promiseList.entries().next().value
|
|
@@ -381,15 +368,39 @@ var Decoder7z = class {//7z解压
|
|
|
let id = waitDecode[0]
|
|
let id = waitDecode[0]
|
|
|
let worker = this.workers.find(e=>!e.inUse)
|
|
let worker = this.workers.find(e=>!e.inUse)
|
|
|
if(worker){
|
|
if(worker){
|
|
|
|
|
+ console.log('begin decode', id, 'worker index:', worker.index)
|
|
|
|
|
+ worker.inUse = true
|
|
|
worker.postMessage({
|
|
worker.postMessage({
|
|
|
t: 'open',
|
|
t: 'open',
|
|
|
- blob: blob,
|
|
|
|
|
|
|
+ blob: waitDecode[1].blob,
|
|
|
id
|
|
id
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ extracted({id, blob}, worker){
|
|
|
|
|
+ if (!this.promiseList.has(id))
|
|
|
|
|
+ throw Error("decode: internal error");
|
|
|
|
|
+ blob.arrayBuffer().then((ab)=>{
|
|
|
|
|
+ let result = getData(ab, this.tree1Byte8)
|
|
|
|
|
+
|
|
|
|
|
+ this.promiseList.get(id).resolve(result)
|
|
|
|
|
+ this.promiseList.delete(id)
|
|
|
|
|
+ console.log('decoded!', id)
|
|
|
|
|
+ setTimeout(()=>{
|
|
|
|
|
+ worker.inUse = false
|
|
|
|
|
+ this.decodeNext()
|
|
|
|
|
+ },1000) //"FS error <generic error, no stack>"
|
|
|
|
|
+
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ready(){
|
|
|
|
|
+ this.wasmReady = true
|
|
|
|
|
+ this.decodeNext()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -656,8 +667,8 @@ var maxTexSize = isMobile() ? 4096 : 8192
|
|
|
this.ready = ((A.root || A.level_0) ? Promise.resolve(A) : this.loadMeta(`${this.path}/data.json`)).then((A => {
|
|
this.ready = ((A.root || A.level_0) ? Promise.resolve(A) : this.loadMeta(`${this.path}/data.json`)).then((A => {
|
|
|
|
|
|
|
|
this.originGsData = A.originGsData
|
|
this.originGsData = A.originGsData
|
|
|
- this.cps7z = A.cps7z
|
|
|
|
|
- this.suffix = A.suffix == void 0 ? (A.originGsData ? '' : '.gs' ) : A.suffix
|
|
|
|
|
|
|
+ this.cps7z = A.cps7z || browser.urlHasValue('7z')//需http-server ./ -c0 -g
|
|
|
|
|
+ this.suffix = A.suffix == void 0 ? (A.originGsData ? '' : this.cps7z ? '.7z' : '.gs' ) : A.suffix
|
|
|
this.tree1Byte8 = A.tree1Byte8
|
|
this.tree1Byte8 = A.tree1Byte8
|
|
|
this.size = A.size|| A.files*65536,
|
|
this.size = A.size|| A.files*65536,
|
|
|
this.ratio = A.ratio,
|
|
this.ratio = A.ratio,
|
|
@@ -682,9 +693,7 @@ var maxTexSize = isMobile() ? 4096 : 8192
|
|
|
this.decoder = new Decoder(this.texWidth,this.blockHeight,4)
|
|
this.decoder = new Decoder(this.texWidth,this.blockHeight,4)
|
|
|
}else if(this.cps7z){
|
|
}else if(this.cps7z){
|
|
|
this.decoder = new Decoder7z(this.tree1Byte8)
|
|
this.decoder = new Decoder7z(this.tree1Byte8)
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
|
|
+ }
|
|
|
} ))
|
|
} ))
|
|
|
}
|
|
}
|
|
|
loadMeta(A) {
|
|
loadMeta(A) {
|
|
@@ -751,9 +760,9 @@ var maxTexSize = isMobile() ? 4096 : 8192
|
|
|
//console.log('fileRecord count: '+ this.fileRecord.size)
|
|
//console.log('fileRecord count: '+ this.fileRecord.size)
|
|
|
//console.log('fileRecord '+ this.fileRecord.size+'个:'+ Array.from(this.fileRecord.keys()) )
|
|
//console.log('fileRecord '+ this.fileRecord.size+'个:'+ Array.from(this.fileRecord.keys()) )
|
|
|
}
|
|
}
|
|
|
- )).catch((g => {
|
|
|
|
|
- this.loading.delete(fileName),
|
|
|
|
|
- console.error(`Error downloading block ${fileName}: ${g}`),
|
|
|
|
|
|
|
+ )).catch((err => {
|
|
|
|
|
+ //this.loading.delete(fileName),
|
|
|
|
|
+ console.error(`Error downloading block ${fileName}: ${err}`),
|
|
|
this.loadQueue()
|
|
this.loadQueue()
|
|
|
}
|
|
}
|
|
|
)) }
|
|
)) }
|
|
@@ -761,11 +770,14 @@ var maxTexSize = isMobile() ? 4096 : 8192
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- load(fileName) {
|
|
|
|
|
|
|
+ load(fileName) {
|
|
|
|
|
+ let max = browser.urlHasValue('maxBlock',true)
|
|
|
|
|
+ if( max !== '' && fileName > max || window.pauseLoad)fileName += '_'
|
|
|
|
|
+
|
|
|
let url = `${this.path}/${fileName}${this.suffix}?m=${this.dataVersion}`
|
|
let url = `${this.path}/${fileName}${this.suffix}?m=${this.dataVersion}`
|
|
|
return fetch(url).then((A => {
|
|
return fetch(url).then((A => {
|
|
|
if (!A.ok)
|
|
if (!A.ok)
|
|
|
- throw Error(`Error fetching ${g}: ${A.status} ${A.statusText}`);
|
|
|
|
|
|
|
+ throw Error(`Error fetching ${fileName}: ${A.status} ${A.statusText}`);
|
|
|
return this.cps7z ? A.blob() : A.arrayBuffer()
|
|
return this.cps7z ? A.blob() : A.arrayBuffer()
|
|
|
})).then((A => {
|
|
})).then((A => {
|
|
|
|
|
|