3

In the following line of code

mesh = new THREE.Mesh(new THREE.SphereGeometry(500,60,40),
           new THREE.MeshBasicMaterial({map:texture,overdraw:true}));

What are the values 60 and 40 and what is their effect on the sphere?

mesh.scale.x = -1;

What does the above statement do??

I have gone through many articles but none explains the above and even the three.js documentation gives the syntax for use and not the description.

WestLangley
  • 102,557
  • 10
  • 276
  • 276
DPH
  • 261
  • 4
  • 16

1 Answers1

2

Take a look at the documentation of the Three.js:

http://threejs.org/docs/#Reference/Extras.Geometries/SphereGeometry

So 60 and 40 are numbers of segments that sphere is divided into, horizontally and vertically.

mesh.scale.x = -1; would invert the mesh "inside-out". Generally, the scale value for same axis multiplies vertex's position on according axis with scale factor for that axis. So scale on x axis would multiply x-component of the vertex's position with it. Try to avoid negative scaling factors, it might lead to very undesirable effects. It is also recommended to always scale mesh uniformly on all three axis, something like:

var factor = 2.0;
mesh.scale = new THREE.Vector3(factor, factor, factor);
Dragan Okanovic
  • 7,509
  • 3
  • 32
  • 48
  • Thank you. Is it possible to use multiple textures on a sphere? Or texture 'n' number of segments of a sphere with different images? – DPH Dec 04 '13 at 09:37
  • Would you please go through this question http://stackoverflow.com/questions/20350251/using-multiuple-textures-on-a-sphere-in-three-js – DPH Dec 04 '13 at 09:43