Tweens
Updated
Three tweens from one script: a ball that bobs for ever, a box that turns and waits, and a shape that pulses when you click it, awaiting each step.
Click the diamond on the right to make it pulse. Drag to orbit the camera, scroll to zoom.
Tweens
#pragma lifecycle(startup)
async function startup() { const bob = findEntity('Bob'); const turn = findEntity('Turn'); const pulse = findEntity('Pulse');
// Up and down for ever: repeat with yoyo plays every other run backwards. Tween.to(bob.position, { y: 1.8 }, { duration: 1.2, ease: Ease.InOutSine, repeat: Infinity, yoyo: true });
// Click: grow, then shrink back, one awaited step after the other. on('pulse/clicked', async (event) => { if (event.eventType !== EventType.Selectable.Select) return; // Select fires only on becoming selected: release it so every click counts. pulse.getComponent(SelectableComponent).setSelected(false); await Tween.to(pulse.scale, { x: 1.5, y: 1.5, z: 1.5 }, { duration: 0.25, ease: Ease.OutBack }); await Tween.to(pulse.scale, { x: 1, y: 1, z: 1 }, { duration: 0.4 }); log('Pulsed'); });
// A quarter turn, a pause, and again. for (;;) { await Tween.to(turn.rotation, { y: turn.rotation.y + Math.PI / 2 }, { duration: 0.8, ease: Ease.InOutCubic }); if (!(await Tween.value(0, 1, () => {}, { duration: 0.6 }))) return; }}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.
TweenAnimation.xrproj