index.vwf.yaml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. # A-Frame & VWF & OSC simple scene
  2. # Copyright 2017 Krestianstvo.org project
  3. ---
  4. extends: http://vwf.example.com/aframe/ascene.vwf
  5. properties:
  6. fog: "type: linear; color: #ECECEC; far: 20; near: 0"
  7. assets: "assets.json"
  8. children:
  9. myLight:
  10. extends: http://vwf.example.com/aframe/alight.vwf
  11. properties:
  12. type: "point"
  13. color: "white"
  14. position: "0 10 5"
  15. rotation: "0 0 0"
  16. groundPlane:
  17. extends: http://vwf.example.com/aframe/aplane.vwf
  18. properties:
  19. height: 50
  20. width: 50
  21. repeat: "10 10"
  22. rotation: [-90, 0, 0]
  23. wireframe: false
  24. src: "#bg2"
  25. spaceText:
  26. extends: http://vwf.example.com/aframe/atext.vwf
  27. properties:
  28. value: "Virtual World Framework & A-Frame & OSC"
  29. color: "#2b5d83"
  30. position: [-2, 2.5, -3]
  31. cube:
  32. extends: http://vwf.example.com/aframe/abox.vwf
  33. properties:
  34. position: "0 1 -3"
  35. rotation: "0 0 0"
  36. color: "#3c7249"
  37. depth: 1
  38. height: 1
  39. width: 1
  40. osc: true
  41. methods:
  42. getOSC:
  43. parameters:
  44. - msg
  45. body: |
  46. this.parseColorOSC(msg);
  47. this.parseSingleOSC(msg);
  48. parseColorOSC:
  49. parameters:
  50. - msg
  51. body: |
  52. let str = msg.address + JSON.stringify(msg.args);
  53. var match = this.oscLang.grammar.match(str, "rgb");
  54. if (match.succeeded())
  55. {
  56. let res = this.oscLang.semantics(match).parse();
  57. this.setColorFromOSC(res);
  58. }
  59. setSinglePropFromOSC:
  60. parameters:
  61. - val
  62. body: |
  63. if (this.properties[val.propName]){
  64. this[val.propName] = val.propValue
  65. }
  66. setColorFromOSC:
  67. parameters:
  68. - propValue
  69. body: |
  70. this.color = propValue;
  71. //this.parent.myLight.color = propValue;
  72. parseSingleOSC:
  73. parameters:
  74. - msg
  75. body: |
  76. let str = msg.address + JSON.stringify(msg.args[0]);
  77. var match = this.oscLang.grammar.match(str, "prop");
  78. if (match.succeeded())
  79. {
  80. let res = this.oscLang.semantics(match).parse();
  81. this.setSinglePropFromOSC(res);
  82. }
  83. children:
  84. oscLang:
  85. extends: http://vwf.example.com/ohm/node.vwf
  86. properties:
  87. grammar:
  88. semantics:
  89. ohmLang: |
  90. parseOSC {
  91. rgb = "/rgb/" row
  92. row = "[" col rep "]"
  93. rep = ("," col)*
  94. col = colChar*
  95. colChar = ~("[" | "," | "]") number
  96. prop = "/" propSingle "/" number
  97. propSingle = letter*
  98. number (a number)
  99. = digit* "." digit+ -- fract
  100. | digit+ -- whole
  101. }
  102. methods:
  103. initLang:
  104. body: |
  105. console.log("add operations to semantics")
  106. this.addOperationLang();
  107. addOperationLang:
  108. body: |
  109. var self = this;
  110. this.semantics.addOperation('parse',
  111. {
  112. rgb: function(_, e)
  113. {
  114. return 'rgb('+ e.parse() + ')'
  115. },
  116. prop: function(_l, e, _r, k){
  117. return {'propName': e.parse(), 'propValue': k.parse()};
  118. },
  119. row: function(_l, e, k, _e){
  120. return e.parse() +','+ k.parse();
  121. },
  122. rep: function(_, e){ return e.parse()},
  123. col: function(e) {return e.parse()},
  124. colChar: function(e) {return e.parse()},
  125. number: function(_) {return parseFloat(this.sourceString)},
  126. propSingle: function(_){return this.sourceString}
  127. });
  128. newSky:
  129. extends: http://vwf.example.com/aframe/aentity.vwf
  130. children:
  131. skyshader:
  132. extends: http://vwf.example.com/aframe/app-skyshader-component.vwf