feat: water shader with Fresnel, caustics & light shafts (#3)

This commit is contained in:
2026-10-06 19:10:31 +00:00
parent 4492b7ace8
commit b7489af394
2 changed files with 221 additions and 0 deletions
+5
View File
@@ -1,5 +1,6 @@
import * as THREE from "three";
import { createTank } from "./scene/Tank";
import { createWater } from "./scene/Water";
import { setupLighting } from "./scene/Lighting";
const canvas = document.querySelector<HTMLCanvasElement>("#aquarium");
@@ -28,6 +29,7 @@ camera.lookAt(0, 1.2, 0);
// Scene content
setupLighting(scene, renderer);
createTank(scene);
const water = createWater(scene);
// Resize handling
function resize(): void {
@@ -42,8 +44,11 @@ resize();
window.addEventListener("resize", resize);
// Render loop
const startTime = performance.now();
function animate(): void {
requestAnimationFrame(animate);
const time = (performance.now() - startTime) / 1000;
water.update(time);
renderer.render(scene, camera);
}
animate();