demo repository to show selfhosting of spline 3D scene (exports)
Two approaches used:
Demo:
npm install
npm run dev
Spline offers several ways to export code, see: Exporting as Code . There is also a Web Component available: spline-viewer.
First, we scaffold a new vite project with vanillajs:
# https://vitejs.dev/guide/#scaffolding-your-first-vite-project
npm create vite@latest . -- --template vanilla
# https://www.npmjs.com/package/@splinetool/runtime
npm install @splinetool/runtime
Use "Download bundled zip (Web content)" here:
Unzip it and place the scene.splinecode
file into public/3d-models
.
<canvas>
to index.html, add spline JS code to main.jsInstead of loading the scene from the spline server, we use the local file:
spline.load('/3d-models/planet/scene.splinecode');
# https://www.npmjs.com/package/@splinetool/viewer
npm install @splinetool/viewer
// import spline-viewer web component
import { SplineViewer } from '@splinetool/viewer';
<spline-viewer width="500" height="500" url="/3d-models/planet/scene.splinecode"></spline-viewer>