set crossOrigin on WebGL atlas image loaders

Atlases now load from the CDN; without crossOrigin = "anonymous" the
browser refuses to texImage2D the cross-origin image. Requires the CDN
to send Access-Control-Allow-Origin for /_assets/atlases/.
This commit is contained in:
evanpelle
2026-05-17 14:03:58 -07:00
parent 69b5a9cba2
commit b8d72d3a4e
9 changed files with 9 additions and 0 deletions
@@ -207,6 +207,7 @@ export class ConquestPopupPass {
private loadAtlas(): void {
const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => {
const gl = this.gl;
const tex = gl.createTexture()!;
@@ -268,6 +268,7 @@ export class FxSpritePass {
private async loadAtlas(): Promise<void> {
const img = new Image();
img.crossOrigin = "anonymous";
img.src = fxAtlasUrl;
await img.decode();
const gl = this.gl;
@@ -113,6 +113,7 @@ export class IconProgram {
const gl = this.gl;
const load = (url: string, cb: (tex: WebGLTexture) => void) => {
const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => {
const tex = gl.createTexture()!;
gl.bindTexture(gl.TEXTURE_2D, tex);
@@ -105,6 +105,7 @@ export class StatusIconProgram {
private loadAtlas(): void {
const gl = this.gl;
const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => {
const tex = gl.createTexture()!;
gl.bindTexture(gl.TEXTURE_2D, tex);
@@ -127,6 +127,7 @@ export class TextProgram {
private loadAtlas(): void {
const gl = this.gl;
const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => {
const tex = gl.createTexture()!;
gl.bindTexture(gl.TEXTURE_2D, tex);
@@ -229,6 +229,7 @@ export class RadialMenuPass {
private loadEmojiAtlas(): void {
const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => {
this.atlasImg = img;
this.rebuildAtlasTexture();
@@ -210,6 +210,7 @@ export class StructureLevelPass {
private loadAtlas(): void {
const img = new Image();
img.crossOrigin = "anonymous";
img.onload = () => {
const gl = this.gl;
const tex = gl.createTexture()!;
@@ -245,6 +245,7 @@ export class StructurePass {
private async loadAtlas(): Promise<void> {
const img = new Image();
img.crossOrigin = "anonymous";
img.src = iconAtlasUrl;
await img.decode();
const gl = this.gl;
+1
View File
@@ -301,6 +301,7 @@ export class UnitPass {
private async loadAtlas(): Promise<void> {
const img = new Image();
img.crossOrigin = "anonymous";
img.src = unitAtlasUrl;
await img.decode();
const gl = this.gl;