Skip to content
Open
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
9 changes: 6 additions & 3 deletions Chat/lib/lira-avatar/liraCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class LiraCore {

// FIX: Disable Pixi auto-resize which might catch the container at 0x0 during animation
// and corrupt the mask buffers. We handle resize manually via Observer.
this.app.resizeTo = null as any;
this.app.resizeTo = null;

// FIX: Force immediate renderer resize to fix "Disappearing Head" (Masking)
// Ensure we NEVER resize to 0x0. Use safe defaults if container is collapsing.
Expand Down Expand Up @@ -117,13 +117,17 @@ export class LiraCore {
console.log("[LiraCore] Model reused from cache.");
this.model = globalModel;
this.model.visible = true;

// FIX: Ensure previous models are cleared even when reusing
this.app.stage.removeChildren();
this.app.stage.addChild(this.model);

this.setupTicker();
return;
}

try {
console.log(`[LiraCore] Loading Fresh Model: ${modelPath}`);
// @ts-ignore
const Live2DModel = window.PIXI.live2d.Live2DModel;

// MONKEY PATCH (Keep it, it's safe)
Expand All @@ -143,7 +147,6 @@ export class LiraCore {
this.model.autoUpdate = false;

// FIX: Clear previous models to prevent duplication
// @ts-ignore
this.app.stage.removeChildren();
this.app.stage.addChild(this.model);

Expand Down
13 changes: 13 additions & 0 deletions Chat/lib/lira-avatar/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Live2DModelType {
y: number;
width: number;
height: number;
visible: boolean;
scale: { x: number, y: number, set: (x: number, y?: number) => void };
anchor: { set: (x: number, y?: number) => void };
on: (event: string, callback: (hitAreas: string[]) => void) => void;
Expand Down Expand Up @@ -36,6 +37,8 @@ export interface PixiApp {
view: HTMLCanvasElement;
stage: {
addChild: (child: any) => void;
removeChild: (child: any) => void;
removeChildren: (beginIndex?: number, endIndex?: number) => void;
};
screen: {
width: number;
Expand All @@ -44,10 +47,16 @@ export interface PixiApp {
ticker: {
add: (fn: (delta: number) => void) => void;
remove: (fn: (delta: number) => void) => void;
stop: () => void;
start: () => void;
elapsedMS: number;
};
start: () => void;
stop: () => void;
resizeTo: HTMLElement | null;
destroy: (removeView?: boolean, stageOptions?: any) => void;
renderer: {
resize: (width: number, height: number) => void;
plugins: {
interaction: {
on: (event: string, fn: (e: any) => void) => void;
Expand All @@ -61,8 +70,12 @@ declare global {
interface Window {
PIXI: {
Application: new (options: any) => PixiApp;
BLEND_MODES: {
NORMAL: any;
};
live2d: {
Live2DModel: {
prototype: any;
from: (url: string, options?: any) => Promise<Live2DModelType>;
registerTicker: (ticker: any) => void;
};
Expand Down
9 changes: 6 additions & 3 deletions LiraCompanion/lib/lira-avatar/liraCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class LiraCore {

// FIX: Disable Pixi auto-resize which might catch the container at 0x0 during animation
// and corrupt the mask buffers. We handle resize manually via Observer.
this.app.resizeTo = null as any;
this.app.resizeTo = null;

// FIX: Force immediate renderer resize to fix "Disappearing Head" (Masking)
// Ensure we NEVER resize to 0x0. Use safe defaults if container is collapsing.
Expand Down Expand Up @@ -124,13 +124,17 @@ export class LiraCore {
console.log("[LiraCore] Model reused from cache.");
this.model = globalModel;
this.model.visible = true;

// FIX: Ensure previous models are cleared even when reusing
this.app.stage.removeChildren();
this.app.stage.addChild(this.model);

this.setupTicker();
return;
}

try {
console.log(`[LiraCore] Loading Fresh Model: ${modelPath}`);
// @ts-ignore
const Live2DModel = window.PIXI.live2d.Live2DModel;

// MONKEY PATCH (Keep it, it's safe)
Expand All @@ -150,7 +154,6 @@ export class LiraCore {
this.model.autoUpdate = false;

// FIX: Clear previous models to prevent duplication
// @ts-ignore
this.app.stage.removeChildren();
this.app.stage.addChild(this.model);

Expand Down
13 changes: 13 additions & 0 deletions LiraCompanion/lib/lira-avatar/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Live2DModelType {
y: number;
width: number;
height: number;
visible: boolean;
scale: { x: number, y: number, set: (x: number, y?: number) => void };
anchor: { set: (x: number, y?: number) => void };
on: (event: string, callback: (hitAreas: string[]) => void) => void;
Expand Down Expand Up @@ -36,6 +37,8 @@ export interface PixiApp {
view: HTMLCanvasElement;
stage: {
addChild: (child: any) => void;
removeChild: (child: any) => void;
removeChildren: (beginIndex?: number, endIndex?: number) => void;
};
screen: {
width: number;
Expand All @@ -44,10 +47,16 @@ export interface PixiApp {
ticker: {
add: (fn: (delta: number) => void) => void;
remove: (fn: (delta: number) => void) => void;
stop: () => void;
start: () => void;
elapsedMS: number;
};
start: () => void;
stop: () => void;
resizeTo: HTMLElement | null;
destroy: (removeView?: boolean, stageOptions?: any) => void;
renderer: {
resize: (width: number, height: number) => void;
plugins: {
interaction: {
on: (event: string, fn: (e: any) => void) => void;
Expand All @@ -61,8 +70,12 @@ declare global {
interface Window {
PIXI: {
Application: new (options: any) => PixiApp;
BLEND_MODES: {
NORMAL: any;
};
live2d: {
Live2DModel: {
prototype: any;
from: (url: string, options?: any) => Promise<Live2DModelType>;
registerTicker: (ticker: any) => void;
};
Expand Down
1 change: 1 addition & 0 deletions LiraCompanion/liraLive2D.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class LiraLive2D {
this.model.y = 50;

// Add to stage
this.app.stage.removeChildren();
this.app.stage.addChild(this.model);

console.log('[Live2D] Model loaded successfully!');
Expand Down