phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.17k stars 7.1k forks source link

3.60 Beta 9: Compressed texture can't be used as tileSprite #6156

Closed Kosmoon closed 2 years ago

Kosmoon commented 2 years ago

Version

3.60 beta 9

Description

compressed texture works fine when used as image or sprite, but throw an error when used as tileSprite:

phaser.min.js:1 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(CSSImageValue or HTMLCanvasElement or HTMLImageElement or HTMLVideoElement or ImageBitmap or OffscreenCanvas or SVGImageElement or VideoFrame)'

Example Test Code

Here is an example with a dxt5 texture (for desktop, but same errors with ASTC on mobile), i uploaded one on a cdn, but you can try with any compressed texture: In preload: this.load.texture("dxt5_test", { S3TC: { type: "PVR", textureURL: "https://cdn-121.anonfiles.com/V8I97as4y2/09fa227c-1656244249/test.pvr", }, IMG: { textureURL: "test.png", }, });

In create: this.add.sprite(0, 0, 'dxt5_test') // works this.add.image(0, 0, 'dxt5_test') // works this.add.tileSprite(0, 0,100,100 'dxt5_test') // Throws an error

photonstorm commented 2 years ago

Yes, I would expect this. There's no way around it, so I'll see if it's possible to at least throw an error in the console if you do this.