DPH
DPH

Reputation: 261

Three.js sphere

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.

Upvotes: 3

Views: 1499

Answers (1)

Dragan Okanovic
Dragan Okanovic

Reputation: 7781

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);

Upvotes: 2

Related Questions