networked-aframe
Version:
A web framework for building multi-user virtual reality experiences.
28 lines (24 loc) • 578 B
JavaScript
class ChildEntityCache {
constructor() {
this.dict = {};
}
addChild(parentNetworkId, childData) {
if (!this.hasParent(parentNetworkId)) {
this.dict[parentNetworkId] = [];
}
this.dict[parentNetworkId].push(childData);
}
getChildren(parentNetworkId) {
if (!this.hasParent(parentNetworkId)) {
return [];
}
var children = this.dict[parentNetworkId];
delete this.dict[parentNetworkId];
return children;
}
/* Private */
hasParent(parentId) {
return !!this.dict[parentId];
}
}
module.exports = ChildEntityCache;