Skip to content

Instantly share code, notes, and snippets.

@mattearnshaw
Last active January 25, 2018 14:17
Show Gist options
  • Save mattearnshaw/c22427ff7c91e843b6248d185fc41131 to your computer and use it in GitHub Desktop.
Save mattearnshaw/c22427ff7c91e843b6248d185fc41131 to your computer and use it in GitHub Desktop.
create3DCylinderFromNode: function (cylNode, material, minRadius, maxRadius) {
var bottomBasePos = new THREE.Vector3(cylNode.position.x, cylNode.position.y, cylNode.position.z);
var topBasePos = new THREE.Vector3(cylNode.distal.x, cylNode.distal.y, cylNode.distal.z);
var topRadius = cylNode.topRadius;
var bottomRadius = cylNode.bottomRadius;
var axis = new THREE.Vector3();
axis.subVectors(topBasePos, bottomBasePos);
var c = new THREE.CylinderGeometry(topRadius, bottomRadius, axis.length(), 20, 1, false);
var threeObject = new THREE.Mesh( c, material );
return threeObject;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment