diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx index d43ae57df..8f95b066c 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Control.tsx @@ -3,6 +3,7 @@ import { invalidate, useThree } from '@react-three/fiber'; import { useEffect, useRef, useState } from 'react'; import { PerspectiveCamera, Vector3 } from 'three'; import { OrbitControls as OrbitControlsClass } from 'three-stdlib'; +import { degToRad } from 'three/src/math/MathUtils.js'; import { awaitableModelDefinitions } from '../../../../../../core/awaitables/modelDefinitions'; import { applyPitchYawLimits } from '../../../../../../core/blitz/applyPitchYawLimits'; import { hasEquipment } from '../../../../../../core/blitzkit/hasEquipment'; @@ -19,7 +20,7 @@ const poseDistances: Record = { const modelDefinitions = await awaitableModelDefinitions; -const ARCADE_MODE_DISTANCE = 19; +const ARCADE_MODE_DISTANCE = 16; const ARCADE_MODE_ANGLE = Math.PI / 8; export const ARCADE_MODE_FOV = 54; @@ -73,13 +74,11 @@ export function Controls() { const [autoRotate, setAutoRotate] = useState( display !== TankopediaDisplay.ShootingRange, ); - let initialPosition = [ - -8, + const gunHeight = protagonistHullOrigin.y + - protagonistTurretOrigin.y + - protagonistGunOrigin.y, - -13, - ] as const; + protagonistTurretOrigin.y + + protagonistGunOrigin.y; + const initialPosition = [-8, gunHeight + 4, -13] as const; useEffect(() => { if (!orbitControls.current) return; @@ -88,16 +87,16 @@ export function Controls() { (camera as PerspectiveCamera).fov = ARCADE_MODE_FOV; camera.position.set( 0, - initialPosition[1] + ARCADE_MODE_DISTANCE * Math.sin(ARCADE_MODE_ANGLE), + gunHeight + ARCADE_MODE_DISTANCE * Math.sin(ARCADE_MODE_ANGLE), ARCADE_MODE_DISTANCE * Math.cos(ARCADE_MODE_ANGLE), ); - orbitControls.current.target.set(0, initialPosition[1] + 3, 0); + orbitControls.current.target.set(0, gunHeight + 3, 0); orbitControls.current.enablePan = false; orbitControls.current.enableZoom = false; } else { (camera as PerspectiveCamera).fov = INSPECT_MODE_FOV; camera.position.set(...initialPosition); - orbitControls.current.target.set(0, initialPosition[1] / 2, 0); + orbitControls.current.target.set(0, gunHeight / 2, 0); orbitControls.current.enablePan = true; orbitControls.current.enableZoom = true; } @@ -243,6 +242,7 @@ export function Controls() { enabled={tankopediaEphemeralStore.getState().controlsEnabled} rotateSpeed={0.25} enableDamping={false} + maxPolarAngle={degToRad(100)} autoRotate={autoRotate} autoRotateSpeed={1 / 4} /> diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Lighting.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Lighting.tsx index d2fb8f313..431d43b3c 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Lighting.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/Lighting.tsx @@ -1,10 +1,13 @@ import { Environment } from '@react-three/drei'; +import { times } from 'lodash-es'; import { useModel } from '../../../../../../hooks/useModel'; import { Duel } from '../../../../../../stores/duel'; import { TankopediaEphemeral } from '../../../../../../stores/tankopediaEphemeral'; import { TankopediaPersistent } from '../../../../../../stores/tankopediaPersistent'; import { TankopediaDisplay } from '../../../../../../stores/tankopediaPersistent/constants'; +const LIGHTS_COUNT = 5; + export function Lighting() { const protagonist = Duel.use((state) => state.protagonist); const display = TankopediaEphemeral.use((state) => state.display); @@ -18,11 +21,29 @@ export function Lighting() { return ( <> - + {display !== TankopediaDisplay.ShootingRange && ( + + )} + {display === TankopediaDisplay.ShootingRange && ( + <> + + + {times(LIGHTS_COUNT, (index) => ( + + ))} + + )} ); } diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps.tsx index c697d3fc1..738e94149 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps.tsx @@ -31,11 +31,11 @@ export function SceneProps() { )} {display === TankopediaDisplay.ShootingRange && ( <> - {/* - - - - */} + {/* */} + + + + )} diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx index be6c1cba6..40c6ca864 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/TankModel.tsx @@ -102,7 +102,7 @@ export const TankModel = memo(() => { return jsxTree( node, { - mesh: { onPointerDown }, + mesh: { onPointerDown, castShadow: true }, // group(group) { // return { // visible: @@ -194,7 +194,7 @@ export const TankModel = memo(() => { return jsxTree( node, { - mesh: { onPointerDown }, + mesh: { onPointerDown, castShadow: true }, // group(group) { // return { // visible: @@ -289,7 +289,7 @@ export const TankModel = memo(() => { return jsxTree( node, { - mesh: { onPointerDown }, + mesh: { onPointerDown, castShadow: true }, // group(group) { // return { // visible: diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx index 0a8b120a3..fbc7e5edf 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx @@ -177,7 +177,6 @@ export const TankSandbox = forwardRef( style={{ userSelect: 'none' }} camera={{ fov: INSPECT_MODE_FOV, - far: 32, }} >