Refactor Scene component for improved readability and performance adjustments

This commit is contained in:
2025-10-17 15:23:20 +05:30
parent 0b09058191
commit 1465043faf

View File

@@ -19,11 +19,7 @@ import { Color, SRGBColorSpace } from "three";
import { compressImage } from "../../utils/compressImage";
import { ALPHA_ORG } from "../../pages/Dashboard";
export default function Scene({
layout,
}: {
readonly layout: "Main Layout" | "Comparison Layout";
}) {
export default function Scene({ layout }: { readonly layout: "Main Layout" | "Comparison Layout" }) {
const map = useMemo(
() => [
{ name: "forward", keys: ["ArrowUp", "w", "W"] },
@@ -46,11 +42,7 @@ export default function Scene({
useEffect(() => {
if (!projectId || loadingProgress !== 0) return;
const canvas = document.getElementById("sceneCanvas")?.getElementsByTagName("canvas")[0];
if (
!canvas ||
!(layoutType === "default" || (layoutType === "useCase" && organization === ALPHA_ORG))
)
return;
if (!canvas || !(layoutType === "default" || (layoutType === "useCase" && organization === ALPHA_ORG))) return;
compressImage(canvas.toDataURL("image/png")).then((screenshotDataUrl) => {
const updateProjects = {
projectId,
@@ -62,7 +54,6 @@ export default function Scene({
projectSocket.emit("v1:project:update", updateProjects);
}
});
// eslint-disable-next-line
}, [activeModule, assets, loadingProgress, projectId, layoutType]);
return (
@@ -77,7 +68,7 @@ export default function Scene({
}}
resize={{ polyfill: ResizeObserver }}
style={{ width: "100vw", height: "100vh", background: "#202020" }}
performance={{ min: 0.9, max: 1.0 }}
performance={{ min: 0.9, max: 1 }}
onCreated={(e) => {
e.scene.background = layout === "Main Layout" ? null : new Color(0x19191d);
}}