2022-11-20 14:39:15 -07:00
|
|
|
import * as THREE from "three";
|
2022-11-24 01:00:06 -07:00
|
|
|
import React, { Suspense } from "react";
|
|
|
|
import { useLoader } from "@react-three/fiber";
|
2022-11-20 14:39:15 -07:00
|
|
|
|
|
|
|
interface ImagePlaneProps {
|
|
|
|
url: string;
|
2022-11-23 22:46:32 -07:00
|
|
|
height: number;
|
|
|
|
}
|
2022-11-20 14:39:15 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Draw an image on a plane geometry.
|
|
|
|
*/
|
|
|
|
export default function ImagePlane(props: ImagePlaneProps) {
|
|
|
|
const texture = useLoader(THREE.TextureLoader, props.url);
|
2022-11-23 22:46:32 -07:00
|
|
|
|
2022-11-20 14:39:15 -07:00
|
|
|
return (
|
|
|
|
<Suspense fallback={null}>
|
2022-11-24 01:00:06 -07:00
|
|
|
<mesh rotation-z={-Math.PI / 2} position-y={props.height}>
|
|
|
|
<planeGeometry attach="geometry" args={[5, 5]} />
|
2022-11-20 14:39:15 -07:00
|
|
|
<meshBasicMaterial attach="material" map={texture} />
|
|
|
|
</mesh>
|
|
|
|
</Suspense>
|
|
|
|
);
|
|
|
|
}
|