diff --git a/package.json b/package.json index ac20b51..9c71e76 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "watch": "rollup -c -w" }, "peerDependencies": { - "playcanvas": "^2.19.0" + "playcanvas": "^2.20.1" }, "devDependencies": { "@mediapipe/tasks-vision": "0.10.35", diff --git a/src/components/gsplat-component.ts b/src/components/gsplat-component.ts index 20f1da9..5830c28 100644 --- a/src/components/gsplat-component.ts +++ b/src/components/gsplat-component.ts @@ -20,6 +20,10 @@ class GSplatComponentElement extends ComponentElement { private _lodMultiplier = 3; + private _lodRangeMin = 0; + + private _lodRangeMax = 99; + /** @ignore */ constructor() { super('gsplat'); @@ -30,7 +34,9 @@ class GSplatComponentElement extends ComponentElement { asset: AssetElement.get(this._asset), castShadows: this._castShadows, lodBaseDistance: this._lodBaseDistance, - lodMultiplier: this._lodMultiplier + lodMultiplier: this._lodMultiplier, + lodRangeMin: this._lodRangeMin, + lodRangeMax: this._lodRangeMax }; } @@ -126,13 +132,58 @@ class GSplatComponentElement extends ComponentElement { return this._lodMultiplier; } + /** + * Sets the minimum allowed LOD index (inclusive). The LOD selected by distance is clamped so it + * never goes finer (lower index) than this value. Raising it avoids downloading the highest + * quality (largest) LOD files. Defaults to 0. Only affects assets that contain LOD levels (e.g. + * `.lod-meta.json`). + * @param value - The minimum LOD index. + */ + set lodRangeMin(value: number) { + this._lodRangeMin = value; + if (this.component) { + this.component.lodRangeMin = value; + } + } + + /** + * Gets the minimum allowed LOD index. + * @returns The minimum LOD index. + */ + get lodRangeMin() { + return this._lodRangeMin; + } + + /** + * Sets the maximum allowed LOD index (inclusive). The LOD selected by distance is clamped so it + * never goes coarser (higher index) than this value. The default of 99 effectively means "no + * cap". Defaults to 99. Only affects assets that contain LOD levels (e.g. `.lod-meta.json`). + * @param value - The maximum LOD index. + */ + set lodRangeMax(value: number) { + this._lodRangeMax = value; + if (this.component) { + this.component.lodRangeMax = value; + } + } + + /** + * Gets the maximum allowed LOD index. + * @returns The maximum LOD index. + */ + get lodRangeMax() { + return this._lodRangeMax; + } + static get observedAttributes() { return [ ...super.observedAttributes, 'asset', 'cast-shadows', 'lod-base-distance', - 'lod-multiplier' + 'lod-multiplier', + 'lod-range-min', + 'lod-range-max' ]; } @@ -152,6 +203,12 @@ class GSplatComponentElement extends ComponentElement { case 'lod-multiplier': this.lodMultiplier = Number(newValue); break; + case 'lod-range-min': + this.lodRangeMin = Number(newValue); + break; + case 'lod-range-max': + this.lodRangeMax = Number(newValue); + break; } } }