Skip to content

Commit b9c4c16

Browse files
committed
remove useless resize
1 parent 48063f7 commit b9c4c16

2 files changed

Lines changed: 24 additions & 23 deletions

File tree

src/renderer/src/components/canvas/live2d.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-shadow */
22
/* eslint-disable no-underscore-dangle */
33
/* eslint-disable @typescript-eslint/ban-ts-comment */
4-
import { memo, useRef, useEffect } from "react";
4+
import { memo, useRef, useEffect, useCallback } from "react";
55
import { useLive2DConfig } from "@/context/live2d-config-context";
66
import { useIpcHandlers } from "@/hooks/utils/use-ipc-handlers";
77
import { useInterrupt } from "@/hooks/utils/use-interrupt";
@@ -23,7 +23,7 @@ export const Live2D = memo(
2323
const { modelInfo } = useLive2DConfig();
2424
const internalContainerRef = useRef<HTMLDivElement>(null);
2525
const { aiState } = useAiState();
26-
const { resetExpression } = useLive2DExpression();
26+
const { resetExpression, setExpression } = useLive2DExpression();
2727

2828
// Get canvasRef from useLive2DResize
2929
const { canvasRef } = useLive2DResize({
@@ -55,6 +55,28 @@ export const Live2D = memo(
5555
}
5656
}, [aiState, modelInfo, resetExpression]);
5757

58+
// Expose setExpression for console testing
59+
useEffect(() => {
60+
const testSetExpression = (expressionValue: string | number) => {
61+
const lappAdapter = (window as any).getLAppAdapter?.();
62+
if (lappAdapter) {
63+
setExpression(expressionValue, lappAdapter, `[Console Test] Set expression to: ${expressionValue}`);
64+
} else {
65+
console.error('[Console Test] LAppAdapter not found.');
66+
}
67+
};
68+
69+
// Expose the function to the window object
70+
(window as any).testSetExpression = testSetExpression;
71+
console.log('[Debug] testSetExpression function exposed to window.');
72+
73+
// Cleanup function to remove the function from window when the component unmounts
74+
return () => {
75+
delete (window as any).testSetExpression;
76+
console.log('[Debug] testSetExpression function removed from window.');
77+
};
78+
}, [setExpression]);
79+
5880
const handlePointerDown = (e: React.PointerEvent) => {
5981
handlers.onMouseDown(e);
6082
};

src/renderer/src/hooks/canvas/use-live2d-resize.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -201,27 +201,6 @@ export const useLive2DResize = ({
201201
const delegate = LAppDelegate.getInstance();
202202
if (delegate) {
203203
delegate.onResize();
204-
205-
const viewMatrix = new CubismMatrix44();
206-
let scaleToApply: number;
207-
208-
if (!hasAppliedInitialScale.current) {
209-
scaleToApply = modelInfo?.kScale || DEFAULT_SCALE;
210-
lastScaleRef.current = scaleToApply;
211-
targetScaleRef.current = scaleToApply;
212-
hasAppliedInitialScale.current = true;
213-
} else {
214-
scaleToApply = lastScaleRef.current;
215-
}
216-
217-
viewMatrix.scale(scaleToApply, scaleToApply);
218-
219-
const manager = LAppLive2DManager.getInstance();
220-
if (manager) {
221-
manager.setViewMatrix(viewMatrix);
222-
} else {
223-
console.warn('[Resize] LAppLive2DManager instance not found.');
224-
}
225204
} else {
226205
console.warn('[Resize] LAppDelegate instance not found.');
227206
}

0 commit comments

Comments
 (0)