fix: pixi v7 isInteractive TypeError + outfit texture swap
- Added isInteractive() stub on Live2DModel to prevent 'e.isInteractive is not a function' errors in pixi v7 - Swapped outfit texture loading to use Assets.load() with cascading fallbacks (model.setTexture -> internalModel -> coreModel) - Removed unused Texture import
This commit is contained in:
@@ -48,7 +48,7 @@ export default function KiraAvatar(props: Props) {
|
||||
}
|
||||
|
||||
await loadScript('/live2d/cubism/live2dcubismcore.min.js');
|
||||
const { Application, Texture } = await import('pixi.js');
|
||||
const { Application } = await import('pixi.js');
|
||||
const { Live2DModel } = await import('pixi-live2d-display/cubism4');
|
||||
|
||||
// Responsive sizing
|
||||
@@ -81,6 +81,9 @@ export default function KiraAvatar(props: Props) {
|
||||
|
||||
app.stage.addChild(model as any);
|
||||
|
||||
// Fix: prevent pixi v7 isInteractive TypeError with Live2D model
|
||||
(model as any).isInteractive = () => false;
|
||||
|
||||
// Store reference to texture_02 for outfit swapping
|
||||
try {
|
||||
textureRef.current = {
|
||||
@@ -166,10 +169,20 @@ export default function KiraAvatar(props: Props) {
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
const { Texture, BaseTexture } = await import('pixi.js');
|
||||
const base = await BaseTexture.from(outfitUrl);
|
||||
const tex = new Texture(base);
|
||||
model.internalModel.coreModel.setTexture(2, base);
|
||||
const { Assets, Texture } = await import('pixi.js');
|
||||
const tex = await Assets.load(outfitUrl);
|
||||
// Swap texture slot 2 (clothing layer)
|
||||
if ((model as any).setTexture) {
|
||||
(model as any).setTexture(2, tex);
|
||||
} else {
|
||||
// Fallback: try internal model
|
||||
try {
|
||||
(model.internalModel as any).setTexture(2, tex);
|
||||
} catch {
|
||||
// Fallback: direct core model
|
||||
(model.internalModel.coreModel as any).setTexture(2, tex);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[Outfit] texture swap failed:', e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user