Skip to content

Commit bc26640

Browse files
authored
fix: fixed firefox sticky mouse (#336)
1 parent adb8307 commit bc26640

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"eslint": "^9.29.0",
4343
"eslint-import-resolver-typescript": "^4.4.3",
4444
"globals": "^16.2.0",
45-
"playcanvas": "2.10.5",
45+
"playcanvas": "^2.10.6",
4646
"qrious": "^4.0.2",
4747
"react": "^18.3.1",
4848
"react-dom": "^18.3.1",

src/camera-controls.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,8 @@ class CameraControls {
249249

250250
const orbit = +(this._mode === 'orbit');
251251
const fly = +(this._mode === 'fly');
252-
const pan = +(this._state.touches > 1);
252+
const double = +(this._state.touches > 1);
253+
const pan = this._state.mouse[2] || +(button[2] === -1) || double;
253254
const distance = this._pose.distance;
254255

255256
const { deltas } = frame;
@@ -259,7 +260,7 @@ class CameraControls {
259260
const keyMove = this._state.axis.clone().normalize();
260261
v.add(keyMove.mulScalar(fly * this.moveSpeed * (this._state.shift ? 2 : this._state.ctrl ? 0.5 : 1) * dt));
261262
const panMove = screenToWorld(this._camera, mouse[0], mouse[1], distance);
262-
v.add(panMove.mulScalar(this._state.mouse[2]));
263+
v.add(panMove.mulScalar(pan));
263264
const wheelMove = new Vec3(0, 0, -wheel[0]);
264265
v.add(wheelMove.mulScalar(this.wheelSpeed * dt));
265266
// FIXME: need to flip z axis for orbit camera
@@ -268,7 +269,7 @@ class CameraControls {
268269
// desktop rotate
269270
v.set(0, 0, 0);
270271
const mouseRotate = new Vec3(mouse[0], mouse[1], 0);
271-
v.add(mouseRotate.mulScalar((1 - this._state.mouse[2]) * this.orbitSpeed * dt));
272+
v.add(mouseRotate.mulScalar((1 - pan) * this.orbitSpeed * dt));
272273
deltas.rotate.append([v.x, v.y, v.z]);
273274

274275
// mobile move
@@ -278,7 +279,7 @@ class CameraControls {
278279
const flyMove = new Vec3(leftInput[0], 0, -leftInput[1]);
279280
v.add(flyMove.mulScalar(fly * this.moveSpeed * this.touchSensitivity * dt));
280281
const pinchMove = new Vec3(0, 0, pinch[0]);
281-
v.add(pinchMove.mulScalar(orbit * pan * this.pinchSpeed * dt));
282+
v.add(pinchMove.mulScalar(orbit * double * this.pinchSpeed * dt));
282283
deltas.move.append([v.x, v.y, v.z]);
283284

284285
// mobile rotate

0 commit comments

Comments
 (0)