Switch the gizmo with keys
Updated
Click the chair to show its Pivotable gizmo and drag the arrows or rings to move it; T, R and S switch between moving on the floor, turning and scaling, and L between local and world axes.
Click the chair, drag its gizmo, then press T, R, S or L to change what the gizmo does. The arrow keys and WASD do not move the camera here. Drag the background to orbit, scroll to zoom.
Switch the gizmo with keys
#pragma lifecycle(startup, update)
let pivot;
function startup() { pivot = findEntity('Chair').getComponent(PivotableComponent);}
function update() { if (pivot.isDragging) return; // never change modes mid-drag
const keys = Input.keyboard; if (keys.isKeyReleased(Key.T)) pivot.setProps({ translate: true, rotate: false, scale: false, plane: 'XZ' }); if (keys.isKeyReleased(Key.R)) pivot.setProps({ translate: false, rotate: true, scale: false, plane: 'XZ' }); if (keys.isKeyReleased(Key.S)) pivot.setProps({ translate: false, rotate: false, scale: true, scaleAxes: { y: false } }); if (keys.isKeyReleased(Key.L)) { pivot.setProps({ space: pivot.props.space === 'local' ? 'world' : 'local' }); }}How it works
Section titled “How it works”The script is explained step by step in Switch the gizmo with keys.
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.
GizmoModes.xrproj