diff --git a/packages/website/src/components/MixerScene/components/Model.tsx b/packages/website/src/components/MixerScene/components/Model.tsx index 6ba450857..25fa9c211 100644 --- a/packages/website/src/components/MixerScene/components/Model.tsx +++ b/packages/website/src/components/MixerScene/components/Model.tsx @@ -47,6 +47,7 @@ export function Model() { const pointer = useRef(new Vector2()); const delta = useRef(new Vector2()); + const enablePitchRotation = useRef(true); const handlePointerDown = useCallback((event: ThreeEvent) => { event.stopPropagation(); @@ -65,8 +66,10 @@ export function Model() { modelTransformEvent.dispatch({ pitch: - modelTransformEvent.last!.pitch + - delta.current.y * (Math.PI / bounds.height), + modelTransformEvent.last!.pitch - + (enablePitchRotation.current + ? delta.current.y * (Math.PI / bounds.height) + : 0), yaw: modelTransformEvent.last!.yaw + delta.current.x * (Math.PI / bounds.width), @@ -84,6 +87,7 @@ export function Model() { event: QuicklimeEvent ) { turretGroup.current.rotation.z = event.data.yaw; + gunGroup.current.rotation.x = event.data.pitch; } modelTransformEvent.on(handleModelTransform); @@ -110,19 +114,14 @@ export function Model() { }); })} - - - - - { + enablePitchRotation.current = false; + handlePointerDown(event); + }} /> ); }, @@ -155,44 +157,62 @@ export function Model() { })} - {gunNodes.map((node) => { - const isCurrentMantlet = - node.name === - `gun_${gunModel.model_id.toString().padStart(2, "0")}_mask`; - const isCurrentGun = - node.name === - `gun_${gunModel.model_id.toString().padStart(2, "0")}`; - const isVisible = isCurrentGun || isCurrentMantlet; + + {gunNodes.map((node) => { + const isCurrentMantlet = + node.name === + `gun_${gunModel.model_id.toString().padStart(2, "0")}_mask`; + const isCurrentGun = + node.name === + `gun_${gunModel.model_id.toString().padStart(2, "0")}`; + const isVisible = isCurrentGun || isCurrentMantlet; - if (!isVisible) return null; + if (!isVisible) return null; - return jsxTree(node, { - mesh(_, props, key) { - return ; - }, - }); - })} + return jsxTree(node, { + mesh(_, props, key) { + return ( + { + enablePitchRotation.current = true; + handlePointerDown(event); + }} + /> + ); + }, + }); + })} +