Zoom with the wheel and reset with the right button
Updated
The mouse wheel scales a model between half and three times its size, read with Input.mouse.wheelDelta(); a right click puts it back to its own size.
Turn the mouse wheel over the scene to grow or shrink the model, then right-click to reset it. Drag to orbit the camera.
Zoom with the wheel and reset with the right button
#pragma lifecycle(startup, update)
const MIN = 0.5;const MAX = 3;const STEP = 0.001; // scale change per pixel of wheel travellet size = 1;let model;
function startup() { model = findEntity('Showcase');}
function update() { const wheel = Input.mouse.wheelDelta(); if (wheel !== 0) { size = Math.min(MAX, Math.max(MIN, size + wheel * STEP)); model.scale.setScalar(size); }
if (Input.mouse.isButtonReleased(MouseButton.Right)) { size = 1; model.scale.setScalar(size); }}How it works
Section titled “How it works”The script is explained step by step in Zoom with the wheel and reset with the right button.
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.
WheelZoom.xrproj