refactor: Improve code readability by adding missing commas and logging data in socket responses
This commit is contained in:
@@ -14,6 +14,7 @@ import useModuleStore, { useSubModuleStore } from '../../../../../store/useModul
|
|||||||
import { useLeftData, useTopData } from '../../../../../store/visualization/useZone3DWidgetStore';
|
import { useLeftData, useTopData } from '../../../../../store/visualization/useZone3DWidgetStore';
|
||||||
import { useSelectedAsset } from '../../../../../store/simulation/useSimulationStore';
|
import { useSelectedAsset } from '../../../../../store/simulation/useSimulationStore';
|
||||||
import { useProductContext } from '../../../../simulation/products/productContext';
|
import { useProductContext } from '../../../../simulation/products/productContext';
|
||||||
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
function Model({ asset }: { readonly asset: Asset }) {
|
function Model({ asset }: { readonly asset: Asset }) {
|
||||||
const { camera, controls, gl } = useThree();
|
const { camera, controls, gl } = useThree();
|
||||||
@@ -38,6 +39,7 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
const [gltfScene, setGltfScene] = useState<GLTF | null>(null);
|
const [gltfScene, setGltfScene] = useState<GLTF | null>(null);
|
||||||
const [boundingBox, setBoundingBox] = useState<THREE.Box3 | null>(null);
|
const [boundingBox, setBoundingBox] = useState<THREE.Box3 | null>(null);
|
||||||
const groupRef = useRef<THREE.Group>(null);
|
const groupRef = useRef<THREE.Group>(null);
|
||||||
|
const { projectId } = useParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loader = new GLTFLoader();
|
const loader = new GLTFLoader();
|
||||||
@@ -157,6 +159,7 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
if (activeTool === 'delete' && deletableFloorItem && deletableFloorItem.uuid === asset.modelUuid) {
|
if (activeTool === 'delete' && deletableFloorItem && deletableFloorItem.uuid === asset.modelUuid) {
|
||||||
const email = localStorage.getItem('email')
|
const email = localStorage.getItem('email')
|
||||||
const organization = (email!.split("@")[1]).split(".")[0];
|
const organization = (email!.split("@")[1]).split(".")[0];
|
||||||
|
const userId = localStorage.getItem("userId");
|
||||||
|
|
||||||
//REST
|
//REST
|
||||||
|
|
||||||
@@ -168,10 +171,12 @@ function Model({ asset }: { readonly asset: Asset }) {
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
modelUuid: asset.modelUuid,
|
modelUuid: asset.modelUuid,
|
||||||
modelName: asset.modelName,
|
modelName: asset.modelName,
|
||||||
socketId: socket.id
|
socketId: socket.id,
|
||||||
|
userId,
|
||||||
|
projectId
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = socket.emit('v2:model-asset:delete', data)
|
const response = socket.emit('v1:model-asset:delete', data)
|
||||||
|
|
||||||
useEventsStore.getState().removeEvent(asset.modelUuid);
|
useEventsStore.getState().removeEvent(asset.modelUuid);
|
||||||
useProductStore.getState().deleteEvent(asset.modelUuid);
|
useProductStore.getState().deleteEvent(asset.modelUuid);
|
||||||
|
|||||||
@@ -72,7 +72,8 @@ const DxfFile = ({
|
|||||||
line: lineData.line,
|
line: lineData.line,
|
||||||
type: lineData.type,
|
type: lineData.type,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:create', input);
|
socket.emit('v1:Line:create', input);
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ export default async function addDragControl(
|
|||||||
position: { "x": event.object.position.x, "y": 0.01, "z": event.object.position.z },
|
position: { "x": event.object.position.x, "y": 0.01, "z": event.object.position.z },
|
||||||
uuid: event.object.uuid,
|
uuid: event.object.uuid,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:update', data);
|
socket.emit('v1:Line:update', data);
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ async function drawOnlyFloor(
|
|||||||
line: data.line,
|
line: data.line,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:create', input);
|
socket.emit('v1:Line:create', input);
|
||||||
@@ -162,7 +163,9 @@ async function drawOnlyFloor(
|
|||||||
layer: data.layer,
|
layer: data.layer,
|
||||||
line: data.line,
|
line: data.line,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
socketId: socket.id,projectId,userId
|
socketId: socket.id,
|
||||||
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:create', input);
|
socket.emit('v1:Line:create', input);
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ async function DeleteLayer(
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
layer: removedLayer,
|
layer: removedLayer,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:delete:layer', data);
|
socket.emit('v1:Line:delete:layer', data);
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ function deleteLine(
|
|||||||
{ "uuid": linePoints[1][1] }
|
{ "uuid": linePoints[1][1] }
|
||||||
],
|
],
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:delete', data);
|
socket.emit('v1:Line:delete', data);
|
||||||
|
|||||||
@@ -91,7 +91,8 @@ async function drawWall(
|
|||||||
line: data.line,
|
line: data.line,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('input: ', input);
|
console.log('input: ', input);
|
||||||
@@ -153,7 +154,8 @@ async function drawWall(
|
|||||||
line: data.line,
|
line: data.line,
|
||||||
type: data.type,
|
type: data.type,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('input: ', input);
|
console.log('input: ', input);
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ function splitLine(
|
|||||||
{ "uuid": visibleIntersect.object.userData.linePoints[0][1] },
|
{ "uuid": visibleIntersect.object.userData.linePoints[0][1] },
|
||||||
{ "uuid": visibleIntersect.object.userData.linePoints[1][1] }
|
{ "uuid": visibleIntersect.object.userData.linePoints[1][1] }
|
||||||
],
|
],
|
||||||
socketId: socket.id,projectId,userId
|
socketId: socket.id,
|
||||||
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:delete', data);
|
socket.emit('v1:Line:delete', data);
|
||||||
@@ -94,7 +96,9 @@ function splitLine(
|
|||||||
layer: line1.layer,
|
layer: line1.layer,
|
||||||
line: line1.line,
|
line: line1.line,
|
||||||
type: line1.type,
|
type: line1.type,
|
||||||
socketId: socket.id,projectId,userId
|
socketId: socket.id,
|
||||||
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:create', input1);
|
socket.emit('v1:Line:create', input1);
|
||||||
@@ -110,7 +114,9 @@ function splitLine(
|
|||||||
layer: line2.layer,
|
layer: line2.layer,
|
||||||
line: line2.line,
|
line: line2.line,
|
||||||
type: line2.type,
|
type: line2.type,
|
||||||
socketId: socket.id,projectId,userId
|
socketId: socket.id,
|
||||||
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:Line:create', input2);
|
socket.emit('v1:Line:create', input2);
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ function deletePoint(
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
uuid: DeletedPointUUID,
|
uuid: DeletedPointUUID,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('data: ', data);
|
console.log('data: ', data);
|
||||||
|
|||||||
@@ -114,7 +114,9 @@ async function AddWallItems(
|
|||||||
position: newWallItem.position,
|
position: newWallItem.position,
|
||||||
quaternion: newWallItem.quaternion,
|
quaternion: newWallItem.quaternion,
|
||||||
scale: newWallItem.scale,
|
scale: newWallItem.scale,
|
||||||
socketId: socket.id, projectId, userId
|
socketId: socket.id,
|
||||||
|
projectId,
|
||||||
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
// console.log('data: ', data);
|
// console.log('data: ', data);
|
||||||
|
|||||||
@@ -36,7 +36,9 @@ function DeleteWallItems(
|
|||||||
organization: organization,
|
organization: organization,
|
||||||
modelUuid: removedItem?.model?.uuid!,
|
modelUuid: removedItem?.model?.uuid!,
|
||||||
modelName: removedItem?.modelName!,
|
modelName: removedItem?.modelName!,
|
||||||
socketId: socket.id,projectId,userId
|
socketId: socket.id,
|
||||||
|
projectId,
|
||||||
|
userId
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.emit('v1:wallItems:delete', data);
|
socket.emit('v1:wallItems:delete', data);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (toolMode === 'move') {
|
if (toolMode === 'move') {
|
||||||
addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket,projectId);
|
addDragControl(dragPointControls, currentLayerPoint, state, floorPlanGroupPoint, floorPlanGroupLine, lines, onlyFloorlines, socket, projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -50,7 +50,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||||||
const organization = (email!.split("@")[1]).split(".")[0];
|
const organization = (email!.split("@")[1]).split(".")[0];
|
||||||
|
|
||||||
// Load data from localStorage if available
|
// Load data from localStorage if available
|
||||||
getLines(organization,projectId).then((data) => {
|
getLines(organization, projectId).then((data) => {
|
||||||
// console.log('data: ', data);
|
// console.log('data: ', data);
|
||||||
|
|
||||||
const Lines: Types.Lines = objectLinesToArray(data);
|
const Lines: Types.Lines = objectLinesToArray(data);
|
||||||
@@ -107,7 +107,7 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (removedLayer !== null) {
|
if (removedLayer !== null) {
|
||||||
DeleteLayer(removedLayer, lines, floorPlanGroupLine, floorPlanGroupPoint, onlyFloorlines, floorGroup, setDeletedLines, setRemovedLayer, socket,projectId);
|
DeleteLayer(removedLayer, lines, floorPlanGroupLine, floorPlanGroupPoint, onlyFloorlines, floorGroup, setDeletedLines, setRemovedLayer, socket, projectId);
|
||||||
}
|
}
|
||||||
}, [removedLayer]);
|
}, [removedLayer]);
|
||||||
|
|
||||||
@@ -153,19 +153,19 @@ const FloorPlanGroup = ({ floorPlanGroup, floorPlanGroupLine, floorPlanGroupPoin
|
|||||||
|
|
||||||
if (deletePointOrLine) {
|
if (deletePointOrLine) {
|
||||||
if (hoveredDeletablePoint.current !== null) {
|
if (hoveredDeletablePoint.current !== null) {
|
||||||
deletePoint(hoveredDeletablePoint, onlyFloorlines, floorPlanGroupPoint, floorPlanGroupLine, lines, setDeletedLines, socket,projectId);
|
deletePoint(hoveredDeletablePoint, onlyFloorlines, floorPlanGroupPoint, floorPlanGroupLine, lines, setDeletedLines, socket, projectId);
|
||||||
}
|
}
|
||||||
if (hoveredDeletableLine.current !== null) {
|
if (hoveredDeletableLine.current !== null) {
|
||||||
deleteLine(hoveredDeletableLine, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroupPoint, setDeletedLines, socket,projectId);
|
deleteLine(hoveredDeletableLine, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroupPoint, setDeletedLines, socket, projectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolMode === "Wall") {
|
if (toolMode === "Wall") {
|
||||||
drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket);
|
drawWall(raycaster, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toolMode === "Floor") {
|
if (toolMode === "Floor") {
|
||||||
drawOnlyFloor(raycaster, state, camera, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, onlyFloorline, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket,projectId);
|
drawOnlyFloor(raycaster, state, camera, plane, floorPlanGroupPoint, snappedPoint, isSnapped, isSnappedUUID, line, ispreSnapped, anglesnappedPoint, isAngleSnapped, onlyFloorline, onlyFloorlines, lines, floorPlanGroupLine, floorPlanGroup, ReferenceLineMesh, LineCreated, currentLayerPoint, dragPointControls, setNewLines, setDeletedLines, activeLayer, socket, projectId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -155,7 +155,8 @@ const WallItemsGroup = ({
|
|||||||
quaternion: currentItem.quaternion,
|
quaternion: currentItem.quaternion,
|
||||||
scale: currentItem.scale!,
|
scale: currentItem.scale!,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
// console.log('data: ', data);
|
// console.log('data: ', data);
|
||||||
|
|||||||
@@ -82,10 +82,11 @@ const ZoneGroup: React.FC = () => {
|
|||||||
|
|
||||||
const organization = email.split("@")[1].split(".")[0];
|
const organization = email.split("@")[1].split(".")[0];
|
||||||
const data = await getZonesApi(organization, projectId);
|
const data = await getZonesApi(organization, projectId);
|
||||||
|
console.log('data: ', data);
|
||||||
|
|
||||||
if (data.data && data.data.length > 0) {
|
if (data.length > 0) {
|
||||||
const fetchedZones = data.data.map((zone: any) => ({
|
const fetchedZones = data.map((zone: any) => ({
|
||||||
zoneId: zone.zoneId,
|
zoneUuid: zone.zoneUuid,
|
||||||
zoneName: zone.zoneName,
|
zoneName: zone.zoneName,
|
||||||
points: zone.points,
|
points: zone.points,
|
||||||
viewPortCenter: zone.viewPortCenter,
|
viewPortCenter: zone.viewPortCenter,
|
||||||
@@ -95,7 +96,7 @@ const ZoneGroup: React.FC = () => {
|
|||||||
|
|
||||||
setZones(fetchedZones);
|
setZones(fetchedZones);
|
||||||
|
|
||||||
const fetchedPoints = data.data.flatMap((zone: any) =>
|
const fetchedPoints = data.flatMap((zone: any) =>
|
||||||
zone.points
|
zone.points
|
||||||
.slice(0, 4)
|
.slice(0, 4)
|
||||||
.map(
|
.map(
|
||||||
@@ -130,7 +131,7 @@ const ZoneGroup: React.FC = () => {
|
|||||||
zones
|
zones
|
||||||
.filter((zone: any) => zone.layer === removedLayer)
|
.filter((zone: any) => zone.layer === removedLayer)
|
||||||
.forEach((zone: any) => {
|
.forEach((zone: any) => {
|
||||||
deleteZoneFromBackend(zone.zoneId);
|
deleteZoneFromBackend(zone.zoneUuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
setRemovedLayer(null);
|
setRemovedLayer(null);
|
||||||
@@ -153,12 +154,12 @@ const ZoneGroup: React.FC = () => {
|
|||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
const addZoneToBackend = async (zone: {
|
const addZoneToBackend = async (zone: {
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
zoneName: string;
|
zoneName: string;
|
||||||
points: [number, number, number][];
|
points: [number, number, number][];
|
||||||
layer: string;
|
layer: string;
|
||||||
}) => {
|
}) => {
|
||||||
console.log('zoneId: ', zone);
|
console.log('zoneUuid: ', zone);
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const userId = localStorage.getItem("userId");
|
const userId = localStorage.getItem("userId");
|
||||||
const organization = email!.split("@")[1].split(".")[0];
|
const organization = email!.split("@")[1].split(".")[0];
|
||||||
@@ -192,10 +193,11 @@ const ZoneGroup: React.FC = () => {
|
|||||||
|
|
||||||
const input = {
|
const input = {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
projectId,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
zoneData: {
|
zoneData: {
|
||||||
zoneName: zone.zoneName,
|
zoneName: zone.zoneName,
|
||||||
zoneId: zone.zoneId,
|
zoneUuid: zone.zoneUuid,
|
||||||
points: zone.points,
|
points: zone.points,
|
||||||
viewPortCenter: target,
|
viewPortCenter: target,
|
||||||
viewPortposition: position,
|
viewPortposition: position,
|
||||||
@@ -203,12 +205,12 @@ const ZoneGroup: React.FC = () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v2:zone:set", input);
|
socket.emit("v1:zone:set", input);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
const updateZoneToBackend = async (zone: {
|
const updateZoneToBackend = async (zone: {
|
||||||
zoneId: string;
|
zoneUuid: string;
|
||||||
zoneName: string;
|
zoneName: string;
|
||||||
points: [number, number, number][];
|
points: [number, number, number][];
|
||||||
layer: string;
|
layer: string;
|
||||||
@@ -246,10 +248,11 @@ const ZoneGroup: React.FC = () => {
|
|||||||
|
|
||||||
const input = {
|
const input = {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
projectId,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
zoneData: {
|
zoneData: {
|
||||||
zoneName: zone.zoneName,
|
zoneName: zone.zoneName,
|
||||||
zoneId: zone.zoneId,
|
zoneUuid: zone.zoneUuid,
|
||||||
points: zone.points,
|
points: zone.points,
|
||||||
viewPortCenter: target,
|
viewPortCenter: target,
|
||||||
viewPortposition: position,
|
viewPortposition: position,
|
||||||
@@ -257,29 +260,30 @@ const ZoneGroup: React.FC = () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v2:zone:set", input);
|
socket.emit("v1:zone:set", input);
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteZoneFromBackend = async (zoneId: string) => {
|
const deleteZoneFromBackend = async (zoneUuid: string) => {
|
||||||
const email = localStorage.getItem("email");
|
const email = localStorage.getItem("email");
|
||||||
const userId = localStorage.getItem("userId");
|
const userId = localStorage.getItem("userId");
|
||||||
const organization = email!.split("@")[1].split(".")[0];
|
const organization = email!.split("@")[1].split(".")[0];
|
||||||
|
|
||||||
const input = {
|
const input = {
|
||||||
userId: userId,
|
userId: userId,
|
||||||
|
projectId,
|
||||||
organization: organization,
|
organization: organization,
|
||||||
zoneId: zoneId,
|
zoneUuid: zoneUuid,
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v2:zone:delete", input);
|
socket.emit("v1:zone:delete", input);
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
const handleDeleteZone = (zoneId: string) => {
|
const handleDeleteZone = (zoneUuid: string) => {
|
||||||
const updatedZones = zones.filter((zone: any) => zone.zoneId !== zoneId);
|
const updatedZones = zones.filter((zone: any) => zone.zoneUuid !== zoneUuid);
|
||||||
setZones(updatedZones);
|
setZones(updatedZones);
|
||||||
|
|
||||||
const zoneIndex = zones.findIndex((zone: any) => zone.zoneId === zoneId);
|
const zoneIndex = zones.findIndex((zone: any) => zone.zoneUuid === zoneUuid);
|
||||||
if (zoneIndex !== -1) {
|
if (zoneIndex !== -1) {
|
||||||
const zonePointsToRemove = zonePoints.slice(
|
const zonePointsToRemove = zonePoints.slice(
|
||||||
zoneIndex * 4,
|
zoneIndex * 4,
|
||||||
@@ -294,7 +298,7 @@ const ZoneGroup: React.FC = () => {
|
|||||||
);
|
);
|
||||||
setZonePoints(updatedzonePoints);
|
setZonePoints(updatedzonePoints);
|
||||||
}
|
}
|
||||||
deleteZoneFromBackend(zoneId);
|
deleteZoneFromBackend(zoneUuid);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -356,9 +360,9 @@ const ZoneGroup: React.FC = () => {
|
|||||||
] as [number, number, number][];
|
] as [number, number, number][];
|
||||||
|
|
||||||
const zoneName = `Zone ${zones.length + 1}`;
|
const zoneName = `Zone ${zones.length + 1}`;
|
||||||
const zoneId = THREE.MathUtils.generateUUID();
|
const zoneUuid = THREE.MathUtils.generateUUID();
|
||||||
const newZone = {
|
const newZone = {
|
||||||
zoneId,
|
zoneUuid,
|
||||||
zoneName,
|
zoneName,
|
||||||
points: points,
|
points: points,
|
||||||
layer: activeLayer,
|
layer: activeLayer,
|
||||||
@@ -402,8 +406,8 @@ const ZoneGroup: React.FC = () => {
|
|||||||
);
|
);
|
||||||
if (sphereIndex !== -1) {
|
if (sphereIndex !== -1) {
|
||||||
const zoneIndex = Math.floor(sphereIndex / 4);
|
const zoneIndex = Math.floor(sphereIndex / 4);
|
||||||
const zoneId = zones[zoneIndex].zoneId;
|
const zoneUuid = zones[zoneIndex].zoneUuid;
|
||||||
handleDeleteZone(zoneId);
|
handleDeleteZone(zoneUuid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -534,9 +538,9 @@ const ZoneGroup: React.FC = () => {
|
|||||||
<group name="zones" visible={!toggleView}>
|
<group name="zones" visible={!toggleView}>
|
||||||
{zones.map((zone: any) => (
|
{zones.map((zone: any) => (
|
||||||
<group
|
<group
|
||||||
key={zone.zoneId}
|
key={zone.zoneUuid}
|
||||||
name={zone.zoneName}
|
name={zone.zoneName}
|
||||||
visible={zone.zoneId === selectedZone.zoneUuid}
|
visible={zone.zoneUuid === selectedZone.zoneUuid}
|
||||||
>
|
>
|
||||||
{zone.points
|
{zone.points
|
||||||
.slice(0, -1)
|
.slice(0, -1)
|
||||||
@@ -613,7 +617,7 @@ const ZoneGroup: React.FC = () => {
|
|||||||
return (
|
return (
|
||||||
<Html
|
<Html
|
||||||
// data
|
// data
|
||||||
key={zone.zoneId}
|
key={zone.zoneUuid}
|
||||||
position={htmlPosition}
|
position={htmlPosition}
|
||||||
// class
|
// class
|
||||||
className="zone-name-wrapper"
|
className="zone-name-wrapper"
|
||||||
@@ -632,14 +636,14 @@ const ZoneGroup: React.FC = () => {
|
|||||||
.filter((zone: any) => zone.layer === activeLayer)
|
.filter((zone: any) => zone.layer === activeLayer)
|
||||||
.map((zone: any) => (
|
.map((zone: any) => (
|
||||||
<Line
|
<Line
|
||||||
key={zone.zoneId}
|
key={zone.zoneUuid}
|
||||||
points={zone.points}
|
points={zone.points}
|
||||||
color="#007BFF"
|
color="#007BFF"
|
||||||
lineWidth={3}
|
lineWidth={3}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (deletePointOrLine) {
|
if (deletePointOrLine) {
|
||||||
handleDeleteZone(zone.zoneId);
|
handleDeleteZone(zone.zoneUuid);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -705,10 +709,10 @@ const ZoneGroup: React.FC = () => {
|
|||||||
.flatMap((zone: any) =>
|
.flatMap((zone: any) =>
|
||||||
zone.points.slice(0, 4).map((point: any, pointIndex: number) => (
|
zone.points.slice(0, 4).map((point: any, pointIndex: number) => (
|
||||||
<Sphere
|
<Sphere
|
||||||
key={`${zone.zoneId}-point-${pointIndex}`}
|
key={`${zone.zoneUuid}-point-${pointIndex}`}
|
||||||
position={new THREE.Vector3(...point)}
|
position={new THREE.Vector3(...point)}
|
||||||
args={[0.3, 16, 16]}
|
args={[0.3, 16, 16]}
|
||||||
name={`point-${zone.zoneId}-${pointIndex}`}
|
name={`point-${zone.zoneUuid}-${pointIndex}`}
|
||||||
>
|
>
|
||||||
<meshBasicMaterial color="red" />
|
<meshBasicMaterial color="red" />
|
||||||
</Sphere>
|
</Sphere>
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ export default function SocketResponses({
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("v1:Line:response:update", (data: any) => {
|
socket.on("v1:Line:response:update", (data: any) => {
|
||||||
|
console.log('data: ', data);
|
||||||
if (socket.id === data.socketId) {
|
if (socket.id === data.socketId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -670,6 +671,7 @@ export default function SocketResponses({
|
|||||||
const organization = email!.split("@")[1].split(".")[0];
|
const organization = email!.split("@")[1].split(".")[0];
|
||||||
|
|
||||||
socket.on("v1:Line:response:create", async (data: any) => {
|
socket.on("v1:Line:response:create", async (data: any) => {
|
||||||
|
console.log('data: ', data);
|
||||||
//
|
//
|
||||||
if (socket.id === data.socketId) {
|
if (socket.id === data.socketId) {
|
||||||
return;
|
return;
|
||||||
@@ -788,6 +790,7 @@ export default function SocketResponses({
|
|||||||
const organization = email!.split("@")[1].split(".")[0];
|
const organization = email!.split("@")[1].split(".")[0];
|
||||||
|
|
||||||
socket.on("v1:zone:response:updates", (data: any) => {
|
socket.on("v1:zone:response:updates", (data: any) => {
|
||||||
|
console.log('data: ', data);
|
||||||
if (socket.id === data.socketId) {
|
if (socket.id === data.socketId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -833,6 +836,7 @@ export default function SocketResponses({
|
|||||||
});
|
});
|
||||||
|
|
||||||
socket.on("v1:zone:response:delete", (data: any) => {
|
socket.on("v1:zone:response:delete", (data: any) => {
|
||||||
|
console.log('data: ', data);
|
||||||
if (socket.id === data.socketId) {
|
if (socket.id === data.socketId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ export default function updateCamPosition(
|
|||||||
position: position,
|
position: position,
|
||||||
target: new THREE.Vector3(target.x, 0, target.z),
|
target: new THREE.Vector3(target.x, 0, target.z),
|
||||||
rotation: new THREE.Vector3(rotation.x, rotation.y, rotation.z),
|
rotation: new THREE.Vector3(rotation.x, rotation.y, rotation.z),
|
||||||
socketId: socket.id,projectId
|
socketId: socket.id,
|
||||||
|
projectId
|
||||||
};
|
};
|
||||||
socket.emit("v1:Camera:set", camData);
|
socket.emit("v1:Camera:set", camData);
|
||||||
localStorage.setItem("cameraPosition", JSON.stringify(position));
|
localStorage.setItem("cameraPosition", JSON.stringify(position));
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ export default function Controls() {
|
|||||||
|
|
||||||
const camData = {
|
const camData = {
|
||||||
organization: organization,
|
organization: organization,
|
||||||
userId: localStorage.getItem('userId')!,
|
userId: userId,
|
||||||
position: new THREE.Vector3(...CONSTANTS.threeDimension.defaultPosition),
|
position: new THREE.Vector3(...CONSTANTS.threeDimension.defaultPosition),
|
||||||
target: new THREE.Vector3(...CONSTANTS.threeDimension.defaultTarget),
|
target: new THREE.Vector3(...CONSTANTS.threeDimension.defaultTarget),
|
||||||
rotation: new THREE.Vector3(...CONSTANTS.threeDimension.defaultRotation),
|
rotation: new THREE.Vector3(...CONSTANTS.threeDimension.defaultRotation),
|
||||||
|
|||||||
@@ -359,7 +359,8 @@ const CopyPasteControls = ({
|
|||||||
isVisible: true,
|
isVisible: true,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
eventData: eventData,
|
eventData: eventData,
|
||||||
userId, projectId
|
userId,
|
||||||
|
projectId
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v1:model-asset:add", data);
|
socket.emit("v1:model-asset:add", data);
|
||||||
@@ -412,7 +413,9 @@ const CopyPasteControls = ({
|
|||||||
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
rotation: { x: obj.rotation.x, y: obj.rotation.y, z: obj.rotation.z },
|
||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
socketId: socket.id, projectId, userId
|
socketId: socket.id,
|
||||||
|
projectId,
|
||||||
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v1:model-asset:add", data);
|
socket.emit("v1:model-asset:add", data);
|
||||||
|
|||||||
@@ -334,7 +334,8 @@ const DuplicationControls = ({
|
|||||||
isVisible: true,
|
isVisible: true,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
eventData: eventData,
|
eventData: eventData,
|
||||||
projectId, userId
|
projectId,
|
||||||
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v1:model-asset:add", data);
|
socket.emit("v1:model-asset:add", data);
|
||||||
@@ -382,7 +383,8 @@ const DuplicationControls = ({
|
|||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
userId, projectId
|
userId,
|
||||||
|
projectId
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v1:model-asset:add", data);
|
socket.emit("v1:model-asset:add", data);
|
||||||
|
|||||||
@@ -314,7 +314,8 @@ function MoveControls({
|
|||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v1:model-asset:add", data);
|
socket.emit("v1:model-asset:add", data);
|
||||||
|
|||||||
@@ -269,7 +269,8 @@ function RotateControls({
|
|||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
projectId,userId
|
projectId,
|
||||||
|
userId
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v1:model-asset:add", data);
|
socket.emit("v1:model-asset:add", data);
|
||||||
|
|||||||
@@ -131,9 +131,11 @@ export default function TransformControl() {
|
|||||||
isLocked: false,
|
isLocked: false,
|
||||||
isVisible: true,
|
isVisible: true,
|
||||||
socketId: socket.id,
|
socketId: socket.id,
|
||||||
|
userId,
|
||||||
|
projectId
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.emit("v2:model-asset:add", data);
|
socket.emit("v1:model-asset:add", data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user