2025-04-29 07:20:14 +00:00
|
|
|
import React from "react";
|
|
|
|
import CustomAvatar from "../users/Avatar";
|
2025-05-22 10:14:13 +00:00
|
|
|
import { useSelectedUserStore } from "../../../store/collaboration/useCollabStore";
|
2025-05-13 12:23:00 +00:00
|
|
|
import { useCamMode } from "../../../store/builder/store";
|
2025-04-29 07:20:14 +00:00
|
|
|
|
|
|
|
interface CollabUserIconProps {
|
|
|
|
userName: string;
|
|
|
|
userImage?: string;
|
|
|
|
color: string;
|
2025-05-14 13:09:47 +00:00
|
|
|
id: string;
|
2025-04-29 07:20:14 +00:00
|
|
|
position?: {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
z: number;
|
|
|
|
};
|
|
|
|
rotation?: {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
z: number;
|
|
|
|
};
|
2025-05-07 10:01:07 +00:00
|
|
|
target?: {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
z: number;
|
|
|
|
};
|
2025-04-29 07:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const CollabUserIcon: React.FC<CollabUserIconProps> = ({
|
|
|
|
userImage,
|
|
|
|
userName,
|
2025-05-07 11:01:59 +00:00
|
|
|
id,
|
2025-04-29 07:20:14 +00:00
|
|
|
color,
|
|
|
|
position,
|
|
|
|
rotation,
|
2025-05-07 10:01:07 +00:00
|
|
|
target,
|
2025-04-29 07:20:14 +00:00
|
|
|
}) => {
|
|
|
|
const { setSelectedUser } = useSelectedUserStore();
|
|
|
|
const { setCamMode } = useCamMode();
|
|
|
|
return (
|
|
|
|
<div className="collab-user-live-container">
|
|
|
|
<button
|
2025-05-14 13:09:47 +00:00
|
|
|
id="live-user-button"
|
2025-04-29 07:20:14 +00:00
|
|
|
className="user-image-container"
|
|
|
|
onClick={() => {
|
2025-05-07 10:01:07 +00:00
|
|
|
if (!position || !rotation || !target) return;
|
2025-04-29 07:20:14 +00:00
|
|
|
// Set the selected user in the store
|
2025-05-07 10:01:07 +00:00
|
|
|
setSelectedUser({
|
2025-05-07 11:01:59 +00:00
|
|
|
id: id,
|
2025-05-07 10:01:07 +00:00
|
|
|
color: color,
|
|
|
|
name: userName,
|
|
|
|
location: { position, rotation, target },
|
|
|
|
});
|
2025-04-29 07:20:14 +00:00
|
|
|
setCamMode("FollowPerson");
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{userImage ? (
|
|
|
|
<img className="user-image" src={userImage} alt={userName} />
|
|
|
|
) : (
|
|
|
|
<CustomAvatar name={userName} color={color} />
|
|
|
|
)}
|
|
|
|
</button>
|
|
|
|
<div className="user-name" style={{ backgroundColor: color }}>
|
|
|
|
{userName}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default CollabUserIcon;
|