|
| 1 | +<p align="center"> |
| 2 | + <picture> |
| 3 | + <img alt="Forge" src="https://github.com/user-attachments/assets/adb2f0d7-df30-49e5-be7f-75c14f008735" width="auto" height="180"> |
| 4 | + </picture> |
| 5 | + <br> |
| 6 | + <h3 align="center">An advanced 3D Gaussian Splatting renderer for THREE.js</h3> |
| 7 | + <div align="center"> |
| 8 | + |
| 9 | + [Features](#features) - |
| 10 | + [Getting Started](#getting-started) - |
| 11 | + <a href="https://www.forge.dev/">Documentation</a> - |
| 12 | + <a href="https://www.forge.dev/">FAQ</a> |
| 13 | + </div> |
| 14 | + </p> |
| 15 | + |
| 16 | + <div align="center"> |
| 17 | + |
| 18 | + [](https://github.com/forge-gfx/forge/blob/main/LICENSE) |
| 19 | + [](https://www.npmjs.com/package/forge) |
| 20 | + |
| 21 | + </div> |
| 22 | + |
| 23 | +<p> |
| 24 | + <a href="https://www.forge.dev" target="_blank"> |
| 25 | + <picture> |
| 26 | + </picture> |
| 27 | + </a> |
| 28 | + |
| 29 | +## Features |
| 30 | + |
| 31 | +- Load multiple splats files simultaneously ([demo]()) |
| 32 | +- Combine and composite splats with regular Meshes ([demo]()) |
| 33 | +- Animation ([demo]()) |
| 34 | +- Real Time Visual Effects ([demo]()) |
| 35 | +- Multiple Camera Views ([demo]()) |
| 36 | +- Procedurally generated splats ([demo]()) |
| 37 | + |
| 38 | +Check out all the [examples]() |
| 39 | + |
| 40 | +## Getting Started |
| 41 | + |
| 42 | +### Copy code |
| 43 | + |
| 44 | +Copy code below in an `index.html` file. |
| 45 | + |
| 46 | +```html |
| 47 | +<style> body {margin: 0;} </style> |
| 48 | +<script type="importmap"> |
| 49 | +{ |
| 50 | + "imports": { |
| 51 | + "three": "/node_modules/three/build/three.module.js", |
| 52 | + "@forge/forge": "/dist/forge.module.js" |
| 53 | + } |
| 54 | +} |
| 55 | +</script> |
| 56 | +<script type="module"> |
| 57 | +import * as THREE from "three"; |
| 58 | +import { SplatMesh } from "@forge/forge"; |
| 59 | +
|
| 60 | +const scene = new THREE.Scene(); |
| 61 | +const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); |
| 62 | +const renderer = new THREE.WebGLRenderer(); |
| 63 | +renderer.setSize(window.innerWidth, window.innerHeight); |
| 64 | +document.body.appendChild(renderer.domElement) |
| 65 | +
|
| 66 | +const butterfly = new SplatMesh({ url: "../assets/basic/butterfly.wlg"}); |
| 67 | +butterfly.quaternion.set(1, 0, 0, 0); |
| 68 | +butterfly.position.set(0, 0, -1); |
| 69 | +scene.add(butterfly); |
| 70 | +
|
| 71 | +renderer.setAnimationLoop(function animate(time) { |
| 72 | + renderer.render(scene, camera); |
| 73 | + butterfly.rotation.y += 0.01; |
| 74 | +}); |
| 75 | +</script> |
| 76 | +``` |
| 77 | + |
| 78 | +### Web Editor |
| 79 | + |
| 80 | +Remix the [glitch starter template](https://glitch.com/edit/#!/forge-dev) |
| 81 | + |
| 82 | +### Usage from CDN |
| 83 | + |
| 84 | +```html |
| 85 | +<script type="importmap"> |
| 86 | + { |
| 87 | + "imports": { |
| 88 | + "three": "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.174.0/three.module.js", |
| 89 | + "forge": "cdn/url/to/forge.module.js" |
| 90 | + } |
| 91 | + } |
| 92 | +</script> |
| 93 | +``` |
| 94 | + |
| 95 | +### Install with NPM |
| 96 | + |
| 97 | +```shell |
| 98 | +npm install forge-dev |
| 99 | +``` |
| 100 | + |
| 101 | +## Develop and contribute to the project |
| 102 | + |
| 103 | +The examples fetch the assets from an external URL. To work offline is possible to downloading the assets files locally with the following command: |
| 104 | + |
| 105 | +``` |
| 106 | +npm run assets:download |
| 107 | +``` |
| 108 | + |
| 109 | +Install [Rust](https://www.rust-lang.org/tools/install) if it's not already installed in your machine. |
| 110 | + |
| 111 | +Next, build Forge by running: |
| 112 | +``` |
| 113 | +npm install |
| 114 | +npm run build |
| 115 | +``` |
| 116 | +This will first build the Rust Wasm component (can be invoked via `npm run build:wasm`), then Forge itself (`npm run build`). |
| 117 | + |
| 118 | +Once you've fetched the data and built Forge, you can run run the examples: |
| 119 | +``` |
| 120 | +npm run dev |
| 121 | +``` |
| 122 | +This will run a dev server by default at [http://localhost:8080/](http://localhost:8080/). Check the console log output to see if yours is served on a different port. |
| 123 | + |
| 124 | +## Build troubleshooting |
| 125 | + |
| 126 | +First try cleaning all the build files and re-building everything: |
| 127 | +``` |
| 128 | +npm run clean |
| 129 | +npm install |
| 130 | +npm run build |
| 131 | +``` |
| 132 | + |
| 133 | +There's no versioning system for assets. If you need to re-download a specific file you can delete that asset file individually or download all assets from scratch: |
| 134 | + |
| 135 | +``` |
| 136 | + npm run assets:clean |
| 137 | + npm run assets:download |
| 138 | +``` |
| 139 | + |
| 140 | +## Ignore dist directory during development |
| 141 | + |
| 142 | +To ignore the dist directory and prevent accidental commits and merge conflicts |
| 143 | + |
| 144 | +``` |
| 145 | +git update-index --assume-unchanged dist/* |
| 146 | +``` |
| 147 | + |
| 148 | +To revert and be able to commit into to the dist directory again: |
| 149 | + |
| 150 | +``` |
| 151 | +git update-index --no-assume-unchanged dist/* |
| 152 | +``` |
| 153 | + |
| 154 | +To liste ignored files in case of need to troubleshoot |
| 155 | + |
| 156 | +``` |
| 157 | +git ls-files -v | grep '^[a-z]' | cut -c3- |
| 158 | +``` |
| 159 | + |
| 160 | +## Build docs |
| 161 | + |
| 162 | +Install [Mkdocs Material](https://squidfunk.github.io/mkdocs-material/) |
| 163 | + |
| 164 | +``` |
| 165 | +pip install mkdocs-material |
| 166 | +``` |
| 167 | + |
| 168 | +If you hit an `externally managed environment` error on macOS and if you installed python via `brew` try: |
| 169 | + |
| 170 | +``` |
| 171 | +brew install mkdocs-material |
| 172 | +``` |
| 173 | + |
| 174 | +Edit markdown in `/docs` directory |
| 175 | + |
| 176 | +``` |
| 177 | +mkdocs serve |
| 178 | +``` |
| 179 | + |
| 180 | +## Build Forge website |
| 181 | + |
| 182 | +Build the static site and docs in a `site` directory. |
| 183 | + |
| 184 | +``` |
| 185 | +npm run site:build |
| 186 | +``` |
| 187 | + |
| 188 | +You can run any static server in the `site` directory but for convenience you can run |
| 189 | + |
| 190 | +``` |
| 191 | +npm run site:serve |
| 192 | +``` |
| 193 | + |
| 194 | +## Deploy Forge website |
| 195 | + |
| 196 | +TO-DO |
0 commit comments