playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
37 lines (36 loc) • 976 B
JavaScript
import { http, Http } from "../../platform/net/http.js";
import { GSplatOctreeResource } from "../../scene/gsplat-unified/gsplat-octree.resource.js";
import { GSplatAssetLoader } from "../components/gsplat/gsplat-asset-loader.js";
class GSplatOctreeParser {
app;
maxRetries;
constructor(app, maxRetries) {
this.app = app;
this.maxRetries = maxRetries;
}
load(url, callback, asset) {
if (typeof url === "string") {
url = {
load: url,
original: url
};
}
const options = {
retry: this.maxRetries > 0,
maxRetries: this.maxRetries,
responseType: Http.ResponseType.JSON
};
http.get(url.load, options, (err, data) => {
if (!err) {
const assetLoader = new GSplatAssetLoader(this.app.assets);
const resource = new GSplatOctreeResource(asset.file.url, data, assetLoader);
callback(null, resource);
} else {
callback(`Error loading gsplat octree: ${url.original} [${err}]`);
}
});
}
}
export {
GSplatOctreeParser
};