Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spritesheet with a normal map loads texture twice #5886

Closed
inmylo opened this issue Oct 26, 2021 · 1 comment
Closed

Spritesheet with a normal map loads texture twice #5886

inmylo opened this issue Oct 26, 2021 · 1 comment

Comments

@inmylo
Copy link

inmylo commented Oct 26, 2021

Version

  • Phaser Version: v3.55.2
  • Operating system: Linux
  • Browser: Google Chrome

Description

I try to load multiple textures with this.load.pack(). JSON file contains a section of spritesheets and one of them has a normal map included.

When I load the game browser shows the error: Texture key already in use: m4a1. I'm sure my JSON file doesn't contain the same key twice. Then I move a normalMap definition to the next image - the error now is: Texture key already in use: gun2.

This means generating sprites with normal map uses the same key twice somewhere.

📝 The example below is very basic, so the error happens once per 30-50 page refreshes, not every single time. In my bigger project this happens much more often

Detailed browser error:

​ Texture key already in use: m4a1
checkKey @ phaser-arcade-physics-3.55.2.js:96888
addImage @ phaser-arcade-physics-3.55.2.js:97083
addToCache @ phaser-arcade-physics-3.55.2.js:16963
fileProcessComplete @ phaser-arcade-physics-3.55.2.js:189073
onProcessComplete @ phaser-arcade-physics-3.55.2.js:4961
data.onload @ phaser-arcade-physics-3.55.2.js:16931
load (async)
onProcess @ phaser-arcade-physics-3.55.2.js:16927
nextFile @ phaser-arcade-physics-3.55.2.js:189018
onLoad @ phaser-arcade-physics-3.55.2.js:4890
load (async)
XHRLoader @ phaser-arcade-physics-3.55.2.js:117741
load @ phaser-arcade-physics-3.55.2.js:4855
(anonymous) @ phaser-arcade-physics-3.55.2.js:188972
each @ phaser-arcade-physics-3.55.2.js:36745
checkLoadQueue @ phaser-arcade-physics-3.55.2.js:188958
update @ phaser-arcade-physics-3.55.2.js:188940
emit @ phaser-arcade-physics-3.55.2.js:1928
step @ phaser-arcade-physics-3.55.2.js:44529
update @ phaser-arcade-physics-3.55.2.js:95105
step @ phaser-arcade-physics-3.55.2.js:155129
step @ phaser-arcade-physics-3.55.2.js:84182
step @ phaser-arcade-physics-3.55.2.js:84429
requestAnimationFrame (async)
step @ phaser-arcade-physics-3.55.2.js:84431
requestAnimationFrame (async)
step @ phaser-arcade-physics-3.55.2.js:84431
requestAnimationFrame (async)
start @ phaser-arcade-physics-3.55.2.js:84483
start @ phaser-arcade-physics-3.55.2.js:84052
start @ phaser-arcade-physics-3.55.2.js:155074
texturesReady @ phaser-arcade-physics-3.55.2.js:155054
emit @ phaser-arcade-physics-3.55.2.js:1926
updatePending @ phaser-arcade-physics-3.55.2.js:96868
emit @ phaser-arcade-physics-3.55.2.js:1907
image.onload @ phaser-arcade-physics-3.55.2.js:96998
load (async)
addBase64 @ phaser-arcade-physics-3.55.2.js:96990
boot @ phaser-arcade-physics-3.55.2.js:96847
emit @ phaser-arcade-physics-3.55.2.js:1926
boot @ phaser-arcade-physics-3.55.2.js:155037
check @ phaser-arcade-physics-3.55.2.js:86801

Example Test Code

<!DOCTYPE html>
<html>
<head>
    <script src="files/phaser-arcade-physics-3.55.2.js"></script>
</head>
<body>

    <script>
    var config = {
        type: Phaser.AUTO,
        width: 800,
        height: 600,
        scene: {
            preload: preload,
            create:  create
        }
    };

    var game = new Phaser.Game(config);

    function preload ()
    {
        this.load.pack('assets', 'files/pack.json');
    }

    function create ()
    {
        gun = this.add.sprite(100, 100, 'm4a1');
    }
    </script>

</body>
</html>

pack.json content:

{
    "spritesheets": {
        "path": "files",
        "defaultType": "spritesheet",
        "files": [
            { "key": "m4a1", "url": "m4a1.png", "frameConfig": { "frameWidth": 58, "frameHeight": 21  }, "normalMap": "m4a1-normal.png" },
            { "key": "gun2", "url": "gun2.png", "frameConfig": { "frameWidth": 58, "frameHeight": 21  }}
        ]
    }
}
@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants