• Stars
    star
    469
  • Rank 93,595 (Top 2 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 2 years ago
  • Updated 3 months ago

Reviews

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

Repository Details

A suite of libraries for making game development with Three.js and React not only awesome, but so good, it would feel wrong to use anything else.

Composer Suite Contributor Covenant

A suite of libraries for making game development with Three.js and React not only awesome, but "so good, it would feel wrong to use anything else." – hmans

Building games with React and Three.js is already pretty cool, but a lot of tooling you need to make those games really nice is still missing. This project tries to fill some of these gaps by providing a collection of libraries for various aspects of game development, from GPU-driven particle systems and VFX, to game UI, editor tooling, camera rigs, audio, multi-device input, and more.

Note While this suite of libraries targets building games with React and React-Three-Fiber, some of them can also be used outside of React, just like some others are not specific to Three.js or React-Three-Fiber. But building games with React is where our hearts are at, which is why you will find most example code in this document to be written in React. 😎

Sponsors ❤️

This project wouldn't be possible without the support from its lovely sponsors. If you'd like to sponsor this project and help make game development with React & Three.js incredible, click here!

Kenneth PirmanStefan StübenJorgen HookhamDarrin MassenaGonzalo Martinesebp

Getting Started

Most of the packages in this repository are under heavy development, and even though I regularly push new bits to NPM, expect much of it to be largely undocumented and unstable, particularly anything that has yet to reach version 1.0.0.

If you'd like to give this stuff a try today, the easiest way would be to either clone this repository to your local computer and run one of the many example apps (or the demo game, Space Rage; see below). Alternatively, you can also open this repository on CodeSandbox and play with the code there!

Space Rage

spacerage-banner

The development of the Composer Suite is primarily driven by that of Space Rage, an open-source top-down twin-stick shooter game that is also intended to be a showcase for the libraries here.

Packages 📦

Shader Composer
react vanilla three

Shader Composer takes a graph of nodes (here called "units") and compiles it to a working GLSL shader. It provides a library of ready-to-use shader units, but you can, of course, add your own. Parameterized sub-graphs of your shaders can be implemented as plain JavaScript functions.

const ShaderComposerExample = () => {
  const shader = useShader(() =>
    ShaderMaterialMaster({
      color: pipe(
        Vec3(new Color("red")),
        (v) => Mix(v, new Color("white"), NormalizePlusMinusOne(Sin(Time()))),
        (v) => Add(v, Fresnel())
      )
    })
  )

  return (
    <mesh>
      <sphereGeometry />
      <shaderMaterial {...shader} />
    </mesh>
  )
}

material-composer-thin
react vanilla three

Material Composer provides a mechanism to hook into Three.js materials and customize their behavior using a sequence of material modules. Modules are higher-level implementations of Shader-based functionality, and implemented using Shader Composer. Material Composer provides a library of these material modules that are easy to extend and customize; but, as always, you can add your own.

const MaterialComposerExample = () => (
  <mesh position-y={1.5} castShadow>
    <sphereGeometry />

    <Composable.MeshStandardMaterial>
      <Modules.Color color="#d62828" />

      <Layer opacity={NormalizePlusMinusOne(Sin(Time()))}>
        <Modules.Color color="#003049" />
      </Layer>

      <Modules.Fresnel intensity={0.2} />
    </Composable.MeshStandardMaterial>
  </mesh>
)

VFX Composer
react vanilla three

TODO

timeline-composer-thin
react

Timeline Composer provides a small, but powerful collection of React components that can be used to orchestrate an animation sequence:

<Lifetime seconds={5}>
  <SmokeRing />
  <Fireball />

  <Delay seconds={0.3}>
    <CameraShake decay />
    <Fireball />

    <Delay seconds={0.2}>
      <Rocks />
      <SmokeCloud />
    </Delay>
  </Delay>
</Lifetime>

Render Composer

react three

A preconfigured, opinionated render pipeline for your React-Three-Fiber games.

TODO

Input Composer

react vanilla

Composable multi-device game input.

TODO

UI Composer

react

Screen-space UI for games and game tooling.

TODO

Camera Composer

react vanilla three

Composable camera automation.

TODO

State Composer

react

Helpers for managing game state.

TODO

Development 🛠

Repository Structure

The repository is structured as a monorepo. You will find all packages that are part of the Composer Suite inside the packages directory, and a collection of applications (examples and otherwise) inside apps.

Development Mode

This repository uses Preconstruct for building packages and providing a development environment. To start the development environment, run:

pnpm dev:link

This will cause Preconstruct to link all apps and packages together so they consume each others' TypeScript source, allowing you to modify code without having to rebuild after every change.

Running Example Apps

Use the pnpm dev task to start up all available apps in development mode, or supply a --filter argument to just start one of them. Examples:

# Start all apps
pnpm dev

# Start individual apps
pnpm dev --filter spacerage
pnpm dev --filter vfx-composer-examples
pnpm dev --filter shader-composer-examples

Note The pnpm dev task uses Turborepo. Please refer to their CLI Documentation to learn about additional options.

Core Tenets

All of the libraries in the Composer Suite are aiming for the following:

  • Authored in and for TypeScript.
    All libraries are authored in TypeScript, with first-class type support. This means that you can use these libraries in JavaScript, but you will get the best experience when using TypeScript. If you're using them from within JavaScript, please be aware that these libraries will not make any significant effort to provide runtime type checking or similar.
  • Flawless HMR.
    The libraries should provide a fun and flawless development experience with the best support for hot-module reloading possible. The user should be able to hot-reload their code and see the changes immediately in the browser. Where possible, state should be retained; there must never be errors when hot-reloading.
  • Prefer Declarative over Imperative.
    Where possible, allow the user to declare logic and data using JSX, instead of forcing them out of the declarative JSX layer and towards hooks (or even further into the imperative world.)
  • Usable Individually, and Together.
    Where possible, libraries should be designed so they can be used individually, but also together.

License 👩‍⚖️

Copyright (c) 2022 Hendrik Mans

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

miniplex

A 👩‍💻 developer-friendly entity management system for 🕹 games and similarly demanding applications, based on 🛠 ECS architecture.
TypeScript
827
star
2

three-elements

Web Components-powered custom HTML elements for building Three.js-powered games and interactive experiences. 🎉
TypeScript
398
star
3

slodown

Markdown + oEmbed + Sanitize + CodeRay = the ultimate user input rendering pipeline!
Ruby
251
star
4

rbfu

Minimal Ruby version management is minimal.
Shell
118
star
5

shader-composer

80
star
6

schnitzelpress

A lean, mean blogging machine for hackers and fools.
Ruby
77
star
7

statery

Surprise-Free State Management! Designed for React with functional components, but can also be used with other frameworks (or no framework at all.)
TypeScript
72
star
8

happy

A happy little toolkit for writing web applications.
Ruby
66
star
9

pants

PANTS: Distributed Social Blogging.
Ruby
64
star
10

controlfreak

Composable Game Input.
TypeScript
59
star
11

flutterby

A flexible, Ruby-powered static site generator.
Ruby
57
star
12

timeline-composer

Compose React timelines from <Repeat>, <Delay> and <Lifetime>.
19
star
13

eventery

Super-lightweight event class implementation. 🚀
TypeScript
19
star
14

Godot-RigidBody-Auto-Scaler

Want to scale rigidbodies in Godot? Now you can. 🚀
GDScript
17
star
15

allowance

Allowance is a general-use permission management library for Ruby. It's decidedly simple, highly flexible, and has out-of-the-box support for ActiveModel-compliant classes.
Ruby
16
star
16

space-scene-sandbox

TypeScript
15
star
17

indiepants

IndiePants, aka Pants Phase 2. A clean indieweb-like implementation.
Ruby
13
star
18

hamburg-io

A hub for the Hamburg tech community.
Ruby
10
star
19

trinity

TypeScript
9
star
20

trinity-legacy

TypeScript
7
star
21

create-react-game

JavaScript
7
star
22

godot-survival-guide

Assorted Workarounds and Dirty Hacks for Stuff That's Missing, Broken, or Otherwise Weird in the Godot Engine
7
star
23

things

TypeScript
7
star
24

signal

TypeScript
6
star
25

react-game-starter

TypeScript
5
star
26

bigby-legacy

TypeScript
5
star
27

crankypants

A thing that does things.
Crystal
5
star
28

Godot-ParticlesPortal

GDScript
4
star
29

spacerage-one

Dumb little web-based space shootybang. (Yes, that's an actual genre.)
CoffeeScript
4
star
30

material-composer

4
star
31

awesome-freelancing-germany

Nützliche Ressourcen für Freelancer in Deutschland.
4
star
32

three-vfx-starter

JavaScript
4
star
33

supermutant

EMBRACE THE MUTATION and turn any JavaScript object into a SUPERMUTANT REACTIVE STATE CONTAINER. UUUAAAAAHHHHHHHHHHHRRRRRR
TypeScript
4
star
34

lit-shootybang

JavaScript
3
star
35

schnitzelpress-skeleton

Schnitzelpress Skeleton App. Clone/fork/download this as a base for your own Schnitzelpress powered blog.
Ruby
3
star
36

solid-trinity

TypeScript
3
star
37

spacerage.liveview

Phoenix + LiveView + three-elements = ?
Elixir
3
star
38

spacerage.6dof

Space pew pew using react-three-fiber.
TypeScript
3
star
39

fantasy-js-physics-engine

2
star
40

hmansify

Some stuff from my home directory.
Ruby
2
star
41

happy-resources

A collection of resource-focused controllers for the Happy Web Application Toolkit.
Ruby
2
star
42

ingrid

Spatial Hash Grids and not much else.
TypeScript
2
star
43

bumpy

Bumpy bumps your gem's version number.
Ruby
2
star
44

webmade.games

https://webmade.games
Astro
2
star
45

hmans_me

My blog, as seen on http://hmans.io. Powered by Flutterby.
CSS
2
star
46

randomish

TypeScript
2
star
47

render-composer

2
star
48

flutterby-website

The official website for Flutterby.
Ruby
2
star
49

indiepants-docker

Docker & Fig configuration for painless IndiePants deployment.
2
star
50

playground

A collection of experimental react-three-fiber tools and toys that aren't quite ready to be released as their own packages.
JavaScript
2
star
51

particulous

A playground for exploring patterns around CPU-based particle systems.
TypeScript
2
star
52

shadenfreude-planet

Created with CodeSandbox
TypeScript
2
star
53

bevy-mrp-macos-performance

Rust
2
star
54

panties

Command line client for #pants.
Ruby
1
star
55

happy-helpers

[Deprecated!] View helpers for your custom Rack app or framework.
Ruby
1
star
56

publicbox

Serves JSON indices of your favorite public Dropbox folders.
Ruby
1
star
57

resourcery

It's resource sorcery! Or something.
Ruby
1
star
58

imaginary

Client gem for Imaginary.
Ruby
1
star
59

happy-cli

Command line tool for the Happy web application toolkit.
Ruby
1
star
60

xml-muncher

TypeScript
1
star
61

Godot4-Node-Performance

GDScript
1
star
62

twotter

TWOTTER 🦆 - a little playground app for my Ruby on Rails trainings.
Ruby
1
star
63

glowlayer

Experimental Glow Layer for Three.js
JavaScript
1
star
64

compass-naked

An experimental Rack-only app I'm using to find the easiest way to integrate Compass with Tilt.
Ruby
1
star
65

trinity-examples

A collection of examples for (and experiments with) the Trinity framework.
JavaScript
1
star
66

schnitzel-rails-template

The Team Schnitzel Rails application template. \o/
Ruby
1
star
67

schnitzelpress-org

The source code for schnitzelpress.org.
Ruby
1
star
68

splodybox

A VFX/R3F demo
JavaScript
1
star
69

spacerage

TypeScript
1
star
70

schnitzelstyle

A tiny, light-weight, hopefully sane CSS framework with a Schnitzel flavor.
Ruby
1
star
71

hmans_net

My personal weblog, powered by SchnitzelPress (www.schnitzelpress.org)
Ruby
1
star
72

three-increments

TypeScript
1
star
73

fun-with-kittehs-presentation

Fun With Kittehs. Yeah.
1
star
74

learn-bevy-cube-of-cubes

Rust
1
star