Expose lod-range-min and lod-range-max attributes on pc-gsplat#254
Merged
Conversation
Add lodRangeMin/lodRangeMax to the pc-gsplat element, completing the LOD control surface alongside the existing lod-base-distance/lod-multiplier. These clamp the LOD index selected by distance (min = finest allowed, max = coarsest allowed); raising the min avoids downloading the largest, highest-quality LOD files. The engine's GSplatComponentSystem.initializeComponentData only applies a fixed allow-list of properties and ignores lodRangeMin/lodRangeMax, so the values are applied through the initComponent() hook after the component exists rather than via getInitialComponentData(). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
playcanvas/engine#8968 (merged) adds lodRangeMin/lodRangeMax to the gsplat component system's _properties list, fixing the root cause at the engine level. Note this in the comment so the initComponent() override can be removed once web-components' minimum supported engine version includes the fix. No behavior change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
lodRangeMin/lodRangeMax were first added to GSplatComponent in engine 2.20.0, so versions earlier than 2.20.0 do not have them at all. The gsplat system _properties allow-list omitted them only in 2.20.0; the fix (playcanvas/engine#8968) shipped in 2.20.1. Reword the comment so it no longer implies "2.20.0 and earlier" are affected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Engine 2.20.1 (playcanvas/engine#8968) adds lodRangeMin/lodRangeMax to the gsplat component system's _properties allow-list, so they now apply correctly via getInitialComponentData() like the other attributes. Move them there and remove the initComponent() override. Bump the playcanvas peer dependency to ^2.20.1 so consumers can't land on 2.20.0, where these props exist on the component but are dropped from initialization data. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds two new attributes to the
<pc-gsplat>element, completing the LOD control surface that already includeslod-base-distanceandlod-multiplier:lod-range-minlodRangeMin0lod-range-maxlodRangeMax9999effectively means "no cap".These only affect assets that contain LOD levels (e.g.
.lod-meta.jsonstreaming splats).Why
An audit of
GSplatComponent(engine 2.20.0) against the attributespc-gsplatcurrently exposes (asset,cast-shadows,lod-base-distance,lod-multiplier) foundlodRangeMin/lodRangeMaxto be the clean, missing additions — simple numeric properties that complete the LOD authoring story declaratively. Other unexposed properties were considered and left out (workBufferUpdatepairs with the JS-onlysetWorkBufferModifier();layersisn't exposed on any otherpc-*component;customAabb/resource/idaren't cleanly attribute-expressible; the rest are deprecated/@ignore).Implementation note for reviewers
The engine's
GSplatComponentSystem.initializeComponentDataonly applies a fixed allow-list of properties (unified, lodBaseDistance, lodMultiplier, castShadows, material, asset, resource, layers) and ignoreslodRangeMin/lodRangeMax. Passing them throughgetInitialComponentData()is therefore silently dropped by the engine. They are instead applied via the existinginitComponent()hook (used the same way byelement-component.tsandscript-component.ts), which runs after the component is created so the setters reach the live component. The runtime setter path (changing the attribute after load) was already covered by the standardattributeChangedCallback→ setter sync.Testing
npm run lintandnpm run buildpass clean againstplaycanvas@2.20.0.<pc-gsplat lod-range-min="1" lod-range-max="3">reportscomponent.lodRangeMin === 1/component.lodRangeMax === 3on the underlying engine component at load, the runtime setter path syncs correctly, and there are no console warnings/errors.