π»ν λ‘μμ λ§μ΄ν΄ ThreeJS Drei λΌμ΄λΈλ¬λ¦¬λ₯Ό νμ©νμ¬ μΌμ€μ€ν 곡λλ¬μ§ λ§λ€κΈ°, Float, Sparkles, GodRays(μ€μ!) νμ΅νκΈ° μν΄ μ μλ κ°μΈ 곡λΆμ©
νλ‘μ νΈ
μ°μ , GodRays
λ? μ§μ κ·Έλλ‘ μ μ μ§μ¬κ΄μ μ μλ―Ένλ©° μ λ°©μ νΌμ¬μ²΄μ κ°λ €μ§λ λΉμ μλ―Ένλ€.
const mesh = new Mesh(
new CylinderGeometry(0.3, 0.3, 0.2, 20),
new MeshBasicMaterial({
color: lightColor,
transparent: true,
opacity: 1,
})
);
<GodRays
sun={mesh} // κ΄μ, νμ¬ νλ‘μ νΈμμ μλΏν 물체μ κΈ°λ³Έ μ§κ°μ μ
ν μ¬μ©νμμ(ν¬νΈ λ΄λΆ μ΅μλ¨ κ΄μ)
blendFunction={BlendFunction.Screen} // νλ©΄ μ 체μ μ μ©
samples={40} //
density={0.97} // λΉμ λ°λ, μΌλ§λ νΌμ§λ
decay={0.97} // 거리μ λ°λ₯Έ λλΆμ¬μ κ°μ λ
weight={0.6} // λΉμ μ
exposure={0.3} // λ
ΈμΆ, λΉμ λ°κΈ°
clampMax={1} // κ΄μμ μ΄λ
width={Resizer.AUTO_SIZE} // κ°λ‘ ν
height={Resizer.AUTO_SIZE} // μΈλ‘ ν
kernelSize={KernelSize.SMALL} // blur ν¬κΈ°
blur={true} // blur μ¬λΆ
/>
νμλͺ¨λ μ€μΉ
npm install
λ‘컬νκ²½μ μ€ν (localhost:5173)
npm run dev
- Framework
- React(Vite)
- "react": "^18.2.0"
- React(Vite)
- etc
- ThreeJS
- "@react-three/drei": "9.14.3",
- "@react-three/fiber": "8.0.26",
- "@react-three/postprocessing": "2.4.4",
- ThreeJS
μ΄μμ¬νμ λ±λ‘ν΄μ£Όμλ©΄ λ°λ‘ νμΈν΄λ³΄κ² μ΅λλ€.
2023-11-08
λ°°ν¬ λ° μ μλμ νμΈ