aentity.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. this.setGizmoMode = function (mode) {
  2. if (this.gizmo) {
  3. this.gizmo.properties.mode = mode
  4. }
  5. }
  6. this.showCloseGizmo = function () {
  7. let gizmoNode =
  8. {
  9. "extends": "http://vwf.example.com/aframe/gizmoComponent.vwf",
  10. "type": "component",
  11. "properties":
  12. {
  13. "mode": "translate"
  14. }
  15. }
  16. if (this.properties.edit) {
  17. this.children.create("gizmo", gizmoNode);
  18. } else {
  19. if (this.gizmo) {
  20. this.children.delete(this.gizmo)
  21. }
  22. }
  23. }
  24. // Parse a parameter as a translation specification.
  25. this.translationFromValue = function( propertyValue ) {
  26. var value = goog.vec.Vec3.create();
  27. if (propertyValue.hasOwnProperty('x')) {
  28. value = goog.vec.Vec3.createFromValues(propertyValue.x, propertyValue.y, propertyValue.z)
  29. }
  30. else if (Array.isArray(propertyValue) || propertyValue instanceof Float32Array ) {
  31. value = goog.vec.Vec3.createFromArray(propertyValue);}
  32. else if (typeof propertyValue === 'string') {
  33. let val = AFRAME.utils.coordinates.parse(propertyValue);
  34. value = goog.vec.Vec3.createFromValues(val.x, val.y, val.z)
  35. }
  36. return value
  37. // return value && value.length >= 3 ?
  38. // value :
  39. // goog.vec.Vec3.create();
  40. };