added dew things
This commit is contained in:
@@ -5,18 +5,22 @@ import CollaborationPopup from "../../templates/CollaborationPopup";
|
|||||||
import { getAvatarColor } from "../../../modules/collaboration/functions/getAvatarColor";
|
import { getAvatarColor } from "../../../modules/collaboration/functions/getAvatarColor";
|
||||||
import { useSelectedUserStore } from "../../../store/collaboration/useCollabStore";
|
import { useSelectedUserStore } from "../../../store/collaboration/useCollabStore";
|
||||||
import { useToggleStore } from "../../../store/ui/useUIToggleStore";
|
import { useToggleStore } from "../../../store/ui/useUIToggleStore";
|
||||||
import { ToggleSidebarIcon } from "../../icons/HeaderIcons";
|
import { useSocketStore } from "../../../store/socket/useSocketStore";
|
||||||
import useModuleStore from "../../../store/ui/useModuleStore";
|
|
||||||
import { getUserData } from "../../../functions/getUserData";
|
|
||||||
import { useSceneContext } from "../../../modules/scene/sceneContext";
|
import { useSceneContext } from "../../../modules/scene/sceneContext";
|
||||||
|
import useModuleStore from "../../../store/ui/useModuleStore";
|
||||||
|
import { ToggleSidebarIcon } from "../../icons/HeaderIcons";
|
||||||
|
import { getUserData } from "../../../functions/getUserData";
|
||||||
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
const Header: React.FC = () => {
|
const Header: React.FC = () => {
|
||||||
|
const { builderSocket } = useSocketStore();
|
||||||
const { collabUsersStore } = useSceneContext();
|
const { collabUsersStore } = useSceneContext();
|
||||||
const { collabUsers } = collabUsersStore();
|
const { collabUsers } = collabUsersStore();
|
||||||
const { userId, userName } = getUserData();
|
const { userId, userName, organization } = getUserData();
|
||||||
const { toggleUILeft, toggleUIRight, setToggleUI } = useToggleStore();
|
const { toggleUILeft, toggleUIRight, setToggleUI } = useToggleStore();
|
||||||
const { activeModule } = useModuleStore();
|
const { activeModule } = useModuleStore();
|
||||||
const { toggleView } = useToggleView();
|
const { toggleView } = useToggleView();
|
||||||
|
const { projectId } = useParams();
|
||||||
|
|
||||||
const guestUsers = collabUsers.filter((user) => user.userId !== userId);
|
const guestUsers = collabUsers.filter((user) => user.userId !== userId);
|
||||||
|
|
||||||
@@ -27,6 +31,7 @@ const Header: React.FC = () => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ((activeModule !== "builder" && activeModule !== "simulation") || (toggleView && selectedUser)) {
|
if ((activeModule !== "builder" && activeModule !== "simulation") || (toggleView && selectedUser)) {
|
||||||
clearSelectedUser();
|
clearSelectedUser();
|
||||||
|
setCamMode("ThirdPerson");
|
||||||
}
|
}
|
||||||
}, [toggleView, activeModule, selectedUser]);
|
}, [toggleView, activeModule, selectedUser]);
|
||||||
|
|
||||||
@@ -50,7 +55,7 @@ const Header: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// retun on no data
|
// retun on no data
|
||||||
if (!position || !target || !rotation) return;
|
if (!position || !target || !rotation || !builderSocket?.connected || !organization || !projectId) return;
|
||||||
|
|
||||||
// Set the selected user in the store
|
// Set the selected user in the store
|
||||||
setSelectedUser({
|
setSelectedUser({
|
||||||
@@ -60,6 +65,8 @@ const Header: React.FC = () => {
|
|||||||
location: { position, rotation, target },
|
location: { position, rotation, target },
|
||||||
});
|
});
|
||||||
setCamMode("FollowPerson");
|
setCamMode("FollowPerson");
|
||||||
|
|
||||||
|
builderSocket.emit("v1:room:userdata:set", { followingUser: user.userId, organization, projectId });
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const FollowPerson: React.FC = () => {
|
|||||||
className="follow-person-container"
|
className="follow-person-container"
|
||||||
onPointerDown={() => {
|
onPointerDown={() => {
|
||||||
clearSelectedUser();
|
clearSelectedUser();
|
||||||
setCamMode("FirstPerson");
|
setCamMode("FollowPerson");
|
||||||
}}
|
}}
|
||||||
style={{ "--user-color": selectedUser.color } as React.CSSProperties}
|
style={{ "--user-color": selectedUser.color } as React.CSSProperties}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { useCallback } from "react";
|
||||||
|
import { useSceneContext } from "../../scene/sceneContext";
|
||||||
|
|
||||||
|
function useAisleResponseHandler() {
|
||||||
|
const { aisleStore } = useSceneContext();
|
||||||
|
const { addAisle, updateAisle, removeAisle } = aisleStore();
|
||||||
|
|
||||||
|
const addAisleToScene = useCallback(
|
||||||
|
(aisle: Aisle, callback?: () => void) => {
|
||||||
|
addAisle(aisle);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[addAisle]
|
||||||
|
);
|
||||||
|
|
||||||
|
const updateAisleInScene = useCallback(
|
||||||
|
(aisle: Aisle, callback?: () => void) => {
|
||||||
|
updateAisle(aisle.aisleUuid, aisle);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[updateAisle]
|
||||||
|
);
|
||||||
|
|
||||||
|
const removeAisleFromScene = useCallback(
|
||||||
|
(aisleUuid: string, callback?: () => void) => {
|
||||||
|
removeAisle(aisleUuid);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[removeAisle]
|
||||||
|
);
|
||||||
|
|
||||||
|
const duplicateAisleInScene = useCallback((aisleUuid: string, callback?: () => void) => {
|
||||||
|
console.log("Duplicating aisle: ", aisleUuid);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const pasteAssetAisleToScene = useCallback((aisle: Aisle, callback?: () => void) => {
|
||||||
|
console.log("Pasting aisle: ", aisle);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
addAisleToScene,
|
||||||
|
updateAisleInScene,
|
||||||
|
removeAisleFromScene,
|
||||||
|
duplicateAisleInScene,
|
||||||
|
pasteAssetAisleToScene,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useAisleResponseHandler;
|
||||||
@@ -5,23 +5,32 @@ function useAssetResponseHandler() {
|
|||||||
const { assetStore } = useSceneContext();
|
const { assetStore } = useSceneContext();
|
||||||
const { addAsset, updateAsset, removeAsset } = assetStore();
|
const { addAsset, updateAsset, removeAsset } = assetStore();
|
||||||
|
|
||||||
const addAssetToScene = useCallback((asset: Asset, callback?: () => void) => {
|
const addAssetToScene = useCallback(
|
||||||
|
(asset: Asset, callback?: () => void) => {
|
||||||
addAsset(asset);
|
addAsset(asset);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[addAsset]
|
||||||
|
);
|
||||||
|
|
||||||
const updateAssetInScene = useCallback((asset: Asset, callback?: () => void) => {
|
const updateAssetInScene = useCallback(
|
||||||
|
(asset: Asset, callback?: () => void) => {
|
||||||
updateAsset(asset.modelUuid, asset);
|
updateAsset(asset.modelUuid, asset);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[updateAsset]
|
||||||
|
);
|
||||||
|
|
||||||
const removeAssetFromScene = useCallback((modelUuid: string, callback?: () => void) => {
|
const removeAssetFromScene = useCallback(
|
||||||
|
(modelUuid: string, callback?: () => void) => {
|
||||||
removeAsset(modelUuid);
|
removeAsset(modelUuid);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[removeAsset]
|
||||||
|
);
|
||||||
|
|
||||||
const duplicateAssetInScene = useCallback((modelUuid: string, callback?: () => void) => {
|
const duplicateAssetInScene = useCallback((modelUuid: string, callback?: () => void) => {
|
||||||
console.log("Duplicating asset: ", modelUuid);
|
console.log("Duplicating asset: ", modelUuid);
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { useCallback } from "react";
|
||||||
|
import { useSceneContext } from "../../scene/sceneContext";
|
||||||
|
|
||||||
|
function useFloorResponseHandler() {
|
||||||
|
const { floorStore } = useSceneContext();
|
||||||
|
const { addFloor, updateFloor, removeFloor } = floorStore();
|
||||||
|
|
||||||
|
const addFloorToScene = useCallback(
|
||||||
|
(floor: Floor, callback?: () => void) => {
|
||||||
|
addFloor(floor);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[addFloor]
|
||||||
|
);
|
||||||
|
|
||||||
|
const updateFloorInScene = useCallback(
|
||||||
|
(floor: Floor, callback?: () => void) => {
|
||||||
|
updateFloor(floor.floorUuid, floor);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[updateFloor]
|
||||||
|
);
|
||||||
|
|
||||||
|
const removeFloorFromScene = useCallback(
|
||||||
|
(floorUuid: string, callback?: () => void) => {
|
||||||
|
removeFloor(floorUuid);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[removeFloor]
|
||||||
|
);
|
||||||
|
|
||||||
|
const duplicateFloorInScene = useCallback((floorUuid: string, callback?: () => void) => {
|
||||||
|
console.log("Duplicating floor: ", floorUuid);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const pasteAssetFloorToScene = useCallback((floor: Floor, callback?: () => void) => {
|
||||||
|
console.log("Pasting floor: ", floor);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
addFloorToScene,
|
||||||
|
updateFloorInScene,
|
||||||
|
removeFloorFromScene,
|
||||||
|
duplicateFloorInScene,
|
||||||
|
pasteAssetFloorToScene,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useFloorResponseHandler;
|
||||||
@@ -5,23 +5,32 @@ function useWallAssetResponseHandler() {
|
|||||||
const { wallAssetStore } = useSceneContext();
|
const { wallAssetStore } = useSceneContext();
|
||||||
const { addWallAsset, updateWallAsset, removeWallAsset } = wallAssetStore();
|
const { addWallAsset, updateWallAsset, removeWallAsset } = wallAssetStore();
|
||||||
|
|
||||||
const addWallAssetToScene = useCallback((asset: WallAsset, callback?: () => void) => {
|
const addWallAssetToScene = useCallback(
|
||||||
|
(asset: WallAsset, callback?: () => void) => {
|
||||||
addWallAsset(asset);
|
addWallAsset(asset);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[addWallAsset]
|
||||||
|
);
|
||||||
|
|
||||||
const updateWallAssetInScene = useCallback((asset: WallAsset, callback?: () => void) => {
|
const updateWallAssetInScene = useCallback(
|
||||||
|
(asset: WallAsset, callback?: () => void) => {
|
||||||
updateWallAsset(asset.modelUuid, asset);
|
updateWallAsset(asset.modelUuid, asset);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[updateWallAsset]
|
||||||
|
);
|
||||||
|
|
||||||
const removeWallAssetFromScene = useCallback((modelUuid: string, callback?: () => void) => {
|
const removeWallAssetFromScene = useCallback(
|
||||||
|
(modelUuid: string, callback?: () => void) => {
|
||||||
removeWallAsset(modelUuid);
|
removeWallAsset(modelUuid);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[removeWallAsset]
|
||||||
|
);
|
||||||
|
|
||||||
const duplicateWallAssetInScene = useCallback((modelUuid: string, callback?: () => void) => {
|
const duplicateWallAssetInScene = useCallback((modelUuid: string, callback?: () => void) => {
|
||||||
console.log("Duplicating wallAsset: ", modelUuid);
|
console.log("Duplicating wallAsset: ", modelUuid);
|
||||||
|
|||||||
@@ -5,23 +5,32 @@ function useWallResponseHandler() {
|
|||||||
const { wallStore } = useSceneContext();
|
const { wallStore } = useSceneContext();
|
||||||
const { addWall, updateWall, removeWall } = wallStore();
|
const { addWall, updateWall, removeWall } = wallStore();
|
||||||
|
|
||||||
const addWallToScene = useCallback((wall: Wall, callback?: () => void) => {
|
const addWallToScene = useCallback(
|
||||||
|
(wall: Wall, callback?: () => void) => {
|
||||||
addWall(wall);
|
addWall(wall);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[addWall]
|
||||||
|
);
|
||||||
|
|
||||||
const updateWallInScene = useCallback((wall: Wall, callback?: () => void) => {
|
const updateWallInScene = useCallback(
|
||||||
|
(wall: Wall, callback?: () => void) => {
|
||||||
updateWall(wall.wallUuid, wall);
|
updateWall(wall.wallUuid, wall);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[updateWall]
|
||||||
|
);
|
||||||
|
|
||||||
const removeWallFromScene = useCallback((modelUuid: string, callback?: () => void) => {
|
const removeWallFromScene = useCallback(
|
||||||
|
(modelUuid: string, callback?: () => void) => {
|
||||||
removeWall(modelUuid);
|
removeWall(modelUuid);
|
||||||
|
|
||||||
if (callback) callback();
|
if (callback) callback();
|
||||||
}, []);
|
},
|
||||||
|
[removeWall]
|
||||||
|
);
|
||||||
|
|
||||||
const duplicateWallInScene = useCallback((modelUuid: string, callback?: () => void) => {
|
const duplicateWallInScene = useCallback((modelUuid: string, callback?: () => void) => {
|
||||||
console.log("Duplicating wall: ", modelUuid);
|
console.log("Duplicating wall: ", modelUuid);
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
import { useCallback } from "react";
|
||||||
|
import { useSceneContext } from "../../scene/sceneContext";
|
||||||
|
|
||||||
|
function useZoneResponseHandler() {
|
||||||
|
const { zoneStore } = useSceneContext();
|
||||||
|
const { addZone, updateZone, removeZone } = zoneStore();
|
||||||
|
|
||||||
|
const addZoneToScene = useCallback(
|
||||||
|
(zone: Zone, callback?: () => void) => {
|
||||||
|
addZone(zone);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[addZone]
|
||||||
|
);
|
||||||
|
|
||||||
|
const updateZoneInScene = useCallback(
|
||||||
|
(zone: Zone, callback?: () => void) => {
|
||||||
|
updateZone(zone.zoneUuid, zone);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[updateZone]
|
||||||
|
);
|
||||||
|
|
||||||
|
const removeZoneFromScene = useCallback(
|
||||||
|
(zoneUuid: string, callback?: () => void) => {
|
||||||
|
removeZone(zoneUuid);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
},
|
||||||
|
[removeZone]
|
||||||
|
);
|
||||||
|
|
||||||
|
const duplicateZoneInScene = useCallback((zoneUuid: string, callback?: () => void) => {
|
||||||
|
console.log("Duplicating zone: ", zoneUuid);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const pasteAssetZoneToScene = useCallback((zone: Zone, callback?: () => void) => {
|
||||||
|
console.log("Pasting zone: ", zone);
|
||||||
|
|
||||||
|
if (callback) callback();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return {
|
||||||
|
addZoneToScene,
|
||||||
|
updateZoneInScene,
|
||||||
|
removeZoneFromScene,
|
||||||
|
duplicateZoneInScene,
|
||||||
|
pasteAssetZoneToScene,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default useZoneResponseHandler;
|
||||||
2
app/src/types/collaborationTypes.d.ts
vendored
2
app/src/types/collaborationTypes.d.ts
vendored
@@ -10,6 +10,8 @@ interface CollabUsersScheme {
|
|||||||
rotation: { x: number; y: number; z: number };
|
rotation: { x: number; y: number; z: number };
|
||||||
target: { x: number; y: number; z: number };
|
target: { x: number; y: number; z: number };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
followingUser: string | null;
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user