edittool.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. this.createVisual = function () {
  2. let parent = this.parent;
  3. let dim = parent.boundingBox().getSize(new THREE.Vector3());
  4. let size = Math.max(dim.x, dim.y, dim.z);
  5. let childNode = function (position, rotation) {
  6. let rot = rotation ? rotation : [0, 0, 0];
  7. return {
  8. "extends": "proxy/aframe/abox.vwf",
  9. "properties": {
  10. "position": position,
  11. "rotation": rot,
  12. "height": 0.3,
  13. "width": 0.3,
  14. "depth": 0.3
  15. },
  16. "children": {
  17. "material": {
  18. "extends": "proxy/aframe/aMaterialComponent.vwf",
  19. "type": "component",
  20. "properties": {
  21. "color": "red",
  22. "transparent": true,
  23. "opacity": 0.7
  24. }
  25. }
  26. }
  27. }
  28. }
  29. let visNode = {
  30. "extends": "proxy/aframe/abox.vwf",
  31. "properties": {
  32. "position": [0, 0, 0],
  33. "rotation": [0, 0, 0],
  34. "height": size,
  35. "width": size,
  36. "depth": size
  37. },
  38. "children": {
  39. "material": {
  40. "extends": "proxy/aframe/aMaterialComponent.vwf",
  41. "type": "component",
  42. "properties": {
  43. "color": "white",
  44. "transparent": true,
  45. "opacity": 0.5
  46. }
  47. },
  48. "drag": childNode([0, (size/2) + 0.3, 0])
  49. }
  50. }
  51. this.children.create("visualNode", visNode);
  52. }