Awesome
WebGL Seed
A simple hello triangle example you could use to as a basis when starting WebGL.
Setup
First install:
-
A Text Editor such as Visual Studio Code.
Then type the following in any terminal your such as VS Code's Integrated Terminal.
# π Clone the repo
git clone https://github.com/alaingalvan/webgl-seed
# πΏ go inside the folder
cd webgl-seed
# π¨ Start building the project
npm start
Refer to this blog post on designing web libraries and apps for more details on Node.js, packages, etc.
Project Layout
As your project becomes more complex, you'll want to separate files and organize your application to something more akin to a game or renderer, check out this post on game engine architecture and this one on real time renderer architecture for more details.
ββ π node_modules/ # πΆ Dependencies
β ββ π gl-matrix # β Linear Algebra
β ββ π ... # π Other Dependencies (TypeScript, Webpack, etc.)
ββ π src/ # π Source Files
β ββ π renderer.ts # πΊ Triangle Renderer
β ββ π main.ts # π Application Main
ββ π .gitignore # ποΈ Ignore certain files in git repo
ββ π package.json # π¦ Node Package File
ββ π license.md # βοΈ Your License (Unlicense)
ββ πreadme.md # π Read Me!
Some key dependencies are:
-
gl-matrix - WebGL's best linear algebra library, perfect for people used to linear algebra libraries like GLM or the built in GLSL data structures.
-
Webpack - Compiles our TypeScript files and creates binaries for us to use.
-
TypeScript - JavaScript with types, makes it significantly easier to program web apps with instant autocomplete and type checking.