# beam
**Repository Path**: mirrors_doodlewind/beam
## Basic Information
- **Project Name**: beam
- **Description**: ✨ Expressive WebGL
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 1
- **Created**: 2022-01-10
- **Last Updated**: 2026-05-10
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Beam
Expressive WebGL

中文介绍
* [如何设计一个 WebGL 基础库](https://zhuanlan.zhihu.com/p/93500639)
* [实用 WebGL 图像处理入门](https://zhuanlan.zhihu.com/p/100388037)
* [WebGL 版康威生命游戏](https://zhuanlan.zhihu.com/p/197675822)
## Introduction
Beam is a tiny (~10KB) WebGL library. It's **NOT** a renderer or 3D engine by itself. Instead, Beam provides some essential abstractions, allowing you to build WebGL infrastructures within a very small and easy-to-use API surface.
The WebGL API is known to be verbose, with a steep learning curve. Just like how jQuery simplifies DOM operations, Beam wraps WebGL in a succinct way, making it easier to build WebGL renderers with clean and terse code.
How is this possible? Instead of just reorganizing boilerplate code, Beam defines some essential concepts on top of WebGL, which can be much easier to be understood and used. These highly simplified concepts include:
* **Shaders** - Objects containing graphics algorithms. In contrast of JavaScript that only runs on CPU with a single thread, shaders are run in parallel on GPU, computing colors for millions of pixels every frame.
* **Resources** - Objects containing graphics data. Just like how JSON works in your web app, resources are the data passed to shaders, which mainly includes triangle arrays (aka buffers), image textures, and global options (uniforms).
* **Draw** - Requests for running shaders with resources. To render a scene, different shaders and resources may be used. You are free to combine them, so as to fire multi draw calls that eventually compose a frame. In fact, each draw call will start the graphics render pipeline for once.
So there are only 3 concepts to learn, represented by 3 core APIs in Beam: **beam.shader**, **beam.resource** and **beam.draw**. Conceptually only with these 3 methods, you can render a frame with WebGL.
If you are a beginner, you can check out the tutorial below to get started. For API definitions, please refer to [index.d.ts](./src/index.d.ts).
## Installation
``` bash
npm install beam-gl
```
Or you can clone this repository and start a static HTTP server to try it out. Beam runs directly in modern browser, without any need to build or compile.
## Hello World with Beam
Now we are going to write a simplest WebGL app with Beam, which renders a colorful triangle:

Here is the code snippet:
``` js
import { Beam, ResourceTypes } from 'beam-gl'
import { MyShader } from './my-shader.js'
const { VertexBuffers, IndexBuffer } = ResourceTypes
// Remember to create a `