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
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,9 @@ assetListLoader.load(() => {
// toggle unified rendering for all gsplats via controls
data.on('unified:set', () => {
const unified = !!data.get('unified');
const comps = /** @type {any[]} */ (app.root.findComponents('gsplat'));
comps.forEach((comp /** @type {import('playcanvas').GSplatComponent} */) => {
comp.enabled = false;
comp.entity.enabled = false;
const comps = /** @type {pc.GSplatComponent[]} */ (app.root.findComponents('gsplat'));
comps.forEach((comp) => {
comp.unified = unified;
comp.enabled = true;
comp.entity.enabled = true;
});
});
});
Expand Down
20 changes: 8 additions & 12 deletions src/framework/components/gsplat/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ import { GSplatPlacement } from '../../../scene/gsplat-unified/gsplat-placement.
* entity.gsplat.unified = true;
* ```
*
* Note: The `unified` property can only be changed when the component is disabled.
*
* Relevant Engine API examples:
*
* - [Simple Splat Loading](https://playcanvas.github.io/#/gaussian-splatting/simple)
Expand Down Expand Up @@ -439,21 +437,19 @@ class GSplatComponent extends Component {
}

/**
* Sets whether to use the unified gsplat rendering. Can be changed only when the component is
* not enabled. Default is false.
* Sets whether to use the unified gsplat rendering. Default is false.
*
* Note: Material handling differs between modes. When unified is false, use
* {@link GSplatComponent#material}. When unified is true, materials are shared per
* camera/layer - use {@link GSplatComponentSystem#getGSplatMaterial} instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this naming. I prefer something like GSplatComponentSystem#getMaterial.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep good point, will address separately.

*
* @type {boolean}
* @alpha
*/
set unified(value) {

if (this.enabled && this.entity.enabled) {
Debug.warn('GSplatComponent#unified can be changed only when the component is not enabled. Ignoring change.');
return;
if (this._unified !== value) {
this._unified = value;
this._onGSplatAssetAdded();
}

this._unified = value;
this._onGSplatAssetAdded();
}

/**
Expand Down