Cross-fade between two captures
Updated
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.
Cross-fade between two captures
#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 });}How it works
Section titled “How it works”The script is explained step by step in Cross-fade between two captures.
Open it in XR Creator
Section titled “Open it in XR Creator”Download the project file below, then import it in XR Hub with Projects › New › Import, as described in Projects and templates. It opens in XR Creator with the same scene you see running above, each script already attached to its Behavior entity. From there you can edit the scripts, adjust components and their props, preview your changes, and deploy the result as a world of your own.
SplatBeforeAfter.xrproj