Skip to content

Commit c156676

Browse files
authored
feat: add state event handling and improve frame discard logic in CameraControls (#7970)
1 parent ce7bc50 commit c156676

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

scripts/esm/camera-controls.mjs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,15 @@ class CameraControls extends Script {
380380
// mode
381381
this._setMode('orbit');
382382

383+
// state
384+
this.on('state', () => {
385+
// discard inputs
386+
this._desktopInput.read();
387+
this._orbitMobileInput.read();
388+
this._flyMobileInput.read();
389+
this._gamepadInput.read();
390+
});
391+
383392
// destroy
384393
this.on('destroy', this._destroy, this);
385394
}
@@ -796,8 +805,8 @@ class CameraControls extends Script {
796805
v.add(stickRotate.mulScalar(fly * rotateJoystickMult));
797806
deltas.rotate.append([v.x, v.y, v.z]);
798807

799-
// check for frame discard (entity disabled, xr active or skipUpdate)
800-
if (this.app.xr?.active || !this.entity.enabled || this.skipUpdate) {
808+
// check for frame discard (xr active or skipUpdate)
809+
if (this.app.xr?.active || this.skipUpdate) {
801810
frame.read();
802811
return;
803812
}

0 commit comments

Comments
 (0)