【问题标题】:How to swift between face and line?如何在面部和线条之间快速切换?
【发布时间】:2013-08-17 00:01:17
【问题描述】:

我想显示一个可以通过开关在面和线之间更改的对象。我应该怎么办? 这是我的代码:

【问题讨论】:

    标签: x3d


    【解决方案1】:

    您可以使用包含两个版本对象的Switch 节点(一个使用IndexedFaceSet,一个使用IndexedLineSet)并使用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
    

    【讨论】:

    • 如何将您的示例更改为 html 网站?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多