@splnlss/3d-story-viewer 0.5.6 → 0.5.7
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/build/viewer.js
CHANGED
|
@@ -27196,7 +27196,7 @@ class GeojsonLayer extends ContentLayer {
|
|
|
27196
27196
|
this.clear();
|
|
27197
27197
|
}
|
|
27198
27198
|
}
|
|
27199
|
-
const GAUSSIAN_FORMATS = /* @__PURE__ */ new Set(["ply", "sog", "spz"]);
|
|
27199
|
+
const GAUSSIAN_FORMATS = /* @__PURE__ */ new Set(["ply", "sog", "spz", "rad"]);
|
|
27200
27200
|
function geodeticToEcefPosition(longitude, latitude, altitude) {
|
|
27201
27201
|
const semiMajorAxis = 6378137;
|
|
27202
27202
|
const eccentricity = 0.081819190842622;
|
|
@@ -27233,7 +27233,7 @@ function validateGaussianSplatLayerDefinition(definition) {
|
|
|
27233
27233
|
}
|
|
27234
27234
|
requireNonEmptyString((_a3 = definition.data) == null ? void 0 : _a3.url, "data.url");
|
|
27235
27235
|
if (!GAUSSIAN_FORMATS.has((_b2 = definition.data) == null ? void 0 : _b2.format)) {
|
|
27236
|
-
throw new Error('data.format must be "ply", "sog", or "
|
|
27236
|
+
throw new Error('data.format must be "ply", "sog", "spz", or "rad".');
|
|
27237
27237
|
}
|
|
27238
27238
|
const renderOrder = ((_c = definition.options) == null ? void 0 : _c.renderOrder) ?? 0;
|
|
27239
27239
|
if (renderOrder !== 0) {
|
|
@@ -27306,7 +27306,8 @@ function makeGaussianSplatTransform(transform) {
|
|
|
27306
27306
|
const FORMAT_TYPES = {
|
|
27307
27307
|
ply: SplatFileType.PLY,
|
|
27308
27308
|
sog: SplatFileType.PCSOGSZIP,
|
|
27309
|
-
spz: SplatFileType.SPZ
|
|
27309
|
+
spz: SplatFileType.SPZ,
|
|
27310
|
+
rad: SplatFileType.RAD
|
|
27310
27311
|
};
|
|
27311
27312
|
function normalizeError(error) {
|
|
27312
27313
|
return error instanceof Error ? error : new Error(String(error));
|
|
@@ -27337,39 +27338,15 @@ class GaussianSplatLayer extends ContentLayer {
|
|
|
27337
27338
|
}
|
|
27338
27339
|
}
|
|
27339
27340
|
async load() {
|
|
27340
|
-
var _a3, _b2, _c, _d, _e2, _f, _g, _h, _i2;
|
|
27341
|
+
var _a3, _b2, _c, _d, _e2, _f, _g, _h, _i2, _j;
|
|
27341
27342
|
if (this.loadState === "loading" || this.loadState === "ready" || this.loadState === "disposed") return;
|
|
27342
27343
|
const attempt = ++this.loadAttempt;
|
|
27343
27344
|
this.loadState = "loading";
|
|
27344
|
-
this.abortController = new AbortController();
|
|
27345
27345
|
let mesh = null;
|
|
27346
27346
|
try {
|
|
27347
27347
|
(_b2 = (_a3 = this.callbacks).onStart) == null ? void 0 : _b2.call(_a3, this);
|
|
27348
27348
|
(_d = (_c = this.callbacks).ensureRenderer) == null ? void 0 : _d.call(_c);
|
|
27349
|
-
|
|
27350
|
-
if (!response.ok) {
|
|
27351
|
-
throw new Error(`Failed to load Gaussian splat: ${response.status} ${response.statusText}`);
|
|
27352
|
-
}
|
|
27353
|
-
if (!response.body) {
|
|
27354
|
-
throw new Error("Failed to load Gaussian splat: response body is unavailable.");
|
|
27355
|
-
}
|
|
27356
|
-
const contentLengthHeader = response.headers.get("Content-Length");
|
|
27357
|
-
const contentLength = contentLengthHeader === null ? void 0 : Number.parseInt(contentLengthHeader, 10);
|
|
27358
|
-
mesh = new SplatMesh({
|
|
27359
|
-
stream: response.body,
|
|
27360
|
-
streamLength: Number.isFinite(contentLength) && contentLength >= 0 ? contentLength : void 0,
|
|
27361
|
-
fileType: FORMAT_TYPES[this.definition.data.format],
|
|
27362
|
-
onProgress: (event) => {
|
|
27363
|
-
var _a4, _b3;
|
|
27364
|
-
if (this.loadState !== "disposed" && attempt === this.loadAttempt) {
|
|
27365
|
-
(_b3 = (_a4 = this.callbacks).onProgress) == null ? void 0 : _b3.call(_a4, this, {
|
|
27366
|
-
loaded: event.loaded,
|
|
27367
|
-
total: event.total,
|
|
27368
|
-
lengthComputable: event.lengthComputable
|
|
27369
|
-
});
|
|
27370
|
-
}
|
|
27371
|
-
}
|
|
27372
|
-
});
|
|
27349
|
+
mesh = this.definition.data.format === "rad" ? this.createPagedMesh() : await this.createDirectMesh(attempt);
|
|
27373
27350
|
mesh.layers.set(0);
|
|
27374
27351
|
mesh.matrix.copy(this.transformMatrix);
|
|
27375
27352
|
mesh.matrix.decompose(mesh.position, mesh.quaternion, mesh.scale);
|
|
@@ -27377,23 +27354,66 @@ class GaussianSplatLayer extends ContentLayer {
|
|
|
27377
27354
|
mesh.matrixWorldNeedsUpdate = true;
|
|
27378
27355
|
this.splatMesh = mesh;
|
|
27379
27356
|
this.add(mesh);
|
|
27380
|
-
|
|
27357
|
+
if (this.definition.data.format === "rad") {
|
|
27358
|
+
if (!((_e2 = mesh.paged) == null ? void 0 : _e2.getRadMeta)) {
|
|
27359
|
+
throw new Error("Failed to initialize paged RAD streaming.");
|
|
27360
|
+
}
|
|
27361
|
+
await Promise.all([mesh.initialized, mesh.paged.getRadMeta()]);
|
|
27362
|
+
} else {
|
|
27363
|
+
await mesh.initialized;
|
|
27364
|
+
}
|
|
27381
27365
|
if (this.loadState === "disposed" || attempt !== this.loadAttempt) {
|
|
27382
27366
|
this.disposeMesh(mesh);
|
|
27383
27367
|
return;
|
|
27384
27368
|
}
|
|
27385
27369
|
this.abortController = null;
|
|
27386
27370
|
this.loadState = "ready";
|
|
27387
|
-
(
|
|
27371
|
+
(_g = (_f = this.callbacks).onReady) == null ? void 0 : _g.call(_f, this);
|
|
27388
27372
|
} catch (error) {
|
|
27389
27373
|
this.disposeMesh(mesh);
|
|
27390
|
-
const aborted = (
|
|
27374
|
+
const aborted = (_h = this.abortController) == null ? void 0 : _h.signal.aborted;
|
|
27391
27375
|
this.abortController = null;
|
|
27392
27376
|
if (this.loadState === "disposed" || attempt !== this.loadAttempt || aborted) return;
|
|
27393
27377
|
this.loadState = "error";
|
|
27394
|
-
(
|
|
27378
|
+
(_j = (_i2 = this.callbacks).onError) == null ? void 0 : _j.call(_i2, this, normalizeError(error));
|
|
27395
27379
|
}
|
|
27396
27380
|
}
|
|
27381
|
+
createPagedMesh() {
|
|
27382
|
+
const paged = new PagedSplats({
|
|
27383
|
+
rootUrl: this.definition.data.url,
|
|
27384
|
+
fileType: FORMAT_TYPES[this.definition.data.format]
|
|
27385
|
+
});
|
|
27386
|
+
return new SplatMesh({
|
|
27387
|
+
paged
|
|
27388
|
+
});
|
|
27389
|
+
}
|
|
27390
|
+
async createDirectMesh(attempt) {
|
|
27391
|
+
this.abortController = new AbortController();
|
|
27392
|
+
const response = await fetch(this.definition.data.url, { signal: this.abortController.signal });
|
|
27393
|
+
if (!response.ok) {
|
|
27394
|
+
throw new Error(`Failed to load Gaussian splat: ${response.status} ${response.statusText}`);
|
|
27395
|
+
}
|
|
27396
|
+
if (!response.body) {
|
|
27397
|
+
throw new Error("Failed to load Gaussian splat: response body is unavailable.");
|
|
27398
|
+
}
|
|
27399
|
+
const contentLengthHeader = response.headers.get("Content-Length");
|
|
27400
|
+
const contentLength = contentLengthHeader === null ? void 0 : Number.parseInt(contentLengthHeader, 10);
|
|
27401
|
+
return new SplatMesh({
|
|
27402
|
+
stream: response.body,
|
|
27403
|
+
streamLength: Number.isFinite(contentLength) && contentLength >= 0 ? contentLength : void 0,
|
|
27404
|
+
fileType: FORMAT_TYPES[this.definition.data.format],
|
|
27405
|
+
onProgress: (event) => {
|
|
27406
|
+
var _a3, _b2;
|
|
27407
|
+
if (this.loadState !== "disposed" && attempt === this.loadAttempt) {
|
|
27408
|
+
(_b2 = (_a3 = this.callbacks).onProgress) == null ? void 0 : _b2.call(_a3, this, {
|
|
27409
|
+
loaded: event.loaded,
|
|
27410
|
+
total: event.total,
|
|
27411
|
+
lengthComputable: event.lengthComputable
|
|
27412
|
+
});
|
|
27413
|
+
}
|
|
27414
|
+
}
|
|
27415
|
+
});
|
|
27416
|
+
}
|
|
27397
27417
|
disposeMesh(mesh) {
|
|
27398
27418
|
if (!mesh || mesh.userData.gaussianSplatDisposed) return;
|
|
27399
27419
|
mesh.userData.gaussianSplatDisposed = true;
|