index.vwf.yaml 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  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. assets: "assets.json"
  7. children:
  8. fog:
  9. extends: http://vwf.example.com/aframe/aSceneFogComponent.vwf
  10. type: "component"
  11. properties:
  12. fogType: "linear"
  13. fogColor: "#ECECEC"
  14. far: 20
  15. near: 0
  16. myLight:
  17. extends: http://vwf.example.com/aframe/alight.vwf
  18. properties:
  19. type: "point"
  20. color: "white"
  21. position: "0 10 5"
  22. rotation: "0 0 0"
  23. groundPlane:
  24. extends: http://vwf.example.com/aframe/aplane.vwf
  25. properties:
  26. height: 50
  27. width: 50
  28. rotation: [-90, 0, 0]
  29. children:
  30. material:
  31. extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
  32. properties:
  33. wireframe: false
  34. src: "#bg2"
  35. repeat: "10 10"
  36. spaceText:
  37. extends: http://vwf.example.com/aframe/atext.vwf
  38. properties:
  39. value: "Virtual World Framework & A-Frame & OSC"
  40. color: "#2b5d83"
  41. position: [-2, 2.5, -3]
  42. cube:
  43. extends: http://vwf.example.com/aframe/abox.vwf
  44. properties:
  45. position: "0 1 -3"
  46. rotation: "0 0 0"
  47. depth: 1
  48. height: 1
  49. width: 1
  50. children:
  51. material:
  52. extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
  53. properties:
  54. color: "#3c7249"
  55. sphere:
  56. extends: http://vwf.example.com/aframe/asphere.vwf
  57. properties:
  58. position: "0 2 0"
  59. rotation: "0 0 0"
  60. radius: 0.4
  61. children:
  62. material:
  63. extends: http://vwf.example.com/aframe/aMaterialComponent.vwf
  64. properties:
  65. color: "#3c7249"
  66. newSky:
  67. extends: http://vwf.example.com/aframe/aentity.vwf
  68. children:
  69. skyshader:
  70. extends: http://vwf.example.com/aframe/app-skyshader-component.vwf
  71. oscLang:
  72. extends: http://vwf.example.com/ohm/node.vwf
  73. properties:
  74. osc: true
  75. grammar:
  76. semantics:
  77. ohmLang: |
  78. parseOSC {
  79. all = address ":" props
  80. address = ("/" addr)*
  81. addr = ~("/") propSingle
  82. props
  83. = propSingle row -- single
  84. | "rgb" row -- rgb
  85. | propSingle number -- prop
  86. row = "[" col rep "]"
  87. rep = ("," col)*
  88. col = colChar*
  89. colChar = ~("[" | "," | "]") number
  90. propSingle = ~("rgb") letter*
  91. number (a number)
  92. = digit* "." digit+ -- fract
  93. | digit+ -- whole
  94. }
  95. methods:
  96. initLang:
  97. body: |
  98. console.log("add operations to semantics")
  99. this.addOperationLang();
  100. addOperationLang:
  101. body: |
  102. var self = this;
  103. this.semantics.addOperation('parse',
  104. {
  105. all: function(e, _, k){ return {"address": e.parse(), "params": k.parse()} },
  106. address: function(_, e){ return e.parse()},
  107. addr: function(e) {return e.parse() },
  108. props: function(e) {return e.parse()},
  109. props_single: function( e, k){
  110. return {'propName': e.parse(), 'propValue': k.parse()};
  111. },
  112. props_rgb: function(_, e)
  113. {
  114. return {'propName': 'color', 'propValue': ['rgb('+ e.parse() + ')']};
  115. },
  116. props_prop: function(e, k){
  117. return {'propName': e.parse(), 'propValue': k.parse()};
  118. },
  119. row: function(_l, e, k, _e){
  120. let end = k.parse();
  121. if (end.length !== 0) {
  122. return e.parse() +','+ k.parse();
  123. }
  124. return e.parse()
  125. },
  126. rep: function(_, e){ return e.parse()},
  127. col: function(e) {return e.parse()},
  128. colChar: function(e) {return e.parse()},
  129. number: function(_) {return parseFloat(this.sourceString)},
  130. propSingle: function(_){return this.sourceString}
  131. });
  132. getOSC:
  133. parameters:
  134. - msg
  135. body: |
  136. this.parseOSC(msg);
  137. parseOSC:
  138. parameters:
  139. - msg
  140. body: |
  141. let str = msg.address + JSON.stringify(msg.args);
  142. var match = this.grammar.match(str, "all");
  143. if (match.succeeded())
  144. {
  145. let res = this.semantics(match).parse();
  146. this.setPropsFromOSC(res);
  147. }
  148. setPropsFromOSC:
  149. parameters:
  150. - res
  151. body: |
  152. //console.log(res);
  153. let address = '/'+res.address.join('/');
  154. let nodeID = vwf.find("", address);
  155. if (res.params.propValue.length == 1) {
  156. vwf_view.kernel.setProperty(nodeID, res.params.propName, [res.params.propValue[0]])
  157. }
  158. if (res.params.propValue.length >= 1) {
  159. vwf_view.kernel.setProperty(nodeID, res.params.propName, [res.params.propValue])
  160. }