Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webgal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"mitt": "^3.0.0",
"modern-css-reset": "^1.4.0",
"pixi-filters": "^4.2.0",
"pixi-live2d-display-webgal": "^0.5.12",
"pixi-live2d-display-webgal": "^0.5.16",
"pixi.js": "^6.3.0",
"popmotion": "^11.0.5",
"react": "^17.0.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export async function loadLive2dResources(url: string, load: LoadDependency): Pr
const settings = await load<Live2dSettings>(url, 'json');
const files = settings.FileReferences;
const resolve = (file: string) => new URL(file, url).href;
const textures = await Promise.all(
const rawTextures = await Promise.all(
(files?.Textures ?? settings.textures ?? []).map((file) => load<Texture>(resolve(file), 'texture')),
);
const adaptor = Live2D.createCubism2Texture;
const textures = files?.Moc || !adaptor ? rawTextures : rawTextures.map((texture) => adaptor(texture));

const model = files?.Moc ?? settings.model;
if (model) await load(resolve(model), 'binary');
// 可选动作损坏不应让本来能显示的模型加载失败;SDK 会在使用时重试。
Expand Down
6 changes: 5 additions & 1 deletion packages/webgal/src/Core/live2DCore.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Texture } from 'pixi.js';
import { installLive2dAssetCache } from './controller/stage/pixi/assets/live2dAssetCache';
/** 眨眼参数,毫秒 */
export interface BlinkParam {
Expand Down Expand Up @@ -36,6 +37,8 @@ export class Live2DCore {
public SoundManager: any;
public Config: any;

public createCubism2Texture?: (texture: Texture) => Texture;

// 临时记录未初始化前的数据
// 旧版表情混合模式
private _legacyExpressionBlendMode = false;
Expand All @@ -62,14 +65,15 @@ export class Live2DCore {
console.warn('live2d plugin load failed');
return;
}
const { Live2DModel, SoundManager, config, Live2DLoader, ModelSettings } = await import(
const { Live2DModel, SoundManager, config, Live2DLoader, ModelSettings, createCubism2Texture } = await import(
'pixi-live2d-display-webgal'
);
installLive2dAssetCache({ Live2DLoader, ModelSettings });
this.Live2DModel = Live2DModel;
this.SoundManager = SoundManager;
this.Config = config;
this.isAvailable = true;
this.createCubism2Texture = createCubism2Texture;
console.log('Live2D plugin load success');
this.initConfig();
})
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4993,10 +4993,10 @@ pixi-filters@^4.2.0:
"@pixi/filter-twist" "4.2.0"
"@pixi/filter-zoom-blur" "4.2.0"

pixi-live2d-display-webgal@^0.5.12:
version "0.5.12"
resolved "https://registry.yarnpkg.com/pixi-live2d-display-webgal/-/pixi-live2d-display-webgal-0.5.12.tgz#f920f926e37bacf222c77343782b5b6fc3d209ab"
integrity sha512-93UDIM8ducia8zIgVtidqxlDamxlwEK4+ddUnl/8XcEKBinbr2Qlu0bBN9i1f4c5rzX5OPgEKc0DhjlDa7fJVg==
pixi-live2d-display-webgal@^0.5.16:
version "0.5.16"
resolved "https://registry.yarnpkg.com/pixi-live2d-display-webgal/-/pixi-live2d-display-webgal-0.5.16.tgz#eddc6a4a478f9fef51fce942d0a21faccc2a7074"
integrity sha512-dKKWLHRdC70FUGyo10R0oNtB0fH4q1sCmJxFr3DhHDlUI+rPtsCiGag5PJ8yF6KG9HX+rUpe6R2GrvuHk3N5PA==
dependencies:
gh-pages "^4.0.0"

Expand Down
Loading