Adding a cubemap using the PC Engine

Trying to add a cubemap using the PC Engine/API.

Found this…

… and copied the HMTL/CSS/JS to my own Dreamweaver project.

It works.

The problem is when I try to load the assets locally or otherwise. I downloaded the assets used in this example and I downloaded a fresh skybox w/ assets directly from PlayCanvas. In both cases the skybox won’t appear. I also tried putting the assets on my server and loading from there…still didn’t work. The only assets that work are coming from the server referenced in the CodePen code.

The error that pops up in the console is:

RangeError: attempting to construct out-of-bounds TypedArray on ArrayBuffer

So in summary this code works:

var data = {
name: ‘forest’,
cubemap: ‘’,
textures: [’,’,’,’,’,

This code doesn’t work:

var data = {
name: ‘forest’,
cubemap: ‘…/cubemaps/forest/’,
textures: [

Full code is in the next post. Been banging my head on this for hours…anybody have an idea what is going on?

Joe H.

P.S. Thought it might be the crossOrigin deal causing the problem but if I remove that line of code it still doesn’t work

Here’s the full code that isn’t working:

// Create a PlayCanvas application
var canvas = document.getElementById(“application-canvas”);
var app = new pc.Application(canvas, {
mouse: new pc.Mouse(canvas)
app.loader._handlers.texture.crossOrigin = true;

// Fill the available space at full resolution

// Resize the canvas when the window is resized
window.addEventListener(‘resize’, function () {
app.resizeCanvas(canvas.width, canvas.height);

// Create camera entity
var camera = new pc.Entity();
camera.addComponent(‘camera’, {clearColor: new pc.Color(0.1, 0.2, 0.3)});
camera.translate(0, 0, 10);

camera.setPosition(0, 0, 3);

var data = {
name: ‘forest’,
cubemap: ‘…/cubemaps/forest/’,
textures: [

var textures =, i) {
var asset = new pc.Asset( + ‘-’ + i, ‘texture’, { url: v });

var cubemap = new pc.Asset(,
{ url: data.cubemap },
anisotropy: 1,
magFilter: 1,
minFilter: 5,
rgbm: true,
textures: textures


NM…pathing error. Knew it had to be something simple.

var data = {
name: ‘forest’,
cubemap: ‘cubemaps/forest/’,
textures: [

Hi, I am the author of the codepen you show. :smile:

Here is some points:

  • As the browser can only fetch file by HTTP/HTTPS, you should serve your local assets by a web server.
  • Make sure the path of cubemap and textures are correct. (Otherwise you will see 404 error in the console)



Thanks for the info. Ultimately I think the assets will be stored on a server, maybe in a database or CMS. This project was me putting together a strawman to see if the basic concepts would work. It took me a bit, but I eventually got the prefiltered cubemap I downloaded from PlayCanvas to work as expected with reflections, etc.