【发布时间】:2019-01-21 07:32:47
【问题描述】:
我的组件旨在在检查时创建一个新实体,它确实这样做了,它添加了大部分属性,但不添加旋转和位置。我看到这似乎是一个问题,是 0.5.0 之前的版本,但我使用的是 0.8.0,它仍然没有更新。有什么想法吗?
AFRAME.registerComponent('new-room', {
schema: {
on: {type: 'string'},
rotation: {type: 'string'},
target: {type: 'selector'},
iconposition: {type: 'string'},
iconrotation: {type: 'string'}
},
init: function () {
// Do something when component first attached.
var data = this.data;
var el = this.el;
el.addEventListener(data.on, function () {
// Set image.
data.target.setAttribute('rotation', data.rotation);
// Remove all room icons
var entityEl = document.querySelector('.icons');
entityEl.parentNode.removeChild(entityEl);
// Adjust room icons
var entityEl = document.createElement('a-entity');
document.querySelector('a-scene').appendChild(entityEl);
entityEl.setAttribute('geometry', {primitive: 'plane', height: '1', width: '1'});
entityEl.setAttribute('material', {shader: 'flat', src: '#thumb', transparent: 'true', opacity: '.3'});
entityEl.setAttribute('class','icons');
entityEl.setAttribute('position',data.iconposition);
document.querySelector('a-scene').flushToDOM(true);
});
}
});
【问题讨论】:
-
它需要与简单的可运行示例链接才能重现。也使用 0.8.2