StdDraw3D: Texturing


In this tutorial we will be covering texturing a sphere using the StdDraw3D library.

What You Will Need to Start

For this tutorial you will need to have completed the basic setup for a Java3D application, you will need to import all of the libraries that Java3D applications require. If you haven’t done that and don’t know how to do that, click here to find out how. You will also need to have imported the StdDraw3D class into your project, click here to find out how.


Wrapping a texture around a sphere using the StdDraw3D library is very simple, all it takes is an additional argument when creating the sphere.

First of all let’s find a texture that we want to use and add it into the project folder. Grab any texture from any website, I’m using a texture of the Earth. Then in the root folder for the project create a folder named ‘res’. Then inside that folder add your texture.

If you cannot find a texture you could use this texture here. This is an 8k texture so is rather large. It is not recommended that you use 8k textures if you are animating the shape.


We can then store this directory within a string. We can then call this variable to wrap the texture around a shape.


To wrap a texture around the sphere, the single line of code below is used.


The code below is all the code that is needed to texture a sphere.


Finally, the finished program will display a 3D sphere with a texture wrapped.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s