Skip to content

Splat Mesh

Updated

Shows a Gaussian splat capture.

Type
ent-splat-mesh
Script class
SplatMeshEntity
Family
Meshes

A Splat Mesh shows a Gaussian splat: a photoreal capture of a real place or object, made of millions of small, soft, coloured blobs instead of triangles. You make one by scanning a real space with a phone or a camera and processing the photos into a splat file. Use it for places and objects that would take weeks to model: a courtyard, a statue, a shop interior, a product.

The capture is held by the entity’s required Splat Mesh component (comp-splat-mesh); its size and placement are the entity’s transform. A splat takes no material, and Mask, Decal and Cache Mesh do not apply to it: its colours come from the photographs. It loads .ply (including .compressed.ply), .spz, .sog and .rad files, and refuses any other file type, including .splat and .ksplat.

A far capture draws fewer blobs, and in play a capture whose bounds are out of view is neither sorted nor drawn. Rays hit a splat like any mesh, so Selectable and Grabbable work on it.

Use a Splat Mesh for captured reality. For models built in a modelling tool, use a Mesh Gltf.

The props that matter most:

  • src: the splat file, as a project asset reference (ASSET-<uuid>) or a URL. Changing it reloads the capture.
  • quality: how much view-dependent colour is kept, the way a blob’s colour shifts with the viewing angle (shine, reflections, sheen). 'flat', 'low' (the default), 'medium' or 'high'. Lower is lighter on memory; it never changes the number of blobs. Changing it reloads the capture.
  • color: a tint multiplied over every blob, applied live.
  • opacity: from 0 to 1, applied live without reloading.

The component also has whenDrawn(), which returns a promise that resolves once the capture is drawn.

  1. Add a Splat Mesh entity to the scene (see Scenes and hierarchy) and set its src to the capture file.
  2. Move, turn and scale the entity until the capture lines up with the rest of the world.
  3. Keep quality on 'low', or 'flat' for captures without shiny surfaces. Raise it only for close-up views on desktop.
  4. Crop away the parts of the capture nobody will see before importing it: blob count drives the cost.
  5. To let rays pass through it, put it on a layer that is not raycastable.

Goal: a capture can take a moment to download and decode; keep it invisible until it is drawn, then fade it in.

FadeInCapture.jx
#pragma lifecycle(startup)
async function startup() {
const capture = self.parent.getComponent(SplatMeshComponent);
capture.setProps({ opacity: 0 });
await capture.whenDrawn();
Tween.value(0, 1, (value) => capture.setProps({ opacity: value }), {
duration: 2,
ease: Ease.InOutSine,
});
}
  • The Behavior is on the Splat Mesh entity itself, so self.parent.getComponent(SplatMeshComponent) finds the capture.
  • opacity: 0 hides the capture without unloading it: opacity changes never reload the file.
  • await capture.whenDrawn() pauses startup until the capture is drawn. await is allowed because startup is async.
  • Tween.value raises the opacity smoothly; each step is a live prop change.

Goal: use less memory on phones and headsets, and keep more shine on desktop, for every capture in a list.

SplatQuality.jx
#pragma lifecycle(startup)
const CAPTURES = ['Courtyard', 'Fountain', 'Statue'];
function startup() {
let quality = 'medium';
if (Device.isHeadset()) quality = 'flat';
else if (Device.isMobile()) quality = 'low';
for (const name of CAPTURES) {
const entity = findEntity(name);
if (!entity) continue;
const capture = entity.getComponent(SplatMeshComponent);
if (capture.props.quality !== quality) capture.setProps({ quality });
}
log('Splat quality:', quality);
}
  • Device.isHeadset() and Device.isMobile() describe the device the app runs on.
  • Changing quality reloads the capture, so the script changes it only when it differs from the saved value.
  • Doing it in startup, before the player looks around, keeps the reload out of sight.

Goal: a capture’s colours come from daylight photos; warm them up when the world turns to dusk.

DuskTint.jx
#pragma lifecycle(startup)
const DAY = new THREE.Color('#ffffff');
const DUSK = new THREE.Color('#ffb27a');
const mixed = new THREE.Color();
function startup() {
const capture = findEntity('Courtyard').getComponent(SplatMeshComponent);
on('sky/dusk', () => {
Tween.value(0, 1, (t) => {
mixed.copy(DAY).lerp(DUSK, t);
capture.setProps({ color: `#${mixed.getHexString()}` });
}, { duration: 6, ease: Ease.InOutSine });
});
}
  • Another script raises the sky/dusk signal with emit('sky/dusk').
  • THREE.Color holds the two end colours; lerp blends between them by t, from 0 to 1.
  • color takes a hex string, written here with getHexString(). Tint changes apply live, with no reload.
  • The colours are created once at the top of the script and reused at every step.
  • Blob count and overdraw drive the cost: use trimmed captures. A lower quality saves memory, not blobs.
  • A capture at opacity 0 is still in the scene and can still be picked. Disable the entity to take it out of play.
  • Captures that share a file and a quality share one decoded copy in memory, and the splat renderer loads only with the first splat of an app.

What a new Splat Mesh is made of. Required components are always present and cannot be removed; the others can. Per entity says whether an entity can hold one of that component or several. Layer, Lock and Enable are on every placed entity, and Transform holds its position, rotation and scale.

Component Type Role Per entity What it does
Layer comp-layer Required One Puts the entity on a render/raycast layer so cameras and rays can include or skip it.
Lock comp-lock Required One Editor-only flag that stops the entity from being selected or moved.
Enable comp-enable Required One Turns the entity and its children on or off: hides them and stops their behavior.
Transform comp-transform Required One Position, rotation and scale of the entity, with optional editor-only per-axis locks.
Splat Mesh comp-splat-mesh Required One Shows a Gaussian splat capture.

You can also add 12 optional components, such as Animation Graph, Animation Timeline, Attribution, Billboard, Enable On Signal, Grabbable.

The settings of a new entity, as the runtime creates it. Change them in the Properties panel of XR Creator, or from a script with getComponent(…).setProps({ … }).

Prop Default Range
color "#ffffff"
opacity 1 0 ≤ x ≤ 1
quality "low"

With a Signal Emitter on the entity, these events reach scripts as { entityId, eventType, data }. Compare eventType with the EventType constants.

It reports the events every entity has: Transform::change (and position-change, rotation-change, scale-change), Enable::change, Layer::change and Lock::change.

Run it in the browser, read its scripts, and download it as an XR Creator project.

Find the entity by its name, check its class, and work with its components. Name the entity in the Hierarchy first; this example expects My Splat Mesh.

SplatMeshEntity.jx
#pragma lifecycle(startup)
function startup() {
// Find the entity by the name it has in the Hierarchy.
const entity = findEntity('My Splat Mesh');
if (!(entity instanceof SplatMeshEntity)) return;
// Its Splat Mesh component holds the settings listed under Props.
const component = entity.getComponent(SplatMeshComponent);
log('opacity is', component.props.opacity);
component.setProps({ opacity: 1 });
}