index.vwf.yaml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. children:
  41. sphere:
  42. extends: http://vwf.example.com/aframe/asphere.vwf
  43. properties:
  44. position: "0 2 0"
  45. rotation: "0 0 0"
  46. color: "#3c7249"
  47. radius: 0.4
  48. newSky:
  49. extends: http://vwf.example.com/aframe/aentity.vwf
  50. children:
  51. skyshader:
  52. extends: http://vwf.example.com/aframe/app-skyshader-component.vwf
  53. oscLang:
  54. extends: http://vwf.example.com/ohm/node.vwf
  55. properties:
  56. osc: true
  57. grammar:
  58. semantics:
  59. ohmLang: |
  60. parseOSC {
  61. all = address ":" props
  62. address = ("/" addr)*
  63. addr = ~("/") propSingle
  64. props
  65. = propSingle row -- single
  66. | "rgb" row -- rgb
  67. | propSingle number -- prop
  68. row = "[" col rep "]"
  69. rep = ("," col)*
  70. col = colChar*
  71. colChar = ~("[" | "," | "]") number
  72. propSingle = ~("rgb") letter*
  73. number (a number)
  74. = digit* "." digit+ -- fract
  75. | digit+ -- whole
  76. }
  77. methods:
  78. initLang:
  79. body: |
  80. console.log("add operations to semantics")
  81. this.addOperationLang();
  82. addOperationLang:
  83. body: |
  84. var self = this;
  85. this.semantics.addOperation('parse',
  86. {
  87. all: function(e, _, k){ return {"address": e.parse(), "params": k.parse()} },
  88. address: function(_, e){ return e.parse()},
  89. addr: function(e) {return e.parse() },
  90. props: function(e) {return e.parse()},
  91. props_single: function( e, k){
  92. return {'propName': e.parse(), 'propValue': k.parse()};
  93. },
  94. props_rgb: function(_, e)
  95. {
  96. return {'propName': 'color', 'propValue': ['rgb('+ e.parse() + ')']};
  97. },
  98. props_prop: function(e, k){
  99. return {'propName': e.parse(), 'propValue': k.parse()};
  100. },
  101. row: function(_l, e, k, _e){
  102. let end = k.parse();
  103. if (end.length !== 0) {
  104. return e.parse() +','+ k.parse();
  105. }
  106. return e.parse()
  107. },
  108. rep: function(_, e){ return e.parse()},
  109. col: function(e) {return e.parse()},
  110. colChar: function(e) {return e.parse()},
  111. number: function(_) {return parseFloat(this.sourceString)},
  112. propSingle: function(_){return this.sourceString}
  113. });
  114. getOSC:
  115. parameters:
  116. - msg
  117. body: |
  118. this.parseOSC(msg);
  119. parseOSC:
  120. parameters:
  121. - msg
  122. body: |
  123. let str = msg.address + JSON.stringify(msg.args);
  124. var match = this.grammar.match(str, "all");
  125. if (match.succeeded())
  126. {
  127. let res = this.semantics(match).parse();
  128. this.setPropsFromOSC(res);
  129. }
  130. setPropsFromOSC:
  131. parameters:
  132. - res
  133. body: |
  134. //console.log(res);
  135. let address = '/'+res.address.join('/');
  136. let nodeID = vwf.find("", address);
  137. if (res.params.propValue.length == 1) {
  138. vwf_view.kernel.setProperty(nodeID, res.params.propName, [res.params.propValue[0]])
  139. }
  140. if (res.params.propValue.length >= 1) {
  141. vwf_view.kernel.setProperty(nodeID, res.params.propName, [res.params.propValue])
  142. }