Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update next.config #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
compress: true,
async headers() {
return [
{
source: "/:all*(gz)",
locale: false,
headers: [
{
key: "Content-Encoding",
value: "gzip",
},
{
key: "Content-Type",
value: "application/gzip",
},
],
},
];
},
};

module.exports = nextConfig
module.exports = nextConfig;
134 changes: 71 additions & 63 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useCallback, useEffect, useState } from "react";
import { Unity, useUnityContext } from "react-unity-webgl";
import '@/styles/globals.scss'
import "@/styles/globals.scss";
import PrinciplePage from "@/components/PrinciplePage";
import LandingPage from "@/components/LandingPage";
import MuteLottie from "@/components/UI/MuteLottie";
Expand All @@ -15,28 +15,36 @@ import { playSound } from "@/hooks/utils/audio";
import Loader from "@/components/Loader";

export default function App() {

// react-unity-webgl config
// const { unityProvider, sendMessage, addEventListener, removeEventListener, isLoaded } = useUnityContext({
// loaderUrl: "/unity/BuildGzip.loader.js",
// dataUrl: "/unity/BuildGzip.data.gz",
// frameworkUrl: "/unity/BuildGzip.framework.js",
// codeUrl: "/unity/BuildGzip.wasm.gz",
// });
// const { unityProvider, sendMessage, addEventListener, removeEventListener, isLoaded } = useUnityContext({
// loaderUrl: "/Build/Build_Gzip/BuildGzip.loader.js",
// dataUrl: "/Build/Build_Gzip/BuildGzip.data.gz",
// frameworkUrl: "/Build/Build_Gzip/BuildGzip.framework.js",
// codeUrl: "/Build/Build_Gzip/BuildGzip.wasm.gz",
// });

const { unityProvider, sendMessage, addEventListener, removeEventListener, loadingProgression, isLoaded } = useUnityContext({
loaderUrl: "/Build/Build.loader.js",
dataUrl: "/Build/Build.data",
frameworkUrl: "/Build/Build.framework.js",
codeUrl: "/Build/Build.wasm",
const {
unityProvider,
sendMessage,
addEventListener,
removeEventListener,
isLoaded,
loadingProgression,
initialisationError,
} = useUnityContext({
loaderUrl: "/Build/Build_Gzip/BuildGzip.loader.js",
dataUrl: "/Build/Build_Gzip/BuildGzip.data.gz",
frameworkUrl: "/Build/Build_Gzip/BuildGzip.framework.js.gz",
codeUrl: "/Build/Build_Gzip/BuildGzip.wasm.gz",
});

// const { unityProvider, sendMessage, addEventListener, removeEventListener, loadingProgression, isLoaded } = useUnityContext({
// loaderUrl: "/Build/Build.loader.js",
// dataUrl: "/Build/Build.data",
// frameworkUrl: "/Build/Build.framework.js",
// codeUrl: "/Build/Build.wasm",
// });

// global state management for interactions
const landingPage = useStore((state: any) => state.landingPage);
const setLandingPage = useStore((state: any) => state.setLandingPage);
Expand All @@ -45,60 +53,64 @@ export default function App() {
const spotLight = useStore((state: any) => state.spotLight);
const hamburgerMenu = useStore((state: any) => state.hamburgerMenu);
const backToMap = useStore((state: any) => state.backToMap);
const setBackToMap = useStore((state: any) => state.setBackToMap)
const principle = useStore((state: any) => state.principle)
const openPrinciple = useStore((state: any) => state.openPrinciple)
const setSpotLight = useStore((state: any) => state.setSpotLight)
const setBackToMap = useStore((state: any) => state.setBackToMap);
const principle = useStore((state: any) => state.principle);
const openPrinciple = useStore((state: any) => state.openPrinciple);
const setSpotLight = useStore((state: any) => state.setSpotLight);

// returning visitor state
const [visited, setVisited] = useState('false')
const [visited, setVisited] = useState("false");

useEffect(() => {
const siteState = window.sessionStorage.getItem("siteState");
const siteState = window.sessionStorage.getItem("siteState");
console.log(siteState);

if (visited == "true") {
sendMessage("Spotlight_Manager","unity_open")
sendMessage("Spotlight_Manager", "unity_open");
setLandingPage(false);
}
if (siteState == 'true') {
setVisited('true')
} else if (siteState == 'false') {
setVisited('false')
if (siteState == "true") {
setVisited("true");
} else if (siteState == "false") {
setVisited("false");
}
}, [visited, isLoaded])
}, [visited, isLoaded]);

// send messages to Unity Build
useEffect(() => {
if (!videoSequence) {
sendMessage("Spotlight_Manager","unity_open")
sendMessage("Spotlight_Manager", "unity_open");
}
}, [videoSequence])
}, [videoSequence]);

useEffect(() => {
if (!welcomeScreen) {
sendMessage("Spotlight_Manager", "map_intro")
sendMessage("Spotlight_Manager", "map_intro");
}
}, [welcomeScreen])
}, [welcomeScreen]);

useEffect(() => {
if (spotLight) {
sendMessage("Spotlight_Manager", "open_spotlight", `${principle.toString()}`)
sendMessage(
"Spotlight_Manager",
"open_spotlight",
`${principle.toString()}`
);
}
}, [spotLight, principle])
}, [spotLight, principle]);

useEffect(() => {
if (backToMap == true) {
sendMessage("Spotlight_Manager", "return_to_map")
sendMessage("Spotlight_Manager", "return_to_map");
}
}, [backToMap])
}, [backToMap]);

// handle spotlight open functionality
const openSpotlight = useCallback((principle: any) => {
setSpotLight(true)
setBackToMap(false)
playSound('ui_click')
playSound('transition')
setSpotLight(true);
setBackToMap(false);
playSound("ui_click");
playSound("transition");
}, []);

// event listeners for Unity functions
Expand All @@ -108,49 +120,45 @@ export default function App() {
removeEventListener("PageOpen", openSpotlight);
};
}, [addEventListener, removeEventListener, openSpotlight]);

return (

useEffect(() => {
console.log(initialisationError);
}, [initialisationError]);

return (
<>
<div className="main">
<LandingPage />
<Sound />

{welcomeScreen && (
<WelcomeScreen />
)}
{welcomeScreen && <WelcomeScreen />}

{!welcomeScreen && (
<>
<TopNav />
{!openPrinciple && (
<BottomNav />
)}
{!openPrinciple && <BottomNav />}
</>
)}

{openPrinciple && (
<>
<PrinciplePage page={principle}/>
<PrinciplePage page={principle} />
</>
)}

{((spotLight) && (!openPrinciple))&& (
<SpotlightFooter />
)}
{spotLight && !openPrinciple && <SpotlightFooter />}

{hamburgerMenu && (
<MainMenu />
)}
{hamburgerMenu && <MainMenu />}
</div>
<MuteLottie />
{!isLoaded && (
<Loader loadingProgress={Math.round(loadingProgression * 100)}/>
)}
<Unity
unityProvider={unityProvider}
className="unity_canvas"
style={{ visibility: isLoaded ? "visible" : "hidden" }}
/>
<Loader loadingProgress={Math.round(loadingProgression * 100)} />
)}
<Unity
unityProvider={unityProvider}
className="unity_canvas"
style={{ visibility: isLoaded ? "visible" : "hidden" }}
/>
</>
)
}
);
}