Skip to content

Commit 750e9f1

Browse files
committed
ClientControls to accept callbacks for the initial user interaction
1 parent 97e3827 commit 750e9f1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/core/systems/ClientControls.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export class ClientControls extends System {
6868
delta: 0,
6969
}
7070
this.xrSession = null
71+
72+
this.pointerLockOccurred = false
73+
document.addEventListener('pointerlockchange', () => this.pointerLockOccurred = true, { once: true })
7174
}
7275

7376
start() {
@@ -406,6 +409,15 @@ export class ClientControls extends System {
406409
}
407410
}
408411

412+
onInitialPointerLock(callback) {
413+
if (this.pointerLockOccurred) {
414+
callback.call()
415+
416+
} else {
417+
document.addEventListener('pointerlockchange', callback, { once: true })
418+
}
419+
}
420+
409421
onKeyDown = e => {
410422
if (e.defaultPrevented) return
411423
if (e.repeat) return

0 commit comments

Comments
 (0)