fix: Finalize 3D view with HTML labels
This commit is contained in:
parent
dc2f491fa9
commit
15ab32a75a
1 changed files with 19 additions and 21 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { Text } from '@react-three/drei';
|
import { Html } from '@react-three/drei';
|
||||||
import * as THREE from 'three';
|
import * as THREE from 'three';
|
||||||
import type { Room3D } from '../../lib/layoutApi';
|
import type { Room3D } from '../../lib/layoutApi';
|
||||||
import { PlantPosition, VisMode, COLORS } from './types';
|
import { PlantPosition, VisMode, COLORS } from './types';
|
||||||
|
|
@ -94,31 +94,29 @@ export function RoomObject({ room, visMode, onPlantClick, highlightedTags, dimMo
|
||||||
position={[actualRoom.posX + actualRoom.width / 2, 6, actualRoom.posY + actualRoom.height / 2]}
|
position={[actualRoom.posX + actualRoom.width / 2, 6, actualRoom.posY + actualRoom.height / 2]}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* Room label - positioned above the actual content area */}
|
{/* Room label - HTML Overlay for clear readability */}
|
||||||
<Text
|
<Html
|
||||||
position={[actualRoom.posX + actualRoom.width / 2, 0.05, actualRoom.posY + actualRoom.height / 2]}
|
position={[actualRoom.posX + actualRoom.width / 2, 0, actualRoom.posY + actualRoom.height / 2]}
|
||||||
rotation={[-Math.PI / 2, 0, 0]}
|
center
|
||||||
fontSize={Math.min(actualRoom.width, actualRoom.height) / 8}
|
zIndexRange={[100, 0]}
|
||||||
color="#f8fafc"
|
|
||||||
fillOpacity={0.5}
|
|
||||||
anchorX="center"
|
|
||||||
anchorY="middle"
|
|
||||||
>
|
>
|
||||||
{room.name}
|
<div className="px-3 py-1.5 bg-slate-900/80 backdrop-blur-sm border border-white/10 rounded-lg text-white font-medium text-sm whitespace-nowrap shadow-xl pointer-events-none select-none transform transition-transform">
|
||||||
</Text>
|
{room.name}
|
||||||
|
</div>
|
||||||
|
</Html>
|
||||||
|
|
||||||
{(visMode === 'TEMP' || visMode === 'HUMIDITY') && (
|
{(visMode === 'TEMP' || visMode === 'HUMIDITY') && (
|
||||||
<Text
|
<Html
|
||||||
position={[actualRoom.posX + actualRoom.width / 2, 4, actualRoom.posY + actualRoom.height / 2]}
|
position={[actualRoom.posX + actualRoom.width / 2, 4, actualRoom.posY + actualRoom.height / 2]}
|
||||||
rotation={[-Math.PI / 4, 0, 0]}
|
center
|
||||||
fontSize={Math.min(4, actualRoom.width / 4)}
|
|
||||||
color="#fff"
|
|
||||||
outlineColor="#000"
|
|
||||||
outlineWidth={0.15}
|
|
||||||
anchorX="center"
|
|
||||||
>
|
>
|
||||||
{visMode === 'TEMP' ? `${env.temp}°F` : `${env.humidity}%`}
|
<div className={cn(
|
||||||
</Text>
|
"px-2 py-1 rounded text-xs font-bold text-white shadow-lg pointer-events-none",
|
||||||
|
visMode === 'TEMP' ? "bg-orange-500" : "bg-blue-500"
|
||||||
|
)}>
|
||||||
|
{visMode === 'TEMP' ? `${env.temp}°F` : `${env.humidity}%`}
|
||||||
|
</div>
|
||||||
|
</Html>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Room floor - use calculated bounds */}
|
{/* Room floor - use calculated bounds */}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue