How to change thickness of three.js cyclinder

Clash Royale CLAN TAG#URR8PPP
How to change thickness of three.js cyclinder
If I have a basic hollow cyclinder made using three.js like in the JSFiddle how can I change the thickness of the walls?
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera( 95, window.innerWidth / window.innerHeight, 0.1, 1000 );
var renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
var geometry = new THREE.CylinderGeometry( 2, 2, 5, 360, 1, true );
var material = new THREE.MeshNormalMaterial( color: 0x00ff00, side: THREE.DoubleSide );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );
camera.position.y = 5;
camera.position.z = 5;
camera.lookAt(0,0,0);
function animate()
requestAnimationFrame( animate );
renderer.render( scene, camera );
animate();
JSFiddle example
Yeah I saw that but didn't quite understand it. So is it saying that a cyclinder can't have a thickness and if you want to have one then you have to use arcshape instead?
– geoffs3310
Aug 8 at 11:40
1 Answer
1
No, you have to subtract another cylinder from a cylinder. The one you subtract from it is the inner diameter of the cylinder.
So I changed your code to this:
var outerGeometry = new THREE.CylinderGeometry(2, 2, 5, 360, 1);
var innerGeometry = new THREE.CylinderGeometry(1.5, 1.5, 5, 360, 1);
var material = new THREE.MeshNormalMaterial(
color: 0x00ff00,
side: THREE.DoubleSide
);
var outerCylinder = new ThreeBSP(outerGeometry);
var innerCylinder = new ThreeBSP(innerGeometry);
var hollowedCylinder = innerCylinder.union(outerCylinder);
scene.add(hollowedCylinder.toMesh(material));
Here is the fiddle:
http://jsfiddle.net/gerdonabbink/tephoLr1/133/
As you can see the inner cylinder is 1.5, change this to 1 for example to make the thickness 1.
Oh ok so how do you subtract a cyclinder from a cyclinder in order to create the thickness then?
– geoffs3310
Aug 8 at 11:51
Updated my answer with your solution, in the fiddle you can also see I've added the threejs and threecsg scripts
– Greaperc4
Aug 8 at 12:19
Oh my god amazing thanks!
– geoffs3310
Aug 8 at 12:23
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Do you mean something like this: stackoverflow.com/questions/11826798/…
– Greaperc4
Aug 8 at 11:37