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