appui.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. function createApp() {
  2. let self = this
  3. function makeSetter(val) {
  4. let setstr = 'this.' + val + '= value; this.redrawEvent();'
  5. return setstr
  6. }
  7. function getNewPosition() {
  8. //let allChild = vwf.find("","/*")
  9. let cursorVisID = vwf.find("avatar-" + vwf.moniker_, "./avatarNode/myHead")[0];
  10. let avPos = AFRAME.utils.coordinates.parse(vwf.callMethod(cursorVisID, 'worldPosition'));
  11. let newPos = [avPos.x, avPos.y, avPos.z]
  12. return newPos
  13. }
  14. return {
  15. $cell: true,
  16. $type: "div",
  17. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  18. $components: [
  19. {
  20. $cell: true,
  21. $type: "div",
  22. class: "mdc-layout-grid__inner",
  23. $components: [
  24. {
  25. $cell: true,
  26. $type: "div",
  27. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  28. $components: [
  29. // {
  30. // $cell: true,
  31. // $type: "button",
  32. // class: "mdc-button mdc-button--raised",
  33. // $text: "Draw L-System",
  34. // onclick: function (e) {
  35. // let sceneID = vwf.find("","/")[0];
  36. // vwf_view.kernel.callMethod(sceneID, "drawLSys1");
  37. // }
  38. // },
  39. {
  40. $cell: true,
  41. $type: "button",
  42. class: "mdc-button mdc-button--raised",
  43. $text: "Create new turtle",
  44. onclick: function (e) {
  45. let sceneID = vwf.find("", "/")[0];
  46. let turtleID = vwf.find("", "/turtle")[0];
  47. console.log("create new turtle");
  48. let newTurtle = _app.helpers.getNodeDef(turtleID);//vwf.getNode(turtleID, true);
  49. //newTurtle.properties.position = getNewPosition();
  50. let randomName = "turtle-new-" + _app.helpers.GUID();
  51. vwf_view.kernel.callMethod(sceneID, "createTurtle", [randomName, newTurtle, "avatar-" + vwf.moniker_]);
  52. //vwf_view.kernel.createChild(sceneID, randomName, newTurtle);
  53. }
  54. }
  55. ]
  56. },
  57. {
  58. $cell: true,
  59. $type: "div",
  60. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  61. $components: [
  62. {
  63. $type: "img",
  64. src: "/defaults/assets/lsys/Koch.jpg",
  65. class: "mdc-elevation--z2",
  66. style: "width: 150px",
  67. onclick: function (evt) {
  68. let turtleID = vwf.find("", "/turtle")[0];
  69. let params = {
  70. "angle": 60,
  71. "iteration": 3,
  72. "stepLength": 0.3,
  73. "rule": 'F++F++F',
  74. "axiomF": 'F-F++F-F',
  75. "axiomG": ''
  76. }
  77. vwf_view.kernel.callMethod(turtleID, 'setTurtleParams', [Object.entries(params)])
  78. }
  79. }
  80. ]
  81. },
  82. {
  83. $cell: true,
  84. $type: "div",
  85. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  86. $components: [
  87. {
  88. $type: "img",
  89. src: "/defaults/assets/lsys/dragon.jpg",
  90. class: "mdc-elevation--z2",
  91. style: "width: 150px",
  92. onclick: function (evt) {
  93. let turtleID = vwf.find("", "/turtle")[0];
  94. let params = {
  95. "angle": 90,
  96. "iteration": 10,
  97. "stepLength": 0.3,
  98. "rule": 'F',
  99. "axiomF": 'F+G+',
  100. "axiomG": '-F-G'
  101. }
  102. vwf_view.kernel.callMethod(turtleID, 'setTurtleParams', [Object.entries(params)])
  103. }
  104. }
  105. ]
  106. },
  107. {
  108. $cell: true,
  109. $type: "div",
  110. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  111. $components: [
  112. {
  113. $type: "img",
  114. src: "/defaults/assets/lsys/SierpinskiCurve.jpg",
  115. class: "mdc-elevation--z2",
  116. style: "width: 150px",
  117. onclick: function (evt) {
  118. let turtleID = vwf.find("", "/turtle")[0];
  119. let params = {
  120. "angle": 60,
  121. "iteration": 5,
  122. "stepLength": 0.3,
  123. "rule": 'F',
  124. "axiomF": 'G-F-G',
  125. "axiomG": 'F+G+F'
  126. }
  127. vwf_view.kernel.callMethod(turtleID, 'setTurtleParams', [Object.entries(params)])
  128. }
  129. }
  130. ]
  131. },
  132. {
  133. $cell: true,
  134. $type: "div",
  135. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  136. $components: [
  137. {
  138. $type: "img",
  139. src: "/defaults/assets/lsys/SierpinskiTriangle.jpg",
  140. class: "mdc-elevation--z2",
  141. style: "width: 150px",
  142. onclick: function (evt) {
  143. let turtleID = vwf.find("", "/turtle")[0];
  144. let params = {
  145. "angle": 120,
  146. "iteration": 5,
  147. "stepLength": 0.3,
  148. "rule": 'F--F--F',
  149. "axiomF": 'F--F--F--G',
  150. "axiomG": 'GG'
  151. }
  152. vwf_view.kernel.callMethod(turtleID, 'setTurtleParams', [Object.entries(params)])
  153. }
  154. }
  155. ]
  156. }
  157. ]
  158. }
  159. ]
  160. }
  161. }