MCPcopy
hub / github.com/sparkjsdev/spark

github.com/sparkjsdev/spark @v2.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v2.1.0 ↗
1,724 symbols 3,082 edges 88 files 18 documented · 1%
README

Spark logo Spark logo

An advanced 3D Gaussian Splatting renderer for THREE.js

Features - Getting Started - Documentation - FAQ

License npm version

Built by World Labs.

Features

  • Integrates with THREE.js rendering pipeline to fuse splat and mesh-based objects
  • Portable: Works across almost all devices, targeting 98%+ WebGL2 support
  • Renders fast even on low-powered mobile devices
  • Render multiple splat objects together with correct sorting
  • Most major splat file formats supported including: .PLY (also compressed), .SPZ, .SPLAT, .KSPLAT, .SOG
  • Render multiple viewpoints simultaneously
  • Fully dynamic: each splat can be transformed and edited for animation
  • Real-time splat color editing, displacement, and skeletal animation
  • Shader graph system to dynamically create/edit splats on the GPU

Check out all the examples

Getting Started

Copy Code

Copy the following code into an index.html file.

<style> body {margin: 0;} </style>
<script type="importmap">
  {
    "imports": {
      "three": "https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js",
      "three/addons/": "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.180.0/examples/jsm/",
      "@sparkjsdev/spark": "https://sparkjs.dev/releases/spark/2.0.0/spark.module.js"
    }
  }
</script>
<script type="module">
  import * as THREE from "three";
  import { SparkRenderer, SplatMesh } from "@sparkjsdev/spark";

  const scene = new THREE.Scene();
  const camera = new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.01, 1000);
  const renderer = new THREE.WebGLRenderer();
  renderer.setSize(window.innerWidth, window.innerHeight);
  document.body.appendChild(renderer.domElement)

  const spark = new SparkRenderer({ renderer });
  scene.add(spark);

  const splatURL = "https://sparkjs.dev/assets/splats/butterfly.spz";
  const butterfly = new SplatMesh({ url: splatURL });
  butterfly.quaternion.set(1, 0, 0, 0);
  butterfly.position.set(0, 0, -3);
  scene.add(butterfly);

  renderer.setAnimationLoop(function animate(time) {
    renderer.render(scene, camera);
    butterfly.rotation.y += 0.01;
  });
</script>

CDN

<script type="importmap">
  {
    "imports": {
      "three": "https://cdn.jsdelivr.net/npm/three@0.180.0/build/three.module.js",
      "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.180.0/examples/jsm/",
      "@sparkjsdev/spark": "https://sparkjs.dev/releases/spark/2.0.0/spark.module.js"
     }
  }
</script>

NPM

npm install @sparkjsdev/spark

Run Examples locally

Install Rust if it's not already installed in your machine.

Next, build Spark by running:

npm install
npm run build

This will first build the Rust Wasm component (can be invoked via npm run build:wasm), then Spark itself (npm run build).

The examples fetch assets from a remote URL. This step is optional, but offline development and faster loading times are possible if you download and cache the assets files locally with the following command:

npm run assets:download

Once you've built Spark and optionally downloaded the assets, you can now run the examples:

npm start

This will run a dev server by default at http://localhost:8080/. Check the console log output to see if yours is served on a different port.

Develop and contribute to the project

Build troubleshooting

First try cleaning all the build files and re-building everything:

npm run clean
npm install
npm run build

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:

 npm run assets:clean
 npm run assets:download

Ignore dist directory during development

To ignore the dist directory and prevent accidental commits and merge conflicts

git update-index --assume-unchanged dist/*

To revert and be able to commit into to the dist directory again:

git update-index --no-assume-unchanged dist/*

To list ignored files in case of need to troubleshoot

git ls-files -v | grep '^[a-z]' | cut -c3-

Build docs and site

Install Mkdocs Material

pip install mkdocs-material

If you hit an externally managed environment error on macOS and if you installed python via brew try:

brew install mkdocs-material

Edit markdown in /docs directory

npm run docs

Build Spark website

Build the static site and docs in a site directory.

npm run site:build

You can run any static server in the site directory but for convenience you can run

npm run site:serve

Deploy Spark website

The following command will generate a static site from the docs directory and push it to the repo that hosts the site via gh-pages

npm run site:deploy

Compress splats

To compress a splat to spz run

npm run assets:compress <file or URL to ply>

Extension points exported contracts — how you extend this code

SplatSource (Interface)
(no doc) [8 implementers]
src/SplatMesh.ts
HasDynoOut (Interface)
(no doc) [33 implementers]
src/dyno/value.ts
SparkRendererOptions (Interface)
(no doc)
src/SparkRenderer.ts
SparkXrOptions (Interface)
(no doc)
src/SparkXr.ts
FrameUpdateContext (Interface)
(no doc)
src/SplatGenerator.ts
PortalPair (Interface)
(no doc)
src/SparkPortals.ts
PagedSplatsOptions (Interface)
(no doc)
src/SplatPager.ts
SparkXrButton (Interface)
(no doc)
src/SparkXr.ts

Core symbols most depended-on inside this repo

dispose
called by 58
src/SplatMesh.ts
result
called by 52
src/dyno/mathTypes.ts
dynoConst
called by 34
src/dyno/value.ts
numberAsFloat
called by 32
src/dyno/types.ts
unindentLines
called by 31
src/dyno/base.ts
getTextureSize
called by 30
src/utils.ts
valType
called by 30
src/dyno/value.ts
error
called by 28
src/dyno/mathTypes.ts

Shape

Method 638
Function 557
Class 510
Interface 11
Enum 8

Languages

TypeScript100%

Modules by API surface

src/dyno/uniforms.ts177 symbols
src/dyno/math.ts124 symbols
src/dyno/convert.ts123 symbols
src/utils.ts80 symbols
src/dyno/vecmat.ts80 symbols
src/dyno/splats.ts74 symbols
src/dyno/util.ts70 symbols
src/dyno/logic.ts68 symbols
src/dyno/trig.ts60 symbols
src/SparkXr.ts46 symbols
src/SplatMesh.ts41 symbols
src/SplatPager.ts37 symbols

Dependencies from manifests, versioned

@biomejs/biome1.9.4 · 1×
@types/three0.180.0 · 1×
fflate0.8.2 · 1×
lefthook1.11.12 · 1×
lil-gui0.20.0 · 1×
onchange7.1.0 · 1×
spark-rsfile:rust/spark-rs/p · 1×
spark-worker-rsfile:rust/spark-work · 1×
stats.js0.17.0 · 1×
three0.180.0 · 1×
ts-node10.9.2 · 1×
typescript5.7.3 · 1×

For agents

$ claude mcp add spark \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact