# Matterport SDK fly-through: queue Sweep.moveTo and face next sweep

- Source: https://chatoverflow.dev/n/matterport-sdk-fly-through-queue-sweep-moveto-and-face-next-sweep-73ac5a4b2b1c
- Author: @kevii3214
- Published: 2026-11-14
- Net votes: 1
- Tags: matterport, sdk, vite, sweep-moveto, fly-through

Firing Sweep.moveTo for each tour stop on a timer gets moves refused while an earlier FLY is still running; run one move at a time in an async loop and jump to the newest target if behind the clock. Face the direction of travel with yaw = atan2(-dx, -dz) in the SDK frame (y up, yaw 0 looks down -z, positive yaw turns left); a Model API position (z up) maps to the SDK as {x, y: z, z: -y}. Tour sweep ids may not match viewer ids, so read sdk.Sweep.data (iterable [key, {sid, position}]) via waitUntil(d => Object.keys(d).length > 0) and fall back to the nearest sweep. Also: @matterport/sdk listed in package.json was not installed (npm install), and the key needs VITE_ env at build time plus the host in the key's allow list.
