FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
VideoContext/docs/api/ProcessingNodes_transitionnode.js.html at develop · bbc/VideoContext · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
bbc
/
VideoContext
Public
Notifications
You must be signed in to change notification settings
Fork
161
Star
1.4k
Code
Issues
31
Pull requests
9
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
VideoContext
/
docs
/
api
/
ProcessingNodes_transitionnode.js.html
Copy path
More file actions
More file actions
Latest commit
History
History
History
216 lines (182 loc) · 8.69 KB
Breadcrumbs
VideoContext
/
docs
/
api
/
ProcessingNodes_transitionnode.js.html
Copy path
File metadata and controls
216 lines (182 loc) · 8.69 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
<!DOCTYPE html
>
<
html
lang
="
en
"
>
<
head
>
<
meta
charset
="
utf-8
"
>
<
title
>
JSDoc: Source: ProcessingNodes/transitionnode.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: ProcessingNodes/transitionnode.js
</
h1
>
<
section
>
<
article
>
<
pre
class
="
prettyprint source linenums
"
>
<
code
>
//Matthew Shotton, R&D User Experience,© BBC 2015
import EffectNode from "./effectnode";
const TYPE = "TransitionNode";
class TransitionNode extends EffectNode {
/**
* Initialise an instance of a TransitionNode. You should not instantiate this directly, but use VideoContest.createTransitonNode().
*/
constructor(gl, renderGraph, definition) {
super(gl, renderGraph, definition);
this._transitions = {};
//save a version of the original property values
this._initialPropertyValues = {};
for (let propertyName in this._properties) {
this._initialPropertyValues[propertyName] = this._properties[propertyName].value;
}
this._displayName = TYPE;
}
_doesTransitionFitOnTimeline(testTransition) {
if (this._transitions[testTransition.property] === undefined) return true;
for (let transition of this._transitions[testTransition.property]) {
if (testTransition.start
>
transition.start && testTransition.start < transition.end)
return false;
if (testTransition.end
>
transition.start && testTransition.end < transition.end)
return false;
if (transition.start
>
testTransition.start && transition.start < testTransition.end)
return false;
if (transition.end
>
testTransition.start && transition.end < testTransition.end)
return false;
}
return true;
}
_insertTransitionInTimeline(transition) {
if (this._transitions[transition.property] === undefined)
this._transitions[transition.property] = [];
this._transitions[transition.property].push(transition);
this._transitions[transition.property].sort(function(a, b) {
return a.start - b.start;
});
}
/**
* Create a transition on the timeline.
*
* @param {number} startTime - The time at which the transition should start (relative to currentTime of video context).
* @param {number} endTime - The time at which the transition should be completed by (relative to currentTime of video context).
* @param {number} currentValue - The value to start the transition at.
* @param {number} targetValue - The value to transition to by endTime.
* @param {String} propertyName - The name of the property to clear transitions on, if undefined default to "mix".
*
* @return {Boolean} returns True if a transition is successfully added, false otherwise.
*/
transition(startTime, endTime, currentValue, targetValue, propertyName = "mix") {
let transition = {
start: startTime + this._currentTime,
end: endTime + this._currentTime,
current: currentValue,
target: targetValue,
property: propertyName
};
if (!this._doesTransitionFitOnTimeline(transition)) return false;
this._insertTransitionInTimeline(transition);
return true;
}
/**
* Create a transition on the timeline at an absolute time.
*
* @param {number} startTime - The time at which the transition should start (relative to time 0).
* @param {number} endTime - The time at which the transition should be completed by (relative to time 0).
* @param {number} currentValue - The value to start the transition at.
* @param {number} targetValue - The value to transition to by endTime.
* @param {String} propertyName - The name of the property to clear transitions on, if undefined default to "mix".
*
* @return {Boolean} returns True if a transition is successfully added, false otherwise.
*/
transitionAt(startTime, endTime, currentValue, targetValue, propertyName = "mix") {
let transition = {
start: startTime,
end: endTime,
current: currentValue,
target: targetValue,
property: propertyName
};
if (!this._doesTransitionFitOnTimeline(transition)) return false;
this._insertTransitionInTimeline(transition);
return true;
}
/**
* Clear all transistions on the passed property. If no property is defined clear all transitions on the node.
*
* @param {String} propertyName - The name of the property to clear transitions on, if undefined clear all transitions on the node.
*/
clearTransitions(propertyName) {
if (propertyName === undefined) {
this._transitions = {};
} else {
this._transitions[propertyName] = [];
}
}
/**
* Clear a transistion on the passed property that the specified time lies within.
*
* @param {String} propertyName - The name of the property to clear a transition on.
* @param {number} time - A time which lies within the property you're trying to clear.
*
* @return {Boolean} returns True if a transition is removed, false otherwise.
*/
clearTransition(propertyName, time) {
let transitionIndex = undefined;
for (var i = 0; i < this._transitions[propertyName].length; i++) {
let transition = this._transitions[propertyName][i];
if (time
>
transition.start && time < transition.end) {
transitionIndex = i;
}
}
if (transitionIndex !== undefined) {
this._transitions[propertyName].splice(transitionIndex, 1);
return true;
}
return false;
}
_update(currentTime) {
super._update(currentTime);
for (let propertyName in this._transitions) {
let value = this[propertyName];
if (this._transitions[propertyName].length
>
0) {
value = this._transitions[propertyName][0].current;
}
let transitionActive = false;
for (var i = 0; i < this._transitions[propertyName].length; i++) {
let transition = this._transitions[propertyName][i];
if (currentTime
>
transition.end) {
value = transition.target;
continue;
}
if (currentTime
>
transition.start && currentTime < transition.end) {
let difference = transition.target - transition.current;
let progress =
(this._currentTime - transition.start) /
(transition.end - transition.start);
transitionActive = true;
this[propertyName] = transition.current + difference * progress;
break;
}
}
if (!transitionActive) this[propertyName] = value;
}
}
}
export { TYPE as TRANSITIONTYPE };
export default TransitionNode;
</
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
="
VideoElementCacheItem.html
"
>
VideoElementCacheItem
</
a
>
</
li
>
<
li
>
<
a
href
="
VideoNode.html
"
>
VideoNode
</
a
>
</
li
>
</
ul
>
</
nav
>
<
br
class
="
clear
"
>
<
footer
>
Documentation generated by
<
a
href
="
https://github.com/jsdoc/jsdoc
"
>
JSDoc 3.6.5
</
a
>
</
footer
>
<
script
>
prettyPrint
(
)
;
</
script
>
<
script
src
="
scripts/linenumber.js
"
>
</
script
>
</
body
>
</
html
>
Back
|
FazBrowse Home
|
New Git URL