mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-01-19 20:25:01 +00:00
split up context, rebuild
This commit is contained in:
parent
1db338f855
commit
91111f8986
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -2,7 +2,7 @@
|
|||
2:I[9766,[],""]
|
||||
3:I[8924,[],""]
|
||||
4:I[1959,[],"ClientPageRoot"]
|
||||
5:I[1222,["367","static/chunks/b536a0f1-05ee2c75df4a3b9d.js","831","static/chunks/bd904a5c-3aea2adebde6f067.js","664","static/chunks/a3cd4a83-5c5b758da206345b.js","794","static/chunks/f6211eb1-4f3105d2434536dc.js","413","static/chunks/1329d575-16915d95397758f8.js","749","static/chunks/749-d375ce6a5d05b15b.js","974","static/chunks/app/page-d55096a5cdf8744d.js"],"default"]
|
||||
5:I[1222,["367","static/chunks/b536a0f1-05ee2c75df4a3b9d.js","831","static/chunks/bd904a5c-3aea2adebde6f067.js","664","static/chunks/a3cd4a83-5c5b758da206345b.js","794","static/chunks/f6211eb1-4f3105d2434536dc.js","413","static/chunks/1329d575-16915d95397758f8.js","749","static/chunks/749-d375ce6a5d05b15b.js","974","static/chunks/app/page-1d80ebcf53b20763.js"],"default"]
|
||||
8:I[4431,[],"OutletBoundary"]
|
||||
a:I[5278,[],"AsyncMetadataOutlet"]
|
||||
c:I[4431,[],"ViewportBoundary"]
|
||||
|
|
@ -10,7 +10,7 @@ e:I[4431,[],"MetadataBoundary"]
|
|||
f:"$Sreact.suspense"
|
||||
11:I[7150,[],""]
|
||||
:HL["/t2-mapper/_next/static/css/71910d47103c2b82.css","style"]
|
||||
0:{"P":null,"b":"GES-iHcopYCN0QbsPTVOa","p":"/t2-mapper","c":["",""],"i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/css/71910d47103c2b82.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[["$","$L4",null,{"Component":"$5","searchParams":{},"params":{},"promises":["$@6","$@7"]}],null,["$","$L8",null,{"children":["$L9",["$","$La",null,{"promise":"$@b"}]]}]]}],{},null,false]},null,false],["$","$1","h",{"children":[null,[["$","$Lc",null,{"children":"$Ld"}],null],["$","$Le",null,{"children":["$","div",null,{"hidden":true,"children":["$","$f",null,{"fallback":null,"children":"$L10"}]}]}]]}],false]],"m":"$undefined","G":["$11",[]],"s":false,"S":true}
|
||||
0:{"P":null,"b":"MfKrWH0yW4dA6XW3Li2xh","p":"/t2-mapper","c":["",""],"i":false,"f":[[["",{"children":["__PAGE__",{}]},"$undefined","$undefined",true],["",["$","$1","c",{"children":[[["$","link","0",{"rel":"stylesheet","href":"/t2-mapper/_next/static/css/71910d47103c2b82.css","precedence":"next","crossOrigin":"$undefined","nonce":"$undefined"}]],["$","html",null,{"lang":"en","children":["$","body",null,{"children":["$","$L2",null,{"parallelRouterKey":"children","error":"$undefined","errorStyles":"$undefined","errorScripts":"$undefined","template":["$","$L3",null,{}],"templateStyles":"$undefined","templateScripts":"$undefined","notFound":[[["$","title",null,{"children":"404: This page could not be found."}],["$","div",null,{"style":{"fontFamily":"system-ui,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\"","height":"100vh","textAlign":"center","display":"flex","flexDirection":"column","alignItems":"center","justifyContent":"center"},"children":["$","div",null,{"children":[["$","style",null,{"dangerouslySetInnerHTML":{"__html":"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}"}}],["$","h1",null,{"className":"next-error-h1","style":{"display":"inline-block","margin":"0 20px 0 0","padding":"0 23px 0 0","fontSize":24,"fontWeight":500,"verticalAlign":"top","lineHeight":"49px"},"children":404}],["$","div",null,{"style":{"display":"inline-block"},"children":["$","h2",null,{"style":{"fontSize":14,"fontWeight":400,"lineHeight":"49px","margin":0},"children":"This page could not be found."}]}]]}]}]],[]],"forbidden":"$undefined","unauthorized":"$undefined"}]}]}]]}],{"children":["__PAGE__",["$","$1","c",{"children":[["$","$L4",null,{"Component":"$5","searchParams":{},"params":{},"promises":["$@6","$@7"]}],null,["$","$L8",null,{"children":["$L9",["$","$La",null,{"promise":"$@b"}]]}]]}],{},null,false]},null,false],["$","$1","h",{"children":[null,[["$","$Lc",null,{"children":"$Ld"}],null],["$","$Le",null,{"children":["$","div",null,{"hidden":true,"children":["$","$f",null,{"fallback":null,"children":"$L10"}]}]}]]}],false]],"m":"$undefined","G":["$11",[]],"s":false,"S":true}
|
||||
6:{}
|
||||
7:"$0:f:0:1:2:children:1:props:children:0:props:params"
|
||||
d:[["$","meta","0",{"charSet":"utf-8"}],["$","meta","1",{"name":"viewport","content":"width=device-width, initial-scale=1"}]]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { PositionalAudio, Vector3 } from "three";
|
|||
import { ConsoleObject, getPosition, getProperty } from "../mission";
|
||||
import { audioToUrl } from "../loaders";
|
||||
import { useAudio } from "./AudioContext";
|
||||
import { useSettings } from "./SettingsProvider";
|
||||
import { useDebug, useSettings } from "./SettingsProvider";
|
||||
import { FloatingLabel } from "./FloatingLabel";
|
||||
|
||||
// Global audio buffer cache
|
||||
|
|
@ -37,7 +37,7 @@ export const AudioEmitter = memo(function AudioEmitter({
|
|||
}: {
|
||||
object: ConsoleObject;
|
||||
}) {
|
||||
const { debugMode } = useSettings();
|
||||
const { debugMode } = useDebug();
|
||||
const fileName = getProperty(object, "fileName")?.value ?? "";
|
||||
const volume = parseFloat(getProperty(object, "volume")?.value ?? "1");
|
||||
const minDistance = parseFloat(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { Stats, Html } from "@react-three/drei";
|
||||
import { useSettings } from "./SettingsProvider";
|
||||
import { useDebug } from "./SettingsProvider";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { AxesHelper } from "three";
|
||||
|
||||
export function DebugElements() {
|
||||
const { debugMode } = useSettings();
|
||||
const { debugMode } = useDebug();
|
||||
const axesRef = useRef<AxesHelper>(null);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {
|
|||
} from "../shaderMaterials";
|
||||
import { MeshStandardMaterial } from "three";
|
||||
import { setupColor } from "../textureUtils";
|
||||
import { useSettings } from "./SettingsProvider";
|
||||
import { useDebug } from "./SettingsProvider";
|
||||
import { useShapeInfo } from "./ShapeInfoProvider";
|
||||
import { FloatingLabel } from "./FloatingLabel";
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ export type StaticShapeType = "StaticShape" | "TSStatic" | "Item" | "Turret";
|
|||
|
||||
export const ShapeModel = memo(function ShapeModel() {
|
||||
const { shapeName } = useShapeInfo();
|
||||
const { debugMode } = useSettings();
|
||||
const { debugMode } = useDebug();
|
||||
const { nodes } = useStaticShape(shapeName);
|
||||
|
||||
const hullBoneIndices = useMemo(() => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getResourceList } from "../manifest";
|
||||
import { useSettings } from "./SettingsProvider";
|
||||
import { useControls, useDebug, useSettings } from "./SettingsProvider";
|
||||
|
||||
const excludeMissions = new Set([
|
||||
"SkiFree",
|
||||
|
|
@ -23,15 +23,13 @@ export function InspectorControls({
|
|||
const {
|
||||
fogEnabled,
|
||||
setFogEnabled,
|
||||
speedMultiplier,
|
||||
setSpeedMultiplier,
|
||||
fov,
|
||||
setFov,
|
||||
audioEnabled,
|
||||
setAudioEnabled,
|
||||
debugMode,
|
||||
setDebugMode,
|
||||
} = useSettings();
|
||||
const { speedMultiplier, setSpeedMultiplier } = useControls();
|
||||
const { debugMode, setDebugMode } = useDebug();
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import {
|
|||
getScale,
|
||||
} from "../mission";
|
||||
import { setupColor } from "../textureUtils";
|
||||
import { FloatingLabel } from "./FloatingLabel";
|
||||
import { useDebug } from "./SettingsProvider";
|
||||
|
||||
const FALLBACK_URL = `${BASE_URL}/black.png`;
|
||||
|
||||
|
|
@ -55,6 +57,7 @@ function InteriorMesh({ node }: { node: Mesh }) {
|
|||
export const InteriorModel = memo(
|
||||
({ interiorFile }: { interiorFile: string }) => {
|
||||
const { nodes } = useInterior(interiorFile);
|
||||
const { debugMode } = useDebug();
|
||||
|
||||
return (
|
||||
<group rotation={[0, -Math.PI / 2, 0]}>
|
||||
|
|
@ -66,6 +69,7 @@ export const InteriorModel = memo(
|
|||
.map(([name, node]: [string, any]) => (
|
||||
<InteriorMesh key={name} node={node} />
|
||||
))}
|
||||
{debugMode ? <FloatingLabel>{interiorFile}</FloatingLabel> : null}
|
||||
</group>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Vector3 } from "three";
|
|||
import { useFrame, useThree } from "@react-three/fiber";
|
||||
import { KeyboardControls, useKeyboardControls } from "@react-three/drei";
|
||||
import { PointerLockControls } from "three-stdlib";
|
||||
import { useSettings } from "./SettingsProvider";
|
||||
import { useControls } from "./SettingsProvider";
|
||||
|
||||
enum Controls {
|
||||
forward = "forward",
|
||||
|
|
@ -19,7 +19,7 @@ const MIN_SPEED_ADJUSTMENT = 0.05;
|
|||
const MAX_SPEED_ADJUSTMENT = 0.5;
|
||||
|
||||
function CameraMovement() {
|
||||
const { speedMultiplier, setSpeedMultiplier } = useSettings();
|
||||
const { speedMultiplier, setSpeedMultiplier } = useControls();
|
||||
const [subscribe, getKeys] = useKeyboardControls<Controls>();
|
||||
const { camera, gl } = useThree();
|
||||
const controlsRef = useRef<PointerLockControls | null>(null);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import {
|
|||
} from "react";
|
||||
|
||||
const SettingsContext = createContext(null);
|
||||
const DebugContext = createContext(null);
|
||||
const ControlsContext = createContext(null);
|
||||
|
||||
type PersistedSettings = {
|
||||
fogEnabled?: boolean;
|
||||
|
|
@ -22,6 +24,14 @@ export function useSettings() {
|
|||
return useContext(SettingsContext);
|
||||
}
|
||||
|
||||
export function useDebug() {
|
||||
return useContext(DebugContext);
|
||||
}
|
||||
|
||||
export function useControls() {
|
||||
return useContext(ControlsContext);
|
||||
}
|
||||
|
||||
export function SettingsProvider({ children }: { children: ReactNode }) {
|
||||
const [fogEnabled, setFogEnabled] = useState(true);
|
||||
const [speedMultiplier, setSpeedMultiplier] = useState(1);
|
||||
|
|
@ -29,20 +39,26 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|||
const [audioEnabled, setAudioEnabled] = useState(false);
|
||||
const [debugMode, setDebugMode] = useState(false);
|
||||
|
||||
const value = useMemo(
|
||||
const settingsContext = useMemo(
|
||||
() => ({
|
||||
fogEnabled,
|
||||
setFogEnabled,
|
||||
speedMultiplier,
|
||||
setSpeedMultiplier,
|
||||
fov,
|
||||
setFov,
|
||||
audioEnabled,
|
||||
setAudioEnabled,
|
||||
debugMode,
|
||||
setDebugMode,
|
||||
}),
|
||||
[fogEnabled, speedMultiplier, fov, audioEnabled, debugMode, setDebugMode]
|
||||
[fogEnabled, speedMultiplier, fov, audioEnabled]
|
||||
);
|
||||
|
||||
const debugContext = useMemo(
|
||||
() => ({ debugMode, setDebugMode }),
|
||||
[debugMode, setDebugMode]
|
||||
);
|
||||
|
||||
const controlsContext = useMemo(
|
||||
() => ({ speedMultiplier, setSpeedMultiplier }),
|
||||
[speedMultiplier, setSpeedMultiplier]
|
||||
);
|
||||
|
||||
// Read persisted settings from localStoarge.
|
||||
|
|
@ -103,8 +119,12 @@ export function SettingsProvider({ children }: { children: ReactNode }) {
|
|||
}, [fogEnabled, speedMultiplier, fov, audioEnabled, debugMode]);
|
||||
|
||||
return (
|
||||
<SettingsContext.Provider value={value}>
|
||||
{children}
|
||||
<SettingsContext.Provider value={settingsContext}>
|
||||
<DebugContext.Provider value={debugContext}>
|
||||
<ControlsContext.Provider value={controlsContext}>
|
||||
{children}
|
||||
</ControlsContext.Provider>
|
||||
</DebugContext.Provider>
|
||||
</SettingsContext.Provider>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import {
|
|||
setupMask,
|
||||
updateTerrainTextureShader,
|
||||
} from "../textureUtils";
|
||||
import { useSettings } from "./SettingsProvider";
|
||||
import { useDebug } from "./SettingsProvider";
|
||||
|
||||
const DEFAULT_SQUARE_SIZE = 8;
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ function BlendedTerrainTextures({
|
|||
textureNames: string[];
|
||||
alphaMaps: Uint8Array[];
|
||||
}) {
|
||||
const { debugMode } = useSettings();
|
||||
const { debugMode } = useDebug();
|
||||
|
||||
const baseTextures = useTexture(
|
||||
textureNames.map((name) => terrainTextureToUrl(name)),
|
||||
|
|
|
|||
Loading…
Reference in a new issue