Feat/map-environment #6

Merged
math-pixel merged 116 commits from feat/map-environment into develop 2026-05-29 00:00:51 +00:00
4 changed files with 30 additions and 14 deletions
Showing only changes of commit b8cff43545 - Show all commits
+19 -7
View File
@@ -1,8 +1,22 @@
import { useEffect, useMemo } from "react";
import * as THREE from "three";
import { useLoggedGLTF } from "@/hooks/three/useLoggedGLTF";
import type { ModelTransformProps, Vector3Tuple } from "@/types/three/three";
import { disposeObject3D } from "@/utils/three/dispose";
function applyShadowSettings(
object: THREE.Object3D,
castShadow: boolean,
receiveShadow: boolean,
): void {
object.traverse((child) => {
if (!(child instanceof THREE.Mesh)) return;
child.castShadow = castShadow;
child.receiveShadow = receiveShadow;
});
}
export interface SimpleModelConfig extends ModelTransformProps {
modelPath: string;
castShadow?: boolean;
@@ -30,6 +44,10 @@ export function SimpleModel({
});
const model = useMemo(() => scene.clone(true), [scene]);
useEffect(() => {
applyShadowSettings(model, castShadow, receiveShadow);
}, [castShadow, model, receiveShadow]);
useEffect(() => {
return () => {
disposeObject3D(model);
@@ -41,13 +59,7 @@ export function SimpleModel({
return (
<group position={position} rotation={rotation} scale={parsedScale}>
{children ?? (
<primitive
object={model}
castShadow={castShadow}
receiveShadow={receiveShadow}
/>
)}
{children ?? <primitive object={model} />}
</group>
);
}
+1 -1
View File
@@ -3,7 +3,7 @@ import { TERRAIN_COLORS } from "@/data/world/terrainConfig";
export type FogMode = "linear" | "exp2";
export const FOG_CONFIG = {
enabled: true,
enabled: false,
mode: "exp2" as FogMode,
color: "#dfe7d8",
near: 32,
+3 -5
View File
@@ -9,7 +9,7 @@ import {
GAME_SCENE_SKY_MODEL_SCALE,
PHYSICS_SCENE_BACKGROUND_COLOR,
} from "@/data/world/environmentConfig";
import { FOG_CONFIG, FOG_LIGHTING_COLOR_MIX } from "@/data/world/fogConfig";
import { FOG_LIGHTING_COLOR_MIX } from "@/data/world/fogConfig";
import { useCameraMode } from "@/hooks/debug/useCameraMode";
import { useSceneMode } from "@/hooks/debug/useSceneMode";
import { useFogSettings } from "@/hooks/world/useFogSettings";
@@ -57,15 +57,13 @@ export function Environment(): React.JSX.Element {
return (
<>
{FOG_CONFIG.enabled &&
fogEnabled &&
{fogEnabled &&
sceneMode === "game" &&
cameraMode === "player" &&
fog.mode === "linear" ? (
<fog attach="fog" args={[fogColor, fog.near, fog.far]} />
) : null}
{FOG_CONFIG.enabled &&
fogEnabled &&
{fogEnabled &&
sceneMode === "game" &&
cameraMode === "player" &&
fog.mode === "exp2" ? (
+7 -1
View File
@@ -391,7 +391,13 @@ function FallbackMapNode({ node }: { node: MapNode }): React.JSX.Element {
const normalizedScale = normalizeMapScale(scale);
return (
<mesh position={position} rotation={rotation} scale={normalizedScale}>
<mesh
castShadow
position={position}
receiveShadow
rotation={rotation}
scale={normalizedScale}
>
<boxGeometry args={[1, 1, 1]} />
<meshStandardMaterial color="#64748b" wireframe />
</mesh>