fix: Live2D Ticker registration + outfit texture swap path
- Registered pixi Ticker via (Live2DModel as any).registerTicker() to fix 'No Ticker registered' warning and animation issues - Fixed outfit texture swap: textures live on model.textures[] not model.internalModel.textures[]
This commit is contained in:
@@ -48,9 +48,13 @@ export default function KiraAvatar(props: Props) {
|
||||
}
|
||||
|
||||
await loadScript('/live2d/cubism/live2dcubismcore.min.js');
|
||||
const { Application } = await import('pixi.js');
|
||||
const { Application, Ticker } = await import('pixi.js');
|
||||
const { Live2DModel } = await import('pixi-live2d-display/cubism4');
|
||||
|
||||
// Register pixi Ticker so Live2DModel can drive animations
|
||||
// Cast needed due to pixi-live2d-display expecting older Ticker type
|
||||
(Live2DModel as any).registerTicker(Ticker as any);
|
||||
|
||||
// Responsive sizing
|
||||
const size = Math.min(container.clientWidth || 260, 260);
|
||||
const app = new Application({
|
||||
@@ -173,8 +177,8 @@ export default function KiraAvatar(props: Props) {
|
||||
const tex = await Assets.load(outfitUrl);
|
||||
// Swap texture slot 2 (clothing layer) in the model's texture array.
|
||||
// The render loop automatically binds WebGL textures from PixiJS textures.
|
||||
if ((model as any).internalModel?.textures) {
|
||||
(model as any).internalModel.textures[2] = tex;
|
||||
if ((model as any).textures) {
|
||||
(model as any).textures[2] = tex;
|
||||
} else {
|
||||
console.warn('[Outfit] cannot swap — no textures array');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user