Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"watch": "rollup -c -w"
},
"peerDependencies": {
"playcanvas": "^2.19.0"
"playcanvas": "^2.20.1"
},
"devDependencies": {
"@mediapipe/tasks-vision": "0.10.35",
Expand Down
61 changes: 59 additions & 2 deletions src/components/gsplat-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ class GSplatComponentElement extends ComponentElement {

private _lodMultiplier = 3;

private _lodRangeMin = 0;

private _lodRangeMax = 99;

/** @ignore */
constructor() {
super('gsplat');
Expand All @@ -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
};
}

Expand Down Expand Up @@ -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'
];
}

Expand All @@ -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;
}
}
}
Expand Down