[name]

The goal of this article is to give a brief introduction to creating custom Verge3D applications using JavaScript. We will start by creating a new app with a spinning cube.

Before we start

Before you can use Verge3D, you need to create a new app using Verge3D App Manager.
Select Custom App option on Create new App panel and click Create App button.
The App Manager create the following HTML file:
<!DOCTYPE html> <html lang="en"> <head> <title>Verge3D Application</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <link rel="stylesheet" type="text/css" href="my_awesome_app.css"> </head> <body> <div id="container"></div> <script src="v3d.js"></script> <script src="my_awesome_app.js"></script> <script src="visual_logic.js"></script> </body> </html>
That's all. All the code below goes into the my_awesome_app.js script.

Creating the app

To actually be able to display anything with Verge3D, we need to do three things: create a new App, load your glTF scene and enable basic controls:
'use strict'; window.addEventListener('load', function() { var app = new v3d.App('container', null, new v3d.SimplePreloader({ container: 'container' })); var url = 'template.gltf'; app.load(url, function() { app.enableControls(); runCode(); }); function runCode() { // add you code here, e.g. console.log('Hello, World!'); } });
You can extend the functionality of your first app in one of the following ways: edit your scene, use Verge3D Puzzles tool or create custom logic with JavaScript.