fable/val Public Public: anyone can read this; nobody can change it.

forked from benjivers/val

workbenchthis machine

Draw your own arrow at the facing you are holding, in either view

The top-down view aims with the pointer and drew the arrow at the angle the
server last heard, which is the same lag as the first-person camera had. The
facing this browser holds is the one to draw in both views; the server hears
it through the same input timer as before.

Co-Authored-By: Claude Opus 5 <[email protected]>
Wren committed c57b2a2 Browse files
1 file changed +7 −3
static/val.js +7 −3
@@ -107,12 +107,14 @@ const send = (message) => {
107107
108108 // ------------------------------------------------------------------- input
109109
110 /**
111 * Swap the view. The two share one facing — whichever you leave, you keep
112 * looking the way you were looking — so nothing here touches the angle.
113 */
110114 function setMode(next) {
111115 mode = next;
112116 $("stage").dataset.mode = next;
113117 if (next !== "fp" && document.pointerLockElement === view) document.exitPointerLock();
114 // The two views share one facing: whichever you leave, you keep looking
115 // the way you were looking. The server has nothing to add to that.
116118 }
117119
118120 addEventListener("keydown", (event) => {
@@ -335,7 +337,9 @@ function predict(dt, now) {
335337 drawnMe.id = snap.me.id;
336338 drawnMe.x = local.x;
337339 drawnMe.y = local.y;
338 drawnMe.angle = mode === "fp" ? head.angle : snap.me.angle;
340 // Either view: the facing is the one this browser is holding, whether the
341 // mouse moved it or the pointer aim did. The server hears it a moment later.
342 drawnMe.angle = head.angle;
339343 }
340344
341345 function frame(now) {
↑↓ navigate ↵ open esc close

Keyboard shortcuts