UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

35 lines (32 loc) 1.02 kB
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 { 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 };