How to specify position of an aframe object using angular parameters?

隐身守侯 提交于 2019-12-10 23:13:09

问题


I am trying to specify the position of an aframe object using values set in the angular (version 4) component:

<a-text value="Plane" position="{{billBoard.x}} {{billBoard.y}} {{billBoard.z}}" color="#806040" side="double"></a-text>

Angular constructor:

  constructor() {
    this.billBoard['x'] = 1;
    this.billBoard['y'] = 3;
    this.billBoard['z'] = 6;
}

However, it ignores the values in the Angular component and just defaults to (0,0,0). What am I doing wrong?


回答1:


You can't do string interpolation, you will have to use Angular's [attr.*] data binding (ng-attr-* for AngularJS).

Example:

import ...

@Component({
    selector: 'app-root',
    template: `
        <a-scene>
            <a-box [attr.position]="'0 ' + pos.y +' 0'" color="red"></a-box>
            <a-plane rotation="-90 0 0" width="75" height="75" color="blue"></a-plane>
            <a-sky color="#f9f9f9"></a-sky>
        </a-scene>
  `
})
export class App {

    // a-box position
    private pos = new THREE.Vector3(0, 5, 0);
}

See this plunker: Angular A-Frame - set component attribute values



来源:https://stackoverflow.com/questions/43730697/how-to-specify-position-of-an-aframe-object-using-angular-parameters

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!