feat: Enhance multi-face texture handling for Minecraft blocks in Map3D component
This commit is contained in:
@@ -355,7 +355,7 @@ function TurtleModel({ turtle, isSelected, onClick }) {
|
||||
{/* LED glow */}
|
||||
<pointLight
|
||||
position={[0, 0.2, 0.85]}
|
||||
color={mode === 'mining' ? "#00ff00" : mode === 'returning' ? "#ffaa00" : "#00aaff"}
|
||||
color={activeMode === 'mining' ? "#00ff00" : activeMode === 'returning' || activeMode === 'goHome' ? "#ffaa00" : "#00aaff"}
|
||||
intensity={0.5}
|
||||
distance={2}
|
||||
/>
|
||||
@@ -397,7 +397,7 @@ function TurtleModel({ turtle, isSelected, onClick }) {
|
||||
</mesh>
|
||||
|
||||
{/* Tool/Mining arm - only show when mining */}
|
||||
{mode === 'mining' && (
|
||||
{activeMode === 'mining' && (
|
||||
<>
|
||||
<mesh position={[0, 0.1, 0.7]}>
|
||||
<boxGeometry args={[0.1, 0.1, 0.3]} />
|
||||
@@ -536,7 +536,7 @@ function getBlockAppearance(blockName) {
|
||||
// WorldBlocks component to render discovered blocks with Minecraft textures
|
||||
function WorldBlocks({ blocks }) {
|
||||
const [hoveredBlock, setHoveredBlock] = useState(null);
|
||||
const { textures, loading } = useMinecraftTextures(blocks);
|
||||
const { textures, multiFaceTextures, loading } = useMinecraftTextures(blocks);
|
||||
|
||||
// Group blocks by block name for better performance
|
||||
const blockGroups = useMemo(() => {
|
||||
@@ -561,6 +561,7 @@ function WorldBlocks({ blocks }) {
|
||||
{blockGroups.map(([blockName, blockList]) => {
|
||||
const appearance = getBlockAppearance(blockName);
|
||||
const texture = textures[blockName];
|
||||
const multiFace = multiFaceTextures[blockName];
|
||||
|
||||
return (
|
||||
<group key={blockName}>
|
||||
@@ -579,16 +580,36 @@ function WorldBlocks({ blocks }) {
|
||||
onPointerOut={() => setHoveredBlock(null)}
|
||||
>
|
||||
<boxGeometry args={[1.0, 1.0, 1.0]} />
|
||||
<meshStandardMaterial
|
||||
map={texture}
|
||||
color={texture ? '#ffffff' : appearance.color}
|
||||
emissive={appearance.emissive || appearance.color}
|
||||
emissiveIntensity={isHovered ? (appearance.intensity || 0.05) + 0.2 : (appearance.intensity || 0.05)}
|
||||
roughness={appearance.pattern === 'ore' ? 0.4 : 0.8}
|
||||
metalness={appearance.pattern === 'ore' ? 0.2 : 0.0}
|
||||
transparent
|
||||
opacity={isHovered ? 0.98 : 0.9}
|
||||
/>
|
||||
{multiFace ? (
|
||||
// Multi-face block (different top/side/bottom)
|
||||
// Box face order: +x, -x, +y, -y, +z, -z
|
||||
multiFace.map((faceTexture, i) => (
|
||||
<meshStandardMaterial
|
||||
key={i}
|
||||
attach={`material-${i}`}
|
||||
map={faceTexture}
|
||||
color="#ffffff"
|
||||
emissive={appearance.emissive || '#000000'}
|
||||
emissiveIntensity={isHovered ? 0.25 : (appearance.intensity || 0.02)}
|
||||
roughness={0.8}
|
||||
metalness={0.0}
|
||||
transparent
|
||||
opacity={isHovered ? 0.98 : 0.9}
|
||||
/>
|
||||
))
|
||||
) : (
|
||||
// Single texture or color fallback
|
||||
<meshStandardMaterial
|
||||
map={texture}
|
||||
color={texture ? '#ffffff' : appearance.color}
|
||||
emissive={appearance.emissive || appearance.color}
|
||||
emissiveIntensity={isHovered ? (appearance.intensity || 0.05) + 0.2 : (appearance.intensity || 0.05)}
|
||||
roughness={appearance.pattern === 'ore' ? 0.4 : 0.8}
|
||||
metalness={appearance.pattern === 'ore' ? 0.2 : 0.0}
|
||||
transparent
|
||||
opacity={isHovered ? 0.98 : 0.9}
|
||||
/>
|
||||
)}
|
||||
</mesh>
|
||||
|
||||
{/* Block label on hover */}
|
||||
|
||||
Reference in New Issue
Block a user