@@ -18,6 +18,7 @@ import { setModelSize, resetModelPosition } from "./use-live2d-resize";
1818import { audioTaskQueue } from "@/utils/task-queue" ;
1919import { AiStateEnum , useAiState } from "@/context/ai-state-context" ;
2020import { toaster } from "@/components/ui/toaster" ;
21+ import { useForceIgnoreMouse } from "../utils/use-force-ignore-mouse" ;
2122
2223interface UseLive2DModelProps {
2324 isPet : boolean ; // Whether the model is in pet mode
@@ -38,6 +39,7 @@ export const useLive2DModel = ({
3839 const loadingRef = useRef ( false ) ;
3940 const { setAiState, aiState } = useAiState ( ) ;
4041 const [ isModelReady , setIsModelReady ] = useState ( false ) ;
42+ const { forceIgnoreMouse } = useForceIgnoreMouse ( ) ;
4143
4244 // Cleanup function for Live2D model
4345 const cleanupModel = useCallback ( ( ) => {
@@ -196,6 +198,7 @@ export const useLive2DModel = ({
196198 ( model : Live2DModel ) => {
197199 if ( ! model ) return ;
198200
201+ // Clear all previous listeners
199202 model . removeAllListeners ( "pointerenter" ) ;
200203 model . removeAllListeners ( "pointerleave" ) ;
201204 model . removeAllListeners ( "rightdown" ) ;
@@ -204,6 +207,17 @@ export const useLive2DModel = ({
204207 model . removeAllListeners ( "pointerup" ) ;
205208 model . removeAllListeners ( "pointerupoutside" ) ;
206209
210+ // If force ignore mouse is enabled, disable interaction
211+ if ( forceIgnoreMouse && isPet ) {
212+ model . interactive = false ;
213+ model . cursor = "default" ;
214+ return ;
215+ }
216+
217+ // Enable interactions
218+ model . interactive = true ;
219+ model . cursor = "pointer" ;
220+
207221 let dragging = false ;
208222 let pointerX = 0 ;
209223 let pointerY = 0 ;
@@ -265,7 +279,7 @@ export const useLive2DModel = ({
265279 dragging = false ;
266280 } ) ;
267281 } ,
268- [ isPet ] ,
282+ [ isPet , forceIgnoreMouse ] ,
269283 ) ;
270284
271285 const handleTapMotion = useCallback (
@@ -331,7 +345,7 @@ export const useLive2DModel = ({
331345 if ( modelRef . current && isModelReady ) {
332346 setupModelInteractions ( modelRef . current ) ;
333347 }
334- } , [ isModelReady , setupModelInteractions ] ) ; // Dependency of setupModelInteractions includes isPet already
348+ } , [ isModelReady , setupModelInteractions , forceIgnoreMouse ] ) ;
335349
336350 return {
337351 canvasRef,
0 commit comments