Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js - can't create a Cylinder

I'm trying to create a Cylinder but with no success. This is my code:

geometry02 = new THREE.CylinderGeometry( 20, 100, 100, 1000 );
material02 = new THREE.MeshBasicMaterial({color: 0x0000ff});
cylinder02 = new THREE.Mesh( geometry02, material02 );
cylinder02.position.x = 300;
scene.addObject( cylinder02 );

Am I forgetting to include something?

like image 975
BorisD Avatar asked Nov 28 '11 07:11

BorisD


1 Answers

There is nothing wrong with the snippet you just posted. I can confirm it runs ok if I paste in an example.

Make sure that:

  1. There aren't any javascript errors (check your browser's Console)
  2. The camera is pointing in the right direction (as anshulkatta mentions, camera.lookAt(yourObject); is a good way to do that)
  3. Your model's position/scale has decent values/is within the camera's frustrum/visible area

As a side note, you might want to decrease the segmentsRadius parameter(1000) to a smaller value. You might get a similar look/level detail with less vertices/faces.

like image 163
George Profenza Avatar answered Sep 29 '22 05:09

George Profenza