vrspace icon indicating copy to clipboard operation
vrspace copied to clipboard

in VR, avatar vertical position, height and arm movement messed up

Open jalmasi opened this issue 3 years ago • 0 comments

By default, we send up to 5 events per second, and create animations to interpolate in between. This is controlled by fps and createAnimations, so if you want to see your arm movements as they are, set fps=25 and createAnimations=false. I don't think these have anything to do with the bug though.

Sending side is trackChanges(), specifically

      // track camera movements
      if ( this.camera.ellipsoid ) {
        var height = this.camera.globalPosition.y - this.camera.ellipsoid.y*2;
        if ( this.camera.ellipsoidOffset ) {
          height += this.camera.ellipsoidOffset.y;
        }
        this.checkChange("position", this.pos, new BABYLON.Vector3(this.camera.globalPosition.x, height, this.camera.globalPosition.z), changes);
      } else {
        this.checkChange("position", this.pos, this.camera.globalPosition, changes);
      }
...
        // track and transmit userHeight in VR
        if ( this.isChanged( this.userHeight, vrHelper.realWorldHeight(), this.resolution)) {
          this.userHeight = vrHelper.realWorldHeight();
          changes.push({field: 'userHeight', value: this.userHeight});
        }

The method later sends all changes in one packet, like VRSPACE.sendMyChanges(changes). The purpose here is to calculate where your feet are. Then on receiving side, when we load the avatar (loadAvatar method), we add a parent mesh, and use it to move the avatar around (changeAvatar method) like

      if ( 'position' === field ) {
        if ( ! obj.translate ) {
          obj.translate = VRSPACEUI.createAnimation(node, "position", this.fps);
        }
        VRSPACEUI.updateAnimation(obj.translate, node.position, obj.position);
...
      } else if ( 'userHeight' === field ) {
        avatar.trackHeight(obj.userHeight);

If we're lucky, this is simply feet position being miscalculated on sending side. But I don't see anything obviously wrong with it. More likely, it's mess with avatar positioning. Note that network events get routed to the same trackHeight() method that is a hack with hardcoded numeric values. So what I'd do here is, comment out calls to trackHeight() and see what happens.

There's a chance we need to call Avatar.recompute() at some point. I hope not, as it may be computationally heavy. I'm not clear when it has to be called.

jalmasi avatar Jul 09 '22 13:07 jalmasi