diff --git a/public/gate_object_texture.png b/public/gate_object_texture.png new file mode 100644 index 0000000..16cb7f5 Binary files /dev/null and b/public/gate_object_texture.png differ diff --git a/src/components/GateScene/GateMiddleObject/Mirror.tsx b/src/components/GateScene/GateMiddleObject/Mirror.tsx index b26f14d..0705715 100644 --- a/src/components/GateScene/GateMiddleObject/Mirror.tsx +++ b/src/components/GateScene/GateMiddleObject/Mirror.tsx @@ -1,35 +1,59 @@ import React, { useMemo, useRef } from "react"; -import gateMirrorTexture from "../../../static/sprite/gate_object_texture.png"; import { useFrame, useLoader } from "react-three-fiber"; import * as THREE from "three"; const Mirror = () => { - const gateMirrorTex = useLoader(THREE.TextureLoader, gateMirrorTexture); + + const cubeTexture = useLoader( + // @ts-ignore + THREE.CubeTextureLoader, + [ + "gate_object_texture_2.png", + "gate_object_texture_2.png", + "gate_object_texture_2.png", + "gate_object_texture_2.png", + "gate_object_texture_2.png", + "gate_object_texture_2.png", + "gate_object_texture_2.png", + ], + (loader: THREE.CubeTextureLoader) => loader.setPath("../../../static") + ); + + const mirrorMaterial = useMemo(() => { + const loader = new THREE.CubeTextureLoader(); + const texture = loader.load([ + "gate_object_texture.png", + "gate_object_texture.png", + "gate_object_texture.png", + "gate_object_texture.png", + "gate_object_texture.png", + "gate_object_texture.png", + ]); + return new THREE.MeshBasicMaterial({ + envMap: cubeTexture, + depthTest: false, + transparent: true, + }); + }, []); + const mirrorRef = useRef(); - const textureMemo = useMemo(() => { - gateMirrorTex.wrapS = THREE.RepeatWrapping; - gateMirrorTex.wrapT = THREE.RepeatWrapping; - - return gateMirrorTex; - }, [gateMirrorTex]); - useFrame(() => { if (mirrorRef.current) { mirrorRef.current.rotation.y += 0.03; } + mirrorMaterial.needsUpdate = true; }); return ( - + - );