Easy Papervision3D skybox tutorial and source


Adding a skybox in Papervision3D is extremely easy. I couldn’t find a whole lot of examples/tutorials about skyboxes in Papervision3D, but I managed to find a skybox tutorial source and learned how to do it. The tutorial I got the initial source from is actually about adding stars using particle fields, but I just used the skybox part of it (and used the textures).

I decided to clean it up and make a nice class out of it. I’ve used the trunk of the papervision code repository, revision 851, but since it’s very basic stuff I doubt it’ll break with future versions.


See the line material.doubleSided = true;? That’s needed since we’re inside the cube that is the skybox. Since normally you can only see objects from the outside we’re setting the double-sidedness of the skybox. Perhaps a better solution is to flip the faces of the skybox and leave out the double-sidedness all together:

To use the Skybox class, here’s an example:

Here are the steps you need:

  • define a bunch of textures in the top of your classes by embedding them and pass these classes to the Skybox constructor.
  • pass in a size for your skybox: I’ve used Number.MAX_VALUE so the skybox won’t move or pixelate while I move through it with the camera.
  • pass in a quality value: this can be any number actually, I just found 4, 6 and 8 to work nicely. These numbers determine how many segments are used in each of the faces of the skybox to avoid texture distortion and awkward transitions from one texture into another.

For my own convenience I’ve made a NebulaSkybox which simply encapsulates all the embedded images for the nebula sky:


Leave a Reply