From 0ac563145ddf913230d7660f4ad1015090f1ee82 Mon Sep 17 00:00:00 2001 From: Protean Productions Date: Fri, 5 Dec 2025 14:41:05 +0100 Subject: [PATCH 1/2] ClientControls to accept callbacks for the initial user interaction --- src/core/systems/ClientControls.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/systems/ClientControls.js b/src/core/systems/ClientControls.js index 07a9d9629..ddf0c45d8 100644 --- a/src/core/systems/ClientControls.js +++ b/src/core/systems/ClientControls.js @@ -85,6 +85,9 @@ export class ClientControls extends System { delta: 0, } this.xrSession = null + + this.pointerLockOccurred = false + document.addEventListener('pointerlockchange', () => this.pointerLockOccurred = true, { once: true }) } start() { @@ -549,6 +552,15 @@ export class ClientControls extends System { } } + onInitialPointerLock(callback) { + if (this.pointerLockOccurred) { + callback.call() + + } else { + document.addEventListener('pointerlockchange', callback, { once: true }) + } + } + onKeyDown = e => { if (e.defaultPrevented) return if (e.repeat) return From 3e12cf9440b56767e5f886f9fe67f8121e3b2f28 Mon Sep 17 00:00:00 2001 From: Protean Productions Date: Wed, 31 Dec 2025 09:48:03 +0100 Subject: [PATCH 2/2] ClientControls to accept callbacks for the initial user interaction --- src/core/systems/ClientControls.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/systems/ClientControls.js b/src/core/systems/ClientControls.js index ddf0c45d8..ffbe67f63 100644 --- a/src/core/systems/ClientControls.js +++ b/src/core/systems/ClientControls.js @@ -86,8 +86,8 @@ export class ClientControls extends System { } this.xrSession = null - this.pointerLockOccurred = false - document.addEventListener('pointerlockchange', () => this.pointerLockOccurred = true, { once: true }) + this.pointerInteractionOccurred = false + document.addEventListener('pointerdown', () => this.pointerInteractionOccurred = true, { once: true }) } start() { @@ -552,12 +552,12 @@ export class ClientControls extends System { } } - onInitialPointerLock(callback) { - if (this.pointerLockOccurred) { + onInitialPointerInteraction(callback) { + if (this.pointerInteractionOccurred) { callback.call() } else { - document.addEventListener('pointerlockchange', callback, { once: true }) + document.addEventListener('pointerdown', callback, { once: true }) } }