Skip to content

Issue regarding loading normal maps with spritesheets #6491

@dreasgrech

Description

@dreasgrech

Version

  • Phaser Version: Phaser 3.6.0
  • Operating system: Windows 10
  • Browser: Google Chrome v.112.0.5615.138 (64bit)

Description

Encountered an issue where sometimes, most noticeably in unfavorable network conditions, when loading a normal map image for a spritesheet, the normal map image doesn't fully load.

Example Test Code

The issue was first observed in one of the fellow Discord member's project where the frames of a spritesheet were not being loaded. We confirmed this with the following code:

preload()
{
    window.savedThis = this;

    // Adding a filecomplete hook so that we can look at the loaded frames
    this.load.on(`filecomplete-spritesheet-${pt.Tiles}`, function (key, type, data) {
        console.log("finished loading", key, type, data, savedThis.textures.get(pt.Tiles).frames);
    });

    this.load.spritesheet({
        key: pt.Tiles,
        url: "assets/main-tileset/breakout-extruded.png",
        normalMap: "assets/main-tileset/breakout-extruded_n.png",
        frameConfig: {
            frameWidth: 16,
            frameHeight: 16,
            spacing: 2,
            margin: 1,
            startFrame: 0,
            endFrame: 99
        }
    })

    ...
}

When loading the page normally, all of the 100 frames were correctly being logged to the console. But in intermittent cases, we were receiving the log that there aren't any frames in .frames

This was later confirmed when looking at the following online example: https://labs.phaser.io/edit.html?src=src/game%20objects/lights/sprite%20sheet%20light.js

When I disabled caching and set the network emulation to 3G in Chrome' dev tools, I got these warnings in the online normal example:

image

Additional Information

Network emulation and disabling caching is done from Chrome Dev tools:

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions