From 12c41ee813690304dbbf86a387e826e927951ac9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=AD=E5=85=89=E5=BF=97?= <411020382@qq.com> Date: Tue, 7 May 2024 19:25:04 +0800 Subject: [PATCH 1/7] perf: use "includes" instead of "forEach". --- .../src/Core/util/prefetcher/assetsPrefetcher.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/webgal/src/Core/util/prefetcher/assetsPrefetcher.ts b/packages/webgal/src/Core/util/prefetcher/assetsPrefetcher.ts index 2847473cd..7b6e31d2e 100644 --- a/packages/webgal/src/Core/util/prefetcher/assetsPrefetcher.ts +++ b/packages/webgal/src/Core/util/prefetcher/assetsPrefetcher.ts @@ -9,15 +9,9 @@ import { WebGAL } from '@/Core/WebGAL'; */ export const assetsPrefetcher = (assetList: Array) => { for (const asset of assetList) { - // 是否要插入这个标签 - let isInsert = true; // 判断是否已经存在 - WebGAL.sceneManager.settledAssets.forEach((settledAssetUrl) => { - if (settledAssetUrl === asset.url) { - isInsert = false; - } - }); - if (!isInsert) { + const hasPrefetch = WebGAL.sceneManager.settledAssets.includes(asset.url); + if (hasPrefetch) { logger.warn('该资源已在预加载列表中,无需重复加载'); } else { const newLink = document.createElement('link'); From 4b3764e232b562fd8bb734abcd46d0447aad8038 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Thu, 9 May 2024 13:22:50 +0800 Subject: [PATCH 2/7] feat: use alpha filter instead of alpha --- .../src/Core/controller/stage/pixi/PixiController.ts | 2 +- .../Core/controller/stage/pixi/WebGALPixiContainer.ts | 11 +++++++++++ .../Core/controller/stage/pixi/animations/timeline.ts | 6 ++++++ .../stage/pixi/animations/universalSoftIn.ts | 6 +++--- .../stage/pixi/animations/universalSoftOff.ts | 8 ++++---- 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts b/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts index 9a9577273..0254de9de 100644 --- a/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts +++ b/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts @@ -232,7 +232,7 @@ export default class PixiStage { const target = this.getStageObjByKey(thisTickerFunc.targetKey); if (target) { const targetTransform = { - alpha: target.pixiContainer.alpha, + alpha: target.pixiContainer.alphaFilterVal, scale: { x: target.pixiContainer.scale.x, y: target.pixiContainer.scale.y, diff --git a/packages/webgal/src/Core/controller/stage/pixi/WebGALPixiContainer.ts b/packages/webgal/src/Core/controller/stage/pixi/WebGALPixiContainer.ts index bd1b11bf7..5dc9047c2 100644 --- a/packages/webgal/src/Core/controller/stage/pixi/WebGALPixiContainer.ts +++ b/packages/webgal/src/Core/controller/stage/pixi/WebGALPixiContainer.ts @@ -21,8 +21,19 @@ export class WebGALPixiContainer extends PIXI.Container { private baseX = 0; private baseY = 0; + private alphaFilter = new PIXI.filters.AlphaFilter(1); + public constructor() { super(); + this.addFilter(this.alphaFilter); + } + + public get alphaFilterVal() { + return this.alphaFilter.alpha; + } + + public set alphaFilterVal(value: number) { + this.alphaFilter.alpha = value; } public addFilter(filter: PIXI.Filter) { diff --git a/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts b/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts index 377db8ef6..8d94cd474 100644 --- a/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts +++ b/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts @@ -17,6 +17,12 @@ export function generateTimelineObj( targetKey: string, duration: number, ) { + for (const segment of timeline) { + // 处理 alphaL + // @ts-ignore + segment['alphaFilterVal'] = segment.alpha; + segment.alpha = 1; + } const target = WebGAL.gameplay.pixiStage!.getStageObjByKey(targetKey); let currentDelay = 0; const values = []; diff --git a/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftIn.ts b/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftIn.ts index b3bd4e85a..1d7ebcffd 100644 --- a/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftIn.ts +++ b/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftIn.ts @@ -11,7 +11,7 @@ export function generateUniversalSoftInAnimationObj(targetKey: string, duration: */ function setStartState() { if (target) { - target.pixiContainer.alpha = 0; + target.pixiContainer.alphaFilterVal = 0; } } @@ -21,7 +21,7 @@ export function generateUniversalSoftInAnimationObj(targetKey: string, duration: */ function setEndState() { if (target) { - target.pixiContainer.alpha = 1; + target.pixiContainer.alphaFilterVal = 1; } } @@ -36,7 +36,7 @@ export function generateUniversalSoftInAnimationObj(targetKey: string, duration: const currentAddOplityDelta = (duration / baseDuration) * delta; const increasement = 1 / currentAddOplityDelta; // const decreasement = 5 / currentAddOplityDelta; - if (sprite.alpha < 1) { + if (sprite.alphaFilterVal < 1) { sprite.alpha += increasement; } } diff --git a/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftOff.ts b/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftOff.ts index e11a04cc7..0d6c8915d 100644 --- a/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftOff.ts +++ b/packages/webgal/src/Core/controller/stage/pixi/animations/universalSoftOff.ts @@ -14,7 +14,7 @@ export function generateUniversalSoftOffAnimationObj(targetKey: string, duration * 在此书写为动画设置终态的操作 */ function setEndState() { - if (target) target.pixiContainer.alpha = 0; + if (target) target.pixiContainer.alphaFilterVal = 0; } /** @@ -23,12 +23,12 @@ export function generateUniversalSoftOffAnimationObj(targetKey: string, duration */ function tickerFunc(delta: number) { if (target) { - const sprite = target.pixiContainer; + const targetContainer = target.pixiContainer; const baseDuration = WebGAL.gameplay.pixiStage!.frameDuration; const currentAddOplityDelta = (duration / baseDuration) * delta; const decreasement = 1 / currentAddOplityDelta; - if (sprite.alpha > 0) { - sprite.alpha -= decreasement; + if (targetContainer.alphaFilterVal > 0) { + targetContainer.alphaFilterVal -= decreasement; } } } From 93fe65e3422caf3bf2b7d5d9b88cf8e7bbd0254c Mon Sep 17 00:00:00 2001 From: Mahiru Date: Thu, 9 May 2024 13:32:35 +0800 Subject: [PATCH 3/7] fix: convert transform for alpha filter --- packages/webgal/src/Stage/MainStage/useSetEffects.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/webgal/src/Stage/MainStage/useSetEffects.ts b/packages/webgal/src/Stage/MainStage/useSetEffects.ts index 318e020be..796b461cd 100644 --- a/packages/webgal/src/Stage/MainStage/useSetEffects.ts +++ b/packages/webgal/src/Stage/MainStage/useSetEffects.ts @@ -38,6 +38,6 @@ function convertTransform(transform: ITransform | undefined) { if (!transform) { return {}; } - const { position, ...rest } = transform; - return { ...rest, x: position.x, y: position.y }; + const { position, alpha, ...rest } = transform; + return { ...rest, x: position.x, y: position.y, alphaFilterVal: alpha }; } From a04a243da0f3f5fab64cdafc0ea93853e039aab7 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Fri, 10 May 2024 11:15:43 +0800 Subject: [PATCH 4/7] fix: moc3 problem --- .../Core/controller/stage/pixi/PixiController.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts b/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts index 9a9577273..7893468f7 100644 --- a/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts +++ b/packages/webgal/src/Core/controller/stage/pixi/PixiController.ts @@ -657,6 +657,8 @@ export default class PixiStage { // key: key, // pixiContainer: thisFigureContainer, // sourceUrl: jsonPath, + // sourceType: 'live2d', + // sourceExt: 'json', // }); // // eslint-disable-next-line @typescript-eslint/no-this-alias // const instance = this; @@ -707,9 +709,18 @@ export default class PixiStage { // } // instance.updateL2dExpressionByKey(key, expressionToSet); // model.expression(expressionToSet); + // // @ts-ignore + // if (model.internalModel.eyeBlink) { + // // @ts-ignore + // model.internalModel.eyeBlink.blinkInterval = 1000 * 60 * 60 * 24; // @ts-ignore + // model.internalModel.eyeBlink.nextBlinkTimeLeft = 1000 * 60 * 60 * 24; + // } // // // lip-sync is still a problem and you can not. - // SoundManager.volume = 0; + // SoundManager.volume = 0; // @ts-ignore + // if (model.internalModel.angleXParamIndex !== undefined) model.internalModel.angleXParamIndex = 999; // @ts-ignore + // if (model.internalModel.angleYParamIndex !== undefined) model.internalModel.angleYParamIndex = 999; // @ts-ignore + // if (model.internalModel.angleZParamIndex !== undefined) model.internalModel.angleZParamIndex = 999; // thisFigureContainer.addChild(model); // }); // })(); From c5bfd13a57aceeec30ca45b53d849d7b1aacaf00 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sat, 11 May 2024 13:39:54 +0800 Subject: [PATCH 5/7] fix: use true scene name in "sync with terre" --- packages/webgal/src/Core/util/syncWithEditor/syncWithOrigine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/webgal/src/Core/util/syncWithEditor/syncWithOrigine.ts b/packages/webgal/src/Core/util/syncWithEditor/syncWithOrigine.ts index ab5b527a7..1debdad3f 100644 --- a/packages/webgal/src/Core/util/syncWithEditor/syncWithOrigine.ts +++ b/packages/webgal/src/Core/util/syncWithEditor/syncWithOrigine.ts @@ -24,7 +24,7 @@ export const syncWithOrigine = (sceneName: string, sentenceId: number) => { const sceneUrl: string = assetSetter(sceneName, fileType.scene); // 场景写入到运行时 sceneFetcher(sceneUrl).then((rawScene) => { - WebGAL.sceneManager.sceneData.currentScene = sceneParser(rawScene, 'start.txt', sceneUrl); + WebGAL.sceneManager.sceneData.currentScene = sceneParser(rawScene, sceneName, sceneUrl); // 开始快进到指定语句 const currentSceneName = WebGAL.sceneManager.sceneData.currentScene.sceneName; WebGAL.gameplay.isFast = true; From be4d8d7ff7035955a16370e72e8e195d4fe88f19 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sun, 19 May 2024 17:44:28 +0800 Subject: [PATCH 6/7] update version number --- packages/webgal/package.json | 2 +- packages/webgal/public/game/template/template.json | 2 +- packages/webgal/src/config/info.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/webgal/package.json b/packages/webgal/package.json index 05118541e..f9022768b 100644 --- a/packages/webgal/package.json +++ b/packages/webgal/package.json @@ -1,7 +1,7 @@ { "name": "webgal", "private": true, - "version": "4.5.0", + "version": "4.5.1", "scripts": { "dev": "vite --host --port 3000", "build": "cross-env NODE_ENV=production tsc && vite build --base=./", diff --git a/packages/webgal/public/game/template/template.json b/packages/webgal/public/game/template/template.json index 59d462b61..8616a5c80 100644 --- a/packages/webgal/public/game/template/template.json +++ b/packages/webgal/public/game/template/template.json @@ -1,4 +1,4 @@ { "name":"Default Template", - "webgal-version":"4.5.0" + "webgal-version":"4.5.1" } diff --git a/packages/webgal/src/config/info.ts b/packages/webgal/src/config/info.ts index a1ae0235f..27b475513 100644 --- a/packages/webgal/src/config/info.ts +++ b/packages/webgal/src/config/info.ts @@ -1,5 +1,5 @@ export const __INFO = { - version: 'WebGAL 4.5.0', + version: 'WebGAL 4.5.1', contributors: [ { username: 'Mahiru', link: 'https://github.com/MakinoharaShoko' }, { username: 'Hoshinokinya', link: 'https://github.com/hshqwq' }, From c1d9ea6967a208fcfc51bf8a049fc1a8a546298f Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sun, 19 May 2024 17:48:00 +0800 Subject: [PATCH 7/7] Update releasenote.md --- releasenote.md | 44 +++++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/releasenote.md b/releasenote.md index a20fb5356..9d896e034 100644 --- a/releasenote.md +++ b/releasenote.md @@ -8,17 +8,15 @@ #### 新功能 -引入标题和文本框的 UI 自定义功能 - -添加了一个新的水波纹进入特效 +Pixi Container 使用 AlphaFilter 代替 alpha 属性,更好地兼容 Live2D #### 修复 -WebGAL Parser 的部分问题 +WebGAL 与编辑器同步的部分问题 -WebSocket 连接问题 +提高资源预加载效率 -iOS 下字体重叠的问题 +修复 moc3 Live2D 加载问题 ## Release Notes @@ -31,18 +29,15 @@ iOS 下字体重叠的问题 #### New Features -Introduced UI customization for title and textbox - -Added a new ripple entrance effect +Pixi Container uses AlphaFilter instead of alpha property for better Live2D compatibility #### Fixes -Some issues in WebGAL Parser - -WebSocket connection issues +Some issues with WebGAL syncing with the editor -Font overlapping issue on iOS +Improved resource preloading efficiency +Fixed moc3 Live2D loading issues ## リリースノート @@ -55,18 +50,15 @@ Font overlapping issue on iOS #### 新機能 -タイトルとテキストボックスの UI カスタマイズ機能を導入 - -新しい波紋エフェクトを追加 +Pixi Containerがalpha属性の代わりにAlphaFilterを使用するようになり、Live2Dとの互換性が向上しました。 #### 修正 -WebGAL パーサーの一部問題 - -WebSocket 接続の問題 +WebGALとエディターの同期に関するいくつかの問題を修正しました。 -iOS でのフォントの重なり問題 +リソースのプリロード効率を向上させました。 +moc3 Live2Dのロードに関する問題を修正しました。 ## Notes de version @@ -79,15 +71,13 @@ iOS でのフォントの重なり問題 #### Nouvelles fonctionnalités -Ajout de la personnalisation de l'interface utilisateur des titres et des zones de texte - -Ajout d'un nouvel effet d'entrée d'ondulation +Pixi Container utilise AlphaFilter à la place de la propriété alpha, pour une meilleure compatibilité avec Live2D -#### Corrections +#### Correctifs -Quelques problèmes avec WebGAL Parser +Certains problèmes de synchronisation entre WebGAL et l'éditeur -Problèmes de connexion WebSocket +Amélioration de l'efficacité du préchargement des ressources -Problème de chevauchement des polices sous iOS +Correction du problème de chargement de Live2D moc3