fix has pbr

This commit is contained in:
tresabhi committed 2026-08-12 13:41:59 -05:00
1 parent 56d5d5e956
commit 5092d43e8e
4 files changed
+19 -10

No files matched your search

@@ -1,3 +1,4 @@
import { useModel } from "../hooks/useModel";
import { Guess, GuessState } from "../stores/guess";
import { SmartCanvas } from "./SmartCanvas";
import { Controls } from "./Tankopedia/HeroSection/components/TankSandbox/components/Control";
@@ -12,6 +13,9 @@ export function GuessRenderer() {
const helpingReveal = Guess.use((state) => state.helpingReveal);
const isRevealed = helpingReveal || guessState !== GuessState.NotGuessed;
const id = Guess.use((state) => state.tank.id);
const { hasPbr } = useModel(id);
return (
<SmartCanvas
style={{
@@ -24,7 +28,7 @@ export function GuessRenderer() {
camera={{ position: [-5, 5, -5] }}
>
<Controls zoomable={false} />
<Lighting />
<Lighting hasPbr={hasPbr} />
<TankModel />
</SmartCanvas>
);
@@ -43,7 +43,7 @@ export const MixerScene = forwardRef<HTMLCanvasElement>((_, ref) => {
target={[0, 0.5, 0]}
/>
<Lighting />
<Lighting hasPbr={false} />
<SceneProps />
<Suspense fallback={<MixerFallback />}>
@@ -12,8 +12,6 @@ import {
} from "react";
import { HemisphereLight, SpotLight, type Group } from "three";
import { degToRad, lerp } from "three/src/math/MathUtils.js";
import { useModel } from "../../../../../../hooks/useModel";
import { Duel } from "../../../../../../stores/duel";
import { Tankopedia } from "../../../../../../stores/tankopedia";
import { TankopediaPersistent } from "../../../../../../stores/tankopediaPersistent";
import { TankopediaDisplay } from "../../../../../../stores/tankopediaPersistent/constants";
@@ -39,7 +37,11 @@ const SHADOW_FOCUS = 2 ** 0;
export const transitionEvent = new Quicklime<number>(0);
export function Lighting() {
interface Props {
hasPbr: boolean;
}
export function Lighting({ hasPbr }: Props) {
const wrapper = useRef<Group>(null);
const highGraphics = TankopediaPersistent.use((state) => state.highGraphics);
@@ -84,6 +86,7 @@ export function Lighting() {
{animate && (
<Animator
hasPbr={hasPbr}
t0={t0}
animationTime={animationTime}
wrapper={wrapper}
@@ -142,15 +145,13 @@ interface AnimatorProps {
t0: RefObject<number>;
animationTime: RefObject<number>;
wrapper: RefObject<Group | null>;
hasPbr: boolean;
}
function Animator({ stop, t0, animationTime, wrapper }: AnimatorProps) {
function Animator({ stop, t0, animationTime, wrapper, hasPbr }: AnimatorProps) {
const requestedDisplay = Tankopedia.use((state) => state.requestedDisplay);
const id = Duel.use((state) => state.protagonist.tank.id);
const display = Tankopedia.use((state) => state.display);
const { hasPbr } = useModel(id);
const factor =
!hasPbr && display !== TankopediaDisplay.StaticArmor ? NON_PBR_FACTOR : 1;
@@ -9,6 +9,7 @@ import { applyPitchYawLimits } from "../../../../../core/blitz/applyPitchYawLimi
import { modelTransformEvent } from "../../../../../core/blitzkit/modelTransform";
import { Pose, poseEvent } from "../../../../../core/blitzkit/pose";
import { useEquipment } from "../../../../../hooks/useEquipment";
import { useModel } from "../../../../../hooks/useModel";
import { useTankModelDefinition } from "../../../../../hooks/useTankModelDefinition";
import { Duel } from "../../../../../stores/duel";
import { Tankopedia } from "../../../../../stores/tankopedia";
@@ -49,6 +50,9 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
(state) => state.hideTankModelUnderArmor,
);
const id = Duel.use((state) => state.protagonist.tank.id);
const { hasPbr } = useModel(id);
useImperativeHandle(ref, () => canvas.current!, []);
function handlePointerDown() {
@@ -169,7 +173,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
outline: undefined,
}}
>
<Lighting />
<Lighting hasPbr={hasPbr} />
<SceneProps />
{(display === TankopediaDisplay.Model ||