~holger-seelig/titania-library/trunk

« back to all changes in this revision

Viewing changes to Tests/Components/Layout/library/Rotor.x3dv

  • Committer: Holger Seelig
  • Date: 2017-09-18 02:55:31 UTC
  • Revision ID: holger.seelig@yahoo.de-20170918025531-n60g34kd9bfs41t1
Updated prototypes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#X3D V3.3 utf8 Titania
 
2
 
 
3
PROTO Rotor [
 
4
  inputOutput SFBool     enabled TRUE
 
5
  inputOutput SFTime     cycleInterval 1
 
6
  inputOutput SFVec3f    axis 0 0 1
 
7
  inputOutput SFFloat    angle 0
 
8
  inputOutput SFBool     loop FALSE
 
9
  inputOutput SFTime     startTime 0
 
10
  inputOutput SFTime     pauseTime 0
 
11
  inputOutput SFTime     resumeTime 0
 
12
  inputOutput SFTime     stopTime 0
 
13
  outputOnly  SFBool     isActive
 
14
  outputOnly  SFTime     cycleTime
 
15
  outputOnly  SFRotation rotation_changed
 
16
]
 
17
{
 
18
  DEF Timer TimeSensor {
 
19
    enabled IS enabled
 
20
    cycleInterval IS cycleInterval
 
21
    loop IS loop
 
22
    startTime IS startTime
 
23
    pauseTime IS pauseTime
 
24
    resumeTime IS resumeTime
 
25
    stopTime IS stopTime
 
26
    isActive IS isActive
 
27
    cycleTime IS cycleTime
 
28
  }
 
29
 
 
30
  DEF Interpolator OrientationInterpolator {
 
31
    key [ 0, 0.25, 0.5, 0.75, 1 ]
 
32
    keyValue [ 0 0 1 0, 0 0 1 1.5708, 0 0 1 3.14159, 0 0 1 4.71239, 0 0 1 0 ]
 
33
    value_changed IS rotation_changed
 
34
  }
 
35
 
 
36
  DEF Rotor Script {
 
37
    inputOnly      SFVec3f set_axis
 
38
    inputOnly      SFFloat set_angle
 
39
    inputOutput    SFVec3f axis IS axis
 
40
    inputOutput    SFFloat angle IS angle
 
41
    initializeOnly SFNode  interpolator USE Interpolator
 
42
 
 
43
    url "vrmlscript:
 
44
 
 
45
function initialize ()
 
46
{
 
47
        eventsProcessed ();
 
48
}
 
49
 
 
50
function set_axis ()
 
51
{ }
 
52
 
 
53
function set_angle ()
 
54
{ }
 
55
 
 
56
function eventsProcessed ()
 
57
{
 
58
        var keyValue = interpolator .keyValue;
 
59
 
 
60
        for (var i = 0; i < 4; ++ i)
 
61
                keyValue [i] = new SFRotation (axis, angle + 2 * Math .PI / 4 * i);
 
62
        
 
63
        keyValue [4] = keyValue [0];
 
64
}
 
65
"
 
66
  }
 
67
 
 
68
  ROUTE Timer.fraction_changed TO Interpolator.set_fraction
 
69
}
 
70