playcanvas
Version:
PlayCanvas WebGL game engine
162 lines (160 loc) • 4.79 kB
JavaScript
/**
* Parameters for GSplat unified system.
*
* @category Graphics
*/ class GSplatParams {
/**
* Enables colorization by selected LOD level when rendering GSplat objects. Defaults to false.
* Marks params dirty on change.
*
* @type {boolean}
*/ set colorizeLod(value) {
if (this._colorizeLod !== value) {
this._colorizeLod = value;
this.dirty = true;
}
}
/**
* Gets colorize-by-LOD flag.
*
* @returns {boolean} Current enabled state.
*/ get colorizeLod() {
return this._colorizeLod;
}
/**
* Multiplier applied to effective distance for nodes behind the camera when determining LOD.
* Value 1 means no penalty; higher values drop LOD faster for nodes behind the camera.
*
* Note: when using a penalty > 1, it often makes sense to set a positive
* {@link GSplatParams#lodUpdateAngle} so LOD is re-evaluated on camera rotation,
* not just translation.
*
* @type {number}
*/ set lodBehindPenalty(value) {
if (this._lodBehindPenalty !== value) {
this._lodBehindPenalty = value;
this.dirty = true;
}
}
/**
* Gets behind-camera LOD penalty multiplier.
*
* @type {number}
*/ get lodBehindPenalty() {
return this._lodBehindPenalty;
}
/**
* Minimum allowed LOD index (inclusive). Defaults to 0.
*
* @type {number}
*/ set lodRangeMin(value) {
if (this._lodRangeMin !== value) {
this._lodRangeMin = value;
this.dirty = true;
}
}
/**
* Gets minimum allowed LOD index (inclusive).
*
* @type {number}
*/ get lodRangeMin() {
return this._lodRangeMin;
}
/**
* Maximum allowed LOD index (inclusive). Defaults to 10.
*
* @type {number}
*/ set lodRangeMax(value) {
if (this._lodRangeMax !== value) {
this._lodRangeMax = value;
this.dirty = true;
}
}
/**
* Gets maximum allowed LOD index (inclusive).
*
* @type {number}
*/ get lodRangeMax() {
return this._lodRangeMax;
}
/**
* Maximum number of LOD levels allowed below the optimal level when the optimal data is not
* resident in memory. The system may temporarily use a coarser LOD within this limit until the
* optimal LOD is available. Defaults to 0, which disables fallback (always load optimal).
* Higher values allow faster loading by using lower-quality data.
*
* @type {number}
*/ set lodUnderfillLimit(value) {
if (this._lodUnderfillLimit !== value) {
this._lodUnderfillLimit = value;
this.dirty = true;
}
}
/**
* Gets the maximum allowed underfill LOD range.
*
* @type {number}
*/ get lodUnderfillLimit() {
return this._lodUnderfillLimit;
}
constructor(){
/**
* Enables debug rendering of AABBs for GSplat objects. Defaults to false.
*
* @type {boolean}
*/ this.debugAabbs = false;
/**
* Enables radial sorting based on distance from camera (for cubemap rendering). When false,
* uses directional sorting along camera forward vector. Defaults to false.
*
* Note: Radial sorting helps reduce sorting artifacts when the camera rotates (looks around),
* while linear sorting is better at minimizing artifacts when the camera translates (moves).
*
* @type {boolean}
*/ this.radialSorting = false;
/**
* Enables debug rendering of AABBs for GSplat octree nodes. Defaults to false.
*
* @type {boolean}
*/ this.debugNodeAabbs = false;
/**
* Internal dirty flag to trigger update of gsplat managers when some params change.
*
* @ignore
* @type {boolean}
*/ this.dirty = false;
/**
* @type {boolean}
* @private
*/ this._colorizeLod = false;
/**
* Distance threshold in world units to trigger LOD updates for camera and gsplat instances.
* Defaults to 1.
*
* @type {number}
*/ this.lodUpdateDistance = 1;
/**
* Angle threshold in degrees to trigger LOD updates based on camera rotation. Set to 0 to
* disable rotation-based updates. Defaults to 0.
*
* @type {number}
*/ this.lodUpdateAngle = 0;
/**
* @type {number}
* @private
*/ this._lodBehindPenalty = 1;
/**
* @type {number}
* @private
*/ this._lodRangeMin = 0;
/**
* @type {number}
* @private
*/ this._lodRangeMax = 10;
/**
* @type {number}
* @private
*/ this._lodUnderfillLimit = 0;
}
}
export { GSplatParams };