avatar.vwf.yaml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # avatar
  2. # Copyright 2017 Krestianstvo.org project
  3. ---
  4. extends: http://vwf.example.com/aframe/aentity.vwf
  5. type: "avatar"
  6. properties:
  7. methods:
  8. createAvatarBody:
  9. body: |
  10. let myColor = this.getRandomColor();
  11. var newNode =
  12. {
  13. "extends": "http://vwf.example.com/aframe/abox.vwf",
  14. "properties": {
  15. "color": myColor,
  16. "position": [0,0,0.5]
  17. },
  18. "children": {
  19. "avatarNameNode": {
  20. "extends": "http://vwf.example.com/aframe/atext.vwf",
  21. "properties": {
  22. "color": myColor,
  23. "value": this.id,
  24. "side": "double",
  25. "rotation": [0, 180, 0],
  26. "position": [0, 1, 0.5]
  27. }
  28. }
  29. }
  30. }
  31. let cursor = {
  32. "id": 'cursor-' + this.id,
  33. "extends": "http://vwf.example.com/aframe/acursor.vwf"
  34. }
  35. let camera = {
  36. "id": 'camera-' + this.id,
  37. "extends": "http://vwf.example.com/aframe/acamera.vwf",
  38. "properties": {
  39. "forAvatar": true,
  40. "look-controls-enabled": false,
  41. "wasd-controls": false
  42. }
  43. }
  44. this.interpolation = "50ms";
  45. this.children.create( "avatarBody", newNode );
  46. this.children.create( "avatarCursor", cursor );
  47. this.children.create( "avatarCamera", camera );
  48. getRandomColor:
  49. body: |
  50. var letters = '0123456789ABCDEF';
  51. var color = '#';
  52. for (var i = 0; i < 6; i++) {
  53. color += letters[Math.floor(this.random() * 16)]; }
  54. return color;