index.vwf.json 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {
  2. "extends": "proxy/aframe/ascene.vwf",
  3. "methods": {
  4. "initialize": {
  5. "body": " var calc = vwf_view.kernel.find(\"\", \"/calcText\")[0];\n console.log(calc);\n vwf_view.kernel.callMethod(calc, \"calcMe\");\n",
  6. "type": "application/javascript"
  7. }
  8. },
  9. "children": {
  10. "assetBG2": {
  11. "extends": "proxy/aframe/a-asset-image-item.vwf",
  12. "properties": {
  13. "itemID": "bg2",
  14. "itemSrc": "/defaults/assets/checker.jpg"
  15. }
  16. },
  17. "light1": {
  18. "extends": "proxy/aframe/alight.vwf",
  19. "properties": {
  20. "type": "ambient",
  21. "color": "#BBB"
  22. }
  23. },
  24. "light2": {
  25. "extends": "proxy/aframe/alight.vwf",
  26. "properties": {
  27. "type": "directional",
  28. "color": "#FFF",
  29. "intensity": "0.6",
  30. "position": [
  31. -0.5,
  32. 1,
  33. 1
  34. ]
  35. }
  36. },
  37. "groundPlane": {
  38. "extends": "proxy/aframe/aplane.vwf",
  39. "properties": {
  40. "height": "50",
  41. "width": "50",
  42. "rotation": [
  43. -90,
  44. 0,
  45. 0
  46. ]
  47. },
  48. "children": {
  49. "material": {
  50. "extends": "proxy/aframe/aMaterialComponent.vwf",
  51. "properties": {
  52. "wireframe": false,
  53. "src": "#bg2",
  54. "repeat": "10 10"
  55. }
  56. }
  57. }
  58. },
  59. "calcResult": {
  60. "extends": "proxy/aframe/atext.vwf",
  61. "properties": {
  62. "value": "",
  63. "color": "#1d7027",
  64. "position": [
  65. 1,
  66. 2.5,
  67. -2
  68. ],
  69. "scale": [
  70. 3,
  71. 3,
  72. 3
  73. ],
  74. "side": "double"
  75. }
  76. },
  77. "calcText": {
  78. "extends": "proxy/aframe/atext.vwf",
  79. "properties": {
  80. "value": {
  81. "set": "this.value = value; this.calcMe()",
  82. "get": "return this.value",
  83. "value": "1 * pi"
  84. },
  85. "color": "#b74217",
  86. "position": [
  87. -1,
  88. 2.5,
  89. -2
  90. ],
  91. "scale": [
  92. 2,
  93. 2,
  94. 2
  95. ],
  96. "side": "double"
  97. },
  98. "methods": {
  99. "calcMe": {
  100. "body": " let match = this.calcLang.grammar.match(this.value);\n if (match.succeeded()){\n if (typeof this.calcLang.semantics === 'function'){\n let result = this.calcLang.semantics(match).interpret(); \n if (this.parent.calcResult && (typeof this.parent.calcResult.value == 'string')) {\n this.parent.calcResult.value = result \n} \n }}\n //this.future( 0.1 ).calcMe();\n",
  101. "type": "application/javascript"
  102. }
  103. },
  104. "children": {
  105. "calcLang": {
  106. "extends": "proxy/ohm/node.vwf",
  107. "properties": {
  108. "ohmLang": "Arithmetic {\n Exp\n = AddExp\n\n AddExp\n = AddExp \"+\" MulExp -- plus\n | AddExp \"-\" MulExp -- minus\n | MulExp\n\n MulExp\n = MulExp \"*\" ExpExp -- times\n | MulExp \"/\" ExpExp -- divide\n | ExpExp\n\n ExpExp\n = PriExp \"^\" ExpExp -- power\n | PriExp\n\n PriExp\n = \"(\" Exp \")\" -- paren\n | \"+\" PriExp -- pos\n | \"-\" PriExp -- neg\n | ident\n | number\n ident (an identifier)\n = letter alnum*\n\n number (a number)\n = digit* \".\" digit+ -- fract\n | digit+ -- whole\n }\n"
  109. },
  110. "methods": {
  111. "initLang": {
  112. "body": " console.log(\"add operations to semantics\")\n this.addOperationLang();\n",
  113. "type": "application/javascript"
  114. },
  115. "addOperationLang": {
  116. "body": " var constants = {pi: Math.PI, e: Math.E};\n this.semantics.addOperation('interpret', {\n Exp: function(e) {\n return e.interpret(); \n },\n AddExp: function(e) {\n return e.interpret();\n },\n AddExp_plus: function(x, _, y) {\n return x.interpret() + y.interpret();\n },\n AddExp_minus: function(x, _, y) {\n return x.interpret() - y.interpret();\n },\n MulExp: function(e) { return e.interpret(); },\n MulExp_times: function(x, _, y) { return x.interpret() * y.interpret(); },\n MulExp_divide: function(x, _, y) { return x.interpret() / y.interpret(); },\n ExpExp: function(e) { return e.interpret(); },\n ExpExp_power: function(x, _, y) { return Math.pow(x.interpret(), y.interpret()); },\n PriExp: function(e) { return e.interpret(); },\n PriExp_paren: function(_l, e, _r) { return e.interpret(); },\n PriExp_pos: function(_, e) { return e.interpret(); },\n PriExp_neg: function(_, e) { return -e.interpret(); },\n ident: function(_l, _ns) {\n // Look up the value of a named constant, e.g., 'pi'.\n return constants[this.sourceString] || 0;\n },\n number: function(_) {\n // Use `parseFloat` to convert (e.g.) the string '123' to the number 123.\n return parseFloat(this.sourceString);\n }\n })\n",
  117. "type": "application/javascript"
  118. },
  119. "testLang": {
  120. "body": " var match = this.grammar.match('2+2');\n console.log(match);\n var res = this.semantics(match).interpret();\n console.log(res);\n",
  121. "type": "application/javascript"
  122. }
  123. }
  124. }
  125. }
  126. },
  127. "sky": {
  128. "extends": "proxy/aframe/asky.vwf",
  129. "children": {
  130. "material": {
  131. "extends": "proxy/aframe/aMaterialComponent.vwf",
  132. "properties": {
  133. "color": "#ECECEC",
  134. "side": "back"
  135. }
  136. }
  137. }
  138. }
  139. }
  140. }