Skip to content

Commit 0ac5631

Browse files
committed
ClientControls to accept callbacks for the initial user interaction
1 parent 5d20037 commit 0ac5631

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/core/systems/ClientControls.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ export class ClientControls extends System {
8585
delta: 0,
8686
}
8787
this.xrSession = null
88+
89+
this.pointerLockOccurred = false
90+
document.addEventListener('pointerlockchange', () => this.pointerLockOccurred = true, { once: true })
8891
}
8992

9093
start() {
@@ -549,6 +552,15 @@ export class ClientControls extends System {
549552
}
550553
}
551554

555+
onInitialPointerLock(callback) {
556+
if (this.pointerLockOccurred) {
557+
callback.call()
558+
559+
} else {
560+
document.addEventListener('pointerlockchange', callback, { once: true })
561+
}
562+
}
563+
552564
onKeyDown = e => {
553565
if (e.defaultPrevented) return
554566
if (e.repeat) return

0 commit comments

Comments
 (0)