3

Is it possible to texture a sphere part by part? For example we can use 6 textures on 6 sides of the cube making it possible for us to texture the cube face by face. Is it possible to do the same in sphere?? I do not want to overlap one texture on the other, but use different textures on different parts of the sphere. For example first 1/4th of sphere with texture 1, second 1/4th of sphere with texture 2...so on. Can we achieve this using THREE.js or any other library?

Thanks in advance.

1 Answer 1

4

The SphereGeometry constructor has parameters that let you construct a sector of a sphere:

THREE.SphereGeometry( radius, widthSegments, heightSegments, phiStart, phiLength, thetaStart, thetaLength )

The easiest way to achieve what you want is to use the following pattern:

var parent = new THREE.Object3D();
scene.add( parent );

var geometry = new THREE.SphereGeometry( 5, 24, 16, 0 * Math.PI/2, Math.PI/2 );
var material = new THREE.MeshLambertMaterial( { map: texture0 } );
mesh = new THREE.Mesh( geometry, material );
parent.add( mesh );

var geometry = new THREE.SphereGeometry( 5, 24, 16, 1 * Math.PI/2, Math.PI/2 );
var material = new THREE.MeshLambertMaterial( { map: texture1 } );
mesh = new THREE.Mesh( geometry, material );
parent.add( mesh );

var geometry = new THREE.SphereGeometry( 5, 24, 16, 2 * Math.PI/2, Math.PI/2 );
var material = new THREE.MeshLambertMaterial( { map: texture2 } );
mesh = new THREE.Mesh( geometry, material );
parent.add( mesh );

var geometry = new THREE.SphereGeometry( 5, 24, 16, 3 * Math.PI/2, Math.PI/2 );
var material = new THREE.MeshLambertMaterial( { map: texture3 } );
mesh = new THREE.Mesh( geometry, material );
parent.add( mesh );

three.js r.63

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks a lot. Its working great. There is a problem, suppose i have 32 tiles/image to be filled, i would require 32 spheres, when i do it my browser crashes very often and in IE it doesn't even show up a single tile. My main intention is load my page faster by bringing in images part by part rather than loading whole image at once. Please give me some suggestions.
The question was about 4 tiles, not 32. Consider other approaches, and post a new, detailed queestion if you are having problems.
Hey i need a favor, would you please suggest me some articles to go through to understand the factors or constraints that should be kept in mind while developing a high performance webgl application. I need to understand the factors that affect the webgl performance.
That is a very general webgl question. If you have more questions, you will have to make a new post and tag it as webgl.
I have made a new post regarding the issue. Please follow this link stackoverflow.com/questions/20606350/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.