【问题标题】:Using raycaster method refreshObjects() in AFrame在 AFrame 中使用 raycaster 方法 refreshObjects()
【发布时间】:2017-01-28 08:58:04
【问题描述】:

我想知道如何在实体中使用组件的方法 例如:我有一个带有光标和光线投射器组件的实体:

<a-entity id=”raycaster_cursor" raycaster="objects: .clickable" cursor=”fuse .....

现在我想使用 raycaster 组件的 refreshObjects() 方法。我怎么做? 我只是不了解实体和组件的概念吗?

我试着这样做:

var myCursor = document.querySelector(”#raycaster_cursor");
myCursor.aycaster.refreshObjects();

像这样:

var myCursor = document.querySelector(”#raycaster_cursor");
myCursor.components.raycaster.refreshObjects();

但这不起作用。

【问题讨论】:

    标签: javascript aframe


    【解决方案1】:

    https://aframe.io/docs/0.4.0/core/component.html#accessing-a-component's-methods-and-properties

    // <a-entity foo>
    var fooComponent = document.querySelector('[foo]').components.foo;
    console.log(fooComponent.barProperty);
    fooComponent.bazMethod();
    

    【讨论】:

      猜你喜欢
      • 2018-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-24
      • 1970-01-01
      • 2021-09-21
      • 2019-08-18
      • 2018-10-04
      相关资源
      最近更新 更多