'G.objects.map().on()' 仅由放置数据的浏览器触发。其他浏览器无法获得任何有关它的事件。
当我单击橙色按钮时,会创建一个随机对象。但它适用于一个浏览器。不同步。请检查这个 gif。
另一个节点的 .on() 类似位置被很好地触发。
枪的版本 0.2019.627。
这是我的代码。
放入数据的一部分
let object = {
id: S.myAlias + Math.floor( Math.random()*1000 ).toString(16),
parent: 'scene',
tagName: 'a-entity',
attributes: {
geometry : {
primitive: geometries[Math.floor(Math.random()* geometries.length)] // random geometries
},
color: '#'+toHex(rgb),
position : {
x : Math.random() * 16 - 8,
y : Math.random() * 10 - 3,
z : Math.random() * 25 - 25,
},
rotation: {
x : Math.random() * 2 * Math.PI,
y : Math.random() * 2 * Math.PI,
z : Math.random() * 2 * Math.PI
},
'transform-controls' : { activated: false }
}
};
G.objects.get( object.id ).put(object); // put!!!!!
G.scene.get('children').set( G.objects.get(object.id) )
部分订阅数据
G.objects.map().on( function createEntity(data, key){
console.log('come on!!!!!!');
let el = checkElement(key);
this.get('attributes').once().map().once(function updateAttributes(data, key){
// el.setAttribute(key, data);
switch (key) {
case 'geometry': this.once( updateGeometry );
break;
case 'color': this.once( updateColor );
break;
case 'transform-controls': this.once( updateTransformControls );
break;
default: el.setAttribute(key, data);
}
});
});
我怎样才能让每个连接的浏览器都收到它的事件?