Getting Started
Quick Start
Copy and paste code below in an index.html file or remix in the Web Playground
<style> body {margin: 0;} </style>
<script type="importmap">
{
"imports": {
"three": "https://cdnjs.cloudflare.com/ajax/libs/three.js/0.180.0/three.module.js",
"@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>
Install with NPM
Develop and contribute to Spark
Build Spark (It requires Rust installed in your machine)
This will run a Web server at http://localhost:8080/ with the examples.
Table of Contents
- New Features in 2.0
- 0.1 → 2.0 Migration Guide
- Spark Level-of-Detail
- Spark Overview
- System Design
- SparkRenderer
- SplatMesh
- PackedSplats
- ExtSplats
- Loading Gsplats
- Procedural Splats
- Splat RGBA-XYZ SDF editing
- Dyno overview
- Dyno standard library
- Level-of-Detail Deep Dive
- Controls
- Performance tuning
- Community Resources