如何从链接加载纹理 - 没有 React 导入?任务是:制作一个圆圈,其中会有一张从后端链接中拍摄的人的照片......
import React from "react";
import { usePlane } from "@react-three/cannon";
import { useLoader } from "@react-three/fiber";
import { TextureLoader } from "three/src/loaders/TextureLoader";
import gamerPhoto from "./../../../assets/images/profile_pictures/Regular_face_1.png";
const Gamer = ({texture, refGamer}) => {
// Работает, но с импортом мне не надо
const texture = useLoader(TextureLoader, gamerPhoto);
// Не работает Uncaught Could not load ./../../../assets/images/profile_pictures/Regular_face_1.png: undefined
const texture = useLoader(TextureLoader, "./../../../assets/images/profile_pictures/Regular_face_1.png");
// Ни относительно файла, ни относительно reducer, ни просто ссылка, ни прямая http ссылка взятая с гугла (в браузере открывается):
// "./../../../assets/images/profile_pictures/Regular_face_1.png"
// "./../assets/images/profile_pictures/Regular_face_1.png"
// "assets/images/profile_pictures/Regular_face_1.png"
// "https://codeworkshop.dev/static/8a5b2989e06c0d8376faabd9a879dbf9/fcb16/frontendbackend.jpg"
const [refGamer] = usePlane(() => ({
position: [0, 0, 0],
}));
return (
<mesh ref={refGamer}>
<circleGeometry args={[1, 35]} />
<meshStandardMaterial map={texture} />
</mesh>
);
};