From 7739dbd0a3b2851f5066ea781e227004617ab938 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Mon, 10 Aug 2026 16:42:35 -0500 Subject: [PATCH] faster lighting --- .../TankSandbox/components/Lighting.tsx | 23 +++++++++++-------- .../components/SceneProps/index.tsx | 5 ++-- .../components/TankSandbox/index.tsx | 2 -- .../[...chunk_api]/tanks/[id]/model.glb.ts | 12 +++------- 4 files changed, 19 insertions(+), 23 deletions(-) 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 75ee0f3fc..bf2f1f93f 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,3 +1,4 @@ +import { ContactShadows } from "@react-three/drei"; import { useFrame } from "@react-three/fiber"; import { clamp, times } from "lodash-es"; import { Quicklime } from "quicklime"; @@ -12,25 +13,24 @@ import { HemisphereLight, SpotLight, type Group } from "three"; import { degToRad, lerp } from "three/src/math/MathUtils.js"; import { Tankopedia } from "../../../../../../stores/tankopedia"; import { TankopediaPersistent } from "../../../../../../stores/tankopediaPersistent"; -import { HelpingSpotLight } from "../../../../../HelpingSpotLight"; const ANGLE = degToRad(12); const REVEAL_ANIMATION_TIME = 3; const TRANSITION_ANIMATION_TIME = 0.5; -const LIGHTS_COUNT = 4; +const LIGHTS_COUNT = 3; const THETA_OFFSET = degToRad(180 - 45); const LIGHT_DISTANCE = 20; const LIGHT_HEIGHT_0 = 4; const LIGHT_HEIGHT_1 = 6; -const INTENSITY_0 = 6 * 9; -const INTENSITY_1 = 3 * 9; -const HEMISPHERE_INTENSITY = 2; +const INTENSITY_0 = 2 ** 6.5; +const INTENSITY_1 = 2 ** 3.5; +const HEMISPHERE_INTENSITY = 2 ** 1.2; export const transitionEvent = new Quicklime(0); export function Lighting() { - const wrapper = useRef(null!); + const wrapper = useRef(null); const highGraphics = TankopediaPersistent.use((state) => state.highGraphics); const requestedDisplay = Tankopedia.use((state) => state.requestedDisplay); @@ -61,6 +61,8 @@ export function Lighting() { return ( <> + + {animate && ( - + {times(LIGHTS_COUNT, (index) => { const x = index / (LIGHTS_COUNT - 1); @@ -86,8 +88,7 @@ export function Lighting() { const intensity = lerp(INTENSITY_0, INTENSITY_1, x); return ( - ; animationTime: RefObject; - wrapper: RefObject; + wrapper: RefObject; } function Animator({ stop, t0, animationTime, wrapper }: AnimatorProps) { const requestedDisplay = Tankopedia.use((state) => state.requestedDisplay); const apply = useCallback((t: number) => { + if (wrapper.current === null) return; + for (const child of wrapper.current.children) { if (child instanceof SpotLight) { child.angle = ANGLE * t; diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps/index.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps/index.tsx index 76cb0675e..c8cbf3d16 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/components/SceneProps/index.tsx @@ -3,7 +3,7 @@ import { Quicklime, type QuicklimeEvent } from "quicklime"; import { useEffect, useRef } from "react"; import { Mesh, MeshStandardMaterial } from "three"; -const SIZE = 2 ** 4; +const SIZE = 2 ** 5; export const screenshotReadyEvent = new Quicklime(false); @@ -26,6 +26,7 @@ export function SceneProps() { return ( ); 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 b8b7dcdfa..732bf7927 100644 --- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx +++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandbox/index.tsx @@ -5,7 +5,6 @@ import { useImperativeHandle, useRef, } from "react"; -import { Fog } from "three"; import { applyPitchYawLimits } from "../../../../../core/blitz/applyPitchYawLimits"; import { modelTransformEvent } from "../../../../../core/blitzkit/modelTransform"; import { Pose, poseEvent } from "../../../../../core/blitzkit/pose"; @@ -150,7 +149,6 @@ export const TankSandbox = forwardRef(