THREE.EquirectangularToCubemap
Convert an equirectangular panorama into a cubemap texture
Here's a demo loading an equirectangular panorama and converting it to two different cubemaps: Demo
How to use
Include script after THREE is included
<script src="EquirectangularToCubemap.js"></script>
or use npm to install it
npm i three.equirectangular-to-cubemap
and include it in your code (don't forget to require three.js)
var THREE = ;var EquirectangularToCubemap = ;
Define a new instance of THREE.EquirectangularToCubemap and call .convert
// create your renderer, scene, etc. renderer = ; // load the image you want to convert var loader = ;loader;
So .convert()
accepts a texture as source
and a number (power of two) as size (with and height) of the cube map.
THREE.EquirectangularToCubemap
automatically checks for the maximum possible size for cube maps, and clamps the size provided (there seems to be a bug with Android, at least in Nexus 5 Android 6)
License
MIT licensed
Copyright (C) 2016 Jaume Sanchez Elias, http://www.clicktorelease.com