playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
51 lines (50 loc) • 2 kB
JavaScript
var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
import { Vec3 } from "../../core/math/vec3.js";
import { BoundingBox } from "../../core/shape/bounding-box.js";
import { GSplatOctree } from "./gsplat-octree.js";
class GSplatOctreeResource {
/**
* @param {string} assetFileUrl - The file URL of the container asset.
* @param {object} data - Parsed JSON data.
* @param {object} assetLoader - Asset loader instance (framework-level object).
*/
constructor(assetFileUrl, data, assetLoader) {
/** @type {BoundingBox} */
__publicField(this, "aabb", new BoundingBox());
/**
* Version counter for centers array changes. Always 0 for octree resources (static).
*
* @ignore
*/
__publicField(this, "centersVersion", 0);
/** @type {GSplatOctree|null} */
__publicField(this, "octree");
/**
* Raw parsed manifest data, retained for consumers that read custom or extension
* fields the octree itself does not consume (for example application-specific
* metadata accompanying a `lod-meta.json`). The `tree` field is nulled out by the
* constructor since {@link GSplatOctree} consumes it — access node hierarchy via
* {@link GSplatOctreeResource#octree} instead.
*
* @type {object}
*/
__publicField(this, "data");
this.octree = new GSplatOctree(assetFileUrl, data);
this.octree.assetLoader = assetLoader;
this.aabb.setMinMax(new Vec3(data.tree.bound.min), new Vec3(data.tree.bound.max));
this.data = data;
this.data.tree = null;
}
/**
* Destroys the octree resource and cleans up all associated resources.
*/
destroy() {
this.octree?.destroy();
this.octree = null;
}
}
export {
GSplatOctreeResource
};