Spaces:
				
			
			
	
			
			
					
		Running
		
	
	
	
			
			
	
	
	
	
		
		
					
		Running
		
	add rotation indicator
Browse files
    	
        public/textures/clockwise.png
    ADDED
    
    
											 
									 | 
									
								
    	
        public/textures/counter-clockwise.png
    ADDED
    
    
											 
									 | 
									
								
    	
        src/components/cube-piece.tsx
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ import { useState } from "react"; 
     | 
|
| 5 | 
         | 
| 6 | 
         
             
            // Standard Rubik's cube colors
         
     | 
| 7 | 
         
             
            const CUBE_COLORS = {
         
     | 
| 8 | 
         
            -
              front: "# 
     | 
| 9 | 
         
            -
              back: "# 
     | 
| 10 | 
         
            -
              left: "# 
     | 
| 11 | 
         
            -
              right: "# 
     | 
| 12 | 
         
            -
              top: "# 
     | 
| 13 | 
         
             
              bottom: "#ffffff", // White
         
     | 
| 14 | 
         
             
            };
         
     | 
| 15 | 
         | 
| 
         | 
|
| 5 | 
         | 
| 6 | 
         
             
            // Standard Rubik's cube colors
         
     | 
| 7 | 
         
             
            const CUBE_COLORS = {
         
     | 
| 8 | 
         
            +
              front: "#ff0000", // Red
         
     | 
| 9 | 
         
            +
              back: "#ff00ff", // Purple
         
     | 
| 10 | 
         
            +
              left: "#00ff00", // Green
         
     | 
| 11 | 
         
            +
              right: "#0000ff", // Blue
         
     | 
| 12 | 
         
            +
              top: "#ffff00", // Yellow
         
     | 
| 13 | 
         
             
              bottom: "#ffffff", // White
         
     | 
| 14 | 
         
             
            };
         
     | 
| 15 | 
         | 
    	
        src/components/env.tsx
    CHANGED
    
    | 
         @@ -12,7 +12,7 @@ export const Env = () => { 
     | 
|
| 12 | 
         
             
              const [preset, setPreset] = useState<PresetsType>("sunset");
         
     | 
| 13 | 
         
             
              const { autoRotate } = useControls({
         
     | 
| 14 | 
         
             
                autoRotate: {
         
     | 
| 15 | 
         
            -
                  value:  
     | 
| 16 | 
         
             
                },
         
     | 
| 17 | 
         
             
                preset: {
         
     | 
| 18 | 
         
             
                  value: preset,
         
     | 
| 
         | 
|
| 12 | 
         
             
              const [preset, setPreset] = useState<PresetsType>("sunset");
         
     | 
| 13 | 
         
             
              const { autoRotate } = useControls({
         
     | 
| 14 | 
         
             
                autoRotate: {
         
     | 
| 15 | 
         
            +
                  value: false,
         
     | 
| 16 | 
         
             
                },
         
     | 
| 17 | 
         
             
                preset: {
         
     | 
| 18 | 
         
             
                  value: preset,
         
     | 
    	
        src/components/rotation-panel.tsx
    ADDED
    
    | 
         @@ -0,0 +1,34 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            "use client";
         
     | 
| 2 | 
         
            +
             
     | 
| 3 | 
         
            +
            import { useLoader } from "@react-three/fiber";
         
     | 
| 4 | 
         
            +
            import { TextureLoader } from "three";
         
     | 
| 5 | 
         
            +
             
     | 
| 6 | 
         
            +
            type RotationPanelProps = {
         
     | 
| 7 | 
         
            +
              direction: "clockwise" | "counter-clockwise";
         
     | 
| 8 | 
         
            +
              face: "front" | "back" | "left" | "right" | "top" | "bottom";
         
     | 
| 9 | 
         
            +
            };
         
     | 
| 10 | 
         
            +
             
     | 
| 11 | 
         
            +
            export const RotationPanel = ({ direction, face }: RotationPanelProps) => {
         
     | 
| 12 | 
         
            +
              const clockwise = direction === "clockwise";
         
     | 
| 13 | 
         
            +
              const texture = useLoader(TextureLoader, `/textures/${direction}.png`);
         
     | 
| 14 | 
         
            +
              const position: Record<string, [number, number, number]> = {
         
     | 
| 15 | 
         
            +
                front: clockwise ? [0.5, 0, 1.01] : [-0.5, 0, 1.01],
         
     | 
| 16 | 
         
            +
                back: clockwise ? [-0.5, 0, -1.01] : [0.5, 0, -1.01],
         
     | 
| 17 | 
         
            +
              };
         
     | 
| 18 | 
         
            +
              const rotation: Record<string, [number, number, number]> = {
         
     | 
| 19 | 
         
            +
                front: [0, 0, 0],
         
     | 
| 20 | 
         
            +
                back: [0, Math.PI, 0],
         
     | 
| 21 | 
         
            +
              };
         
     | 
| 22 | 
         
            +
              return (
         
     | 
| 23 | 
         
            +
                <mesh position={position[face]} rotation={rotation[face]}>
         
     | 
| 24 | 
         
            +
                  <planeGeometry args={[0.8, 1.6]} />
         
     | 
| 25 | 
         
            +
                  <meshStandardMaterial
         
     | 
| 26 | 
         
            +
                    color={"#aaaaaa"}
         
     | 
| 27 | 
         
            +
                    roughness={0.5}
         
     | 
| 28 | 
         
            +
                    opacity={0.7}
         
     | 
| 29 | 
         
            +
                    map={texture}
         
     | 
| 30 | 
         
            +
                    transparent
         
     | 
| 31 | 
         
            +
                  />
         
     | 
| 32 | 
         
            +
                </mesh>
         
     | 
| 33 | 
         
            +
              );
         
     | 
| 34 | 
         
            +
            };
         
     | 
    	
        src/components/rubiks-cube.tsx
    CHANGED
    
    | 
         @@ -1,4 +1,5 @@ 
     | 
|
| 1 | 
         
             
            import { CubePiece } from "./cube-piece";
         
     | 
| 
         | 
|
| 2 | 
         | 
| 3 | 
         
             
            const CUBE_POSITIONS: Array<[number, number, number]> = [];
         
     | 
| 4 | 
         
             
            for (let x = -0.5; x <= 0.5; x++) {
         
     | 
| 
         @@ -23,6 +24,10 @@ export const RubiksCube = ({ roughness }: RubiksCubeProps) => { 
     | 
|
| 23 | 
         
             
                      roughness={roughness}
         
     | 
| 24 | 
         
             
                    />
         
     | 
| 25 | 
         
             
                  ))}
         
     | 
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 26 | 
         
             
                </group>
         
     | 
| 27 | 
         
             
              );
         
     | 
| 28 | 
         
             
            };
         
     | 
| 
         | 
|
| 1 | 
         
             
            import { CubePiece } from "./cube-piece";
         
     | 
| 2 | 
         
            +
            import { RotationPanel } from "./rotation-panel";
         
     | 
| 3 | 
         | 
| 4 | 
         
             
            const CUBE_POSITIONS: Array<[number, number, number]> = [];
         
     | 
| 5 | 
         
             
            for (let x = -0.5; x <= 0.5; x++) {
         
     | 
| 
         | 
|
| 24 | 
         
             
                      roughness={roughness}
         
     | 
| 25 | 
         
             
                    />
         
     | 
| 26 | 
         
             
                  ))}
         
     | 
| 27 | 
         
            +
                  <RotationPanel direction="clockwise" face="front" />
         
     | 
| 28 | 
         
            +
                  <RotationPanel direction="counter-clockwise" face="front" />
         
     | 
| 29 | 
         
            +
                  <RotationPanel direction="clockwise" face="back" />
         
     | 
| 30 | 
         
            +
                  <RotationPanel direction="counter-clockwise" face="back" />
         
     | 
| 31 | 
         
             
                </group>
         
     | 
| 32 | 
         
             
              );
         
     | 
| 33 | 
         
             
            };
         
     |