#VRML V2.0 utf8 WorldInfo { title "Reverse" info [ "2000/9/1 by GoGoGo" "http://www1.plala.or.jp/Studio_GoGoGo/" ] } NavigationInfo {headlight FALSE} Viewpoint {position 0 0 4} #光源設定 DirectionalLight {color 0.3 1 0.3 direction 1 0 -1} DirectionalLight {color 0.3 0.3 1 direction -1 0 -1} DirectionalLight {color 1 0 1 direction 1 0 1 intensity 0.8} DirectionalLight {color 0 1 1 direction -1 0 1 intensity 0.8} DirectionalLight {color 1 0 0 direction 0 -1 0} DirectionalLight {color 1 1 0 direction 0 1 0} #折り紙 DEF origami Transform { translation 0 -0.707 0 children [ DEF TS TouchSensor {} Shape { appearance Appearance { material Material { diffuseColor 1 1 1 } } geometry IndexedFaceSet { coord DEF origamiPoint Coordinate { point [ -1 0 1 0 0 1 1 0 1 1 0 0 1 0 -1 0 0 -1 -1 0 -1 -1 0 0 0 0 0 ] } coordIndex [ 0 1 8 -1 1 2 8 -1 2 3 8 -1 3 4 8 -1 4 5 8 -1 5 6 8 -1 6 7 8 -1 7 0 8 -1 ] solid FALSE } } ] } #変形 DEF CI CoordinateInterpolator { key [0 1] keyValue [ -1 0 1 #変形前 0 0 1 1 0 1 1 0 0 1 0 -1 0 0 -1 -1 0 -1 -1 0 0 0 0 0 -0.01 0 0.01 #変形後 0 0.707 0.707 0.01 0 0.01 0.707 0.707 0 0.01 0 -0.01 0 0.707 -0.707 -0.01 0 -0.01 -0.707 0.707 0 0 1.414 0 ] } #回転 DEF OI OrientationInterpolator { key [0 0.5 1] keyValue [0 1 0 0, 0 1 0 3.14, 0 1 0 6.28] } #fraction_changed 反転用スクリプト DEF TIMER TimeSensor {cycleInterval 2} DEF SC Script { eventIn SFTime touchTime eventIn SFFloat f_in eventOut SFFloat f_out field SFNode TIMER USE TIMER field SFBool folded FALSE url "javascript: function touchTime(value){ if(!TIMER.isActive){ if(!folded) folded=TRUE; else folded=FALSE; } } function f_in(value){ if(folded) f_out=value; else f_out=1-value; }" } ROUTE TS.touchTime TO TIMER.startTime ROUTE TS.touchTime TO SC.touchTime ROUTE TIMER.fraction_changed TO SC.f_in ROUTE SC.f_out TO CI.set_fraction ROUTE SC.f_out TO OI.set_fraction ROUTE CI.value_changed TO origamiPoint.set_point ROUTE OI.value_changed TO origami.set_rotation