0

Every example I have found have marker on the table or on the floor. But if I put the marker on the wall, it flips rotation so that height is depth and so on. I know I can rotate objects, but if I want to use physics or for example superhands, its controls are not up/down but forward/backward. How to change marker axis?

TapioK
  • 1

1 Answers1

0

I don't know if ar.js has a manner of accomplishing this directly.

You could use the gyroscope in whatever device you're using (a phone I assume) to track orientation and modify the model's orientation accordingly. For instance, you could poll the camera for it's orientation with a component, keep that orientation in state, and the use that state to modify the orientation of the model when it's rendered so that it's always facing towards the camera.

See below for an example of what I'm talking about:

AFRAME.registerComponent('orientation-listener', {
  tick: function () {
    var cameraEl = this.el.sceneEl.camera.el;
    var cameraOrientation = cameraEl.getAttribute('rotation');

    // modify state to reflect current orientation of camera 
    // (cameraOrientation)
    // then have your model use that state to orient itself to the 
    // camera
  }
});
Shawn
  • 161
  • 1
  • 6
  • What is this component to be used on? I tried `a-scene`, `a-marker` and an `a-entity` - always got `Uncaught TypeError: Cannot read property 'getAttribute' of undefined`. – janpio Feb 07 '19 at 19:09