Skip to content

salazarr-js/three-app

Repository files navigation

Three App logo

Three App

ThreeJs but functional and declarative.

Warning

This project/package is a Work In Progress and was created for learning purposes. Do not use in production.

🚀 Features

ThreeApp is simply a set of functions and helpers designed to speed up your ThreeJs development

  • 🍦 Vanilla and framework agnostic
  • 🔑 Type Safe
  • ⚡ Batteries included (Default Camera and Renderer, render loop and common event handling)
  • 📦 Lightweight
  • 🔌 ESM & CommonJs compatible

🚨 Limitations

The way all hooks were written limit the amount of instances that can be created to one by page.

⭐ Heavily inspired on

📚 References

Tutorials

Library/NPM Package

Github Projects

Logo

Oscar Reutersvärd

The Three App logo design was heavily inspired by Oscar Reutersvärd work.


🧰 Setup

Install NodeJs LTS version using fnm (RECOMMENDED)

fnm use --resolve-engines --install-if-missing

Scripts

npm run dev      # Start `core` and `docs` packages dev server
npm run dev:core # Start `core` package dev server
npm run dev:docs # Start `docs` package dev server
npm run publish  # Build and publish to npm core package

🛸 Getting Started

Installation

npm install three @slzr/three-app
npm install -D @types/three

Add the container element to your markup

<div id="three-app"></div>

Basic Usage

import { createThreeApp } from '@slzr/three-app'
import { BoxGeometry, Mesh, MeshBasicMaterial } from 'three'

// It can be composed into `components`
const geometry = new BoxGeometry(1, 1, 1)
const material = new MeshBasicMaterial({ color: 0x00FF00 })
const cube = new Mesh(geometry, material)

const app = await createThreeApp({
  container: '#container',
  onInit({ scene }) {
    scene.add(cube)
  },
  onRender({ time, }) {
    cube.rotation.x += 0.01
    cube.rotation.y += 0.01
  }
})

app.start()

🗃️ Documentation

To learn more about Three App, check the documentation.

Releases

No releases published

Packages

No packages published