-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
108 lines (79 loc) · 2.02 KB
/
Copy pathindex.js
File metadata and controls
108 lines (79 loc) · 2.02 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
if (typeof AFRAME === 'undefined') {
throw 'Component attempted to register before AFRAME was available.'
}
/**
* A-Frame GIF Component component for A-Frame.
* @desc original code is by @gtk2k
* @see https://github.com/gtk2k/gtk2k.github.io/tree/master/animation_gif
*/
AFRAME.registerComponent('gif', {
/**
* Called once when component is attached. Generally for initial setup.
* @protected
*/
init(){
if (this.el.getAttribute('material').shader !== 'gif') {
throw 'Use aframe-gif-shader for shader for aframe-gif-component'
}
/* set shader */
this.shader = this.el.components.material.shader
},
/**
* Called when component is attached and when component data changes.
* Generally modifies the entity based on the data.
* @protected
*/
update (oldData) { },
/**
* Called when a component is removed (e.g., via removeAttribute).
* Generally undoes all modifications to the entity.
* @protected
*/
remove () { },
/**
* Called on each scene tick.
* @protected
*/
tick (t) { },
/**
* Called when entity pauses.
* Use to stop or remove any dynamic or background behavior such as events.
* @protected
*/
pause () {
this.shader.pause && this.shader.pause()
},
/**
* Called when entity resumes.
* Use to continue or add any dynamic or background behavior such as events.
* @protected
*/
play () {
this.shader.play && this.shader.play()
},
/*================================
= playback =
================================*/
/**
* Toggle playback. play if paused and pause if played.
* @public
*/
togglePlayback () {
this.shader.togglePlayback && this.shader.togglePlayback()
},
/**
* Return if the playback is paused.
* @public
* @return {boolean}
*/
paused () {
this.shader.paused && this.shader.paused()
},
/**
* Go to next frame
* @public
*/
nextFrame () {
this.shader.nextFrame && this.shader.nextFrame()
},
})