refactor: remove 'naked' prop from Controls and TankSandbox components

This commit is contained in:
TrèsAbhi committed 2025-11-27 17:24:12 -06:00
1 parent 54b73d11ce
commit 58c70f98e1
2 files changed
+10 -22

No files matched your search

@@ -22,14 +22,12 @@ const poseDistances: Record<Pose, number> = {
const modelDefinitions = await awaitableModelDefinitions; const modelDefinitions = await awaitableModelDefinitions;
interface ControlsProps { interface ControlsProps {
naked?: boolean;
autoRotate?: boolean; autoRotate?: boolean;
zoomable?: boolean; zoomable?: boolean;
enableRotate?: boolean; enableRotate?: boolean;
} }
export function Controls({ export function Controls({
naked,
autoRotate = true, autoRotate = true,
zoomable = true, zoomable = true,
enableRotate = true, enableRotate = true,
@@ -79,11 +77,7 @@ export function Controls({
protagonistHullOrigin.y + protagonistHullOrigin.y +
protagonistTurretOrigin.y + protagonistTurretOrigin.y +
protagonistGunOrigin.y; protagonistGunOrigin.y;
const inspectModeInitialPosition = new Vector3( const inspectModeInitialPosition = new Vector3(-8, 2, -13);
-8,
naked ? gunHeight + 10 : 2,
-13
);
const t0 = useRef(Date.now() / 1000); const t0 = useRef(Date.now() / 1000);
useFrame(() => { useFrame(() => {
@@ -236,14 +230,10 @@ export function Controls({
orbitControls.current.rotateSpeed = 0.25; orbitControls.current.rotateSpeed = 0.25;
camera.position.copy(inspectModeInitialPosition); camera.position.copy(inspectModeInitialPosition);
orbitControls.current.target.set( orbitControls.current.target.set(0, gunHeight * 0.6, 0);
0,
gunHeight * (naked ? 1 / 4 : 3 / 4),
0
);
orbitControls.current.enablePan = true; orbitControls.current.enablePan = true;
orbitControls.current.enableZoom = true; orbitControls.current.enableZoom = true;
camera.fov = naked ? 20 : 25; camera.fov = 25;
camera.updateProjectionMatrix(); camera.updateProjectionMatrix();
} }
@@ -1,4 +1,3 @@
import { BLITZKIT_TANK_ICON_SIZE } from "@blitzkit/core";
import { import {
forwardRef, forwardRef,
Suspense, Suspense,
@@ -33,11 +32,10 @@ import { TankModel } from "./components/TankModel";
interface TankSandboxProps { interface TankSandboxProps {
thicknessRange: ThicknessRange; thicknessRange: ThicknessRange;
naked?: boolean;
} }
export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>( export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
({ thicknessRange, naked }, ref) => { ({ thicknessRange }, ref) => {
const canvas = useRef<HTMLCanvasElement>(null); const canvas = useRef<HTMLCanvasElement>(null);
const hasImprovedVerticalStabilizer = useEquipment(122); const hasImprovedVerticalStabilizer = useEquipment(122);
const hasDownImprovedVerticalStabilizer = useEquipment(124); const hasDownImprovedVerticalStabilizer = useEquipment(124);
@@ -153,7 +151,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
return ( return (
<SmartCanvas <SmartCanvas
ref={canvas} ref={canvas}
scene={{ fog: naked ? undefined : new Fog("black", 30, 50) }} scene={{ fog: new Fog("black", 30, 50) }}
gl={{ gl={{
clippingPlanes: [], clippingPlanes: [],
localClippingEnabled: true, localClippingEnabled: true,
@@ -169,14 +167,14 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
}} }}
style={{ style={{
userSelect: "none", userSelect: "none",
width: naked ? BLITZKIT_TANK_ICON_SIZE.width : "100%", width: "100%",
height: naked ? BLITZKIT_TANK_ICON_SIZE.height : "100%", height: "100%",
outline: naked ? "1rem red solid" : undefined, outline: undefined,
}} }}
> >
<Lighting /> <Lighting />
{!naked && <SceneProps />} <SceneProps />
{(display === TankopediaDisplay.Model || {(display === TankopediaDisplay.Model ||
(display === TankopediaDisplay.DynamicArmor && (display === TankopediaDisplay.DynamicArmor &&
!hideTankModelUnderArmor)) && <TankModel />} !hideTankModelUnderArmor)) && <TankModel />}
@@ -186,7 +184,7 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
<Suspense> <Suspense>
{/* Controls within Suspense to allow for frame-perfect start of camera auto-rotate */} {/* Controls within Suspense to allow for frame-perfect start of camera auto-rotate */}
<Controls naked={naked} /> <Controls />
{display === TankopediaDisplay.DynamicArmor && <Armor />} {display === TankopediaDisplay.DynamicArmor && <Armor />}
{display === TankopediaDisplay.StaticArmor && ( {display === TankopediaDisplay.StaticArmor && (