You can now publish to VIVERSE from Unity, Godot, ThreeJS and more!
VIVERSE Documentation
LogoLogo
VIVERSESupportBlogDiscord
  • Publishing to VIVERSE
  • Polygon Streaming
  • Developer Tools
  • Introduction to Creator Tools
  • VIVERSE Studio
  • Optimizing for the Web
  • Publishing From Templates
    • Creating From Templates
    • Edit Mode
    • Supported Media & Settings
  • Standalone Publishing
    • Installing the CLI
  • Publishing to VIVERSE with the CLI
  • Unity WebGL Example
  • ThreeJS Example
  • Godot HTML5 Example
  • PlayCanvas SDK
    • PlayCanvas Extension Setup
    • Publishing to VIVERSE
    • Scene Settings
    • No Code Tools
      • Sample Project
      • Quests
      • Trigger & Action
        • Event Listeners
        • Entity Enabling & Disabling
        • Entity Collision Enabling & Disabling
        • Entity Physics
        • Avatar Teleport & Checkpoint
        • Animation & Sound
        • Asset Management
      • Media
        • Polygon Streaming
        • Images
        • Video
        • Audio
      • Pick and Throw
      • Networked
      • Seat
      • GPU Mesh Instancing
    • Custom Code
      • Connecting No-Code Events to Custom Scripts
      • Introduction to MJS
      • Camera Management: Settings and Switching
      • Custom Loading Screens
      • Change Avatars Programatically
    • Examples
      • Create Your First PlayCanvas Project
      • SHADEART | Custom Shader
      • WITHIN | A Generative Audiovisual Maze
      • First Person Shooter with Destruction
      • Pet Rescue Template Project
Powered by GitBook
LogoLogo

Important Links

  • COOKIE POLICY
  • TERMS OF SERVICE
  • PRIVACY POLICY
  • VIVERSE PARTNERS

Socials

  • X / Twitter
  • LinkedIn
  • Instagram

© 2025 HTC CORPORATION

On this page
  • Introduction
  • A. Installing Node.js
  • Download Node.js
  • Automatically install the necessary tools
  • Confirm Node.js is installed with at least v22
  • B. Installing Three.js and making an example project
  • Create project folder
  • Create the index.html
  • Create the main.js
  • Install Three.js framework
  • Confirm Three.js framework is installed
  • C. Installing Vite and using it to build your project
  • Install the build tool Vite
  • Confirm Vite has been installed
  • Add the Vite build settings
  • Add the vite.config.js file
  • Create a development build of the Three.js project
  • Test development build
  • Create production build
  • D. Installing the VIVERSE CLI
  • Install the VIVERSE (CLI) command-line tool
  • E. Logging in with the VIVERSE CLI
  • Login to VIVERSE platform
  • F. Publishing from VIVERSE
  • Publish content
  • Re-publishing content
  • Test project

Was this helpful?

Edit on GitHub
Export as PDF

ThreeJS Example

This document provides a guide for creating a sample app in Three.js, building the app with Vite and deploying the app to VIVERSE.

PreviousUnity WebGL ExampleNextGodot HTML5 Example

Last updated 2 days ago

Was this helpful?


Introduction

In this getting-started guide, we will cover the basics of setting up a ThreeJS project and publishing to VIVERSE using .

A. Installing Node.js

1

Download Node.js

A. Download the latest version of Node.js (LTS) from http .

2

Automatically install the necessary tools

A. Use the defaults during the installation, but place a checkmark in the Automatically install the necessary tools checkbox

3

Confirm Node.js is installed with at least v22

A. Open a command prompt and type: node, then click Enter.

B. Confirm that Node.js is installed when the following message prints in command prompt: Welcome to Node.js v##.##.##.

B. Installing Three.js and making an example project

This guide is a walkthrough for creating an example Three.js project

1

Create project folder

A. Create a new folder that will contain the project.

2

Create the index.html

A. Create the index.html page inside the project folder. This can be done by creating a text file, pasting the code and saving it as a .HTML page or using an IDE, such as Visual Studio Code.

index.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>My first three.js app</title>
    <style>
      body { margin: 0; }
    </style>
  </head>
  <body>
    <script type="module" src="/main.js"></script>
  </body>
</html>
3

Create the main.js

A. Create the main.js page inside the project folder. This can be done by creating a text file, pasting the code and saving it as a .JS file or using an IDE, such as Visual Studio Code.

main.js

import * as THREE from 'three';

const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

const renderer = new THREE.WebGLRenderer();
renderer.setSize( window.innerWidth, window.innerHeight );
renderer.setAnimationLoop( animate );
document.body.appendChild( renderer.domElement );

const geometry = new THREE.BoxGeometry( 1, 1, 1 );
const material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } );
const cube = new THREE.Mesh( geometry, material );
scene.add( cube );

camera.position.z = 5;

function animate() {

  cube.rotation.x += 0.01;
  cube.rotation.y += 0.01;

  renderer.render( scene, camera );

}
4

Install Three.js framework

A. Three.js needs to be installed in the project folder. Open command prompt and change directories to your Three.js project.

B. Type: npm install --save three.

5

Confirm Three.js framework is installed

A. Confirm node_modules folder and package.json have been added to the directory.

B. Confirm the three folder folder and .package-lock.json have been added to the node_modules directory.

C. Installing Vite and using it to build your project

1

Install the build tool Vite

A. If choosing to use Vite as the build tool, it needs to be installed in the Three.js project folder also. With command prompt opened and the directory set to your Three.js project, type the command: npm install --save-dev vite.

2

Confirm Vite has been installed

A. Confirm Vite has been installed by checking for additional folders in the node_modules folder.

3

Add the Vite build settings

A. Add the Vite build settings to package.json file.

package.json

{
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  },
  "dependencies": {
    "three": "^0.175.0"
  },
  "devDependencies": {
    "vite": "^6.3.2"
  }
}
4

Add the vite.config.js file

A. Add the vite.config.js file to the root of the project.

vite.config.js

import { defineConfig } from 'vite';
import path from 'path';

// https://vite.dev/config/
export default defineConfig({
  base: './', // Use relative path as base URL
});
 
5

Create a development build of the Three.js project

A. To create a development build of the Three.js project, type the following command inside command prompt under the Three.js project directory: npx vite.

B. Confirm the development build of the Three.js project was built successfully when Vite provides a localhost URL to test.

6

Test development build

A. To test a development build of the Three.js project, open the browser and navigate to the URL that was printed in the previous step. In this example, the URL is . Confirm the app works as expected.

7

Create production build

A. To create a production build of the Three.js project, type the following command inside command prompt under the Three.js project directory: npx vite build.

B. Confirm the production build of the Three.js project was built successfully by confirming the dist folder was created and populated.

D. Installing the VIVERSE CLI

1

Install the VIVERSE (CLI) command-line tool

A. Inside a command prompt, type: npm install -g @viverse/cli, then click Enter. Installing a package with -g installs the package globally. The location of globally installed packages depends on your operating system and npm configuration:

  • Windows : In windows, packages are installed in %APPDATA%\npm\node_modules.

  • macOS and Linux : In mac or Linux packages are typically installed in /usr/local/lib/node_modules or a user-specific directory like ~/.npm-global.

B. Confirm that the command line tool is installed based on screen feedback.

E. Logging in with the VIVERSE CLI

1

Login to VIVERSE platform

A. Open a command prompt and type: viverse-cli auth login, then click Enter.

B. Enter VIVERSE email and password.

C. Confirm login was successful.

F. Publishing from VIVERSE

1

Publish content

A. To publish content to VIVERSE type the following command with the project path to the project's production build folder: viverse-cli publish <path>, then click Enter.

B. Enter an Application title and Application description.

C. Confirm the content was published successfully.

2

Re-publishing content

A. To re-publish content to VIVERSE when a project is already published, type the following command with the project path to the project's production build folder: viverse-cli publish <path>, then click Enter.

B. Confirm the manifest file is updated.

C. Confirm the content was published successfully.

3

Test project

A. Confirm project was published successfully and working properly in VIVERSE by visiting the URL that is printed in the Publish Details.

the VIVERSE CLI
https://nodejs.org/en
http://localhost:5173

For this guide, we are using the VIVERSE CLI, but it is also possible to compress and .

upload your build file directly to the VIVERSE Studio