qg3dviewer 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +41 -24
- package/dist/index.umd.js +11 -11
- package/dist/modeldata/loaders/SplatLoader copy.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -993,24 +993,29 @@ async function Gc(n) {
|
|
|
993
993
|
console.warn(`fetch error: ${o.status}`), n.status === P.Fetching && (n.status = P.FetchFailed);
|
|
994
994
|
return;
|
|
995
995
|
}
|
|
996
|
-
const s = o.body.getReader(), r =
|
|
997
|
-
n.rowLength = 32, n.fileSize =
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
996
|
+
const s = o.body.getReader(), r = o.headers.get("content-length"), c = r ? parseInt(r) : 0;
|
|
997
|
+
if (n.rowLength = 32, n.fileSize = c, c > 0) {
|
|
998
|
+
n.modelSplatCount = c / n.rowLength | 0;
|
|
999
|
+
const u = Math.min(n.modelSplatCount, n.fetchLimit);
|
|
1000
|
+
n.splatData = new Uint8Array(u * 32);
|
|
1001
|
+
} else {
|
|
1002
|
+
const u = n.fetchLimit > 0 ? n.fetchLimit : 1e5;
|
|
1003
|
+
n.modelSplatCount = u, n.splatData = new Uint8Array(u * 32);
|
|
1002
1004
|
}
|
|
1003
|
-
n.CompressionRatio = "7.75x", n.
|
|
1005
|
+
n.CompressionRatio = "7.75x", n.downloadSplatCount = 0, n.watermarkData = new Uint8Array(0);
|
|
1004
1006
|
let A = new Uint8Array(32), l = 0;
|
|
1005
1007
|
for (; ; ) {
|
|
1006
1008
|
let { done: u, value: g } = await s.read();
|
|
1007
1009
|
if (u) break;
|
|
1008
|
-
l + g.byteLength < n.rowLength ? (A.set(g, l), l += g.byteLength, t += g.length, n.downloadSize = t) : (l = await e(n, l, A, g), l && A.set(g.slice(g.byteLength - l), 0)), n.downloadSplatCount >= n.fetchLimit
|
|
1010
|
+
if (l + g.byteLength < n.rowLength ? (A.set(g, l), l += g.byteLength, t += g.length, n.downloadSize = t) : (l = await e(n, l, A, g), l && A.set(g.slice(g.byteLength - l), 0)), n.downloadSplatCount >= n.fetchLimit) {
|
|
1011
|
+
n.abortController.abort();
|
|
1012
|
+
break;
|
|
1013
|
+
}
|
|
1009
1014
|
}
|
|
1010
1015
|
} catch (i) {
|
|
1011
1016
|
i.name === "AbortError" ? (n.opts.url, n.status === P.Fetching && (n.status = P.FetchAborted)) : (console.error(i), n.status === P.Fetching && (n.status = P.FetchFailed));
|
|
1012
1017
|
} finally {
|
|
1013
|
-
n.status === P.Fetching && (n.status = P.FetchDone);
|
|
1018
|
+
n.splatData && n.dataSplatCount * 32 < n.splatData.length && (n.splatData = n.splatData.slice(0, n.dataSplatCount * 32)), n.status === P.Fetching && (n.status = P.FetchDone);
|
|
1014
1019
|
}
|
|
1015
1020
|
async function e(i, a, o, s) {
|
|
1016
1021
|
return new Promise(async (r) => {
|
|
@@ -1031,14 +1036,25 @@ async function Gc(n) {
|
|
|
1031
1036
|
}
|
|
1032
1037
|
function qs(n, t) {
|
|
1033
1038
|
let e = t.byteLength / O;
|
|
1034
|
-
const i =
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
+
const i = (n.dataSplatCount + e) * O;
|
|
1040
|
+
if (i > n.splatData.length) {
|
|
1041
|
+
let r = Math.max(n.splatData.length * 2, i);
|
|
1042
|
+
n.fetchLimit > 0 && (r = Math.min(r, n.fetchLimit * O));
|
|
1043
|
+
const c = new Uint8Array(r);
|
|
1044
|
+
c.set(n.splatData), n.splatData = c;
|
|
1045
|
+
}
|
|
1046
|
+
const a = n.splatData.length / O;
|
|
1047
|
+
if (n.dataSplatCount + e > a) {
|
|
1048
|
+
if (e = a - n.dataSplatCount, e <= 0) return;
|
|
1049
|
+
n.splatData.set(t.slice(0, e * O), n.dataSplatCount * O);
|
|
1050
|
+
} else
|
|
1051
|
+
n.splatData.set(t, n.dataSplatCount * O);
|
|
1052
|
+
const o = new Float32Array(t.buffer);
|
|
1053
|
+
for (let r = 0, c = 0, A = 0, l = 0; r < e; r++)
|
|
1054
|
+
c = o[r * 8], A = o[r * 8 + 1], l = o[r * 8 + 2], n.minX = Math.min(n.minX, c), n.maxX = Math.max(n.maxX, c), n.minY = Math.min(n.minY, A), n.maxY = Math.max(n.maxY, A), n.minZ = Math.min(n.minZ, l), n.maxZ = Math.max(n.maxZ, l);
|
|
1039
1055
|
n.dataSplatCount += e;
|
|
1040
|
-
const
|
|
1041
|
-
n.currentRadius = Math.sqrt(n.maxX * n.maxX +
|
|
1056
|
+
const s = n.header?.MinTopY || 0;
|
|
1057
|
+
n.currentRadius = Math.sqrt(n.maxX * n.maxX + s * s + n.maxZ * n.maxZ), n.aabbCenter = new Q((n.minX + n.maxX) / 2, (n.minY + n.maxY) / 2, (n.minZ + n.maxZ) / 2), n.maxRadius = 0.5 * Math.sqrt(Math.pow(n.maxX - n.minX, 2) + Math.pow(n.maxY - n.minY, 2) + Math.pow(n.maxZ - n.minZ, 2)), n.metaMatrix && n.aabbCenter.applyMatrix4(n.metaMatrix);
|
|
1042
1058
|
}
|
|
1043
1059
|
const qc = [ic, rc];
|
|
1044
1060
|
async function Vc(n) {
|
|
@@ -1051,7 +1067,7 @@ async function Vc(n) {
|
|
|
1051
1067
|
}
|
|
1052
1068
|
const a = i.body.getReader(), o = parseInt(i.headers.get("content-length") || "0");
|
|
1053
1069
|
if (o - fe < Kr) {
|
|
1054
|
-
console.warn("data empty", n.opts.url), n.status === P.Fetching && (n.status = P.Invalid);
|
|
1070
|
+
console.warn("spx data empty", n.opts.url), n.status === P.Fetching && (n.status = P.Invalid);
|
|
1055
1071
|
return;
|
|
1056
1072
|
}
|
|
1057
1073
|
n.fileSize = o;
|
|
@@ -5509,13 +5525,14 @@ class au {
|
|
|
5509
5525
|
}
|
|
5510
5526
|
//
|
|
5511
5527
|
forward(t, e = "dir") {
|
|
5512
|
-
if (
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5528
|
+
if (this.splatMesh.dir)
|
|
5529
|
+
if (e === "dir") {
|
|
5530
|
+
const i = this.splatMesh.dir.clone().multiplyScalar(t || 0.5);
|
|
5531
|
+
this.opts.controls.target.add(i), this.opts.camera.position.add(i), this.opts.controls.update();
|
|
5532
|
+
} else {
|
|
5533
|
+
const i = this.splatMesh.len, a = this.splatMesh.dir.clone().multiplyScalar((t || 0) * i), o = this.opts.position || [0, 0, 0], s = this.opts.lookAt || [0, 0, 1];
|
|
5534
|
+
this.opts.controls.object.position.set(o[0] + a.x, o[1] + a.y, o[2] + a.z), this.opts.controls.target.set(s[0] + a.x, s[1] + a.y, s[2] + a.z), this.opts.controls.update();
|
|
5535
|
+
}
|
|
5519
5536
|
}
|
|
5520
5537
|
/**
|
|
5521
5538
|
* 允许拖拽本地文件进行渲染
|