docsLiquid Ocean

Liquid Ocean

A mesmerizing Three.js animated ocean scene featuring flowing waves, floating boxes, and a rotating camera. Built with React Three Fiber, replicating the “Little Boxes” experiment.

Loading Preview...

Install using CLI

npx shadcn@latest add "https://www.vengenceui.com/r/liquid-ocean.json"

Install Manually

1

Install dependencies

npm install three @react-three/fiber @react-three/drei clsx tailwind-merge
2

Add util file

lib/utils.ts

import { ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
3

Copy the source code

Copy the code below and paste it into components/ui/liquid-ocean.tsx

"use client";
import React, { useRef, useMemo, useEffect } from "react";
import { Canvas, useFrame, useThree } from "@react-three/fiber";
import { RectAreaLightUniformsLib } from "three/examples/jsm/lights/RectAreaLightUniformsLib.js";
import * as THREE from "three";
import { cn } from "@/lib/utils";
// Initialize RectAreaLight uniforms
if (typeof window !== "undefined") {
RectAreaLightUniformsLib.init();
}
// ... Full component source available via CLI install

Usage

1import { LiquidOcean } from "@/components/ui/liquid-ocean"
2
3// Basic usage - exact original appearance
4export function Example() {
5return (
6 <div className="relative h-[500px] w-full">
7 <LiquidOcean>
8 <h1 className="text-white text-6xl">Liquid</h1>
9 </LiquidOcean>
10 </div>
11);
12}
13
14// Custom theme colors
15export function CustomColors() {
16return (
17 <LiquidOcean
18 backgroundColor={0x0a1a1a}
19 accentColor={0x00ffff}
20 boatCount={7}
21 />
22);
23}

Examples

Minimal Ocean (No Boats, No Grid)

Loading Preview...

Cyan Theme

Loading Preview...

Purple Theme

Loading Preview...

Sunset Theme

Loading Preview...

Matrix Theme

Loading Preview...

Calm Waters

Loading Preview...

High Detail Mode

Loading Preview...

Props

Prop NameTypeDefaultDescription
classNamestring-Additional CSS classes for the container.
backgroundColornumber0x000000Background color as hex number (e.g., 0x000000 for black).
accentColornumber0xF00589Accent color for ocean, boats, and lights (original pink).
gridColornumber0x333333Grid helper line color.
fovnumber20Camera field of view.
rotationSpeednumber0.001Scene rotation speed per frame.
showGridbooleantrueShow the grid helper.
showBoatsbooleantrueShow floating boxes/boats.
boatCountnumber5Number of floating boxes.
boatSpreadnumber5Spread range for floating boxes.
oceanSizenumber25Ocean plane size.
oceanFragmentsnumber25Ocean geometry subdivisions. Higher = more detail.
waveAmplitudenumber0.2Maximum wave height.
waveSpeednumber0.05Wave animation speed multiplier.
showWireframebooleantrueShow wireframe overlay on ocean.
oceanOpacitynumber0.85Ocean surface opacity (0-1).
childrenReact.ReactNode-Overlay content to display on top of the ocean.

Features

3D Animated Ocean: Flowing wave animation with configurable speed and amplitude

Floating Boxes: Animated boxes that bob and tilt with the waves

Fully Customizable: Change colors, wave settings, boat count, and more

Multiple Themes: Create any color scheme with hex color props

React Three Fiber: Built with modern React 3D patterns for optimal performance

Overlay Support: Add any content on top of the ocean scene