load texture
This commit is contained in:
		@@ -1,10 +1,14 @@
 | 
				
			|||||||
import { useThree, extend } from '@react-three/fiber'
 | 
					import { useThree, extend } from '@react-three/fiber'
 | 
				
			||||||
import { OrbitControls } from '@react-three/drei'
 | 
					import { OrbitControls, useTexture } from '@react-three/drei'
 | 
				
			||||||
import { DoubleSide } from 'three'
 | 
					import { DoubleSide } from 'three'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function Experience()
 | 
					export default function Experience()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  const { camera, gl } = useThree()
 | 
					  const { camera, gl } = useThree()
 | 
				
			||||||
 | 
					  // const harborSealRockTexture = useTexture('./MARS-Harbor-Seal-Rock-in-Jezero-Crater-cross-eyed-Manzoni_May-1662x2048.jpg')
 | 
				
			||||||
 | 
					  const goliathTexture = useTexture('https://tile.loc.gov/storage-services/service/pnp/stereo/1s00000/1s00000/1s00600/1s00612v.jpg')
 | 
				
			||||||
 | 
					  const texture = goliathTexture
 | 
				
			||||||
 | 
					  const {width, height} = texture.image
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return <>
 | 
					  return <>
 | 
				
			||||||
    <OrbitControls />
 | 
					    <OrbitControls />
 | 
				
			||||||
@@ -12,14 +16,9 @@ export default function Experience()
 | 
				
			|||||||
    <directionalLight position={ [ 1, 2, 3 ] } intensity={ 4.5 } />
 | 
					    <directionalLight position={ [ 1, 2, 3 ] } intensity={ 4.5 } />
 | 
				
			||||||
    <ambientLight intensity={ 1.5 } />
 | 
					    <ambientLight intensity={ 1.5 } />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    <mesh position-y={ 5 } scale={ 10 }>
 | 
					    <mesh position-y={ 5 } scale={ .01 }>
 | 
				
			||||||
      <planeGeometry />
 | 
					      <planeGeometry args={[width, height]}/>
 | 
				
			||||||
      <meshStandardMaterial color="blue" side={DoubleSide}/>
 | 
					      <meshStandardMaterial map={texture} side={DoubleSide} />
 | 
				
			||||||
    </mesh>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <mesh position-y={ - 1 } rotation-x={ - Math.PI * 0.5 } scale={ 10 }>
 | 
					 | 
				
			||||||
      <planeGeometry />
 | 
					 | 
				
			||||||
      <meshStandardMaterial color="grey" side={DoubleSide}/>
 | 
					 | 
				
			||||||
    </mesh>
 | 
					    </mesh>
 | 
				
			||||||
  </>
 | 
					  </>
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -11,7 +11,7 @@ root.render(
 | 
				
			|||||||
            fov: 45,
 | 
					            fov: 45,
 | 
				
			||||||
            near: 0.1,
 | 
					            near: 0.1,
 | 
				
			||||||
            far: 200,
 | 
					            far: 200,
 | 
				
			||||||
            position: [ - 4, 3, 6 ]
 | 
					            position: [ 0, 5, 20 ]
 | 
				
			||||||
        } }
 | 
					        } }
 | 
				
			||||||
    >
 | 
					    >
 | 
				
			||||||
        <Experience />
 | 
					        <Experience />
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user