npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

three.equirectangular-to-cubemap

v2.0.0

Published

Convert an equirectangular panorama into a three.js cubemap texture

Readme

THREE.EquirectangularToCubemap

Convert an equirectangular panorama into a cubemap texture

2026 update

Disclaimer: this library is from 2016, and three.js has had this conversion built in since r106, so you might not need it anymore

texture.mapping = THREE.EquirectangularReflectionMapping;
scene.background = texture;
scene.environment = texture;

// or, to get the cube map itself

const cubemap = new THREE.WebGLCubeRenderTarget( 1024 ).fromEquirectangularTexture( renderer, texture ).texture;

The library has been rewritten for current three.js. What changed from the 2016 version:

  • it's an ES module, and it needs three.js r152 or later and WebGL 2
  • the cube map is no longer mirrored
  • cube maps can be disposed, and HDR panoramas keep their range

With faces as tall as the panorama, the output is identical to the one built into three.js. What this library does differently:

  • cube maps smaller than the panorama are filtered with its mipmaps and the poles stay sharp. three.js gives you one or the other: it aliases if the panorama hasn't been rendered yet, and blurs the poles if it has
  • the type, color space, filters and mipmaps of the cube map can be overridden, three.js always copies them from the panorama
  • the size is clamped to what the GPU supports, and a panorama that hasn't loaded or an invalid size throws an error

Here's a demo loading an equirectangular panorama and converting it to two different cubemaps: Demo

How to use

Use npm to install it, alongside three.js

npm i three three.equirectangular-to-cubemap

and import it in your code

import * as THREE from 'three';
import { EquirectangularToCubemap } from 'three.equirectangular-to-cubemap';

It's a plain ES module, so it also works without a bundler as long as an import map resolves three (see examples/index.html).

Define a new instance of EquirectangularToCubemap and call .convert()

// create your renderer, scene, etc.

const renderer = new THREE.WebGLRenderer();

// load the image you want to convert

const loader = new THREE.TextureLoader();
loader.load( 'equirectangular-panorama.jpg', function( res ) {

  res.colorSpace = THREE.SRGBColorSpace;

  // once it's loaded, create the helper and use it

  const equiToCube = new EquirectangularToCubemap( renderer );

  // convert the image, in this case it's been used as environment map

  const mesh = new THREE.Mesh(
    new THREE.TorusKnotGeometry( 10, 3, 100, 32 ),
    new THREE.MeshBasicMaterial( { envMap: equiToCube.convert( res, 1024 ) } )
  );
  scene.add( mesh );

} );

So .convert( source, size, options ) accepts a loaded texture as source and a number as size (width and height of each face of the cube map), and returns a cube texture. It throws if the texture has no image yet or if the size is not a positive number. 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)

The cube map takes its type, color space, filters and mipmap setting from the source texture, so an HDR panorama gives an HDR cube map. options is optional, it's passed to THREE.WebGLCubeRenderTarget and overrides any of those

const cubemap = equiToCube.convert( res, 1024, { type: THREE.HalfFloatType, generateMipmaps: false } );

Every cube map holds GPU memory until it's disposed. Dispose the helper too once there's nothing left to convert

cubemap.dispose();
equiToCube.dispose();

Requirements

three.js r152 or later, and WebGL 2. For three.js r116 and earlier use version 1.x of this library.

License

MIT licensed

Copyright (C) 2016 Jaume Sanchez Elias, http://www.clicktorelease.com