{"action":"created","comment":{"url":"https://api.github.com/repos/ninjadev/nin/pulls/comments/71612267","id":71612267,"diff_hunk":"@@ -0,0 +1,132 @@\n+class NodeManager {\n+\n+  constructor() {\n+    this.nodes = {};\n+    this.graphChangeListeners = [];\n+  }\n+\n+  onGraphChange(fn) {\n+    this.graphChangeListeners.push(fn);\n+  }\n+\n+  fireGraphChange() {\n+    console.log('graph change!');\n+    for(var i = 0; i < this.graphChangeListeners.length; i++) {\n+      this.graphChangeListeners[i]();\n+    }\n+  }\n+\n+  createNode(nodeInfo) {\n+    nodeInfo.options = nodeInfo.options || {};\n+    var node;\n+    if(nodeInfo.type.slice(0, 4) == 'NIN.') {\n+      node = new NIN[nodeInfo.type.slice(4)](nodeInfo.id, nodeInfo.options);\n+    } else {\n+      node = new window[nodeInfo.type](nodeInfo.id, nodeInfo.options);\n+    }\n+    for(var key in node.inputs) {\n+      node.inputs[key].node = node;\n+    }\n+    for(var key in node.outputs) {\n+      node.outputs[key].node = node;\n+    }\n+    return node;\n+  }\n+\n+  insertNode(node) {\n+    if(this.nodes[node.id]) {\n+      for(var key in this.nodes[node.id].inputs) {\n+        if(this.nodes[node.id].inputs[key].source) {\n+          node.inputs[key].source = this.nodes[node.id].inputs[key].source;\n+          node.inputs[key].source.destination = node.inputs[key];\n+        }\n+      }\n+      for(var key in this.nodes[node.id].outputs) {\n+        if(this.nodes[node.id].outputs[key].destination) {\n+          node.outputs[key].destination = this.nodes[node.id].outputs[key].destination;\n+          node.outputs[key].destination.source = node.outputs[key];\n+        }\n+      }\n+    }\n+    this.nodes[node.id] = node;\n+    this.fireGraphChange();\n+  }\n+\n+  connect(fromNodeId, outputName, toNodeId, inputName) {\n+    this.nodes[fromNodeId].outputs[outputName].destination =\n+      this.nodes[toNodeId].inputs[inputName];\n+    this.nodes[toNodeId].inputs[inputName].source =\n+      this.nodes[fromNodeId].outputs[outputName];\n+    this.fireGraphChange();\n+  }\n+\n+  resize() {\n+    for(var key in this.nodes) {\n+      this.nodes[key].resize(); \n+    }\n+  }\n+\n+  traverseNodeGraphPostOrderDfs(node, fn, visitedSet) {","path":"nin/dasBoot/NodeManager.js","position":69,"original_position":69,"commit_id":"74e11e39811303cc575cfc5443c9af6675310870","original_commit_id":"74e11e39811303cc575cfc5443c9af6675310870","user":{"login":"aleksanb","id":1413365,"avatar_url":"https://avatars.githubusercontent.com/u/1413365?v=3","gravatar_id":"","url":"https://api.github.com/users/aleksanb","html_url":"https://github.com/aleksanb","followers_url":"https://api.github.com/users/aleksanb/followers","following_url":"https://api.github.com/users/aleksanb/following{/other_user}","gists_url":"https://api.github.com/users/aleksanb/gists{/gist_id}","starred_url":"https://api.github.com/users/aleksanb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aleksanb/subscriptions","organizations_url":"https://api.github.com/users/aleksanb/orgs","repos_url":"https://api.github.com/users/aleksanb/repos","events_url":"https://api.github.com/users/aleksanb/events{/privacy}","received_events_url":"https://api.github.com/users/aleksanb/received_events","type":"User","site_admin":false},"body":"Nope! They're evaluated at each call time!","created_at":"2016-07-20T21:42:47Z","updated_at":"2016-07-20T21:42:47Z","html_url":"https://github.com/ninjadev/nin/pull/254#discussion_r71612267","pull_request_url":"https://api.github.com/repos/ninjadev/nin/pulls/254","_links":{"self":{"href":"https://api.github.com/repos/ninjadev/nin/pulls/comments/71612267"},"html":{"href":"https://github.com/ninjadev/nin/pull/254#discussion_r71612267"},"pull_request":{"href":"https://api.github.com/repos/ninjadev/nin/pulls/254"}}},"pull_request":{"url":"https://api.github.com/repos/ninjadev/nin/pulls/254","id":78209530,"html_url":"https://github.com/ninjadev/nin/pull/254","diff_url":"https://github.com/ninjadev/nin/pull/254.diff","patch_url":"https://github.com/ninjadev/nin/pull/254.patch","issue_url":"https://api.github.com/repos/ninjadev/nin/issues/254","number":254,"state":"open","locked":false,"title":"Shift paradigm from layers to nodes","user":{"login":"sigvef","id":578029,"avatar_url":"https://avatars.githubusercontent.com/u/578029?v=3","gravatar_id":"","url":"https://api.github.com/users/sigvef","html_url":"https://github.com/sigvef","followers_url":"https://api.github.com/users/sigvef/followers","following_url":"https://api.github.com/users/sigvef/following{/other_user}","gists_url":"https://api.github.com/users/sigvef/gists{/gist_id}","starred_url":"https://api.github.com/users/sigvef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sigvef/subscriptions","organizations_url":"https://api.github.com/users/sigvef/orgs","repos_url":"https://api.github.com/users/sigvef/repos","events_url":"https://api.github.com/users/sigvef/events{/privacy}","received_events_url":"https://api.github.com/users/sigvef/received_events","type":"User","site_admin":false},"body":"![image](https://cloud.githubusercontent.com/assets/578029/17000987/6d38a7ac-4ec5-11e6-8fb0-7a351829e284.png)\r\n\r\n\r\nThis commit shifts the central paradigm of nin from being a layer-based\r\nsystem to being a node-based system. Not all features have been ported\r\nover to the new system, although it is certainly complete enough to be\r\nused to make demos. Hopefully we are willing to merge this sooner rather\r\nthan later, and we can then later fix the rest of the features as they\r\nare needed.\r\n\r\n* Overview\r\n\r\nBefore, a demo in nin would consist of several layers in an ordered\r\nlist. Each layer would have a start time and end time, and each\r\nlayer's update and render methods would be called with the usual\r\nupdate/render call semantics while demo time was within a layer's start\r\nand end times. Each layer exposed an EffectComposer pass, and all passes\r\nfor active layers were chained together in a top-to-bottom such that the\r\nnext layer could optionally access the rendered data of the previous\r\nlayer.\r\n\r\nNow, a demo in nin consists of several nodes in a graph. Nodes do not\r\nhave start times or end times. Rather, the graph is traversed from a\r\ndesignated root node in order call update and render for each of the\r\nreachable nodes. A node may enable or disable their inputs, which serves\r\nas temporary graph modification in order to \"connect and disconnect\"\r\ndifferent nodes at different times in the demo. This is the spiritual\r\nreplacement of start times and end times from the layer system.  The big\r\nadvantage of the new node-based system over the old layer system  is\r\nthat it is now easier to create more advanced multi-pass rendering\r\npipelines.\r\n\r\n* Nodes and the graph\r\n\r\nNodes have different types, and all nodes inherit from the base\r\nNIN.Node. A node type may declare a number of named and typed inputs and\r\noutputs. Nodes may produce data and store it in their outputs. Connected\r\nnodes may then read that same data from their inputs. The directed graph\r\nof connections from node outputs to node inputs may not contain cycles.\r\n\r\nThe graph is stored in res/graph.json, which is analogous to the old\r\nres/layers.json. Because of the frequency of graph edits in the UI\r\n(particularly dragging nodes to change their position), and in the\r\ninterest of simplicity and performance, res/graph.json is not actively\r\nwatched for changes on disk after the first load at the beginning of\r\n`nin run`. The intention is that most changes to res/graph.json should\r\nbe made via the UI.\r\n\r\nCurrently, all graphs *must* have a node of type NIN.RootNode called\r\nroot in order for the demo to update and render properly. This node is\r\nthe root node that is used for traversal during update and render, and\r\nthe texture made available to the root node's only input root.screen is\r\nwhat is finally showed on the screen.\r\n\r\nThe LayerManager of old has been replaced with an analogous NodeManager.\r\n\r\n* Current state of features\r\n\r\nThis section elaborates upon the different features of nin and their\r\ncurrent state with regards to the paradigm shift. Features that are not\r\naffected are probably not mentioned here.\r\n\r\n** Node graph viewer / editor\r\n\r\nReplacing the old layer viewer/editor, the node graph viewer / editor\r\ncurrently supports visualization of the graph including connections and\r\nactiveness of nodes. Nodes are persistently draggable. The viewer is\r\npan/zoom-enabled, but has no pan/zoom persistence. It is currently not\r\npossible to create or delete nodes or connections.\r\n\r\n** Generate\r\n\r\nThis has not been touched, so it most likely does not work.\r\n\r\n** Compilation\r\n\r\nThis has not been touched, so it most likely does not work.\r\n\r\n** Init\r\n\r\nThis has not been touched, so it most likely does not work.\r\n\r\n** Backend res/layers.json / res/graph.js manipulation\r\n\r\nThis has been updated and works for whatever it is being used for in\r\nthis commit, but has not been scrutinized for completeness.\r\n\r\n** Shader updates\r\n\r\nThis is probably broken. Perhaps we can leverage the node system in\r\norder to make it less grep-y in the future.\r\n\r\n** Camera paths, fly-around mode\r\n\r\nThis is probably broken.\r\n\r\n** Layer / Node inspection\r\n\r\nNodes can no longer be inspected, but inputs and outputs can. Currently,\r\nthe only inspectable inputs/outputs are texture input/outputs. When\r\ninspected, they will render their texture to the demo screen after the\r\nregular render pass is finished.","created_at":"2016-07-20T20:00:57Z","updated_at":"2016-07-20T21:42:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0fabb880c0b8e3c67f89085dab8b25557814c5f5","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ninjadev/nin/pulls/254/commits","review_comments_url":"https://api.github.com/repos/ninjadev/nin/pulls/254/comments","review_comment_url":"https://api.github.com/repos/ninjadev/nin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ninjadev/nin/issues/254/comments","statuses_url":"https://api.github.com/repos/ninjadev/nin/statuses/74e11e39811303cc575cfc5443c9af6675310870","head":{"label":"ninjadev:paradigm-shift","ref":"paradigm-shift","sha":"74e11e39811303cc575cfc5443c9af6675310870","user":{"login":"ninjadev","id":1992931,"avatar_url":"https://avatars.githubusercontent.com/u/1992931?v=3","gravatar_id":"","url":"https://api.github.com/users/ninjadev","html_url":"https://github.com/ninjadev","followers_url":"https://api.github.com/users/ninjadev/followers","following_url":"https://api.github.com/users/ninjadev/following{/other_user}","gists_url":"https://api.github.com/users/ninjadev/gists{/gist_id}","starred_url":"https://api.github.com/users/ninjadev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ninjadev/subscriptions","organizations_url":"https://api.github.com/users/ninjadev/orgs","repos_url":"https://api.github.com/users/ninjadev/repos","events_url":"https://api.github.com/users/ninjadev/events{/privacy}","received_events_url":"https://api.github.com/users/ninjadev/received_events","type":"Organization","site_admin":false},"repo":{"id":13017625,"name":"nin","full_name":"ninjadev/nin","owner":{"login":"ninjadev","id":1992931,"avatar_url":"https://avatars.githubusercontent.com/u/1992931?v=3","gravatar_id":"","url":"https://api.github.com/users/ninjadev","html_url":"https://github.com/ninjadev","followers_url":"https://api.github.com/users/ninjadev/followers","following_url":"https://api.github.com/users/ninjadev/following{/other_user}","gists_url":"https://api.github.com/users/ninjadev/gists{/gist_id}","starred_url":"https://api.github.com/users/ninjadev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ninjadev/subscriptions","organizations_url":"https://api.github.com/users/ninjadev/orgs","repos_url":"https://api.github.com/users/ninjadev/repos","events_url":"https://api.github.com/users/ninjadev/events{/privacy}","received_events_url":"https://api.github.com/users/ninjadev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ninjadev/nin","description":"nin is ninjatool","fork":false,"url":"https://api.github.com/repos/ninjadev/nin","forks_url":"https://api.github.com/repos/ninjadev/nin/forks","keys_url":"https://api.github.com/repos/ninjadev/nin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ninjadev/nin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ninjadev/nin/teams","hooks_url":"https://api.github.com/repos/ninjadev/nin/hooks","issue_events_url":"https://api.github.com/repos/ninjadev/nin/issues/events{/number}","events_url":"https://api.github.com/repos/ninjadev/nin/events","assignees_url":"https://api.github.com/repos/ninjadev/nin/assignees{/user}","branches_url":"https://api.github.com/repos/ninjadev/nin/branches{/branch}","tags_url":"https://api.github.com/repos/ninjadev/nin/tags","blobs_url":"https://api.github.com/repos/ninjadev/nin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ninjadev/nin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ninjadev/nin/git/refs{/sha}","trees_url":"https://api.github.com/repos/ninjadev/nin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ninjadev/nin/statuses/{sha}","languages_url":"https://api.github.com/repos/ninjadev/nin/languages","stargazers_url":"https://api.github.com/repos/ninjadev/nin/stargazers","contributors_url":"https://api.github.com/repos/ninjadev/nin/contributors","subscribers_url":"https://api.github.com/repos/ninjadev/nin/subscribers","subscription_url":"https://api.github.com/repos/ninjadev/nin/subscription","commits_url":"https://api.github.com/repos/ninjadev/nin/commits{/sha}","git_commits_url":"https://api.github.com/repos/ninjadev/nin/git/commits{/sha}","comments_url":"https://api.github.com/repos/ninjadev/nin/comments{/number}","issue_comment_url":"https://api.github.com/repos/ninjadev/nin/issues/comments{/number}","contents_url":"https://api.github.com/repos/ninjadev/nin/contents/{+path}","compare_url":"https://api.github.com/repos/ninjadev/nin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ninjadev/nin/merges","archive_url":"https://api.github.com/repos/ninjadev/nin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ninjadev/nin/downloads","issues_url":"https://api.github.com/repos/ninjadev/nin/issues{/number}","pulls_url":"https://api.github.com/repos/ninjadev/nin/pulls{/number}","milestones_url":"https://api.github.com/repos/ninjadev/nin/milestones{/number}","notifications_url":"https://api.github.com/repos/ninjadev/nin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ninjadev/nin/labels{/name}","releases_url":"https://api.github.com/repos/ninjadev/nin/releases{/id}","deployments_url":"https://api.github.com/repos/ninjadev/nin/deployments","created_at":"2013-09-22T17:30:37Z","updated_at":"2016-07-08T16:52:15Z","pushed_at":"2016-07-20T20:24:38Z","git_url":"git://github.com/ninjadev/nin.git","ssh_url":"git@github.com:ninjadev/nin.git","clone_url":"https://github.com/ninjadev/nin.git","svn_url":"https://github.com/ninjadev/nin","homepage":null,"size":36971,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":19,"forks":1,"open_issues":19,"watchers":13,"default_branch":"master"}},"base":{"label":"ninjadev:master","ref":"master","sha":"fd23b9dc813f714e6d310188e9addceba9f3cfe3","user":{"login":"ninjadev","id":1992931,"avatar_url":"https://avatars.githubusercontent.com/u/1992931?v=3","gravatar_id":"","url":"https://api.github.com/users/ninjadev","html_url":"https://github.com/ninjadev","followers_url":"https://api.github.com/users/ninjadev/followers","following_url":"https://api.github.com/users/ninjadev/following{/other_user}","gists_url":"https://api.github.com/users/ninjadev/gists{/gist_id}","starred_url":"https://api.github.com/users/ninjadev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ninjadev/subscriptions","organizations_url":"https://api.github.com/users/ninjadev/orgs","repos_url":"https://api.github.com/users/ninjadev/repos","events_url":"https://api.github.com/users/ninjadev/events{/privacy}","received_events_url":"https://api.github.com/users/ninjadev/received_events","type":"Organization","site_admin":false},"repo":{"id":13017625,"name":"nin","full_name":"ninjadev/nin","owner":{"login":"ninjadev","id":1992931,"avatar_url":"https://avatars.githubusercontent.com/u/1992931?v=3","gravatar_id":"","url":"https://api.github.com/users/ninjadev","html_url":"https://github.com/ninjadev","followers_url":"https://api.github.com/users/ninjadev/followers","following_url":"https://api.github.com/users/ninjadev/following{/other_user}","gists_url":"https://api.github.com/users/ninjadev/gists{/gist_id}","starred_url":"https://api.github.com/users/ninjadev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ninjadev/subscriptions","organizations_url":"https://api.github.com/users/ninjadev/orgs","repos_url":"https://api.github.com/users/ninjadev/repos","events_url":"https://api.github.com/users/ninjadev/events{/privacy}","received_events_url":"https://api.github.com/users/ninjadev/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ninjadev/nin","description":"nin is ninjatool","fork":false,"url":"https://api.github.com/repos/ninjadev/nin","forks_url":"https://api.github.com/repos/ninjadev/nin/forks","keys_url":"https://api.github.com/repos/ninjadev/nin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ninjadev/nin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ninjadev/nin/teams","hooks_url":"https://api.github.com/repos/ninjadev/nin/hooks","issue_events_url":"https://api.github.com/repos/ninjadev/nin/issues/events{/number}","events_url":"https://api.github.com/repos/ninjadev/nin/events","assignees_url":"https://api.github.com/repos/ninjadev/nin/assignees{/user}","branches_url":"https://api.github.com/repos/ninjadev/nin/branches{/branch}","tags_url":"https://api.github.com/repos/ninjadev/nin/tags","blobs_url":"https://api.github.com/repos/ninjadev/nin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ninjadev/nin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ninjadev/nin/git/refs{/sha}","trees_url":"https://api.github.com/repos/ninjadev/nin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ninjadev/nin/statuses/{sha}","languages_url":"https://api.github.com/repos/ninjadev/nin/languages","stargazers_url":"https://api.github.com/repos/ninjadev/nin/stargazers","contributors_url":"https://api.github.com/repos/ninjadev/nin/contributors","subscribers_url":"https://api.github.com/repos/ninjadev/nin/subscribers","subscription_url":"https://api.github.com/repos/ninjadev/nin/subscription","commits_url":"https://api.github.com/repos/ninjadev/nin/commits{/sha}","git_commits_url":"https://api.github.com/repos/ninjadev/nin/git/commits{/sha}","comments_url":"https://api.github.com/repos/ninjadev/nin/comments{/number}","issue_comment_url":"https://api.github.com/repos/ninjadev/nin/issues/comments{/number}","contents_url":"https://api.github.com/repos/ninjadev/nin/contents/{+path}","compare_url":"https://api.github.com/repos/ninjadev/nin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ninjadev/nin/merges","archive_url":"https://api.github.com/repos/ninjadev/nin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ninjadev/nin/downloads","issues_url":"https://api.github.com/repos/ninjadev/nin/issues{/number}","pulls_url":"https://api.github.com/repos/ninjadev/nin/pulls{/number}","milestones_url":"https://api.github.com/repos/ninjadev/nin/milestones{/number}","notifications_url":"https://api.github.com/repos/ninjadev/nin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ninjadev/nin/labels{/name}","releases_url":"https://api.github.com/repos/ninjadev/nin/releases{/id}","deployments_url":"https://api.github.com/repos/ninjadev/nin/deployments","created_at":"2013-09-22T17:30:37Z","updated_at":"2016-07-08T16:52:15Z","pushed_at":"2016-07-20T20:24:38Z","git_url":"git://github.com/ninjadev/nin.git","ssh_url":"git@github.com:ninjadev/nin.git","clone_url":"https://github.com/ninjadev/nin.git","svn_url":"https://github.com/ninjadev/nin","homepage":null,"size":36971,"stargazers_count":13,"watchers_count":13,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":19,"forks":1,"open_issues":19,"watchers":13,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ninjadev/nin/pulls/254"},"html":{"href":"https://github.com/ninjadev/nin/pull/254"},"issue":{"href":"https://api.github.com/repos/ninjadev/nin/issues/254"},"comments":{"href":"https://api.github.com/repos/ninjadev/nin/issues/254/comments"},"review_comments":{"href":"https://api.github.com/repos/ninjadev/nin/pulls/254/comments"},"review_comment":{"href":"https://api.github.com/repos/ninjadev/nin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ninjadev/nin/pulls/254/commits"},"statuses":{"href":"https://api.github.com/repos/ninjadev/nin/statuses/74e11e39811303cc575cfc5443c9af6675310870"}}}}
{"actor":{"display_login":"aleksanb"}}