scene.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. this.initialize = function () {
  2. if(Object.getPrototypeOf(this).id.includes('scene.vwf')){
  3. console.log("Initialize of Scene...", this.id);
  4. this.future(3).clientWatch();
  5. } else {
  6. console.log("Initialize proto Scene..", this.id);
  7. }
  8. //this.createDefaultXRCostume();
  9. };
  10. this.clientWatch = function () {
  11. var self = this;
  12. if (this.children.length !== 0) {
  13. var clients = this.find("doc('proxy/clients.vwf')")[0];
  14. if (clients !== undefined) {
  15. //console.log(clients.children);
  16. let clientsArray = [];
  17. clients.children.forEach(function (element) {
  18. clientsArray.push(element.name);
  19. });
  20. this.children.forEach(function (node) {
  21. if (node.id.indexOf('avatar-') != -1) {
  22. if (clientsArray.includes(node.id.slice(7))) {
  23. //console.log(node.id + 'is here!');
  24. } else {
  25. //console.log(node.id + " needed to delete!");
  26. let idToDelete = node.id.slice(7);
  27. let nodes = self.children.filter(el=>
  28. (el.id.includes(idToDelete) &&
  29. ( el.id.includes('avatar-') ||
  30. el.id.includes('xrcontroller-') ||
  31. el.id.includes('mouse-') ||
  32. el.id.includes('gearvr-')))
  33. );
  34. nodes.forEach(el => {
  35. self.children.delete(self.children[el.id])
  36. })
  37. }
  38. }
  39. });
  40. }
  41. }
  42. this.future(5).clientWatch();
  43. };