use case bug fixed

This commit is contained in:
2025-09-22 11:19:19 +05:30
parent 2b74d00740
commit da90feadb7
3 changed files with 10 additions and 9 deletions

View File

@@ -23,13 +23,14 @@ import { getUserData } from "../../../functions/getUserData";
import { getCameraApi } from "../../../services/factoryBuilder/camera/getCameraApi";
import { setCameraApi } from "../../../services/factoryBuilder/camera/setCameraApi";
import updateCamPosition from "../camera/functions/updateCameraPosition";
import { ALPHA_ORG } from "../../../pages/Dashboard";
export default function Controls() {
const controlsRef = useRef<CameraControls>(null);
const state = useThree();
const { toggleView } = useToggleView();
const { resetCamera, setResetCamera } = useResetCamera();
const { camType } = useSceneStore();
const { camType, layoutType } = useSceneStore();
const { builderSocket } = useSocketStore();
const { projectId } = useParams();
const { userId, organization } = getUserData();
@@ -55,7 +56,7 @@ export default function Controls() {
}, [projectId]);
useEffect(() => {
if (resetCamera && projectId) {
if (resetCamera && projectId && (layoutType === "default" || (layoutType === "useCase" && organization === ALPHA_ORG))) {
controlsRef.current?.setPosition(...CONSTANTS.threeDimension.defaultPosition);
controlsRef.current?.setTarget(...CONSTANTS.threeDimension.defaultTarget);
controlsRef.current?.rotateAzimuthTo(CONSTANTS.threeDimension.defaultAzimuth);
@@ -82,7 +83,7 @@ export default function Controls() {
setResetCamera(false);
}
}, [resetCamera, builderSocket, projectId]);
}, [resetCamera, builderSocket, projectId, layoutType]);
useEffect(() => {
controlsRef.current?.setBoundary(new THREE.Box3(new THREE.Vector3(...CONSTANTS.threeDimension.boundaryBottom), new THREE.Vector3(...CONSTANTS.threeDimension.boundaryTop)));
@@ -118,7 +119,7 @@ export default function Controls() {
};
const controls = controlsRef.current;
if (controls && !toggleView && camType === "perspective") {
if (controls && !toggleView && camType === "perspective" && (layoutType === "default" || (layoutType === "useCase" && organization === ALPHA_ORG))) {
controls.addEventListener("sleep", handleRest);
controls.addEventListener("control", startInterval);
controls.addEventListener("controlend", stopInterval);
@@ -132,7 +133,7 @@ export default function Controls() {
}
stopInterval();
};
}, [toggleView, state, builderSocket, camType]);
}, [toggleView, state, builderSocket, camType, layoutType]);
return (
<>

View File

@@ -64,7 +64,7 @@ type SceneContextValue = {
layout: "Main Layout" | "Comparison Layout";
layoutType: "project" | "usecase" | "tutorial" | null;
layoutType: "default" | "useCase" | "tutorial" | null;
};
const SceneContext = createContext<SceneContextValue | null>(null);
@@ -76,7 +76,7 @@ export function SceneProvider({
}: {
readonly children: React.ReactNode;
readonly layout: "Main Layout" | "Comparison Layout";
readonly layoutType: "project" | "usecase" | "tutorial" | null;
readonly layoutType: "default" | "useCase" | "tutorial" | null;
}) {
const versionStore = useMemo(() => createVersionStore(), []);

View File

@@ -18,9 +18,9 @@ type SceneStore = {
setCamType: (type: "orthographic" | "perspective") => void;
layoutType: "project" | "usecase" | "tutorial" | null;
layoutType: "default" | "useCase" | "tutorial" | null;
setLayoutType: (layoutType: "project" | "usecase" | "tutorial" | null) => void;
setLayoutType: (layoutType: "default" | "useCase" | "tutorial" | null) => void;
};
export const useSceneStore = create<SceneStore>()(