jsonxr / webgfx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

webgfx

A graphics library inspired by three.js compiled to WebAssembly. The goal of this library is to be as fast as possible to write 3d graphics in a browser from javascript. This library can not achieve this goal until the interface-types proposal (formally known as host bindings) is implemented. Without this, there is a lot of marshalling between js and WebAssembly.

How to install

npm install webgfx

How to use

index.html

<html>
<body>
  <script module="index.js">
  <canvas id="canvas"></canvas>
</body>
</html>

index.js

import { BoxGeometry, Mesh, MeshBasicMaterial, PerspectiveCamera, Renderer, Scene } from 'webgfx';

// 1. Build the Scene
const geometry = new BoxGeometry(1, 1, 1);
const material = new MeshBasicMaterial();
const cube = new Mesh(geometry, material);
const scene = new Scene();
scene.add(cube);

// 2. Render the Scene statically (not in an animation loop)
const camera = new PerspectiveCamera();
let renderer = new WebGLRenderer({ canvas: document.getElementById('canvas') });
//     let renderer = new WebGLRenderer();

renderer.render(scene, camera);

Future

This library probably isn't usable until the following are implemented fully:

About

License:MIT License


Languages

Language:Rust 84.4%Language:JavaScript 12.1%Language:HTML 2.4%Language:GLSL 1.0%