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