index.vwf.yaml 5.1 KB

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