refacto : cleaning the codebasebase again
This commit is contained in:
@@ -21,15 +21,16 @@ import {
|
||||
GRAB_THROW_BOOST_STEP,
|
||||
} from "@/data/grabConfig";
|
||||
import { useDebugFolder } from "@/hooks/debug/useDebugFolder";
|
||||
import type { ColliderShape, Vector3Tuple } from "@/types/3d";
|
||||
|
||||
interface GrabbableObjectProps {
|
||||
position: [number, number, number];
|
||||
position: Vector3Tuple;
|
||||
children: React.ReactNode;
|
||||
colliders?: "cuboid" | "ball" | "hull";
|
||||
colliders?: ColliderShape;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
// Shared mutable params — one debug folder controls all instances.
|
||||
// Shared params let one debug folder drive every instance.
|
||||
const params = {
|
||||
stiffness: GRAB_STIFFNESS_DEFAULT,
|
||||
throwBoost: GRAB_THROW_BOOST_DEFAULT,
|
||||
|
||||
@@ -10,17 +10,15 @@ import {
|
||||
} from "@/data/debugConfig";
|
||||
import { Debug } from "@/utils/debug/Debug";
|
||||
import { useDebugFolder } from "@/hooks/debug/useDebugFolder";
|
||||
import {
|
||||
InteractionManager,
|
||||
type InteractableHandle,
|
||||
type InteractableKind,
|
||||
} from "@/stateManager/InteractionManager";
|
||||
import { InteractionManager } from "@/stateManager/InteractionManager";
|
||||
import { INTERACTION_RADIUS } from "@/data/interactionConfig";
|
||||
import type { Vector3Tuple } from "@/types/3d";
|
||||
import type { InteractableHandle, InteractableKind } from "@/types/interaction";
|
||||
|
||||
interface InteractableObjectProps {
|
||||
kind: InteractableKind;
|
||||
label: string;
|
||||
position: [number, number, number];
|
||||
position: Vector3Tuple;
|
||||
bodyRef?: RefObject<RapierRigidBody | null>;
|
||||
onPress: () => void;
|
||||
onRelease?: () => void;
|
||||
|
||||
@@ -9,21 +9,22 @@ import {
|
||||
TRIGGER_DEFAULT_SPAWN_OFFSET,
|
||||
} from "@/data/triggerConfig";
|
||||
import { AudioManager } from "@/stateManager/AudioManager";
|
||||
import type { ColliderShape, Vector3Tuple } from "@/types/3d";
|
||||
|
||||
interface SpawnedModel {
|
||||
id: number;
|
||||
position: [number, number, number];
|
||||
position: Vector3Tuple;
|
||||
}
|
||||
|
||||
interface TriggerObjectProps {
|
||||
position: [number, number, number];
|
||||
position: Vector3Tuple;
|
||||
children: React.ReactNode;
|
||||
colliders?: "cuboid" | "ball" | "hull";
|
||||
colliders?: ColliderShape;
|
||||
label?: string;
|
||||
soundPath?: string;
|
||||
soundVolume?: number;
|
||||
spawnModel?: string;
|
||||
spawnOffset?: [number, number, number];
|
||||
spawnOffset?: Vector3Tuple;
|
||||
}
|
||||
|
||||
let _spawnCounter = 0;
|
||||
@@ -33,7 +34,7 @@ function SpawnedModelInstance({
|
||||
position,
|
||||
}: {
|
||||
path: string;
|
||||
position: [number, number, number];
|
||||
position: Vector3Tuple;
|
||||
}): React.JSX.Element {
|
||||
const { scene } = useGLTF(path);
|
||||
return <primitive object={scene.clone()} position={position} />;
|
||||
@@ -64,7 +65,7 @@ export function TriggerObject({
|
||||
}
|
||||
|
||||
if (spawnModel) {
|
||||
const spawnPos: [number, number, number] = [
|
||||
const spawnPos: Vector3Tuple = [
|
||||
position[0] + spawnOffset[0],
|
||||
position[1] + spawnOffset[1],
|
||||
position[2] + spawnOffset[2],
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useCameraMode } from "@/hooks/debug/useCameraMode";
|
||||
import { useInteractionSelector } from "@/hooks/useInteraction";
|
||||
import { useInteraction } from "@/hooks/useInteraction";
|
||||
|
||||
export function Crosshair(): React.JSX.Element | null {
|
||||
const cameraMode = useCameraMode();
|
||||
const focused = useInteractionSelector((state) => state.focused);
|
||||
const { focused } = useInteraction();
|
||||
|
||||
if (cameraMode !== "player") return null;
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import { INTERACT_KEY } from "@/data/keybindings";
|
||||
import { useCameraMode } from "@/hooks/debug/useCameraMode";
|
||||
import { useInteractionSelector } from "@/hooks/useInteraction";
|
||||
import { useInteraction } from "@/hooks/useInteraction";
|
||||
|
||||
export function InteractPrompt(): React.JSX.Element | null {
|
||||
const cameraMode = useCameraMode();
|
||||
const focused = useInteractionSelector((state) => state.focused);
|
||||
const holding = useInteractionSelector((state) => state.holding);
|
||||
const { focused, holding } = useInteraction();
|
||||
|
||||
if (cameraMode !== "player") return null;
|
||||
if (!focused || holding || focused.kind !== "trigger") return null;
|
||||
|
||||
Reference in New Issue
Block a user