Merge remote-tracking branch 'origin/merge/wall-collab' into main-dev
This commit is contained in:
@@ -216,139 +216,3 @@ const DashboardProjects: React.FC = () => {
|
|||||||
export default DashboardProjects;
|
export default DashboardProjects;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// const MyProjects = () => {
|
|
||||||
// const { projectSocket } = useSocketStore();
|
|
||||||
// const { userId, organization } = getUserData();
|
|
||||||
|
|
||||||
// const fetchAllProjects = async () => {
|
|
||||||
// try {
|
|
||||||
// const projects = await getAllProjects(userId, organization);
|
|
||||||
// if (!projects || !projects.Projects) return;
|
|
||||||
|
|
||||||
// if (JSON.stringify(projects) !== JSON.stringify(workspaceProjects)) {
|
|
||||||
// setWorkspaceProjects(projects);
|
|
||||||
// }
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Error fetching projects:", error);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// const handleDeleteProject = async (projectId: any) => {
|
|
||||||
// try {
|
|
||||||
// // const deletedProject = await deleteProject(
|
|
||||||
// // projectId,
|
|
||||||
// // userId,
|
|
||||||
// // organization
|
|
||||||
// // );
|
|
||||||
// // console.log('deletedProject: ', deletedProject);
|
|
||||||
// const deleteProjects = {
|
|
||||||
// projectId,
|
|
||||||
// organization,
|
|
||||||
// userId,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// //socket for deleting the project
|
|
||||||
// if (projectSocket) {
|
|
||||||
// projectSocket.emit("v1:project:delete", deleteProjects);
|
|
||||||
// } else {
|
|
||||||
// console.error("Socket is not connected.");
|
|
||||||
// }
|
|
||||||
// setWorkspaceProjects((prevDiscardedProjects: WorkspaceProjects) => {
|
|
||||||
// if (!Array.isArray(prevDiscardedProjects?.Projects)) {
|
|
||||||
// return prevDiscardedProjects;
|
|
||||||
// }
|
|
||||||
// const updatedProjectDatas = prevDiscardedProjects.Projects.filter(
|
|
||||||
// (project) => project._id !== projectId
|
|
||||||
// );
|
|
||||||
// return {
|
|
||||||
// ...prevDiscardedProjects,
|
|
||||||
// Projects: updatedProjectDatas,
|
|
||||||
// };
|
|
||||||
// });
|
|
||||||
// setIsSearchActive(false);
|
|
||||||
// } catch (error) {
|
|
||||||
// console.error("Error deleting project:", error);
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const handleDuplicateWorkspaceProject = async (
|
|
||||||
// projectId: string,
|
|
||||||
// projectName: string,
|
|
||||||
// thumbnail: string
|
|
||||||
// ) => {
|
|
||||||
// // await handleDuplicateProjects({
|
|
||||||
// // userId,
|
|
||||||
// // organization,
|
|
||||||
// // projectId,
|
|
||||||
// // projectName,
|
|
||||||
// // projectSocket,
|
|
||||||
// // thumbnail,
|
|
||||||
// // setWorkspaceProjects,
|
|
||||||
// // setIsSearchActive
|
|
||||||
// // });
|
|
||||||
// const duplicateProjectData = {
|
|
||||||
// userId,
|
|
||||||
// thumbnail,
|
|
||||||
// organization,
|
|
||||||
// projectUuid: projectId,
|
|
||||||
// projectName,
|
|
||||||
// };
|
|
||||||
// projectSocket.emit("v1:project:Duplicate", duplicateProjectData);
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const renderProjects = () => {
|
|
||||||
// if (activeFolder !== "myProjects") return null;
|
|
||||||
|
|
||||||
// const projectList = workspaceProjects[Object.keys(workspaceProjects)[0]];
|
|
||||||
|
|
||||||
// if (!projectList?.length) {
|
|
||||||
// return <div className="empty-state">No projects found</div>;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return projectList.map((project) => (
|
|
||||||
// <DashboardCard
|
|
||||||
// key={project._id}
|
|
||||||
// projectName={project.projectName}
|
|
||||||
// thumbnail={project.thumbnail}
|
|
||||||
// projectId={project._id}
|
|
||||||
// createdAt={project.createdAt}
|
|
||||||
// handleDeleteProject={handleDeleteProject}
|
|
||||||
// setIsSearchActive={setIsSearchActive}
|
|
||||||
// handleDuplicateWorkspaceProject={handleDuplicateWorkspaceProject}
|
|
||||||
// setProjectDuplicateData={setProjectDuplicateData}
|
|
||||||
// />
|
|
||||||
// ));
|
|
||||||
// };
|
|
||||||
|
|
||||||
// const renderSharedProjects = () => {
|
|
||||||
// if (activeFolder !== "shared") return null;
|
|
||||||
|
|
||||||
// const projectList = workspaceProjects[Object.keys(workspaceProjects)[0]];
|
|
||||||
|
|
||||||
// if (!projectList?.length) {
|
|
||||||
// return <div className="empty-state">No projects found</div>;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return projectList.map((project) => (
|
|
||||||
// <DashboardCard
|
|
||||||
// key={project._id}
|
|
||||||
// projectName={project.projectName}
|
|
||||||
// thumbnail={project.thumbnail}
|
|
||||||
// projectId={project._id}
|
|
||||||
// createdAt={project.createdAt}
|
|
||||||
// handleDeleteProject={handleDeleteProject}
|
|
||||||
// setIsSearchActive={setIsSearchActive}
|
|
||||||
// handleDuplicateWorkspaceProject={handleDuplicateWorkspaceProject}
|
|
||||||
// setProjectDuplicateData={setProjectDuplicateData}
|
|
||||||
// />
|
|
||||||
// ));
|
|
||||||
// };
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (!isSearchActive) {
|
|
||||||
// fetchAllProjects();
|
|
||||||
// }
|
|
||||||
// }, [isSearchActive]);
|
|
||||||
|
|
||||||
// return null
|
|
||||||
// }
|
|
||||||
@@ -9,7 +9,6 @@ import { useActiveUsers } from "../../store/builder/store";
|
|||||||
import { getUserData } from "../../functions/getUserData";
|
import { getUserData } from "../../functions/getUserData";
|
||||||
import { getProjectSharedList } from "../../services/factoryBuilder/collab/getProjectSharedList";
|
import { getProjectSharedList } from "../../services/factoryBuilder/collab/getProjectSharedList";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { projection } from "@turf/turf";
|
|
||||||
import { shareAccess } from "../../services/factoryBuilder/collab/shareAccess";
|
import { shareAccess } from "../../services/factoryBuilder/collab/shareAccess";
|
||||||
import { getAvatarColor } from "../../modules/collaboration/functions/getAvatarColor";
|
import { getAvatarColor } from "../../modules/collaboration/functions/getAvatarColor";
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { useProjectName } from "../../store/builder/store";
|
|||||||
import { getAllProjects } from "../../services/dashboard/getAllProjects";
|
import { getAllProjects } from "../../services/dashboard/getAllProjects";
|
||||||
import { useComparisonProduct } from "../../store/simulation/useSimulationStore";
|
import { useComparisonProduct } from "../../store/simulation/useSimulationStore";
|
||||||
import { getUserData } from "../../functions/getUserData";
|
import { getUserData } from "../../functions/getUserData";
|
||||||
import { recentlyViewed } from "../../services/dashboard/recentlyViewed";
|
|
||||||
import { sharedWithMeProjects } from "../../services/dashboard/sharedWithMeProject";
|
import { sharedWithMeProjects } from "../../services/dashboard/sharedWithMeProject";
|
||||||
|
|
||||||
interface LoadingPageProps {
|
interface LoadingPageProps {
|
||||||
@@ -20,23 +19,6 @@ const LoadingPage: React.FC<LoadingPageProps> = ({ progress }) => {
|
|||||||
const { userId, organization } = getUserData();
|
const { userId, organization } = getUserData();
|
||||||
|
|
||||||
const validatedProgress = Math.min(100, Math.max(0, progress));
|
const validatedProgress = Math.min(100, Math.max(0, progress));
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (!userId) return;
|
|
||||||
|
|
||||||
|
|
||||||
// // getAllProjects(userId, organization).then((projects) => {
|
|
||||||
// // sharedWithMeProjects().then((shared) => {
|
|
||||||
// // console.log('filterProject: ', shared);
|
|
||||||
// // const filterProject = (projects?.Projects || shared)?.find((val: any) => val.projectUuid === projectId || val._id === projectId)
|
|
||||||
// // console.log('filterProject: ', filterProject);
|
|
||||||
// // // setProjectName(filterProject?.projectName)
|
|
||||||
|
|
||||||
// // })
|
|
||||||
// // }).catch(() => {
|
|
||||||
// // console.error("Error fetching projects")
|
|
||||||
// // })
|
|
||||||
// }, []);
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!userId) {
|
if (!userId) {
|
||||||
console.error("User data not found in localStorage");
|
console.error("User data not found in localStorage");
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import useLayoutStore from "../../store/builder/uselayoutStore";
|
import useLayoutStore from "../../store/builder/uselayoutStore";
|
||||||
import { useDfxUpload } from "../../store/builder/store";
|
import { useActiveLayer, useDfxUpload } from "../../store/builder/store";
|
||||||
import DxfParser from "dxf-parser";
|
import DxfParser from "dxf-parser";
|
||||||
import { getWallPointsFromBlueprint } from "../../modules/builder/dfx/functions/getWallPointsFromBlueprint";
|
import { getWallPointsFromBlueprint } from "../../modules/builder/dfx/functions/getWallPointsFromBlueprint";
|
||||||
import { convertDXFToThree } from "../../modules/builder/dfx/functions/convertDxfToThree";
|
import { convertDXFToThree } from "../../modules/builder/dfx/functions/convertDxfToThree";
|
||||||
import { AIIcon } from "../icons/ExportCommonIcons";
|
import { AIIcon } from "../icons/ExportCommonIcons";
|
||||||
|
import { useBuilderStore } from "../../store/builder/useBuilderStore";
|
||||||
|
import { useSceneContext } from "../../modules/scene/sceneContext";
|
||||||
type DXFData = any;
|
type DXFData = any;
|
||||||
const SelectFloorPlan: React.FC = () => {
|
const SelectFloorPlan: React.FC = () => {
|
||||||
// Access layout state and state setters
|
// Access layout state and state setters
|
||||||
const { currentLayout, setLayout } = useLayoutStore();
|
const { currentLayout, setLayout } = useLayoutStore();
|
||||||
// Access DXF-related states and setters
|
// Access DXF-related states and setters
|
||||||
const { setDfxUploaded, setDfxGenerate, setObjValue, objValue } =
|
const { setDfxUploaded, setDxfWallGenerate, setObjValue, objValue } =
|
||||||
useDfxUpload();
|
useDfxUpload();
|
||||||
|
const { activeLayer } = useActiveLayer();
|
||||||
|
const { wallThickness, wallHeight, insideMaterial, outsideMaterial } = useBuilderStore();
|
||||||
|
const { wallStore } = useSceneContext();
|
||||||
|
const { addWall } = wallStore();
|
||||||
// Local state to store the parsed DXF file
|
// Local state to store the parsed DXF file
|
||||||
const [parsedFile, setParsedFile] = useState<DXFData | undefined>(undefined);
|
const [parsedFile, setParsedFile] = useState<DXFData | undefined>(undefined);
|
||||||
|
const { walls } = wallStore();
|
||||||
// Flag to trigger generation after file upload
|
// Flag to trigger generation after file upload
|
||||||
const [generate, setGenerate] = useState<boolean>(false);
|
const [generate, setGenerate] = useState<boolean>(false);
|
||||||
|
|
||||||
@@ -58,8 +63,9 @@ const SelectFloorPlan: React.FC = () => {
|
|||||||
if (parsedFile !== undefined) {
|
if (parsedFile !== undefined) {
|
||||||
getWallPointsFromBlueprint({
|
getWallPointsFromBlueprint({
|
||||||
parsedData: parsedFile,
|
parsedData: parsedFile,
|
||||||
setDfxGenerate,
|
setDxfWallGenerate,
|
||||||
objValue,
|
objValue,
|
||||||
|
wallThickness, wallHeight, outsideMaterial, insideMaterial, activeLayer, addWall, walls
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [generate]);
|
}, [generate]);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { getSearchUsers } from "../../../services/factoryBuilder/collab/getSearchUsers";
|
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
|
|
||||||
|
import { getSearchUsers } from "../../../services/factoryBuilder/collab/getSearchUsers";
|
||||||
import { shareProject } from "../../../services/factoryBuilder/collab/shareProject";
|
import { shareProject } from "../../../services/factoryBuilder/collab/shareProject";
|
||||||
import { getUserData } from "../../../functions/getUserData";
|
import { getUserData } from "../../../functions/getUserData";
|
||||||
|
|
||||||
@@ -11,59 +12,61 @@ interface UserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface MultiEmailProps {
|
interface MultiEmailProps {
|
||||||
users: any,
|
users: Array<any>;
|
||||||
getData: any,
|
getData: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MultiEmailInvite: React.FC<MultiEmailProps> = ({ users, getData }) => {
|
const MultiEmailInvite: React.FC<MultiEmailProps> = ({ users, getData }) => {
|
||||||
const [emails, setEmails] = useState<any>([]);
|
const [selectedUsers, setSelectedUsers] = useState<UserData[]>([]);
|
||||||
const [searchedEmail, setSearchedEmail] = useState<UserData[]>([]);
|
const [searchResults, setSearchResults] = useState<UserData[]>([]);
|
||||||
const [inputFocus, setInputFocus] = useState(false);
|
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
const [isFocused, setIsFocused] = useState(false);
|
||||||
|
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
const { userId } = getUserData();
|
const { userId } = getUserData();
|
||||||
|
|
||||||
const handleAddEmail = async (selectedUser: UserData) => {
|
|
||||||
if (!projectId || !selectedUser) return
|
|
||||||
const trimmedEmail = inputValue.trim();
|
|
||||||
setEmails((prev: any[]) => {
|
|
||||||
if (!selectedUser) return prev;
|
|
||||||
const isNotCurrentUser = selectedUser._id !== userId;
|
|
||||||
const alreadyExistsInEmails = prev.some(email => email._id === selectedUser._id);
|
|
||||||
const alreadyExistsInUsers = users.some((val: any) => val.userId === selectedUser._id);
|
|
||||||
if (isNotCurrentUser && !alreadyExistsInEmails && !alreadyExistsInUsers) {
|
|
||||||
return [...prev, selectedUser];
|
|
||||||
}
|
|
||||||
|
|
||||||
return prev;
|
const handleSearchInput = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
});
|
const value = e.target.value.trim();
|
||||||
setInputValue(""); // Clear the input field after adding
|
setInputValue(value);
|
||||||
};
|
|
||||||
const handleSearchMail = async (e: any) => {
|
if (value.length < 3) return;
|
||||||
setInputValue(e.target.value);
|
|
||||||
const trimmedEmail = e.target.value.trim();
|
|
||||||
|
|
||||||
if (trimmedEmail.length < 3) return;
|
|
||||||
try {
|
try {
|
||||||
const searchedMail = await getSearchUsers(trimmedEmail);
|
const result = await getSearchUsers(value);
|
||||||
const filteredEmail = searchedMail.sharchMail?.filtered;
|
const filtered = result?.sharchMail?.filtered || [];
|
||||||
if (filteredEmail) {
|
setSearchResults(filtered);
|
||||||
setSearchedEmail(filteredEmail)
|
} catch (err) {
|
||||||
}
|
console.error("Search failed:", err);
|
||||||
} catch (error) {
|
|
||||||
console.error("Failed to search mail:", error);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleAddUser = (user: UserData) => {
|
||||||
|
if (!user || user._id === userId) return;
|
||||||
|
|
||||||
const handleKeyDown = async (e: React.KeyboardEvent<HTMLInputElement>) => {
|
const isAlreadySelected = selectedUsers.some(u => u._id === user._id);
|
||||||
if (e.key === "Enter" || e.key === "," && searchedEmail.length > 0) {
|
const isAlreadyShared = users.some(u => u.userId === user._id);
|
||||||
e.preventDefault();
|
|
||||||
handleAddEmail(searchedEmail[0]);
|
if (!isAlreadySelected && !isAlreadyShared) {
|
||||||
|
setSelectedUsers(prev => [...prev, user]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setInputValue("");
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
if ((e.key === "Enter" || e.key === ",") && searchResults.length > 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
handleAddUser(searchResults[0]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleRemoveUser = (userIdToRemove: string) => {
|
||||||
|
setSelectedUsers(prev => prev.filter(user => user._id !== userIdToRemove));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveEmail = (idToRemove: string) => {
|
const handleRemoveEmail = (idToRemove: string) => {
|
||||||
setEmails((prev: any) => prev.filter((email: any) => email._id !== idToRemove));
|
setSelectedUsers((prev: any) => prev.filter((email: any) => email._id !== idToRemove));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -72,60 +75,62 @@ const MultiEmailInvite: React.FC<MultiEmailProps> = ({ users, getData }) => {
|
|||||||
return emailRegex.test(email);
|
return emailRegex.test(email);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInvite = () => {
|
const handleAddEmail = async () => {
|
||||||
if (!projectId) return;
|
if (!projectId) return;
|
||||||
try {
|
|
||||||
emails.forEach((user: any) => {
|
|
||||||
shareProject(user._id, projectId)
|
|
||||||
.then((res) => {
|
|
||||||
console.log("sharedProject:", res);
|
|
||||||
|
|
||||||
})
|
try {
|
||||||
.catch((err) => {
|
await Promise.all(
|
||||||
console.error("Error sharing project:", err);
|
selectedUsers.map(user =>
|
||||||
});
|
shareProject(user._id, projectId)
|
||||||
setEmails([])
|
.then(res => console.log("Shared:", res))
|
||||||
setInputValue("")
|
.catch(err => console.error("Share error:", err))
|
||||||
});
|
)
|
||||||
setTimeout(() => {
|
);
|
||||||
getData()
|
|
||||||
}, 1000);
|
setSelectedUsers([]);
|
||||||
|
setInputValue("");
|
||||||
|
setTimeout(getData, 1000);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("General error:", error);
|
console.error("Invite error:", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="multi-email-invite-input-container">
|
<div className="multi-email-invite-input-container">
|
||||||
<div className={`multi-email-invite-input${inputFocus ? " active" : ""}`}>
|
<div className={`multi-email-invite-input${isFocused ? " active" : ""}`}>
|
||||||
{emails.map((email: any, index: number) => (
|
{selectedUsers.map(user => (
|
||||||
<div key={index} className="entered-emails">
|
<div key={user._id} className="entered-emails">
|
||||||
{email.Email}
|
{user.Email}
|
||||||
<span onClick={() => handleRemoveEmail(email._id)}>×</span>
|
<span onClick={() => handleRemoveUser(user._id)}>×</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
value={inputValue}
|
value={inputValue}
|
||||||
onChange={(e) => handleSearchMail(e)}
|
onChange={handleSearchInput}
|
||||||
onFocus={() => setInputFocus(true)}
|
onFocus={() => setIsFocused(true)}
|
||||||
// onBlur={() => setInputFocus(false)}
|
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
placeholder="Enter email and press Enter or comma to seperate"
|
placeholder="Enter email and press Enter or comma"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div onClick={handleInvite} className="invite-button">
|
|
||||||
|
<div onClick={handleAddEmail} className="invite-button">
|
||||||
Add
|
Add
|
||||||
</div>
|
</div>
|
||||||
{inputFocus && inputValue.length > 2 && searchedEmail && searchedEmail.length > 0 && (
|
|
||||||
|
{isFocused && inputValue.length > 2 && searchResults.length > 0 && (
|
||||||
<div className="users-list-container">
|
<div className="users-list-container">
|
||||||
{/* list available users here */}
|
{searchResults.map(user => (
|
||||||
{searchedEmail.map((val: any, i: any) => (
|
<div
|
||||||
<div onClick={(e) => {
|
key={user._id}
|
||||||
handleAddEmail(val)
|
onClick={() => {
|
||||||
setInputFocus(false)
|
handleAddUser(user);
|
||||||
}} key={i} >
|
setIsFocused(false);
|
||||||
{val?.Email}
|
}}
|
||||||
|
>
|
||||||
|
{user.Email}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -134,4 +139,5 @@ const MultiEmailInvite: React.FC<MultiEmailProps> = ({ users, getData }) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MultiEmailInvite;
|
|
||||||
|
export default MultiEmailInvite;
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEffect, useRef } from 'react';
|
import { useEffect, useRef } from 'react';
|
||||||
import { useDfxUpload, useSocketStore, useToggleView, useUpdateScene } from '../../../store/builder/store';
|
import { useActiveLayer, useDfxUpload, useSocketStore, useToggleView, useUpdateScene } from '../../../store/builder/store';
|
||||||
import { LineBasicMaterial, Line } from 'three';
|
import { LineBasicMaterial, Line } from 'three';
|
||||||
import { TransformControls } from '@react-three/drei';
|
import { TransformControls } from '@react-three/drei';
|
||||||
import { getWallPointsFromBlueprint } from './functions/getWallPointsFromBlueprint';
|
import { getWallPointsFromBlueprint } from './functions/getWallPointsFromBlueprint';
|
||||||
@@ -7,6 +7,8 @@ import * as Types from '../../../types/world/worldTypes';
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { getUserData } from '../../../functions/getUserData';
|
import { getUserData } from '../../../functions/getUserData';
|
||||||
import { useVersionContext } from '../version/versionContext';
|
import { useVersionContext } from '../version/versionContext';
|
||||||
|
import { useBuilderStore } from '../../../store/builder/useBuilderStore';
|
||||||
|
import { useSceneContext } from '../../scene/sceneContext';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DxfFile component handles the rendering and manipulation of DXf file data in a 3D scene.
|
* DxfFile component handles the rendering and manipulation of DXf file data in a 3D scene.
|
||||||
@@ -15,48 +17,44 @@ import { useVersionContext } from '../version/versionContext';
|
|||||||
*/
|
*/
|
||||||
const DxfFile = () => {
|
const DxfFile = () => {
|
||||||
// State management hooks
|
// State management hooks
|
||||||
const { dfxuploaded, dfxWallGenerate, setObjValue, objValue } = useDfxUpload();
|
const { dfxuploaded, dfxWallGenerate, setObjValue, objValue, setDfxUploaded } = useDfxUpload();
|
||||||
const { toggleView } = useToggleView();
|
const { toggleView } = useToggleView();
|
||||||
const { socket } = useSocketStore();
|
const { socket } = useSocketStore();
|
||||||
const { selectedVersionStore } = useVersionContext();
|
const { selectedVersionStore } = useVersionContext();
|
||||||
const { selectedVersion } = selectedVersionStore();
|
const { selectedVersion } = selectedVersionStore();
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
const { userId, organization } = getUserData();
|
const { userId, organization } = getUserData();
|
||||||
|
const { activeLayer } = useActiveLayer();
|
||||||
|
const { wallThickness, wallHeight, insideMaterial, outsideMaterial, } = useBuilderStore();
|
||||||
// Refs for storing line objects
|
// Refs for storing line objects
|
||||||
const lineRefs = useRef<Line[]>([]);
|
const lineRefs = useRef<Line[]>([]);
|
||||||
|
const { wallStore } = useSceneContext();
|
||||||
|
const { addWall, } = wallStore();
|
||||||
|
const { walls } = wallStore();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effect hook that runs when DXF wall generation is triggered.
|
* Effect hook that runs when DXF wall generation is triggered.
|
||||||
* Loads initial points and lines from the DXF data and updates the scene.
|
* Loads initial points and lines from the DXF data and updates the scene.
|
||||||
*/
|
*/
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
if (dfxWallGenerate) {
|
if (dfxWallGenerate) {
|
||||||
// Store generated lines in ref
|
dfxWallGenerate.map((wall: Wall) => {
|
||||||
// lines.current.push(...dfxWallGenerate);
|
const data = {
|
||||||
// dfxWallGenerate.map((line: any) => {
|
wallData: wall,
|
||||||
// const lineData = arrayLineToObject(line as Types.Line);
|
projectId: projectId,
|
||||||
|
versionId: selectedVersion?.versionId || '',
|
||||||
|
userId: userId,
|
||||||
|
organization: organization
|
||||||
|
}
|
||||||
|
addWall(wall);
|
||||||
|
socket.emit('v1:model-Wall:add', data);
|
||||||
|
// API
|
||||||
|
|
||||||
// //REST
|
// if (projectId) {
|
||||||
|
// upsertWallApi(projectId, selectedVersion?.versionId || '', wall);
|
||||||
// // setLine(organization, lineData.layer!, lineData.line!, lineData.type!);
|
// }
|
||||||
|
})
|
||||||
// //SOCKET
|
|
||||||
|
|
||||||
// const input = {
|
|
||||||
// organization,
|
|
||||||
// layer: lineData.layer,
|
|
||||||
// line: lineData.line,
|
|
||||||
// type: lineData.type,
|
|
||||||
// socketId: socket.id,
|
|
||||||
// versionId: selectedVersion?.versionId || '',
|
|
||||||
// projectId,
|
|
||||||
// userId
|
|
||||||
// }
|
|
||||||
|
|
||||||
// socket.emit('v1:Line:create', input);
|
|
||||||
|
|
||||||
// })
|
|
||||||
}
|
}
|
||||||
}, [dfxWallGenerate]);
|
}, [dfxWallGenerate]);
|
||||||
|
|
||||||
@@ -78,10 +76,15 @@ const DxfFile = () => {
|
|||||||
// Recalculate wall points based on new position
|
// Recalculate wall points based on new position
|
||||||
getWallPointsFromBlueprint({
|
getWallPointsFromBlueprint({
|
||||||
objValue: { x: position.x, y: position.y, z: position.z },
|
objValue: { x: position.x, y: position.y, z: position.z },
|
||||||
setDfxGenerate: () => { },
|
setDxfWallGenerate: () => { },
|
||||||
|
wallThickness, wallHeight, outsideMaterial, insideMaterial, activeLayer, addWall, walls
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
if (!toggleView) {
|
||||||
|
setDfxUploaded([])
|
||||||
|
}
|
||||||
|
}, [toggleView])
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* Render DXF lines with transform controls when DXF data is available and view is toggled */}
|
{/* Render DXF lines with transform controls when DXF data is available and view is toggled */}
|
||||||
|
|||||||
@@ -1,11 +1,21 @@
|
|||||||
import { MathUtils, Vector3, BufferGeometry } from "three";
|
import { MathUtils, Vector3, BufferGeometry } from "three";
|
||||||
|
import { useActiveLayer } from "../../../../store/builder/store";
|
||||||
|
import { useBuilderStore } from "../../../../store/builder/useBuilderStore";
|
||||||
|
import { wait } from "@testing-library/user-event/dist/utils";
|
||||||
type DXFData = any; // Replace with actual DXF data type
|
type DXFData = any; // Replace with actual DXF data type
|
||||||
type DXFEntity = any; // Replace with actual DXF entity type
|
type DXFEntity = any; // Replace with actual DXF entity type
|
||||||
type WallLineVertex = [Vector3, string, number, string]; // Represents a wall segment with start point, ID, weight, and type
|
type WallLineVertex = [Vector3, string, number, string]; // Represents a wall segment with start point, ID, weight, and type
|
||||||
interface Props {
|
interface Props {
|
||||||
parsedData?: DXFData; // Parsed DXF file data
|
parsedData?: DXFData; // Parsed DXF file data
|
||||||
setDfxGenerate?: (walls: WallLineVertex[][]) => void; // Callback to set generated walls
|
setDxfWallGenerate?: any; // Callback to set generated walls
|
||||||
objValue: any; // Object position values for offset calculation
|
objValue: any; // Object position values for offset calculation
|
||||||
|
wallThickness: number;
|
||||||
|
wallHeight: number;
|
||||||
|
outsideMaterial: string;
|
||||||
|
insideMaterial: string;
|
||||||
|
activeLayer: number; // Active layer for wall points
|
||||||
|
addWall: (wall: Wall) => void; // Function to add a wall to the scene
|
||||||
|
walls: Wall[]; // Array of walls to be processed
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -15,20 +25,36 @@ interface Props {
|
|||||||
*
|
*
|
||||||
* @param {Props} params - Configuration parameters
|
* @param {Props} params - Configuration parameters
|
||||||
* @param {DXFData} params.parsedData - Parsed DXF file data
|
* @param {DXFData} params.parsedData - Parsed DXF file data
|
||||||
* @param {Function} params.setDfxGenerate - Callback to store generated walls
|
* @param {Function} params.setDxfWallGenerate - Callback to store generated walls
|
||||||
* @param {Object} params.objValue - Contains x,y,z offsets for position adjustment
|
* @param {Object} params.objValue - Contains x,y,z offsets for position adjustment
|
||||||
*/
|
*/
|
||||||
export function getWallPointsFromBlueprint({
|
export function getWallPointsFromBlueprint({
|
||||||
parsedData,
|
parsedData,
|
||||||
setDfxGenerate,
|
setDxfWallGenerate,
|
||||||
objValue,
|
objValue,
|
||||||
|
wallThickness,
|
||||||
|
wallHeight,
|
||||||
|
outsideMaterial,
|
||||||
|
insideMaterial,
|
||||||
|
activeLayer,
|
||||||
|
addWall,
|
||||||
|
walls,
|
||||||
}: Props) {
|
}: Props) {
|
||||||
// Early return if no data is provided
|
// Early return if no data is provided
|
||||||
if (!parsedData) return;
|
if (!parsedData) return;
|
||||||
if (!parsedData.entities) return;
|
if (!parsedData.entities) return;
|
||||||
|
|
||||||
const unit = 1000; // Conversion factor from millimeters to meters
|
const unit = 1000; // Conversion factor from millimeters to meters
|
||||||
const wallVertex: WallLineVertex[][] = []; // Stores all generated wall segments
|
const wallVertex: any[] = []; // Array to store wall vertices
|
||||||
|
const findExistingPoint = (vec: Vector3): Point | undefined => {
|
||||||
|
for (const wall of wallVertex) {
|
||||||
|
for (const pt of wall.points) {
|
||||||
|
const pos = new Vector3(...pt.position);
|
||||||
|
if (pos.equals(vec)) return pt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
};
|
||||||
|
|
||||||
// Process each entity in the DXF file
|
// Process each entity in the DXF file
|
||||||
parsedData.entities.forEach((entity: DXFEntity) => {
|
parsedData.entities.forEach((entity: DXFEntity) => {
|
||||||
@@ -47,31 +73,41 @@ export function getWallPointsFromBlueprint({
|
|||||||
-entity.vertices[1].y / unit
|
-entity.vertices[1].y / unit
|
||||||
).add(new Vector3(objValue.x, 0, objValue.z));
|
).add(new Vector3(objValue.x, 0, objValue.z));
|
||||||
|
|
||||||
// Check if points already exist to avoid duplicates
|
// Create start and end points
|
||||||
const existingStart = wallVertex
|
const existingStart = findExistingPoint(startVec);
|
||||||
.flat()
|
const startPoint: Point = existingStart || {
|
||||||
.find((v) => v[0].equals(startVec));
|
pointUuid: MathUtils.generateUUID(),
|
||||||
const startPoint: WallLineVertex = existingStart || [
|
pointType: "Wall",
|
||||||
startVec,
|
position: [startVec.x, startVec.y, startVec.z],
|
||||||
MathUtils.generateUUID(), // Generate unique ID for new points
|
layer: activeLayer,
|
||||||
1, // Default weight
|
};
|
||||||
"WallLine", // Type identifier
|
|
||||||
];
|
|
||||||
|
|
||||||
const existingEnd = wallVertex.flat().find((v) => v[0].equals(endVec));
|
const existingEnd = findExistingPoint(endVec);
|
||||||
const endPoint: WallLineVertex = existingEnd || [
|
const endPoint: Point = existingEnd || {
|
||||||
endVec,
|
pointUuid: MathUtils.generateUUID(),
|
||||||
MathUtils.generateUUID(),
|
pointType: "Wall",
|
||||||
1,
|
position: [endVec.x, endVec.y, endVec.z],
|
||||||
"WallLine",
|
layer: activeLayer,
|
||||||
];
|
};
|
||||||
|
|
||||||
// Add the line segment to our collection
|
// Create the wall
|
||||||
wallVertex.push([startPoint, endPoint]);
|
const wallSet: Wall = {
|
||||||
|
wallUuid: MathUtils.generateUUID(),
|
||||||
|
points: [startPoint, endPoint], // Store start and end points
|
||||||
|
outsideMaterial: insideMaterial,
|
||||||
|
insideMaterial: outsideMaterial,
|
||||||
|
wallThickness: wallThickness,
|
||||||
|
wallHeight: wallHeight,
|
||||||
|
decals: [],
|
||||||
|
};
|
||||||
|
wallVertex.push(wallSet); // Store wall segment in array
|
||||||
|
// Add the wall to the scene
|
||||||
|
// addWall(wallSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle LWPOLYLINE entities (connected line segments)
|
// Handle LWPOLYLINE entities (connected line segments)
|
||||||
else if (entity.type === "LWPOLYLINE" && entity.vertices) {
|
else if (entity.type === "LWPOLYLINE" && entity.vertices) {
|
||||||
let firstPoint: WallLineVertex | undefined; // Store first point for closing the polyline
|
let firstPoint: Point | undefined; // Store first point for closing the polyline
|
||||||
|
|
||||||
// Process each vertex pair in the polyline
|
// Process each vertex pair in the polyline
|
||||||
for (let i = 0; i < entity.vertices.length - 1; i++) {
|
for (let i = 0; i < entity.vertices.length - 1; i++) {
|
||||||
@@ -88,37 +124,60 @@ export function getWallPointsFromBlueprint({
|
|||||||
-entity.vertices[i + 1].y / unit
|
-entity.vertices[i + 1].y / unit
|
||||||
).add(new Vector3(objValue.x, 0, objValue.z));
|
).add(new Vector3(objValue.x, 0, objValue.z));
|
||||||
|
|
||||||
// Check for existing points
|
// Create start and end points
|
||||||
const existingStart = wallVertex
|
const existingStart = findExistingPoint(startVec);
|
||||||
.flat()
|
const startPoint: Point = existingStart || {
|
||||||
.find((v) => v[0].equals(startVec));
|
pointUuid: MathUtils.generateUUID(), // Generate unique ID for new points
|
||||||
const startPoint: WallLineVertex = existingStart || [
|
pointType: "Wall", // Type identifier
|
||||||
startVec,
|
position: [startVec.x, startVec.y, startVec.z], // Position in 3D space
|
||||||
MathUtils.generateUUID(),
|
layer: activeLayer,
|
||||||
1,
|
};
|
||||||
"WallLine",
|
|
||||||
];
|
|
||||||
|
|
||||||
const existingEnd = wallVertex.flat().find((v) => v[0].equals(endVec));
|
const existingEnd = findExistingPoint(endVec);
|
||||||
const endPoint: WallLineVertex = existingEnd || [
|
const endPoint: Point = existingEnd || {
|
||||||
endVec,
|
pointUuid: MathUtils.generateUUID(), // Generate unique ID for new points
|
||||||
MathUtils.generateUUID(),
|
pointType: "Wall", // Type identifier
|
||||||
1,
|
position: [endVec.x, endVec.y, endVec.z], // Position in 3D space
|
||||||
"WallLine",
|
layer: activeLayer,
|
||||||
];
|
};
|
||||||
|
|
||||||
wallVertex.push([startPoint, endPoint]);
|
// Create the wall segment
|
||||||
|
const wallSet: Wall = {
|
||||||
|
wallUuid: MathUtils.generateUUID(),
|
||||||
|
points: [startPoint, endPoint], // Store start and end points
|
||||||
|
outsideMaterial: insideMaterial,
|
||||||
|
insideMaterial: outsideMaterial,
|
||||||
|
wallThickness: wallThickness,
|
||||||
|
wallHeight: wallHeight,
|
||||||
|
decals: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add the wall segment
|
||||||
|
// addWall(wallSet);
|
||||||
|
wallVertex.push(wallSet);
|
||||||
// Store first point and create closing segment if this is the last vertex
|
// Store first point and create closing segment if this is the last vertex
|
||||||
if (i === 0) firstPoint = startPoint;
|
if (i === 0) firstPoint = startPoint;
|
||||||
if (i === entity.vertices.length - 2 && firstPoint) {
|
if (i === entity.vertices.length - 2 && firstPoint) {
|
||||||
wallVertex.push([endPoint, firstPoint]);
|
const closingWallSet: Wall = {
|
||||||
|
wallUuid: MathUtils.generateUUID(),
|
||||||
|
points: [endPoint, firstPoint], // Create closing segment
|
||||||
|
outsideMaterial: insideMaterial,
|
||||||
|
insideMaterial: outsideMaterial,
|
||||||
|
wallThickness: wallThickness,
|
||||||
|
wallHeight: wallHeight,
|
||||||
|
decals: [],
|
||||||
|
};
|
||||||
|
// Add the closing wall
|
||||||
|
wallVertex.push(closingWallSet);
|
||||||
|
// addWall(closingWallSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle ARC entities
|
// Handle ARC entities
|
||||||
else if (entity.type === "ARC") {
|
else if (entity.type === "ARC") {
|
||||||
const { center, radius, startAngle, endAngle } = entity;
|
const { center, radius, startAngle, endAngle } = entity;
|
||||||
|
|
||||||
// Validate required ARC properties
|
// Validate required ARC properties
|
||||||
if (
|
if (
|
||||||
!center ||
|
!center ||
|
||||||
@@ -154,34 +213,46 @@ export function getWallPointsFromBlueprint({
|
|||||||
const startVec = arcPoints[i];
|
const startVec = arcPoints[i];
|
||||||
const endVec = arcPoints[i + 1];
|
const endVec = arcPoints[i + 1];
|
||||||
|
|
||||||
// Check for existing points
|
// Create start and end points
|
||||||
const existingStart = wallVertex
|
const existingStart = findExistingPoint(startVec);
|
||||||
.flat()
|
const startPoint: Point = existingStart || {
|
||||||
.find((v) => v[0].equals(startVec));
|
pointUuid: MathUtils.generateUUID(),
|
||||||
const startPoint: WallLineVertex = existingStart || [
|
pointType: "Wall",
|
||||||
startVec,
|
position: [startVec.x, startVec.y, startVec.z],
|
||||||
MathUtils.generateUUID(),
|
layer: activeLayer,
|
||||||
1,
|
};
|
||||||
"WallLine",
|
|
||||||
];
|
|
||||||
|
|
||||||
const existingEnd = wallVertex.flat().find((v) => v[0].equals(endVec));
|
const existingEnd = findExistingPoint(endVec);
|
||||||
const endPoint: WallLineVertex = existingEnd || [
|
const endPoint: Point = existingEnd || {
|
||||||
endVec,
|
pointUuid: MathUtils.generateUUID(),
|
||||||
MathUtils.generateUUID(),
|
pointType: "Wall",
|
||||||
1,
|
position: [endVec.x, endVec.y, endVec.z],
|
||||||
"WallLine",
|
layer: activeLayer,
|
||||||
];
|
};
|
||||||
|
|
||||||
wallVertex.push([startPoint, endPoint]);
|
// Create the wall segment
|
||||||
|
const wallSet: Wall = {
|
||||||
|
wallUuid: MathUtils.generateUUID(),
|
||||||
|
points: [startPoint, endPoint],
|
||||||
|
outsideMaterial: insideMaterial,
|
||||||
|
insideMaterial: outsideMaterial,
|
||||||
|
wallThickness: wallThickness,
|
||||||
|
wallHeight: wallHeight,
|
||||||
|
decals: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
// Add the wall segment
|
||||||
|
// addWall(wallSet);
|
||||||
|
wallVertex.push(wallSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Log unsupported entity types
|
// Log unsupported entity types
|
||||||
else {
|
else {
|
||||||
console.error("Unsupported entity type:", entity.type);
|
console.error("Unsupported entity type:", entity.type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
console.log("wallVertex: ", wallVertex);
|
||||||
// Return the generated walls through callback if provided
|
// Return the generated walls through callback if provided
|
||||||
setDfxGenerate && setDfxGenerate(wallVertex);
|
setDxfWallGenerate && setDxfWallGenerate(wallVertex);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ function WallCreator() {
|
|||||||
|
|
||||||
if (wallIntersect && !pointIntersects) {
|
if (wallIntersect && !pointIntersects) {
|
||||||
const wall = getWallByPoints(wallIntersect.object.userData.points);
|
const wall = getWallByPoints(wallIntersect.object.userData.points);
|
||||||
|
console.log('wall: ', wall);
|
||||||
if (wall) {
|
if (wall) {
|
||||||
const ThroughPoint = wallIntersect.object.userData.path.getPoints(Constants.lineConfig.lineIntersectionPoints);
|
const ThroughPoint = wallIntersect.object.userData.path.getPoints(Constants.lineConfig.lineIntersectionPoints);
|
||||||
let intersectionPoint = getClosestIntersection(ThroughPoint, wallIntersect.point);
|
let intersectionPoint = getClosestIntersection(ThroughPoint, wallIntersect.point);
|
||||||
@@ -294,7 +295,9 @@ function WallCreator() {
|
|||||||
position: [position.x, position.y, position.z],
|
position: [position.x, position.y, position.z],
|
||||||
layer: activeLayer
|
layer: activeLayer
|
||||||
};
|
};
|
||||||
|
console.log('newPoint: ', newPoint);
|
||||||
|
|
||||||
|
console.log('snappedPoint: ', snappedPoint);
|
||||||
if (snappedPosition && snappedPoint) {
|
if (snappedPosition && snappedPoint) {
|
||||||
newPoint.pointUuid = snappedPoint.pointUuid;
|
newPoint.pointUuid = snappedPoint.pointUuid;
|
||||||
newPoint.position = snappedPosition;
|
newPoint.position = snappedPosition;
|
||||||
@@ -316,6 +319,7 @@ function WallCreator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('tempPoints: ', tempPoints);
|
||||||
if (tempPoints.length === 0) {
|
if (tempPoints.length === 0) {
|
||||||
setTempPoints([newPoint]);
|
setTempPoints([newPoint]);
|
||||||
setIsCreating(true);
|
setIsCreating(true);
|
||||||
@@ -330,6 +334,7 @@ function WallCreator() {
|
|||||||
decals: []
|
decals: []
|
||||||
};
|
};
|
||||||
addWall(wall);
|
addWall(wall);
|
||||||
|
console.log('wall: ', wall);
|
||||||
|
|
||||||
// API
|
// API
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,12 @@ interface PolygonGeneratorProps {
|
|||||||
export default function PolygonGenerator({
|
export default function PolygonGenerator({
|
||||||
groupRef,
|
groupRef,
|
||||||
}: PolygonGeneratorProps) {
|
}: PolygonGeneratorProps) {
|
||||||
const { aisleStore } = useSceneContext();
|
const { aisleStore, wallStore } = useSceneContext();
|
||||||
const { aisles } = aisleStore();
|
const { aisles } = aisleStore();
|
||||||
const { scene } = useThree();
|
const { scene } = useThree();
|
||||||
|
const { walls } = wallStore();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// let allLines = arrayLinesToObject(lines.current);
|
|
||||||
// const wallLines = allLines?.filter((line) => line?.type === "WallLine");
|
|
||||||
const result = aisles
|
const result = aisles
|
||||||
.filter(
|
.filter(
|
||||||
(aisle) =>
|
(aisle) =>
|
||||||
@@ -61,9 +60,12 @@ export default function PolygonGenerator({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// const wallPoints = wallLines
|
|
||||||
// .map((pair) => pair?.line.map((vals) => vals.position))
|
const wallPoints: THREE.Vector3[][] = walls
|
||||||
// .filter((wall): wall is THREE.Vector3[] => !!wall);
|
.map((wall) =>
|
||||||
|
wall.points.map((pt) => new THREE.Vector3(pt.position[0], pt.position[1], pt.position[2]))
|
||||||
|
)
|
||||||
|
.filter(points => points.length === 2);
|
||||||
|
|
||||||
|
|
||||||
if (!result || result.some((line) => !line)) {
|
if (!result || result.some((line) => !line)) {
|
||||||
@@ -81,7 +83,7 @@ export default function PolygonGenerator({
|
|||||||
|
|
||||||
const polygons = turf.polygonize(turf.featureCollection(validLineFeatures));
|
const polygons = turf.polygonize(turf.featureCollection(validLineFeatures));
|
||||||
|
|
||||||
// renderWallGeometry(wallPoints);
|
renderWallGeometry(wallPoints);
|
||||||
|
|
||||||
if (polygons.features.length > 0) {
|
if (polygons.features.length > 0) {
|
||||||
polygons.features.forEach((feature) => {
|
polygons.features.forEach((feature) => {
|
||||||
@@ -116,7 +118,7 @@ export default function PolygonGenerator({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [ aisles, scene]);
|
}, [aisles, scene, walls]);
|
||||||
|
|
||||||
const renderWallGeometry = (walls: THREE.Vector3[][]) => {
|
const renderWallGeometry = (walls: THREE.Vector3[][]) => {
|
||||||
walls.forEach((wall) => {
|
walls.forEach((wall) => {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import { SceneProvider } from "../modules/scene/sceneContext";
|
|||||||
import { getVersionHistoryApi } from "../services/factoryBuilder/versionControl/getVersionHistoryApi";
|
import { getVersionHistoryApi } from "../services/factoryBuilder/versionControl/getVersionHistoryApi";
|
||||||
import { useVersionHistoryStore } from "../store/builder/useVersionHistoryStore";
|
import { useVersionHistoryStore } from "../store/builder/useVersionHistoryStore";
|
||||||
import { VersionProvider } from "../modules/builder/version/versionContext";
|
import { VersionProvider } from "../modules/builder/version/versionContext";
|
||||||
import { recentlyViewed } from "../services/dashboard/recentlyViewed";
|
|
||||||
import { sharedWithMeProjects } from "../services/dashboard/sharedWithMeProject";
|
import { sharedWithMeProjects } from "../services/dashboard/sharedWithMeProject";
|
||||||
|
|
||||||
const Project: React.FC = () => {
|
const Project: React.FC = () => {
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ export const getProjectSharedList = async (projectId: string) => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
const newAccessToken = response.headers.get("x-access-token");
|
||||||
|
if (newAccessToken) {
|
||||||
|
//console.log("New token received:", newAccessToken);
|
||||||
|
localStorage.setItem("token", newAccessToken);
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Failed to get users");
|
throw new Error("Failed to get users");
|
||||||
|
|||||||
@@ -14,6 +14,11 @@ export const getSearchUsers = async (searchMail: string) => {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
const newAccessToken = response.headers.get("x-access-token");
|
||||||
|
if (newAccessToken) {
|
||||||
|
//console.log("New token received:", newAccessToken);
|
||||||
|
localStorage.setItem("token", newAccessToken);
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error("Failed to get users");
|
throw new Error("Failed to get users");
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export const shareAccess = async (
|
|||||||
const body: any = {
|
const body: any = {
|
||||||
projectId,
|
projectId,
|
||||||
targetUserId,
|
targetUserId,
|
||||||
newAccessPoint
|
newAccessPoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -26,6 +26,11 @@ export const shareAccess = async (
|
|||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
const newAccessToken = response.headers.get("x-access-token");
|
||||||
|
if (newAccessToken) {
|
||||||
|
//console.log("New token received:", newAccessToken);
|
||||||
|
localStorage.setItem("token", newAccessToken);
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error("Failed to clearPanel in the zone");
|
console.error("Failed to clearPanel in the zone");
|
||||||
|
|||||||
@@ -12,6 +12,12 @@ export const shareProject = async (addUserId: string, projectId: string) => {
|
|||||||
},
|
},
|
||||||
body: JSON.stringify({ addUserId, projectId }),
|
body: JSON.stringify({ addUserId, projectId }),
|
||||||
});
|
});
|
||||||
|
const newAccessToken = response.headers.get("x-access-token");
|
||||||
|
if (newAccessToken) {
|
||||||
|
//console.log("New token received:", newAccessToken);
|
||||||
|
localStorage.setItem("token", newAccessToken);
|
||||||
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
console.error("Failed to add project");
|
console.error("Failed to add project");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ export const useDfxUpload = create<any>((set: any) => ({
|
|||||||
dfxWallGenerate: [],
|
dfxWallGenerate: [],
|
||||||
objValue: { x: 0, y: 0, z: 0 },
|
objValue: { x: 0, y: 0, z: 0 },
|
||||||
setDfxUploaded: (x: any) => set({ dfxuploaded: x }),
|
setDfxUploaded: (x: any) => set({ dfxuploaded: x }),
|
||||||
setDfxGenerate: (x: any) => set({ dfxWallGenerate: x }),
|
setDxfWallGenerate: (x: any) => set({ dfxWallGenerate: x }),
|
||||||
setObjValue: (x: any) => set({ objValue: x }),
|
setObjValue: (x: any) => set({ objValue: x }),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,14 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import useModuleStore, { useSubModuleStore, useThreeDStore } from "../../store/useModuleStore";
|
import useModuleStore, {
|
||||||
|
useSubModuleStore,
|
||||||
|
useThreeDStore,
|
||||||
|
} from "../../store/useModuleStore";
|
||||||
import { usePlayerStore, useToggleStore } from "../../store/useUIToggleStore";
|
import { usePlayerStore, useToggleStore } from "../../store/useUIToggleStore";
|
||||||
import useVersionHistoryVisibleStore, {
|
import useVersionHistoryVisibleStore, {
|
||||||
useActiveSubTool,
|
useActiveSubTool,
|
||||||
useActiveTool,
|
useActiveTool,
|
||||||
useAddAction,
|
useAddAction,
|
||||||
|
useDfxUpload,
|
||||||
useRenameModeStore,
|
useRenameModeStore,
|
||||||
useSaveVersion,
|
useSaveVersion,
|
||||||
useSelectedComment,
|
useSelectedComment,
|
||||||
@@ -49,7 +53,7 @@ const KeyPressListener: React.FC = () => {
|
|||||||
const { setCreateNewVersion } = useVersionHistoryStore();
|
const { setCreateNewVersion } = useVersionHistoryStore();
|
||||||
const { setVersionHistoryVisible } = useVersionHistoryVisibleStore();
|
const { setVersionHistoryVisible } = useVersionHistoryVisibleStore();
|
||||||
const { setSelectedComment } = useSelectedComment();
|
const { setSelectedComment } = useSelectedComment();
|
||||||
|
const { setDfxUploaded, setDxfWallGenerate } = useDfxUpload();
|
||||||
const isTextInput = (element: Element | null): boolean =>
|
const isTextInput = (element: Element | null): boolean =>
|
||||||
element instanceof HTMLInputElement ||
|
element instanceof HTMLInputElement ||
|
||||||
element instanceof HTMLTextAreaElement ||
|
element instanceof HTMLTextAreaElement ||
|
||||||
@@ -160,14 +164,14 @@ const KeyPressListener: React.FC = () => {
|
|||||||
setCreateNewVersion(true);
|
setCreateNewVersion(true);
|
||||||
setVersionHistoryVisible(true);
|
setVersionHistoryVisible(true);
|
||||||
setSubModule("properties");
|
setSubModule("properties");
|
||||||
setActiveModule('builder');
|
setActiveModule("builder");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "Ctrl+H":
|
case "Ctrl+H":
|
||||||
if (!isPlaying) {
|
if (!isPlaying) {
|
||||||
setVersionHistoryVisible(true);
|
setVersionHistoryVisible(true);
|
||||||
setSubModule("properties");
|
setSubModule("properties");
|
||||||
setActiveModule('builder');
|
setActiveModule("builder");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -195,6 +199,7 @@ const KeyPressListener: React.FC = () => {
|
|||||||
clearComparisonProduct();
|
clearComparisonProduct();
|
||||||
setIsLogListVisible(false);
|
setIsLogListVisible(false);
|
||||||
setIsRenameMode(false);
|
setIsRenameMode(false);
|
||||||
|
setDfxUploaded([]);
|
||||||
setSelectedComment(null);
|
setSelectedComment(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user