THREE.js部分球体几何体给出两个预期一个片段的片段

时间:2015-03-15 23:17:33

标签: three.js geometry

我正在尝试使用THREE.SphereGeometry构造函数的扩展选项制作部分球体几何,例如。

    // material
    var dish_material = new THREE.MeshLambertMaterial( {
        color: 0x00ffff, 
        side: THREE.DoubleSide,
        ambient: 0x00ffff,
        shading: THREE.FlatShading,
        transparent: true,
        opacity: 0.7,
    } );

    var segment_material = new THREE.MeshLambertMaterial( {
        color: 0xffff00, 
        side: THREE.DoubleSide,
        ambient: 0x00ffff,
        shading: THREE.FlatShading,
        transparent: true,
        opacity: 0.7,
    } );    

    // geometries
    var dish_geometry = new THREE.SphereGeometry(radius=5, widthSegments=16, heightSegments=16, 
phiStart=0, phiLength=Math.PI*2, 
thetaStart=Math.PI, thetaLength=Math.PI/4);

    var segment_geometry = new THREE.SphereGeometry(radius=5, widthSegments=16, heightSegments=16, 
phiStart=0, phiLength=Math.PI/4, 
thetaStart=0, thetaLength=Math.PI*2);

    // meshes
    dish = new THREE.Mesh( dish_geometry, dish_material );
    scene.add( dish );

    segment = new THREE.Mesh( segment_geometry, segment_material );
    scene.add( segment );

以下是使用上述代码的JSFiddle

"菜"对象(蓝色)看起来像预期的那样。

但"段"对象(黄色)有两个部分,我只期望一个。

我的问题

这是"双段"预期的几何形状?

1 个答案:

答案 0 :(得分:1)

您指定了thetaLength = Math.PI * 2,这将产生一个完整的圆圈。如果旋转该圆圈,您将获得所描述的几何体。

我想你会想要写thetaLength = Math.PI。