; Methane (CH4) molecule model ; by Andy Yeh (2014) to arm fd 0.7 rd 90 setscale 0.4 0.5 0.4 setmat 0 32 can ru 90 fd 0.5 rd 90 setmat 0 33 can ru 90 fd 0.7 rd 90 setscale 1 1 1 ball ru 90 bk 1.9 end cs reset setbg 43 make "tetra_angle 2 * arctan sqrt 2 setmat 0 32 ball ; the carbon atom at the centre make "carbon object ru 90 arm repeat 3 [ rd :tetra_angle arm ru :tetra_angle tl 120 ] rd 90 ; back to beginning direction showall ; add behaviour and simple animation so when clicked on the model it will toggle a simple rotation. ; firstly create a transform node and move all into the tranform node. transform make "methane object repeat 13 [ make "source word "obj_ repcount - 1 move :source :methane ] ; start creating animation. These codes are borrowed from other blogs such as ; from https://vrmath2.net/content/rotating-elevationgrid MAKE "key [] ; make a variable :key as an empty list MAKE "orilist [] ; make a variable :orilist as an empty list QUEUE "key 0 ; queue first value in key list QUEUE "orilist ORI ; queue first value of current orientation REPEAT 4 [ ; use repeat to collect the next 4 values. QUEUE "key REPCOUNT / 4 ; queue is a command to add a value to the end of the list RT 90 QUEUE "orilist ORI ] TIMESENSOR "ts 10 "true ORIENTATIONINTERPOLATOR "oi :key :orilist ROUTE "route1 "ts "fraction_changed "oi "set_fraction ROUTE "route2 "oi "value_changed :methane "rotation ; start adding behaviour ; sample codes borrowed from https://vrmath2.net/content/music-box TOGGLE "act1 "ts "enabled ; create a toggle action named act1 ; the transform at the moment deos not catch the click event, so I associate the click with the carbon atom in line 21 CLICK :carbon "act1 ; associate box click to act1