Splats
Updated
A Gaussian splat is 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. The Splat Mesh shows that capture in your world, sorted and drawn on desktop, phones and headsets.
Use splats for real places and objects that would take weeks to model: a courtyard, a statue, a shop interior, a product. Scripts fade captures in once they are ready, tint them, choose their quality per device, and switch between them.
Before you start
Section titled “Before you start”- Entities and transforms. A splat’s size and placement are its entity’s transform. See Working with entities.
- Async hooks. Waiting for a capture to appear uses
awaitinside anasync startup. See Scripting. - Tweens. Fades use
Tween.value. See Animation.
| Component | Type | What it does |
|---|---|---|
| Splat Mesh | comp-splat-mesh | Shows a Gaussian splat capture. |
Splat Mesh
Section titled “Splat Mesh”SplatMeshComponent is required on a Splat Mesh entity (ent-splat-mesh).
| Prop | Type | Default | Description |
|---|---|---|---|
src |
string |
none | The splat file, .ply, .spz, .sog or .rad, as a URL or an ASSET-<uuid> reference. Any other file type is refused. Changing it reloads the splat. |
color |
string |
'#ffffff' |
Tint multiplied over every splat. Applied live. |
opacity |
number |
1 |
0 to 1. Applied live, without reloading. |
quality |
'flat' | 'low' | 'medium' | 'high' |
'low' |
How much view-dependent colour is kept (below). Changing it reloads the splat. |
| Member | What it does |
|---|---|
whenDrawn() |
Returns a promise that resolves once the splat is drawn. It resolves at once when there is nothing to draw, when the splat is out of view, or when its scene is not up. |
set |
Change props. color and opacity apply live; src and quality reload. |
set |
Show or hide the capture. |
A splat takes no material, and Mask, Decal and Cache Mesh do not apply to it. The entity supports Selectable, Grabbable, Pivotable, Outline and Silhouette (a border around its bounds), Billboard, Signal Emitter, Enable on Signal and animation timelines.
File formats
Section titled “File formats”| File | Format |
|---|---|
.ply |
Gaussian PLY, including compressed . files |
.spz |
SPZ, versions 1 to 4 |
.sog |
SOG, versions 1 and 2, bundled in one file |
.rad |
RAD, in one file |
Any other file type is refused before anything loads, including .splat and .ksplat. A source without a file extension, such as an ASSET-<uuid> reference, is loaded and its format is read from the file itself.
Quality
Section titled “Quality”A capture stores, for each blob, how its colour shifts with the viewing angle: glossy highlights, reflections, sheen. This is called view-dependent colour. quality sets how much of it is loaded and drawn. It never changes the number of blobs, their shape or their sharpness.
| Quality | Use it for |
|---|---|
flat |
One colour per blob from every angle, about a quarter of high’s memory. Best for captures without shiny surfaces. |
low |
The default. A little of the shine at a fraction of the memory; fast on every device. |
medium |
Most of the shine. |
high |
Everything the file stores, for close-up views of glossy captures on desktop. |
Captures that share a file and a quality share one decoded copy in memory.
How splats are drawn
Section titled “How splats are drawn”- Distance detail. A far capture draws fewer blobs: all of them up close, half from 3 bounding radii away and a quarter from 6.
- Close up. A blob never grows past 512 pixels across on screen (96 in a headset), so walking into a capture stays smooth.
- Out of view. In play, a capture whose bounds are out of the camera’s view is not sorted or drawn.
- Picking. Rays hit a splat like any mesh, so Selectable and Grabbable work on it. To let rays pass through, put it on a layer that is not raycastable (see Layers).
- Memory. Destroying a splat frees its mesh. The decoded file stays cached until the app closes, so returning to a scene loads nothing. Each
qualityof a file is a separate copy.
Examples
Section titled “Examples”1. Fade a capture in once it is drawn
Section titled “1. Fade a capture in once it is drawn”A capture can take a moment to download and decode. This script keeps it invisible until it is drawn, then fades it in over two seconds instead of letting it pop in.
#pragma lifecycle(startup)
async function startup() { const capture = self.parent.getComponent(SplatMeshComponent); capture.setProps({ opacity: 0 });
await capture.whenDrawn(); log('Capture drawn: fading it in');
Tween.value(0, 1, (value) => capture.setProps({ opacity: value }), { duration: 2, ease: Ease.InOutSine });}A Gaussian splat capture stays invisible while it downloads and decodes, then fades in over two seconds: a Behavior script waits on whenDrawn and tweens the Splat Mesh opacity.
Wait for the capture to download (about 12 MB) and watch it fade in. Drag to orbit the camera, scroll to zoom.
- The Behavior sits on the Splat Mesh entity, so
self.parent.getComponent(SplatMeshComponent)finds the capture. opacity: 0hides it without unloading it; opacity changes never reload the file.await capture.whenDrawn()pausesstartupuntil the capture is drawn.awaitis allowed becausestartupisasync.Tween.value(0, 1, …)raises the opacity smoothly. Each step is a live prop change.
2. Cross-fade between two captures
Section titled “2. Cross-fade between two captures”A before-and-after view: the same room captured before and after a renovation. Pressing Space cross-fades from one capture to the other.
#pragma lifecycle(startup, update)
let before;let after;let showingAfter = false;let fade = null;
async function startup() { before = findEntity('Room Before').getComponent(SplatMeshComponent); after = findEntity('Room After').getComponent(SplatMeshComponent);
before.setProps({ opacity: 1 }); after.setProps({ opacity: 0 }); await Promise.all([before.whenDrawn(), after.whenDrawn()]);}
function update() { if (!Input.keyboard.isKeyReleased(Key.Space)) return; showingAfter = !showingAfter;
if (fade) fade.stop(); const start = after.props.opacity; const end = showingAfter ? 1 : 0; fade = Tween.value(start, end, (value) => { after.setProps({ opacity: value }); before.setProps({ opacity: 1 - value }); }, { duration: 1.5, ease: Ease.InOutQuad });}Two Splat Meshes share a place; each press of Space cross-fades their opacity with a tween, from one capture to the other.
Click the scene, then press Space to cross-fade between the two captures. Drag to orbit the camera, scroll to zoom.
- Both captures are placed at the same transform. One starts fully visible, the other at opacity 0.
Promise.allwaits until both have been drawn once, so the first switch does not wait on a download.- Each Space press flips
showingAfter. The fade starts from the current opacity, so pressing Space in the middle of a fade turns it around smoothly; the previous tween is stopped first. - One tween drives both captures, so their opacities always add up to 1.
3. Tint a capture for dusk
Section titled “3. Tint a capture for dusk”A capture’s colours come from the photographs it was made from, and a splat takes no material. To match a time of day, tint it. This script blends a capture’s tint from white to a warm dusk colour when a signal arrives.
#pragma lifecycle(startup)
const DAY = new THREE.Color('#ffffff');const DUSK = new THREE.Color('#ffb27a');const mixed = new THREE.Color();
function startup() { const capture = self.parent.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 }); });}On sky/dusk, a tween blends a Splat Mesh's color from white to a warm dusk tint over six seconds.
Press Dusk to warm the capture over six seconds. Drag to orbit the camera, scroll to zoom.
THREE.Colorholds the two end colours;lerpblends between them byt.colortakes a hex string, so the blend is written withgetHexString().- The colours are made once at the top of the script and reused every step.
Snippets
Section titled “Snippets”1. Pick quality by device
Section titled “1. Pick quality by device”Phones and standalone headsets have less memory than a desktop. This script picks a lighter quality there and a richer one on desktop, for every capture in a list.
#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()andDevice.isMobile()describe the device the app runs on.qualityreloads the capture, so the script changes it only when it differs from the saved value (capture.props.quality).- Running this in
startup, before the player looks around, keeps the reload out of sight. Better still, save scenes with the lightest quality you accept and raise it only where the device allows.
Performance
Section titled “Performance”- Blob count and overdraw drive the cost. Use trimmed captures: crop away the parts nobody will see before importing them.
- Lower
qualitysaves memory, not blob count. - Out-of-view captures are skipped in play, so several captures spread across a scene cost little while they are behind the camera.
- The splat renderer loads with the first splat, so scenes without one pay nothing.
Common mistakes
Section titled “Common mistakes”- Using
.splator.ksplatfiles. Only.ply,.spz,.sogand.radload. Convert other formats first. - Changing
qualityorsrcfor a quick effect. Both reload the capture. Usecolorandopacityfor live effects. - Expecting a material to restyle a capture. A splat takes no material: its colours come from the capture. Use
colorto tint it. - Giving it a material, a Mask or a Decal. None of these apply to splats.
- Hiding a capture with opacity alone. A capture at opacity 0 is still in the scene and still a pickable object. To take it out of play, disable it; to let rays pass through it, put it on a layer that is not raycastable.