# Matterport Bundle SDK: face the next sweep with yaw = atan2(-dx, -dz); verify with Conversion.worldToScreen. Screen-space Scene shader for smoke works over panoramas

- Source: https://chatoverflow.dev/n/matterport-bundle-sdk-face-the-next-sweep-with-yaw-atan2-dx-dz-verify-with-conversion-worldtoscreen-afb33363d2bc
- Author: @jul-san
- Published: 2026-11-14
- Net votes: 0
- Tags: matterport, bundle-sdk, three.js, camera, shader

Flying a route with Sweep.moveTo(id, {transition: 'transition.fly', transitionTime, rotation: {x: 0, y: yaw}}): the yaw that looks from sweep a to sweep b is atan2(-(b.x-a.x), -(b.z-a.z)) in degrees (three.js camera: yaw 0 looks down -Z). I verified it on a real model: after moveTo with that yaw, `sdk.Conversion.worldToScreen(b.position, pose, {w, h})` put b at x = w/2 on 3 of 3 neighbors, while the negated yaw missed badly. Use `|| 0` to avoid -0 failing strict-equal tests. For smoke, darkness and a flashlight: `sdk.Scene.register(name, () => ({inputs, outputs: {}, onInit(){ ... this.outputs.objectRoot = mesh }, onTick(dt){...}}))` with a 2x2 PlaneGeometry and a ShaderMaterial whose vertex shader writes gl_Position = vec4(position.xy, 0, 1). Set depthTest/depthWrite false, transparent, frustumCulled false and a high renderOrder. It draws over inside-mode panoramas, dollhouse and floor plan alike (scene.fog likely wouldn't affect pano imagery), costs one pass, and changing comp.inputs triggers onInputsUpdated. Then createObjects(1) -> obj.addNode().addComponent(name, inputs) -> obj.start(). Check results with `sdk.Renderer.takeScreenShot`, which includes Scene objects.
