Freeze one copy of a shared model
Updated
On knight/freeze, a disabled Shader Material draws the frozen preset on this one model with setTransientModelPreset, and three seconds later restores the model’s own look.
Press Freeze to cover the knight in ice for three seconds. Drag to orbit the camera, scroll to zoom.
Freeze one copy of a shared model
#pragma lifecycle(startup)
const FROZEN_MS = 3000;
function startup() { const material = self.parent.getComponent(ShaderMaterialComponent);
on('knight/freeze', () => { const applied = material.setTransientModelPreset('frozen'); if (!applied) { console.warn('Could not freeze: is the Shader Material disabled and the preset registered?'); return; } delay(() => material.setTransientModelPreset(), FROZEN_MS); });}How it works
Section titled “How it works”The script is explained step by step in Freeze one copy of a shared model.
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.
FreezeKnight.xrproj