aentity.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. else if (typeof propertyValue === 'string') {
  37. let val = AFRAME.utils.coordinates.parse(propertyValue);
  38. value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
  39. }
  40. return value
  41. // return value && value.length >= 3 ?
  42. // value :
  43. // goog.vec.Vec3.create();
  44. };