scene.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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('mouse-')))
  31. );
  32. nodes.forEach(el => {
  33. self.children[el.id].stepping = false;
  34. self.children.delete(self.children[el.id])
  35. })
  36. }
  37. }
  38. });
  39. }
  40. }
  41. this.future(5).clientWatch();
  42. };