相关疑难解决方法(0)

Three.js线向量到圆柱?

我有这个在2点之间创建一条线:

var geometry = new THREE.Geometry();
geometry.vertices.push(new THREE.Vector3(0, 0, 0));
geometry.vertices.push(new THREE.Vector3(20, 100, 55));
var line = new THREE.Line(geometry, material, parameters = { linewidth: 400 });
scene.add(line);
Run Code Online (Sandbox Code Playgroud)

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

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

three.js

7
推荐指数
2
解决办法
6929
查看次数

three.js - 两个点,一个圆柱,对齐问题

(stackoverflow的新手,webgl/three.js的新手,...)

我正在使用three.js r54绘制一个力导向图.节点之间的边缘是THREE.Lines,很好,但是用raycaster不能选择线条.所以我的目标是采用圆柱代替(或同时)线条(也因为我可以做更多的东西:使用纹理,......)

这就是我正在做的放置圆柱体:

// init reference vector
var upVec = new THREE.Vector3(0,1,0);

//---withhin a loop---
// get direction
var direction = startPoint.subSelf(endPoint).clone();

// half length for cylinder height
var halfLength = direction.length() * 0.5;  

// get offset
var offset = endPoint.clone().addSelf(direction.clone().multiplyScalar(0.5));

// normalize direc
direction.normalize();

//newUpVec = upVec - (upVec *(dot) direction) * direction - projection of direction
var newUpVec = upVec.clone().subSelf(direction.clone().multiplyScalar(upVec.dot(direction.clone()))).normalize();
var right = newUpVec.clone().crossSelf(direction.clone());

//build rotation matrix
var rot = new THREE.Matrix4(right.x, right.y, right.z, 0,
                            newUpVec.x, newUpVec.y, …
Run Code Online (Sandbox Code Playgroud)

rotation three.js cylindrical

4
推荐指数
1
解决办法
3145
查看次数

标签 统计

three.js ×2

cylindrical ×1

rotation ×1