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