2013-08-16 37 views

回答

0

您可以使用包含(使用在IndexedFaceSet一個又一個使用IndexedLineSet)對象的兩個版本一個Switch節點,並使用它們之間進行切換Switch.whichChoice屬性。

下面是一個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 TO script.clicked 
+0

我怎樣才能改變你的榜樣成HTML網站? – user2676909

+0

後,我把它變成一個網站,它只是不工作。 – user2676909