123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- {
- "extends": "proxy/aframe/ascene.vwf",
- "methods": {
- "initialize": {
- "body": " console.log(\"initialising scene\");\n",
- "type": "application/javascript"
- },
- "drawLSys1": {
- "body": " this.turtle.makeLSys()\n",
- "type": "application/javascript"
- },
- "testTurtle": {
- "body": " this.turtle.goForward(1);\n this.turtle.goForward(1);\n this.turtle.turn(45);\n this.turtle.goForward(1);\n this.turtle.goForward(1);\n this.turtle.turn(45);\n this.turtle.goForward(1);\n",
- "type": "application/javascript"
- }
- },
- "children": {
- "assetBG2": {
- "extends": "proxy/aframe/a-asset-image-item.vwf",
- "properties": {
- "itemID": "bg2",
- "itemSrc": "/defaults/assets/checker.jpg"
- }
- },
- "skySun": {
- "extends": "proxy/aframe/aentity.vwf",
- "children": {
- "sun": {
- "extends": "proxy/aframe/app-sun-component.vwf"
- }
- }
- },
- "newSky": {
- "extends": "proxy/aframe/aentity.vwf",
- "children": {
- "skyshader": {
- "extends": "proxy/aframe/app-skyshader-component.vwf"
- }
- }
- },
- "groundPlane": {
- "extends": "proxy/aframe/aplane.vwf",
- "properties": {
- "height": "50",
- "width": "50",
- "rotation": [
- -90,
- 0,
- 0
- ]
- },
- "children": {
- "material": {
- "extends": "proxy/aframe/aMaterialComponent.vwf",
- "properties": {
- "wireframe": false,
- "src": "#bg2",
- "repeat": "10 10"
- }
- }
- }
- },
- "turtle": {
- "extends": "proxy/aframe/asphere.vwf",
- "properties": {
- "position": [
- 1,
- 1.25,
- -4
- ],
- "radius": "0.2",
- "angleInRadians": {
- "value": 0,
- "get": "",
- "set": ""
- },
- "iteration": {
- "value": 5,
- "get": "",
- "set": ""
- },
- "angle": {
- "value": 60,
- "get": "",
- "set": ""
- },
- "stepLength": {
- "value": 0.3,
- "get": "",
- "set": ""
- },
- "rule": {
- "value": "F",
- "get": "",
- "set": ""
- },
- "axiomF": {
- "value": "G-F-G",
- "get": "",
- "set": ""
- },
- "axiomG": {
- "value": "F+G+F",
- "get": "",
- "set": ""
- },
- "lsys": {
- "value": "",
- "get": "",
- "set": ""
- },
- "readyForDraw": {
- "value": true,
- "get": "",
- "set": ""
- }
- },
- "methods": {
- "parseLSys": {
- "body": " var str = this.rule;\n var axioms = {\"F\": this.axiomF, \"G\": this.axiomG};\n for (var i = 1; i < this.iteration; i++)\n {\n var match = this.lsysLang.grammar.match(str, 'Gen<\"y\">');\n if (match.succeeded()){\n var res = this.lsysLang.semantics(match).gen(axioms);\n str = res.join(\"\");\n }\n }\n console.log(str);\n this.lsys = str;\n",
- "type": "application/javascript"
- },
- "makeLSys": {
- "body": " if (this.readyForDraw){\n this.drawNode.position = [0, 0, 0]\n this.angleInRadians = 0;\n this.drawNode.linepath.path = [];\n this.parseLSys();\n this.drawLSys();\n this.drawNode.position = [0, 0, 0]\n }\n",
- "type": "application/javascript"
- },
- "drawLSys": {
- "body": " var match = this.turtleLang.grammar.match(this.lsys, 'Draw<\"1\",\"1\">');\n if (match.succeeded()){\n var res = this.turtleLang.semantics(match).draw(this.stepLength, this.angle);\n }\n",
- "type": "application/javascript"
- },
- "turn": {
- "parameters": [
- "angle"
- ],
- "body": " var angle0 = this.angleInRadians;\n var targetAngle = angle * Math.PI / 180.0;\n this.angleInRadians = angle0 + targetAngle;\n",
- "type": "application/javascript"
- },
- "goForward": {
- "parameters": [
- "step"
- ],
- "body": " let pos = this.drawNode.position;\n var x0 = pos[0];\n var y0 = pos[1];\n var xx = Math.sin(this.angleInRadians);\n var yy = Math.cos(this.angleInRadians);\n let startPosition = {x: pos[0], y: pos[1], z:pos[2]};\n let endPosition = {x: x0 + step * xx, y: y0 + step * yy, z: pos[2]};\n var drawPath = this.drawNode.linepath.path.slice();\n drawPath.push(startPosition);\n drawPath.push(endPosition);\n this.drawNode.linepath.path = drawPath;\n this.drawNode.position = [endPosition.x, endPosition.y, endPosition.z];\n",
- "type": "application/javascript"
- },
- "setTurtleParams": {
- "parameters": [
- "val"
- ],
- "body": " this.readyForDraw = false;\n val.forEach(el => {\n this[el[0]] = el[1]\n })\n this.readyForDraw = true;\n this.makeLSys();\n",
- "type": "application/javascript"
- },
- "initialize": {
- "body": " //this.redrawEvent = function(){this.makeLSys()}\n vwf_view.kernel.callMethod(this.id, \"makeLSys\");\n console.log(\"initialising turtle\");\n",
- "type": "application/javascript"
- }
- },
- "children": {
- "interpolation": {
- "extends": "proxy/aframe/interpolation-component.vwf",
- "properties": {
- "enabled": true
- }
- },
- "material": {
- "extends": "proxy/aframe/aMaterialComponent.vwf",
- "properties": {
- "wireframe": true,
- "color": "#e0e014"
- }
- },
- "drawNode": {
- "extends": "proxy/aframe/aentity.vwf",
- "properties": {
- "position": [
- 0,
- 0,
- 0
- ]
- },
- "children": {
- "linepath": {
- "extends": "proxy/aframe/linepath.vwf",
- "properties": {
- "color": "#445447",
- "path": [
- ],
- "width": 0.02
- }
- }
- }
- },
- "lsysLang": {
- "extends": "proxy/ohm/node.vwf",
- "properties": {
- "ohmLang": "LSys { Gen<x> \n = ReadRule+ \n ReadRule \n = letters | symbols\n letters = \"F\" | \"G\" \n symbols = \"-\" | \"+\" }\n"
- },
- "methods": {
- "initLang": {
- "body": " console.log(\"add operations to semantics\")\n this.addOperationLang();\n",
- "type": "application/javascript"
- },
- "addOperationLang": {
- "body": " this.semantics.addOperation('gen(x)', {\n Gen: function(e)\n {\n return e.gen(this.args.x);\n },\n ReadRule: function(e)\n {\n return e.gen(this.args.x);\n },\n letters: function(_)\n {\n for (var propName in this.args.x)\n {\n if (propName == this.sourceString)\n return this.args.x[propName]\n }\n return this.sourceString\n },\n symbols: function(_)\n {\n return this.sourceString;\n }\n });\n",
- "type": "application/javascript"
- }
- }
- },
- "turtleLang": {
- "extends": "proxy/ohm/node.vwf",
- "properties": {
- "ohmLang": "Turtle {\nDraw<x, y> \n = (drawLetter | turn)+ \ndrawLetter \n = letter\nturn \n = \"+\" | \"-\" }\n"
- },
- "methods": {
- "initLang": {
- "body": " console.log(\"add operations to semantics\")\n this.addOperationLang();\n",
- "type": "application/javascript"
- },
- "addOperationLang": {
- "body": " var turtleID = this.parent.id;\n var self = this;\n this.semantics.addOperation('draw(x,y)', {\n Draw: function(e)\n {\n e.draw(this.args.x, this.args.y);\n },\n drawLetter: function(e)\n {\n //vwf_view.kernel.callMethod(turtleID, 'goForward', [this.args.x]);\n self.parent.goForward(this.args.x);\n },\n turn: function(e)\n {\n if (this.sourceString == \"+\")\n //vwf_view.kernel.callMethod(turtleID, 'turn', [this.args.y]);\n self.parent.turn(this.args.y);\n if (this.sourceString == \"-\")\n //vwf_view.kernel.callMethod(turtleID, 'turn', [-1 * this.args.y]);\n self.parent.turn(-1*this.args.y);\n }\n });\n",
- "type": "application/javascript"
- }
- }
- }
- }
- }
- }
- }
|