utahpot
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

UtahPot

BETA. Use at your own risk

Library and documentation are under active development

You can find developers, join team, leave issues or suggestions on GitHub or Reddit

This repository contains UtahPot library, which help when using WebGPU (WGPU) in your projects.

To install:
npm i utahpot

Here is the example of using this library on our landing page.
Here is the base project to use with Utahpot.
Here is the documentation for WebGPU

We reccomend to use this architecture:

Architecture

Documentation:

Camera
  • position: vec3 -> position of this camera in the scene
  • eulers: vec3 -> euler angles / tilt of this camera
  • view: mat4 -> visible part of the scene for this camera in frame
  • forwards, right, up: vec3 -> camera movement information

constuctor(position: vec3, thetha: number, phi: number)

Creates a new camera at the "position" with "eulers" of "thetha" and "phi"

update()

Updates all info about camera for new frame

get_view()

Returns "view"

get_position() / set_position(position: vec3)

Returns or sets "position"

get_eulers() / set_eulers(eulers: vec3)

Returns or sets "eulers"

spin_camera(dX: number, dY: number)

Tilts the camera along X and Y axes for "dX" and "dY" degrees

move_camera(forwards_amount: number, right_amount: number, up_amount: number)

Moves camera for "forwards_amound", "right_amount", "up_amount"

♦ Light
  • position: vec3 -> position of this light in the scene
  • eulers: vec3 -> euler angles / tilt of this light
  • forwards, right, up: vec3 -> light movement information

constuctor(position: vec3)

Creates a new light at the "position"

update()

Updates all info about light for new frame

get_position() / set_position(position: vec3)

Returns or sets "position"

get_eulers() / set_eulers(eulers: vec3)

Returns or sets "eulers"

move_camera(forwards_amount: number, right_amount: number, up_amount: number)

Moves light for "forwards_amound", "right_amount", "up_amount"

Triangle / Quad / Subject
  • position: vec3 -> position of this object in the scene
  • eulers: vec3 -> euler angles / tilt of this object
  • model: mat4 -> object model information

constuctor(position: vec3)

Creates a new object at the "position"

update()

Updates all info about object for new frame

get_model()

Returns "model"

get_position() / set_position(position: vec3)

Returns or sets "position"

get_eulers() / set_eulers(eulers: vec3)

Returns or sets "eulers"

rotateX(deg: number) / rotateY(deg: number) / rotateZ(deg: number)

Rotates the object for "deg" degrees

Material
  • texture?: GPUTexture
  • view?: GPUTextureView
  • sampler?: GPUSampler
  • bindGroup?: GPUBindGroup

initialize(device: GPUDevice, url: string, bindGroupLayout)

Initializing a new Material(texture) from "url" for the "device" with "bindGroupLayout"

Triangle_mesh / Quad_mesh
  • buffer: GPUBuffer
  • bufferLayout: GPUVertexBufferLayout

constructor(device: GPUDevice)

Creates a new mesh for the "device"

♦ Obj_mesh
  • buffer?: GPUBuffer
  • bufferLayout: GPUVertexBufferLayout
  • v: vec3[] -> vertexes
  • vt: vec2[] -> uv coords
  • vn: vec3[] -> normals
  • vertices?: Float32Array -> all faces data in a row
  • vertexCount?: number -> number of vertices

constructor()

Creates an empty obj file mesh

initialize(device: GPUDevice, url: string)

Initializing a new .obj file mesh from "url" for the "device" ready for rendering

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.42latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.42
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i utahpot

Weekly Downloads

2

Version

1.0.4

License

MIT

Unpacked Size

37.8 kB

Total Files

27

Last publish

Collaborators

  • tarasnar
  • helotan
  • saerafi