The Entity that this Component is attached to.
The ComponentSystem used to create this Component.
Gets whether gsplat will cast shadows for lights that have shadow casting enabled.
Sets whether gsplat will cast shadows for lights that have shadow casting enabled. Defaults to false.
Gets the custom object space bounding box for visibility culling of the attached gsplat. Returns the custom AABB if set, otherwise falls back to the resource's AABB.
Sets a custom object space bounding box for visibility culling of the attached gsplat.
Gets the enabled state of the component.
Sets the enabled state of the component.
Gets whether the high quality (true) or the fast approximate (false) spherical-harmonic calculation is used when rendering SOG data.
Sets whether to use the high quality or the approximate (but fast) spherical-harmonic calculation when rendering SOG data.
The low quality approximation evaluates the scene's spherical harmonic contributions along the camera's Z-axis instead of using each gaussian's view vector. This results in gaussians being accurate at the center of the screen and becoming less accurate as they appear further from the center. This is a good trade-off for performance when rendering large SOG datasets, especially on mobile devices.
Defaults to false.
Gets the unique identifier for this component. This ID is used by the picking system
and is also written to the work buffer when app.scene.gsplat.enableIds is enabled, making
it available to custom shaders for effects like highlighting or animation.
Gets the array of layer IDs (Layer#id) to which this gsplat belongs.
Sets an array of layer IDs (Layer#id) to which this gsplat should belong. Don't push, pop, splice or modify this array. If you want to change it, set a new one instead.
Gets a copy of LOD distance thresholds previously set, or null when not set.
Sets LOD distance thresholds used by octree-based gsplat rendering. The provided array is copied.
Gets the material used to render the gsplat.
Note: This getter returns null when unified is true. In unified mode, materials are
organized per camera/layer combination rather than per component. To access materials in
unified mode, use GSplatComponentSystem#getMaterial.
Sets the material used to render the gsplat.
Note: This setter is only supported when unified is false. When it's true, multiple
gsplat components share a single material per camera/layer combination. To access materials in
unified mode, use GSplatComponentSystem#getMaterial.
The material instance.
Gets the GSplat resource. Returns the directly set resource if available, otherwise returns the resource from the assigned asset.
Sets a GSplat resource directly (for procedural/container splats). When set, this takes precedence over the asset property.
Gets the splat budget limit for this component.
Sets the target number of splats to render for this component. The system will adjust LOD levels bidirectionally to reach this budget:
This ensures optimal use of available rendering budget while prioritizing quality for closer/more important geometry.
Set to 0 to disable the budget (default). When disabled, optimal LOD is determined purely by distance and configured LOD parameters.
Only applies to octree-based gsplat rendering in unified mode.
AlphaGets whether to use the unified gsplat rendering.
Sets whether to use the unified gsplat rendering. Default is false.
Note: Material handling differs between modes. When unified is false, use GSplatComponent#material. When unified is true, materials are shared per camera/layer - use GSplatComponentSystem#getMaterial instead.
Gets the work buffer update mode.
Sets the work buffer update mode. Only applicable in unified rendering mode.
In unified mode, splat data is rendered to a work buffer only when needed (e.g., when transforms change). Can be:
This is typically useful when using custom shader code via workBufferModifier that depends on external factors like time or animated uniforms.
Note: WORKBUFFER_UPDATE_ALWAYS has a performance impact as it re-renders
all splat data to the work buffer every frame. Where possible, consider using shader
customization on the unified gsplat material (app.scene.gsplat.material) which is
applied during final rendering without re-rendering the work buffer.
Deletes a shader parameter previously set with setParameter.
The name of the parameter to delete.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optionalarg1: anyFirst argument that is passed to the event handler.
Optionalarg2: anySecond argument that is passed to the event handler.
Optionalarg3: anyThird argument that is passed to the event handler.
Optionalarg4: anyFourth argument that is passed to the event handler.
Optionalarg5: anyFifth argument that is passed to the event handler.
Optionalarg6: anySixth argument that is passed to the event handler.
Optionalarg7: anySeventh argument that is passed to the event handler.
Optionalarg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Gets an instance texture by name. Instance textures are per-component textures defined
in the resource's format with storage: GSPLAT_STREAM_INSTANCE. Only available in unified mode.
The name of the texture.
The texture, or null if not found or not in unified mode.
// Add an instance stream to the resource format
resource.format.addExtraStreams([
{ name: 'instanceTint', format: pc.PIXELFORMAT_RGBA8, storage: pc.GSPLAT_STREAM_INSTANCE }
]);
// Get the instance texture and fill it with data
const texture = entity.gsplat.getInstanceTexture('instanceTint');
if (texture) {
const data = texture.lock();
// Fill texture data...
texture.unlock();
}
Gets a shader parameter value previously set with setParameter.
The name of the parameter.
The parameter value, or undefined if not set.
Test if there are any handlers bound to an event name.
The name of the event to test.
True if the object has handlers bound to the specified event name.
Stop rendering this component without removing its mesh instance from the scene hierarchy.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optionalname: stringName of the event to unbind.
Optionalcallback: HandleEventCallbackFunction to be unbound.
Optionalscope: anyScope that was used as the this when the event is fired.
Self for chaining.
const handler = () => {};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optionalscope: any = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optionalscope: any = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Sets a shader parameter for this gsplat instance. Parameters set here are applied during unified rendering.
The name of the parameter (uniform name in shader).
The value for the parameter.
Sets custom shader code for modifying splats when written to the work buffer. Only applicable in unified rendering mode.
Must provide all three functions:
modifySplatCenter: Modify the splat center positionmodifySplatRotationScale: Modify the splat rotation and scalemodifySplatColor: Modify the splat colorCalling this method automatically triggers a work buffer re-render.
The modifier code for GLSL and/or WGSL.
entity.gsplat.setWorkBufferModifier({
glsl: `
void modifySplatCenter(inout vec3 center) {}
void modifySplatRotationScale(vec3 originalCenter, vec3 modifiedCenter, inout vec4 rotation, inout vec3 scale) {}
void modifySplatColor(vec3 center, inout vec4 color) { color.rgb *= vec3(1.0, 0.0, 0.0); }
`,
wgsl: `
fn modifySplatCenter(center: ptr<function, vec3f>) {}
fn modifySplatRotationScale(originalCenter: vec3f, modifiedCenter: vec3f, rotation: ptr<function, vec4f>, scale: ptr<function, vec3f>) {}
fn modifySplatColor(center: vec3f, color: ptr<function, vec4f>) { (*color).r = 1.0; (*color).g = 0.0; (*color).b = 0.0; }
`
});
Enable rendering of the component if hidden using GSplatComponent#hide.
The GSplatComponent enables an Entity to render 3D Gaussian Splats. Splats are always loaded from Assets rather than being created programmatically. The asset type is
gsplatwhich supports multiple file formats including.ply,.sog,.meta.json(SOG format), and.lod-meta.json(streaming LOD format).You should never need to use the GSplatComponent constructor directly. To add an GSplatComponent to an Entity, use Entity#addComponent:
Once the GSplatComponent is added to the entity, you can access it via the Entity#gsplat property:
Unified Rendering
The GSplatComponent#unified property enables unified rendering mode, which provides advanced features for Gaussian Splats:
Relevant Engine API examples: