• Stars
    star
    878
  • Rank 51,998 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 5 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WebGL in WebAssembly with AssemblyScript

LUME

GLAS

WebGL in WebAssembly with AssemblyScript.

This is a work-in-progress port of Three.js, a JavaScript 3D WebGL library, into AssemblyScript.

Motivation

It'd be sweet to have a high-performing WebGL engine that runs in the web via WebAssembly and is written in a language that web developers are already familiar with: JavaScript, in the form of TypeScript (a superset of JavaScript with types).

Enter AssemblyScript, a toolchain that allows us to write a strictly-typed subset of TypeScript code and compile it to WebAssembly (an assembly-like language representing machine code) for speed.

Status

⚠️ ALPHA STATE

The project is currently in its very early alpha stages. We have an amazing group of programmers building the initial ASWebGLue library. This library allows AssemblyScript programs to call the browser's underlying WebGL interface. This is required before we are able render anything to the screen. A majority of the Three.js library and their unit test have been ported over.

See the current progress in the project board or review our issues.

Goal

Our initial port project board we're tracking all the classes that need to be ported. The initial goal is to reproduce the following basic Three.js demo, but entirely in AssemblyScript:

Initial Goal: https://codepen.io/trusktr/pen/EzBKYM

Contribute

A brief overview of the work consists of picking a Three.js class, translating it from JavaScript (with TypeScript declaration files), and porting into AssemblyScript (effectively merging the .js and .d.ts files).

Most logic can be ported unchanged, but sometimes there are features of plain JS that AssemblyScript does not support. For example Assembly script does not support any type. Three.js APIs that accept plain object literals with arbitrary properties need to be converted into class structures with specific property types. Additionally unit test files also need to be ported over from *.test.js and into as-pect *.spec.ts files.

If you would like to help, awesome! We are currenty looking for help, testing, and feedback. Please read about how to contribute or view a detailed example of how to port some of the code.

How It Works

We have an HTML page that loads the glas WebAssembly module and runs it, but so far this module only instantiates an Object3D instance to show that we're able to run the module.

Later we'll eventually connect the module to a <canvas> element in the DOM and actually render something.

Build & Run

To run the example GLAS application in your browser use the following command:

# install or update dependencies
npm install

# build and serve the project in browser
npm start

Now see the devtools console in your browser tab for some output that tell us that our GLAS program has been loaded and initialized.

NOTE: the project does not currently have a watch mode with automatic rebuild. So you will need to execute npm run build again and then refresh to see the changes.

Our goal is to get GLAS distributed as a library on NPM so that you can include into your own AssemblyScript application. Until this is implemented, you can add your application code into the src/as/index.ts AssemblyScript file. This is currently the entry point for GLAS.

Testing

Unit testing is handled by the as-pect test runner for AssemblyScript. It is based on Mocha testing API with similar describe and it functions, etc.

To run the tests, run the following commands in your terminal:

# run unit tests
npm test

The console output should report which tests pass and which tests fail.

Development

If you are interested in developing GLAS please read the detailed process on our development page

More Repositories

1

lume

Create 3D web applications with HTML. Bring a new depth to your DOM!
TypeScript
1,334
star
2

autolayout

Apple's Auto Layout and Visual Format Language for JavaScript (using cassowary constraints)
TypeScript
306
star
3

element

Fast and simple custom elements.
TypeScript
122
star
4

element-behaviors

An entity-component system for HTML elements.
TypeScript
103
star
5

asdom

Use DOM APIs in AssemblyScript
TypeScript
92
star
6

classy-solid

Solid.js reactivity patterns for classes, and class components. See https://github.com/lume/element for a Custom Element system built with classy-solid.
TypeScript
56
star
7

three-instanced-mesh

A better InstancedMesh class for Three.js
JavaScript
15
star
8

variable

DEPRECATED, use https://solidjs.com and https://github.com/lume/classy-solid directly instead. Create reactive variables and observe their changes in a simple and concise way with less code and less coupling.
TypeScript
13
star
9

live-code

`<live-code>` element to display editable code with live output. Demo:
TypeScript
11
star
10

animation-loop

Easily make and manage animation loops.
JavaScript
11
star
11

basicss

Better default CSS styling for the browser's builtin elements.
HTML
8
star
12

cli

A CLI for managing TypeScript packages.
JavaScript
6
star
13

three-projected-material

A Three.js material that projects a texture onto an object
TypeScript
6
star
14

code-mirror-el

A customizeable <code-mirror> element that makes a code editor powered by CodeMirror. Use it in React, Vue, Svelte, Solid, etc. Demo:
TypeScript
5
star
15

website

JavaScript
3
star
16

eventful

A class (or mixin) whose instances emit events that external code can subscribe to.
TypeScript
2
star
17

showcase

WIP, showcase page that will show projects made with Lume
TypeScript
2
star
18

stack

A full-stack foundation for building real-time interactive applications.
1
star
19

readem

Read the !@#$%^& docs! (WIP)
TypeScript
1
star