forked from bbc/VideoContext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphnode.js.html
More file actions
175 lines (141 loc) · 5.39 KB
/
graphnode.js.html
File metadata and controls
175 lines (141 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: graphnode.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: graphnode.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>//Matthew Shotton, R&D User Experience,© BBC 2015
const TYPE = "GraphNode";
class GraphNode {
/**
* Base class from which all processing and source nodes are derrived.
*/
constructor(gl, renderGraph, inputNames, limitConnections = false) {
this._renderGraph = renderGraph;
this._limitConnections = limitConnections;
this._inputNames = inputNames;
this._destroyed = false;
//Setup WebGL output texture
this._gl = gl;
this._renderGraph = renderGraph;
this._rendered = false;
this._displayName = TYPE;
}
/**
* Get a string representation of the class name.
*
* @return String A string of the class name.
*/
get displayName() {
return this._displayName;
}
/**
* Get the names of the inputs to this node.
*
* @return {String[]} An array of the names of the inputs ot the node.
*/
get inputNames() {
return this._inputNames.slice();
}
/**
* The maximum number of connections that can be made to this node. If there is not limit this will return Infinity.
*
* @return {number} The number of connections which can be made to this node.
*/
get maximumConnections() {
if (this._limitConnections === false) return Infinity;
return this._inputNames.length;
}
/**
* Get an array of all the nodes which connect to this node.
*
* @return {GraphNode[]} An array of nodes which connect to this node.
*/
get inputs() {
let result = this._renderGraph.getInputsForNode(this);
result = result.filter(function(n) {
return n !== undefined;
});
return result;
}
/**
* Get an array of all the nodes which this node outputs to.
*
* @return {GraphNode[]} An array of nodes which this node connects to.
*/
get outputs() {
return this._renderGraph.getOutputsForNode(this);
}
/**
* Get whether the node has been destroyed or not.
*
* @return {boolean} A true/false value of whather the node has been destoryed or not.
*/
get destroyed() {
return this._destroyed;
}
/**
* Connect this node to the targetNode
*
* @param {GraphNode} targetNode - the node to connect.
* @param {(number| String)} [targetPort] - the port on the targetNode to connect to, this can be an index, a string identifier, or undefined (in which case the next available port will be connected to).
*
*/
connect(targetNode, targetPort) {
return this._renderGraph.registerConnection(this, targetNode, targetPort);
}
/**
* Disconnect this node from the targetNode. If targetNode is undefind remove all out-bound connections.
*
* @param {GraphNode} [targetNode] - the node to disconnect from. If undefined, disconnect from all nodes.
*
*/
disconnect(targetNode) {
if (targetNode === undefined) {
let toRemove = this._renderGraph.getOutputsForNode(this);
toRemove.forEach(target => this._renderGraph.unregisterConnection(this, target));
if (toRemove.length > 0) return true;
return false;
}
return this._renderGraph.unregisterConnection(this, targetNode);
}
/**
* Destory this node, removing it from the graph.
*/
destroy() {
this.disconnect();
for (let input of this.inputs) {
input.disconnect(this);
}
this._destroyed = true;
}
}
export { TYPE as GRAPHTYPE };
export default GraphNode;
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-VideoContext.html">VideoContext</a></li></ul><h3>Classes</h3><ul><li><a href="AudioNode.html">AudioNode</a></li><li><a href="CanvasNode.html">CanvasNode</a></li><li><a href="CompositingNode.html">CompositingNode</a></li><li><a href="DestinationNode.html">DestinationNode</a></li><li><a href="EffectNode.html">EffectNode</a></li><li><a href="GraphNode.html">GraphNode</a></li><li><a href="ImageNode.html">ImageNode</a></li><li><a href="MediaNode.html">MediaNode</a></li><li><a href="module-VideoContext.html">VideoContext</a></li><li><a href="ProcessingNode.html">ProcessingNode</a></li><li><a href="RenderGraph.html">RenderGraph</a></li><li><a href="SourceNode.html">SourceNode</a></li><li><a href="TransitionNode.html">TransitionNode</a></li><li><a href="VideoNode.html">VideoNode</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a>
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>