c-frame / aframe-extras

Add-ons and helpers for A-Frame VR.
https://c-frame.github.io/aframe-extras/examples/
MIT License
972 stars 305 forks source link

[gamepad-controls] Continuous drift without user input with movement-controls on Vive Focus 3 #382

Closed micrology closed 11 months ago

micrology commented 2 years ago

The basic A-Frame code below works as expected on Desktop and with Meta Quest 2: in VR, the scene shows a static set of orthogonal axes, which one can move around using the thumbstick. However, using a Vive Focus 3, and either the depreciated Firefox browser or the new Vive Browser, the scene drifts counter-clockwise (i.e. to the left) even without any user input. This is reproducible on several Vive Focus 3 headsets, i.e. it is not a hardware fault in a controller.

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Vive Focus 3 drift problem</title>
        <meta charset="utf-8" />
        <!--        Basic A-Frame code -->
        <script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
        <!--        Move around using controllers code -->
        <script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-extras@v6.1.1/dist/aframe-extras.min.js"></script>
    </head>
    <body>
        <a-scene>
            <!-- camera -->
            <a-entity id="cameraRig" movement-controls="fly: true">
                <a-camera id="camera" look-controls="pointerLockEnabled: true"></a-camera>
            </a-entity>
            <!-- centre point and axes -->
            <a-sphere class="origin-box" color="lightgray" radius="0.05" position="0 0 -1"></a-sphere>
            <a-entity line="start: -500 0 -1; end: 500 0 -1; color: red"></a-entity>
            <a-entity line="start: 0 -500 -1; end: 0 500 -1; color: green"></a-entity>
            <a-entity line="start: 0 0 -501; end: 0 0 499; color: blue"></a-entity>
            <!-- sky -->
            <a-sky color="#87CEFA"></a-sky>
        </a-scene>
    </body>
</html>
vincentfretin commented 1 year ago

Do you still have the issue with latest master build? https://cdn.jsdelivr.net/gh/n5ro/aframe-extras@14411ea/dist/aframe-extras.controls.min.js There is already a epsilon check to ignore the joystick value if below 0.2. You can try a higher value 0.25 or 0.3? You can change it here https://github.com/n5ro/aframe-extras/blob/14411eaae311663da7446febec2aad80f67fbf04/src/controls/gamepad-controls.js#L13

You can also add some console.log https://github.com/n5ro/aframe-extras/blob/14411eaae311663da7446febec2aad80f67fbf04/src/controls/gamepad-controls.js#L116-L117 and here https://github.com/n5ro/aframe-extras/blob/14411eaae311663da7446febec2aad80f67fbf04/src/controls/gamepad-controls.js#L151-L152 to see what values you're getting when you don't touch anything.

vincentfretin commented 1 year ago

@micrology Are you able to test what I suggested? You can create a build with npm install and npm run dist from the repository, then use the created dist/aframe-extras.min.js in your page instead of the cdn. But before that, please test the latest master: https://cdn.jsdelivr.net/gh/n5ro/aframe-extras@09b8445/dist/aframe-extras.min.js

micrology commented 1 year ago

Apologies for not doing this earlier. I will aim to find time within the next couple of days.

micrology commented 1 year ago

It works! No continuous motion when not moving the thumbsticks, and the thumbsticks work as expected to control the movement.

Thank you so much – and apologies that I was so slow to test it.

vincentfretin commented 1 year ago

What did you test, master or you specified another threshold value? Can you please gave us the minimum value you used that fixes the issue? We'll see if we can change the default value if it doesn't impact the usage on other headsets like the Quest, so everyone having those Vive headsets can benefit the fix.

micrology commented 1 year ago

I had tested the master from the CDN.

Since then I updated the Vive OS to the current version, and now I see some 'jitter' - no drift but slight jumping. This is the case with both the CDN version and a locally installed aframe-extras v 6.1.1.

I wanted to experiment with a higher value of JOYSTICK_EPS, but when I try npm install in the aframe-extras directory, I get the following error:

npm install                          9:39:21
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: aframe-extras@6.1.1
npm ERR! Found: sinon@1.17.7
npm ERR! node_modules/sinon
npm ERR!   dev sinon@"^1.17.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer sinon@">=2.1.0 <5" from karma-sinon-chai@1.3.4
npm ERR! node_modules/karma-sinon-chai
npm ERR!   dev karma-sinon-chai@"^1.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/scs1ng/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/scs1ng/.npm/_logs/2022-12-16T09_39_38_091Z-debug-0.log

log attached 2022-12-16T09_39_38_091Z-debug-0.log

I also tried v6.1.1 on a Quest 2, and it was fine - no jitter or drift.

vincentfretin commented 1 year ago

You can try npm install --legacy-peer-deps like the message says. But this is weird you have this message because it should look at the versions from package-lock.json. What version of npm do you have?

npm -v
8.19.2
vincentfretin commented 1 year ago

Sorry, the info is in the log you provided, it's also v8.19.2 you have on node v18.0.0.

micrology commented 1 year ago

Using npm install --legacy-peer-deps does allow the install to proceed to the end, but generates a host of warnings about the use of depreciated and unmaintained packages, and unsupported engines.

Do you get the same problem when you try npm install?

The package.json calls for a version of sinon at ^1.17.3, but the current version of sinon is 15.0.1 - rather a lot of versions ahead!

I wonder if you are using the same package.json as arrives when a-frame-extras@6.1.1 is downloaded. I have attached a copy. For example, I see that it requests "aframe": "^0.8.2" which is also very out of date. package.json.txt

vincentfretin commented 1 year ago

I don't need to use --legacy-peer-deps for npm install to work on my side, unless I remove package-lock.json first. Anyway yes it's normal that all those versions are super old, nobody updated the build and test stack in this repo. I'll plan to do it like I already did in other repositories like networked-aframe and aframe itself when I'll work on #389

micrology commented 1 year ago

I hope it is OK then to continue testing after you have had a chance to update package.json. Many thanks for your work on this - very much appreciated.

vincentfretin commented 1 year ago

This won't change anything, the old dependencies are only for the build tools and running the tests, those are not runtime dependencies. Please test now.

vincentfretin commented 11 months ago

Closing the issue. Please reopen if you still have the issue with release 7.2.0 and have tested what I said in https://github.com/c-frame/aframe-extras/issues/382#issuecomment-1333677298