x3d - How to swift between face and line? -


i want display obeject can changed between face , line switch. should do? here code:

you can use switch node contains 2 versions of object (one using indexedfaceset , 1 using indexedlineset) , toggle between them using switch.whichchoice property.

here's example:

group {     children [         def sensor touchsensor {}         def shapes switch {             whichchoice 0             choice [                  # choice 0: not wireframe                 shape {                     appearance def appearance appearance {                         material material {                             emissivecolor 0 0.5 0                         }                     }                     geometry indexedfaceset {                         coordindex [0 1 2 0 -1]                         coord def coords coordinate {                             point [                                 -2 -2 0, 0 2 0, 2 -2 0                             ]                         }                         solid false                     }                 }                  # choice 1: wireframe                 shape {                     appearance use appearance                     geometry indexedlineset {                         coordindex [0 1 2 0 -1]                         coord use coords                     }                 }              ]         }     ] }   def script script {     field       sfnode      shapes      use shapes     eventin     sftime      clicked      directoutput true     url "javascript:      function clicked(){         if (shapes.whichchoice == 0){             shapes.whichchoice = 1;         } else {             shapes.whichchoice = 0;              }     }      " } route sensor.touchtime script.clicked 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -