在Angular中访问Aframe事件

问题描述

我有一个基本的Aframe示例,可以在Angular应用中进行渲染。我还能够将ts文件中的数据绑定到aframe实体中。我无法做的是监听事件并在ts文件中执行某些操作。

以下是我的ts文件

import { Component,OnInit } from '@angular/core';
const aframe = (window as any).AFRAME;

@Component({
  selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['./app.component.css']
})

export class AppComponent implements OnInit {


  ngOnInit() {
    aframe.registerComponent('rotation-reader',{
      tick: function () {
        console.log("Hello World!")
        console.log(this.el.object3D.rotation);
        console.log(this.el.object3D.position);
      }
    });
  }

}

这是我的HTML代码的一部分:

<a-entity id="camera" camera="active: true" wasd-controls position="0 2 -2" rotation-header look-controls></a-entity>

当前,即使我旋转或四处移动,也不会在控制台上打印任何内容。即使我可以获得任何事件处理程序的一些示例(例如,侦听实体上的click事件),这也将很有帮助。谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)