#VRML V2.0 utf8 ## ##:@+ first fish morphs ##@ proto shape PROTO shape [ exposedField SFVec3f translation 0 0 0 field MFVec2f scale [] eventIn MFVec2f set_scale eventIn SFFloat fraction exposedField SFColor color 1 0 0 ]{ ##@ body Transform { translation IS translation rotation 0 0 1 -1.57 children [ Shape { appearance Appearance { material Material { diffuseColor IS color } } ##@ geometry -- extrusion geometry DEF X Extrusion { spine [ 0 0 0, 0 1 0, 0 2 0, 0 3 0 ] scale IS scale set_scale IS set_scale } } ] } ##@ script DEF S Script { directOutput TRUE eventIn SFFloat fraction IS fraction eventOut MFVec2f scale field SFNode n USE X field SFInt32 i 0 field MFVec2f s1 [ 0.5 0.5,1 1, 0.5 0.5, 0.1 0.1 ] field MFVec2f s2 [ 0.1 0.1,0.3 0.3, 0.7 0.7, 0.2 0.2 ] field MFVec2f s3 [ 0.3 0.3,0.8 0.8, 0.6 0.6, 0.3 0.3 ] field SFColor c1 1 0 0 field SFColor c2 1 1 0 field SFColor c3 0 1 1 ##@ function url "vrmlscript: function fraction(value) { if (value < 0.3) { n.set_scale = s1; } else if (value >= 0.3 && value < 0.6) { n.set_scale = s2; } else { n.set_scale = s3; } } " } } ##@ instances Transform { children [ DEF S1 shape { translation 0 0 0 color 0 0 1 } DEF S2 shape { translation 2 1 0 color 1 1 0 } DEF S3 shape { translation 2 -1 0 color 0 1 1 } DEF S4 shape { translation 4 0 0 color 1 0 0 } ] } ##@ timer + routing DEF T TimeSensor { cycleInterval 3 loop TRUE enabled TRUE } ROUTE T.fraction_changed TO S1.fraction ROUTE T.fraction_changed TO S2.fraction ROUTE T.fraction_changed TO S3.fraction ROUTE T.fraction_changed TO S4.fraction ##