A modern WebGPU-based alternative to Curtains.js for creating interactive planes and stunning visual effects.
- WebGPU-powered: Leverages the modern WebGPU API for exceptional performance
- Easy-to-use API: Simple, intuitive interface similar to Curtains.js
- Texture Support: Load images, videos, and create procedural textures
- Uniform System: Full support for custom shaders with uniforms
- Auto-resize: Automatic canvas resizing with observer support
- TypeScript: Full TypeScript support with comprehensive type definitions
- Modern Architecture: Clean, modular codebase built for extensibility
npm install podiumjsimport { Podium } from 'podiumjs';
// Create a canvas element
const canvas = document.querySelector('#canvas');
// Initialize PodiumJS
const podium = new Podium({
canvas: canvas,
backgroundColor: [0.1, 0.1, 0.2, 1.0],
autoResize: true
});
// Initialize WebGPU context
await podium.initialize();
// Create a textured plane
await podium.createPlane(
'myPlane',
'path/to/image.jpg',
{ width: 2.0, height: 1.0 } // plane options
);
// Start rendering
podium.startRenderLoop();// Create a plane with uniform support for animations
await podium.createUniformPlane(
'animatedPlane',
'path/to/texture.jpg'
);
// Update transform
podium.setTransform('animatedPlane', {
position: [0.5, 0.2, 0],
scale: [1.2, 1.2, 1],
rotation: [0, 0, 0]
});
// Custom uniform updates (time-based animation is automatic)
podium.updateUniforms('animatedPlane', {
customValue: 0.5,
mousePosition: [mouseX, mouseY]
});Main class that orchestrates rendering and scene management.
interface PodiumOptions {
canvas: HTMLCanvasElement;
powerPreference?: 'low-power' | 'high-performance';
backgroundColor?: [number, number, number, number];
autoResize?: boolean;
alphaMode?: 'opaque' | 'premultiplied';
}Methods:
initialize(): Promise<boolean>- Initialize WebGPU contextcreatePlane(id, imageUrl, options?): Promise<RenderObject>- Create basic textured planecreateUniformPlane(id, imageUrl, options?): Promise<RenderObject>- Create plane with uniform supportsetTransform(id, transform): boolean- Update object transformupdateUniforms(id, data): boolean- Update uniform valuesstartRenderLoop(): void- Start the render loopstopRenderLoop(): void- Stop the render loopdestroy(): void- Clean up resources
Manages WebGPU device and context initialization.
Handles WGSL shader compilation and pipeline management.
Manages texture loading and GPU resource creation.
Handles uniform buffer management and matrix operations.
PodiumJS uses WGSL (WebGPU Shading Language) for shaders:
struct VertexInput {
@location(0) position: vec3f,
@location(1) uv: vec2f,
};
struct VertexOutput {
@builtin(position) position: vec4f,
@location(0) uv: vec2f,
};
@vertex
fn vs_main(input: VertexInput) -> VertexOutput {
var output: VertexOutput;
output.position = vec4f(input.position, 1.0);
output.uv = input.uv;
return output;
}@group(0) @binding(0) var mainTexture: texture_2d<f32>;
@group(0) @binding(1) var mainSampler: sampler;
@fragment
fn fs_main(@location(0) uv: vec2f) -> @location(0) vec4f {
return textureSample(mainTexture, mainSampler, uv);
}# Clone the repository
git clone https://github.com/vdmo/podiumjs-rocks.git
cd podiumjs
# Install dependencies
npm install
# Build the library
npm run build
# Run development server
npm run devsrc/
โโโ core/ # Core classes (Podium, WebGPUContext, UniformManager)
โโโ geometry/ # Geometry classes (Plane)
โโโ shaders/ # Shader management
โโโ textures/ # Texture management
โโโ utils/ # Utility functions
โโโ index.ts # Main entry point
examples/ # Example projects
โโโ basic.html # Basic usage example
โโโ advanced.html # Advanced features demo
- WebGPU Support: Chrome 113+, Firefox Nightly, or Safari Technology Preview
- Modern Browser: ES2020 support required
- HTTPS: Required for WebGPU in production
| Browser | Version | Status |
|---|---|---|
| Chrome | 113+ | โ Stable |
| Edge | 113+ | โ Stable |
| Firefox | Nightly | ๐งช Experimental |
| Safari | TP | ๐งช Experimental |
| Feature | PodiumJS | Curtains.js |
|---|---|---|
| Graphics API | WebGPU | WebGL |
| Performance | Higher (lower overhead) | Good |
| Shader Language | WGSL | GLSL |
| Memory Management | Explicit | Implicit |
| Browser Support | Modern browsers | Wider support |
| Bundle Size | ~50KB | ~80KB |
- Post-processing pipeline - Built-in effects and filters
- Video texture support - Enhanced video handling
- Compute shader support - GPU computing capabilities
- Animation system - Timeline-based animations
- Physics integration - Basic physics simulation
- Particle system - GPU-accelerated particles
- 3D model loading - GLTF/OBJ support
- VR/AR support - WebXR integration
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Curtains.js by Martin Laxenaire
- WebGPU specification by the W3C GPU for the Web Working Group
- WGSL reference implementation
Built by vdmo with โค๏ธ for the modern web
GitHub โข