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