diff --git a/packages/website/src/components/MixerScene/components/Model.tsx b/packages/website/src/components/MixerScene/components/Model.tsx index a068e13f7..471883278 100644 --- a/packages/website/src/components/MixerScene/components/Model.tsx +++ b/packages/website/src/components/MixerScene/components/Model.tsx @@ -1,14 +1,14 @@ -import { awaitableModelDefinitions } from '../../../core/awaitables/modelDefinitions'; -import { jsxTree } from '../../../core/blitzkit/jsxTree'; -import { useModel } from '../../../hooks/useModel'; -import { MixerEphemeral } from '../../../stores/mixerEphemeral'; +import { awaitableModelDefinitions } from "../../../core/awaitables/modelDefinitions"; +import { jsxTree } from "../../../core/blitzkit/jsxTree"; +import { useModel } from "../../../hooks/useModel"; +import { Mixer } from "../../../stores/mixer"; const modelDefinitions = await awaitableModelDefinitions; export function Model() { - const hull = MixerEphemeral.use((state) => state.hull); - const turret = MixerEphemeral.use((state) => state.turret); - const gun = MixerEphemeral.use((state) => state.gun); + const hull = Mixer.use((state) => state.hull); + const turret = Mixer.use((state) => state.turret); + const gun = Mixer.use((state) => state.gun); const hullGltf = useModel(hull.id); const turretGltf = useModel(turret.tank.id); @@ -34,9 +34,9 @@ export function Model() { return ( {hullNodes.map((node) => { - const isHull = node.name === 'hull'; - const isWheel = node.name.startsWith('chassis_wheel_'); - const isTrack = node.name.startsWith('chassis_track_'); + const isHull = node.name === "hull"; + const isWheel = node.name.startsWith("chassis_wheel_"); + const isTrack = node.name.startsWith("chassis_track_"); const isVisible = isHull || isWheel || isTrack; if (!isVisible) return null; @@ -67,7 +67,7 @@ export function Model() { {turretNodes.map((node) => { const isCurrentTurret = node.name === - `turret_${turretModel.model_id.toString().padStart(2, '0')}`; + `turret_${turretModel.model_id.toString().padStart(2, "0")}`; const isVisible = isCurrentTurret; if (!isVisible) return null; @@ -104,10 +104,10 @@ export function Model() { {gunNodes.map((node) => { const isCurrentMantlet = node.name === - `gun_${gunModel.model_id.toString().padStart(2, '0')}_mask`; + `gun_${gunModel.model_id.toString().padStart(2, "0")}_mask`; const isCurrentGun = node.name === - `gun_${gunModel.model_id.toString().padStart(2, '0')}`; + `gun_${gunModel.model_id.toString().padStart(2, "0")}`; const isVisible = isCurrentGun || isCurrentMantlet; if (!isVisible) return null; diff --git a/packages/website/src/components/MixerScene/index.tsx b/packages/website/src/components/MixerScene/index.tsx index b30b214b9..dbfca417d 100644 --- a/packages/website/src/components/MixerScene/index.tsx +++ b/packages/website/src/components/MixerScene/index.tsx @@ -1,12 +1,13 @@ -import { OrbitControls } from '@react-three/drei'; -import { Canvas } from '@react-three/fiber'; -import { Suspense } from 'react'; -import { Model } from './components/Model'; +import { OrbitControls } from "@react-three/drei"; +import { Canvas } from "@react-three/fiber"; +import { Suspense } from "react"; +import { Lighting } from "../Tankopedia/HeroSection/components/TankSandbox/components/Lighting"; +import { Model } from "./components/Model"; export function MixerScene() { return ( - - + diff --git a/packages/website/src/pages/[...locale]/mixer/_index.tsx b/packages/website/src/pages/[...locale]/mixer/_index.tsx index f2c0dbf1d..8b8d5a50e 100644 --- a/packages/website/src/pages/[...locale]/mixer/_index.tsx +++ b/packages/website/src/pages/[...locale]/mixer/_index.tsx @@ -1,13 +1,13 @@ -import { Box } from '@radix-ui/themes'; -import { useRef } from 'react'; -import { MixerScene } from '../../../components/MixerScene'; -import { PageWrapper } from '../../../components/PageWrapper'; -import { awaitableTankDefinitions } from '../../../core/awaitables/tankDefinitions'; +import { Box } from "@radix-ui/themes"; +import { useRef } from "react"; +import { MixerScene } from "../../../components/MixerScene"; +import { PageWrapper } from "../../../components/PageWrapper"; +import { awaitableTankDefinitions } from "../../../core/awaitables/tankDefinitions"; import { LocaleProvider, type LocaleAcceptorProps, -} from '../../../hooks/useLocale'; -import { MixerEphemeral } from '../../../stores/mixerEphemeral'; +} from "../../../hooks/useLocale"; +import { Mixer } from "../../../stores/mixer"; const tankDefinitions = await awaitableTankDefinitions; const tanks = Object.values(tankDefinitions.tanks); @@ -18,35 +18,33 @@ export function Page({ locale }: LocaleAcceptorProps) { const turret = useRef( turretTank.current.turrets[ Math.floor(Math.random() * turretTank.current.turrets.length) - ], + ] ); const gunTank = useRef(tanks[Math.floor(Math.random() * tanks.length)]); const gunTurret = useRef( gunTank.current.turrets[ Math.floor(Math.random() * gunTank.current.turrets.length) - ], + ] ); const gun = useRef( gunTurret.current.guns[ Math.floor(Math.random() * gunTurret.current.guns.length) - ], + ] ); + Mixer.useInitialization({ + hull: hull.current, + turret: { tank: turretTank.current, turret: turret.current }, + gun: { + tank: gunTank.current, + turret: gunTurret.current, + gun: gun.current, + }, + }); + return ( - - - + ); } diff --git a/packages/website/src/stores/mixer.ts b/packages/website/src/stores/mixer.ts new file mode 100644 index 000000000..9669268c1 --- /dev/null +++ b/packages/website/src/stores/mixer.ts @@ -0,0 +1,21 @@ +import type { + GunDefinition, + TankDefinition, + TurretDefinition, +} from "@blitzkit/core"; +import { Varuna } from "varuna"; + +export interface Mixer { + hull: TankDefinition; + turret: { + tank: TankDefinition; + turret: TurretDefinition; + }; + gun: { + tank: TankDefinition; + turret: TurretDefinition; + gun: GunDefinition; + }; +} + +export const Mixer = new Varuna((data) => data); diff --git a/packages/website/src/stores/mixerEphemeral.ts b/packages/website/src/stores/mixerEphemeral.ts deleted file mode 100644 index 2b9801650..000000000 --- a/packages/website/src/stores/mixerEphemeral.ts +++ /dev/null @@ -1,24 +0,0 @@ -import type { - GunDefinition, - TankDefinition, - TurretDefinition, -} from '@blitzkit/core'; -import { create } from 'zustand'; -import { createContextualStore } from '../core/zustand/createContextualStore'; - -export interface MixerEphemeral { - hull: TankDefinition; - turret: { - tank: TankDefinition; - turret: TurretDefinition; - }; - gun: { - tank: TankDefinition; - turret: TurretDefinition; - gun: GunDefinition; - }; -} - -export const MixerEphemeral = createContextualStore((data: MixerEphemeral) => - create()(() => data), -);