Three.js-用indexedfaceset和color加载VRML文件

时间:2018-11-20 09:59:44

标签: javascript three.js 3d

我有一个简单的VRML文件,可以在现有的VRML查看器中加载该文件:

VRML working example in existing viewer

我尝试用Three.js加载它,但是我无法获得每个面上的颜色:

VRML loaded in three.js

请在VRML文件下面找到:

#VRML V2.0 utf8
#Color example: a pyramid
Shape {
appearance Appearance{
    material Material { }
    }
geometry IndexedFaceSet {
    coord Coordinate {
                point [
            # bottom 
            -1.0 -1.0 1.0,  #vertex 0
            1.0 -1.0 1.0,   #vertex 1
            1.0 -1.0 -1.0,  #vertex 2
            -1.0 -1.0 -1.0, #vertex 3
            # top
            0.0 1.0 0.0     #vertex 4
                ]
            }
colorPerVertex FALSE #so each face will have one of the colors
color Color {
                color [
                    1.0 0.0 0.0,#color 0
                    0.0 1.0 0.0,#color 1
                    0.0 0.0 1.0,#color 2
                    1.0 1.0 0.0,#color 3
                    0.0 1.0 1.0,#color 4
                ]
            }
colorIndex [ 2 3 4 0 0 ] #the first face will have color 2, the 2nd color3...
    coordIndex [
        #bottom square
         0, 3, 2, 1, 0, -1,
        #side1
         0, 1, 4, -1,
        #side2
         1, 2, 4, -1,
        #side3
         2, 3, 4, -1,
        #side1
         3, 0, 4, -1,
        ]

}
}

=>是不支持indxedfaceset和颜色关联的VRML加载器吗?

0 个答案:

没有答案