Three.js线向量到圆柱?

前端之家收集整理的这篇文章主要介绍了Three.js线向量到圆柱?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有这个在2点之间创建一条线:
var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(0,0));
geometry.vertices.push(new THREE.Vector3(20,100,55));
var line = new THREE.Line(geometry,material,parameters = { linewidth: 400 });
scene.add(line);

(线宽,没有任何影响.)

我的问题是如何将其转换为圆柱体?我想在两点之间创建一个圆柱体.

解决方法

我有完全相同的问题 – 在WebGL中,线宽总是1.所以这是我写的一个函数,它将采用两个Vector3对象并生成一个圆柱网格:
var cylinderMesh = function( pointX,pointY )
{
    // edge from X to Y
    var direction = new THREE.Vector3().subVectors( pointY,pointX );
    var arrow = new THREE.ArrowHelper( direction,pointX );

    // cylinder: radiusAtTop,radiusAtBottom,//     height,radiusSegments,heightSegments
    var edgeGeometry = new THREE.CylinderGeometry( 2,2,direction.length(),6,4 );

    var edge = new THREE.Mesh( edgeGeometry,new THREE.MeshBasicMaterial( { color: 0x0000ff } ) );
    edge.rotation = arrow.rotation.clone();
    edge.position = new THREE.Vector3().addVectors( pointX,direction.multiplyScalar(0.5) );
    return edge;
}

猜你在找的JavaScript相关文章