new
This commit is contained in:
parent
d3b5111744
commit
da0d7ba0d2
11 changed files with 648 additions and 1 deletions
8
components/three/Models.tsx
Normal file
8
components/three/Models.tsx
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useGLTF } from '@react-three/drei';
|
||||||
|
|
||||||
|
export function Model({ url }: { url: string }) {
|
||||||
|
const { scene } = useGLTF(url);
|
||||||
|
return <primitive object={scene} />;
|
||||||
|
}
|
||||||
36
components/three/ShowcaseCanvas.tsx
Normal file
36
components/three/ShowcaseCanvas.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { Canvas } from '@react-three/fiber';
|
||||||
|
import { OrbitControls, Stage } from '@react-three/drei';
|
||||||
|
import { Suspense } from 'react';
|
||||||
|
import { EffectComposer, Bloom, Noise, Vignette } from '@react-three/postprocessing';
|
||||||
|
import { useAssetLoader } from '@/hooks/useAssetLoader';
|
||||||
|
import { Model } from './Model';
|
||||||
|
|
||||||
|
export default function ShowcaseCanvas() {
|
||||||
|
const { asset, loading, error } = useAssetLoader('/assets.json');
|
||||||
|
|
||||||
|
if (loading || error) return null;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="h-[500px] w-full border border-zinc-800 rounded-xl overflow-hidden bg-black">
|
||||||
|
<Canvas dpr={[1, 2]} shadows camera={{ fov: 45 }}>
|
||||||
|
<color attach="background" args={['#050505']} />
|
||||||
|
|
||||||
|
<Suspense fallback={null}>
|
||||||
|
<Stage intensity={0.5} environment="city">
|
||||||
|
{asset && <Model url={asset.modelUrl} />}
|
||||||
|
</Stage>
|
||||||
|
</Suspense>
|
||||||
|
|
||||||
|
<EffectComposer disableNormalPass>
|
||||||
|
<Bloom luminanceThreshold={1} mipmapBlur intensity={1.5} />
|
||||||
|
<Noise opacity={0.05} />
|
||||||
|
<Vignette eskil={false} offset={0.1} darkness={1.1} />
|
||||||
|
</EffectComposer>
|
||||||
|
|
||||||
|
<OrbitControls makeDefault />
|
||||||
|
</Canvas>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
24
hooks/useAssetLoader.ts
Normal file
24
hooks/useAssetLoader.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
'use client';
|
||||||
|
|
||||||
|
import { useState, useEffect } from 'react';
|
||||||
|
|
||||||
|
export function useAssetLoader(url: string) {
|
||||||
|
const [asset, setAsset] = useState<any>(null);
|
||||||
|
const [loading, setLoading] = useState(true);
|
||||||
|
const [error, setError] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch(url)
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => {
|
||||||
|
setAsset(data);
|
||||||
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
setError(true);
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
|
}, [url]);
|
||||||
|
|
||||||
|
return { asset, loading, error };
|
||||||
|
}
|
||||||
|
|
@ -9,9 +9,14 @@
|
||||||
"lint": "eslint"
|
"lint": "eslint"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@react-three/drei": "^10.7.7",
|
||||||
|
"@react-three/fiber": "^9.6.1",
|
||||||
|
"@react-three/postprocessing": "^3.0.4",
|
||||||
|
"@types/three": "^0.184.1",
|
||||||
"next": "16.2.7",
|
"next": "16.2.7",
|
||||||
"react": "19.2.4",
|
"react": "19.2.4",
|
||||||
"react-dom": "19.2.4"
|
"react-dom": "19.2.4",
|
||||||
|
"three": "^0.184.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tailwindcss/postcss": "^4",
|
"@tailwindcss/postcss": "^4",
|
||||||
|
|
|
||||||
567
pnpm-lock.yaml
generated
567
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
7
public/assets.json
Normal file
7
public/assets.json
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"id": "nike-shoe-001",
|
||||||
|
"name": "Nike Shoe",
|
||||||
|
"modelUrl": "/models/shoe.glb",
|
||||||
|
"category": "Footwear",
|
||||||
|
"price": 120.00
|
||||||
|
}
|
||||||
BIN
public/models/model.glb
Normal file
BIN
public/models/model.glb
Normal file
Binary file not shown.
BIN
public/textures/gltf_embedded_0.jpeg
Normal file
BIN
public/textures/gltf_embedded_0.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 MiB |
BIN
public/textures/gltf_embedded_1@channels=B.jpeg
Normal file
BIN
public/textures/gltf_embedded_1@channels=B.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
BIN
public/textures/gltf_embedded_1@channels=G.jpeg
Normal file
BIN
public/textures/gltf_embedded_1@channels=G.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 MiB |
BIN
public/textures/gltf_embedded_2.jpeg
Normal file
BIN
public/textures/gltf_embedded_2.jpeg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 MiB |
Loading…
Add table
Reference in a new issue