wmurphyrd / aframe-physics-extras

🔧Cannon API interface components the A-Frame Physics System
MIT License
27 stars 9 forks source link

does not seem working with newer versions of webxr api / aframe #14

Open kylebakerio opened 3 years ago

kylebakerio commented 3 years ago

Tried updating the glitch to this:

<!DOCTYPE html>
<html>
 <head>
  <title>My A-Frame Scene</title>
  <script src="https://aframe.io/releases/1.1.0/aframe.min.js"></script>
  <script src="https://cdn.jsdelivr.net/gh/donmccurdy/aframe-physics-system@v2.1.0/dist/aframe-physics-system.min.js"></script>
  <script src="https://unpkg.com/super-hands@2.0.2/dist/super-hands.min.js"></script>
  <script src="https://unpkg.com/aframe-physics-extras@0.1.0/dist/aframe-physics-extras.min.js"></script>
</head>

<body>
  <a-scene physics="gravity: 0">
    <a-assets>
      <a-mixin id="controller"
               physics-collider
               static-body="shape: sphere; sphereRadius: 0.02"
               super-hands="colliderEvent: collisions;
                            colliderEventProperty: els;
                            colliderEndEvent: collisions;
                            colliderEndEventProperty: clearedEls"
               collision-filter = "group: hands;
                                   collidesWith: red, blue;
                                   collisionForces: false">
      </a-mixin>
      <a-mixin id="cube" dynamic-body grabbable
          geometry="primitive: box; width: 0.5; height: 0.5; depth: 0.5">
      </a-mixin>
    </a-assets>
    <!-- settings pulled in from controller mixin above -->
    <a-entity hand-controls="left" mixin="controller"></a-entity>
    <a-entity hand-controls="right" mixin="controller"></a-entity>
    <!-- can be picked up because it collides with the hands group and vice versa -->
    <a-entity mixin="cube" position="0 1.6 -1" material="color: red" sleepy
        collision-filter="group: red; collidesWith: default, hands, blue">
    </a-entity>
    <!-- even though the controller has blue in its collidesWith list,
         since the blue cube doesn't also have hands in its list, you cannot
         pick it up, but you can knock it around with the red cube -->
    <a-entity mixin="cube" position="0 1 -1" material="color: blue" sleepy
        collision-filter="group: blue; collidesWith: default, red">
    </a-entity>
    <!-- floor entity. 'default' collision group so cubes will bounce off -->
    <a-box width="20" depth="20" height="0.1" static-body 
           collision-filter="collidesWith: red, blue"
        material="color: #7BC8A4"></a-box>
  </a-scene>
</body>
</html>

I get two boxes that I cannot interact with on my quest 2. May just need minor updates, haven't dug deep, but just dropping this here.

kylebakerio commented 3 years ago

Just a note, I'm here because I'm following the chains of links that seem to be necessary to get superhands working.

littlemiddlebiddle commented 3 years ago

Not sure if you checked console, but if you're getting:

"core:a-node:error Failure loading node: TypeError: Cannot read property 'charAt' of undefined at i.update (hand-controls.js:198) at initComponent (component.js:330) at i.updateProperties (component.js:302) at i.module.exports.Component (component.js:78) at new i (component.js:662) at HTMLElement.initComponent (a-entity.js:332) at HTMLElement.updateComponent (a-entity.js:495) at HTMLElement.updateComponents (a-entity.js:463) at a-entity.js:249 at a-node.js:127"

If you update:

<a-entity hand-controls="left" mixin="controller"></a-entity> <a-entity hand-controls="right" mixin="controller"></a-entity>

to:

<a-entity id="leftHand" hand-controls="hand: left; handModelStyle: lowPoly; color: #ffcccc"></a-entity> <a-entity id="rightHand" hand-controls="hand: right; handModelStyle: lowPoly; color: #ffcccc"></a-entity>

which is the most up-to-date example in the README for hand-controls component, https://github.com/aframevr/aframe/blob/master/docs/components/hand-controls.md, it should fix it. I created a PR for the READMe (which may get declined if for some reason that was intentionally the case) - https://github.com/wmurphyrd/aframe-physics-extras/pull/15, but that appears to have been the only thing I had to change for this to work out of the box.

wmurphyrd commented 3 years ago

@kylebakerio please note that aframe-physics-extras is not required to user super-hands, you could use another collision detection component such as sphere-collider from aframe-extras in place of physics-collider and drop collision-filter entirely

kylebakerio commented 3 years ago

@wmurphyrd I noticed that in theory something like that should be possible based on the docs, but I assumed going with your own component designed for that purpose would be ideal. I'm also just starting, so I wanted the most standard boiler-plate proof of concept I could get working, and presumed this was it.

Are there any benefits to going with sphere-collider? Presumably it might be more performant/simpler code since it sounds like it only works with one basic type of geometry instead of many kinds?

In the end I got a working example by following a different chain of links, of course, so it's not something super pressing for me personally (for anyone else ending up here: I've added a 'TLDR; how-to make your existing scene super-hands-able' to the superhands repo itself, so check there for what ended up working for me with A-Frame 1.1.0).