aentity.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. this.getChildByName = function (name) {
  2. let nodes = this.children.filter(el => el.displayName == name);
  3. return nodes[0]
  4. }
  5. this.setGizmoMode = function (mode) {
  6. if (this.gizmo) {
  7. this.gizmo.properties.mode = mode
  8. }
  9. }
  10. this.showCloseGizmo = function () {
  11. let gizmoNode =
  12. {
  13. "extends": "http://vwf.example.com/aframe/gizmoComponent.vwf",
  14. "type": "component",
  15. "properties":
  16. {
  17. "mode": "translate"
  18. }
  19. }
  20. if (this.properties.edit) {
  21. this.children.create("gizmo", gizmoNode);
  22. } else {
  23. if (this.gizmo) {
  24. this.children.delete(this.gizmo)
  25. }
  26. }
  27. }
  28. // Parse a parameter as a translation specification.
  29. this.translationFromValue = function (propertyValue) {
  30. var value = goog.vec.Vec3.create();
  31. if (propertyValue.hasOwnProperty('x')) {
  32. value = goog.vec.Vec3.createFromValues(propertyValue.x, propertyValue.y, propertyValue.z)
  33. }
  34. else if (Array.isArray(propertyValue) || propertyValue instanceof Float32Array) {
  35. value = goog.vec.Vec3.createFromArray(propertyValue);
  36. }
  37. else if (typeof propertyValue === 'string') {
  38. let val = AFRAME.utils.coordinates.parse(propertyValue);
  39. value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
  40. }
  41. return value
  42. // return value && value.length >= 3 ?
  43. // value :
  44. // goog.vec.Vec3.create();
  45. };
  46. this.sendOSC = function (msg) {
  47. //sending OSC msg
  48. vwf_view.kernel.fireEvent(this.id, "sendOSC", [msg]);
  49. // if (_OSCManager.port !== null) {
  50. // _OSCManager.port.send(msg);
  51. // }
  52. //on driver side
  53. }
  54. this.intersectEvent = function () {
  55. //this.intersectEventMethod();
  56. }
  57. this.clearIntersectEvent = function () {
  58. //this.clearIntersectEventMethod();
  59. }
  60. this.intersectEventMethod = function () {
  61. //intersect method
  62. }
  63. this.clearIntersectEventMethod = function () {
  64. //clearIntersect method
  65. }
  66. this.setOwner = function (param) {
  67. var clients = this.find("doc('http://vwf.example.com/clients.vwf')")[0];
  68. if (clients !== undefined) {
  69. //console.log(clients.children);
  70. let clientsArray = [];
  71. clients.children.forEach(function (element) {
  72. clientsArray.push(element.name);
  73. });
  74. //console.log(clientsArray);
  75. if (this.ownedBy) {
  76. if (clientsArray.includes(this.ownedBy)) {
  77. console.log(this.id + " already owned by: " + param);
  78. } else {
  79. this.ownedBy = param;
  80. //console.log(this.id + ' set owner to: ' + param);
  81. }
  82. } else {
  83. this.ownedBy = param;
  84. //console.log(this.id + ' set owner to: ' + param);
  85. }
  86. }
  87. }