0.0.10 • Published 4 months ago

madrid v0.0.10

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

Madrid

Minimal WebGPU Framework

Installation

yarn add madrid

Usage

struct Uniforms { mvp: mat4x4f }
struct VertexOutput { @builtin(position) position: vec4f }

@binding(0) @group(0) var<uniform> uniforms: Uniforms;

@vertex fn main( @location(0) position: vec4f ) -> VertexOutput {
  return VertexOutput(uniforms.mvp * position);
}
@fragment fn main() -> @location(0) vec4f {
  return vec4f(0, 0, 0, 0.4);
}
import { Camera, Mesh, Scene, Pipeline, Setup, Render, Plane } from 'madrid'
import vs from './vs.wgsl'
import fs from './fs.wgsl'

onload = async () => {
  const gpu = new Setup()
  await gpu.create()

  const camera = new Camera()
  const geometry = new Plane()
  const mesh = new Mesh({ gpu, geometry })

  const scene = new Scene({ gpu, camera, mesh })
  const pipeline = new Pipeline({ gpu, vs, fs, scene })
  const render = new Render({ gpu, pipeline, scene })

  render.raf(() => {
    mesh.rotation.x += 0.01
    scene.update()
  })
}
0.0.10

4 months ago

0.0.9

6 months ago

0.0.8

6 months ago

0.0.7

6 months ago

0.0.6

6 months ago

0.0.5

6 months ago

0.0.4

6 months ago

0.0.3

6 months ago

0.0.2

6 months ago

0.0.1

6 months ago