From f38bd1456e7d258c73b5022930401fa38f29b72c Mon Sep 17 00:00:00 2001 From: 06wj <06wj@163.com> Date: Thu, 11 Apr 2024 11:25:05 +0800 Subject: [PATCH] fix: return a white texture when the texture is missing in semantic.handlerTexture --- src/material/semantic.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/material/semantic.js b/src/material/semantic.js index e8b501b1..dd3fbadf 100644 --- a/src/material/semantic.js +++ b/src/material/semantic.js @@ -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); }, /** @@ -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 /**