From fe8736540b9a461d8e96658f4d755ff8089a263b Mon Sep 17 00:00:00 2001 From: RGCHN Date: Sun, 17 Dec 2023 17:37:43 +0800 Subject: [PATCH] fix: render sprite incorrectly caused by diff algorithm when config reusable --- .../src/plugins/sprite/sprite-mesh.ts | 24 ++++++++----------- web-packages/demo/src/single.ts | 3 +-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/effects-core/src/plugins/sprite/sprite-mesh.ts b/packages/effects-core/src/plugins/sprite/sprite-mesh.ts index 5caedd896..c11eb76ad 100644 --- a/packages/effects-core/src/plugins/sprite/sprite-mesh.ts +++ b/packages/effects-core/src/plugins/sprite/sprite-mesh.ts @@ -194,24 +194,20 @@ export class SpriteMesh { const uSizeStart = start + 4; const uQuatStart = start + 8; const uColorStart = start + 12; - - if (!selfData.visible && !init) { - mainDataArray[uSizeStart + 2] = -1; - - return; - } - - const uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]]; - - // if (selfData.startSize) { - // selfData.transform.scaleBy(1 / selfData.startSize[0], 1 / selfData.startSize[1], 1); - // } - const tempPos = new Vector3(); const tempQuat = new Quaternion(); const tempScale = new Vector3(); + const uColor = selfData.color || [mainDataArray[uColorStart], mainDataArray[uColorStart + 1], mainDataArray[uColorStart + 2], mainDataArray[uColorStart + 3]]; - selfData.transform.assignWorldTRS(tempPos, tempQuat, tempScale); + if (selfData.visible) { + selfData.transform.assignWorldTRS(tempPos, tempQuat, tempScale); + } else { + if (!init) { + mainDataArray[uSizeStart + 2] = -1; + + return; + } + } const uPos = [...tempPos.toArray(), 0]; const uSize = [...tempScale.toArray(), 0]; diff --git a/web-packages/demo/src/single.ts b/web-packages/demo/src/single.ts index 316bb3eff..0255b8ddf 100644 --- a/web-packages/demo/src/single.ts +++ b/web-packages/demo/src/single.ts @@ -3,14 +3,13 @@ import '@galacean/effects-plugin-spine'; import '@galacean/effects-plugin-model'; import inspireList from './assets/inspire-list'; -const json = inspireList.preComp.url; +const json = 'https://mdn.alipayobjects.com/mars/afts/file/A*3mT3SJ4KGKYAAAAAAAAAAAAADlB4AQ'; const container = document.getElementById('J-container'); (async () => { try { const player = createPlayer(); - const comp = await player.loadScene(json); } catch (e) { console.error('biz', e); }