1
#X3D V3.3 utf8 Titania V3.0.4
5
META "comment" "World of Titania"
8
inputOutput SFVec3f translation
9
inputOutput SFRotation rotation
10
inputOutput SFVec3f scale
11
inputOutput MFInt32 dimension
12
inputOutput MFInt32 majorLineEvery
13
inputOutput MFInt32 majorLineOffset
14
inputOutput SFVec3f planeOffset
15
inputOutput SFColor planeColor
16
inputOutput SFFloat planeTransparency
17
inputOutput SFColor lineColor
18
inputOutput SFFloat lineTransparency
19
inputOutput SFColor majorLineColor
20
inputOutput SFFloat majorLineTransparency
21
inputOutput SFVec3f numberOffset
22
inputOutput SFNode numberAppearance
23
inputOutput SFNode numberFontStyle
24
initializeOnly SFBool solid
28
EXTERNPROTO LineTrail [
29
inputOutput SFTime resetTime
30
inputOutput SFVec3f point
31
inputOutput SFInt32 dimension
33
"LineTrail.x3d#LineTrail"
40
description "Initial View"
47
rotation 1 0 0 1.5707963
48
dimension [ 60, 0, 30 ]
49
planeOffset 0 -0.001 0
54
majorLineTransparency 0.4
55
numberOffset -0.1 0 0.14
56
numberAppearance Appearance {
61
numberFontStyle ScreenFontStyle {
62
justify [ "END", "BEGIN" ]
65
DEF Touch TouchSensor { }
66
DEF PickingScript Script {
67
inputOnly SFTime set_touchTime
68
inputOnly SFVec3f set_hitPoint
69
inputOutput SFBool active FALSE
70
outputOnly SFTime doubleClickTime
71
initializeOnly SFTime doubleClickInterval 0.3
72
initializeOnly SFFloat pointSize 0.5
73
initializeOnly SFNode xInterpolator DEF XInterpolator ScalarInterpolator {
74
key [ 0, 0.375, 0.75, 1 ]
75
keyValue [ -20, -5, 10, 20 ]
77
initializeOnly SFNode yInterpolator DEF XInterpolator_1 ScalarInterpolator {
78
key [ -20, -5, 10, 20 ]
79
keyValue [ -10, 5, -5, 10 ]
87
hitPoint = new SFVec2f (),
88
offset = new SFVec2f ();
90
function initialize ()
92
xInterpolator .key = new MFFloat (0, 0.375, 0.75, 1);
93
xInterpolator .keyValue = new MFFloat (-20, -5, 10, 20);
94
yInterpolator .keyValue = new MFFloat (-10, 5, -5, 10);
97
function set_touchTime (value, time)
99
if (value - firstTime > doubleClickInterval)
105
doubleClickTime = time;
107
if (pointIndex < 0 || pointIndex >= xInterpolator .keyValue .length)
114
function set_hitPoint (value, time)
116
hitPoint .x = value .x;
117
hitPoint .y = value .y;
122
if (pointIndex < 0 || pointIndex >= xInterpolator .keyValue .length)
125
xInterpolator .keyValue [pointIndex] = hitPoint .x + offset .x;
126
yInterpolator .keyValue [pointIndex] = hitPoint .y + offset .y;
129
function set_active (value, time)
134
pointIndex = pick (hitPoint);
137
function pick (hitPoint)
141
for (var i = 0, length = xInterpolator .keyValue .length; i < length; ++ i)
143
var point = new SFVec2f (xInterpolator .keyValue [i],
144
yInterpolator .keyValue [i]);
146
offset = point .subtract (hitPoint);
148
if (offset .length () > pointSize)
160
var pointIndex = getAddPointIndex ()
162
xInterpolator .keyValue .splice (pointIndex, 0, hitPoint .x);
163
yInterpolator .keyValue .splice (pointIndex, 0, hitPoint .y);
165
setXInterpolatorKey ();
168
function removePoint ()
170
var pointIndex = getRemovePointIndex ()
172
xInterpolator .keyValue .splice (pointIndex, 1);
173
yInterpolator .keyValue .splice (pointIndex, 1);
175
setXInterpolatorKey ();
178
function getAddPointIndex ()
180
for (var i = 0, length = xInterpolator .keyValue .length; i < length; ++ i)
182
if (xInterpolator .keyValue [i] > hitPoint .x)
189
function getRemovePointIndex ()
192
first = xInterpolator .keyValue [0];
193
last = xInterpolator .keyValue [xInterpolator .keyValue .length - 1];
195
if (hitPoint .x < first)
198
if (hitPoint .x > last)
199
return xInterpolator .keyValue .length - 1;
201
return pick (hitPoint);
204
function setXInterpolatorKey ()
206
if (xInterpolator .keyValue .length)
209
first = xInterpolator .keyValue [0];
210
last = xInterpolator .keyValue [xInterpolator .keyValue .length - 1];
211
distance = last - first,
215
for (var i = 1, length = xInterpolator .keyValue .length; i < length; ++ i)
217
var point0 = new SFVec2f (xInterpolator .keyValue [i - 1],
218
yInterpolator .keyValue [i - 1]);
220
var point1 = new SFVec2f (xInterpolator .keyValue [i],
221
yInterpolator .keyValue [i]);
223
totalLength += point1 .subtract (point0) .length ();
226
xInterpolator .key [0] = 0;
228
for (var i = 1, length = xInterpolator .keyValue .length; i < length; ++ i)
230
var point0 = new SFVec2f (xInterpolator .keyValue [i - 1],
231
yInterpolator .keyValue [i - 1]);
233
var point1 = new SFVec2f (xInterpolator .keyValue [i],
234
yInterpolator .keyValue [i]);
236
lengthSoFar += point1 .subtract (point0) .length ();
238
xInterpolator .key [i] = lengthSoFar / totalLength;
241
xInterpolator .key .length = length;
245
xInterpolator .key .length = 0;
253
DEF LineTrail Group {
255
DEF Timer TimeSensor {
261
DEF TrailScript Script {
262
inputOnly SFFloat set_y
263
outputOnly SFVec3f point_changed
264
initializeOnly SFNode xInterpolator USE XInterpolator
265
initializeOnly SFNode yInterpolator USE XInterpolator_1
269
function set_y (value, time)
271
point_changed .x = xInterpolator .value_changed;
272
point_changed .y = yInterpolator .value_changed;
277
appearance Appearance {
278
lineProperties LineProperties {
279
linewidthScaleFactor 3
282
emissiveColor 0.552941 0.270588 0.14902
285
geometry DEF Trail LineTrail {
286
resetTime 1505540070.69239
287
point -4.36295 4.5753 0
294
DEF Points Transform {
296
DEF PointsScript Script {
297
inputOnly MFFloat set_x
298
inputOnly MFFloat set_y
299
initializeOnly SFNode points DEF _1 Polypoint2D {
300
point [ -20 -10, -5 5, 10 -5, 20 10 ]
302
initializeOnly SFNode xInterpolator USE XInterpolator
303
initializeOnly SFNode yInterpolator USE XInterpolator_1
307
function initialize ()
312
function eventsProcessed ()
314
for (var i = 0, length = xInterpolator .keyValue .length; i < length; ++ i)
316
points .point [i] .x = xInterpolator .keyValue [i];
317
points .point [i] .y = yInterpolator .keyValue [i];
320
points .point .length = i;
325
appearance Appearance {
326
lineProperties LineProperties {
327
linewidthScaleFactor 20
330
emissiveColor 1 0.75 0.5
336
appearance Appearance {
337
lineProperties LineProperties {
338
linewidthScaleFactor 8
341
emissiveColor 1 0.5 0
349
ROUTE XInterpolator.value_changed TO XInterpolator_1.set_fraction
350
ROUTE Timer.fraction_changed TO XInterpolator.set_fraction
351
ROUTE XInterpolator_1.value_changed TO TrailScript.set_y
352
ROUTE TrailScript.point_changed TO Trail.set_point
353
ROUTE Timer.cycleTime TO Trail.set_resetTime
354
ROUTE XInterpolator.keyValue_changed TO XInterpolator_1.set_key
355
ROUTE XInterpolator.keyValue_changed TO PointsScript.set_x
356
ROUTE XInterpolator_1.keyValue_changed TO PointsScript.set_y
357
ROUTE Touch.isActive TO PickingScript.set_active
358
ROUTE Touch.hitPoint_changed TO PickingScript.set_hitPoint
359
ROUTE Touch.touchTime TO PickingScript.set_touchTime
360
ROUTE PickingScript.doubleClickTime TO Trail.set_resetTime