내가 three.js를 사용하고
three.js를 - 두 지점, 하나 개의 실린더, 정렬 문제
(... 거 같습니다/three.js를 새로운, 유래 할 새)는 포스 - 음모 R54 유향 그래프. 노드 사이의 가장자리는 THREE.Lines이며 괜찮습니다. 그러나 선은 레이 캐스터로 선택할 수 없습니다. 그래서 내 목표는 실린더 (대신에 /와 함께) 줄을 (또한 내가 좀 더 물건을 할 수 있기 때문에 : 텍스처를 사용하여 ...)
이것은 내가 실린더를 배치하고있는거야 :
(에 descripted : http://www.fastgraph.com/makegames/3drotation/)
// 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, newUpVec.z, 0,
direction.x, direction.y, direction.z,0,
0,0,0,1);
//build translation matrix
var transla = new THREE.Matrix4(1, 0, 0, offset.x,
0, 1, 0, offset.y,
0, 0, 1, offset.z,
0, 0, 0, 1);
//build transformation matrix
var transfo = new THREE.Matrix4().multiply(transla, rot);
// create geometry
var cylgeo = new THREE.CylinderGeometry(2, 2, halfLength * 2, 12, 1, false);
cylgeo.applyMatrix(transfo);
var cylMesh = new THREE.Mesh(cylgeo, new THREE.MeshLambertMaterial({color:0x000000,
wireframe: true, shading: THREE.FlatShading}));
은 그래서 실린더가 아니라 가장자리의 두 지점 (시작, 끝)에, 오프셋 및 방법의 일종으로 정렬 오른쪽에 배치됩니다.
제안 사항을 보내 주시면 감사하겠습니다. 그것을 사용
YES를! 그것은 작동합니다! 잘 당신의 언급 한 예를 보았지만 실제로 시도하고있는 것을 이해하지 못하기 때문에 시도하지 않았습니다. 프레임 워크에서 사용되는 함수를 자세히 살펴볼 것입니다. 정말 고맙습니다! – ewo
당신은 http://meta.stackexchange.com/questions/167748/user-cannot-accept-my-answer – jdregister
을 볼 수 있어야합니다. r58에서 rotateX는 makeRotationX 및 multiplySelf에 대해 사용되지 않으며 addSelf, subSelf는 (으)로 변경되어야합니다. 곱하기, 덧셈, 서브 각각 – jdregister