简体   繁体   中英

a-frame changing entity position on interval

I'm completely new to A-Frame, and I'm trying to figure out their equivalent to javascript DOM manipulation of HTML, but right now trying to figure out how writing a component works is flying over my head.

What's the best way to get a sphere to change position on a set interval and, say, based on a unit vector and magnitude?

AFRAME.registerComponent('position-interval', {
  tick: function (t) {
    var entity = this.el;

    // Run on an interval.
    if (t - this.time < 1000) { return; } 
    this.time = t;

    // Calculate a position.
    var position = "CALCULATE ME. e.g., {x: 1, y: 2, z: 3}";

    // Update position.
    entity.setAttribute('position', position);
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM