Start from the template
The Three.js starter includes index.html, game.js, the SDK, local Three.js modules and an optional achievement pilot. It runs from any static server:
npx http-server .Bundle your own project
Build your project with your usual tool (Vite, esbuild, webpack). With Vite, set a relative base so the build works from the hosted path:
export default {
base: "./",
};Include peerless-sdk.js beside index.html and load it before your game script:
<script src="./peerless-sdk.js"></script>
<script type="module" src="./game.js"></script>Connect to PEERLESS
try {
const context = await Peerless.init();
if (context.mode === "peerless") {
showPlayerName(context.player.playerName);
}
startGame();
await Peerless.analytics.gameplayReady().catch(() => {});
} catch (error) {
showLaunchError(error.message);
}gameplayReady() tells PEERLESS that assets are loaded and the controls work. Call it once, after your first playable frame.
Assets and loaders
Relative imports resolved by your bundler already work. For URLs built at runtime, resolve them through Peerless.asset() in your central loader:
loader.load(Peerless.asset("/assets/models/player.glb"), onLoad);Upload settings
Choose Three.js in Builds & releases, set the entrypoint (usually index.html) and declare any external origins. Enable Multiplayer only when the build uses relay rooms or another multiplayer path.