# Look around and click buttons in browser

**URL:** <https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884>\
**Category:** 🌵 Needle Engine\
**Tags:** question\
**Created:** [September 25, 2026, 6:53am UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884 "2026-09-25T06:53:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 25, 2026, 6:53am UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/1 "2026-09-25T06:53:39Z")

</div>

I am looking for a solution that will allow the user in the browser to look around using the mouse and click buttons.

In the hotspots sample I can move the camera and still click on the hotspots, but that is orbit, third person view.

I also tried the First Person Controller with all movement speeds set to 0, but then as soon as I click the left mouse button the mouse can only be used for looking around, I can no longer click buttons.  
I noticed that when I press escape to get out of the first person mode I can click the button. But that is not user-friendly.

In XR I have achieved what I want using the XR Controller and there also settting the movement speed to 0. I can then click the button using the trigger of the right controller.

How can I achieve the same behaviour in the browser?

Thanks!

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 25, 2026, 9:19am UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/4 "2026-09-25T09:19:19Z")

</div>

Replace the FirstPersonController with a **custom mouselook script** that uses **pointer lock only on right mouse button**. Left click stays free for buttons.

In Needle Engine, the built-in FirstPersonController always locks the pointer on left mouse. Instead, write a lightweight controller:

```typescript
import { Behaviour, Input } from "@needle-tools/engine";

export class RightMouseLook extends Behaviour {
  private isLocked = false;

  update() {
    if (Input.getMouseButtonDown(2)) { // right button
      document.body.requestPointerLock();
      this.isLocked = true;
    }
    if (this.isLocked && Input.getKeyDown("Escape")) {
      document.exitPointerLock();
      this.isLocked = false;
    }
    if (this.isLocked) {
      const delta = Input.mouseDelta;
      // rotate the camera / rig using delta.x and delta.y
      this.gameObject.rotation.y -= delta.x * 0.002;
      // ...
    }
  }
}

```

Attach it to your camera rig. Left click now works for any Needle UI or HTML buttons without conflict.

If you need the speed of the FirstPersonController, check its inspector – some versions support a **“Lock Button”** property (set to `Right`). Otherwise, the custom script above is the cleanest fix.

If buttons are inside the 3D scene (Needle UI), they’ll work; if they’re HTML overlays, they’ll also work because left click isn’t captured.

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/scripting-walkthrough.html#:~:text=In%20XR%20the%20user%20is%20parented%20to%20a%20rig%2C%20so%20moving%20the%20rig%20moves%20the%20user.) (63%), [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/scripting/examples.html#:~:text=onPointerClick()%20%7B) (58%), [Needle Engine Docs](https://engine.needle.tools/docs/why.html#:~:text=Getting%20Started%20%E2%80%94%20pick%20Unity%2C%20Blender%2C%20or%20code.) (55%), [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/deployment/playable-ads/#:~:text=WeChat%2FWeixin%20Mini%20Games%20do%20not%20have%20an%20HTML%20page.) (53%)

_1 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 25, 2026, 1:08pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/5 "2026-09-25T13:08:32Z")

</div>

I get compile erros on getMouseButtonDown, getKeyDown and mouseDelta

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 25, 2026, 1:08pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/6 "2026-09-25T13:08:33Z")

</div>

The `getMouseButtonDown`, `getKeyDown`, and `mouseDelta` are part of Needle Engine’s `Input` class. Make sure you import it correctly:

```typescript
import { Input } from "@needle-tools/engine";

```

If you used `Input` from three.js or wrote `window.Input`, that won’t work. Also confirm your Needle Engine version is up to date (3.32.x+). If you’re in a plain HTML project (no TypeScript build step), you can access the Input via the `NeedleEngine` namespace.

If the errors persist, share the exact error text or a minimal reproduction at [engine.needle.tools/new](https://engine.needle.tools/new).

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/why.html#:~:text=three.js%20%E2%80%94%20Needle%20builds%20on%20it%20rather%20than%20replacing%20it.) (57%), [Needle Engine Docs](https://engine.needle.tools/docs/unity/#:~:text=Component%20Reference%20-%20All%20built-in%20components) (56%), [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/scripting-walkthrough.html#:~:text=Learn%20Needle%20Engine%20scripting%20one%20idea%20at%20a%20time.) (56%), [Needle Engine Docs](https://engine.needle.tools/docs/#:~:text=Jump%20straight%20to%20practical%20guides) (54%), [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/scripting/examples.html#:~:text=That's%20the%20whole%20model%3A%20components%20on%20objects%2C%20a%20lifecycle%2C%20and%20a%20context%20they) (54%), [Needle Engine Docs](https://engine.needle.tools/docs/reference/faq.html#:~:text=Needle%20Engine%20uses%20typescript%20decorators%20for%20serialization.) (54%), [Needle Engine Docs](https://engine.needle.tools/docs/blender/#:~:text=Discord%20Community%20Ask%20questions%20and%20get%20real-time%20help%20from%20the%20community.) (53%)

_1 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 25, 2026, 1:14pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/7 "2026-09-25T13:14:24Z")

</div>

The import is from needle engine, as in the script above.

The error message is  
TS2339 Property 'getMousebuttonDown’does not exist on type ‘typeof Input’

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 25, 2026, 1:14pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/8 "2026-09-25T13:14:24Z")

</div>

The error is a simple typo: `getMousebuttonDown` should be `getMouseButtonDown` (capital B).

Fix:

```typescript
if (Input.getMouseButtonDown(2)) { … }

```

Same applies to `getKeyDown` (capital K, capital D) — it’s correct as written, just double-check. `mouseDelta` is correct.

Make sure you import:

```typescript
import { Input } from "@needle-tools/engine";

```

Then it works as described.

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/scripting-walkthrough.html#:~:text=Learn%20Needle%20Engine%20scripting%20one%20idea%20at%20a%20time.) (53%)

_0 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 25, 2026, 1:17pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/9 "2026-09-25T13:17:07Z")

</div>

This was a typo in my copy of the text. I can not copy the actual error mesage, Visual Studio does not allow it. In the code the method names are in the right camel case. The code is as in the script that was suggested in the first post.

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [September 25, 2026, 1:20pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/10 "2026-09-25T13:20:23Z")

</div>

Hi, this is wrong ` Input.getKeyDown("Escape"))`

instead you can access the input class via `this.context.input.getKeyDown` - will check why AI didn’t find this information. Sorry about that.

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 25, 2026, 1:20pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/11 "2026-09-25T13:20:52Z")

</div>

You’re running into a known issue: static `Input.getKeyDown` etc. aren’t always available. The correct way is through the scene context — either

```ts
this.context.input.getMouseButtonDown(0)  
this.context.input.getKeyDown("Escape")  
this.context.input.mouseDelta  

```

Make sure your component extends `Behaviour` and is attached to an active object in the scene so `this.context` exists.

If you’re still stuck, create a minimal repro at [engine.needle.tools/new](https://engine.needle.tools/new) and share the URL.

_4 replies left_  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 25, 2026, 1:25pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/12 "2026-09-25T13:25:47Z")

</div>

Thanks. I was just checking the documentation as well and found that that was probably the reason.

But there is no mouseDelta in this.context.input. I only see getMouseWheelDeltaY, but using the mouse wheel to look around will be awkward.

---

<div class="post-metadata">

**Author:** ![Marcel\_Wiessler1](https://forum.needle.tools/user_avatar/forum.needle.tools/marcel_wiessler1/32/21_2.png) [@Marcel\_Wiessler1](https://forum.needle.tools/u/Marcel_Wiessler1)\
**Post date:** [September 25, 2026, 1:31pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/13 "2026-09-25T13:31:16Z")

</div>

You might want to use [Input | Needle Engine](https://engine.needle.tools/docs/api/classes/Engine_Core.Input.html#getpointerpositiondelta)

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 25, 2026, 2:13pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/14 "2026-09-25T14:13:44Z")

</div>

Fair enough — `mouseDelta` isn’t the one to rely on. Try `this.context.input.getMouseDelta()`; if that’s missing too, your `@needle-tools/engine` version is just older than the docs snippet that mentions it.

For a look-around camera you don’t need the Input class at all. Request pointer lock and read raw deltas:

```ts
start() {
  this.context.domElement.requestPointerLock();
}

```

Then a plain listener on `document` while `document.pointerLockElement` is set, using `evt.movementX / evt.movementY`. That’s version-independent and gives smooth mouse-look.

Post your engine version here and I’ll confirm the exact API — the input methods changed between releases. See the [Handle User Input](https://engine.needle.tools/docs/how-to-guides/scripting/handle-input) guide [9].

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/why.html#:~:text=Getting%20Started%20%E2%80%94%20pick%20Unity%2C%20Blender%2C%20or%20code.) (55%)

_1 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 29, 2026, 7:57am UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/15 "2026-09-29T07:57:45Z")

</div>

Using this.context.input.getPointerPositionDelta(0) I can look around, but I still can’t use the left button to click the button.

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 30, 2026, 7:26am UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/16 "2026-09-30T07:26:48Z")

</div>

The needle engine package version is 5.1.13

Please show the full script for this solution with pointer lock and raw deltas

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 30, 2026, 7:26am UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/17 "2026-09-30T07:26:48Z")

</div>

Left-click on UI fails because pointer lock routes all mouse input to the canvas — locked pointers can’t click DOM buttons until unlocked (Esc). That’s expected, not a bug.

```ts
import { Behaviour } from "@needle-tools/engine";

export class LookAround extends Behaviour {
  private onMove = (e: MouseEvent) => {
    if (document.pointerLockElement !== this.context.domElement) return;
    this.gameObject.rotation.y -= e.movementX * 0.1;
    this.gameObject.rotation.x -= e.movementY * 0.1;
  };

  start() {
    const el = this.context.domElement;
    el.addEventListener("click", () => el.requestPointerLock());
    document.addEventListener("mousemove", this.onMove);
  }
  onDestroy() {
    document.removeEventListener("mousemove", this.onMove);
  }
}

```

So: unlock to interact with buttons, or handle the click yourself and skip the DOM button. If it still misbehaves, drop a URL at engine.needle.tools/new.

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/scripting-walkthrough.html#:~:text=Learn%20Needle%20Engine%20scripting%20one%20idea%20at%20a%20time.) (63%), [Needle Engine Docs](https://engine.needle.tools/docs/why.html#:~:text=Getting%20Started%20%E2%80%94%20pick%20Unity%2C%20Blender%2C%20or%20code.) (63%), [Needle Engine Docs](https://engine.needle.tools/docs/blender/#:~:text=Discord%20Community%20Ask%20questions%20and%20get%20real-time%20help%20from%20the%20community.) (61%), [Needle Engine Docs](https://engine.needle.tools/docs/#:~:text=Jump%20straight%20to%20practical%20guides) (60%), [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/scripting/examples.html#:~:text=Needle%20Engine%20scripting%20in%20a%20handful%20of%20short%20steps.) (59%), [Needle Engine Docs](https://engine.needle.tools/docs/unity/#:~:text=Component%20Reference%20-%20All%20built-in%20components) (59%), [Needle Engine Docs](https://engine.needle.tools/docs/reference/faq.html#:~:text=This%20only%20applies%20to%20web%20projects%20managed%20by%20Unity%20or%20Blender.) (57%), [Needle Engine Docs](https://engine.needle.tools/docs/help/#:~:text=Need%20help%20with%20Needle%20Engine%3F) (57%), [Needle Engine Docs](https://engine.needle.tools/docs/explanation/core-concepts/project-structure.html#:~:text=Typescript%20Guide%20for%20Unity%20Developers) (55%), [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/optimization/#:~:text=Problem%3A%20Production%20build%20fails%20during%20compression) (54%)

_1 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 30, 2026, 2:39pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/18 "2026-09-30T14:39:25Z")

</div>

If this is intended behaviour, how does it work in the Hotspots sample? There I can move the camera using the mouse position through OrbitControls and still use left click to select a hotspot.

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 30, 2026, 2:39pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/19 "2026-09-30T14:39:26Z")

</div>

The Hotspots sample never uses pointer lock. OrbitControls just listens to drag events on the canvas — it doesn’t capture the pointer, so `pointerup`/`click` still fire normally and the engine’s raycast hits the hotspot mesh.

Pointer lock is what’s killing your click: while locked, the pointer is captured and DOM targets can’t receive it.

Drop the lock and either use OrbitControls directly, or mimic it — only apply `getPointerPositionDelta(0)` while your left button is held down (check `this.context.input.getPointerPressed`/button state). A click without movement will then still reach `onPointerClick`.

Why did you need the lock in the first place?

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/scripting/examples.html#:~:text=onPointerClick()%20%7B) (60%), [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/scripting-walkthrough.html#:~:text=Introduces) (57%)

_1 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 30, 2026, 2:43pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/21 "2026-09-30T14:43:26Z")

</div>

This was suggested in the first reply!

Can you rewrite the LookAround script to work in the same way as the orbit controls? But then from a first person view rather than a third person view. And so tha I can still use left mouse click for the buttons.

---

<div class="post-metadata">

**Author:** ![needle-assistant](https://forum.needle.tools/user_avatar/forum.needle.tools/needle-assistant/32/3415_2.png) [@needle-assistant](https://forum.needle.tools/u/needle-assistant)\
**Post date:** [September 30, 2026, 2:43pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/22 "2026-09-30T14:43:27Z")

</div>

Drop pointer lock — apply rotation only while the button is held, so a plain click still reaches the DOM.

```ts
import { Behaviour } from "@needle-tools/engine";
import { Euler } from "three";

export class FirstPersonLook extends Behaviour {
  get isCameraController() { return true; }
  private down = false;
  private e = new Euler(0, 0, 0, "YXZ");

  awake() {
    const el = this.context.domElement;
    el.addEventListener("pointerdown", () => this.down = true);
    window.addEventListener("pointerup", () => this.down = false);
  }

  update() {
    if (!this.down) return;
    const d = this.context.input.getPointerPositionDelta(0);
    this.e.setFromQuaternion(this.gameObject.quaternion, "YXZ");
    this.e.y -= d.x * 0.005;
    this.e.x -= d.y * 0.005;
    this.gameObject.quaternion.setFromEuler(this.e);
  }
}

```

Attach it to the camera; the engine then skips adding OrbitControls. Swap in YXZ so pitch doesn’t roll.

Source: [8] (74%), [5] (79%)

Sources: [Needle Engine Docs](https://engine.needle.tools/docs/tutorials/scripting-walkthrough.html#:~:text=setCameraTargetPosition%20and%20setLookTargetPosition%20place%20the%20camera%20somewhere) (61%), [Needle Engine Docs](https://engine.needle.tools/docs/how-to-guides/scripting/examples.html#:~:text=onPointerClick()%20%7B) (61%), [Needle Engine Docs](https://engine.needle.tools/docs/blender/#:~:text=Now%20let's%20add%20camera%20controls%20so%20users%20can%20explore%20your%20scene.) (55%), [Needle Engine Docs](https://engine.needle.tools/docs/why.html#:~:text=Getting%20Started%20%E2%80%94%20pick%20Unity%2C%20Blender%2C%20or%20code.) (53%)

_0 replies left_ - **[Become PRO](https://needle.tools/pricing)** for more replies.  
_**Reply to this post directly if you need further help (bottom right button)**_

---

<div class="post-metadata">

**Author:** ![joostbos](https://forum.needle.tools/letter_avatar_proxy/v4/letter/j/b4bc9f/32.png) [@joostbos](https://forum.needle.tools/u/joostbos)\
**Post date:** [September 30, 2026, 3:26pm UTC](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884/24 "2026-09-30T15:26:48Z")

</div>

All right. The logic works now. But when I release the right mouse button I get the standard Chrome context menu popup window related to the right mouse button. In the hotspots sample that does not happen. How can this be prevented?

[Next page](https://forum.needle.tools/t/look-around-and-click-buttons-in-browser/2884.md?page=2)
