Graphics Reference
In-Depth Information
There's more...
In this recipe, we created the cubemap object by providing six separate images.
There is, however, an alternative way to create the cubemap object. If you've got a
360 degrees panoramic image, you can use the following code to directly create a
cubemap object from that image:
var texture = THREE.ImageUtils.loadTexture(
360-degrees.png',
new THREE.UVMapping());
Normally when you create a cubemap object, you use the code shown in this recipe
to map it to a skybox. This usually gives the best results but requires some extra
code. You can also use THREE.SphereGeometry to create a skybox like this:
var mesh = new THREE.Mesh(
new THREE.SphereGeometry( 500, 60, 40
),
new THREE.MeshBasicMaterial( { map:
texture }));
mesh.scale.x = -1;
This applies the texture to a sphere and with mesh.scale , turns this sphere inside
out.
Besides reflection, you can also use a cubemap object for refraction (think about
light bending through water drops or glass objects):
Search WWH ::




Custom Search