Skip to content

Commit

Permalink
fix: return a white texture when the texture is missing in semantic.h…
Browse files Browse the repository at this point in the history
…andlerTexture
  • Loading branch information
06wj committed Apr 11, 2024
1 parent 58401a5 commit f38bd14
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/material/semantic.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ const semantic = {
return this.handlerGLTexture(value.target, value.getGLTexture(state), textureIndex);
}

return undefined;
const blankTexture = this.getBlankTexture();
return this.handlerGLTexture(blankTexture.target, blankTexture.getGLTexture(state), textureIndex);
},

/**
Expand Down Expand Up @@ -146,6 +147,20 @@ const semantic = {
return 0;
},

_blankTexture: null,
getBlankTexture() {
if (!this._blankTexture) {
this._blankTexture = new DataTexture({
width: 2,
height: 2,
type: constants.UNSIGNED_BYTE,
image: new Uint8Array([128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128]),
});
}

return this._blankTexture;
},

// attributes

/**
Expand Down

0 comments on commit f38bd14

Please sign in to comment.