小编cod*_*r99的帖子

Three.js Object3d柱面旋转以对齐矢量

我搜索得很远,但似乎无法想象这个非常基本的东西.我已经在一年或两年前看过stackoverflow和其他地方的其他例子,但他们无法使用最新版本的Three.js.

这是我正在研究的版本:http://medschoolgunners.com/sandbox/3d/.

我试图让灰色圆锥与未标记的红色矢量完全对齐.IE浏览器.我希望锥体的尖端与矢量精确对齐,并从该方向的原点指出.

这是我现在的代码:

    //FUNCTION TO CREATE A CYLINDER
function create_cylinder(radiusTop,radiusBottom, height, segmentsRadius, segmentsHeight, openEnded, color)
{
var material = new THREE.MeshLambertMaterial({
    color: color, //0x0000ff
    opacity: 0.2
});
var cylinder = new THREE.Mesh(new THREE.CylinderGeometry(radiusTop,radiusBottom, height, segmentsRadius, segmentsHeight, openEnded), material);

cylinder.overdraw = true;

return cylinder;
}

//ALIGN THE CYLINDER TO A GIVEN VECTOR
var alignVector=new THREE.Vector3(-50,50,50); //the vector to be aligned with

var newcylinder = create_cylinder(0.1, 10, 40, 50, 50, false, "0x0ff0f0");  // the object to be …
Run Code Online (Sandbox Code Playgroud)

javascript rotation quaternions three.js

11
推荐指数
3
解决办法
2万
查看次数

标签 统计

javascript ×1

quaternions ×1

rotation ×1

three.js ×1