Three.js管不够长

时间:2017-07-21 09:52:24

标签: typescript three.js

我想用线段连接顶点。这就是我用简单的线条得到的。它工作正常。

let line2 = (from : Vector3, to : Vector3) : THREE.Line => {

    var lineGeometry = new THREE.BufferGeometry();

    var positions = new Float32Array( 3 * 2 );  

    positions[0]=to.x;
    positions[1]=to.y;
    positions[2]=to.z; 

    positions[3]=from.x;
    positions[4]=from.y;
    positions[5]=from.z; 

    lineGeometry.addAttribute( 'position', new THREE.BufferAttribute( positions, 3 ) );

    let lineMaterial = new THREE.LineBasicMaterial( { color: 0x0f35ff } ); 

    let line = new THREE.Line(lineGeometry, lineMaterial); 

    return line;

};  

Lines ends closed in points as expected

但是当我切换到管子问题时,长度会变短。

enter image description here

管道代码,位置数据是相同的。

let tube = (from : Vector3, to : Vector3) : THREE.Mesh => {

    let path = new THREE.LineCurve3(to, from);  

    let tubeGeometry = new THREE.TubeGeometry( path, 32, 0.05, 8, true);

    let material = new THREE.MeshBasicMaterial({color:0x3212ac});  

    let mesh = new THREE.Mesh(tubeGeometry, material);

    return mesh;

};

1 个答案:

答案 0 :(得分:1)

罪魁祸首似乎是关闭"管末端,如果你启用这个THREE不再生成圆柱体的最后一段(尝试将false作为最终参数传递给TubeGeometry构造函数以查看差异)。

作为quickfix,在generateBufferData()来源的TubeBufferGeometry方法中尝试类似

的内容
//generateSegment((closed === false) ? tubularSegments : 0);
generateSegment(tubularSegments);
if (closed === true)
    generateSegment(0);